Enhances new clipboard's unmark all action
authorMatthias Schmidt <gravatronics@live.com>
Sat, 27 Oct 2012 18:34:10 +0000 (20:34 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 27 Oct 2012 18:34:10 +0000 (20:34 +0200)
The action class now **has to** implement the new `wcf\data\IClipboardAction` interface and the AJAX call to unmark all items includes the container data now.

wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/lib/data/IClipboardAction.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php

index d0df0e1750e33756a7f749ce5ae39047b780d24f..bffcec1b331466076754e182a7acafd0aa7f7f82 100755 (executable)
@@ -1261,6 +1261,7 @@ WCF.Clipboard = {
                        data: {
                                actionName: listItem.data('parameters').actionName,
                                className: listItem.data('parameters').className,
+                               containerData: this._containerData[listItem.data('type')],
                                objectIDs: $objectIDs,
                                parameters: $parameters
                        },
diff --git a/wcfsetup/install/files/lib/data/IClipboardAction.class.php b/wcfsetup/install/files/lib/data/IClipboardAction.class.php
new file mode 100644 (file)
index 0000000..3ed3206
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+namespace wcf\data;
+
+/**
+ * Every database object action class which belongs to database objects which support
+ * clipboard actions has to implement this interface.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2012 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage data
+ * @category   Community Framework
+ */
+interface IClipboardAction {
+       /**
+        * Unmarks all marked objects.
+        */
+       public function unmarkAll();
+       
+       /**
+        * Validates the 'unmarkAll' action.
+        */
+       public function validateUnmarkAll();
+}
index d4b6f1925870ef5b9bf052ebde57c7e7afd223e0..aadde720104614a4fc4919e94e87ed46932999b7 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\data\user;
 use wcf\data\user\group\UserGroup;
 use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\IClipboardAction;
 use wcf\data\ISearchAction;
 use wcf\system\clipboard\ClipboardHandler;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
@@ -20,7 +21,7 @@ use wcf\util\StringUtil;
  * @subpackage data.user
  * @category   Community Framework
  */
-class UserAction extends AbstractDatabaseObjectAction implements ISearchAction {
+class UserAction extends AbstractDatabaseObjectAction implements IClipboardAction, ISearchAction {
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$className
         */
@@ -265,12 +266,12 @@ class UserAction extends AbstractDatabaseObjectAction implements ISearchAction {
        }
        
        /**
-        * Does nothing.
+        * @see wcf\data\IClipboardAction::validateUnmarkAll()
         */
        public function validateUnmarkAll() { }
        
        /**
-        * Unmarks all users.
+        * @see wcf\data\IClipboardAction::unmarkAll()
         */
        public function unmarkAll() {
                ClipboardHandler::getInstance()->removeItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user'));
index e338d333e016c23d3f75f8528d390611f9fb451f..2d41ced066c6735dc54c1e4ac3d3b94bc8ed7936 100644 (file)
@@ -286,6 +286,10 @@ class ClipboardHandler extends SingletonFactory {
                        }
                        
                        // append 'unmark all' item
+                       if (!ClassUtil::isInstanceOf($actionData['object']->getClassName(), 'wcf\data\IClipboardAction')) {
+                               throw new SystemException("'".$actionData['object']->getClassName()."' has to implement 'wcf\data\IClipboardAction'.");
+                       }
+                       
                        $unmarkAll = new ClipboardEditorItem();
                        $unmarkAll->setName('unmarkAll');
                        $unmarkAll->addParameter('actionName', 'unmarkAll');