* finish task #3560.

This commit is contained in:
wangyidong
2018-01-11 11:05:50 +08:00
parent 6301f40a61
commit bd1ea46a9c
45 changed files with 511 additions and 259 deletions
+2
View File
@@ -747,12 +747,14 @@ CREATE TABLE IF NOT EXISTS `zt_todo` (
`begin` smallint(4) unsigned zerofill NOT NULL,
`end` smallint(4) unsigned zerofill NOT NULL,
`type` char(10) NOT NULL,
`cycle` tinyint(3) unsigned NOT NULL DEFAULT '0',
`idvalue` mediumint(8) unsigned NOT NULL default '0',
`pri` tinyint(3) unsigned NOT NULL,
`name` char(150) NOT NULL,
`desc` text NOT NULL,
`status` enum('wait','doing','done') NOT NULL DEFAULT 'wait',
`private` tinyint(1) NOT NULL,
`config` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `todo` (`account`,`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-3
View File
@@ -115,9 +115,6 @@ class action extends control
public function comment($objectType, $objectID)
{
$actionID = $this->action->create($objectType, $objectID, 'Commented', $this->post->comment);
$moduleName = $objectType == 'case' ? 'testcase' : $objectType;
$this->loadModel($moduleName)->sendmail($objectID, $actionID);
die(js::reload('parent'));
}
+1 -1
View File
@@ -61,7 +61,7 @@ class actionModel extends model
$this->file->updateObjectID($this->post->uid, $objectID, $objectType);
$this->loadModel('webhook')->send($objectType, $objectID, $actionType, $actionID);
$this->loadModel('message')->send($objectType, $objectID, $actionType, $actionID);
return $actionID;
}
+3
View File
@@ -331,6 +331,9 @@ class admin extends control
$this->send(array('result' => 'success', 'message' => $this->lang->admin->saveSuccess, 'locate' => 'reload'));
}
$this->loadModel('message');
$this->loadModel('webhook');
$this->view->title = $this->lang->admin->log;
$this->view->position[] = html::a($this->createLink('webhook', 'browse'), $this->lang->admin->api);
$this->view->position[] = $this->lang->admin->log;
+1 -8
View File
@@ -10,16 +10,9 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include $this->app->getModuleRoot() . 'webhook/view/header.html.php';?>
<?php include '../../common/view/form.html.php';?>
<div class='container mw-600px'>
<div id="titlebar">
<div class="heading">
<strong><?php echo html::a($this->createLink('webhook', 'browse'), $lang->admin->api);?></strong>
<small class="text-muted"> <?php echo $lang->admin->log;?></small>
<small class="text-muted"> <?php echo $lang->admin->setting;?></small>
</div>
</div>
<form id='logForm' method='post' class='ajaxForm'>
<table class='table table-form'>
<tr>
+6 -31
View File
@@ -248,7 +248,6 @@ class bug extends control
}
$actionID = $this->action->create('bug', $bugID, 'Opened');
$this->bug->sendmail($bugID, $actionID);
$extras = str_replace(array(',', ' '), array('&', ''), $extras);
parse_str($extras, $output);
@@ -406,7 +405,6 @@ class bug extends control
if(!empty($_POST))
{
$actions = $this->bug->batchCreate($productID, $branch);
foreach($actions as $bugID => $actionID) $this->bug->sendmail($bugID, $actionID);
die(js::locate($this->session->bugList, 'parent'));
}
@@ -548,7 +546,6 @@ 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->bug->sendmail($bugID, $actionID);
}
$bug = $this->bug->getById($bugID);
@@ -643,7 +640,6 @@ class bug extends control
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->bug->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
@@ -768,7 +764,6 @@ 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->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
@@ -805,7 +800,6 @@ class bug extends control
$this->loadModel('action');
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->bug->sendmail($bugID, $actionID);
}
}
$this->loadModel('score')->create('ajax', 'batchOther');
@@ -833,7 +827,6 @@ class bug extends control
$this->loadModel('action');
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->bug->sendmail($bugID, $actionID);
}
}
$this->loadModel('score')->create('ajax', 'batchOther');
@@ -861,7 +854,6 @@ 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->bug->sendmail($bugID, $actionID);
}
$this->loadModel('score')->create('ajax', 'batchOther');
}
@@ -885,7 +877,6 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'bugConfirmed', $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -916,11 +907,7 @@ class bug extends control
$bugIDList = array_unique($bugIDList);
$this->bug->batchConfirm($bugIDList);
if(dao::isError()) die(js::error(dao::getError()));
foreach($bugIDList as $bugID)
{
$actionID = $this->action->create('bug', $bugID, 'bugConfirmed');
$this->bug->sendmail($bugID, $actionID);
}
foreach($bugIDList as $bugID) $this->action->create('bug', $bugID, 'bugConfirmed');
$this->loadModel('score')->create('ajax', 'batchOther');
die(js::locate($this->session->bugList, 'parent'));
}
@@ -942,7 +929,6 @@ 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->bug->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
@@ -997,11 +983,7 @@ class bug extends control
$bugIDList = array_unique($bugIDList);
$bugIDList = $this->bug->batchResolve($bugIDList, $resolution, $resolvedBuild);
if(dao::isError()) die(js::error(dao::getError()));
foreach($bugIDList as $bugID)
{
$actionID = $this->action->create('bug', $bugID, 'Resolved', '', $resolution);
$this->bug->sendmail($bugID, $actionID);
}
foreach($bugIDList as $bugID) $this->action->create('bug', $bugID, 'Resolved', '', $resolution);
$this->loadModel('score')->create('ajax', 'batchOther');
die(js::locate($this->session->bugList, 'parent'));
}
@@ -1020,8 +1002,7 @@ class bug extends control
$this->bug->activate($bugID);
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->bug->sendmail($bugID, $actionID);
$this->action->create('bug', $bugID, 'Activated', $this->post->comment);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -1055,8 +1036,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->bug->sendmail($bugID, $actionID);
$this->action->create('bug', $bugID, 'Closed', $this->post->comment);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -1188,8 +1168,7 @@ class bug extends control
$this->bug->close($bugID);
$actionID = $this->action->create('bug', $bugID, 'Closed');
$this->bug->sendmail($bugID, $actionID);
$this->action->create('bug', $bugID, 'Closed');
}
$this->loadModel('score')->create('ajax', 'batchOther');
if(isset($skipBugs)) echo js::alert(sprintf($this->lang->bug->skipClose, join(',', $skipBugs)));
@@ -1208,11 +1187,7 @@ class bug extends control
if($this->post->statusList)
{
$activateBugs = $this->bug->batchActivate();
foreach($activateBugs as $bugID => $bug)
{
$actionID = $this->action->create('bug', $bugID, 'Activated', $bug['comment']);
$this->bug->sendmail($bugID, $actionID);
}
foreach($activateBugs as $bugID => $bug) $this->action->create('bug', $bugID, 'Activated', $bug['comment']);
$this->loadModel('score')->create('ajax', 'batchOther');
die(js::locate($this->session->bugList, 'parent'));
}
+36 -7
View File
@@ -2543,9 +2543,8 @@ class bugModel extends model
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');
$bug = $this->getByID($bugID);
$users = $this->loadModel('user')->getPairs('noletter');
/* Get action info. */
$action = $this->loadModel('action')->getById($actionID);
@@ -2580,12 +2579,44 @@ class bugModel extends model
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()) trigger_error(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.
*
* @param object $bug
* @access public
* @return bool|array
*/
public function getToAndCcList($bug)
{
/* Set toList and ccList. */
$toList = $bug->assignedTo;
$ccList = trim($bug->mailto, ',');
if(empty($toList))
{
if(empty($ccList)) return;
if(empty($ccList)) return false;
if(strpos($ccList, ',') === false)
{
$toList = $ccList;
@@ -2603,8 +2634,6 @@ class bugModel extends model
$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()));
return array($toList, $ccList);
}
}
+1
View File
@@ -112,6 +112,7 @@ $lang->user->menuOrder = $lang->company->menuOrder;
$lang->admin->menuOrder[5] = 'index';
$lang->admin->menuOrder[10] = 'extension';
$lang->admin->menuOrder[15] = 'custom';
$lang->admin->menuOrder[19] = 'message';
$lang->admin->menuOrder[20] = 'mail';
$lang->admin->menuOrder[25] = 'custom';
$lang->admin->menuOrder[30] = 'convert';
+4 -2
View File
@@ -339,13 +339,12 @@ $lang->admin->menu = new stdclass();
$lang->admin->menu->index = array('link' => '首页|admin|index', 'alias' => 'register,certifytemail,certifyztmobile,ztcompany');
$lang->admin->menu->extension = array('link' => '插件|extension|browse', 'subModule' => 'extension');
$lang->admin->menu->custom = array('link' => '自定义|custom|set', 'subModule' => 'custom');
$lang->admin->menu->mail = array('link' => '发信|mail|index', 'subModule' => 'mail');
$lang->admin->menu->message = array('link' => '消息|message|index', 'subModule' => 'message,mail,webhook');
$lang->admin->menu->backup = array('link' => '备份|backup|index', 'subModule' => 'backup');
$lang->admin->menu->safe = array('link' => '安全|admin|safe', 'alias' => 'checkweak');
$lang->admin->menu->cron = array('link' => '计划任务|cron|index', 'subModule' => 'cron');
$lang->admin->menu->trashes = array('link' => '回收站|action|trash', 'subModule' => 'action');
$lang->admin->menu->dev = array('link' => '二次开发|dev|api', 'alias' => 'db', 'subModule' => 'dev,editor');
$lang->admin->menu->api = array('link' => '接口|webhook|browse', 'alias' => 'create,edit', 'subModule' => 'entry,webhook');
$lang->admin->menu->sso = '然之集成|admin|sso';
$lang->convert = new stdclass();
@@ -360,6 +359,7 @@ $lang->cron = new stdclass();
$lang->dev = new stdclass();
$lang->entry = new stdclass();
$lang->webhook = new stdclass();
$lang->message = new stdclass();
$lang->search = new stdclass();
$lang->convert->menu = $lang->admin->menu;
@@ -374,6 +374,7 @@ $lang->mail->menu = $lang->admin->menu;
$lang->dev->menu = $lang->admin->menu;
$lang->entry->menu = $lang->admin->menu;
$lang->webhook->menu = $lang->admin->menu;
$lang->message->menu = $lang->admin->menu;
/* 菜单分组。*/
$lang->menugroup = new stdclass();
@@ -407,6 +408,7 @@ $lang->menugroup->mail = 'admin';
$lang->menugroup->dev = 'admin';
$lang->menugroup->entry = 'admin';
$lang->menugroup->webhook = 'admin';
$lang->menugroup->message = 'admin';
/* 错误提示信息。*/
$lang->error = new stdclass();
+1
View File
@@ -20,6 +20,7 @@ class mail extends control
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
$this->loadModel('message');
/* Task #1967. check the function of fsocket. */
if(isset($this->config->mail->mta) and $this->config->mail->mta != 'sendcloud' and !function_exists('fsockopen'))
+1
View File
@@ -0,0 +1 @@
$(function(){$('#featurebar .nav #mailTab').addClass('active');})
+2 -2
View File
@@ -51,8 +51,8 @@ $lang->mail->sendTime = 'Send Date';
$lang->mail->status = 'Status';
$lang->mail->failReason = 'Fail Reason';
$lang->mail->statusList['send'] = 'Sent';
$lang->mail->statusList['fail'] = 'Failed';
$lang->mail->statusList['sended'] = 'Sent';
$lang->mail->statusList['fail'] = 'Failed';
$lang->mail->turnonList[1] = 'On';
$lang->mail->turnonList[0] = 'Off';
+2 -2
View File
@@ -51,8 +51,8 @@ $lang->mail->sendTime = '发送时间';
$lang->mail->status = '状态';
$lang->mail->failReason = '失败原因';
$lang->mail->statusList['send'] = '成功';
$lang->mail->statusList['fail'] = '失败';
$lang->mail->statusList['sended'] = '成功';
$lang->mail->statusList['fail'] = '失败';
$lang->mail->turnonList[1] = '打开';
$lang->mail->turnonList[0] = '关闭';
+1 -1
View File
@@ -10,7 +10,7 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div id='titlebar'>
<div class='heading'><?php echo $lang->mail->browse?></div>
</div>
+1 -1
View File
@@ -9,8 +9,8 @@
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-700px'>
<div id='titlebar'>
<div class='heading'>
+1 -1
View File
@@ -9,8 +9,8 @@
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-800px'>
<div id='titlebar'>
<div class='heading'>
+1 -1
View File
@@ -9,8 +9,8 @@
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-700px'>
<div id='titlebar'>
<div class='heading'>
+1 -1
View File
@@ -9,8 +9,8 @@
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-700px'>
<div id='titlebar'>
<div class='heading'>
+1 -1
View File
@@ -9,8 +9,8 @@
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-700px'>
<div id='titlebar'>
<div class='heading'>
+1 -1
View File
@@ -10,7 +10,7 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div id='titlebar'>
<div class='heading'><?php echo $lang->mail->sendcloudUser?></div>
</div>
+1 -1
View File
@@ -15,7 +15,7 @@
<div class='alert alert-warning with-icon'><i class='icon-frown'></i><div class='content'><?php echo join('', $error);?></div></div>
<?php include '../../common/view/footer.lite.html.php';?>
<?php else:?>
<?php include '../../common/view/header.html.php';?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-700px'>
<div id='titlebar'>
<div class='heading'>
+1 -1
View File
@@ -10,7 +10,7 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include $this->app->getModuleRoot() . 'message/view/header.html.php';?>
<div class='container mw-800px'>
<?php if($step == 'license'):?>
<div id='titlebar'>
+26
View File
@@ -0,0 +1,26 @@
<?php
$config->message->objectTypes = array();
$config->message->objectTypes['product'] = array('opened', 'edited', 'closed', 'undeleted');
$config->message->objectTypes['story'] = array('opened', 'edited', 'commented', 'frombug', 'changed', 'reviewed', 'closed', 'activated');
$config->message->objectTypes['productplan'] = array('opened', 'edited');
$config->message->objectTypes['project'] = array('opened', 'edited', 'started', 'delayed', 'suspended', 'closed', 'activated', 'undeleted');
$config->message->objectTypes['task'] = array('opened', 'edited', 'commented', 'assigned', 'confirmed', 'started', 'finished', 'paused', 'canceled', 'restarted', 'closed', 'activated');
$config->message->objectTypes['bug'] = array('opened', 'edited', 'commented', 'assigned', 'confirmed', 'bugconfirmed', 'resolved', 'closed', 'activated');
$config->message->objectTypes['case'] = array('opened', 'edited', 'commented', 'reviewed', 'confirmed');
$config->message->objectTypes['testtask'] = array('opened', 'edited', 'started', 'blocked', 'closed', 'activated');
$config->message->objectTypes['todo'] = array('opened', 'edited');
$config->message->available['mail']['story'] = $config->message->objectTypes['story'];
$config->message->available['mail']['task'] = $config->message->objectTypes['task'];
$config->message->available['mail']['bug'] = $config->message->objectTypes['bug'];
$config->message->available['mail']['testtask'] = array('opened', 'edited', 'closed');
$config->message->available['webhook'] = $config->message->objectTypes;
$config->message->available['message'] = $config->message->objectTypes;
$config->message->typeLink['mail'] = 'mail|index';
$config->message->typeLink['webhook'] = 'webhook|browse';
$config->message->setting['message']['setting'] = $config->message->available['message'];
$config->message->setting['webhook']['setting'] = $config->message->available['webhook'];
$config->message->setting['mail']['setting'] = $config->message->available['mail'];
+56
View File
@@ -0,0 +1,56 @@
<?php
/**
* The control file of message 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 Yidong Wang <yidong@cnezsoft.com>
* @package message
* @version $Id$
* @link http://www.zentao.net
*/
class message extends control
{
/**
* Index
*
* @access public
* @return void
*/
public function index()
{
$this->locate($this->createLink('mail', 'index'));
}
/**
* Setting
*
* @access public
* @return void
*/
public function setting()
{
if($_POST)
{
$data = fixer::input('post')->get();
$data->messageSetting = json_encode($data->messageSetting);
$this->loadModel('setting')->setItem('system.message.setting', $data->messageSetting);
die(js::reload('parent'));
}
$this->loadModel('webhook');
$this->loadModel('action');
$this->view->title = $this->lang->message->setting;
$this->view->position[] = $this->lang->message->common;
$this->view->position[] = $this->lang->message->setting;
$users = $this->loadModel('user')->getPairs('noletter');
unset($users['']);
$this->view->users = $users;
$this->view->objectTypes = $this->message->getObjectTypes();
$this->view->objectActions = $this->message->getObjectActions();
$this->display();
}
}
+2
View File
@@ -0,0 +1,2 @@
.checkbox-inline + .checkbox-inline {margin:0px;}
.checkbox-inline {margin:0px; margin-right:10px !important; width:70px;}
+33
View File
@@ -0,0 +1,33 @@
$(function()
{
$('.objectType').click(function()
{
if($(this).prop('checked'))
{
$(this).closest('tr').find(':checkbox').prop('checked', true);
}
else
{
$(this).closest('tr').find(':checkbox').prop('checked', false);
}
});
$('.messageType').click(function()
{
var index = $(this).closest('th').index();
if($(this).prop('checked'))
{
$(this).closest('table').find('tbody').find('tr').each(function()
{
$(this).find('td').eq(index).find(':checkbox').prop('checked', true);
})
}
else
{
$(this).closest('table').find('tbody').find('tr').each(function()
{
$(this).find('td').eq(index).find(':checkbox').prop('checked', false);
})
}
});
});
+7
View File
@@ -0,0 +1,7 @@
<?php
$lang->message->common = 'Message';
$lang->message->setting = 'Setting';
$lang->message->typeList['mail'] = 'Mail';
$lang->message->typeList['message'] = 'Message';
$lang->message->typeList['webhook'] = 'Webhook';
+7
View File
@@ -0,0 +1,7 @@
<?php
$lang->message->common = '消息';
$lang->message->setting = '设置';
$lang->message->typeList['mail'] = '邮件';
$lang->message->typeList['message'] = '消息';
$lang->message->typeList['webhook'] = 'Webhook';
+84
View File
@@ -0,0 +1,84 @@
<?php
/**
* The model file of message module of ZenTaoCMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package message
* @version $Id$
* @link http://www.zentao.net
*/
class messageModel extends model
{
/**
* Get objectTypes
*
* @access public
* @return array
*/
public function getObjectTypes()
{
$objectTypes = array();
foreach($this->config->message->objectTypes as $objectType => $actions)
{
$objectTypes[$objectType] = $this->lang->action->objectTypes[$objectType];
}
return $objectTypes;
}
/**
* Get object actions.
*
* @access public
* @return array
*/
public function getObjectActions()
{
$objectActions = array();
foreach($this->config->message->objectTypes as $objectType => $actions)
{
foreach($actions as $action)
{
$objectActions[$objectType][$action] = str_replace($this->lang->webhook->trimWords, '', $this->lang->action->label->$action);
}
}
return $objectActions;
}
/**
* Check send.
*
* @param string $objectType
* @param int $objectID
* @param string $actionType
* @param int $actionID
* @access public
* @return void
*/
public function send($objectType, $objectID, $actionType, $actionID)
{
$messageSetting = $this->config->message->setting;
if(is_string($messageSetting)) $messageSetting = json_decode($messageSetting, true);
if(isset($messageSetting['mail']))
{
$actions = $messageSetting['mail']['setting'];
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);
}
}
if(isset($messageSetting['webhook']))
{
$actions = $messageSetting['webhook']['setting'];
if(isset($actions[$objectType]) and in_array($actionType, $actions[$objectType]))
{
$this->loadModel('webhook')->send($objectType, $objectID, $actionType, $actionID);
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php include '../../common/view/header.html.php';?>
<div id='featurebar'>
<ul class='nav'>
<?php foreach($lang->message->typeList as $type => $typeName):?>
<?php if(isset($config->message->typeLink[$type])):?>
<?php list($moduleName, $methodName) = explode('|', $config->message->typeLink[$type]);?>
<li id='<?php echo $type?>Tab'><?php echo html::a($this->createLink($moduleName, $methodName), $typeName)?></li>
<?php endif;?>
<?php endforeach;?>
<li id='settingTab'><?php echo html::a($this->createLink('message', 'setting'), $lang->message->setting)?></li>
</ul>
</div>
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* The setting view file of message 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 Yidong Wang <yidong@cnezsoft.com>
* @package message
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include './header.html.php';?>
<form target='hiddenwin' method='post'>
<table class='table table-hover table-striped table-bordered'>
<thead>
<th></th>
<?php foreach($lang->message->typeList as $type => $typeName):?>
<th><input type='checkbox' class='messageType' /> <?php echo $typeName;?></th>
<?php endforeach;?>
</thead>
<tbody>
<?php foreach($config->message->objectTypes as $objectType => $actions):?>
<tr>
<td class='w-90px'>
<label class='checkbox-inline'>
<input type='checkbox' class='objectType' /> <strong><?php echo $objectTypes[$objectType];?></strong>
</label>
</td>
<?php $messageSetting = is_string($config->message->setting) ? json_decode($config->message->setting, true) : $config->message->setting;?>
<?php foreach($lang->message->typeList as $type => $typeName):?>
<?php if(isset($config->message->available[$type][$objectType])):?>
<?php
$availableActions = array();
foreach($config->message->available[$type][$objectType] as $action)
{
if(!isset($objectActions[$objectType][$action])) continue;
$availableActions[$action] = $objectActions[$objectType][$action];
}
?>
<td>
<?php
echo html::checkbox("messageSetting[$type][setting][$objectType]", $availableActions, isset($messageSetting[$type]['setting'][$objectType]) ? join(',', $messageSetting[$type]['setting'][$objectType]) : '');
if(isset($config->message->condition[$type][$objectType]))
{
$moduleName = $objectType == 'case' ? 'testcase' : $objectType;
$this->app->loadLang($moduleName);
foreach(explode(',', $config->message->condition[$type][$objectType]) as $condition)
{
$listKey = $condition . 'List';
$list = isset($this->lang->$moduleName->$listKey) ? $this->lang->$moduleName->$listKey : $users;
echo html::select("messageSetting[$type][condition][$objectType][$condition][]", $list, isset($messageSetting[$type]['condition'][$objectType][$condition]) ? join(',', $messageSetting[$type]['condition'][$objectType][$condition]) : '', "class='form-control chosen' multiple data-placeholder='{$this->lang->$moduleName->$condition}'");
}
}
?>
</td>
<?php else:?>
<td></td>
<?php endif;?>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='<?php echo count($lang->message->typeList) + 1?>' class='text-center'><?php echo html::submitButton() . html::backButton();?></td>
</tr>
</tfoot>
</table>
</form>
<script>
$(function(){$('#featurebar .nav #settingTab').addClass('active');})
</script>
<?php include '../../common/view/footer.html.php';?>
-3
View File
@@ -400,9 +400,6 @@ class project extends control
$mails = $this->project->importBug($projectID);
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('task');
foreach($mails as $mail) $this->task->sendmail($mail->taskID, $mail->actionID);
die(js::locate($this->createLink('project', 'importBug', "projectID=$projectID"), 'parent'));
}
+1 -20
View File
@@ -74,7 +74,6 @@ class story extends control
$action = $bugID == 0 ? 'Opened' : 'Frombug';
$extra = $bugID == 0 ? '' : $bugID;
$actionID = $this->action->create('story', $storyID, $action, '', $extra);
$this->story->sendmail($storyID, $actionID);
if($todoID > 0)
{
@@ -227,11 +226,7 @@ class story extends control
if(dao::isError()) die(js::error(dao::getError()));
$stories = array();
foreach($mails as $mail)
{
$stories[] = $mail->storyID;
if($mail->actionID) $this->story->sendmail($mail->storyID, $mail->actionID);
}
foreach($mails as $mail) $stories[] = $mail->storyID;
if($project) $this->loadModel('project')->linkStory($project, $stories);
/* If storyID not equal zero, subdivide this story to child stories and close it. */
@@ -241,7 +236,6 @@ class story extends control
$actionID = $this->story->subdivide($storyID, $mails);
if(dao::isError()) die(js::error(dao::getError()));
$this->story->sendmail($storyID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate(inlink('view', "storyID=$storyID"), 'parent'));
@@ -375,7 +369,6 @@ 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->story->sendmail($storyID, $actionID);
}
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -419,7 +412,6 @@ class story extends control
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->story->sendmail($storyID, $actionID);
}
}
die(js::locate($this->session->storyList, 'parent'));
@@ -553,7 +545,6 @@ 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->story->sendmail($storyID, $actionID);
}
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -587,7 +578,6 @@ 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->story->sendmail($storyID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
@@ -697,7 +687,6 @@ class story extends control
$result = $this->post->result;
if($this->post->closedReason != '' and strpos('done,postponed,subdivided,willnotdo', $this->post->closedReason) === false) $result = 'pass';
$actionID = $this->action->create('story', $storyID, 'Reviewed', $this->post->comment, ucfirst($result));
$this->story->sendmail($storyID, $actionID);
if($this->post->result == 'reject')
{
$this->action->create('story', $storyID, 'Closed', '', ucfirst($this->post->closedReason));
@@ -751,7 +740,6 @@ 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->story->sendmail($storyID, $actionID);
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
die(js::locate($this->session->storyList, 'parent'));
}
@@ -771,7 +759,6 @@ 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->story->sendmail($storyID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate(inlink('view', "storyID=$storyID"), 'parent'));
}
@@ -818,7 +805,6 @@ 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->story->sendmail($storyID, $actionID);
}
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
@@ -899,7 +885,6 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->story->sendmail($storyID, $actionID);
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
die(js::reload('parent'));
@@ -922,7 +907,6 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->story->sendmail($storyID, $actionID);
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
die(js::reload('parent'));
@@ -945,7 +929,6 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->story->sendmail($storyID, $actionID);
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
die(js::reload('parent'));
@@ -970,7 +953,6 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, $action);
$this->action->logHistory($actionID, $changes);
$this->story->sendmail($storyID, $actionID);
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
die(js::locate($this->session->storyList, 'parent'));
@@ -992,7 +974,6 @@ class story extends control
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->story->sendmail($storyID, $actionID);
}
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
+39 -9
View File
@@ -2508,9 +2508,8 @@ class storyModel extends model
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');
$story = $this->getById($storyID);
$users = $this->loadModel('user')->getPairs('noletter');
/* Get actions. */
$action = $this->loadModel('action')->getById($actionID);
@@ -2545,14 +2544,47 @@ class storyModel extends model
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()) trigger_error(join("\n", $this->mail->getError()));
}
/**
* Get mail subject.
*
* @param object $story
* @access public
* @return string
*/
public function getSubject($story)
{
$productName = $this->loadModel('product')->getById($story->product)->name;
return 'STORY #' . $story->id . ' ' . $story->title . ' - ' . $productName;
}
/**
* Get toList and ccList.
*
* @param object $story
* @param string $actionType
* @access public
* @return bool|array
*/
public function getToAndCcList($story, $actionType)
{
/* 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')
if(strtolower($actionType) == 'changed' or strtolower($actionType) == 'reviewed')
{
$prjMembers = $this->getProjectMembers($storyID);
$prjMembers = $this->getProjectMembers($story->id);
if($prjMembers)
{
$ccList .= ',' . join(',', $prjMembers);
@@ -2562,7 +2594,7 @@ class storyModel extends model
if(empty($toList))
{
if(empty($ccList)) return;
if(empty($ccList)) return false;
if(strpos($ccList, ',') === false)
{
$toList = $ccList;
@@ -2580,8 +2612,6 @@ class storyModel extends model
$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()));
return array($toList, $ccList);
}
}
+1 -17
View File
@@ -112,8 +112,7 @@ class task extends control
if($taskID['status'] == 'exists') continue;
$taskID = $taskID['id'];
$actionID = $this->action->create('task', $taskID, 'Opened', '');
$this->task->sendmail($taskID, $actionID);
$this->action->create('task', $taskID, 'Opened', '');
}
/* If link from no head then reload*/
@@ -208,8 +207,6 @@ class task extends control
$mails = $this->task->batchCreate($projectID);
if(dao::isError()) die(js::error(dao::getError()));
foreach($mails as $mail) $this->task->sendmail($mail->taskID, $mail->actionID);
/* Locate the browser. */
if($iframe) die(js::reload('parent.parent'));
die(js::locate($storyLink, 'parent'));
@@ -290,7 +287,6 @@ 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->task->sendmail($taskID, $actionID);
}
if($task->fromBug != 0)
@@ -343,7 +339,6 @@ class task extends control
$actionID = $this->loadModel('action')->create('task', $taskID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
$task = $this->task->getById($taskID);
if($task->fromBug != 0)
@@ -443,7 +438,6 @@ 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->task->sendmail($taskID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
@@ -489,7 +483,6 @@ class task extends control
$this->loadModel('action');
$actionID = $this->action->create('task', $taskID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
}
@@ -519,7 +512,6 @@ 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->task->sendmail($taskID, $actionID);
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
die(js::reload('parent'));
@@ -620,7 +612,6 @@ 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->task->sendmail($taskID, $actionID);
}
/* Remind whether to update status of the bug, if task which from that bug has been finished. */
@@ -773,7 +764,6 @@ 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->task->sendmail($taskID, $actionID);
}
if($this->task->needUpdateBugStatus($task))
@@ -882,7 +872,6 @@ 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->task->sendmail($taskID, $actionID);
}
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
@@ -915,7 +904,6 @@ class task extends control
{
$actionID = $this->action->create('task', $taskID, 'Closed', $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
}
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
@@ -956,7 +944,6 @@ class task extends control
{
$actionID = $this->action->create('task', $taskID, 'Canceled', '');
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
}
}
}
@@ -997,7 +984,6 @@ class task extends control
{
$actionID = $this->action->create('task', $taskID, 'Closed', '');
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
}
}
if(isset($skipTasks) and empty($skipTaskIdList))
@@ -1033,7 +1019,6 @@ class task extends control
{
$actionID = $this->action->create('task', $taskID, 'Canceled', $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
}
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
@@ -1067,7 +1052,6 @@ class task extends control
{
$actionID = $this->action->create('task', $taskID, 'Activated', $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->task->sendmail($taskID, $actionID);
}
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
+36 -7
View File
@@ -2224,9 +2224,8 @@ class taskModel extends model
public function sendmail($taskID, $actionID)
{
$this->loadModel('mail');
$task = $this->getById($taskID);
$users = $this->loadModel('user')->getPairs('noletter');
$projectName = $this->loadModel('project')->getById($task->project)->name;
$task = $this->getById($taskID);
$users = $this->loadModel('user')->getPairs('noletter');
/* Get action info. */
$action = $this->loadModel('action')->getById($actionID);
@@ -2253,13 +2252,45 @@ class taskModel extends model
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()) trigger_error(join("\n", $this->mail->getError()));
}
/**
* Get mail subject.
*
* @param object $task
* @access public
* @return string
*/
public function getSubject($task)
{
$projectName = $this->loadModel('project')->getById($task->project)->name;
return 'TASK#' . $task->id . ' ' . $task->name . ' - ' . $projectName;
}
/**
* Get toList and ccList.
*
* @param object $task
* @access public
* @return bool|array
*/
public function getToAndCcList($task)
{
/* Set toList and ccList. */
$toList = $task->assignedTo;
$ccList = trim($task->mailto, ',');
if(empty($toList))
{
if(empty($ccList)) return;
if(empty($ccList)) return false;
if(strpos($ccList, ',') === false)
{
$toList = $ccList;
@@ -2277,9 +2308,7 @@ class taskModel extends model
$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()));
return array($toList, $ccList);
}
/**
+1 -6
View File
@@ -103,8 +103,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->testtask->sendmail($taskID, $actionID);
$this->loadModel('action')->create('testtask', $taskID, 'opened');
die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent'));
}
@@ -423,9 +422,6 @@ class testtask extends control
{
$actionID = $this->loadModel('action')->create('testtask', $taskID, 'edited');
$this->action->logHistory($actionID, $changes);
/* send mail.*/
$this->testtask->sendmail($taskID, $actionID);
}
die(js::locate(inlink('view', "taskID=$taskID"), 'parent'));
}
@@ -553,7 +549,6 @@ class testtask extends control
{
$actionID = $this->action->create('testtask', $taskID, 'Closed', $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->testtask->sendmail($taskID, $actionID);
}
if(isonlybody()) die(js::reload('parent.parent'));
+47 -19
View File
@@ -1255,12 +1255,57 @@ class testtaskModel extends model
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()) trigger_error(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, $tasktask->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.
*
* @param object $testtask
* @access public
* @return bool|array
*/
public function getToAndCcList($testtask)
{
/* Set toList and ccList. */
$toList = $testtask->owner;
$ccList = str_replace(' ', '', trim($testtask->mailto, ','));
if(empty($toList))
{
if(empty($ccList)) return;
if(empty($ccList)) return false;
if(strpos($ccList, ',') === false)
{
$toList = $ccList;
@@ -1273,23 +1318,6 @@ class testtaskModel extends model
$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()));
return array($toList, $ccList);
}
}
-9
View File
@@ -5,15 +5,6 @@ $config->webhook->create->requiredFields = 'name, url';
$config->webhook->edit = new stdclass();
$config->webhook->edit->requiredFields = 'name, url';
$config->webhook->objectTypes['release'] = array('opened', 'edited', 'changestatus');
$config->webhook->objectTypes['build'] = array('opened', 'edited');
$config->webhook->objectTypes['testsuite'] = array('opened', 'edited');
$config->webhook->objectTypes['caselib'] = array('opened', 'edited');
$config->webhook->objectTypes['testreport'] = array('opened', 'edited');
$config->webhook->objectTypes['doc'] = array('created', 'edited', 'commented');
$config->webhook->objectTypes['doclib'] = array('created', 'edited');
$config->webhook->objectTypes['user'] = array('login', 'logout');
/* Unset entry to hide actions. */
$config->webhook->objectTypes = array();
$config->webhook->objectTypes['product'] = array('opened', 'edited', 'closed', 'undeleted');
+6 -4
View File
@@ -11,6 +11,12 @@
*/
class webhook extends control
{
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
$this->loadModel('message');
}
/**
* Browse webhooks.
*
@@ -54,8 +60,6 @@ class webhook extends control
$this->view->title = $this->lang->webhook->api . $this->lang->colon . $this->lang->webhook->create;
$this->view->products = $this->loadModel('product')->getPairs();
$this->view->projects = $this->loadModel('project')->getPairs();
$this->view->objectTypes = $this->webhook->getObjectTypes();
$this->view->objectActions = $this->webhook->getObjectActions();
$this->view->position[] = html::a(inlink('browse'), $this->lang->webhook->api);
$this->view->position[] = html::a(inlink('browse'), $this->lang->webhook->common);
$this->view->position[] = $this->lang->webhook->create;
@@ -83,8 +87,6 @@ class webhook extends control
$this->view->title = $this->lang->webhook->edit . $this->lang->colon . $webhook->name;
$this->view->products = $this->loadModel('product')->getPairs();
$this->view->projects = $this->loadModel('project')->getPairs();
$this->view->objectTypes = $this->webhook->getObjectTypes();
$this->view->objectActions = $this->webhook->getObjectActions();
$this->view->position[] = html::a(inlink('browse'), $this->lang->webhook->api);
$this->view->position[] = html::a(inlink('browse'), $this->lang->webhook->common);
$this->view->position[] = $this->lang->webhook->edit;
-40
View File
@@ -21,7 +21,6 @@ class webhookModel extends model
public function getByID($id)
{
$webhook = $this->dao->select('*')->from(TABLE_WEBHOOK)->where('id')->eq($id)->fetch();
$webhook->actions = json_decode($webhook->actions);
return $webhook;
}
@@ -41,7 +40,6 @@ class webhookModel extends model
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
if($decode) foreach($webhooks as $webhook) $webhook->actions = json_decode($webhook->actions);
return $webhooks;
}
@@ -99,41 +97,6 @@ class webhookModel extends model
return $this->dao->select('*')->from(TABLE_NOTIFY)->where('status')->eq('wait')->andWhere('objectType')->eq('webhook')->orderBy('id')->fetchAll('id');
}
/**
* Get object types.
*
* @access public
* @return array
*/
public function getObjectTypes()
{
$objectTypes = array();
foreach($this->config->webhook->objectTypes as $objectType => $actions)
{
$objectTypes[$objectType] = $this->lang->action->objectTypes[$objectType];
}
return $objectTypes;
}
/**
* Get object actions.
*
* @access public
* @return array
*/
public function getObjectActions()
{
$objectActions = array();
foreach($this->config->webhook->objectTypes as $objectType => $actions)
{
foreach($actions as $action)
{
$objectActions[$objectType][$action] = str_replace($this->lang->webhook->trimWords, '', $this->lang->action->label->$action);
}
}
return $objectActions;
}
/**
* Create a webhook.
*
@@ -151,7 +114,6 @@ class webhookModel extends model
->remove('allParams, allActions')
->get();
$webhook->params = $this->post->params ? implode(',', $this->post->params) . ',text' : 'text';
$webhook->actions = $this->post->actions ? json_encode($this->post->actions) : '[]';
$this->dao->insert(TABLE_WEBHOOK)->data($webhook)
->batchCheck($this->config->webhook->create->requiredFields, 'notempty')
@@ -180,7 +142,6 @@ class webhookModel extends model
->remove('allParams, allActions')
->get();
$webhook->params = $this->post->params ? implode(',', $this->post->params) . ',text' : 'text';
$webhook->actions = $this->post->actions ? json_encode($this->post->actions) : '[]';
$this->dao->update(TABLE_WEBHOOK)->data($webhook)
->batchCheck($this->config->webhook->edit->requiredFields, 'notempty')
@@ -208,7 +169,6 @@ class webhookModel extends model
foreach($webhooks as $id => $webhook)
{
if(!isset($webhook->actions->$objectType) or !in_array($actionType, $webhook->actions->$objectType)) continue;
$postData = $this->buildData($objectType, $objectID, $actionType, $actionID, $webhook);
if(!$postData) continue;
+1 -28
View File
@@ -10,16 +10,10 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include 'header.html.php';?>
<?php include '../../common/view/form.html.php';?>
<?php js::set('urlNote', $lang->webhook->note->typeList);?>
<div class='container mw-1400px'>
<div id="titlebar">
<div class="heading">
<strong><?php echo $lang->webhook->api;?></strong>
<small class="text-muted"> <?php echo $lang->webhook->create;?></small>
</div>
</div>
<form id='webhookForm' method='post' class='ajaxForm'>
<table class='table table-form'>
<tr>
@@ -60,27 +54,6 @@
</th>
<td class='labelWidth' colspan='2'><?php echo html::checkbox('params', $lang->webhook->paramsList, 'text');?></td>
</tr>
<tr>
<th>
<label class='checkbox-inline'>
<input type='checkbox' id='allActions' name='allActions'><strong><?php echo $lang->webhook->action;?></strong>
</label>
</th>
<td colspan='2'>
<table class='table table-bordered'>
<?php foreach($config->webhook->objectTypes as $objectType => $actions):?>
<tr>
<th class='w-80px'>
<label class='checkbox-inline'>
<input type='checkbox' class='objectType'><strong><?php echo $objectTypes[$objectType];?></strong>
</label>
</th>
<td class='labelWidth'><?php echo html::checkbox("actions[$objectType]", $objectActions[$objectType]);?></td>
</tr>
<?php endforeach;?>
</table>
</td>
</tr>
<tr>
<th><?php echo $lang->webhook->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', '', "rows='3' class='form-control'");?></td>
+1 -29
View File
@@ -10,15 +10,9 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include 'header.html.php';?>
<?php include '../../common/view/form.html.php';?>
<div class='container mw-1400px'>
<div id="titlebar">
<div class="heading">
<strong><?php echo $lang->webhook->api;?></strong>
<small class="text-muted"> <?php echo $lang->webhook->edit;?></small>
</div>
</div>
<form id='webhookForm' method='post' class='ajaxForm'>
<table class='table table-form'>
<tr>
@@ -63,28 +57,6 @@
<td class='labelWidth' colspan='2'><?php echo html::checkbox('params', $lang->webhook->paramsList, $webhook->params);?></td>
</tr>
<?php endif;?>
<tr>
<th>
<label class='checkbox-inline'>
<input type='checkbox' id='allActions' name='allActions'><strong><?php echo $lang->webhook->action;?></strong>
</label>
</th>
<td colspan='2'>
<table class='table table-bordered'>
<?php foreach($config->webhook->objectTypes as $objectType => $actions):?>
<tr>
<td class='w-80px'>
<label class='checkbox-inline'>
<?php $checked = isset($webhook->actions->$objectType) ? "checked='checked'" : '';?>
<input type='checkbox' <?php echo $checked;?> class='objectType'><strong><?php echo $objectTypes[$objectType];?></strong>
</label>
</td>
<td class='labelWidth'><?php echo html::checkbox("actions[$objectType]", $objectActions[$objectType], isset($webhook->actions->$objectType) ? $webhook->actions->$objectType : '');?></td>
</tr>
<?php endforeach;?>
</table>
</td>
</tr>
<tr>
<th><?php echo $lang->webhook->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', $webhook->desc, "rows='3' class='form-control'");?></td>
+7 -2
View File
@@ -13,8 +13,13 @@
<?php include '../../common/view/header.html.php';?>
<div id='featurebar'>
<ul class='nav'>
<li id='entry'><?php //common::printLink('entry', 'browse', '', $lang->webhook->entry);?></li>
<li id='webhook' class='active'><?php common::printLink('webhook', 'browse', '', $lang->webhook->common);?></li>
<?php foreach($lang->message->typeList as $type => $typeName):?>
<?php if(isset($config->message->typeLink[$type])):?>
<?php list($moduleName, $methodName) = explode('|', $config->message->typeLink[$type]);?>
<li id='<?php echo $type;?>Tab' <?php if($type == 'webhook') echo "class='active'"?>><?php echo html::a($this->createLink($moduleName, $methodName), $typeName)?></li>
<?php endif;?>
<?php endforeach;?>
<li id='settingTab'><?php echo html::a($this->createLink('message', 'setting'), $lang->message->setting)?></li>
</ul>
<div class='actions'>
<div class='btn-group'>
+1 -1
View File
@@ -10,7 +10,7 @@
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include 'header.html.php';?>
<div id="titlebar">
<div class="heading">
<strong><?php echo html::a(inlink('browse'), $lang->webhook->common);?></strong>