+ add the feature of sendmail of story.

This commit is contained in:
wangchunsheng
2010-02-11 03:17:04 +00:00
parent f9bd56cae7
commit 36e07e1cbd
5 changed files with 100 additions and 22 deletions
+2 -2
View File
@@ -375,11 +375,11 @@ class bug extends control
die(html::select('bug', $bugs, '', 'class=select-1'));
}
/* 发送变量。*/
/* 发送邮件。*/
private function sendmail($bugID, $actionID)
{
/* 设定toList和ccList。*/
$bug = $this->bug->getByID($bugID);
$bug = $this->bug->getByID($bugID);
$toList = $bug->assignedTo;
$ccList = trim($bug->mailto, ',');
if($toList == '')
+5 -19
View File
@@ -1,23 +1,9 @@
<span><?php echo "$action->date, <strong>$action->action</strong> by <strong>$action->actor</strong>"; ?></span>
<?php if(!empty($action->comment) or !empty($histories)):?>
<?php if(isset($users[$action->actor])) $action->actor = $users[$action->actor];?>
<span><?php $this->action->printAction($action);?>
<?php if(!empty($action->comment) or !empty($action->history)):?>
<div class='history'>
<?php
if(!empty($histories))
{
foreach($histories[$action->id] as $history)
{
if($history->diff != '')
{
echo "CHANGE <strong>$history->field</strong>, the diff is: <blockquote>" . nl2br($history->diff) . "</blockquote>";
}
else
{
echo "CHANGE <strong>$history->field</strong> FROM '$history->old' TO '$history->new' . <br />";
}
}
}
echo nl2br($action->comment);
?>
<div><?php echo $this->action->printChanges($action->objectType, $action->history);?></div>
<?php if($action->comment and $action->history) echo '<br />'; echo nl2br($action->comment);?>
</div>
<?php endif;?>
<style>
+48 -1
View File
@@ -40,7 +40,8 @@ class story extends control
$storyID = $this->story->create();
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action');
$this->action->create('story', $storyID, 'Opened', '');
$actionID = $this->action->create('story', $storyID, 'Opened', '');
$this->sendMail($storyID, $actionID);
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -103,6 +104,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);
}
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -132,6 +134,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);
}
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -154,6 +157,7 @@ class story extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('story', $storyID, 'Activated', $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->sendMail($storyID, $actionID);
die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent'));
}
@@ -225,6 +229,7 @@ class story extends control
if(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);
$this->sendMail($storyID, $actionID);
if($this->post->result == 'reject')
{
$this->action->create('story', $storyID, 'Closed', '', ucfirst($this->post->closedReason));
@@ -267,6 +272,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->action->logHistory($actionID);
$this->sendMail($storyID, $actionID);
die(js::locate(inlink('view', "storyID=$storyID"), 'parent'));
}
@@ -315,4 +321,45 @@ class story extends control
$stories = $this->story->getProductStoryPairs($productID, $moduleID);
die(html::select('story', $stories, $storyID, "class=''"));
}
/* 发送邮件。*/
private function sendmail($storyID, $actionID)
{
/* 设定toList和ccList。*/
$story = $this->story->getById($storyID);
$prjMembers = $this->story->getProjectMembers($storyID);
$toList = $story->assignedTo;
$ccList = str_replace(' ', '', trim($story->mailto, ',')) . ',' . join(',', $prjMembers);
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);
}
}
/* 获得action信息。*/
$action = $this->action->getById($actionID);
$history = $this->action->getHistory($actionID);
$action->history = isset($history[$actionID]) ? $history[$actionID] : array();
if(strtolower($action->action) == 'opened') $action->comment = $story->spec;
/* 赋值,获得邮件内容。*/
$this->view->story = $story;
$this->view->action = $action;
$this->view->users = $this->user->getPairs('noletter');
$mailContent = $this->parse($this->moduleName, 'sendmail');
/* 发信。*/
$this->loadModel('mail')->send($toList, 'STORY #' . $story->id . $this->lang->colon . $story->title, $mailContent, $ccList);
if($this->mail->isError()) echo js::error($this->mail->getError());
}
}
+11
View File
@@ -365,6 +365,17 @@ class storyModel extends model
->orderBy($orderBy)->page($pager)->fetchAll();
}
/* 获得需求所在的活动的项目的成员列表。*/
public function getProjectMembers($storyID)
{
$projects = $this->dao->select('project')
->from(TABLE_PROJECTSTORY)->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t1.story')->eq((int)$storyID)
->andWhere('t2.status')->eq('doing')
->fetchPairs();
if($projects) return($this->dao->select('account')->from(TABLE_TEAM)->where('project')->in($projects)->fetchPairs('account'));
}
/* 格式化需求显示。*/
private function formatStories($stories)
{
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* The mail file of story module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package bug
* @version $Id$
* @link http://www.zentao.cn
*/
?>
<table width='98%' align='center'>
<tr class='header'>
<td>
STORY #<?php echo $story->id . "=>$story->assignedTo " . html::a(common::getSysURL() . $this->createLink('story', 'view', "storyID=$story->id"), $story->title);?>
</td>
</tr>
<tr>
<td><?php include '../../common/mail.html.php';?></td>
</tr>
</table>