Additional adjustments
authorMatthias Schmidt <gravatronics@live.com>
Sat, 13 Aug 2011 06:51:22 +0000 (08:51 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 16 Aug 2011 11:34:07 +0000 (13:34 +0200)
wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php
wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php
wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php

index d2f7d5108310132bc3434ffeec8aef9b5c1f9f29..6b152416ff033834638f2d9e639005ca5e778810 100755 (executable)
@@ -187,14 +187,14 @@ class UserGroupAddForm extends AbstractOptionListForm {
         */
        protected function getTypeObject($type) {
                if (!isset($this->typeObjects[$type])) {
-                       $className = 'wcf\system\option\group\\'.StringUtil::toUpperCase($type).'GroupOptionType';
+                       $className = 'wcf\system\option\userGroup\\'.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\group\IGroupOptionType')) {
-                               throw new SystemException("'".$className."' should implement wcf\system\option\group\IGroupOptionType");
+                       if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\userGroup\IUserGroupOptionType')) {
+                               throw new SystemException("'".$className."' should implement wcf\system\option\userGroup\IUserGroupOptionType");
                        }
                        $this->typeObjects[$type] = new $className();
                }
index 4d84984c943e645dfc5a872aee927659ddf5488b..805be58e87bb5dcf72b5ecf4e9c17a2f7f2ff611 100644 (file)
@@ -4,6 +4,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
 use wcf\system\WCF;
 use wcf\util\ClassUtil;
+use wcf\util\StringUtil;
 
 /**
  * Caches the merged group options of a group combination.
@@ -99,18 +100,18 @@ class UserGroupPermissionCacheBuilder implements ICacheBuilder {
         * Returns an object of the requested group option type.
         * 
         * @param       string                  $type
-        * @return      wcf\system\option\group\IGroupOptionType
+        * @return      wcf\system\option\userGroup\IUserGroupOptionType
         */
        protected function getTypeObject($type) {
                if (!isset($this->typeObjects[$type])) {
-                       $className = 'wcf\system\option\group\\'.StringUtil::toUpperCase($type).'GroupOptionType';
+                       $className = 'wcf\system\option\userGroup\\'.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\group\IGroupOptionType')) {
-                               throw new SystemException("'".$className."' should implement wcf\system\option\group\IGroupOptionType");
+                       if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\userGroup\IUserGroupOptionType')) {
+                               throw new SystemException("'".$className."' should implement wcf\system\option\userGroup\IUserGroupOptionType");
                        }
                        
                        // create instance
diff --git a/wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/GroupOptionsPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index 174195d..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-<?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 GroupOptionsPackageInstallationPlugin 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\group\\'.StringUtil::toUpperCase($type).'GroupOptionType';
-               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
-                                       ));
-                               }
-                       }
-               }
-       }
-}
index 16d214733415c7304a3de1b759c94bd07ae63771..c906ff73a2b6cc50f44896200a8b5a8d144f5541 100644 (file)
@@ -62,7 +62,7 @@ class UserGroupOptionsPackageInstallationPlugin extends AbstractOptionPackageIns
                if (isset($option['options'])) $options = $option['options'];
                
                // check if optionType exists
-               $className = 'wcf\system\option\userGroup\\'.StringUtil::toUpperCase($optionType).'UserGroupOptionType';
+               $className = 'wcf\system\option\userGroup\\'.StringUtil::firstCharToUpperCase($optionType).'UserGroupOptionType';
                if (!class_exists($className)) {
                        throw new SystemException("unable to find class '".$className."'");
                }