diff --git a/module/testtask/control.php b/module/testtask/control.php index 9ca049361f..bcada379d9 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -95,10 +95,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'); - if($this->post->owner) - { - $this->sendmail($taskID, $actionID, 'opened'); - } + $this->sendmail($taskID, $actionID, 'opened'); die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent')); } @@ -152,10 +149,11 @@ class testtask extends control $this->view->products = $products; $this->view->projectID = $projectID; } - $this->view->projects = $projects; - $this->view->productID = $productID; - $this->view->builds = $builds; - $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted|qdfirst'); + $this->view->projects = $projects; + $this->view->productID = $productID; + $this->view->builds = $builds; + $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted|qdfirst'); + $this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote'); $this->display(); } @@ -417,10 +415,11 @@ class testtask extends control $this->view->position[] = $this->lang->testtask->common; $this->view->position[] = $this->lang->testtask->edit; - $this->view->task = $task; - $this->view->projects = $this->product->getProjectPairs($productID); - $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = 0, $params = ''); - $this->view->users = $this->loadModel('user')->getPairs('nodeleted', $task->owner); + $this->view->task = $task; + $this->view->projects = $this->product->getProjectPairs($productID); + $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = 0, $params = ''); + $this->view->users = $this->loadModel('user')->getPairs('nodeleted', $task->owner); + $this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote'); $this->display(); } @@ -486,6 +485,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'); } if(isonlybody()) die(js::reload('parent.parent')); @@ -499,11 +499,13 @@ class testtask extends control /* Set menu. */ $this->testtask->setMenu($this->products, $productID, $testtask->branch); - $this->view->testtask = $this->testtask->getById($taskID); - $this->view->title = $testtask->name . $this->lang->colon . $this->lang->close; - $this->view->position[] = $this->lang->testtask->common; - $this->view->position[] = $this->lang->close; - $this->view->actions = $actions; + $this->view->testtask = $this->testtask->getById($taskID); + $this->view->title = $testtask->name . $this->lang->colon . $this->lang->close; + $this->view->position[] = $this->lang->testtask->common; + $this->view->position[] = $this->lang->close; + $this->view->actions = $actions; + $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted|qdfirst'); + $this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote'); $this->display(); } @@ -868,25 +870,55 @@ class testtask extends control /* Reset $this->output. */ $this->clear(); + /* Set toList and ccList. */ $testtask = $this->testtask->getByID($testtaskID); - $action = $this->action->getById($actionID); $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); } - $this->loadModel('mail')->send($this->post->owner, $mailTitle, $mailContent); + + /* 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/lang/en.php b/module/testtask/lang/en.php index d27187345c..d975382274 100644 --- a/module/testtask/lang/en.php +++ b/module/testtask/lang/en.php @@ -45,6 +45,7 @@ $lang->testtask->name = 'Name'; $lang->testtask->begin = 'Begin'; $lang->testtask->end = 'End'; $lang->testtask->desc = 'Desc'; +$lang->testtask->mailto = 'Mailto'; $lang->testtask->status = 'Status'; $lang->testtask->assignedTo = 'Assign'; $lang->testtask->linkVersion = 'Version'; @@ -99,8 +100,10 @@ $lang->testtask->placeholder->end = 'end date'; $lang->testtask->mail = new stdclass(); $lang->testtask->mail->create = new stdclass(); $lang->testtask->mail->edit = new stdclass(); +$lang->testtask->mail->close = new stdclass(); $lang->testtask->mail->create->title = "%s created testtask #%s:%s"; $lang->testtask->mail->edit->title = "%s finished testtask #%s:%s"; +$lang->testtask->mail->close->title = "%s closed testtask #%s:%s"; $lang->testtask->testScope = 'Test scope'; diff --git a/module/testtask/lang/zh-cn.php b/module/testtask/lang/zh-cn.php index a63c9c5110..e27f10559e 100644 --- a/module/testtask/lang/zh-cn.php +++ b/module/testtask/lang/zh-cn.php @@ -45,6 +45,7 @@ $lang->testtask->name = '名称'; $lang->testtask->begin = '开始日期'; $lang->testtask->end = '结束日期'; $lang->testtask->desc = '描述'; +$lang->testtask->mailto = '抄送给'; $lang->testtask->status = '当前状态'; $lang->testtask->assignedTo = '指派给'; $lang->testtask->linkVersion = '版本'; @@ -99,8 +100,10 @@ $lang->testtask->placeholder->end = '结束日期'; $lang->testtask->mail = new stdclass(); $lang->testtask->mail->create = new stdclass(); $lang->testtask->mail->edit = new stdclass(); +$lang->testtask->mail->close = new stdclass(); $lang->testtask->mail->create->title = "%s创建了版本 #%s:%s"; $lang->testtask->mail->edit->title = "%s编辑了版本 #%s:%s"; +$lang->testtask->mail->close->title = "%s关闭了版本 #%s:%s"; $lang->testtask->testScope = '测试范畴'; diff --git a/module/testtask/model.php b/module/testtask/model.php index 38a32eccfd..854bb30b14 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -41,7 +41,7 @@ class testtaskModel extends model */ function create() { - $task = fixer::input('post')->stripTags($this->config->testtask->editor->create['id'], $this->config->allowedTags)->get(); + $task = fixer::input('post')->stripTags($this->config->testtask->editor->create['id'], $this->config->allowedTags)->join('mailto', ',')->get(); $task = $this->loadModel('file')->processEditor($task, $this->config->testtask->editor->create['id']); $this->dao->insert(TABLE_TESTTASK)->data($task) ->autoCheck($skipFields = 'begin,end') @@ -170,7 +170,7 @@ class testtaskModel extends model public function update($taskID) { $oldTask = $this->getById($taskID); - $task = fixer::input('post')->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)->get(); + $task = fixer::input('post')->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)->join('mailto', ',')->get(); $task = $this->loadModel('file')->processEditor($task, $this->config->testtask->editor->edit['id']); $this->dao->update(TABLE_TESTTASK)->data($task) ->autoCheck() @@ -215,6 +215,7 @@ class testtaskModel extends model $testtask = fixer::input('post') ->setDefault('status', 'done') ->stripTags($this->config->testtask->editor->close['id'], $this->config->allowedTags) + ->join('mailto', ',') ->remove('comment')->get(); $testtask = $this->loadModel('file')->processEditor($testtask, $this->config->testtask->editor->close['id']); diff --git a/module/testtask/view/close.html.php b/module/testtask/view/close.html.php index ec6588e352..a68393c535 100644 --- a/module/testtask/view/close.html.php +++ b/module/testtask/view/close.html.php @@ -31,6 +31,15 @@ comment;?> + + testtask->mailto;?> + +
+ mailto), "multiple class='form-control'");?> + +
+ + goback, $this->session->taskList); ?> diff --git a/module/testtask/view/create.html.php b/module/testtask/view/create.html.php index b699c61238..56613844aa 100644 --- a/module/testtask/view/create.html.php +++ b/module/testtask/view/create.html.php @@ -70,6 +70,15 @@ testtask->desc;?> + + testtask->mailto;?> + +
+ + +
+ + diff --git a/module/testtask/view/edit.html.php b/module/testtask/view/edit.html.php index 6044f1456d..7008a5795b 100644 --- a/module/testtask/view/edit.html.php +++ b/module/testtask/view/edit.html.php @@ -64,6 +64,15 @@ testtask->report;?> report), "rows=10 class='form-control'");?> + + testtask->mailto;?> + +
+ mailto), "multiple class='form-control'");?> + +
+ + diff --git a/module/testtask/view/view.html.php b/module/testtask/view/view.html.php index 62ca9fa4e3..c2743570c8 100644 --- a/module/testtask/view/view.html.php +++ b/module/testtask/view/view.html.php @@ -83,6 +83,10 @@ testtask->owner;?> owner];?> + + testtask->mailto;?> + mailto)); foreach($mailto as $account) echo ' ' . zget($users, $account, $account);?> + testtask->pri;?> pri;?>