/** * @see \wcf\system\option\OptionHandler::validateOption() */ protected function validateOption(Option $option) { parent::validateOption($option); if (!$this->isAdmin()) { // get type object $typeObj = $this->getTypeObject($option->optionType); if ($typeObj->compare($this->optionValues[$option->optionName], WCF::getSession()->getPermission($option->optionName)) == 1) { throw new UserInputException($option->optionName, 'exceedsOwnPermission'); } } else { if ($option->optionName == 'admin.user.accessibleGroups' && $this->group !== null && $this->group->isAdminGroup()) { $hasOtherAdminGroup = false; foreach (UserGroup::getGroupsByType() as $userGroup) { if ($userGroup->groupID != $this->group->groupID && $userGroup->isAdminGroup()) { $hasOtherAdminGroup = true; break; } } // prevent users from dropping their own admin state if (!$hasOtherAdminGroup) { // get type object $typeObj = $this->getTypeObject($option->optionType); if ($typeObj->compare($this->optionValues[$option->optionName], WCF::getSession()->getPermission($option->optionName)) == -1) { throw new UserInputException($option->optionName, 'cannotDropPrivileges'); } } } } }
/** * Returns a list of group ids by type. * * @return array<array> */ protected function getGroupIDs() { if ($this->groupIDs === null) { $this->groupIDs = array('admin' => array(), 'mod' => array(), 'all' => array(), 'registered' => array()); $sql = "SELECT\tgroupID, groupType\n\t\t\t\tFROM\twcf" . WCF_N . "_user_group"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); while ($row = $statement->fetchArray()) { $group = new UserGroup(null, $row); $this->groupIDs['all'][] = $group->groupID; if ($group->groupType != UserGroup::EVERYONE && $group->groupType != UserGroup::GUESTS) { $this->groupIDs['registered'][] = $group->groupID; if ($group->isModGroup()) { $this->groupIDs['mod'][] = $group->groupID; } if ($group->isAdminGroup()) { $this->groupIDs['admin'][] = $group->groupID; } } } } return $this->groupIDs; }