From 7ac6afe616b44bec58c4e37fc6bd272f4e4c350a Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 25 Nov 2016 15:32:28 +0800 Subject: [PATCH] * finish task #2719,2729. --- module/bug/control.php | 89 ++++---------------- module/bug/model.php | 65 +++++++++++++++ module/bug/view/sendmail.html.php | 8 +- module/common/model.php | 1 + module/common/view/mail.footer.html.php | 25 ++++-- module/common/view/mail.header.html.php | 2 +- module/mail/control.php | 9 ++- module/mail/lang/en.php | 2 + module/mail/lang/zh-cn.php | 2 + module/mail/model.php | 2 +- module/mail/view/edit.html.php | 36 ++++++--- module/mail/view/sendcloud.html.php | 4 + module/project/control.php | 58 +------------ module/project/view/sendmail.html.php | 32 -------- module/report/control.php | 3 + module/report/model.php | 2 + module/story/control.php | 103 ++++-------------------- module/story/model.php | 77 ++++++++++++++++++ module/story/view/sendmail.html.php | 8 +- module/task/control.php | 88 ++++---------------- module/task/model.php | 66 +++++++++++++++ module/task/view/sendmail.html.php | 8 +- module/testtask/control.php | 72 +---------------- module/testtask/model.php | 74 +++++++++++++++++ module/testtask/view/sendmail.html.php | 8 +- 25 files changed, 420 insertions(+), 424 deletions(-) delete mode 100644 module/project/view/sendmail.html.php diff --git a/module/bug/control.php b/module/bug/control.php index d141e48530..8c226d887e 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -221,7 +221,7 @@ class bug extends control } $actionID = $this->action->create('bug', $bugID, 'Opened'); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); $location = $this->createLink('bug', 'browse', "productID={$this->post->product}&branch=$branch&type=byModule¶m={$this->post->module}"); $response['locate'] = isset($_SESSION['bugList']) ? $this->session->bugList : $location; @@ -361,7 +361,7 @@ class bug extends control if(!empty($_POST)) { $actions = $this->bug->batchCreate($productID, $branch); - foreach($actions as $bugID => $actionID) $this->sendmail($bugID, $actionID); + foreach($actions as $bugID => $actionID) $this->bug->sendmail($bugID, $actionID); die(js::locate($this->session->bugList, 'parent')); } @@ -502,7 +502,7 @@ class bug extends control if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; $actionID = $this->action->create('bug', $bugID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); } $bug = $this->bug->getById($bugID); @@ -597,7 +597,7 @@ class bug extends control $actionID = $this->action->create('bug', $bugID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); $bug = $this->bug->getById($bugID); if($bug->toTask != 0) @@ -701,7 +701,7 @@ class bug extends control if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('bug', $bugID, 'Assigned', $this->post->comment, $this->post->assignedTo); $this->action->logHistory($actionID, $changes); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent')); die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); @@ -737,7 +737,7 @@ class bug extends control $this->loadModel('action'); $actionID = $this->action->create('bug', $bugID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); } } die(js::locate($this->session->bugList, 'parent')); @@ -763,7 +763,7 @@ class bug extends control if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('bug', $bugID, 'Assigned', $this->post->comment, $this->post->assignedTo); $this->action->logHistory($actionID, $changes); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); } } if($type == 'product') die(js::locate($this->createLink('bug', 'browse', "productID=$projectID"))); @@ -785,7 +785,7 @@ class bug extends control $this->bug->confirm($bugID); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('bug', $bugID, 'bugConfirmed', $this->post->comment); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent')); die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } @@ -818,7 +818,7 @@ class bug extends control foreach($bugIDList as $bugID) { $actionID = $this->action->create('bug', $bugID, 'bugConfirmed'); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); } die(js::locate($this->session->bugList, 'parent')); } @@ -840,7 +840,7 @@ class bug extends control $fileAction = !empty($files) ? $this->lang->addFiles . join(',', $files) . "\n" : ''; $actionID = $this->action->create('bug', $bugID, 'Resolved', $fileAction . $this->post->comment, $this->post->resolution . ($this->post->duplicateBug ? ':' . (int)$this->post->duplicateBug : '')); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); $bug = $this->bug->getById($bugID); if($bug->toTask != 0) @@ -896,7 +896,7 @@ class bug extends control foreach($bugIDList as $bugID) { $actionID = $this->action->create('bug', $bugID, 'Resolved', '', $resolution); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); } die(js::locate($this->session->bugList, 'parent')); } @@ -916,7 +916,7 @@ class bug extends control if(dao::isError()) die(js::error(dao::getError())); $files = $this->loadModel('file')->saveUpload('bug', $bugID); $actionID = $this->action->create('bug', $bugID, 'Activated', $this->post->comment); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent')); die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } @@ -951,7 +951,7 @@ class bug extends control $this->bug->close($bugID); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('bug', $bugID, 'Closed', $this->post->comment); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent')); die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } @@ -1083,7 +1083,7 @@ class bug extends control $this->bug->close($bugID); $actionID = $this->action->create('bug', $bugID, 'Closed'); - $this->sendmail($bugID, $actionID); + $this->bug->sendmail($bugID, $actionID); } if(isset($skipBugs)) echo js::alert(sprintf($this->lang->bug->skipClose, join(',', $skipBugs))); @@ -1263,64 +1263,6 @@ class bug extends control $this->display(); } - /** - * Send email. - * - * @param int $bugID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($bugID, $actionID) - { - /* Reset $this->output. */ - $this->clear(); - - /* Set toList and ccList. */ - $bug = $this->bug->getByID($bugID); - $productName = $this->products[$bug->product]; - $toList = $bug->assignedTo; - $ccList = trim($bug->mailto, ','); - if($toList == '') - { - if($ccList == '') return; - if(strpos($ccList, ',') === false) - { - $toList = $ccList; - $ccList = ''; - } - else - { - $commaPos = strpos($ccList, ','); - $toList = substr($ccList, 0, $commaPos); - $ccList = substr($ccList, $commaPos + 1); - } - } - elseif(strtolower($toList) == 'closed') - { - $toList = $bug->resolvedBy; - } - - /* Get action info. */ - $actions = $this->action->getList('bug', $bugID); - $action = zget($actions, $actionID, null); - $history = $this->action->getHistory($actionID); - $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); - if(strtolower($action->action) == 'opened') $action->comment = $bug->steps; - - /* Create the mail content. */ - if($action->action == 'opened') $action->comment = ''; - $this->view->bug = $bug; - $this->view->action = $action; - $this->view->users = $this->user->getPairs('noletter'); - - $mailContent = $this->parse($this->moduleName, 'sendmail'); - - /* Send it. */ - $this->loadModel('mail')->send($toList, 'BUG #'. $bug->id . ' ' . $bug->title . ' - ' . $productName, $mailContent, $ccList); - if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); - } - /** * Get data to export * @@ -1333,6 +1275,7 @@ class bug extends control { if($_POST) { + $this->loadModel('file'); $bugLang = $this->lang->bug; $bugConfig = $this->config->bug; @@ -1469,7 +1412,7 @@ class bug extends control { foreach($relatedFiles[$bug->id] as $file) { - $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname; + $fileURL = common::getSysURL() . $this->file->webPath . $file->pathname; $bug->files .= html::a($fileURL, $file->title, '_blank') . '
'; } } diff --git a/module/bug/model.php b/module/bug/model.php index 9aac978430..ed794fc81b 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2163,4 +2163,69 @@ class bugModel extends model echo ''; } } + + /** + * Send mail + * + * @param int $bugID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($bugID, $actionID) + { + $this->loadModel('mail'); + $bug = $this->getByID($bugID); + $productName = $this->loadModel('product')->getById($bug->product)->name; + $users = $this->loadModel('user')->getPairs('noletter'); + + /* Get action info. */ + $action = $this->loadModel('action')->getById($actionID); + $history = $this->action->getHistory($actionID); + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + + /* Get mail content. */ + $modulePath = $this->app->getModulePath(); + $oldcwd = getcwd(); + $viewFile = $modulePath . 'view/sendmail.html.php'; + chdir($modulePath . 'view'); + if(file_exists($modulePath . 'ext/view/sendmail.html.php')) + { + $viewFile = $modulePath . 'ext/view/sendmail.html.php'; + chdir($modulePath . 'ext/view'); + } + ob_start(); + include $viewFile; + foreach(glob($modulePath . 'ext/view/sendmail.*.html.hook.php') as $hookFile) include $hookFile; + $mailContent = ob_get_contents(); + ob_end_clean(); + chdir($oldcwd); + + /* Set toList and ccList. */ + $toList = $bug->assignedTo; + $ccList = trim($bug->mailto, ','); + if(empty($toList)) + { + if(empty($ccList)) return; + if(strpos($ccList, ',') === false) + { + $toList = $ccList; + $ccList = ''; + } + else + { + $commaPos = strpos($ccList, ','); + $toList = substr($ccList, 0, $commaPos); + $ccList = substr($ccList, $commaPos + 1); + } + } + elseif(strtolower($toList) == 'closed') + { + $toList = $bug->resolvedBy; + } + + /* Send it. */ + $this->mail->send($toList, 'BUG #'. $bug->id . ' ' . $bug->title . ' - ' . $productName, $mailContent, $ccList); + if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); + } } diff --git a/module/bug/view/sendmail.html.php b/module/bug/view/sendmail.html.php index 2d79351921..bd70d8ee20 100644 --- a/module/bug/view/sendmail.html.php +++ b/module/bug/view/sendmail.html.php @@ -11,12 +11,12 @@ */ ?> id . ' ' . $bug->title;?> - +app->getModuleRoot() . 'common/view/mail.header.html.php';?> - +
createLink('bug', 'view', "bugID=$bug->id"), $mailTitle, '', "style='color: #333'");?>config->mail, 'domain', common::getSysURL()) . helper::createLink('bug', 'view', "bugID=$bug->id"), $mailTitle, '', "style='color: #333; text-decoration: underline;'");?>
@@ -24,9 +24,9 @@
- bug->legendSteps;?> + lang->bug->legendSteps;?>
steps;?>
- +app->getModuleRoot() . 'common/view/mail.footer.html.php';?> diff --git a/module/common/model.php b/module/common/model.php index e39f783485..daf473c4cb 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -870,6 +870,7 @@ class commonModel extends model if(strtolower($key) == 'assigneddate') continue; if(strtolower($key) == 'editedby') continue; if(strtolower($key) == 'editeddate') continue; + if(strtolower($key) == 'uid') continue; if($magicQuote) $value = stripslashes($value); if($value != stripslashes($old->$key)) diff --git a/module/common/view/mail.footer.html.php b/module/common/view/mail.footer.html.php index f4db14c5b2..0ba89cb8d1 100644 --- a/module/common/view/mail.footer.html.php +++ b/module/common/view/mail.footer.html.php @@ -1,20 +1,33 @@ +app->getModuleRoot() . 'ext/view/' . basename(__FILE__); +if(file_exists($extViewFile)) +{ + include $extViewFile; + return; +} +?> + comment)):?> + + +
+ lang->comment?> +
comment?>
+
+ + + - getExtViewFile(__FILE__)){include $extView; return helper::cd();}?> actor])) $action->actor = $users[$action->actor];?> extra])) $action->extra = $users[$action->extra];?>  action->printAction($action);?> - comment) or !empty($action->history)):?> + history)):?>
action->printChanges($action->objectType, $action->history);?>
- comment)): ?> -

