diff --git a/module/testtask/control.php b/module/testtask/control.php index 9fea6631f2..bc8e674a52 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -87,7 +87,11 @@ class testtask extends control { $taskID = $this->testtask->create(); if(dao::isError()) die(js::error(dao::getError())); - $this->loadModel('action')->create('testtask', $taskID, 'opened'); + $actionID = $this->loadModel('action')->create('testtask', $taskID, 'opened'); + if($this->post->owner) + { + $this->sendmail($taskID, $actionID, 'opened'); + } die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent')); } @@ -268,6 +272,9 @@ class testtask extends control { $actionID = $this->loadModel('action')->create('testtask', $taskID, 'edited'); $this->action->logHistory($actionID, $changes); + + /* send mail.*/ + $this->sendmail($taskID, $actionID, 'edited'); } die(js::locate(inlink('view', "taskID=$taskID"), 'parent')); } @@ -488,4 +495,37 @@ 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) + { + $testtask = $this->testtask->getByID($testtaskID); + $action = $this->action->getById($actionID); + $users = $this->loadModel('user')->getPairs('noletter'); + + $this->view->testtask = $testtask; + $this->view->action = $action; + $this->view->users = $users; + + $mailContent = $this->parse($this->moduleName, 'sendmail'); + + if($actionType == 'opened') + { + $mailTitle = sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtaskID, $this->post->name); + } + else + { + $mailTitle = sprintf($this->lang->testtask->mail->edit->title, $this->app->user->realname, $testtaskID, $this->post->name); + } + $this->loadModel('mail')->send($this->post->owner, $mailTitle, $mailContent); + if($this->mail->isError()) echo js::error($this->mail->getError()); + } } diff --git a/module/testtask/lang/en.php b/module/testtask/lang/en.php index 326b55082a..511e87d841 100644 --- a/module/testtask/lang/en.php +++ b/module/testtask/lang/en.php @@ -67,3 +67,6 @@ $lang->testtask->lblResults = 'Result'; $lang->testtask->placeholder->begin = 'begin date'; $lang->testtask->placeholder->end = 'end date'; + +$lang->testtask->mail->create->title = "%s created testtask #%s:%s"; +$lang->testtask->mail->edit->title = "%s finished testtask #%s:%s"; diff --git a/module/testtask/lang/zh-cn.php b/module/testtask/lang/zh-cn.php index f55c31eac0..6c8857dd58 100644 --- a/module/testtask/lang/zh-cn.php +++ b/module/testtask/lang/zh-cn.php @@ -64,3 +64,9 @@ $lang->testtask->lblCases = '用例列表'; $lang->testtask->lblUnlinkCase = '移除用例'; $lang->testtask->lblRunCase = '执行用例'; $lang->testtask->lblResults = '执行结果'; + +$lang->testtask->placeholder->begin = '开始日期'; +$lang->testtask->placeholder->end = '结束日期'; + +$lang->testtask->mail->create->title = "%s创建了测试任务 #%s:%s"; +$lang->testtask->mail->edit->title = "%s编辑了测试任务 #%s:%s"; diff --git a/module/testtask/view/sendmail.html.php b/module/testtask/view/sendmail.html.php new file mode 100644 index 0000000000..94ff78230b --- /dev/null +++ b/module/testtask/view/sendmail.html.php @@ -0,0 +1,39 @@ + + * @package bug + * @version $Id: sendmail.html.php 3717 2012-12-10 00:37:07Z zhujinyonging@gmail.com $ + * @link http://www.zentao.net + */ +?> + + + + + + + + + + +
+ TESTTASK #id . "=>$testtask->owner " . html::a(common::getSysURL() . $this->createLink('testtask', 'view', "testtaskID=$testtask->id"), $testtask->name);?> +
+
+ testtask->desc;?> +
+ desc, 'src="data/upload')) + { + $testtask->desc = str_replace('server->http_host . $this->config->webRoot, $testtask->desc); + $testtask->desc = str_replace('server->http_host . $this->config->webRoot, $testtask->desc); + } + echo $testtask->desc; + ?> +
+
+