+++ /dev/null
-<?xml version="1.0"?>
-<!-- The file "option.xsd" is used for xml-files which installs, updates or deletes options. -->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.woltlab.com" targetNamespace="http://www.woltlab.com" elementFormDefault="qualified">
-
- <!-- include types -->
- <xs:include schemaLocation="types.xsd" />
- <!-- include option types -->
- <xs:include schemaLocation="optiontypes.xsd" />
-
- <!-- Represents the data-node. -->
- <xs:element name="data">
- <xs:complexType>
- <xs:all>
- <xs:element name="import" type="import" minOccurs="0" />
- <xs:element name="delete" type="delete" minOccurs="0" />
- </xs:all>
- </xs:complexType>
- </xs:element>
-
- <!-- Represents the import-node. -->
- <xs:complexType name="import">
- <xs:all>
- <xs:element name="categories" type="categories_import" minOccurs="0" />
- <xs:element name="options" type="options_import" minOccurs="0" />
- </xs:all>
- </xs:complexType>
-
- <!-- Represents the import-categories-node. -->
- <xs:complexType name="categories_import">
- <xs:sequence>
- <xs:element name="category" type="category_import" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
-
-
-
- <!-- Represents a category which will be installed or updated. Extends the type "category_delete". -->
- <xs:complexType name="category_import">
- <xs:complexContent>
- <xs:extension base="category_delete">
- <xs:all>
- <xs:element name="parent" type="woltlab_varchar_nullable" minOccurs="0" />
- <xs:element name="showorder" type="xs:unsignedInt" minOccurs="0" />
- <xs:element name="options" type="woltlab_varchar_nullable" minOccurs="0" />
- </xs:all>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
-
- <!-- Represents the import-options-node. -->
- <xs:complexType name="options_import">
- <xs:sequence>
- <xs:element name="option" type="option_import" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
-
-
-
- <!-- Represents an option which will be installed or updated. Extends the type "category_delete". -->
- <xs:complexType name="option_import">
- <xs:complexContent>
- <xs:extension base="option_delete">
- <xs:all>
- <xs:element name="categoryname" type="woltlab_varchar" minOccurs="1" />
- <xs:element name="optiontype" type="woltlab_varchar_nullable" minOccurs="0" />
- <xs:element name="defaultvalue" type="xs:string" minOccurs="0" />
- <xs:element name="validationpattern" type="xs:string" minOccurs="0" />
- <xs:element name="enableoptions" type="xs:string" minOccurs="0" />
- <xs:element name="showorder" type="xs:unsignedInt" minOccurs="0" />
- <xs:element name="options" type="woltlab_varchar_nullable" minOccurs="0" />
- <xs:element name="admindefaultvalue" type="xs:string" minOccurs="0" />
- </xs:all>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-</xs:schema>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<!-- The file "option.xsd" is used for xml-files which installs, updates or deletes options. -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.woltlab.com" targetNamespace="http://www.woltlab.com" elementFormDefault="qualified">
+
+ <!-- include types -->
+ <xs:include schemaLocation="types.xsd" />
+ <!-- include option types -->
+ <xs:include schemaLocation="optiontypes.xsd" />
+
+ <!-- Represents the data-node. -->
+ <xs:element name="data">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="import" type="import" minOccurs="0" />
+ <xs:element name="delete" type="delete" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Represents the import-node. -->
+ <xs:complexType name="import">
+ <xs:all>
+ <xs:element name="categories" type="categories_import" minOccurs="0" />
+ <xs:element name="options" type="options_import" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <!-- Represents the import-categories-node. -->
+ <xs:complexType name="categories_import">
+ <xs:sequence>
+ <xs:element name="category" type="category_import" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+
+
+
+ <!-- Represents a category which will be installed or updated. Extends the type "category_delete". -->
+ <xs:complexType name="category_import">
+ <xs:complexContent>
+ <xs:extension base="category_delete">
+ <xs:all>
+ <xs:element name="parent" type="woltlab_varchar_nullable" minOccurs="0" />
+ <xs:element name="showorder" type="xs:unsignedInt" minOccurs="0" />
+ <xs:element name="options" type="woltlab_varchar_nullable" minOccurs="0" />
+ </xs:all>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+
+ <!-- Represents the import-options-node. -->
+ <xs:complexType name="options_import">
+ <xs:sequence>
+ <xs:element name="option" type="option_import" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+
+
+
+ <!-- Represents an option which will be installed or updated. Extends the type "category_delete". -->
+ <xs:complexType name="option_import">
+ <xs:complexContent>
+ <xs:extension base="option_delete">
+ <xs:all>
+ <xs:element name="categoryname" type="woltlab_varchar" minOccurs="1" />
+ <xs:element name="optiontype" type="woltlab_varchar_nullable" minOccurs="0" />
+ <xs:element name="defaultvalue" type="xs:string" minOccurs="0" />
+ <xs:element name="validationpattern" type="xs:string" minOccurs="0" />
+ <xs:element name="enableoptions" type="xs:string" minOccurs="0" />
+ <xs:element name="showorder" type="xs:unsignedInt" minOccurs="0" />
+ <xs:element name="options" type="woltlab_varchar_nullable" minOccurs="0" />
+ <xs:element name="admindefaultvalue" type="xs:string" minOccurs="0" />
+ </xs:all>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/groupoptions.xsd">
- <import>
- <categories>
- <category name="user"></category>
- <category name="mod"></category>
- <category name="admin"></category>
- <category name="admin.general">
- <parent>admin</parent>
- </category>
- <category name="admin.system">
- <parent>admin</parent>
- </category>
- <category name="admin.system.cronjobs">
- <parent>admin.system</parent>
- </category>
- <category name="admin.system.package">
- <parent>admin.system</parent>
- </category>
- <category name="admin.maintenance">
- <parent>admin.system</parent>
- </category>
- <category name="admin.user">
- <parent>admin</parent>
- </category>
- <category name="admin.user.user">
- <parent>admin.user</parent>
- </category>
- <category name="admin.user.group">
- <parent>admin.user</parent>
- </category>
-
- <category name="admin.display">
- <parent>admin</parent>
- </category>
- <category name="admin.content">
- <parent>admin</parent>
- </category>
- <category name="admin.style">
- <parent>admin.display</parent>
- </category>
- <category name="admin.language">
- <parent>admin.display</parent>
- </category>
- </categories>
-
- <options>
- <option name="admin.general.canViewPrivateUserOptions">
- <categoryname>admin.general</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.canEditOption">
- <categoryname>admin.system</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.canViewLog">
- <categoryname>admin.system</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.cronjobs.canAddCronjob">
- <categoryname>admin.system.cronjobs</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.cronjobs.canEditCronjob">
- <categoryname>admin.system.cronjobs</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.cronjobs.canDeleteCronjob">
- <categoryname>admin.system.cronjobs</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.cronjobs.canEnableDisableCronjob">
- <categoryname>admin.system.cronjobs</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.cronjobs.canDeleteCronjobsLog">
- <categoryname>admin.system.cronjobs</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.package.canUpdatePackage">
- <categoryname>admin.system.package</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.package.canUninstallPackage">
- <categoryname>admin.system.package</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.system.package.canEditServer">
- <categoryname>admin.system.package</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.accessibleGroups">
- <categoryname>admin.user.group</categoryname>
- <optiontype>groups</optiontype>
- <defaultvalue></defaultvalue>
- <admindefaultvalue>1,2,3,4,5,6</admindefaultvalue>
- </option>
- <option name="admin.user.canAddUser">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canSearchUser">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canEditUser">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canEditMailAddress">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canEditPassword">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canDeleteUser">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canMailUser">
- <categoryname>admin.user.user</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canAddGroup">
- <categoryname>admin.user.group</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.user.canDeleteGroup">
- <categoryname>admin.user.group</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.style.canUseDisabledStyle">
- <categoryname>admin.style</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.language.canAddServer">
- <categoryname>admin.language</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.language.canDeleteServer">
- <categoryname>admin.language</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- <option name="admin.language.canEditServer">
- <categoryname>admin.language</categoryname>
- <optiontype>boolean</optiontype>
- <defaultvalue>0</defaultvalue>
- <admindefaultvalue>1</admindefaultvalue>
- </option>
- </options>
- </import>
-</data>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/usergroupoptions.xsd">
+ <import>
+ <categories>
+ <category name="user"></category>
+ <category name="mod"></category>
+ <category name="admin"></category>
+ <category name="admin.general">
+ <parent>admin</parent>
+ </category>
+ <category name="admin.system">
+ <parent>admin</parent>
+ </category>
+ <category name="admin.system.cronjobs">
+ <parent>admin.system</parent>
+ </category>
+ <category name="admin.system.package">
+ <parent>admin.system</parent>
+ </category>
+ <category name="admin.maintenance">
+ <parent>admin.system</parent>
+ </category>
+ <category name="admin.user">
+ <parent>admin</parent>
+ </category>
+ <category name="admin.user.user">
+ <parent>admin.user</parent>
+ </category>
+ <category name="admin.user.group">
+ <parent>admin.user</parent>
+ </category>
+
+ <category name="admin.display">
+ <parent>admin</parent>
+ </category>
+ <category name="admin.content">
+ <parent>admin</parent>
+ </category>
+ <category name="admin.style">
+ <parent>admin.display</parent>
+ </category>
+ <category name="admin.language">
+ <parent>admin.display</parent>
+ </category>
+ </categories>
+
+ <options>
+ <option name="admin.general.canViewPrivateUserOptions">
+ <categoryname>admin.general</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.canEditOption">
+ <categoryname>admin.system</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.canViewLog">
+ <categoryname>admin.system</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.cronjobs.canAddCronjob">
+ <categoryname>admin.system.cronjobs</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.cronjobs.canEditCronjob">
+ <categoryname>admin.system.cronjobs</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.cronjobs.canDeleteCronjob">
+ <categoryname>admin.system.cronjobs</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.cronjobs.canEnableDisableCronjob">
+ <categoryname>admin.system.cronjobs</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.cronjobs.canDeleteCronjobsLog">
+ <categoryname>admin.system.cronjobs</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.package.canUpdatePackage">
+ <categoryname>admin.system.package</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.package.canUninstallPackage">
+ <categoryname>admin.system.package</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.system.package.canEditServer">
+ <categoryname>admin.system.package</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.accessibleGroups">
+ <categoryname>admin.user.group</categoryname>
+ <optiontype>groups</optiontype>
+ <defaultvalue></defaultvalue>
+ <admindefaultvalue>1,2,3,4,5,6</admindefaultvalue>
+ </option>
+ <option name="admin.user.canAddUser">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canSearchUser">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canEditUser">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canEditMailAddress">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canEditPassword">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canDeleteUser">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canMailUser">
+ <categoryname>admin.user.user</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canAddGroup">
+ <categoryname>admin.user.group</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.user.canDeleteGroup">
+ <categoryname>admin.user.group</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.style.canUseDisabledStyle">
+ <categoryname>admin.style</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.language.canAddServer">
+ <categoryname>admin.language</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.language.canDeleteServer">
+ <categoryname>admin.language</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ <option name="admin.language.canEditServer">
+ <categoryname>admin.language</categoryname>
+ <optiontype>boolean</optiontype>
+ <defaultvalue>0</defaultvalue>
+ <admindefaultvalue>1</admindefaultvalue>
+ </option>
+ </options>
+ </import>
+</data>
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\BooleanOptionType;
-
-/**
- * BooleanGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class BooleanGroupOptionType extends BooleanOptionType implements IGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::merge()
- */
- public function merge(array $values) {
- foreach ($values as $value) {
- if ($value) return true;
- }
-
- return false;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\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;
-
-/**
- * GroupsGroupOptionType 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.group
- * @category Community Framework
- */
-class GroupsGroupOptionType extends AbstractOptionType implements IGroupOptionType {
- /**
- * @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\group\IGroupOptionType::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\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.group
- * @category Community Framework
- */
-interface IGroupOptionType 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\group;
-
-/**
- * InfiniteIntegerGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class InfiniteIntegerGroupOptionType extends IntegerGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::merge()
- */
- public function merge(array $values) {
- if (in_array(-1, $values)) return -1;
- return parent::merge($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-
-/**
- * InfiniteInverseIntegerGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class InfiniteInverseIntegerGroupOptionType extends InverseIntegerGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::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\group;
-use wcf\system\option\IntegerOptionType;
-
-/**
- * IntegerGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class IntegerGroupOptionType extends IntegerOptionType implements IGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::merge()
- */
- public function merge(array $values) {
- return max($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\IntegerOptionType;
-
-/**
- * InverseIntegerGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class InverseIntegerGroupOptionType extends IntegerOptionType implements IGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::merge()
- */
- public function merge(array $values) {
- return min($values);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\TextOptionType;
-
-/**
- * TextGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class TextGroupOptionType extends TextOptionType implements IGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::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\group;
-use wcf\system\option\TextareaOptionType;
-
-/**
- * TextareaGroupOptionType is an implementation of IGroupOptionType 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.group
- * @category Community Framework
- */
-class TextareaGroupOptionType extends TextareaOptionType implements IGroupOptionType {
- /**
- * @see wcf\system\option\group\IGroupOptionType::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\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);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\package\plugin;
+use wcf\data\user\group\option\UserGroupOption;
+use wcf\data\user\group\option\UserGroupOptionEditor;
+use wcf\data\user\group\UserGroup;
+use wcf\system\WCF;
+
+/**
+ * This PIP installs, updates or deletes user group permissions.
+ *
+ * @author Benjamin Kunz
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category Community Framework
+ */
+class UserGroupOptionsPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
+ /**
+ * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+ */
+ public $tableName = 'user_group_option';
+
+ public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'admindefaultvalue', 'validationpattern', 'showorder', 'categoryname', 'selectoptions', 'enableoptions', 'permissions', 'options', 'attrs', 'cdata');
+
+ /**
+ * Deletes group-option-categories and/or group-options which where installed by the package.
+ */
+ public function uninstall() {
+ // Delete value-entries using categories or options
+ // which will be deleted.
+ $sql = "DELETE FROM wcf".WCF_N."_user_group_option_value
+ WHERE optionID IN (
+ SELECT optionID
+ FROM wcf".WCF_N."_user_group_option
+ WHERE packageID = ?
+ )";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($this->installation->getPackageID()));
+
+ parent::uninstall();
+ }
+
+ /**
+ * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
+ */
+ protected function saveOption($option, $categoryName, $existingOptionID = 0) {
+ // default values
+ $optionName = $optionType = $defaultValue = $adminDefaultValue = $validationPattern = $enableOptions = $permissions = $options = '';
+ $showOrder = null;
+
+ // get values
+ if (isset($option['name'])) $optionName = $option['name'];
+ if (isset($option['optiontype'])) $optionType = $option['optiontype'];
+ if (isset($option['defaultvalue'])) $defaultValue = $option['defaultvalue'];
+ if (isset($option['admindefaultvalue'])) $adminDefaultValue = $option['admindefaultvalue'];
+ if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
+ if (!empty($option['showorder'])) $showOrder = intval($option['showorder']);
+ $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
+ if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
+ if (isset($option['permissions'])) $permissions = $option['permissions'];
+ if (isset($option['options'])) $options = $option['options'];
+
+ // check if optionType exists
+ $className = 'wcf\system\option\userGroup\\'.StringUtil::toUpperCase($optionType).'UserGroupOptionType';
+ if (!class_exists($className)) {
+ throw new SystemException("unable to find class '".$className."'");
+ }
+
+ // collect additional tags and their values
+ $additionalData = array();
+ foreach ($option as $tag => $value) {
+ if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
+ }
+
+ // check if the otion exist already and was installed by this package
+ $sql = "SELECT optionID
+ FROM wcf".WCF_N."_user_group_option
+ WHERE optionName = ?
+ AND packageID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(
+ $optionName,
+ $this->installation->getPackageID()
+ ));
+ $row = $statement->fetchArray();
+
+ $data = array(
+ 'categoryName' => $categoryName,
+ 'optionType' => $optionType,
+ 'defaultValue' => $defaultValue,
+ 'adminDefaultValue' => $adminDefaultValue,
+ 'validationPattern' => $validationPattern,
+ 'showOrder' => $showOrder,
+ 'enableOptions' => $enableOptions,
+ 'permissions' => $permissions,
+ 'options' => $options,
+ 'additionalData' => serialize($additionalData)
+ );
+
+ if (!empty($row['optionID'])) {
+ // update existing option
+ $optionID = $row['optionID'];
+
+ $groupOption = new UserGroupOption(null, $row);
+ $groupOptionEditor = new UserGroupOptionEditor($groupOption);
+ $groupOptionEditor->update($data);
+ }
+ else {
+ // add new option
+ $data['packageID'] = $this->installation->getPackageID();
+ $data['optionName'] = $optionName;
+
+ $groupOptionEditor = UserGroupOptionEditor::create($data);
+ $optionID = $groupOptionEditor->optionID;
+
+ // get default group ("everyone")
+ $sql = "SELECT groupID
+ FROM wcf".WCF_N."_user_group
+ WHERE groupType = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(UserGroup::EVERYONE));
+ $row = $statement->fetchArray();
+
+ // save default value
+ $sql = "INSERT INTO wcf".WCF_N."_user_group_option_value
+ (groupID, optionID, optionValue)
+ VALUES (?, ?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($row['groupID'], $optionID, $defaultValue));
+
+ if ($adminDefaultValue && $defaultValue != $adminDefaultValue) {
+ $sql = "SELECT groupID
+ FROM wcf".WCF_N."_user_group_option_value
+ WHERE optionID = (
+ SELECT optionID
+ FROM wcf".WCF_N."_user_group_option
+ WHERE optionName = ?
+ )
+ AND optionValue = '1'";
+ $statement2 = WCF::getDB()->prepareStatement($sql);
+ $statement2->execute(array('admin.general.canUseAcp'));
+
+ $acpGroups = array();
+ while ($row = $statement2->fetchArray()) {
+ $acpGroups[] = $row['groupID'];
+ }
+
+ $statement2->execute(array('admin.user.canEditGroup'));
+ while ($row = $statement2->fetchArray()) {
+ if (!in_array($row['groupID'], $acpGroups)) {
+ continue;
+ }
+
+ $statement->execute(array(
+ $row['groupID'],
+ $optionID,
+ $adminDefaultValue
+ ));
+ }
+ }
+ }
+ }
+}