<dd>
{@$formElements[$group->groupID]}
+ {if $errorType[$group->groupID]|isset}
+ <small class="innerError">
+ {lang}wcf.acp.group.option.error.{$errorType[$group->groupID]}{/lang}
+ </small>
+ {/if}
{hascontent}<small>{content}{lang __optional=true}wcf.acp.group.option.{@$userGroupOption->optionName}.description{/lang}{/content}</small>{/hascontent}
</dd>
</dl>
catch (UserInputException $e) {
$this->errorType[$e->getField()] = $e->getType();
}
+
+ if ($this->optionType->compare($optionValue, WCF::getSession()->getPermission($this->userGroupOption->optionName)) == 1) {
+ $this->errorType[$groupID] = 'exceedsOwnPermission';
+ }
}
// add missing values for option type 'boolean'
/**
* @see \wcf\system\option\IOptionType::compare()
*/
- public function compare() {
+ public function compare($value1, $value2) {
return 0;
}
}
return 0;
}
- return ($value1 === true) ? 1 : -1;
+ return ($value1) ? 1 : -1;
}
}
use wcf\system\exception\SystemException;
use wcf\system\option\OptionHandler;
use wcf\util\ClassUtil;
+use wcf\system\WCF;
+use wcf\system\exception\UserInputException;
+use wcf\data\option\Option;
/**
* Handles user group options.
*/
protected $group = null;
+ /**
+ * true if current user can edit every user group
+ * @var boolean
+ */
+ protected $isAdmin = null;
+
/**
* Sets current user group.
*
}
}
}
+
+ /**
+ * Returns true if current user has the permissions to edit every user group.
+ *
+ * @return boolean
+ */
+ protected function isAdmin() {
+ if ($this->isAdmin === null) {
+ $this->isAdmin = false;
+
+ foreach (WCF::getUser()->getGroupIDs() as $groupID) {
+ if (UserGroup::getGroupByID($groupID)->isAdminGroup()) {
+ $this->isAdmin = true;
+ break;
+ }
+ }
+ }
+
+ return $this->isAdmin;
+ }
+
+ /**
+ * @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');
+ }
+ }
+ }
}
* @see \wcf\system\option\IOptionType::compare()
*/
public function compare($value1, $value2) {
- $value1 = explode(',', $value1);
- $value2 = explode(',', $value2);
+ $value1 = ($value1) ? explode(',', $value1) : array();
+ $value2 = ($value2) ? explode(',', $value2) : array();
// check if value1 contains more elements than value2
$diff = array_diff($value1, $value2);
<item name="wcf.acp.group.option.category.user"><![CDATA[Allgemeine Rechte]]></item>
<item name="wcf.acp.group.option.category.user.message"><![CDATA[Nachrichten]]></item>
<item name="wcf.acp.group.option.category.user.message.comment"><![CDATA[Kommentare]]></item>
+ <item name="wcf.acp.group.option.error.exceedsOwnPermission"><![CDATA[Sie können Benutzergruppen keine Berechtigungen gewähren, die Ihre eigenen Berechtigungen übersteigen.]]></item>
<item name="wcf.acp.group.option.error.tooHigh"><![CDATA[Der angegebene Wert ist zu hoch.{if $option->maxvalue !== null} Der maximale Wert ist {#$option->maxvalue}.{/if}]]></item>
<item name="wcf.acp.group.option.error.tooLow"><![CDATA[Der angegebene Wert ist zu gering.{if $option->minvalue !== null} Der minimale Wert ist {#$option->minvalue}.{/if}]]></item>
<item name="wcf.acp.group.showMembers"><![CDATA[Zeige die Mitglieder dieser Benutzergruppe]]></item>
<item name="wcf.acp.group.option.category.user"><![CDATA[General Permissions]]></item>
<item name="wcf.acp.group.option.category.user.message"><![CDATA[Messages]]></item>
<item name="wcf.acp.group.option.category.user.message.comment"><![CDATA[Comments]]></item>
+ <item name="wcf.acp.group.option.error.exceedsOwnPermission"><![CDATA[You cannot grant user group permissions exceeding your own permissions.]]></item>
<item name="wcf.acp.group.option.error.tooHigh"><![CDATA[The given value is too high.{if $option->maxvalue !== null} The maximum value is {#$option->maxvalue}.{/if}]]></item>
<item name="wcf.acp.group.option.error.tooLow"><![CDATA[The given value is too low.{if $option->minvalue !== null} The minimum value is {#$option->minvalue}.{/if}]]></item>
<item name="wcf.acp.group.showMembers"><![CDATA[Show Members]]></item>