From: Matthias Schmidt Date: Wed, 8 Aug 2012 18:49:29 +0000 (+0200) Subject: Adds several interfaces for dbo actions X-Git-Tag: 2.0.0_Beta_1~885^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a427a8c831cc5190a43c452139c7f6febd562a2c;p=GitHub%2FWoltLab%2FWCF.git Adds several interfaces for dbo actions Please be aware that the API for searching objects via AJAX changed! --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index cd92118aae..6bedde4454 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -4045,7 +4045,7 @@ WCF.Search.Base = Class.extend({ }; this._proxy.setOption('data', { - actionName: 'getList', + actionName: 'getSearchResultList', className: this._className, parameters: this._getParameters($parameters) }); diff --git a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php index f810bc0939..21682082e7 100644 --- a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php @@ -18,7 +18,7 @@ use wcf\util\StringUtil; * @subpackage data * @category Community Framework */ -abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction { +abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, IDeleteAction { /** * pending action * @var string @@ -228,7 +228,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction { } /** - * Validates permissions and parameters. + * @see wcf\data\IDeleteAction::validateDelete() */ public function validateDelete() { // validate permissions @@ -291,9 +291,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction { } /** - * Deletes database object and returns the number of deleted objects. - * - * @return integer + * @see wcf\data\IDeleteAction::delete() */ public function delete() { if (!count($this->objects)) { diff --git a/wcfsetup/install/files/lib/data/ICollapsibleContainerAction.class.php b/wcfsetup/install/files/lib/data/ICollapsibleContainerAction.class.php new file mode 100644 index 0000000000..ba8aa44682 --- /dev/null +++ b/wcfsetup/install/files/lib/data/ICollapsibleContainerAction.class.php @@ -0,0 +1,25 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +interface ICollapsibleContainerAction { + /** + * Toggles the container state of the relevant objects. + */ + public function toggleContainer(); + + /** + * Validates the "toggleContainer" action. + */ + public function validateToggleContainer(); +} diff --git a/wcfsetup/install/files/lib/data/IDeleteAction.class.php b/wcfsetup/install/files/lib/data/IDeleteAction.class.php new file mode 100644 index 0000000000..06ad12caa0 --- /dev/null +++ b/wcfsetup/install/files/lib/data/IDeleteAction.class.php @@ -0,0 +1,27 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +interface IDeleteAction { + /** + * Deletes the relevant objects and returns the number of deleted objects. + * + * @return integer + */ + public function delete(); + + /** + * Validates the "delete" action. + */ + public function validateDelete(); +} diff --git a/wcfsetup/install/files/lib/data/ILoadableCollapsibleContainerAction.class.php b/wcfsetup/install/files/lib/data/ILoadableCollapsibleContainerAction.class.php new file mode 100644 index 0000000000..96d41a7954 --- /dev/null +++ b/wcfsetup/install/files/lib/data/ILoadableCollapsibleContainerAction.class.php @@ -0,0 +1,26 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +interface ILoadableCollapsibleContainerAction { + /** + * Toggles the container state of the relevant objects and loads their + * content if necessary. + */ + public function loadContainer(); + + /** + * Validates the "loadContainer" action. + */ + public function validateLoadContainer(); +} \ No newline at end of file diff --git a/wcfsetup/install/files/lib/data/IPositionAction.class.php b/wcfsetup/install/files/lib/data/IPositionAction.class.php new file mode 100644 index 0000000000..2d91b405e5 --- /dev/null +++ b/wcfsetup/install/files/lib/data/IPositionAction.class.php @@ -0,0 +1,25 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +interface IPositionAction { + /** + * Updates the positions of the relevant objects. + */ + public function updatePosition(); + + /** + * Validates the "updatePosition" action. + */ + public function validateUpdatePosition(); +} diff --git a/wcfsetup/install/files/lib/data/ISearchAction.class.php b/wcfsetup/install/files/lib/data/ISearchAction.class.php new file mode 100644 index 0000000000..33629bae14 --- /dev/null +++ b/wcfsetup/install/files/lib/data/ISearchAction.class.php @@ -0,0 +1,27 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +interface ISearchAction { + /** + * Returns a list with data of objects that match the given search criteria. + * + * @return array + */ + public function getSearchResultList(); + + /** + * Validates the "getSearchResultList" action. + */ + public function validateGetSearchResultList(); +} \ No newline at end of file diff --git a/wcfsetup/install/files/lib/data/IToggleAction.class.php b/wcfsetup/install/files/lib/data/IToggleAction.class.php new file mode 100644 index 0000000000..e1fa414bd0 --- /dev/null +++ b/wcfsetup/install/files/lib/data/IToggleAction.class.php @@ -0,0 +1,25 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +interface IToggleAction { + /** + * Toggles the "isDisabled" status of the relevant objects. + */ + public function toggle(); + + /** + * Validates the "toggle" action. + */ + public function validateToggle(); +} diff --git a/wcfsetup/install/files/lib/data/category/CategoryAction.class.php b/wcfsetup/install/files/lib/data/category/CategoryAction.class.php index d20bab41a7..9fab9e7974 100644 --- a/wcfsetup/install/files/lib/data/category/CategoryAction.class.php +++ b/wcfsetup/install/files/lib/data/category/CategoryAction.class.php @@ -1,6 +1,9 @@ objects as $categoryEditor) { @@ -50,7 +53,7 @@ class CategoryAction extends AbstractDatabaseObjectAction { } /** - * Toggles the collapse status of categories. + * @see wcf\data\ICollapsibleContainerAction::toggleContainer() */ public function toggleContainer() { $objectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($this->objects[0]->getCategoryType()->getCollapsibleObjectTypeName()); @@ -66,7 +69,7 @@ class CategoryAction extends AbstractDatabaseObjectAction { } /** - * Updates the position of categories. + * @see wcf\data\IPositionAction::updatePosition() */ public function updatePosition() { $showOrders = array(); @@ -145,14 +148,14 @@ class CategoryAction extends AbstractDatabaseObjectAction { } /** - * Validates the 'toggle' action. + * @see wcf\data\IToggleAction::validateToggle() */ public function validateToggle() { $this->validateUpdate(); } /** - * Validates the 'toggleContainer' action. + * @see wcf\data\ICollapsibleContainerAction::validateToggleContainer() */ public function validateToggleContainer() { $this->validateUpdate(); @@ -189,7 +192,7 @@ class CategoryAction extends AbstractDatabaseObjectAction { } /** - * Validates the 'updatePosition' action. + * @see wcf\data\IPositionAction::validateUpdatePosition() */ public function validateUpdatePosition() { // validate permissions diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php index e01e957715..aba93de57c 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php @@ -2,6 +2,7 @@ namespace wcf\data\cronjob; use wcf\data\cronjob\log\CronjobLogEditor; use wcf\data\AbstractDatabaseObjectAction; +use wcf\data\IToggleAction; use wcf\system\cronjob\CronjobScheduler; use wcf\system\exception\ValidateActionException; use wcf\system\WCF; @@ -17,7 +18,7 @@ use wcf\util\DateUtil; * @subpackage data.cronjob * @category Community Framework */ -class CronjobAction extends AbstractDatabaseObjectAction { +class CronjobAction extends AbstractDatabaseObjectAction implements IToggleAction { /** * @see wcf\data\AbstractDatabaseObjectAction::$className */ @@ -70,7 +71,7 @@ class CronjobAction extends AbstractDatabaseObjectAction { } /** - * Validates permissions and parameters + * @see wcf\data\IToggleAction::validateToggle() */ public function validateToggle() { parent::validateUpdate(); @@ -83,7 +84,7 @@ class CronjobAction extends AbstractDatabaseObjectAction { } /** - * Toggles status. + * @see wcf\data\IToggleAction::toggle() */ public function toggle() { foreach ($this->objects as $cronjob) { diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php index b45b82a689..68166df0b6 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php @@ -1,6 +1,7 @@ objects as $server) { diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 58b532e2fa..75ccd723a8 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -2,6 +2,7 @@ namespace wcf\data\user; use wcf\data\user\group\UserGroup; use wcf\data\AbstractDatabaseObjectAction; +use wcf\data\ISearchAction; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\ValidateActionException; @@ -18,7 +19,7 @@ use wcf\util\StringUtil; * @subpackage data.user * @category Community Framework */ -class UserAction extends AbstractDatabaseObjectAction { +class UserAction extends AbstractDatabaseObjectAction implements ISearchAction { /** * @see wcf\data\AbstractDatabaseObjectAction::$className */ @@ -195,9 +196,9 @@ class UserAction extends AbstractDatabaseObjectAction { } /** - * Validates parameters to search for users and -groups. + * @see wcf\data\ISearchAction::validateGetSearchResultList() */ - public function validateGetList() { + public function validateGetSearchResultList() { if (!isset($this->parameters['data']['searchString'])) { throw new ValidateActionException("Missing parameter 'searchString'"); } @@ -212,11 +213,9 @@ class UserAction extends AbstractDatabaseObjectAction { } /** - * Returns a list of users and -groups based upon given search criteria. - * - * @return array + * @see wcf\data\ISearchAction::getSearchResultList() */ - public function getList() { + public function getSearchResultList() { $searchString = $this->parameters['data']['searchString']; $excludedSearchValues = array(); if (isset($this->parameters['data']['excludedSearchValues'])) {