comment;?>

- - diff --git a/module/common/view/mail.header.html.php b/module/common/view/mail.header.html.php index a9375b5b32..98a77851b6 100644 --- a/module/common/view/mail.header.html.php +++ b/module/common/view/mail.header.html.php @@ -16,7 +16,7 @@ if($onlybody) $_GET['onlybody'] = 'no'; - +
company->name ?>app->company->name ?>
diff --git a/module/mail/control.php b/module/mail/control.php index 7d8a5b82d2..2df6cb4464 100755 --- a/module/mail/control.php +++ b/module/mail/control.php @@ -68,6 +68,7 @@ class mail extends control echo ""; $mailConfig = $this->mail->autoDetect($this->post->fromAddress); $mailConfig->fromAddress = $this->post->fromAddress; + $mailConfig->domain = common::getSysURL(); $this->session->set('mailConfig', $mailConfig); die(js::locate(inlink('edit'), 'parent')); @@ -106,12 +107,15 @@ class mail extends control $this->locate(inlink('detect')); } + $mailConfig->domain = isset($this->config->mail->domain) ? $this->config->mail->domain : common::getSysURL(); + $this->view->title = $this->lang->mail->common . $this->lang->colon . $this->lang->mail->edit; $this->view->position[] = html::a(inlink('index'), $this->lang->mail->common); $this->view->position[] = $this->lang->mail->edit; $this->view->mailExist = $this->mail->mailExist(); $this->view->mailConfig = $mailConfig; + $this->view->openssl = extension_loaded('openssl'); $this->display(); } @@ -133,6 +137,7 @@ class mail extends control $mailConfig->async = $this->post->async; $mailConfig->fromAddress = trim($this->post->fromAddress); $mailConfig->fromName = trim($this->post->fromName); + $mailConfig->domain = trim($this->post->domain); $mailConfig->smtp->host = trim($this->post->host); $mailConfig->smtp->port = trim($this->post->port); $mailConfig->smtp->auth = $this->post->auth; @@ -195,6 +200,7 @@ class mail extends control $mailConfig->async = $this->post->async; $mailConfig->fromAddress = ''; $mailConfig->fromName = ''; + $mailConfig->domain = trim($this->post->domain); $mailConfig->sendcloud->accessKey = trim($this->post->accessKey); $mailConfig->sendcloud->secretKey = trim($this->post->secretKey); @@ -207,13 +213,14 @@ class mail extends control die(js::reload('parent')); } - $mailConfig = ''; + $mailConfig = new stdclass(); if($this->config->mail->turnon) { $mailConfig = $this->config->mail->sendcloud; $mailConfig->fromAddress = $this->config->mail->fromAddress; $mailConfig->fromName = $this->config->mail->fromName; $mailConfig->turnon = $this->config->mail->turnon; + $mailConfig->domain = isset($this->config->mail->domain) ? $this->config->mail->domain : common::getSysURL(); $mailConfig->async = isset($this->config->mail->async) ? $this->config->mail->async : 0; } diff --git a/module/mail/lang/en.php b/module/mail/lang/en.php index 3ca09b5210..40665b2d60 100755 --- a/module/mail/lang/en.php +++ b/module/mail/lang/en.php @@ -16,6 +16,7 @@ $lang->mail->turnon = 'Turn On'; $lang->mail->async = 'Asynchronous'; $lang->mail->fromAddress = 'Email Address'; $lang->mail->fromName = 'Sender'; +$lang->mail->domain = 'Domain'; $lang->mail->host = 'SMTP Server'; $lang->mail->port = 'SMTP Port'; $lang->mail->auth = 'Verification Required'; @@ -74,6 +75,7 @@ $lang->mail->sendmailTips = 'Note: Email author will not receive this email.'; $lang->mail->needConfigure = 'Email configuration is not found. Please cinfigure the Email first.'; $lang->mail->nofsocket = 'fsocket related function has been deactivated. Mails cannot send out. Please modify allow_url_fopen in php.ini to turn on Onopenssl, and restart Apache.'; $lang->mail->noOpenssl = 'Please turn on Onopenssl, and restart Apache.'; +$lang->mail->disableSecure = 'No openssl, disable ssl and tls.'; $lang->mail->sendCloudFail = 'Failed. Reason:'; $lang->mail->sendCloudHelp = <<1、Notice SendCloud是SendCloud的Team通知服务。具体可以到notice.sendcloud.net查看

