From: Alexander Ebert Date: Sun, 12 Aug 2012 15:46:20 +0000 (+0200) Subject: UserMailForm overhaul X-Git-Tag: 2.0.0_Beta_1~961^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7422f4e0327901965cdf37cc4ef16e3cd7753e2a;p=GitHub%2FWoltLab%2FWCF.git UserMailForm overhaul --- diff --git a/wcfsetup/install/files/acp/templates/userMail.tpl b/wcfsetup/install/files/acp/templates/userMail.tpl index bc92fd8ac8..333e8f6f78 100644 --- a/wcfsetup/install/files/acp/templates/userMail.tpl +++ b/wcfsetup/install/files/acp/templates/userMail.tpl @@ -48,7 +48,7 @@ {lang}wcf.acp.user.sendMail.markedUsers{/lang}
- {implode from=$users item=$user}{$user}{/implode} + {implode from=$userList item=$user}{$user}{/implode}
{/if} @@ -141,7 +141,7 @@
- +
diff --git a/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php b/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php index 02ea9878ad..c534e5f9a7 100755 --- a/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserMailForm.class.php @@ -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 * @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 + */ public $groupIDs = array(); + + /** + * list of groups + * @var array + */ + 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 + */ + 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 )); } }