From f8074fdafb6b202f44fec2edb1bf6868e8ce4f47 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 25 Aug 2021 10:45:33 +0800 Subject: [PATCH] * Finish task #41800. --- module/bug/model.php | 71 -------------- module/bug/view/sendmail.html.php | 8 +- module/doc/model.php | 78 --------------- module/doc/view/sendmail.html.php | 8 +- module/mail/model.php | 130 +++++++++++++++++++++++++ module/message/model.php | 3 +- module/my/control.php | 2 +- module/release/model.php | 49 +--------- module/release/view/sendmail.html.php | 6 +- module/story/model.php | 70 ------------- module/story/view/sendmail.html.php | 8 +- module/task/model.php | 62 ------------ module/task/view/sendmail.html.php | 8 +- module/testtask/model.php | 71 -------------- module/testtask/view/sendmail.html.php | 8 +- 15 files changed, 156 insertions(+), 426 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 87ceecdaf1..f739fe39a8 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2901,77 +2901,6 @@ class bugModel extends model echo !common::hasPriv('bug', 'assignTo', $bug) ? "{$assignedToText}" : $assignToHtml; } - /** - * Send mail - * - * @param int $bugID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($bugID, $actionID) - { - $this->loadModel('mail'); - $bug = $this->getByID($bugID); - $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(); - $action->appendLink = ''; - if(strpos($action->extra, ':') !== false) - { - list($extra, $id) = explode(':', $action->extra); - if($id and is_numeric($id)) - { - $action->extra = $extra; - - $name = $this->dao->select('title')->from(TABLE_BUG)->where('id')->eq($id)->fetch('title'); - if($name) $action->appendLink = html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink($action->objectType, 'view', "id=$id", 'html'), "#$id " . $name); - } - } - - /* Get mail content. */ - $modulePath = $this->app->getModulePath($appName = '', 'bug'); - $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); - - $sendUsers = $this->getToAndCcList($bug); - if(!$sendUsers) return; - list($toList, $ccList) = $sendUsers; - $subject = $this->getSubject($bug); - - /* Send it. */ - $this->mail->send($toList, $subject, $mailContent, $ccList); - if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); - } - - /** - * Get subject. - * - * @param object $bug - * @access public - * @return string - */ - public function getSubject($bug) - { - $productName = $this->loadModel('product')->getById($bug->product)->name; - return 'BUG #'. $bug->id . ' ' . $bug->title . ' - ' . $productName; - } - /** * Get toList and ccList. * diff --git a/module/bug/view/sendmail.html.php b/module/bug/view/sendmail.html.php index 3c5cddadd0..9700bb2ed2 100644 --- a/module/bug/view/sendmail.html.php +++ b/module/bug/view/sendmail.html.php @@ -10,15 +10,15 @@ * @link http://www.zentao.net */ ?> -id . ' ' . $bug->title;?> +id . ' ' . $object->title;?> app->getModuleRoot() . 'common/view/mail.header.html.php';?>
- color) ? '#333' : $bug->color;?> - config->mail, 'domain', common::getSysURL()) . helper::createLink('bug', 'view', "bugID=$bug->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> + color) ? '#333' : $object->color;?> + config->mail, 'domain', common::getSysURL()) . helper::createLink('bug', 'view', "bugID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->bug->legendSteps;?> -
steps;?>
+
steps;?>
diff --git a/module/doc/model.php b/module/doc/model.php index 5b597d519f..5a65c679b9 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1935,84 +1935,6 @@ class docModel extends model return $actions; } - /** - * Send mail. - * - * @param int $docID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($docID, $actionID) - { - /* Load module and get doc and users. */ - $this->loadModel('mail'); - $doc = $this->getById($docID); - $users = $this->loadModel('user')->getPairs('noletter'); - - /* When the content type is markdown format, add attributes to the table. */ - if($doc->contentType == 'markdown') - { - $doc->content = $this->app->loadClass('hyperdown')->makeHtml($doc->content); - $doc->content = str_replace("", "
", $doc->content); - $doc->content = str_replace(" diff --git a/module/mail/model.php b/module/mail/model.php index 26686a4a1a..03cb68c11b 100644 --- a/module/mail/model.php +++ b/module/mail/model.php @@ -661,4 +661,134 @@ class mailModel extends model return $result; } + + /** + * Send mail. + * + * @param int $objectID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($objectID, $actionID) + { + /* Load module and get vars. */ + $this->loadModel('action'); + $users = $this->loadModel('user')->getPairs('noletter'); + $action = $this->action->getById($actionID); + $history = $this->action->getHistory($actionID); + $objectType = $action->objectType; + $object = $this->loadModel($objectType)->getByID($objectID); + $nameFields = $this->config->action->objectNameFields[$objectType]; + $title = zget($object, $nameFields, ''); + $subject = $this->getSubject($objectType, $object, $title, $action->action); + + if($objectType == 'review' and empty($object->auditedBy)) return; + + if($objectType == 'doc') + { + if($object->contentType == 'markdown') + { + $object->content = $this->app->loadClass('hyperdown')->makeHtml($object->content); + $object->content = str_replace("
", "", $doc->content); - $doc->content = str_replace("", "", $doc->content); - } - - /* 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($appName = '', 'doc'); - $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); - - /* Get sender and subject. */ - $sendUsers = $this->getToAndCcList($doc); - if(!$sendUsers) return; - list($toList, $ccList) = $sendUsers; - $subject = $this->getSubject($doc, $action->action); - - /* Send mail. */ - $this->mail->send($toList, $subject, $mailContent, $ccList); - if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); - } - - /** - * Get mail subject. - * - * @param object $doc - * @param string $actionType created|edited - * @access public - * @return string - */ - public function getSubject($doc, $actionType) - { - /* Set email title. */ - if($actionType == 'created') - { - return sprintf($this->lang->doc->mail->create->title, $this->app->user->realname, $doc->id, $doc->title); - } - else - { - return sprintf($this->lang->doc->mail->edit->title, $this->app->user->realname, $doc->id, $doc->title); - } - } - /** * Get toList and ccList. * diff --git a/module/doc/view/sendmail.html.php b/module/doc/view/sendmail.html.php index 94e4ede8df..b26e031b90 100644 --- a/module/doc/view/sendmail.html.php +++ b/module/doc/view/sendmail.html.php @@ -10,15 +10,15 @@ * @link https://www.zentao.net */ ?> -lang->doc->common . ' #' . $doc->id . ' ' . $doc->title;?> +lang->doc->common . ' #' . $object->id . ' ' . $object->title;?> app->getModuleRoot() . 'common/view/mail.header.html.php';?>
- color) ? '#333' : $doc->color;?> - config->mail, 'domain', common::getSysURL()) . helper::createLink('doc', 'view', "docID=$doc->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> + color) ? '#333' : $object->color;?> + config->mail, 'domain', common::getSysURL()) . helper::createLink('doc', 'view', "docID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->doc->content;?> -
content;?>
+
content;?>
", "
", $object->content); + $object->content = str_replace(" @@ -18,7 +18,7 @@
", "", $object->content); + $object->content = str_replace("", "", $object->content); + } + } + + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + $action->appendLink = ''; + if(strpos($action->extra, ':') !== false) + { + list($extra, $id) = explode(':', $action->extra); + $action->extra = $extra; + if($title) + { + $action->appendLink = html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink($action->objectType, 'view', "id=$id", 'html'), "#$id " . $title); + } + } + + if($objectType == 'meeting') $rooms = $this->loadmodel('meetingroom')->getpairs(); + if($objectType == 'review') $this->app->loadLang('baseline'); + + /* Get mail content. */ + $modulePath = $this->app->getModulePath($appName = '', $objectType); + $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); + + /* Get the sender. */ + if($objectType == 'story' or $objectType == 'meeting') + { + $sendUsers = $this->{$objectType}->getToAndCcList($object, $action->action); + } + elseif($objectType == 'review') + { + $sendUsers = array($object->auditedBy, ''); + } + else + { + $sendUsers = $this->{$objectType}->getToAndCcList($object); + } + + if(!$sendUsers) return; + list($toList, $ccList) = $sendUsers; + + /* Send it. */ + $this->send($toList, $subject, $mailContent, $ccList); + if($this->isError()) error_log(join("\n", $this->getError())); + } + + /** + * Get subject. + * + * @param string $objectType + * @param object $object + * @param string $title + * @param string $actionType + * @access public + * @return string + */ + public function getSubject($objectType, $object, $title, $actionType) + { + $suffix = ''; + $subject = ''; + $titleType = 'edit'; + + if($objectType == 'testtask') + { + $this->app->loadLang('testtask'); + + if($actionType == 'opened') $titleType = 'create'; + if($actionType == 'closed') $titleType = 'close'; + + $subject = sprintf($this->lang->testtask->mail->{$titleType}->title, $this->app->user->realname, $object->id, $object->name); + } + elseif($objectType == 'doc') + { + $this->app->loadLang('doc'); + + if($actionType == 'created') $titleType = 'create'; + $subject = sprintf($this->lang->doc->mail->{$titleType}->title, $this->app->user->realname, $object->id, $object->title); + } + else + { + if($objectType == 'story' or $objectType == 'bug') $suffix = empty($object->product) ? '' : ' - ' . $this->loadModel('product')->getById($object->product)->name; + if($objectType == 'task') $suffix = empty($object->execution) ? '' : ' - ' . $this->loadModel('execution')->getById($object->execution)->name; + + $subject = strtoupper($objectType) . ' #' . $object->id . ' ' . $title . $suffix; + } + return $subject; + } } diff --git a/module/message/model.php b/module/message/model.php index 522e82f225..bae3422d26 100644 --- a/module/message/model.php +++ b/module/message/model.php @@ -76,8 +76,7 @@ class messageModel extends model if(isset($actions[$objectType]) and in_array($actionType, $actions[$objectType])) { $moduleName = $objectType == 'case' ? 'testcase' : $objectType; - $this->loadModel($moduleName); - if(method_exists($this->$moduleName, 'sendmail')) $this->$moduleName->sendmail($objectID, $actionID); + $this->loadModel('mail')->sendmail($objectID, $actionID); } } diff --git a/module/my/control.php b/module/my/control.php index 66d268244a..cc10336b33 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -529,7 +529,7 @@ class my extends control $this->app->loadLang('project'); $this->app->session->set('programList', $this->app->getURI(true), 'program'); - $this->app->session->set('projectList', $this->app->getURI(true), 'project'); + $this->app->session->set('projectList', $this->app->getURI(true), 'my'); /* Set the pager. */ $this->app->loadClass('pager', $static = true); diff --git a/module/release/model.php b/module/release/model.php index bc85bd1789..3ffa2e60e0 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -477,53 +477,6 @@ class releaseModel extends model return dao::isError(); } - /** - * Send mail. - * - * @param int $releaseID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($releaseID, $actionID) - { - $this->loadModel('mail'); - $release = $this->getByID($releaseID); - $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(); - $action->appendLink = ''; - - /* Get mail content. */ - $modulePath = $this->app->getModulePath($appName = '', 'release'); - $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); - - $sendUsers = $this->getToAndCcList($release); - if(!$sendUsers) return; - list($toList, $ccList) = $sendUsers; - $subject = 'RELEASE #' . $release->id . ' ' . $release->name; - - /* Send it. */ - $this->mail->send($toList, $subject, $mailContent, $ccList); - if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); - } - /** * Get toList and ccList. * @@ -543,7 +496,7 @@ class releaseModel extends model foreach($notifyPersons as $account) { - if(strpos($ccList, ",{$account},") === false) $ccList .= $account . ','; + if(strpos($ccList, ",{$account},") === false) $ccList .= ",$account,"; } $ccList = trim($ccList, ','); diff --git a/module/release/view/sendmail.html.php b/module/release/view/sendmail.html.php index d33dcb10a2..78c4a85bbb 100644 --- a/module/release/view/sendmail.html.php +++ b/module/release/view/sendmail.html.php @@ -10,7 +10,7 @@ * @link http://www.zentao.net */ ?> -id . ' ' . $release->name;?> +id . ' ' . $object->name;?> app->openApp == 'product' ? 'release' : 'projectrelease';?> app->getModuleRoot() . 'common/view/mail.header.html.php';?>
- config->mail, 'domain', common::getSysURL()) . helper::createLink($module, 'view', "releaseID=$release->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?> + config->mail, 'domain', common::getSysURL()) . helper::createLink($module, 'view', "releaseID=$object->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->release->desc;?> -
desc;?>
+
desc;?>
diff --git a/module/story/model.php b/module/story/model.php index 00bd2b658d..387b2e921d 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -3302,19 +3302,6 @@ class storyModel extends model return $storyGroup; } - /** - * Get mail subject. - * - * @param object $story - * @access public - * @return string - */ - public function getSubject($story) - { - $productName = empty($story->product) ? '' : ' - ' . $this->loadModel('product')->getById($story->product)->name; - return 'STORY #' . $story->id . ' ' . $story->title . $productName; - } - /** * Get toList and ccList. * @@ -3880,63 +3867,6 @@ 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); - $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(); - $action->appendLink = ''; - if(strpos($action->extra, ':') !== false) - { - list($extra, $id) = explode(':', $action->extra); - $action->extra = $extra; - if($id) - { - $name = $this->dao->select('title')->from(TABLE_STORY)->where('id')->eq($id)->fetch('title'); - if($name) $action->appendLink = html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink($action->objectType, 'view', "id=$id", 'html'), "#$id " . $name); - } - } - - /* Get mail content. */ - $modulePath = $this->app->getModulePath($appName = '', 'story'); - $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); - - $sendUsers = $this->getToAndCcList($story, $action->action); - if(!$sendUsers) return; - list($toList, $ccList) = $sendUsers; - $subject = $this->getSubject($story); - - /* Send it. */ - $this->mail->send($toList, $subject, $mailContent, $ccList); - if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); - } - /** * Get tracks. * diff --git a/module/story/view/sendmail.html.php b/module/story/view/sendmail.html.php index bb4c80b87f..47ba1948d5 100644 --- a/module/story/view/sendmail.html.php +++ b/module/story/view/sendmail.html.php @@ -10,15 +10,15 @@ * @link http://www.zentao.net */ ?> -id . ' ' . $story->title;?> +id . ' ' . $object->title;?> app->getModuleRoot() . 'common/view/mail.header.html.php';?>
- color) ? '#333' : $story->color;?> - config->mail, 'domain', common::getSysURL()) . helper::createLink('story', 'view', "storyID=$story->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> + color) ? '#333' : $object->color;?> + config->mail, 'domain', common::getSysURL()) . helper::createLink('story', 'view', "storyID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->story->legendSpec;?> -
spec;?>
+
spec;?>
diff --git a/module/task/model.php b/module/task/model.php index f04410db92..1597b728db 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -3166,68 +3166,6 @@ class taskModel extends model echo !common::hasPriv('task', 'assignTo', $task) ? "{$assignedToText}" : $assignToHtml; } - /** - * Send mail. - * - * @param int $taskID - * @param int $actionID - * @access public - * @return void - */ - public function sendmail($taskID, $actionID) - { - $this->loadModel('mail'); - $task = $this->getById($taskID); - $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. */ - $oldcwd = getcwd(); - $modulePath = $this->app->getModulePath($appName = '', 'task'); - $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); - - $sendUsers = $this->getToAndCcList($task); - if(!$sendUsers) return; - list($toList, $ccList) = $sendUsers; - $subject = $this->getSubject($task); - - /* Send emails. */ - $this->mail->send($toList, $subject, $mailContent, $ccList); - if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); - } - - /** - * Get mail subject. - * - * @param object $task - * @access public - * @return string - */ - public function getSubject($task) - { - $executionName = $this->loadModel('execution')->getById($task->execution)->name; - return 'TASK#' . $task->id . ' ' . $task->name . ' - ' . $executionName; - } - /** * Get toList and ccList. * diff --git a/module/task/view/sendmail.html.php b/module/task/view/sendmail.html.php index f104d75895..b318101c13 100644 --- a/module/task/view/sendmail.html.php +++ b/module/task/view/sendmail.html.php @@ -10,15 +10,15 @@ * @link http://www.zentao.net */ ?> -id . ' ' . $task->name;?> +id . ' ' . $object->name;?> app->getModuleRoot() . 'common/view/mail.header.html.php';?>
- color) ? '#333' : $task->color;?> - config->mail, 'domain', common::getSysURL()) . helper::createLink('task', 'view', "taskID=$task->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> + color) ? '#333' : $object->color;?> + config->mail, 'domain', common::getSysURL()) . helper::createLink('task', 'view', "taskID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->task->legendDesc;?> -
desc;?>
+
desc;?>
diff --git a/module/testtask/model.php b/module/testtask/model.php index a60df44674..e6d7cda644 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -1543,77 +1543,6 @@ class testtaskModel extends model } } - /** - * 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($appName = '', 'testtask'); - $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); - - $sendUsers = $this->getToAndCcList($testtask); - if(!$sendUsers) return; - list($toList, $ccList) = $sendUsers; - $subject = $this->getSubject($testtask, $action->action); - - /* Send mail. */ - $this->mail->send($toList, $subject, $mailContent, $ccList); - if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); - } - - /** - * Get mail subject. - * - * @param object $testtask - * @param string $actionType - * @access public - * @return string - */ - public function getSubject($testtask, $actionType) - { - /* Set email title. */ - if($actionType == 'opened') - { - return sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtask->id, $testtask->name); - } - elseif($actionType == 'closed') - { - return sprintf($this->lang->testtask->mail->close->title, $this->app->user->realname, $testtask->id, $testtask->name); - } - else - { - return sprintf($this->lang->testtask->mail->edit->title, $this->app->user->realname, $testtask->id, $testtask->name); - } - } - /** * Get toList and ccList. * diff --git a/module/testtask/view/sendmail.html.php b/module/testtask/view/sendmail.html.php index 492605756e..073eb24259 100644 --- a/module/testtask/view/sendmail.html.php +++ b/module/testtask/view/sendmail.html.php @@ -10,15 +10,15 @@ * @link http://www.zentao.net */ ?> -id . ' ' . $testtask->name;?> +id . ' ' . $object->name;?> app->getModuleRoot() . 'common/view/mail.header.html.php';?>
- color) ? '#333' : $testtask->color;?> - config->mail, 'domain', common::getSysURL()) . helper::createLink('testtask', 'view', "testtaskID=$testtask->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> + color) ? '#333' : $object->color;?> + config->mail, 'domain', common::getSysURL()) . helper::createLink('testtask', 'view', "testtaskID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->testtask->desc;?> -
desc;?>
+
desc;?>