* finish task #2495.

This commit is contained in:
chenfeiCF
2016-02-17 15:20:51 +08:00
parent 8b1c8fb46f
commit ae9b46a05f
8 changed files with 91 additions and 21 deletions

View File

@@ -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()));
}
}

View File

@@ -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';

View File

@@ -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 = '测试范畴';

View File

@@ -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']);

View File

@@ -31,6 +31,15 @@
<th><?php echo $lang->comment;?></th>
<td><?php echo html::textarea('comment', '', "rows='6' class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->testtask->mailto;?></th>
<td colspan='2'>
<div class='input-group'>
<?php echo html::select('mailto[]', $users, str_replace(' ' , '', $testtask->mailto), "multiple class='form-control'");?>
<?php if($contactLists) echo html::select('', $contactLists, '', "class='form-control chosen' onchange=\"setMailto('mailto', this.value)\"");?>
</div>
</td>
</tr>
<tr>
<td colspan='2' class='text-center'><?php echo html::submitButton() . html::linkButton($lang->goback, $this->session->taskList); ?></td>
</tr>

View File

@@ -70,6 +70,15 @@
<th><?php echo $lang->testtask->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', '', "rows=10 class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->testtask->mailto;?></th>
<td colspan='2'>
<div class='input-group'>
<?php echo html::select('mailto[]', $users, '', "multiple class='form-control'");?>
<?php if($contactLists) echo html::select('', $contactLists, '', "class='form-control chosen' onchange=\"setMailto('mailto', this.value)\"");?>
</div>
</td>
</tr>
<tr>
<td></td><td colspan='2'><?php echo html::submitButton() . html::backButton();?> </td>
</tr>

View File

@@ -64,6 +64,15 @@
<th><?php echo $lang->testtask->report;?></th>
<td colspan='2'><?php echo html::textarea('report', htmlspecialchars($task->report), "rows=10 class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->testtask->mailto;?></th>
<td colspan='2'>
<div class='input-group'>
<?php echo html::select('mailto[]', $users, str_replace(' ' , '', $task->mailto), "multiple class='form-control'");?>
<?php if($contactLists) echo html::select('', $contactLists, '', "class='form-control chosen' onchange=\"setMailto('mailto', this.value)\"");?>
</div>
</td>
</tr>
<tr>
<td></td><td colspan='2'><?php echo html::submitButton() . html::backButton();?> </td>
</tr>

View File

@@ -83,6 +83,10 @@
<th><?php echo $lang->testtask->owner;?></th>
<td><?php echo $users[$task->owner];?></td>
</tr>
<tr>
<th><?php echo $lang->testtask->mailto;?></th>
<td><?php $mailto = explode(',', str_replace(' ', '', $task->mailto)); foreach($mailto as $account) echo ' ' . zget($users, $account, $account);?></td>
</tr>
<tr>
<th><?php echo $lang->testtask->pri;?></th>
<td><?php echo $task->pri;?></td>