From 48f9369a015737bcc4fec6432d30996e43206cc1 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 2 Mar 2012 11:00:15 +0100 Subject: [PATCH] Enhances ands acp user clipboard 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. --- wcfsetup/install/files/acp/js/WCF.ACP.js | 4 ++-- .../lib/acp/form/UserAssignToGroupForm.class.php | 2 +- .../acp/form/UserEmailAddressExportForm.class.php | 2 +- .../files/lib/acp/form/UserMailForm.class.php | 2 +- .../lib/action/ClipboardProxyAction.class.php | 4 ++-- .../files/lib/data/user/UserAction.class.php | 4 +++- .../system/clipboard/ClipboardEditorItem.class.php | 7 ------- .../system/clipboard/ClipboardHandler.class.php | 8 +++++--- .../clipboard/action/UserClipboardAction.class.php | 12 ++++++------ .../files/lib/system/worker/MailWorker.class.php | 2 +- wcfsetup/install/lang/de.xml | 14 +++++++++----- wcfsetup/install/lang/en.xml | 14 +++++++++----- 12 files changed, 40 insertions(+), 35 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index ebd4407cc2..e7fd95fcb0 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -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); - } + }); } }; diff --git a/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php b/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php index 7058fbfdf6..062c5574ac 100755 --- a/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php @@ -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."); } diff --git a/wcfsetup/install/files/lib/acp/form/UserEmailAddressExportForm.class.php b/wcfsetup/install/files/lib/acp/form/UserEmailAddressExportForm.class.php index b76fcae584..0cf4f29a27 100755 --- a/wcfsetup/install/files/lib/acp/form/UserEmailAddressExportForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserEmailAddressExportForm.class.php @@ -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."); } diff --git a/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php b/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php index c538ee6dcb..37b50df0f3 100755 --- a/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php @@ -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."); } diff --git a/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php b/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php index 3ebad37f97..336e5a80c5 100644 --- a/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php +++ b/wcfsetup/install/files/lib/action/ClipboardProxyAction.class.php @@ -93,7 +93,7 @@ class ClipboardProxyAction extends AbstractSecureAction { * @return array */ 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 { diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 5193278e13..b05576f74b 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -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(); diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardEditorItem.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardEditorItem.class.php index 4f0defb9a1..3cb49a9058 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardEditorItem.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardEditorItem.class.php @@ -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; } } diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 0d0283cc51..000b83b2da 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -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 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 6e410f0f5d..35d7d59dcd 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php @@ -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))); } } diff --git a/wcfsetup/install/files/lib/system/worker/MailWorker.class.php b/wcfsetup/install/files/lib/system/worker/MailWorker.class.php index 570c44153b..5ecf38e26b 100644 --- a/wcfsetup/install/files/lib/system/worker/MailWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/MailWorker.class.php @@ -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 diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 122f7da86b..3138d1bd5c 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1,10 +1,5 @@ - - - - - @@ -402,6 +397,15 @@ + + + + + + + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 29048abe71..b34bf7b2be 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1,10 +1,5 @@ - - 1}s{/if}?]]> - 1}s{/if} marked]]> - - @@ -402,6 +397,15 @@ + + + + 1}s{/if}?]]> + + + 1}s{/if} marked]]> + + -- 2.20.1