* 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

View File

@@ -2901,77 +2901,6 @@ class bugModel extends model
echo !common::hasPriv('bug', 'assignTo', $bug) ? "<span style='padding-left: 21px' class='{$btnTextClass}'>{$assignedToText}</span>" : $assignToHtml; echo !common::hasPriv('bug', 'assignTo', $bug) ? "<span style='padding-left: 21px' class='{$btnTextClass}'>{$assignedToText}</span>" : $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. * Get toList and ccList.
* *

View File

@@ -10,15 +10,15 @@
* @link http://www.zentao.net * @link http://www.zentao.net
*/ */
?> ?>
<?php $mailTitle = 'BUG #' . $bug->id . ' ' . $bug->title;?> <?php $mailTitle = 'BUG #' . $object->id . ' ' . $object->title;?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?> <?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr> <tr>
<td> <td>
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'> <table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr> <tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'> <td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'>
<?php $color = empty($bug->color) ? '#333' : $bug->color;?> <?php $color = empty($object->color) ? '#333' : $object->color;?>
<?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('bug', 'view', "bugID=$bug->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> <?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('bug', 'view', "bugID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
</td> </td>
</tr> </tr>
</table> </table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'> <td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'> <fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->bug->legendSteps;?></legend> <legend style='color: #114f8e'><?php echo $this->lang->bug->legendSteps;?></legend>
<div style='padding:5px;'><?php echo $bug->steps;?></div> <div style='padding:5px;'><?php echo $object->steps;?></div>
</fieldset> </fieldset>
</td> </td>
</tr> </tr>

View File

@@ -1935,84 +1935,6 @@ class docModel extends model
return $actions; 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("<table>", "<table style='border-collapse: collapse;'>", $doc->content);
$doc->content = str_replace("<th>", "<th style='word-break: break-word; border:1px solid #000;'>", $doc->content);
$doc->content = str_replace("<td>", "<td style='word-break: break-word; border:1px solid #000;'>", $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. * Get toList and ccList.
* *

View File

@@ -10,15 +10,15 @@
* @link https://www.zentao.net * @link https://www.zentao.net
*/ */
?> ?>
<?php $mailTitle = $this->lang->doc->common . ' #' . $doc->id . ' ' . $doc->title;?> <?php $mailTitle = $this->lang->doc->common . ' #' . $object->id . ' ' . $object->title;?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?> <?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr> <tr>
<td> <td>
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'> <table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr> <tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'> <td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'>
<?php $color = empty($doc->color) ? '#333' : $doc->color;?> <?php $color = empty($object->color) ? '#333' : $object->color;?>
<?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('doc', 'view', "docID=$doc->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> <?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('doc', 'view', "docID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
</td> </td>
</tr> </tr>
</table> </table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'> <td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'> <fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->doc->content;?></legend> <legend style='color: #114f8e'><?php echo $this->lang->doc->content;?></legend>
<div style='padding: 5px;'><?php echo $doc->content;?></div> <div style='padding: 5px;'><?php echo $object->content;?></div>
</fieldset> </fieldset>
</td> </td>
</tr> </tr>

View File

@@ -661,4 +661,134 @@ class mailModel extends model
return $result; 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("<table>", "<table style='border-collapse: collapse;'>", $object->content);
$object->content = str_replace("<th>", "<th style='word-break: break-word; border:1px solid #000;'>", $object->content);
$object->content = str_replace("<td>", "<td style='word-break: break-word; border:1px solid #000;'>", $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;
}
} }

View File

@@ -76,8 +76,7 @@ class messageModel extends model
if(isset($actions[$objectType]) and in_array($actionType, $actions[$objectType])) if(isset($actions[$objectType]) and in_array($actionType, $actions[$objectType]))
{ {
$moduleName = $objectType == 'case' ? 'testcase' : $objectType; $moduleName = $objectType == 'case' ? 'testcase' : $objectType;
$this->loadModel($moduleName); $this->loadModel('mail')->sendmail($objectID, $actionID);
if(method_exists($this->$moduleName, 'sendmail')) $this->$moduleName->sendmail($objectID, $actionID);
} }
} }

View File

@@ -529,7 +529,7 @@ class my extends control
$this->app->loadLang('project'); $this->app->loadLang('project');
$this->app->session->set('programList', $this->app->getURI(true), 'program'); $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. */ /* Set the pager. */
$this->app->loadClass('pager', $static = true); $this->app->loadClass('pager', $static = true);

View File

@@ -477,53 +477,6 @@ class releaseModel extends model
return dao::isError(); 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. * Get toList and ccList.
* *
@@ -543,7 +496,7 @@ class releaseModel extends model
foreach($notifyPersons as $account) foreach($notifyPersons as $account)
{ {
if(strpos($ccList, ",{$account},") === false) $ccList .= $account . ','; if(strpos($ccList, ",{$account},") === false) $ccList .= ",$account,";
} }
$ccList = trim($ccList, ','); $ccList = trim($ccList, ',');

