/**
* @see wcf\acp\form\AbstractOptionListForm::$cacheName
*/
- public $cacheName = 'user_group-option-';
+ public $cacheName = 'userGroup-option';
/**
* active tab menu item name
*/
public $optionTree = array();
+ /**
+ * @see wcf\acp\form\AbstractOptionListForm::$optionHandlerClassName
+ */
+ public $optionHandlerClassName = 'wcf\system\option\user\group\UserGroupOptionHandler';
+
/**
* group name
* @var string
*/
public $additionalFields = array();
+ /**
+ * @see wcf\page\IPage::readParameters()
+ */
public function readParameters() {
parent::readParameters();
* @see wcf\page\IPage::readData()
*/
public function readData() {
- AbstractOptionListForm::readData();
+ parent::readData();
- $this->optionTree = $this->getOptionTree();
+ $this->optionTree = $this->optionHandler->getOptionTree();
if (!count($_POST)) {
$this->activeTabMenuItem = $this->optionTree[0]['object']->categoryName;
}
// check master password
WCFACP::checkMasterPassword();
- // get user options and categories from cache
- $this->readCache();
-
// show form
parent::show();
}
*/
public function getData(array $cacheResource) {
$information = explode('-', $cacheResource['cache']);
+ $tableName = '';
+
if (count($information) == 3) {
- $type = $information[0].'_';
+ $type = $information[0];
$packageID = $information[2];
+
+ preg_match_all('~((?:^|[A-Z])[a-z]+)~', $information[0], $matches);
+ if (isset($matches[1])) {
+ for ($i = 0, $length = count($matches[1]); $i < $length; $i++) {
+ $tableName .= strtolower($matches[1][$i]) . '_';
+ }
+ }
}
else {
$type = '';
'categoryStructure' => array(),
'optionToCategories' => array()
);
-
+
// option categories
// get all option categories and sort categories by priority
$sql = "SELECT categoryName, categoryID
- FROM wcf".WCF_N."_".$type."option_category option_category
+ FROM wcf".WCF_N."_".$tableName."option_category option_category
LEFT JOIN wcf".WCF_N."_package_dependency package_dependency
ON (package_dependency.dependency = option_category.packageID)
WHERE package_dependency.packageID = ?
$conditions->add("categoryID IN (?)", array($optionCategories));
$sql = "SELECT option_category.*, package.packageDir
- FROM wcf".WCF_N."_".$type."option_category option_category
+ FROM wcf".WCF_N."_".$tableName."option_category option_category
LEFT JOIN wcf".WCF_N."_package package
ON (package.packageID = option_category.packageID)
".$conditions."
// get all options and sort options by priority
$optionIDs = array();
$sql = "SELECT optionName, optionID
- FROM wcf".WCF_N."_".$type."option option_table
+ FROM wcf".WCF_N."_".$tableName."option option_table
LEFT JOIN wcf".WCF_N."_package_dependency package_dependency
ON (package_dependency.dependency = option_table.packageID)
WHERE package_dependency.packageID = ?
$className = 'wcf\data\option\Option';
if (!empty($type)) {
// strip trailing underscore
- $rawType = substr($type, 0, -1);
- preg_match_all('~((?:^|[A-Z])[a-z]+)~', $rawType, $matches);
+ preg_match_all('~((?:^|[A-Z])[a-z]+)~', $type, $matches);
if (isset($matches[1])) {
$className = 'wcf\data\\';
for ($i = 0, $length = count($matches[1]); $i < $length; $i++) {
$className .= $matches[1][$i] . '\\';
}
- $className .= 'option\\' . ucfirst($rawType) . 'Option';
+ $className .= 'option\\' . ucfirst($type) . 'Option';
}
}
$conditions->add("optionID IN (?)", array($optionIDs));
$sql = "SELECT *
- FROM wcf".WCF_N."_".$type."option
+ FROM wcf".WCF_N."_".$tableName."option
".$conditions."
ORDER BY showOrder ASC";
$statement = WCF::getDB()->prepareStatement($sql);
*/
protected function getTypeObject($type) {
if (!isset($this->typeObjects[$type])) {
- $className = 'wcf\system\option\\'.ucfirst($type).'OptionType';
-
- // validate class
- if (!class_exists($className)) {
- throw new SystemException("unable to find class '".$className."'");
- }
- if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\IOptionType')) {
- throw new SystemException("'".$className."' should implement wcf\system\option\IOptionType");
+ $className = $this->getClassName($type);
+ if ($className === null) {
+ throw new SystemException("unable to find class for option type '".$type."'");
}
// create instance
return $this->typeObjects[$type];
}
+ /**
+ * Returns class name for option type.
+ *
+ * @param string $type
+ * @return string
+ */
+ protected function getClassName($type) {
+ $className = 'wcf\system\option\\'.ucfirst($type).'OptionType';
+
+ // validate class
+ if (!class_exists($className)) {
+ return null;
+ }
+ if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\IOptionType')) {
+ throw new SystemException("'".$className."' should implement wcf\system\option\IOptionType");
+ }
+
+ return $className;
+ }
+
/**
* Gets all options and option categories from cache.
*
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\exception\SystemException;
+use wcf\system\option\OptionHandler;
+use wcf\util\ClassUtil;
+
+/**
+ * Handles user group options.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 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 UserGroupOptionHandler extends OptionHandler {
+ /**
+ * @see wcf\system\option\OptionHandler::getClassName()
+ */
+ protected function getClassName($type) {
+ $className = parent::getClassName($type);
+
+ if ($className === null) {
+ $className = 'wcf\system\option\user\group\\'.ucfirst($type).'UserGroupOptionType';
+
+ // validate class
+ if (!class_exists($className)) {
+ return null;
+ }
+ if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\IOptionType')) {
+ throw new SystemException("'".$className."' should implement wcf\system\option\IOptionType");
+ }
+ }
+
+ return $className;
+ }
+}
\ No newline at end of file