From: Alexander Ebert Date: Fri, 22 Mar 2013 00:38:42 +0000 (+0100) Subject: Improved action methods X-Git-Tag: 2.0.0_Beta_1~417^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a54f8d8f3df4ad8fb812b0fda40354aab1fdbef9;p=GitHub%2FWoltLab%2FWCF.git Improved action methods --- diff --git a/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php index a267139916..dee71f0967 100644 --- a/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php @@ -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 * @package com.woltlab.wcf * @subpackage data diff --git a/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php b/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php index 1854b2e2e5..9d27dd8039 100644 --- a/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php +++ b/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php @@ -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 * @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'); } /** diff --git a/wcfsetup/install/files/lib/data/category/CategoryAction.class.php b/wcfsetup/install/files/lib/data/category/CategoryAction.class.php index 43b226dc8b..5545e59156 100644 --- a/wcfsetup/install/files/lib/data/category/CategoryAction.class.php +++ b/wcfsetup/install/files/lib/data/category/CategoryAction.class.php @@ -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) { diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php index d66a04332a..29c3b21b33 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php @@ -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(); } diff --git a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php index 7ec8e16867..9e19afdaf7 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php @@ -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 * @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(); } } diff --git a/wcfsetup/install/files/lib/data/package/installation/queue/PackageInstallationQueueAction.class.php b/wcfsetup/install/files/lib/data/package/installation/queue/PackageInstallationQueueAction.class.php index 4676a49147..30a0574ab9 100644 --- a/wcfsetup/install/files/lib/data/package/installation/queue/PackageInstallationQueueAction.class.php +++ b/wcfsetup/install/files/lib/data/package/installation/queue/PackageInstallationQueueAction.class.php @@ -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'); } diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index a4bc4118c1..84161e9059 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -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');