* Finish task #41800.

This commit is contained in:
tianshujie98
2021-08-25 10:45:33 +08:00
parent 452aaac4d7
commit f8074fdafb
15 changed files with 156 additions and 426 deletions
-71
View File
@@ -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.
*
+4 -4
View File
@@ -10,15 +10,15 @@
* @link http://www.zentao.net
*/
?>
<?php $mailTitle = 'TESTTASK #' . $testtask->id . ' ' . $testtask->name;?>
<?php $mailTitle = 'TESTTASK #' . $object->id . ' ' . $object->name;?>
<?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 $color = empty($testtask->color) ? '#333' : $testtask->color;?>
<?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('testtask', 'view', "testtaskID=$testtask->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
<?php $color = empty($object->color) ? '#333' : $object->color;?>
<?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('testtask', 'view', "testtaskID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
</td>
</tr>
</table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->testtask->desc;?></legend>
<div style='padding:5px;'><?php echo $testtask->desc;?></div>
<div style='padding:5px;'><?php echo $object->desc;?></div>
</fieldset>
</td>
</tr>