View File

@@ -10,7 +10,7 @@
* @link http://www.zentao.net * @link http://www.zentao.net
*/ */
?> ?>
<?php $mailTitle = 'RELEASE #' . $release->id . ' ' . $release->name;?> <?php $mailTitle = 'RELEASE #' . $object->id . ' ' . $object->name;?>
<?php $module = $this->app->openApp == 'product' ? 'release' : 'projectrelease';?> <?php $module = $this->app->openApp == 'product' ? 'release' : 'projectrelease';?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?> <?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr> <tr>
@@ -18,7 +18,7 @@
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'> <table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr> <tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'> <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($module, 'view', "releaseID=$release->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?> <?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink($module, 'view', "releaseID=$object->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?>
</td> </td>
</tr> </tr>
</table> </table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'> <td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'> <fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->release->desc;?></legend> <legend style='color: #114f8e'><?php echo $this->lang->release->desc;?></legend>
<div style='padding:5px;'><?php echo $release->desc;?></div> <div style='padding:5px;'><?php echo $object->desc;?></div>
</fieldset> </fieldset>
</td> </td>
</tr> </tr>

View File

@@ -3302,19 +3302,6 @@ class storyModel extends model
return $storyGroup; 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. * Get toList and ccList.
* *
@@ -3880,63 +3867,6 @@ class storyModel extends model
return $forceReview; 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. * Get tracks.
* *

View File

@@ -10,15 +10,15 @@
* @link http://www.zentao.net * @link http://www.zentao.net
*/ */
?> ?>
<?php $mailTitle = 'STORY #' . $story->id . ' ' . $story->title;?> <?php $mailTitle = 'STORY #' . $object->id . ' ' . $object->title;?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?> <?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr> <tr>
<td> <td>
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'> <table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr> <tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'> <td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'>
<?php $color = empty($story->color) ? '#333' : $story->color;?> <?php $color = empty($object->color) ? '#333' : $object->color;?>
<?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('story', 'view', "storyID=$story->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> <?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('story', 'view', "storyID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
</td> </td>
</tr> </tr>
</table> </table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'> <td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'> <fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->story->legendSpec;?></legend> <legend style='color: #114f8e'><?php echo $this->lang->story->legendSpec;?></legend>
<div style='padding:5px;'><?php echo $story->spec;?></div> <div style='padding:5px;'><?php echo $object->spec;?></div>
</fieldset> </fieldset>
</td> </td>
</tr> </tr>

View File

@@ -3166,68 +3166,6 @@ class taskModel extends model
echo !common::hasPriv('task', 'assignTo', $task) ? "<span style='padding-left: 21px' class='{$btnTextClass}'>{$assignedToText}</span>" : $assignToHtml; echo !common::hasPriv('task', 'assignTo', $task) ? "<span style='padding-left: 21px' class='{$btnTextClass}'>{$assignedToText}</span>" : $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. * Get toList and ccList.
* *

View File

@@ -10,15 +10,15 @@
* @link http://www.zentao.net * @link http://www.zentao.net
*/ */
?> ?>
<?php $mailTitle = 'TASK #' . $task->id . ' ' . $task->name;?> <?php $mailTitle = 'TASK #' . $object->id . ' ' . $object->name;?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?> <?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr> <tr>
<td> <td>
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'> <table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr> <tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'> <td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'>
<?php $color = empty($task->color) ? '#333' : $task->color;?> <?php $color = empty($object->color) ? '#333' : $object->color;?>
<?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('task', 'view', "taskID=$task->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?> <?php echo html::a(zget($this->config->mail, 'domain', common::getSysURL()) . helper::createLink('task', 'view', "taskID=$object->id", 'html'), $mailTitle, '', "style='color: {$color}; text-decoration: underline;'");?>
</td> </td>
</tr> </tr>
</table> </table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'> <td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'> <fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->task->legendDesc;?></legend> <legend style='color: #114f8e'><?php echo $this->lang->task->legendDesc;?></legend>
<div style='padding:5px;'><?php echo $task->desc;?></div> <div style='padding:5px;'><?php echo $object->desc;?></div>
</fieldset> </fieldset>
</td> </td>
</tr> </tr>

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. * Get toList and ccList.
* *

View File

@@ -10,15 +10,15 @@
* @link http://www.zentao.net * @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';?> <?php include $this->app->getModuleRoot() . 'common/view/mail.header.html.php';?>
<tr> <tr>
<td> <td>
<table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'> <table cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr> <tr>
<td style='padding: 10px; background-color: #F8FAFE; border: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid #e5e5e5;'> <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 $color = empty($object->color) ? '#333' : $object->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 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> </td>
</tr> </tr>
</table> </table>
@@ -28,7 +28,7 @@
<td style='padding: 10px; border: none;'> <td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'> <fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $this->lang->testtask->desc;?></legend> <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> </fieldset>
</td> </td>
</tr> </tr>