* finish task #2719,2729.

This commit is contained in:
wangyidong
2016-11-25 15:32:28 +08:00
parent cc1e0f2cf0
commit 7ac6afe616
25 changed files with 420 additions and 424 deletions
+16 -72
View File
@@ -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') . '<br />';
}
}
+66
View File
@@ -1696,4 +1696,70 @@ class taskModel extends model
echo '</td>';
}
}
/**
* 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()));
}
}
+4 -4
View File
@@ -11,12 +11,12 @@
*/
?>
<?php $mailTitle = 'TASK #' . $task->id . ' ' . $task->name;?>
<?php include '../../common/view/mail.header.html.php';?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr>
<td>
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'><?php echo html::a(common::getSysURL() . $this->createLink('task', 'view', "taskID=$task->id"), $mailTitle, '', "style='color: #333;'");?></td>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'><?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('task', 'view', "taskID=$task->id"), $mailTitle, '', "style='color: #333; text-decoration: underline;'");?></td>
</tr>
</table>
</td>
@@ -24,9 +24,9 @@
<tr>
<td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $lang->task->legendDesc;?></legend>
<legend style='color: #114f8e'><?php echo $this->lang->task->legendDesc;?></legend>
<div style='padding:5px;'><?php echo $task->desc;?></div>
</fieldset>
</td>
</tr>
<?php include '../../common/view/mail.footer.html.php';?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.footer.html.php';?>