Enhances ands acp user clipboard
authorMatthias Schmidt <gravatronics@live.com>
Fri, 2 Mar 2012 10:00:15 +0000 (11:00 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 2 Mar 2012 10:00:15 +0000 (11:00 +0100)
Changelog:

* Fixed illegal call `ClipboardHandler::getTypeID()` to `ClipboardHandler::getObjectTypeID()`
* Fixed wrong database table column name in `ClipboardHandler ::loadMarkedItems()`
* Removed unnecessary SID-related code in `ClipboardEditorItem::setURL()` since that is handled by the `LinkHandler`
* The urls of the clipboard editor items in `UserClipboardAction` are now properly set with the `LinkHandler`
* Fixes bug in `UserAction::validateDelete()` (`$this->users` instead of `$this->objects`)
* Fixes wrong way to get the action name in `ClipboardProxyAction`
* `WCF.ACP.User.List` now uses `WCF.System.Confirmation` for user deletion confirmation dialog.
* Added missing language items and renamed the two existing to better names.

TODO:
* After users are deleted, nothing happens. I think the best thing would be a page refresh.

12 files changed:
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php
wcfsetup/install/files/lib/acp/form/UserEmailAddressExportForm.class.php
wcfsetup/install/files/lib/acp/form/UserMailForm.class.php
wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/system/clipboard/ClipboardEditorItem.class.php
wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php
wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php
wcfsetup/install/files/lib/system/worker/MailWorker.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index ebd4407cc26aa94ebbf4b844922c3aadd3b5ed60..e7fd95fcb09ebe7c5c5d308cd9513b515c7691e7 100644 (file)
@@ -684,9 +684,9 @@ WCF.ACP.User.List.prototype = {
         */
        _delete: function(item) {
                var $confirmMessage = item.data('internalData')['confirmMessage'];
-               if (confirm($confirmMessage)) {
+               WCF.System.Confirmation.show($confirmMessage, function() {
                        WCF.Clipboard.sendRequest(item);
-               }
+               });
        }
 };
 
index 7058fbfdf69d8952fa7966e01917a34680c9c6a7..062c5574acebb9f5e91d1a3874417b1c78f165b0 100755 (executable)
@@ -57,7 +57,7 @@ class UserAssignToGroupForm extends ACPForm {
                parent::readParameters();
                
                // get type id
-               $this->typeID = ClipboardHandler::getInstance()->getTypeID('com.woltlab.wcf.user');
+               $this->typeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
                if ($this->typeID === null) {
                        throw new SystemException("clipboard item type 'com.woltlab.wcf.user' is unknown.");
                }
index b76fcae584818562df2d5bcde5f84f97eb990a6a..0cf4f29a278d4f4615358c32a2f2a441584dbb97 100755 (executable)
@@ -43,7 +43,7 @@ class UserEmailAddressExportForm extends ACPForm {
                parent::readParameters();
                
                // get type id
-               $this->typeID = ClipboardHandler::getInstance()->getTypeID('com.woltlab.wcf.user');
+               $this->typeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
                if ($this->typeID === null) {
                        throw new SystemException("clipboard item type 'com.woltlab.wcf.user' is unknown.");
                }
index c538ee6dcb296cff52e99c9d6f9b4951e15f7ffc..37b50df0f3f87efad69f23263b3c7e4ee76717f6 100755 (executable)
@@ -121,7 +121,7 @@ class UserMailForm extends ACPForm {
                        // get marked user ids
                        if (empty($this->action)) {
                                // get type id
-                               $typeID = ClipboardHandler::getInstance()->getTypeID('com.woltlab.wcf.user');
+                               $typeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
                                if ($typeID === null) {
                                        throw new SystemException("clipboard item type 'com.woltlab.wcf.user' is unknown.");
                                }
index 3ebad37f9774ff7407447a052667457dc529b42b..336e5a80c5ba5770c20fb2a10a69342aaa95c370 100644 (file)
@@ -93,7 +93,7 @@ class ClipboardProxyAction extends AbstractSecureAction {
         * @return      array<integer>
         */
        protected function getObjectIDs() {
-               $typeID = ClipboardHandler::getInstance()->getTypeID($this->typeName);
+               $typeID = ClipboardHandler::getInstance()->getObjectTypeID($this->typeName);
                if ($typeID === null) {
                        throw new AJAXException("clipboard item type '".$this->typeName."' is unknown");
                }
@@ -116,7 +116,7 @@ class ClipboardProxyAction extends AbstractSecureAction {
                $objectIDs = $this->getObjectIDs();
                
                // create object action instance
-               $this->objectAction = new $this->parameters['className']($objectIDs, $this->actionName);
+               $this->objectAction = new $this->parameters['className']($objectIDs, $this->parameters['actionName']);
                
                // validate action
                try {
index 5193278e13ad4f0f3954087e91ebac9ff906e8d3..b05576f74b28aca343fc221f4e37ef872da63315 100644 (file)
@@ -56,7 +56,9 @@ class UserAction extends AbstractDatabaseObjectAction {
                parent::validateDelete();
                
                $userIDs = array();
-               foreach ($this->users as $user) $userIDs[] = $user->userID;
+               foreach ($this->objects as $user) {
+                       $userIDs[] = $user->userID;
+               }
                
                // validate groups
                $conditions = new PreparedStatementConditionBuilder();
index 4f0defb9a1ff24f5bdc16d6f2ce78a1da8178c03..3cb49a905845f7502f74ec450c8ec4ff40070c70 100644 (file)
@@ -129,13 +129,6 @@ final class ClipboardEditorItem {
         * @param       string          $url
         */
        public function setURL($url) {
-               if (StringUtil::indexOf($url, '?') === false) {
-                       $url .= SID_ARG_1ST;
-               }
-               else {
-                       $url .= SID_ARG_2ND_NOT_ENCODED;
-               }
-               
                $this->url = $url;
        }
 }
index 0d0283cc51d49439c6d832da96a65da9ab480d60..000b83b2da1e8f707856cf808faaf2ed689c4a9b 100644 (file)
@@ -151,12 +151,14 @@ class ClipboardHandler extends SingletonFactory {
        /**
         * Loads a list of marked items grouped by type name.
         * 
-        * @param       integer         $typeID
+        * @param       integer         $objectTypeID
         */
-       protected function loadMarkedItems($typeID = null) {
+       protected function loadMarkedItems($objectTypeID = null) {
                $conditions = new PreparedStatementConditionBuilder();
                $conditions->add("userID = ?", array(WCF::getUser()->userID));
-               if ($typeID !== null) $conditions->add("typeID = ?", array($typeID));
+               if ($objectTypeID !== null) {
+                       $conditions->add("objectTypeID = ?", array($objectTypeID));
+               }
                
                // fetch object ids
                $sql = "SELECT  objectTypeID, objectID
index 6e410f0f5d34db36d6d4da14b760ece37a1cfe3b..35d7d59dcdf0f6ff15c963305113a554b2470d81 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\user\group\UserGroup;
 use wcf\system\clipboard\ClipboardEditorItem;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
+use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
 
 /**
@@ -34,7 +35,7 @@ class UserClipboardAction implements IClipboardAction {
                switch ($actionName) {
                        case 'assignToGroup':
                                $item->setName('user.assignToGroup');
-                               $item->setURL('index.php?form=UserAssignToGroup');
+                               $item->setURL(LinkHandler::getInstance()->getLink('UserAssignToGroup'));
                        break;
                        
                        case 'delete':
@@ -43,8 +44,7 @@ class UserClipboardAction implements IClipboardAction {
                                        return null;
                                }
                                
-                               // TODO: use language variable
-                               $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.user.confirmMessage', array('count' => $count)));
+                               $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.user.delete.confirmMessage', array('count' => $count)));
                                $item->addParameter('actionName', 'delete');
                                $item->addParameter('className', 'wcf\data\user\UserAction');
                                $item->setName('user.delete');
@@ -52,12 +52,12 @@ class UserClipboardAction implements IClipboardAction {
                        
                        case 'exportMailAddress':
                                $item->setName('user.exportMailAddress');
-                               $item->setURL('index.php?form=UserEmailAddressExport');
+                               $item->setURL(LinkHandler::getInstance()->getLink('UserEmailAddressExport'));
                        break;
                        
                        case 'sendMail':
                                $item->setName('user.sendMail');
-                               $item->setURL('index.php?form=UserMail');
+                               $item->setURL(LinkHandler::getInstance()->getLink('UserMail'));
                        break;
                        
                        default:
@@ -133,6 +133,6 @@ class UserClipboardAction implements IClipboardAction {
         * @see wcf\system\clipboard\action\IClipboardAction::getEditorLabel()
         */
        public function getEditorLabel(array $objects) {
-               return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.user.marked', array('count' => count($objects)));
+               return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.label.user.marked', array('count' => count($objects)));
        }
 }
index 570c44153bbd31ad5ef4e80707b53d5bf744e051..5ecf38e26b5e8223a45dc8d6fb6555f9b3867b17 100644 (file)
@@ -84,7 +84,7 @@ class MailWorker extends AbstractWorker {
                
                if ($progress == 100) {
                        // clear markings
-                       $typeID = ClipboardHandler::getInstance()->getTypeID('com.woltlab.wcf.user');
+                       $typeID = ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user');
                        ClipboardHandler::getInstance()->removeItems($typeID);
                        
                        // clear session
index 122f7da86b9da8cbfdbe366277256b1f363b8720..3138d1bd5c3c9fc25b96a10f17c3e834ab90de0e 100644 (file)
@@ -1,10 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de" languagename="Deutsch">
-       <category name="wcf.clipboard">
-               <item name="wcf.clipboard.user.confirmMessage"><![CDATA[{if $count == 1}Einen{else}{#$count}{/if} Benutzer löschen?]]></item>
-               <item name="wcf.clipboard.user.marked"><![CDATA[{if $count == 1}Ein{else}{#$count}{/if} Benutzer markiert]]></item>
-       </category>
-       
        <category name="wcf.acp.cronjob">
                <item name="wcf.acp.cronjob.list"><![CDATA[Cronjobs]]></item>
                <item name="wcf.acp.cronjob.add"><![CDATA[Cronjob hinzufügen]]></item>
                <item name="wcf.acp.user.sendMail.text"><![CDATA[Nachricht]]></item>
        </category>
        
+       <category name="wcf.clipboard">
+               <item name="wcf.clipboard.item.user.assignToGroup"><![CDATA[Benutzergruppe zuweisen]]></item>
+               <item name="wcf.clipboard.item.user.delete"><![CDATA[Benutzer löschen]]></item>
+               <item name="wcf.clipboard.item.user.delete.confirmMessage"><![CDATA[{if $count == 1}Einen{else}{#$count}{/if} Benutzer löschen?]]></item>
+               <item name="wcf.clipboard.item.user.exportMailAddress"><![CDATA[E-Mail-Adressen exportieren]]></item>
+               <item name="wcf.clipboard.item.user.sendMail"><![CDATA[E-Mail senden]]></item>
+               <item name="wcf.clipboard.label.user.marked"><![CDATA[{if $count == 1}Ein{else}{#$count}{/if} Benutzer markiert]]></item>
+       </category>
+       
        <category name="wcf.date">
                <item name="wcf.date.dateFormat"><![CDATA[j. F Y]]></item>
                <item name="wcf.date.timeFormat"><![CDATA[H:i]]></item>
index 29048abe7124927c71e69aecf7066c98c30932c5..b34bf7b2be3e42d130a2912997d9900a064c6234 100644 (file)
@@ -1,10 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en" languagename="English">
-       <category name="wcf.clipboard">
-               <item name="wcf.clipboard.user.confirmMessage"><![CDATA[Delete {if $count == 1}one{else}{#$count}{/if} user{if $count > 1}s{/if}?]]></item>
-               <item name="wcf.clipboard.user.marked"><![CDATA[{if $count == 1}One{else}{#$count}{/if} user{if $count > 1}s{/if} marked]]></item>
-       </category>
-       
        <category name="wcf.acp.cronjob">
                <item name="wcf.acp.cronjob.list"><![CDATA[Cron jobs]]></item>
                <item name="wcf.acp.cronjob.add"><![CDATA[Add a new cron job]]></item>
                <item name="wcf.acp.user.sendMail.text"><![CDATA[Message]]></item>
        </category>
        
+       <category name="wcf.clipboard">
+               <item name="wcf.clipboard.item.user.assignToGroup"><![CDATA[Assign to user group]]></item>
+               <item name="wcf.clipboard.item.user.delete"><![CDATA[Delete users]]></item>
+               <item name="wcf.clipboard.item.user.delete.confirmMessage"><![CDATA[Delete {if $count == 1}one{else}{#$count}{/if} user{if $count > 1}s{/if}?]]></item>
+               <item name="wcf.clipboard.item.user.exportMailAddress"><![CDATA[Export e-mail addresses]]></item>
+               <item name="wcf.clipboard.item.user.sendMail"><![CDATA[Send an e-mail]]></item>
+               <item name="wcf.clipboard.label.user.marked"><![CDATA[{if $count == 1}One{else}{#$count}{/if} user{if $count > 1}s{/if} marked]]></item>
+       </category>
+       
        <category name="wcf.date">
                <item name="wcf.date.dateFormat"><![CDATA[M jS Y]]></item>
                <item name="wcf.date.timeFormat"><![CDATA[g:ia]]></item>