diff --git a/module/mail/lang/zh-cn.php b/module/mail/lang/zh-cn.php index 00b08f6769..ea81b4c20d 100755 --- a/module/mail/lang/zh-cn.php +++ b/module/mail/lang/zh-cn.php @@ -16,6 +16,7 @@ $lang->mail->turnon = '是否打开'; $lang->mail->async = '异步发送'; $lang->mail->fromAddress = '发信邮箱'; $lang->mail->fromName = '发信人'; +$lang->mail->domain = '发信域名'; $lang->mail->host = 'smtp服务器'; $lang->mail->port = 'smtp端口号'; $lang->mail->auth = '是否需要验证'; @@ -74,6 +75,7 @@ $lang->mail->sendmailTips = '提示:系统不会为当前操作者发信。' $lang->mail->needConfigure = '无法找到邮件配置信息,请先配置邮件发送参数。'; $lang->mail->nofsocket = 'fsocket相关函数被禁用,不能发信!请在php.ini中修改allow_url_fopen为On,打开openssl扩展。 保存并重新启动apache。'; $lang->mail->noOpenssl = 'ssl和tls加密,请打开openssl扩展。 保存并重新启动apache。'; +$lang->mail->disableSecure = '没有openssl扩展,禁用ssl和tls加密'; $lang->mail->sendCloudFail = '操作失败,原因:'; $lang->mail->sendCloudHelp = <<1、Notice SendCloud是SendCloud的团队通知服务。具体可以到notice.sendcloud.net查看

