* 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

View File

@@ -221,7 +221,7 @@ class bug extends control
}
$actionID = $this->action->create('bug', $bugID, 'Opened');
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
$location = $this->createLink('bug', 'browse', "productID={$this->post->product}&branch=$branch&type=byModule&param={$this->post->module}");
$response['locate'] = isset($_SESSION['bugList']) ? $this->session->bugList : $location;
@@ -361,7 +361,7 @@ class bug extends control
if(!empty($_POST))
{
$actions = $this->bug->batchCreate($productID, $branch);
foreach($actions as $bugID => $actionID) $this->sendmail($bugID, $actionID);
foreach($actions as $bugID => $actionID) $this->bug->sendmail($bugID, $actionID);
die(js::locate($this->session->bugList, 'parent'));
}
@@ -502,7 +502,7 @@ class bug extends control
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ;
$actionID = $this->action->create('bug', $bugID, $action, $fileAction . $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
$bug = $this->bug->getById($bugID);
@@ -597,7 +597,7 @@ class bug extends control
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
@@ -701,7 +701,7 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'Assigned', $this->post->comment, $this->post->assignedTo);
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
@@ -737,7 +737,7 @@ class bug extends control
$this->loadModel('action');
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
}
die(js::locate($this->session->bugList, 'parent'));
@@ -763,7 +763,7 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'Assigned', $this->post->comment, $this->post->assignedTo);
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
}
if($type == 'product') die(js::locate($this->createLink('bug', 'browse', "productID=$projectID")));
@@ -785,7 +785,7 @@ class bug extends control
$this->bug->confirm($bugID);
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'bugConfirmed', $this->post->comment);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -818,7 +818,7 @@ class bug extends control
foreach($bugIDList as $bugID)
{
$actionID = $this->action->create('bug', $bugID, 'bugConfirmed');
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
die(js::locate($this->session->bugList, 'parent'));
}
@@ -840,7 +840,7 @@ class bug extends control
$fileAction = !empty($files) ? $this->lang->addFiles . join(',', $files) . "\n" : '';
$actionID = $this->action->create('bug', $bugID, 'Resolved', $fileAction . $this->post->comment, $this->post->resolution . ($this->post->duplicateBug ? ':' . (int)$this->post->duplicateBug : ''));
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
@@ -896,7 +896,7 @@ class bug extends control
foreach($bugIDList as $bugID)
{
$actionID = $this->action->create('bug', $bugID, 'Resolved', '', $resolution);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
die(js::locate($this->session->bugList, 'parent'));
}
@@ -916,7 +916,7 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$files = $this->loadModel('file')->saveUpload('bug', $bugID);
$actionID = $this->action->create('bug', $bugID, 'Activated', $this->post->comment);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -951,7 +951,7 @@ class bug extends control
$this->bug->close($bugID);
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'Closed', $this->post->comment);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -1083,7 +1083,7 @@ class bug extends control
$this->bug->close($bugID);
$actionID = $this->action->create('bug', $bugID, 'Closed');
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
if(isset($skipBugs)) echo js::alert(sprintf($this->lang->bug->skipClose, join(',', $skipBugs)));
@@ -1263,64 +1263,6 @@ class bug extends control
$this->display();
}
/**
* Send email.
*
* @param int $bugID
* @param int $actionID
* @access public
* @return void
*/
public function sendmail($bugID, $actionID)
{
/* Reset $this->output. */
$this->clear();
/* Set toList and ccList. */
$bug = $this->bug->getByID($bugID);
$productName = $this->products[$bug->product];
$toList = $bug->assignedTo;
$ccList = trim($bug->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 = $bug->resolvedBy;
}
/* Get action info. */
$actions = $this->action->getList('bug', $bugID);
$action = zget($actions, $actionID, null);
$history = $this->action->getHistory($actionID);
$action->history = isset($history[$actionID]) ? $history[$actionID] : array();
if(strtolower($action->action) == 'opened') $action->comment = $bug->steps;
/* Create the mail content. */
if($action->action == 'opened') $action->comment = '';
$this->view->bug = $bug;
$this->view->action = $action;
$this->view->users = $this->user->getPairs('noletter');
$mailContent = $this->parse($this->moduleName, 'sendmail');
/* Send it. */
$this->loadModel('mail')->send($toList, 'BUG #'. $bug->id . ' ' . $bug->title . ' - ' . $productName, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
/**
* Get data to export
*
@@ -1333,6 +1275,7 @@ class bug extends control
{
if($_POST)
{
$this->loadModel('file');
$bugLang = $this->lang->bug;
$bugConfig = $this->config->bug;
@@ -1469,7 +1412,7 @@ class bug extends control
{
foreach($relatedFiles[$bug->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;
$bug->files .= html::a($fileURL, $file->title, '_blank') . '<br />';
}
}

View File

@@ -2163,4 +2163,69 @@ class bugModel extends model
echo '</td>';
}
}
/**
* Send mail
*
* @param int $bugID
* @param int $actionID
* @access public
* @return void
*/
public function sendmail($bugID, $actionID)
{
$this->loadModel('mail');
$bug = $this->getByID($bugID);
$productName = $this->loadModel('product')->getById($bug->product)->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 = $bug->assignedTo;
$ccList = trim($bug->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 = $bug->resolvedBy;
}
/* Send it. */
$this->mail->send($toList, 'BUG #'. $bug->id . ' ' . $bug->title . ' - ' . $productName, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
}

View File

@@ -11,12 +11,12 @@
*/
?>
<?php $mailTitle = 'BUG #' . $bug->id . ' ' . $bug->title;?>
<?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('bug', 'view', "bugID=$bug->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('bug', 'view', "bugID=$bug->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->bug->legendSteps;?></legend>
<legend style='color: #114f8e'><?php echo $this->lang->bug->legendSteps;?></legend>
<div style='padding:5px;'><?php echo $bug->steps;?></div>
</fieldset>
</td>
</tr>
<?php include '../../common/view/mail.footer.html.php';?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.footer.html.php';?>

View File

@@ -870,6 +870,7 @@ class commonModel extends model
if(strtolower($key) == 'assigneddate') continue;
if(strtolower($key) == 'editedby') continue;
if(strtolower($key) == 'editeddate') continue;
if(strtolower($key) == 'uid') continue;
if($magicQuote) $value = stripslashes($value);
if($value != stripslashes($old->$key))

View File

@@ -1,20 +1,33 @@
<?php
$extViewFile = $this->app->getModuleRoot() . 'ext/view/' . basename(__FILE__);
if(file_exists($extViewFile))
{
include $extViewFile;
return;
}
?>
<?php if(!empty($action)): ?>
<?php if(!empty($action->comment)):?>
<tr>
<td style="padding:0px 10px 10px 10px; border: none;">
<fieldset style="border: 1px solid #e5e5e5">
<legend style="color: #114f8e"><?php echo $this->lang->comment?></legend>
<div style="padding:5px;"><?php echo $action->comment?></div>
</fieldset>
</td>
</tr>
<?php endif;?>
<tr>
<td style='padding: 10px; background-color: #FFF0D5'>
<?php if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
<?php if(isset($users[$action->actor])) $action->actor = $users[$action->actor];?>
<?php if(isset($users[$action->extra])) $action->extra = $users[$action->extra];?>
<span style='font-size: 16px; color: #F1A325'>●</span> &nbsp;<span><?php $this->action->printAction($action);?></span>
</td>
</tr>
<?php if(!empty($action->comment) or !empty($action->history)):?>
<?php if(!empty($action->history)):?>
<tr>
<td style='padding: 10px;'>
<div><?php echo $this->action->printChanges($action->objectType, $action->history);?></div>
<?php if(!empty($action->comment)): ?>
<p style='padding: 0; padding-left: 10px; margin: 0; margin-top: 8px; border-left: 4px solid #ddd; color: #666'><?php echo $action->comment;?></p>
<?php endif;?>
</div>
</td>
</tr>
<?php endif;?>

View File

@@ -16,7 +16,7 @@ if($onlybody) $_GET['onlybody'] = 'no';
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='600' style='border: none; border-collapse: collapse;'>
<tr>
<td style='padding: 10px 0; border: none; vertical-align: middle;'><strong style='font-size: 16px'><?php echo $app->company->name ?></strong></td>
<td style='padding: 10px 0; border: none; vertical-align: middle;'><strong style='font-size: 16px'><?php echo $this->app->company->name ?></strong></td>
</tr>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='600' style='border-collapse: collapse; background-color: #fff; border: 1px solid #cfcfcf; box-shadow: 0 0px 6px rgba(0, 0, 0, 0.1); margin-bottom: 20px; font-size:13px;'>

View File

@@ -68,6 +68,7 @@ class mail extends control
echo "<script>setTimeout(function(){parent.location.href='" . inlink('edit') . "'}, 10000)</script>";
$mailConfig = $this->mail->autoDetect($this->post->fromAddress);
$mailConfig->fromAddress = $this->post->fromAddress;
$mailConfig->domain = common::getSysURL();
$this->session->set('mailConfig', $mailConfig);
die(js::locate(inlink('edit'), 'parent'));
@@ -106,12 +107,15 @@ class mail extends control
$this->locate(inlink('detect'));
}
$mailConfig->domain = isset($this->config->mail->domain) ? $this->config->mail->domain : common::getSysURL();
$this->view->title = $this->lang->mail->common . $this->lang->colon . $this->lang->mail->edit;
$this->view->position[] = html::a(inlink('index'), $this->lang->mail->common);
$this->view->position[] = $this->lang->mail->edit;
$this->view->mailExist = $this->mail->mailExist();
$this->view->mailConfig = $mailConfig;
$this->view->openssl = extension_loaded('openssl');
$this->display();
}
@@ -133,6 +137,7 @@ class mail extends control
$mailConfig->async = $this->post->async;
$mailConfig->fromAddress = trim($this->post->fromAddress);
$mailConfig->fromName = trim($this->post->fromName);
$mailConfig->domain = trim($this->post->domain);
$mailConfig->smtp->host = trim($this->post->host);
$mailConfig->smtp->port = trim($this->post->port);
$mailConfig->smtp->auth = $this->post->auth;
@@ -195,6 +200,7 @@ class mail extends control
$mailConfig->async = $this->post->async;
$mailConfig->fromAddress = '';
$mailConfig->fromName = '';
$mailConfig->domain = trim($this->post->domain);
$mailConfig->sendcloud->accessKey = trim($this->post->accessKey);
$mailConfig->sendcloud->secretKey = trim($this->post->secretKey);
@@ -207,13 +213,14 @@ class mail extends control
die(js::reload('parent'));
}
$mailConfig = '';
$mailConfig = new stdclass();
if($this->config->mail->turnon)
{
$mailConfig = $this->config->mail->sendcloud;
$mailConfig->fromAddress = $this->config->mail->fromAddress;
$mailConfig->fromName = $this->config->mail->fromName;
$mailConfig->turnon = $this->config->mail->turnon;
$mailConfig->domain = isset($this->config->mail->domain) ? $this->config->mail->domain : common::getSysURL();
$mailConfig->async = isset($this->config->mail->async) ? $this->config->mail->async : 0;
}

View File

@@ -16,6 +16,7 @@ $lang->mail->turnon = 'Turn On';
$lang->mail->async = 'Asynchronous';
$lang->mail->fromAddress = 'Email Address';
$lang->mail->fromName = 'Sender';
$lang->mail->domain = 'Domain';
$lang->mail->host = 'SMTP Server';
$lang->mail->port = 'SMTP Port';
$lang->mail->auth = 'Verification Required';
@@ -74,6 +75,7 @@ $lang->mail->sendmailTips = 'Note: Email author will not receive this email.';
$lang->mail->needConfigure = 'Email configuration is not found. Please cinfigure the Email first.';
$lang->mail->nofsocket = 'fsocket related function has been deactivated. Mails cannot send out. Please modify allow_url_fopen in php.ini to turn on Onopenssl, and restart Apache.';
$lang->mail->noOpenssl = 'Please turn on Onopenssl, and restart Apache.';
$lang->mail->disableSecure = 'No openssl, disable ssl and tls.';
$lang->mail->sendCloudFail = 'Failed. Reason:';
$lang->mail->sendCloudHelp = <<<EOD
<p>1、Notice SendCloud是SendCloud的Team通知服务。具体可以到<a href="http://notice.sendcloud.net/" target="_blank">notice.sendcloud.net</a>查看</p>

View File

@@ -16,6 +16,7 @@ $lang->mail->turnon = '是否打开';
$lang->mail->async = '异步发送';
$lang->mail->fromAddress = '发信邮箱';
$lang->mail->fromName = '发信人';
$lang->mail->domain = '发信域名';
$lang->mail->host = 'smtp服务器';
$lang->mail->port = 'smtp端口号';
$lang->mail->auth = '是否需要验证';
@@ -74,6 +75,7 @@ $lang->mail->sendmailTips = '提示:系统不会为当前操作者发信。'
$lang->mail->needConfigure = '无法找到邮件配置信息,请先配置邮件发送参数。';
$lang->mail->nofsocket = 'fsocket相关函数被禁用不能发信请在php.ini中修改allow_url_fopen为On打开openssl扩展。 保存并重新启动apache。';
$lang->mail->noOpenssl = 'ssl和tls加密请打开openssl扩展。 保存并重新启动apache。';
$lang->mail->disableSecure = '没有openssl扩展禁用ssl和tls加密';
$lang->mail->sendCloudFail = '操作失败,原因:';
$lang->mail->sendCloudHelp = <<<EOD
<p>1、Notice SendCloud是SendCloud的团队通知服务。具体可以到<a href="http://notice.sendcloud.net/" target="_blank">notice.sendcloud.net</a>查看</p>

View File

@@ -290,7 +290,7 @@ class mailModel extends model
$this->clear();
/* Replace full webPath image for mail. */
if(strpos($body, 'src="data/upload')) $body = preg_replace('/<img (.*)src="data\/upload/', '<img $1 src="http://' . $this->server->http_host . $this->config->webRoot . 'data/upload', $body);
if(strpos($body, 'src="data/upload')) $body = preg_replace('/<img (.*)src="data\/upload/', '<img $1 src="' . zget($this->config->mail, 'domain', common::getSysURL()) . $this->config->webRoot . 'data/upload', $body);
try
{

View File

@@ -25,6 +25,7 @@ include '../../common/view/header.html.php';
<th class='rowhead w-110px'><?php echo $lang->mail->turnon; ?></th>
<td class='w-p25-f'><?php echo html::radio('turnon', $lang->mail->turnonList, 1);?></td>
<td></td>
<td></td>
</tr>
<?php if(!empty($config->global->cron)):?>
<tr>
@@ -35,38 +36,51 @@ include '../../common/view/header.html.php';
<tr>
<th><?php echo $lang->mail->fromAddress; ?></th>
<td><?php echo html::input('fromAddress', $mailConfig->fromAddress, "class='form-control'");?></td>
<td><?php echo $lang->mail->addressWhiteList?></td>
<td colspan='2'><?php echo $lang->mail->addressWhiteList?></td>
</tr>
<tr>
<th><?php echo $lang->mail->fromName; ?></th>
<td colspan='2'>
<td colspan='3'>
<div class='required required-wrapper'></div>
<?php echo html::input('fromName', $mailConfig->fromName, "class='form-control'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->mail->domain; ?></th>
<td colspan='3'><?php echo html::input('domain', $mailConfig->domain, "class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->mail->host; ?></th>
<td colspan='2'><?php echo html::input('host', $mailConfig->host, "class='form-control'");?></td>
<td colspan='3'><?php echo html::input('host', $mailConfig->host, "class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->mail->port; ?></th>
<td colspan='2'><?php echo html::input('port', $mailConfig->port, "class='form-control'");?></td>
<td><?php echo html::input('port', $mailConfig->port, "class='form-control'");?></td>
<th class='w-70px'><?php echo $lang->mail->secure; ?></th>
<td>
<?php
if(!$openssl)
{
unset($lang->mail->secureList['ssl']);
unset($lang->mail->secureList['tls']);
$mailConfig->secure = '';
}
echo html::radio('secure', $lang->mail->secureList, $mailConfig->secure);
if(!$openssl) echo " &nbsp; <span class='text-warning'>" . $lang->mail->disableSecure . '</span>';
?>
</td>
</tr>
<tr>
<th><?php echo $lang->mail->auth; ?></th>
<td colspan='2'><?php echo html::radio('auth', $lang->mail->authList, $mailConfig->auth, 'onchange=setAuth(this.value)'); ?></td>
<td colspan='3'><?php echo html::radio('auth', $lang->mail->authList, $mailConfig->auth, 'onchange=setAuth(this.value)'); ?></td>
</tr>
<tr>
<th><?php echo $lang->mail->username; ?></th>
<td colspan='2'><?php echo html::input('username', $mailConfig->username, "class='form-control' autocomplete='off'") ?></td>
<td colspan='3'><?php echo html::input('username', $mailConfig->username, "class='form-control' autocomplete='off'") ?></td>
</tr>
<tr>
<th><?php echo $lang->mail->password; ?></th>
<td colspan='2'><?php echo html::password('password', $mailConfig->password, "class='form-control' autocomplete='off' placeholder='{$lang->mail->placeholder->password}'") ?></td>
</tr>
<tr>
<th><?php echo $lang->mail->secure; ?></th>
<td><?php echo html::radio('secure', $lang->mail->secureList, $mailConfig->secure); ?></td>
<td colspan='3'><?php echo html::password('password', $mailConfig->password, "class='form-control' autocomplete='off' placeholder='{$lang->mail->placeholder->password}'") ?></td>
</tr>
<tr>
<th><?php echo $lang->mail->debug; ?></th>

View File

@@ -32,6 +32,10 @@ include '../../common/view/header.html.php';
</tr>
<?php endif;?>
<tr>
<tr>
<th><?php echo $lang->mail->domain?></th>
<td><?php echo html::input('domain', zget($config->mail, 'domain', common::getSysURL()), "class='form-control'")?></td>
</tr>
<th><?php echo $lang->mail->accessKey; ?></th>
<td>
<div class='required required-wrapper'></div>

View File

@@ -385,7 +385,8 @@ class project extends control
$mails = $this->project->importBug($projectID);
if(dao::isError()) die(js::error(dao::getError()));
foreach($mails as $mail) $this->sendmail($mail->taskID, $mail->actionID);
$this->loadModel('task');
foreach($mails as $mail) $this->task->sendmail($mail->taskID, $mail->actionID);
/* Locate the browser. */
die(js::locate($this->createLink('project', 'importBug', "projectID=$projectID"), 'parent'));
@@ -1413,61 +1414,6 @@ class project 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->loadModel('task')->getById($taskID);
$projectName = $this->project->getById($task->project)->name;
$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;
$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()));
}
/**
* Manage products.
*

View File

@@ -1,32 +0,0 @@
<?php
/**
* The mail file of task module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yangyang Shi<shiyangyang@cnezsoft.com>
* @package task
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php $mailTitle = 'TASK #' . $task->id . ' ' . $task->name;?>
<?php include '../../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>
</tr>
</table>
</td>
</tr>
<tr>
<td style='padding: 10px; border: none;'>
<fieldset style='border: 1px solid #e5e5e5'>
<legend style='color: #114f8e'><?php echo $lang->task->legendDesc;?></legend>
<div style='padding:5px;'><?php echo $task->desc;?></div>
</fieldset>
</td>
</tr>
<?php include '../../common/view/mail.footer.html.php';?>

View File

@@ -206,7 +206,10 @@ class report extends control
/* Get email content and title.*/
$this->view->mail = $mail;
$oldViewType = $this->viewType;
if($oldViewType == 'json') $this->viewType = 'html';
$mailContent = $this->parse('report', 'dailyreminder');
$this->viewType == $oldViewType;
/* Send email.*/
echo date('Y-m-d H:i:s') . " sending to $user, ";

View File

@@ -295,6 +295,8 @@ class reportModel extends model
*/
public function getSysURL()
{
if(isset($this->config->mail->domain)) return $this->config->mail->domain;
/* Ger URL when run in shell. */
if(PHP_SAPI == 'cli')
{

View File

@@ -78,7 +78,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Frombug', '', $bugID);
}
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
if($this->post->newStory)
{
$response['message'] = $this->lang->story->successSaved . $this->lang->story->newStory;
@@ -212,7 +212,7 @@ class story extends control
$mails = $this->story->batchCreate($productID, $branch);
if(dao::isError()) die(js::error(dao::getError()));
foreach($mails as $mail) $this->sendmail($mail->storyID, $mail->actionID);
foreach($mails as $mail) $this->story->sendmail($mail->storyID, $mail->actionID);
die(js::locate($this->createLink('product', 'browse', "productID=$productID&branch=$branch"), 'parent'));
}
@@ -341,7 +341,7 @@ class story extends control
$action = !empty($changes) ? 'Edited' : 'Commented';
$actionID = $this->action->create('story', $storyID, $action, $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -385,7 +385,7 @@ class story extends control
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
}
die(js::locate($this->session->storyList, 'parent'));
@@ -488,7 +488,7 @@ class story extends control
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ;
$actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -523,7 +523,7 @@ class story extends control
$this->story->activate($storyID);
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('story', $storyID, 'Activated', $this->post->comment);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
@@ -634,7 +634,7 @@ class story extends control
if($this->post->closedReason != '' and strpos('done,postponed,subdivided', $this->post->closedReason) !== false) $result = 'pass';
$actionID = $this->action->create('story', $storyID, 'Reviewed', $this->post->comment, ucfirst($result));
$this->action->logHistory($actionID, array());
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
if($this->post->result == 'reject')
{
$this->action->create('story', $storyID, 'Closed', '', ucfirst($this->post->closedReason));
@@ -687,7 +687,7 @@ class story extends control
$actions = $this->story->batchReview($storyIDList, $result, $reason);
if(dao::isError()) die(js::error(dao::getError()));
foreach($actions as $storyID => $actionID) $this->sendmail($storyID, $actionID);
foreach($actions as $storyID => $actionID) $this->story->sendmail($storyID, $actionID);
die(js::locate($this->session->storyList, 'parent'));
}
@@ -706,7 +706,7 @@ class story extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comment, ucfirst($this->post->closedReason) . ($this->post->duplicateStory ? ':' . (int)$this->post->duplicateStory : ''));
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate(inlink('view', "storyID=$storyID"), 'parent'));
}
@@ -753,7 +753,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Closed', htmlspecialchars($this->post->comments[$storyID]), ucfirst($this->post->closedReasons[$storyID]) . ($this->post->duplicateStoryIDList[$storyID] ? ':' . (int)$this->post->duplicateStoryIDList[$storyID] : ''));
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
}
die(js::locate($this->session->storyList, 'parent'));
@@ -827,7 +827,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
die(js::reload('parent'));
}
@@ -848,7 +848,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
die(js::reload('parent'));
}
@@ -869,7 +869,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
die(js::reload('parent'));
}
@@ -890,7 +890,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
die(js::locate($this->session->storyList, 'parent'));
}
@@ -911,7 +911,7 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($storyID, $actionID);
$this->story->sendmail($storyID, $actionID);
}
}
die(js::locate($this->session->storyList));
@@ -1225,76 +1225,6 @@ class story extends control
echo $story->module;
}
/**
* Send email.
*
* @param int $storyID
* @param int $actionID
* @access public
* @return void
*/
public function sendmail($storyID, $actionID)
{
/* Reset $this->output. */
$this->clear();
$story = $this->story->getById($storyID);
$productName = $this->product->getById($story->product)->name;
/* Get actions. */
$actions = $this->action->getList('story', $storyID);
$action = zget($actions, $actionID, null);
$history = $this->action->getHistory($actionID);
$action->history = isset($history[$actionID]) ? $history[$actionID] : array();
if(strtolower($action->action) == 'opened') $action->comment = $story->spec;
/* Set toList and ccList. */
$toList = $story->assignedTo;
$ccList = str_replace(' ', '', trim($story->mailto, ','));
/* If the action is changed or reviewed, mail to the project team. */
if(strtolower($action->action) == 'changed' or strtolower($action->action) == 'reviewed')
{
$prjMembers = $this->story->getProjectMembers($storyID);
if($prjMembers)
{
$ccList .= ',' . join(',', $prjMembers);
$ccList = ltrim($ccList, ',');
}
}
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($toList == 'closed')
{
$toList = $story->openedBy;
}
/* Get the mail content. */
if($action->action == 'opened') $action->comment = '';
$this->view->story = $story;
$this->view->action = $action;
$this->view->users = $this->user->getPairs('noletter');
$mailContent = $this->parse($this->moduleName, 'sendmail');
/* Send it. */
$this->loadModel('mail')->send($toList, 'STORY #' . $story->id . ' ' . $story->title . ' - ' . $productName, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
/**
* The report page.
*
@@ -1349,6 +1279,7 @@ class story extends control
/* format the fields of every story in order to export data. */
if($_POST)
{
$this->loadModel('file');
$storyLang = $this->lang->story;
$storyConfig = $this->config->story;
@@ -1489,7 +1420,7 @@ class story extends control
{
foreach($relatedFiles[$story->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;
$story->files .= html::a($fileURL, $file->title, '_blank') . '<br />';
}
}

View File

@@ -2306,4 +2306,81 @@ 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);
$productName = $this->loadModel('product')->getById($story->product)->name;
$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();
/* 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 = $story->assignedTo;
$ccList = str_replace(' ', '', trim($story->mailto, ','));
/* If the action is changed or reviewed, mail to the project team. */
if(strtolower($action->action) == 'changed' or strtolower($action->action) == 'reviewed')
{
$prjMembers = $this->getProjectMembers($storyID);
if($prjMembers)
{
$ccList .= ',' . join(',', $prjMembers);
$ccList = ltrim($ccList, ',');
}
}
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($toList == 'closed')
{
$toList = $story->openedBy;
}
/* Send it. */
$this->mail->send($toList, 'STORY #' . $story->id . ' ' . $story->title . ' - ' . $productName, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
}

View File

@@ -11,12 +11,12 @@
*/
?>
<?php $mailTitle = 'STORY #' . $story->id . ' ' . $story->title;?>
<?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('story', 'view', "storyID=$story->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('story', 'view', "storyID=$story->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->story->legendSpec;?></legend>
<legend style='color: #114f8e'><?php echo $this->lang->story->legendSpec;?></legend>
<div style='padding:5px;'><?php echo $story->spec;?></div>
</fieldset>
</td>
</tr>
<?php include '../../common/view/mail.footer.html.php';?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.footer.html.php';?>

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 />';
}
}

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

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

View File

@@ -96,7 +96,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');
$this->sendmail($taskID, $actionID, 'opened');
$this->testtask->sendmail($taskID, $actionID);
die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent'));
}
@@ -365,7 +365,7 @@ class testtask extends control
$this->action->logHistory($actionID, $changes);
/* send mail.*/
$this->sendmail($taskID, $actionID, 'edited');
$this->testtask->sendmail($taskID, $actionID);
}
die(js::locate(inlink('view', "taskID=$taskID"), 'parent'));
}
@@ -452,7 +452,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');
$this->testtask->sendmail($taskID, $actionID);
}
if(isonlybody()) die(js::reload('parent.parent'));
@@ -822,70 +822,4 @@ class testtask extends control
->exec();
die(js::locate($this->session->caseList));
}
/**
* Send mail.
*
* @param int $testtaskID
* @param int $actionID
* @param string $action
* @access public
* @return void
*/
public function sendmail($testtaskID, $actionID, $actionType)
{
/* Reset $this->output. */
$this->clear();
/* Set toList and ccList. */
$testtask = $this->testtask->getByID($testtaskID);
$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);
}
/* Send mail. */
$this->loadModel('mail')->send($toList, $mailTitle, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
}

View File

@@ -734,4 +734,78 @@ class testtaskModel extends model
echo '</td>';
}
}
/**
* 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();
$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 = $testtask->owner;
$ccList = str_replace(' ', '', trim($testtask->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);
}
}
/* Set email title. */
if($action->action == 'opened')
{
$mailTitle = sprintf($this->lang->testtask->mail->create->title, $this->app->user->realname, $testtaskID, $this->post->name);
}
elseif($action->action == '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);
}
/* Send mail. */
$this->mail->send($toList, $mailTitle, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
}

View File

@@ -11,12 +11,12 @@
*/
?>
<?php $mailTitle = 'TESTTASK #' . $testtask->id . ' ' . $testtask->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('testtask', 'view', "testtaskID=$testtask->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('testtask', 'view', "testtaskID=$testtask->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->testtask->desc;?></legend>
<legend style='color: #114f8e'><?php echo $this->lang->testtask->desc;?></legend>
<div style='padding:5px;'><?php echo $testtask->desc;?></div>
</fieldset>
</td>
</tr>
<?php include '../../common/view/mail.footer.html.php';?>
<?php include $this->app->getModuleRoot() . 'common/view/mail.footer.html.php';?>