* [perf story #69156] Adjust for get to and cc list.
This commit is contained in:
+1
-1
@@ -238,7 +238,7 @@ class mailTao extends mailModel
|
||||
$objectModel = $this->loadModel($objectType);
|
||||
if(!$objectModel) return false;
|
||||
|
||||
if($objectType == 'story' or $objectType == 'meeting') return $objectModel->getToAndCcList($object, $action->action);
|
||||
if(in_array($objectType, array('story', 'task', 'meeting'))) return $objectModel->getToAndCcList($object, $action->action);
|
||||
if($objectType == 'ticket') return $objectModel->getToAndCcList($object, $action);
|
||||
return $objectModel->getToAndCcList($object);
|
||||
}
|
||||
|
||||
@@ -254,17 +254,10 @@ class messageModel extends model
|
||||
list($toList, $ccList) = $this->loadModel($objectType)->getToAndCcList($object);
|
||||
$toList = $toList . ',' . $ccList;
|
||||
}
|
||||
if(empty($toList) && $objectType == 'task' && $object->mode == 'multi')
|
||||
{
|
||||
/* Get task team members. */
|
||||
$teamMembers = $this->loadModel('task')->getMultiTaskMembers($object->id);
|
||||
$toList = array_filter($teamMembers, function($account){return $account != $this->app->user->account; });
|
||||
$toList = implode(',', $toList);
|
||||
}
|
||||
|
||||
if($toList == 'closed') $toList = '';
|
||||
if($objectType == 'feedback' && $object->status == 'replied') $toList = ',' . $object->openedBy . ',';
|
||||
if(in_array($objectType, array('story', 'epic', 'requirement')) && $actionID)
|
||||
if(in_array($objectType, array('story', 'epic', 'requirement', 'task')) && $actionID)
|
||||
{
|
||||
$action = $this->loadModel('action')->getById($actionID);
|
||||
list($toList, $ccList) = $this->loadModel($objectType)->getToAndCcList($object, $action->action);
|
||||
@@ -301,10 +294,7 @@ class messageModel extends model
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
$flow = $this->loadModel('workflow')->getByModule($objectType);
|
||||
if($flow && !$flow->buildin)
|
||||
{
|
||||
$toList = $this->loadModel('flow')->getToList($flow, $object->id);
|
||||
}
|
||||
if($flow && !$flow->buildin) $toList = $this->loadModel('flow')->getToList($flow, $object->id);
|
||||
}
|
||||
|
||||
return trim($toList, ',');
|
||||
|
||||
+16
-7
@@ -2061,10 +2061,11 @@ class taskModel extends model
|
||||
* Get toList and ccList.
|
||||
*
|
||||
* @param object $task
|
||||
* @param string $action
|
||||
* @access public
|
||||
* @return array|false
|
||||
*/
|
||||
public function getToAndCcList(object $task): array|false
|
||||
public function getToAndCcList(object $task, string $action): array|false
|
||||
{
|
||||
/* Set assignedTo and mailto. */
|
||||
$assignedTo = $task->assignedTo;
|
||||
@@ -2089,6 +2090,17 @@ class taskModel extends model
|
||||
$assignedTo = $task->finishedBy;
|
||||
}
|
||||
|
||||
if(in_array($action, array('paused', 'closed', 'canceled')) && $task->parent > 0)
|
||||
{
|
||||
$parentTasks = $this->dao->select('id,assignedTo,finishedBy,mailto')->from(TABLE_TASK)->where('id')->in($task->path)->fetchAll('id');
|
||||
foreach($parentTasks as $parentID => $parentTask)
|
||||
{
|
||||
$mailto[] = (strtolower($parentTask->assignedTo) == 'closed') ? $parentTask->finishedBy : $parentTask->assignedTo;
|
||||
$mailto += is_null($parentTask->mailto) ? array() : explode(',', trim($parentTask->mailto, ','));
|
||||
}
|
||||
}
|
||||
$mailto = array_unique(array_filter(array_map(function($account) use($assignedTo){ return $account == $assignedTo ? '' : $account;}, $mailto)));
|
||||
|
||||
return array($assignedTo, implode(',', $mailto));
|
||||
}
|
||||
|
||||
@@ -2457,9 +2469,6 @@ class taskModel extends model
|
||||
/* Update kanban status. */
|
||||
$this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq($task->id)->exec();
|
||||
|
||||
/* If task has parent task, update status of the parent task by the child task. */
|
||||
if($oldTask->parent > 0) $this->updateParentStatus($task->id);
|
||||
|
||||
/* If output is not empty, update kanban cell. */
|
||||
$this->updateKanbanCell($task->id, $output, $oldTask->execution);
|
||||
|
||||
@@ -3243,20 +3252,20 @@ class taskModel extends model
|
||||
$status = $this->taskTao->getParentStatusById($parentID);
|
||||
if(empty($status))
|
||||
{
|
||||
$this->dao->update(TABLE_TASK)->set('parent')->eq('0')->set('path')->eq(",{$parentID},")->where('id')->eq($parentID)->exec();
|
||||
$this->dao->update(TABLE_TASK)->set('parent')->eq('0')->set('isParent')->eq(0)->set('path')->eq(",{$parentID},")->where('id')->eq($parentID)->exec();
|
||||
continue;
|
||||
}
|
||||
if(!in_array($status, array('doing', 'done'))) continue;
|
||||
if($parentTask->status == $status) continue;
|
||||
|
||||
/* Update task status. */
|
||||
$this->taskTao->updateTaskByChildAndStatus($parentTask, $childTask, $status);
|
||||
$this->taskTao->autoUpdateTaskByStatus($parentTask, $childTask, $status);
|
||||
if(dao::isError() || !$createAction) return;
|
||||
|
||||
if($parentTask->story) $this->story->setStage($parentTask->story);
|
||||
|
||||
/* Create action record. */
|
||||
$this->taskTao->createUpdateParentTaskAction($parentTask);
|
||||
$this->taskTao->createAutoUpdateAction($parentTask);
|
||||
if($this->config->edition != 'open' && $parentTask->feedback) $this->loadModel('feedback')->updateStatus('task', $parentTask->feedback, $status, $parentTask->status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,15 +1012,16 @@ class taskTest
|
||||
* Test get toList and ccList.
|
||||
*
|
||||
* @param int $taskID
|
||||
* @param string $action
|
||||
* @access public
|
||||
* @return array|false
|
||||
*/
|
||||
public function getToAndCcListTest(int $taskID): array|false
|
||||
public function getToAndCcListTest(int $taskID, string $action = ''): array|false
|
||||
{
|
||||
$task = $this->objectModel->getByID($taskID);
|
||||
if(empty($task)) return false;
|
||||
|
||||
return $this->objectModel->getToAndCcList($task);
|
||||
return $this->objectModel->getToAndCcList($task, $action);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/task.unittest.class.php';
|
||||
|
||||
zenData('task')->loadYaml('task')->gen(5);
|
||||
zenData('task')->loadYaml('task')->gen(9);
|
||||
zenData('taskteam')->loadYaml('taskteam')->gen(5);
|
||||
su('admin');
|
||||
|
||||
@@ -14,12 +14,14 @@ cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
$taskIDList = array('1', '2', '3', '4', '5', '10');
|
||||
$taskIDList = array('1', '2', '3', '4', '5', '7', '10');
|
||||
|
||||
$task = new taskTest();
|
||||
$task4Result = $task->getToAndCcListTest($taskIDList[3]);
|
||||
r(count($task->getToAndCcListTest($taskIDList[0]), true)) && p() && e('2'); //计算无assignedto 无mailto的发信列表
|
||||
r($task->getToAndCcListTest($taskIDList[1])) && p('0') && e('admin'); //计算有assignedto 无mailto的发信列表
|
||||
r($task->getToAndCcListTest($taskIDList[2])) && p('0,1') && e('admin,user1'); //计算有assignedto 有mailto的发信列表
|
||||
r($task->getToAndCcListTest($taskIDList[3])) && p('0,1') && e('admin,user1'); //计算无assignedto 多mailto的发信列表
|
||||
r($task->getToAndCcListTest($taskIDList[4])) && p('0') && e('user1'); //计算无assignedto 单个mailto的发信列表
|
||||
r($task->getToAndCcListTest($taskIDList[5])) && p() && e('0'); //计算不存在的task的发信列表
|
||||
r($task4Result[0]) && p() && e('user2'); //计算无assignedto 多mailto的发信列表的toList
|
||||
r($task4Result[1]) && p() && e('admin,user1'); //计算无assignedto 多mailto的发信列表的ccList
|
||||
r($task->getToAndCcListTest($taskIDList[4])) && p('0') && e('user3'); //计算无assignedto 单个mailto的发信列表
|
||||
r($task->getToAndCcListTest($taskIDList[6])) && p() && e('0'); //计算不存在的task的发信列表
|
||||
|
||||
@@ -23,7 +23,7 @@ fields:
|
||||
- field: deleted
|
||||
range: 0{9},1{3}
|
||||
- field: assignedTo
|
||||
range: "[],admin{2},[]{3}"
|
||||
range: "[],admin{2},user2,user3,user4,user5,[]{3}"
|
||||
- field: mailto
|
||||
fields:
|
||||
- field: mailto1
|
||||
|
||||
Reference in New Issue
Block a user