* rewrite the test param of send() to includeMe.

This commit is contained in:
wangchunsheng
2011-10-29 13:05:11 +00:00
parent bc019927de
commit cb07c5608d
2 changed files with 15 additions and 11 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ EOT;
if(file_put_contents($configPath . 'zzzemail.php', $config))
{
/* Send test mail */
$this->mail->send($this->app->user->account, $this->lang->mail->subject, $this->lang->mail->content,"",'test');
$this->mail->send($this->app->user->account, $this->lang->mail->subject, $this->lang->mail->content,"", true);
if($this->mail->isError()) echo js::error($this->mail->getError());
echo js::confirm($this->lang->mail->confirmSave,$this->createLink('mail', 'set'));
}
+14 -10
View File
@@ -106,25 +106,29 @@ class mailModel extends model
* @param string $subject
* @param string $body
* @param array $ccList
* @param bool $includeMe
* @access public
* @return void
*/
public function send($toList, $subject, $body = '', $ccList = '', $test = '')
public function send($toList, $subject, $body = '', $ccList = '', $includeMe = false)
{
if(!$this->config->mail->turnon) return;
/* Process toList and ccList, remove current user from them. If toList is empty, use the first cc as to. */
$account = $this->app->user->account;
$toList = $toList ? explode(',', str_replace(' ', '', $toList)) : array();
$ccList = $ccList ? explode(',', str_replace(' ', '', $ccList)) : array();
if($includeMe == false)
{
$account = $this->app->user->account;
$toList = $toList ? explode(',', str_replace(' ', '', $toList)) : array();
$ccList = $ccList ? explode(',', str_replace(' ', '', $ccList)) : array();
foreach($toList as $key => $to) if(trim($to) == $account or !trim($to)) unset($toList[$key]);
foreach($ccList as $key => $cc) if(trim($cc) == $account or !trim($cc)) unset($ccList[$key]);
foreach($toList as $key => $to) if(trim($to) == $account or !trim($to)) unset($toList[$key]);
foreach($ccList as $key => $cc) if(trim($cc) == $account or !trim($cc)) unset($ccList[$key]);
if(!$toList and !$ccList) return;
if(!$toList and $ccList) $toList = array(array_shift($ccList));
$toList = join(',', $toList);
$ccList = join(',', $ccList);
if(!$toList and !$ccList) return;
if(!$toList and $ccList) $toList = array(array_shift($ccList));
$toList = join(',', $toList);
$ccList = join(',', $ccList);
}
/* Get realname and email of users. */
$this->loadModel('user');