Improved action methods
authorAlexander Ebert <ebert@woltlab.com>
Fri, 22 Mar 2013 00:38:42 +0000 (01:38 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 22 Mar 2013 00:38:42 +0000 (01:38 +0100)
wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php
wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php
wcfsetup/install/files/lib/data/category/CategoryAction.class.php
wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php
wcfsetup/install/files/lib/data/language/LanguageAction.class.php
wcfsetup/install/files/lib/data/package/installation/queue/PackageInstallationQueueAction.class.php
wcfsetup/install/files/lib/data/user/UserAction.class.php

index a26713991622a33ea0cebf9c673094e11e91b636..dee71f09671c064f70775b9bc6af6c8242320a54 100644 (file)
@@ -6,7 +6,7 @@ use wcf\system\version\VersionHandler;
  * Abstract class for all versionable data actions.
  * 
  * @author     Jeffrey Reichardt
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data
index 1854b2e2e54888eda50326504c43f3e54961e7a7..9d27dd80394912abb2dfe03eea7c4447ef8a3935 100644 (file)
@@ -10,7 +10,7 @@ use wcf\util\StringUtil;
  * Executes ACP search provider-related actions.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.acp.search.provider
@@ -21,10 +21,7 @@ class ACPSearchProviderAction extends AbstractDatabaseObjectAction implements IS
         * @see wcf\data\ISearchAction::validateGetSearchResultList()
         */
        public function validateGetSearchResultList() {
-               $this->parameters['data']['searchString'] = (isset($this->parameters['data']['searchString'])) ? StringUtil::trim($this->parameters['data']['searchString']) : '';
-               if (empty($this->parameters['data']['searchString'])) {
-                       throw new UserInputException('searchString');
-               }
+               $this->readString('searchString', false, 'data');
        }
        
        /**
index 43b226dc8b53a34ef3f9197822a5bf5b11eb2028..5545e591566eb0f492e53cf3d1bcaf17b89606ee 100644 (file)
@@ -100,9 +100,7 @@ class CategoryAction extends AbstractDatabaseObjectAction implements ISortableAc
         * @see wcf\data\AbstractDatabaseObjectAction::validateDelete()
         */
        public function validateCreate() {
-               if (!isset($this->parameters['data']['objectTypeID'])) {
-                       throw new UserInputException('objectTypeID');
-               }
+               $this->readInteger('objectTypeID', false, 'data');
                
                $objectType = CategoryHandler::getInstance()->getObjectType($this->parameters['data']['objectTypeID']);
                if ($objectType === null) {
index d66a04332a55bad2f69f0fb4767c63b2ad47e436..29c3b21b335b334deb7d8cc125a221afeba3d7f7 100644 (file)
@@ -98,7 +98,6 @@ class CronjobAction extends AbstractDatabaseObjectAction implements IToggleActio
         * Validates the 'execute' action.
         */
        public function validateExecute() {
-               // TODO: Fix this: We need update permissions for executing?
                parent::validateUpdate();
        }
        
index 7ec8e168677d6cd09a2bad8454d6981c276c1c69..9e19afdaf7fdfba330a560a3b4dd7335e4d39b99 100644 (file)
@@ -8,7 +8,7 @@ use wcf\system\WCF;
  * Executes language-related actions.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.language
@@ -35,27 +35,25 @@ class LanguageAction extends AbstractDatabaseObjectAction {
         */
        protected $permissionsUpdate = array('admin.language.canEditLanguage');
        
+       /**
+        * language editor object
+        * @var wcf\data\language\LanguageEditor
+        */
+       protected $languageEditor = null;
+       
        /**
         * Validates permission to set a language as default.
         */
        public function validateSetAsDefault() {
                WCF::getSession()->checkPermissions($this->permissionsUpdate);
                
-               // read objects
-               if (empty($this->objects)) {
-                       $this->readObjects();
-                       
-                       if (empty($this->objects)) {
-                               throw new UserInputException('objectIDs');
-                       }
-               }
+               $this->languageEditor = $this->getSingleObject();
        }
        
        /**
         * Sets language as default
         */
        public function setAsDefault() {
-               $language = array_shift($this->objects);
-               $language->setAsDefault();
+               $this->languageEditor->setAsDefault();
        }
 }
index 4676a491475246dc555828768ee5f61c68835201..30a0574ab98a3a85c87d52909047ab9937a30c98 100644 (file)
@@ -22,12 +22,6 @@ class PackageInstallationQueueAction extends AbstractDatabaseObjectAction {
         */
        protected $package = null;
        
-       /**
-        * id of the package the prepared queue belongs to
-        * @var integer
-        */
-       protected $packageID = 0;
-       
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$className
         */
@@ -37,9 +31,9 @@ class PackageInstallationQueueAction extends AbstractDatabaseObjectAction {
         * Validates the 'prepareQueue' action:
         */
        public function validatePrepareQueue() {
-               if (isset($this->parameters['packageID'])) $this->packageID = intval($this->parameters['packageID']);
+               $this->readInteger('packageID');
                
-               $this->package = new Package($this->packageID);
+               $this->package = new Package($this->parameters['packageID']);
                if (!$this->package->packageID) {
                        throw new UserInputException('packageID');
                }
index a4bc4118c155d7ddc4d5369cbaf74408c6db0335..84161e90598f8e0bd4100ab1cc124d84e7c8345f 100644 (file)
@@ -46,9 +46,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
         * Validates permissions and parameters.
         */
        public function validateCreate() {
-               if (!isset($this->parameters['data']['password'])) {
-                       throw new UserInputException('password');
-               }
+               $this->readString('password', false, 'data');
        }
        
        /**
@@ -201,13 +199,8 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
         * @see wcf\data\ISearchAction::validateGetSearchResultList()
         */
        public function validateGetSearchResultList() {
-               if (!isset($this->parameters['data']['searchString'])) {
-                       throw new UserInputException('searchString');
-               }
-               
-               if (!isset($this->parameters['data']['includeUserGroups'])) {
-                       throw new UserInputException('includeUserGroups');
-               }
+               $this->readBoolean('includeUserGroups', false, 'data');
+               $this->readString('searchString', false, 'data');
                
                if (isset($this->parameters['data']['excludedSearchValues']) && !is_array($this->parameters['data']['excludedSearchValues'])) {
                        throw new UserInputException('excludedSearchValues');