/** * 构造用户组 * * @param string $gid * @return string */ private function _buildGids($gid) { $gidOptions = '<option value="-1" ' . Pw::isSelected($gid == -1) . '>全部用户组</option>'; $gidOptions .= '<option value="0" ' . Pw::isSelected($gid == 0) . '>会员组</option>'; /* @var $groupDs PwUserGroups */ $groupDs = Wekit::load('usergroup.PwUserGroups'); $groups = $groupDs->getClassifiedGroups(); if (!$groups) { return $gidOptions; } $types = $groupDs->getTypeNames(); unset($types['member']); foreach ($types as $_k => $_v) { if (!isset($groups[$_k])) { continue; } $option = '<optgroup label="' . $_v . '">'; foreach ($groups[$_k] as $_item) { $option .= '<option value="' . $_item['gid'] . '" ' . Pw::isSelected($gid == $_item['gid']) . '>' . $_item['name'] . '</option>'; } $gidOptions .= $option; } return $gidOptions; }