<?php
namespace wcf\system\option\user\group;
+use wcf\data\user\group\UserGroup;
use wcf\system\exception\SystemException;
use wcf\system\option\OptionHandler;
use wcf\util\ClassUtil;
* @category Community Framework
*/
class UserGroupOptionHandler extends OptionHandler {
+ /**
+ * user group object
+ * @var wcf\data\user\group\UserGroup
+ */
+ protected $group = null;
+
+ /**
+ * Sets current user group.
+ *
+ * @param wcf\data\user\group\UserGroup $group
+ */
+ public function setUserGroup(UserGroup $group) {
+ $this->group = $group;
+ }
+
/**
* @see wcf\system\option\OptionHandler::getClassName()
*/
return $className;
}
+
+ /**
+ * @see wcf\system\option\IOptionHandler::readData()
+ */
+ public function readData() {
+ $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE);
+ foreach ($this->options as $option) {
+ $this->optionValues[$option->optionName] = $defaultGroup->getGroupOption($option->optionName);
+
+ // use group values over default values
+ if ($this->group !== null) {
+ $groupValue = $this->group->getGroupOption($option->optionName);
+ if ($groupValue !== null) {
+ $this->optionValues[$option->optionName] = $groupValue;
+ }
+ }
+ }
+ }
}
\ No newline at end of file