*/
protected function getTypeObject($type) {
if (!isset($this->typeObjects[$type])) {
- $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($type).'UserGroupOptionType';
+ $className = 'wcf\system\option\user\group\\'.StringUtil::firstCharToUpperCase($type).'UserGroupOptionType';
// create instance
if (!class_exists($className)) {
throw new SystemException("unable to find class '".$className."'");
}
- if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\userGroup\IUserGroupOptionType')) {
- throw new SystemException("'".$className."' should implement wcf\system\option\userGroup\IUserGroupOptionType");
+ if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\user\group\IUserGroupOptionType')) {
+ throw new SystemException("'".$className."' should implement wcf\system\option\user\group\IUserGroupOptionType");
}
$this->typeObjects[$type] = new $className();
}
* Returns an object of the requested group option type.
*
* @param string $type
- * @return wcf\system\option\userGroup\IUserGroupOptionType
+ * @return wcf\system\option\user\group\IUserGroupOptionType
*/
protected function getTypeObject($type) {
if (!isset($this->typeObjects[$type])) {
- $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($type).'UserGroupOptionType';
+ $className = 'wcf\system\option\user\group\\'.StringUtil::firstCharToUpperCase($type).'UserGroupOptionType';
// validate class
if (!class_exists($className)) {
throw new SystemException("unable to find class '".$className."'");
}
- if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\userGroup\IUserGroupOptionType')) {
- throw new SystemException("'".$className."' should implement wcf\system\option\userGroup\IUserGroupOptionType");
+ if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\user\group\IUserGroupOptionType')) {
+ throw new SystemException("'".$className."' should implement wcf\system\option\user\group\IUserGroupOptionType");
}
// create instance
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\BooleanOptionType;
+
+/**
+ * BooleanUserGroupOptionType is an implementation of IUserGroupOptionType for boolean values.
+ * The merge of option values returns true, if at least one value is true. Otherwise false.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class BooleanUserGroupOptionType extends BooleanOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ foreach ($values as $value) {
+ if ($value) return true;
+ }
+
+ return false;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\IOptionType;
+
+/**
+ * Any group permission type should implement this interface.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+interface IUserGroupOptionType extends IOptionType {
+ /**
+ * Merges the different values of an option to a single value.
+ *
+ * @param array $values
+ * @return mixed
+ */
+ public function merge(array $values);
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+
+/**
+ * InfiniteIntegerUserGroupOptionType is an implementation of IUserGroupOptionType
+ * for integer values with the infinite option.
+ * The merge of option values returns true, if at least one value is -1. Otherwise
+ * it returns the highest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class InfiniteIntegerUserGroupOptionType extends IntegerUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ if (in_array(-1, $values)) return -1;
+ return parent::merge($values);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+
+/**
+ * InfiniteInverseIntegerUserGroupOptionType is an implementation of IUserGroupOptionType
+ * for integer values.
+ * The merge of option values returns -1 if all values are -1 otherwise the lowest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class InfiniteInverseIntegerUserGroupOptionType extends InverseIntegerUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ foreach ($values as $key => $value) {
+ if ($value == -1) unset($values[$key]);
+ }
+
+ if (count($values) == 0) return -1;
+ return min($values);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\IntegerOptionType;
+
+/**
+ * IntegerUserGroupOptionType is an implementation of IUserGroupOptionType for integer values.
+ * The merge of option values returns the highest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class IntegerUserGroupOptionType extends IntegerOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user.group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ return max($values);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\IntegerOptionType;
+
+/**
+ * InverseIntegerUserGroupOptionType is an implementation of IUserGroupOptionType for integer values.
+ * The merge of option values returns the lowest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class InverseIntegerUserGroupOptionType extends IntegerOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ return min($values);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\TextOptionType;
+
+/**
+ * TextUserGroupOptionType is an implementation of IUserGroupOptionType for text values.
+ * The merge of option values returns merge of all text values.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class TextUserGroupOptionType extends TextOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ $result = '';
+
+ foreach ($values as $value) {
+ if (!empty($result)) $result .= "\n";
+ $result .= $value;
+ }
+
+ return $result;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\TextareaOptionType;
+
+/**
+ * TextareaUserGroupOptionType is an implementation of IUserGroupOptionType for
+ * text values.
+ * The merge of option values returns merge of all text values.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class TextareaUserGroupOptionType extends TextareaOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ $result = '';
+
+ foreach ($values as $value) {
+ if (!empty($result)) $result .= "\n";
+ $result .= $value;
+ }
+
+ return $result;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\Group;
+use wcf\data\option\Option;
+use wcf\data\user\group\UserGroup;
+use wcf\system\option\AbstractOptionType;
+use wcf\util\ArrayUtil;
+use wcf\util\StringUtil;
+
+/**
+ * UserGroupsUserGroupOptionType generates a select-list of all available user groups.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class UserGroupsUserGroupOptionType extends AbstractOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\IOptionType::getFormElement()
+ */
+ public function getFormElement(Option $option, $value) {
+ // get selected group
+ $selectedGroups = explode(',', $value);
+
+ // get all groups
+ $groups = UserGroup::getGroupsByType();
+
+ // generate html
+ $html = '';
+ foreach ($groups as $group) {
+ $html .= '<label><input type="checkbox" name="values['.StringUtil::encodeHTML($option->optionName).'][]" value="'.$group->groupID.'" '.(in_array($group->groupID, $selectedGroups) ? 'checked="checked" ' : '').'/> '.StringUtil::encodeHTML($group->groupName).'</label>';
+ }
+
+ return $html;
+ }
+
+ /**
+ * @see wcf\system\option\IOptionType::validate()
+ */
+ public function validate(Option $option, $newValue) {
+ // get all groups
+ $groups = UserGroup::getGroupsByType();
+
+ // get new value
+ if (!is_array($newValue)) $newValue = array();
+ $selectedGroups = ArrayUtil::toIntegerArray($newValue);
+
+ // check groups
+ foreach ($selectedGroups as $groupID) {
+ if (!isset($groups[$groupID])) {
+ throw new UserInputException($option->optionName, 'validationFailed');
+ }
+ }
+ }
+
+ /**
+ * @see wcf\system\option\IOptionType::getData()
+ */
+ public function getData(Option $option, $newValue) {
+ if (!is_array($newValue)) $newValue = array();
+ $newValue = ArrayUtil::toIntegerArray($newValue);
+ sort($newValue, SORT_NUMERIC);
+ return implode(',', $newValue);
+ }
+
+ /**
+ * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ $result = array();
+ foreach ($values as $value) {
+ $value = explode(',', $value);
+ $result = array_merge($result, $value);
+ }
+
+ $result = array_unique($result);
+
+ return implode(',', $result);
+ }
+}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\system\option\BooleanOptionType;
-
-/**
- * BooleanUserGroupOptionType is an implementation of IUserGroupOptionType for boolean values.
- * The merge of option values returns true, if at least one value is true. Otherwise false.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class BooleanUserGroupOptionType extends BooleanOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- foreach ($values as $value) {
- if ($value) return true;
- }
-
- return false;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\system\option\IOptionType;
-
-/**
- * Any group permission type should implement this interface.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-interface IUserGroupOptionType extends IOptionType {
- /**
- * Merges the different values of an option to a single value.
- *
- * @param array $values
- * @return mixed
- */
- public function merge(array $values);
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-
-/**
- * InfiniteIntegerUserGroupOptionType is an implementation of IUserGroupOptionType
- * for integer values with the infinite option.
- * The merge of option values returns true, if at least one value is -1. Otherwise
- * it returns the highest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class InfiniteIntegerUserGroupOptionType extends IntegerUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- if (in_array(-1, $values)) return -1;
- return parent::merge($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-
-/**
- * InfiniteInverseIntegerUserGroupOptionType is an implementation of IUserGroupOptionType
- * for integer values.
- * The merge of option values returns -1 if all values are -1 otherwise the lowest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class InfiniteInverseIntegerUserGroupOptionType extends InverseIntegerUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- foreach ($values as $key => $value) {
- if ($value == -1) unset($values[$key]);
- }
-
- if (count($values) == 0) return -1;
- return min($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\system\option\IntegerOptionType;
-
-/**
- * IntegerUserGroupOptionType is an implementation of IUserGroupOptionType for integer values.
- * The merge of option values returns the highest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class IntegerUserGroupOptionType extends IntegerOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- return max($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\system\option\IntegerOptionType;
-
-/**
- * InverseIntegerUserGroupOptionType is an implementation of IUserGroupOptionType for integer values.
- * The merge of option values returns the lowest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class InverseIntegerUserGroupOptionType extends IntegerOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- return min($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\system\option\TextOptionType;
-
-/**
- * TextUserGroupOptionType is an implementation of IUserGroupOptionType for text values.
- * The merge of option values returns merge of all text values.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class TextUserGroupOptionType extends TextOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- $result = '';
-
- foreach ($values as $value) {
- if (!empty($result)) $result .= "\n";
- $result .= $value;
- }
-
- return $result;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\system\option\TextareaOptionType;
-
-/**
- * TextareaUserGroupOptionType is an implementation of IUserGroupOptionType for
- * text values.
- * The merge of option values returns merge of all text values.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class TextareaUserGroupOptionType extends TextareaOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- $result = '';
-
- foreach ($values as $value) {
- if (!empty($result)) $result .= "\n";
- $result .= $value;
- }
-
- return $result;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\userGroup;
-use wcf\data\option\Option;
-use wcf\data\user\group\UserGroup;
-use wcf\system\option\AbstractOptionType;
-use wcf\util\ArrayUtil;
-use wcf\util\StringUtil;
-
-/**
- * UserGroupsUserGroupOptionType generates a select-list of all available user groups.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.option.userGroup
- * @category Community Framework
- */
-class UserGroupsUserGroupOptionType extends AbstractOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\IOptionType::getFormElement()
- */
- public function getFormElement(Option $option, $value) {
- // get selected group
- $selectedGroups = explode(',', $value);
-
- // get all groups
- $groups = UserGroup::getGroupsByType();
-
- // generate html
- $html = '';
- foreach ($groups as $group) {
- $html .= '<label><input type="checkbox" name="values['.StringUtil::encodeHTML($option->optionName).'][]" value="'.$group->groupID.'" '.(in_array($group->groupID, $selectedGroups) ? 'checked="checked" ' : '').'/> '.StringUtil::encodeHTML($group->groupName).'</label>';
- }
-
- return $html;
- }
-
- /**
- * @see wcf\system\option\IOptionType::validate()
- */
- public function validate(Option $option, $newValue) {
- // get all groups
- $groups = UserGroup::getGroupsByType();
-
- // get new value
- if (!is_array($newValue)) $newValue = array();
- $selectedGroups = ArrayUtil::toIntegerArray($newValue);
-
- // check groups
- foreach ($selectedGroups as $groupID) {
- if (!isset($groups[$groupID])) {
- throw new UserInputException($option->optionName, 'validationFailed');
- }
- }
- }
-
- /**
- * @see wcf\system\option\IOptionType::getData()
- */
- public function getData(Option $option, $newValue) {
- if (!is_array($newValue)) $newValue = array();
- $newValue = ArrayUtil::toIntegerArray($newValue);
- sort($newValue, SORT_NUMERIC);
- return implode(',', $newValue);
- }
-
- /**
- * @see wcf\system\option\userGroup\IUserGroupOptionType::merge()
- */
- public function merge(array $values) {
- $result = array();
- foreach ($values as $value) {
- $value = explode(',', $value);
- $result = array_merge($result, $value);
- }
-
- $result = array_unique($result);
-
- return implode(',', $result);
- }
-}
if (isset($option['options'])) $options = $option['options'];
// check if optionType exists
- $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($optionType).'UserGroupOptionType';
+ $className = 'wcf\system\option\user\group\\'.StringUtil::firstCharToUpperCase($optionType).'UserGroupOptionType';
if (!class_exists($className)) {
throw new SystemException("unable to find class '".$className."'");
}