diff --git a/trunk/module/task/control.php b/trunk/module/task/control.php index cc62cd7255..8119b0f756 100644 --- a/trunk/module/task/control.php +++ b/trunk/module/task/control.php @@ -45,7 +45,8 @@ class task extends control $taskID = $this->task->create($projectID); if(dao::isError()) die(js::error(dao::getError())); $this->loadModel('action'); - $this->action->create('task', $taskID, 'Opened', ''); + $actionID = $this->action->create('task', $taskID, 'Opened', ''); + $this->sendmail($taskID, $actionID); if($this->post->after == 'continueAdding') { echo js::alert($this->lang->task->successSaved . $this->lang->task->afterChoices['continueAdding']); @@ -74,16 +75,17 @@ class task extends control $this->assign('stories', $stories); $this->assign('storyID', $storyID); $this->assign('members', $members); + $this->assign('users', $this->loadModel('user')->getPairs('noletter')); $this->display(); } /* 公共的操作。*/ public function commonAction($taskID) { - $this->view->task = $this->task->getById($taskID); + $this->view->task = $this->task->getByID($taskID); $this->view->project = $this->project->getById($this->view->task->project); $this->view->members = $this->project->getTeamMemberPairs($this->view->project->id); - $this->view->users = $this->view->members; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->actions = $this->loadModel('action')->getList('task', $taskID); /* 设置菜单。*/ @@ -112,6 +114,7 @@ class task extends control if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; $actionID = $this->action->create('task', $taskID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); + $this->sendmail($taskID, $actionID); } die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } @@ -144,6 +147,7 @@ class task extends control if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; $actionID = $this->action->create('task', $taskID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); + $this->sendmail($taskID, $actionID); } die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } @@ -207,6 +211,45 @@ class task extends control } } + /* 发送邮件。*/ + private function sendmail($taskID, $actionID) + { + /* 设定toList和ccList。*/ + $task = $this->task->getByID($taskID); + $toList = $task->owner; + + $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); + } + } + + /* 获得action信息。*/ + $action = $this->action->getById($actionID); + $history = $this->action->getHistory($actionID); + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + + /* 赋值,获得邮件内容。*/ + $this->assign('task', $task); + $this->assign('action', $action); + $mailContent = $this->parse($this->moduleName, 'sendmail'); + + /* 发信。*/ + $this->loadModel('mail')->send($toList, 'TASK#' . $task->id . $this->lang->colon . $task->name, $mailContent, $ccList); + if($this->mail->isError()) echo js::error($this->mail->getError()); + } + /* Ajax请求: 返回用户任务的下拉列表框。*/ public function ajaxGetUserTasks($account = '', $status = 'wait,doing') { diff --git a/trunk/module/task/lang/zh-cn.php b/trunk/module/task/lang/zh-cn.php index b2d19f528f..69a3eb2534 100644 --- a/trunk/module/task/lang/zh-cn.php +++ b/trunk/module/task/lang/zh-cn.php @@ -42,6 +42,7 @@ $lang->task->name = '任务名称'; $lang->task->type = '任务类型'; $lang->task->pri = '优先级'; $lang->task->owner = '指派给'; +$lang->task->mailto = '抄送给'; $lang->task->estimate = '最初预计'; $lang->task->estimateAB = '预计'; $lang->task->left = '预计剩余'; diff --git a/trunk/module/task/model.php b/trunk/module/task/model.php index 0d1a853df1..8b6c86b92b 100644 --- a/trunk/module/task/model.php +++ b/trunk/module/task/model.php @@ -97,6 +97,13 @@ class taskModel extends model ->where('t1.id')->eq((int)$taskID) ->fetch(); if(!$task) return false; + if($task->mailto) + { + $task->mailto = ltrim(trim($task->mailto), ','); // 去掉开始的,。 + $task->mailto = str_replace(' ', '', $task->mailto); + $task->mailto = rtrim($task->mailto, ',') . ','; + $task->mailto = str_replace(',', ', ', $task->mailto); + } $task->files = $this->loadModel('file')->getByObject('task', $taskID); return $this->processTask($task); } diff --git a/trunk/module/task/view/create.html.php b/trunk/module/task/view/create.html.php index def7f3516e..4aeb64d53f 100644 --- a/trunk/module/task/view/create.html.php +++ b/trunk/module/task/view/create.html.php @@ -32,7 +32,11 @@ function copyStoryTitle() storyTitle = storyTitle.substr(storyTitle.lastIndexOf(':')+ 1); $('#name').attr('value', storyTitle); } - +function sendMailTo() +{ + var userList = "".split(','); + $("#mailto").autocomplete(userList, { multiple: true, mustMatch: true}); +} /* 设置预览的链接。*/ function setPreview() { @@ -84,6 +88,10 @@ $(document).ready(function()