diff --git a/module/mail/model.php b/module/mail/model.php index 4220bad0e3..be6f0292b0 100644 --- a/module/mail/model.php +++ b/module/mail/model.php @@ -290,7 +290,7 @@ class mailModel extends model $this->clear(); /* Replace full webPath image for mail. */ - if(strpos($body, 'src="data/upload')) $body = preg_replace('/server->http_host . $this->config->webRoot . 'data/upload', $body); + if(strpos($body, 'src="data/upload')) $body = preg_replace('/config->mail, 'domain', common::getSysURL()) . $this->config->webRoot . 'data/upload', $body); try { diff --git a/module/mail/view/edit.html.php b/module/mail/view/edit.html.php index 2fccaa63df..e38e91057e 100755 --- a/module/mail/view/edit.html.php +++ b/module/mail/view/edit.html.php @@ -25,6 +25,7 @@ include '../../common/view/header.html.php';
+ global->cron)):?> @@ -35,38 +36,51 @@ include '../../common/view/header.html.php'; - + - + + + + - + - + + + - + - + - - - - - + diff --git a/module/mail/view/sendcloud.html.php b/module/mail/view/sendcloud.html.php index 605f94d5cb..0f952a4062 100755 --- a/module/mail/view/sendcloud.html.php +++ b/module/mail/view/sendcloud.html.php @@ -32,6 +32,10 @@ include '../../common/view/header.html.php'; + + + + - - - - - - diff --git a/module/report/control.php b/module/report/control.php index a2a042033c..819b34bf2f 100644 --- a/module/report/control.php +++ b/module/report/control.php @@ -206,7 +206,10 @@ class report extends control /* Get email content and title.*/ $this->view->mail = $mail; + $oldViewType = $this->viewType; + if($oldViewType == 'json') $this->viewType = 'html'; $mailContent = $this->parse('report', 'dailyreminder'); + $this->viewType == $oldViewType; /* Send email.*/ echo date('Y-m-d H:i:s') . " sending to $user, "; diff --git a/module/report/model.php b/module/report/model.php index b796015fc1..c5c7c84b65 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -295,6 +295,8 @@ class reportModel extends model */ public function getSysURL() { + if(isset($this->config->mail->domain)) return $this->config->mail->domain; + /* Ger URL when run in shell. */ if(PHP_SAPI == 'cli') { diff --git a/module/story/control.php b/module/story/control.php index 87db2fdf87..7d0eb11ba9 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -78,7 +78,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Frombug', '', $bugID); } - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); if($this->post->newStory) { $response['message'] = $this->lang->story->successSaved . $this->lang->story->newStory; @@ -212,7 +212,7 @@ class story extends control $mails = $this->story->batchCreate($productID, $branch); if(dao::isError()) die(js::error(dao::getError())); - foreach($mails as $mail) $this->sendmail($mail->storyID, $mail->actionID); + foreach($mails as $mail) $this->story->sendmail($mail->storyID, $mail->actionID); die(js::locate($this->createLink('product', 'browse', "productID=$productID&branch=$branch"), 'parent')); } @@ -341,7 +341,7 @@ class story extends control $action = !empty($changes) ? 'Edited' : 'Commented'; $actionID = $this->action->create('story', $storyID, $action, $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent')); } @@ -385,7 +385,7 @@ class story extends control $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } } die(js::locate($this->session->storyList, 'parent')); @@ -488,7 +488,7 @@ class story extends control if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; $actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent')); } @@ -523,7 +523,7 @@ class story extends control $this->story->activate($storyID); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('story', $storyID, 'Activated', $this->post->comment); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent')); @@ -634,7 +634,7 @@ class story extends control if($this->post->closedReason != '' and strpos('done,postponed,subdivided', $this->post->closedReason) !== false) $result = 'pass'; $actionID = $this->action->create('story', $storyID, 'Reviewed', $this->post->comment, ucfirst($result)); $this->action->logHistory($actionID, array()); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); if($this->post->result == 'reject') { $this->action->create('story', $storyID, 'Closed', '', ucfirst($this->post->closedReason)); @@ -687,7 +687,7 @@ class story extends control $actions = $this->story->batchReview($storyIDList, $result, $reason); if(dao::isError()) die(js::error(dao::getError())); - foreach($actions as $storyID => $actionID) $this->sendmail($storyID, $actionID); + foreach($actions as $storyID => $actionID) $this->story->sendmail($storyID, $actionID); die(js::locate($this->session->storyList, 'parent')); } @@ -706,7 +706,7 @@ class story extends control if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comment, ucfirst($this->post->closedReason) . ($this->post->duplicateStory ? ':' . (int)$this->post->duplicateStory : '')); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate(inlink('view', "storyID=$storyID"), 'parent')); } @@ -753,7 +753,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Closed', htmlspecialchars($this->post->comments[$storyID]), ucfirst($this->post->closedReasons[$storyID]) . ($this->post->duplicateStoryIDList[$storyID] ? ':' . (int)$this->post->duplicateStoryIDList[$storyID] : '')); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } } die(js::locate($this->session->storyList, 'parent')); @@ -827,7 +827,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } die(js::reload('parent')); } @@ -848,7 +848,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } die(js::reload('parent')); } @@ -869,7 +869,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } die(js::reload('parent')); } @@ -890,7 +890,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } die(js::locate($this->session->storyList, 'parent')); } @@ -911,7 +911,7 @@ class story extends control { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($storyID, $actionID); + $this->story->sendmail($storyID, $actionID); } } die(js::locate($this->session->storyList)); @@ -1225,76 +1225,6 @@ class story extends control echo $story->module; } - /** - * Send email. - * - * @param int $storyID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($storyID, $actionID) - { - /* Reset $this->output. */ - $this->clear(); - - $story = $this->story->getById($storyID); - $productName = $this->product->getById($story->product)->name; - - /* Get actions. */ - $actions = $this->action->getList('story', $storyID); - $action = zget($actions, $actionID, null); - $history = $this->action->getHistory($actionID); - $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); - if(strtolower($action->action) == 'opened') $action->comment = $story->spec; - - /* Set toList and ccList. */ - $toList = $story->assignedTo; - $ccList = str_replace(' ', '', trim($story->mailto, ',')); - - /* If the action is changed or reviewed, mail to the project team. */ - if(strtolower($action->action) == 'changed' or strtolower($action->action) == 'reviewed') - { - $prjMembers = $this->story->getProjectMembers($storyID); - if($prjMembers) - { - $ccList .= ',' . join(',', $prjMembers); - $ccList = ltrim($ccList, ','); - } - } - - if($toList == '') - { - if($ccList == '') return; - if(strpos($ccList, ',') === false) - { - $toList = $ccList; - $ccList = ''; - } - else - { - $commaPos = strpos($ccList, ','); - $toList = substr($ccList, 0, $commaPos); - $ccList = substr($ccList, $commaPos + 1); - } - } - elseif($toList == 'closed') - { - $toList = $story->openedBy; - } - - /* Get the mail content. */ - if($action->action == 'opened') $action->comment = ''; - $this->view->story = $story; - $this->view->action = $action; - $this->view->users = $this->user->getPairs('noletter'); - - $mailContent = $this->parse($this->moduleName, 'sendmail'); - - /* Send it. */ - $this->loadModel('mail')->send($toList, 'STORY #' . $story->id . ' ' . $story->title . ' - ' . $productName, $mailContent, $ccList); - if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); - } /** * The report page. * @@ -1349,6 +1279,7 @@ class story extends control /* format the fields of every story in order to export data. */ if($_POST) { + $this->loadModel('file'); $storyLang = $this->lang->story; $storyConfig = $this->config->story; @@ -1489,7 +1420,7 @@ class story extends control { foreach($relatedFiles[$story->id] as $file) { - $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname; + $fileURL = common::getSysURL() . $this->file->webPath . $file->pathname; $story->files .= html::a($fileURL, $file->title, '_blank') . '
'; } } diff --git a/module/story/model.php b/module/story/model.php index f5ec41a913..9d734fb990 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2306,4 +2306,81 @@ class storyModel extends model return $forceReview; } + + /** + * Send mail + * + * @param int $storyID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($storyID, $actionID) + { + $this->loadModel('mail'); + $story = $this->getById($storyID); + $productName = $this->loadModel('product')->getById($story->product)->name; + $users = $this->loadModel('user')->getPairs('noletter'); + + /* Get actions. */ + $action = $this->loadModel('action')->getById($actionID); + $history = $this->action->getHistory($actionID); + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + + /* Get mail content. */ + $modulePath = $this->app->getModulePath(); + $oldcwd = getcwd(); + $viewFile = $modulePath . 'view/sendmail.html.php'; + chdir($modulePath . 'view'); + if(file_exists($modulePath . 'ext/view/sendmail.html.php')) + { + $viewFile = $modulePath . 'ext/view/sendmail.html.php'; + chdir($modulePath . 'ext/view'); + } + ob_start(); + include $viewFile; + foreach(glob($modulePath . 'ext/view/sendmail.*.html.hook.php') as $hookFile) include $hookFile; + $mailContent = ob_get_contents(); + ob_end_clean(); + chdir($oldcwd); + + /* Set toList and ccList. */ + $toList = $story->assignedTo; + $ccList = str_replace(' ', '', trim($story->mailto, ',')); + + /* If the action is changed or reviewed, mail to the project team. */ + if(strtolower($action->action) == 'changed' or strtolower($action->action) == 'reviewed') + { + $prjMembers = $this->getProjectMembers($storyID); + if($prjMembers) + { + $ccList .= ',' . join(',', $prjMembers); + $ccList = ltrim($ccList, ','); + } + } + + if(empty($toList)) + { + if(empty($ccList)) return; + if(strpos($ccList, ',') === false) + { + $toList = $ccList; + $ccList = ''; + } + else + { + $commaPos = strpos($ccList, ','); + $toList = substr($ccList, 0, $commaPos); + $ccList = substr($ccList, $commaPos + 1); + } + } + elseif($toList == 'closed') + { + $toList = $story->openedBy; + } + + /* Send it. */ + $this->mail->send($toList, 'STORY #' . $story->id . ' ' . $story->title . ' - ' . $productName, $mailContent, $ccList); + if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); + } } diff --git a/module/story/view/sendmail.html.php b/module/story/view/sendmail.html.php index c037e6cab7..27b9370106 100644 --- a/module/story/view/sendmail.html.php +++ b/module/story/view/sendmail.html.php @@ -11,12 +11,12 @@ */ ?> id . ' ' . $story->title;?> - +app->getModuleRoot() . 'common/view/mail.header.html.php';?> @@ -24,9 +24,9 @@ - +app->getModuleRoot() . 'common/view/mail.footer.html.php';?> diff --git a/module/task/control.php b/module/task/control.php index 61d7371ad2..7223d90344 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -96,7 +96,7 @@ class task extends control $taskID = $taskID['id']; $actionID = $this->action->create('task', $taskID, 'Opened', ''); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } /* If link from no head then reload*/ @@ -179,7 +179,7 @@ class task extends control $mails = $this->task->batchCreate($projectID); if(dao::isError()) die(js::error(dao::getError())); - foreach($mails as $mail) $this->sendmail($mail->taskID, $mail->actionID); + foreach($mails as $mail) $this->task->sendmail($mail->taskID, $mail->actionID); /* Locate the browser. */ if($iframe) die(js::reload('parent.parent')); @@ -260,7 +260,7 @@ class task extends control $fileAction = !empty($files) ? $this->lang->addFiles . join(',', $files) . "\n" : ''; $actionID = $this->action->create('task', $taskID, $action, $fileAction . $this->post->comment); if(!empty($changes)) $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } if($task->fromBug != 0) @@ -313,7 +313,7 @@ class task extends control $actionID = $this->loadModel('action')->create('task', $taskID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); $task = $this->task->getById($taskID); if($task->fromBug != 0) @@ -412,7 +412,7 @@ class task extends control if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); @@ -445,7 +445,7 @@ class task extends control $this->loadModel('action'); $actionID = $this->action->create('task', $taskID, 'Edited'); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } } die(js::reload('parent')); @@ -472,7 +472,7 @@ class task extends control if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } die(js::locate($this->createLink('project', 'task', "projectID=$project"), 'parent')); } @@ -570,7 +570,7 @@ class task extends control $act = $this->post->left == 0 ? 'Finished' : 'Started'; $actionID = $this->action->create('task', $taskID, $act, $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } /* Remind whether to update status of the bug, if task which from that bug has been finished. */ @@ -722,7 +722,7 @@ class task extends control $fileAction = !empty($files) ? $this->lang->addFiles . join(',', $files) . "\n" : ''; $actionID = $this->action->create('task', $taskID, 'Finished', $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } if($this->task->needUpdateBugStatus($task)) @@ -804,7 +804,7 @@ class task extends control $act = $this->post->left == 0 ? 'Finished' : 'Restarted'; $actionID = $this->action->create('task', $taskID, $act, $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); @@ -837,7 +837,7 @@ class task extends control { $actionID = $this->action->create('task', $taskID, 'Closed', $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); @@ -883,7 +883,7 @@ class task extends control { $actionID = $this->action->create('task', $taskID, 'Closed', ''); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } } if(isset($skipTasks)) echo js::alert(sprintf($this->lang->task->error->skipClose, join(',', $skipTasks))); @@ -912,7 +912,7 @@ class task extends control { $actionID = $this->action->create('task', $taskID, 'Canceled', $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); @@ -946,7 +946,7 @@ class task extends control { $actionID = $this->action->create('task', $taskID, 'Activated', $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID); + $this->task->sendmail($taskID, $actionID); } if(isonlybody()) die(js::closeModal('parent.parent', 'this')); die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); @@ -985,63 +985,6 @@ class task extends control } } - /** - * Send email. - * - * @param int $taskID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($taskID, $actionID) - { - /* Reset $this->output. */ - $this->clear(); - - /* Set toList and ccList. */ - $task = $this->task->getById($taskID); - $projectName = $this->project->getById($task->project)->name; - $users = $this->loadModel('user')->getPairs('noletter'); - $toList = $task->assignedTo; - $ccList = trim($task->mailto, ','); - - if($toList == '') - { - if($ccList == '') return; - if(strpos($ccList, ',') === false) - { - $toList = $ccList; - $ccList = ''; - } - else - { - $commaPos = strpos($ccList, ','); - $toList = substr($ccList, 0, $commaPos); - $ccList = substr($ccList, $commaPos + 1); - } - } - elseif(strtolower($toList) == 'closed') - { - $toList = $task->finishedBy; - } - - /* Get action info. */ - $action = $this->loadModel('action')->getById($actionID); - $history = $this->action->getHistory($actionID); - $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); - - /* Create the email content. */ - $this->view->task = $task; - $this->view->action = $action; - $this->view->users = $users; - - $mailContent = $this->parse($this->moduleName, 'sendmail'); - - /* Send emails. */ - $this->loadModel('mail')->send($toList, 'TASK#' . $task->id . ' ' . $task->name . ' - ' . $projectName, $mailContent, $ccList); - if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); - } - /** * AJAX: return tasks of a user in html select. * @@ -1139,6 +1082,7 @@ class task extends control { if($_POST) { + $this->loadModel('file'); $taskLang = $this->lang->task; $taskConfig = $this->config->task; @@ -1217,7 +1161,7 @@ class task extends control $task->files = ''; foreach($relatedFiles[$task->id] as $file) { - $fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname; + $fileURL = common::getSysURL() . $this->file->webPath . $file->pathname; $task->files .= html::a($fileURL, $file->title, '_blank') . '
'; } } diff --git a/module/task/model.php b/module/task/model.php index 07bf6613bc..12ca40708c 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1696,4 +1696,70 @@ class taskModel extends model echo ''; } } + + /** + * Send mail. + * + * @param int $taskID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($taskID, $actionID) + { + $this->loadModel('mail'); + $task = $this->getById($taskID); + $projectName = $this->loadModel('project')->getById($task->project)->name; + $users = $this->loadModel('user')->getPairs('noletter'); + + /* Get action info. */ + $action = $this->loadModel('action')->getById($actionID); + $history = $this->action->getHistory($actionID); + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + + /* Get mail content. */ + $modulePath = $this->app->getModulePath(); + $oldcwd = getcwd(); + $viewFile = $modulePath . 'view/sendmail.html.php'; + chdir($modulePath . 'view'); + if(file_exists($modulePath . 'ext/view/sendmail.html.php')) + { + $viewFile = $modulePath . 'ext/view/sendmail.html.php'; + chdir($modulePath . 'ext/view'); + } + ob_start(); + include $viewFile; + foreach(glob($modulePath . 'ext/view/sendmail.*.html.hook.php') as $hookFile) include $hookFile; + $mailContent = ob_get_contents(); + ob_end_clean(); + chdir($oldcwd); + + /* Set toList and ccList. */ + $toList = $task->assignedTo; + $ccList = trim($task->mailto, ','); + + if(empty($toList)) + { + if(empty($ccList)) return; + if(strpos($ccList, ',') === false) + { + $toList = $ccList; + $ccList = ''; + } + else + { + $commaPos = strpos($ccList, ','); + $toList = substr($ccList, 0, $commaPos); + $ccList = substr($ccList, $commaPos + 1); + } + } + elseif(strtolower($toList) == 'closed') + { + $toList = $task->finishedBy; + } + + /* Send emails. */ + $this->mail->send($toList, 'TASK#' . $task->id . ' ' . $task->name . ' - ' . $projectName, $mailContent, $ccList); + if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); + } } diff --git a/module/task/view/sendmail.html.php b/module/task/view/sendmail.html.php index b19c009899..2a7b0dda6d 100644 --- a/module/task/view/sendmail.html.php +++ b/module/task/view/sendmail.html.php @@ -11,12 +11,12 @@ */ ?> id . ' ' . $task->name;?> - +app->getModuleRoot() . 'common/view/mail.header.html.php';?> @@ -24,9 +24,9 @@ - +app->getModuleRoot() . 'common/view/mail.footer.html.php';?> diff --git a/module/testtask/control.php b/module/testtask/control.php index 19fd54e9d3..a1ab1124eb 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -96,7 +96,7 @@ class testtask extends control $taskID = $this->testtask->create(); if(dao::isError()) die(js::error(dao::getError())); $actionID = $this->loadModel('action')->create('testtask', $taskID, 'opened'); - $this->sendmail($taskID, $actionID, 'opened'); + $this->testtask->sendmail($taskID, $actionID); die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent')); } @@ -365,7 +365,7 @@ class testtask extends control $this->action->logHistory($actionID, $changes); /* send mail.*/ - $this->sendmail($taskID, $actionID, 'edited'); + $this->testtask->sendmail($taskID, $actionID); } die(js::locate(inlink('view', "taskID=$taskID"), 'parent')); } @@ -452,7 +452,7 @@ class testtask extends control { $actionID = $this->action->create('testtask', $taskID, 'Closed', $this->post->comment); $this->action->logHistory($actionID, $changes); - $this->sendmail($taskID, $actionID, 'closed'); + $this->testtask->sendmail($taskID, $actionID); } if(isonlybody()) die(js::reload('parent.parent')); @@ -822,70 +822,4 @@ class testtask extends control ->exec(); die(js::locate($this->session->caseList)); } - - /** - * Send mail. - * - * @param int $testtaskID - * @param int $actionID - * @param string $action - * @access public - * @return void - */ - public function sendmail($testtaskID, $actionID, $actionType) - { - /* Reset $this->output. */ - $this->clear(); - - /* Set toList and ccList. */ - $testtask = $this->testtask->getByID($testtaskID); - $users = $this->loadModel('user')->getPairs('noletter'); - $toList = $testtask->owner; - $ccList = str_replace(' ', '', trim($testtask->mailto, ',')); - if($toList == '') - { - if($ccList == '') return; - if(strpos($ccList, ',') === false) - { - $toList = $ccList; - $ccList = ''; - } - else - { - $commaPos = strpos($ccList, ','); - $toList = substr($ccList, 0, $commaPos); - $ccList = substr($ccList, $commaPos + 1); - } - } - - /* Get action info. */ - $action = $this->loadModel('action')->getById($actionID); - $history = $this->action->getHistory($actionID); - $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); - - /* Create the email content. */ - $this->view->testtask = $testtask; - $this->view->action = $action; - $this->view->users = $users; - - $mailContent = $this->parse($this->moduleName, 'sendmail'); - - /* Set email title. */ - if($actionType == 'opened') - { - $mailTitle = sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtaskID, $this->post->name); - } - elseif($actionType == 'closed') - { - $mailTitle = sprintf($this->lang->testtask->mail->close->title, $this->app->user->realname, $testtaskID, $testtask->name); - } - else - { - $mailTitle = sprintf($this->lang->testtask->mail->edit->title, $this->app->user->realname, $testtaskID, $this->post->name); - } - - /* Send mail. */ - $this->loadModel('mail')->send($toList, $mailTitle, $mailContent, $ccList); - if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); - } } diff --git a/module/testtask/model.php b/module/testtask/model.php index eb9bd353b7..8bc2009ea5 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -734,4 +734,78 @@ class testtaskModel extends model echo ''; } } + + /** + * Send mail. + * + * @param int $testtaskID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($testtaskID, $actionID) + { + $this->loadModel('mail'); + $testtask = $this->getByID($testtaskID); + $users = $this->loadModel('user')->getPairs('noletter'); + + /* Get action info. */ + $action = $this->loadModel('action')->getById($actionID); + $history = $this->action->getHistory($actionID); + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + + /* Get mail content. */ + $modulePath = $this->app->getModulePath(); + $oldcwd = getcwd(); + $viewFile = $modulePath . 'view/sendmail.html.php'; + chdir($modulePath . 'view'); + if(file_exists($modulePath . 'ext/view/sendmail.html.php')) + { + $viewFile = $modulePath . 'ext/view/sendmail.html.php'; + chdir($modulePath . 'ext/view'); + } + ob_start(); + include $viewFile; + foreach(glob($modulePath . 'ext/view/sendmail.*.html.hook.php') as $hookFile) include $hookFile; + $mailContent = ob_get_contents(); + ob_end_clean(); + chdir($oldcwd); + + /* Set toList and ccList. */ + $toList = $testtask->owner; + $ccList = str_replace(' ', '', trim($testtask->mailto, ',')); + if(empty($toList)) + { + if(empty($ccList)) return; + if(strpos($ccList, ',') === false) + { + $toList = $ccList; + $ccList = ''; + } + else + { + $commaPos = strpos($ccList, ','); + $toList = substr($ccList, 0, $commaPos); + $ccList = substr($ccList, $commaPos + 1); + } + } + + /* Set email title. */ + if($action->action == 'opened') + { + $mailTitle = sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtaskID, $this->post->name); + } + elseif($action->action == 'closed') + { + $mailTitle = sprintf($this->lang->testtask->mail->close->title, $this->app->user->realname, $testtaskID, $testtask->name); + } + else + { + $mailTitle = sprintf($this->lang->testtask->mail->edit->title, $this->app->user->realname, $testtaskID, $this->post->name); + } + + /* Send mail. */ + $this->mail->send($toList, $mailTitle, $mailContent, $ccList); + if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); + } } diff --git a/module/testtask/view/sendmail.html.php b/module/testtask/view/sendmail.html.php index 2bb4658ad0..1e1320d78d 100644 --- a/module/testtask/view/sendmail.html.php +++ b/module/testtask/view/sendmail.html.php @@ -11,12 +11,12 @@ */ ?> id . ' ' . $testtask->name;?> - +app->getModuleRoot() . 'common/view/mail.header.html.php';?> @@ -24,9 +24,9 @@ - +app->getModuleRoot() . 'common/view/mail.footer.html.php';?>
mail->turnon; ?> mail->turnonList, 1);?>
mail->fromAddress; ?> fromAddress, "class='form-control'");?>mail->addressWhiteList?>mail->addressWhiteList?>
mail->fromName; ?> +
fromName, "class='form-control'");?>
mail->domain; ?>domain, "class='form-control'");?>
mail->host; ?>host, "class='form-control'");?>host, "class='form-control'");?>
mail->port; ?>port, "class='form-control'");?>port, "class='form-control'");?>mail->secure; ?> + mail->secureList['ssl']); + unset($lang->mail->secureList['tls']); + $mailConfig->secure = ''; + } + echo html::radio('secure', $lang->mail->secureList, $mailConfig->secure); + if(!$openssl) echo "   " . $lang->mail->disableSecure . ''; + ?> +
mail->auth; ?>mail->authList, $mailConfig->auth, 'onchange=setAuth(this.value)'); ?>mail->authList, $mailConfig->auth, 'onchange=setAuth(this.value)'); ?>
mail->username; ?>username, "class='form-control' autocomplete='off'") ?>username, "class='form-control' autocomplete='off'") ?>
mail->password; ?>password, "class='form-control' autocomplete='off' placeholder='{$lang->mail->placeholder->password}'") ?>
mail->secure; ?>mail->secureList, $mailConfig->secure); ?>password, "class='form-control' autocomplete='off' placeholder='{$lang->mail->placeholder->password}'") ?>
mail->debug; ?>
mail->domain?>mail, 'domain', common::getSysURL()), "class='form-control'")?>
mail->accessKey; ?>
diff --git a/module/project/control.php b/module/project/control.php index b43908e4c4..40ba301867 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -385,7 +385,8 @@ class project extends control $mails = $this->project->importBug($projectID); if(dao::isError()) die(js::error(dao::getError())); - foreach($mails as $mail) $this->sendmail($mail->taskID, $mail->actionID); + $this->loadModel('task'); + foreach($mails as $mail) $this->task->sendmail($mail->taskID, $mail->actionID); /* Locate the browser. */ die(js::locate($this->createLink('project', 'importBug', "projectID=$projectID"), 'parent')); @@ -1413,61 +1414,6 @@ class project extends control } } - /** - * Send email. - * - * @param int $taskID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($taskID, $actionID) - { - /* Reset $this->output. */ - $this->clear(); - - /* Set toList and ccList. */ - $task = $this->loadModel('task')->getById($taskID); - $projectName = $this->project->getById($task->project)->name; - $toList = $task->assignedTo; - $ccList = trim($task->mailto, ','); - - if($toList == '') - { - if($ccList == '') return; - if(strpos($ccList, ',') === false) - { - $toList = $ccList; - $ccList = ''; - } - else - { - $commaPos = strpos($ccList, ','); - $toList = substr($ccList, 0, $commaPos); - $ccList = substr($ccList, $commaPos + 1); - } - } - elseif(strtolower($toList) == 'closed') - { - $toList = $task->finishedBy; - } - - /* Get action info. */ - $action = $this->loadModel('action')->getById($actionID); - $history = $this->action->getHistory($actionID); - $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); - - /* Create the email content. */ - $this->view->task = $task; - $this->view->action = $action; - - $mailContent = $this->parse($this->moduleName, 'sendmail'); - - /* Send emails. */ - $this->loadModel('mail')->send($toList, 'TASK#' . $task->id . ' ' . $task->name . ' - ' . $projectName, $mailContent, $ccList); - if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError())); - } - /** * Manage products. * diff --git a/module/project/view/sendmail.html.php b/module/project/view/sendmail.html.php deleted file mode 100644 index 71150bd0ca..0000000000 --- a/module/project/view/sendmail.html.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @package task - * @version $Id$ - * @link http://www.zentao.net - */ -?> -id . ' ' . $task->name;?> - -
- - - - -
createLink('task', 'view', "taskID=$task->id"), $mailTitle, '', "style='color: #333;'");?>
-
-
- task->legendDesc;?> -
desc;?>
-
-
- +
createLink('story', 'view', "storyID=$story->id"), $mailTitle, '', "style='color: #333;'");?>config->mail, 'domain', common::getSysURL()) . helper::createLink('story', 'view', "storyID=$story->id"), $mailTitle, '', "style='color: #333; text-decoration: underline;'");?>
- story->legendSpec;?> + lang->story->legendSpec;?>
spec;?>
- +
createLink('task', 'view', "taskID=$task->id"), $mailTitle, '', "style='color: #333;'");?>config->mail, 'domain', common::getSysURL()) . helper::createLink('task', 'view', "taskID=$task->id"), $mailTitle, '', "style='color: #333; text-decoration: underline;'");?>
- task->legendDesc;?> + lang->task->legendDesc;?>
desc;?>
- +
createLink('testtask', 'view', "testtaskID=$testtask->id"), $mailTitle, '', "style='color: #333;'");?>config->mail, 'domain', common::getSysURL()) . helper::createLink('testtask', 'view', "testtaskID=$testtask->id"), $mailTitle, '', "style='color: #333; text-decoration: underline;'");?>
- testtask->desc;?> + lang->testtask->desc;?>
desc;?>