Fixed mail worker
authorAlexander Ebert <ebert@woltlab.com>
Wed, 14 Sep 2011 14:33:14 +0000 (16:33 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 14 Sep 2011 14:33:14 +0000 (16:33 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/templates/userMail.tpl
wcfsetup/install/files/lib/acp/form/UserMailForm.class.php
wcfsetup/install/files/lib/system/worker/MailWorker.class.php

index 66509e65b05c6ea9c4e06accd7f3838863751a8c..cc2fce3addbda5831a7da36477e76204cf1121ee 100644 (file)
@@ -603,7 +603,8 @@ WCF.ACP.Worker.prototype = {
                                type: 'POST',
                                data: {
                                        className: $data.className,
-                                       loopCount: $data.loopCount
+                                       loopCount: $data.loopCount,
+                                       parameters: $data.parameters
                                },
                                success: $.proxy(function(data) {
                                        this._dialog.data('responseData', data);
index 52dd548e1f753b1aea49c07fef8192a3911cc951..4014fe6d018847c84b4dfc58c449a54eac43a7a1 100644 (file)
@@ -1,5 +1,17 @@
 {include file='header'}
 
+{if $mailID|isset}
+       <script type="text/javascript">
+               //<![CDATA[
+               $(function() {
+                       new WCF.ACP.Worker('mail', 'wcf\\system\\worker\\MailWorker', {
+                               mailID: {@$mailID}
+                       });
+               });
+               //]]>
+       </script>
+{/if}
+
 <header class="mainHeading">
        <img src="{@RELATIVE_WCF_DIR}icon/email1.svg" alt="" />
        <hgroup>
index 0fc6863a8e5b9b7625bc9dcfccfed5095981914a..c17861a3c582f824c7af923231ad555a35e8497e 100755 (executable)
@@ -5,6 +5,7 @@ use wcf\data\user\UserList;
 use wcf\util\ArrayUtil;
 use wcf\util\StringUtil;
 use wcf\system\WCF;
+use wcf\system\clipboard\ClipboardHandler;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\UserInputException;
 
@@ -106,13 +107,7 @@ class UserMailForm extends ACPForm {
                WCF::getSession()->register('userMailData', $userMailData);
                $this->saved();
                
-               // show worker template
-               WCF::getTPL()->assign(array(
-                       'pageTitle' => WCF::getLanguage()->get(($this->action == 'all' ? 'wcf.acp.user.sendMail.all' : ($this->action == 'group' ? 'wcf.acp.user.sendMail.group' : 'wcf.acp.user.sendMail'))),
-                       'url' => 'index.php?action=UserMail&mailID='.$mailID.''.SID_ARG_2ND_NOT_ENCODED
-               ));
-               WCF::getTPL()->display('worker');
-               exit;
+               WCF::getTPL()->assign('mailID', $mailID);
        }
        
        /**
@@ -124,16 +119,26 @@ class UserMailForm extends ACPForm {
                if (!count($_POST)) {
                        // get marked user ids
                        if (empty($this->action)) {
-                               $markedUsers = WCF::getSession()->getVar('markedUsers');
-                               if (is_array($markedUsers)) $this->userIDs = implode(',', $markedUsers);
-                               if (empty($this->userIDs)) throw new IllegalLinkException();
+                               // get type id
+                               $typeID = ClipboardHandler::getInstance()->getTypeID('com.woltlab.wcf.user');
+                               if ($typeID === null) {
+                                       throw new SystemException("clipboard item type 'com.woltlab.wcf.user' is unknown.");
+                               }
+                               
+                               // get user ids
+                               $users = ClipboardHandler::getInstance()->getMarkedItems($typeID);
+                               if (!isset($users['com.woltlab.wcf.user']) || empty($users['com.woltlab.wcf.user'])) throw new IllegalLinkException();
+                               
+                               // load users
+                               $this->userIDs = array_keys($users['com.woltlab.wcf.user']);
+                               $this->users = $users['com.woltlab.wcf.user'];
                        }
                        
                        if (MAIL_USE_FORMATTED_ADDRESS) $this->from = MAIL_FROM_NAME . ' <' . MAIL_FROM_ADDRESS . '>';
                        else $this->from = MAIL_FROM_ADDRESS;
                }
                
-               if (!empty($this->userIDs)) {
+               if (!empty($this->userIDs) && empty($this->users)) {
                        $userList = new UserList();
                        $userList->getConditionBuilder()->add("user.userID IN (?)", array($this->userIDs));
                        $userList->sqlOrderBy = "user.username ASC";
index f634af53f8cfc47128f3fb25987c309c5a921ade..4d9a55530ae5cfdb64e45b3e817d1ac2c14578e0 100644 (file)
@@ -39,7 +39,7 @@ class MailWorker extends AbstractWorker {
         * @see wcf\system\worker\IWorker::validate()
         */
        public function validate() {
-               WCF::getSession()->checkPermission('admin.user.canMailUser');
+               WCF::getSession()->checkPermissions(array('admin.user.canMailUser'));
                
                if (!isset($this->parameters['mailID'])) {
                        throw new SystemException("mailID missing");