UserMailForm overhaul
authorAlexander Ebert <ebert@woltlab.com>
Sun, 12 Aug 2012 15:46:20 +0000 (17:46 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 12 Aug 2012 15:46:20 +0000 (17:46 +0200)
wcfsetup/install/files/acp/templates/userMail.tpl
wcfsetup/install/files/lib/acp/form/UserMailForm.class.php

index bc92fd8ac8f1d068658358a3a479988f2b75d6a8..333e8f6f7893abe12be8d703ae82d79c56c59fe3 100644 (file)
@@ -48,7 +48,7 @@
                                <legend>{lang}wcf.acp.user.sendMail.markedUsers{/lang}</legend>
                                
                                <div>
-                                       {implode from=$users item=$user}<a href="{link controller='UserEdit' id=$user->userID}{/link}">{$user}</a>{/implode}
+                                       {implode from=$userList item=$user}<a href="{link controller='UserEdit' id=$user->userID}{/link}">{$user}</a>{/implode}
                                </div>
                        </fieldset>     
                {/if}
        <div class="formSubmit">
                <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
                <input type="hidden" name="action" value="{@$action}" />
-               <input type="hidden" name="userIDs" value="{@$userIDs}" />
+               <input type="hidden" name="userIDs" value="{implode from=$userIDs item=userID glue=','}{@$userID}{/implode}" />
        </div>
 </form>
 
index 02ea9878ad8f7b0b538c4101a5a3ddb3f5ce480d..c534e5f9a78aa234fbb8824450b3e0d745fac02d 100755 (executable)
@@ -14,25 +14,65 @@ use wcf\util\StringUtil;
  * Shows the user mail form.
  *
  * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
+ * @copyright  2001-2012 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage acp.form
  * @category   Community Framework
  */
 class UserMailForm extends ACPForm {
-       // system
-       public $neededPermissions = array('admin.user.canMailUser');
+       /**
+        * enable html for message body
+        * @var boolean
+        */
+       public $enableHTML = false;
        
-       // parameters
-       public $userIDs = array();
+       /**
+        * sender name
+        * @var string
+        */
+       public $from = '';
+       
+       /**
+        * list of group ids
+        * @var array<integer>
+        */
        public $groupIDs = array();
+       
+       /**
+        * list of groups
+        * @var array<wcf\data\user\group\UserGroup>
+        */
+       public $groups = array();
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.user.canMailUser');
+       
+       /**
+        * message subject
+        * @var string
+        */
        public $subject = '';
+       
+       /**
+        * message body
+        * @var string
+        */
        public $text = '';
-       public $from = '';
-       public $users = array();
-       public $groups = array();
-       public $enableHTML = 0;
+       
+       /**
+        * list of user ids
+        * @var array<integer>
+        */
+       public $userIDs = array();
+       
+       /**
+        * list of users
+        * @var wcf\data\user\UserList
+        */
+       public $userList = null;
        
        /**
         * @see wcf\page\IPage::readParameters()
@@ -54,7 +94,7 @@ class UserMailForm extends ACPForm {
                if (isset($_POST['subject'])) $this->subject = StringUtil::trim($_POST['subject']);
                if (isset($_POST['text'])) $this->text = StringUtil::trim($_POST['text']);
                if (isset($_POST['from'])) $this->from = StringUtil::trim($_POST['from']);
-               if (isset($_POST['enableHTML'])) $this->enableHTML = intval($_POST['enableHTML']);
+               if (isset($_POST['enableHTML'])) $this->enableHTML = true;
        }
        
        /**
@@ -63,13 +103,11 @@ class UserMailForm extends ACPForm {
        public function validate() {
                parent::validate();
                
-               if ($this->action == 'group') {
-                       if (!count($this->groupIDs)) {
-                               throw new UserInputException('groupIDs');
-                       }
+               if ($this->action == 'group' && empty($this->groupIDs)) {
+                       throw new UserInputException('groupIDs');
                }
-               if ($this->action == '') {
-                       if (empty($this->userIDs)) throw new IllegalLinkException();
+               if ($this->action == '' && empty($this->userIDs)) {
+                       throw new IllegalLinkException();
                }
                
                if (empty($this->subject)) {
@@ -116,7 +154,7 @@ class UserMailForm extends ACPForm {
        public function readData() {
                parent::readData();
                
-               if (!count($_POST)) {
+               if (empty($_POST)) {
                        // get marked user ids
                        if (empty($this->action)) {
                                // get type id
@@ -131,20 +169,17 @@ class UserMailForm extends ACPForm {
                                
                                // 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) && empty($this->users)) {
-                       $userList = new UserList();
-                       $userList->getConditionBuilder()->add("user.userID IN (?)", array($this->userIDs));
-                       $userList->sqlOrderBy = "user.username ASC";
-                       $userList->readObjects();
-                       
-                       $this->users = $userList->getObjects();
+               if (!empty($this->userIDs)) {
+                       $this->userList = new UserList();
+                       $this->userList->getConditionBuilder()->add("user_table.userID IN (?)", array($this->userIDs));
+                       $this->userList->sqlOrderBy = "user_table.username ASC";
+                       $this->userList->readObjects();
                }
                
                $this->groups = UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE));
@@ -157,14 +192,14 @@ class UserMailForm extends ACPForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign(array(
-                       'users' => $this->users,
-                       'groups' => $this->groups,
-                       'userIDs' => $this->userIDs,
+                       'enableHTML' => $this->enableHTML,
+                       'from' => $this->from,
                        'groupIDs' => $this->groupIDs,
+                       'groups' => $this->groups,
                        'subject' => $this->subject,
                        'text' => $this->text,
-                       'from' => $this->from,
-                       'enableHTML' => $this->enableHTML
+                       'userIDs' => $this->userIDs,
+                       'userList' => $this->userList
                ));
        }
 }