From: Matthias Schmidt Date: Wed, 9 Jan 2013 10:31:05 +0000 (+0100) Subject: Adds default implementation AbstractClipboardAction::execute() X-Git-Tag: 2.0.0_Beta_1~569^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=106a5ea4f317ff075bf37be2ebdc81a8026a2ac3;p=GitHub%2FWoltLab%2FWCF.git Adds default implementation AbstractClipboardAction::execute() --- diff --git a/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php index 1a2725d927..85b35bcf0f 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php @@ -1,5 +1,7 @@ + */ + protected $actionClassActions = array(); + + /** + * relevant database objects + * @var array + */ + protected $objects = array(); + + /** + * list of the supported clipboard actions + * @var array + */ + protected $supportedActions = array(); + + /** + * @see wcf\system\clipboard\action\IClipboardAction::execute() + */ + public function execute(array $objects, $actionName) { + if (!in_array($actionName, $this->supportedActions)) { + throw new SystemException("Unknown clipboard action '".$actionName."'"); + } + + $this->objects = $objects; + + $item = new ClipboardEditorItem(); + $item->setName($this->getTypeName().'.'.$actionName); + if (in_array($actionName, $this->actionClassActions)) { + $item->addParameter('actionName', $actionName); + $item->addParameter('className', $this->getClassName()); + } + + $methodName = 'validate'.ucfirst($actionName); + if (method_exists($this, $methodName)) { + $objectIDs = $this->$methodName(); + if (empty($objectIDs)) { + return null; + } + + $item->addParameter('objectIDs', $objectIDs); + } + + return $item; + } + /** * @see wcf\system\clipboard\action\IClipboardAction::filterObjects() */ diff --git a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php index c1636a7f44..36f19ac564 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php @@ -1,9 +1,7 @@ setName('user.assignToGroup'); $item->setURL(LinkHandler::getInstance()->getLink('UserAssignToGroup')); break; case 'delete': - $userIDs = $this->validateDelete($objects); - if (empty($userIDs)) { - return null; - } - - $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.user.delete.confirmMessage', array('count' => count($userIDs)))); - $item->addParameter('actionName', 'delete'); - $item->addParameter('className', 'wcf\data\user\UserAction'); - $item->addParameter('objectIDs', $userIDs); - $item->setName('user.delete'); + $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.com.woltlab.wcf.user.delete.confirmMessage', array( + 'count' => $item->getCount() + ))); break; case 'exportMailAddress': - $item->setName('user.exportMailAddress'); $item->setURL(LinkHandler::getInstance()->getLink('UserEmailAddressExport')); break; case 'sendMail': - $item->setName('user.sendMail'); $item->setURL(LinkHandler::getInstance()->getLink('UserMail')); break; - - default: - throw new SystemException("action '".$actionName."' is invalid"); - break; } return $item; @@ -76,23 +67,28 @@ class UserClipboardAction extends AbstractClipboardAction { return 'wcf\data\user\UserAction'; } + /** + * @see wcf\system\clipboard\action\IClipboardAction::getTypeName() + */ + public function getTypeName() { + return 'com.woltlab.wcf.user'; + } + /** * Returns the ids of the users which can be deleted. * - * @param array $objects - * @return integer + * @return array */ - protected function validateDelete(array $objects) { + protected function validateDelete() { // check permissions if (!WCF::getSession()->getPermission('admin.user.canDeleteUser')) { return 0; } // user cannot delete itself - $userIDs = array_keys($objects); + $userIDs = array_keys($this->objects); foreach ($userIDs as $index => $userID) { if ($userID == WCF::getUser()->userID) { - unset($objects[$userID]); unset($userIDs[$index]); } } @@ -133,6 +129,8 @@ class UserClipboardAction extends AbstractClipboardAction { * @see wcf\system\clipboard\action\IClipboardAction::getEditorLabel() */ public function getEditorLabel(array $objects) { - return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.label.user.marked', array('count' => count($objects))); + return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.label.com.woltlab.wcf.user.marked', array( + 'count' => count($objects) + )); } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index cf30ee1279..1f8dae9a65 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -697,12 +697,12 @@ - - - - - - + + + + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index befea72c40..400f9a6983 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -474,11 +474,11 @@ - - 1}s{/if}?]]> - - - 1}s{/if} marked]]> + + 1}s{/if}?]]> + + + 1}s{/if} marked]]>