diff --git a/module/message/model.php b/module/message/model.php index 26b3403394..529991ef99 100755 --- a/module/message/model.php +++ b/module/message/model.php @@ -136,7 +136,7 @@ class messageModel extends model public function saveNotice(string $objectType, int $objectID, string $actionType, int $actionID, string $actor = ''): bool { if(empty($actor)) $actor = $this->app->user->account; - if(empty($actor)) return false; + if(empty($actor) || !$objectID) return false; $this->loadModel('action'); $user = $this->loadModel('user')->getById($actor); @@ -176,23 +176,24 @@ class messageModel extends model } /** + * 获取抄送给的人员。 * Get toList. * - * @param object $object - * @param string $objectType - * @param int $actionID + * @param object $object + * @param string $objectType + * @param int $actionID * @access public * @return string */ - public function getToList($object, $objectType, $actionID = 0) + public function getToList(object $object, string $objectType, int $actionID = 0): string { $toList = ''; if(!empty($object->assignedTo)) $toList = $object->assignedTo; - if(empty($toList) and $objectType == 'todo') $toList = $object->account; - if(empty($toList) and $objectType == 'testtask') $toList = $object->owner; - if(empty($toList) and $objectType == 'meeting') $toList = $object->host . $object->participant; - if(empty($toList) and $objectType == 'mr') $toList = $object->createdBy . ',' . $object->assignee; - if(empty($toList) and $objectType == 'release') + if(empty($toList) && $objectType == 'todo') $toList = $object->account; + if(empty($toList) && $objectType == 'testtask') $toList = $object->owner; + if(empty($toList) && $objectType == 'meeting') $toList = $object->host . $object->participant; + if(empty($toList) && $objectType == 'mr') $toList = $object->createdBy . ',' . $object->assignee; + if(empty($toList) && $objectType == 'release') { /* Get notifiy persons. */ $notifyPersons = array(); @@ -200,8 +201,9 @@ class messageModel extends model if(!empty($notifyPersons)) $toList = implode(',', $notifyPersons); } - if(empty($toList) and $objectType == 'task' and $object->mode == 'multi') + 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; @@ -210,8 +212,8 @@ class messageModel extends model } if($toList == 'closed') $toList = ''; - if($objectType == 'feedback' and $object->status == 'replied') $toList = ',' . $object->openedBy . ','; - if($objectType == 'story' and $actionID) + if($objectType == 'feedback' && $object->status == 'replied') $toList = ',' . $object->openedBy . ','; + if($objectType == 'story' && $actionID) { $action = $this->loadModel('action')->getById($actionID); list($toList, $ccList) = $this->loadModel($objectType)->getToAndCcList($object, $action->action); diff --git a/module/message/test/message.class.php b/module/message/test/message.class.php index 9f12349049..886c23ae03 100644 --- a/module/message/test/message.class.php +++ b/module/message/test/message.class.php @@ -115,22 +115,25 @@ class messageTest } /** - * Get toList. + * 测试获取要发送的人列表。 + * Test get toList. * - * @param int $objectType + * @param string $objectType + * @param int $objectID + * @param int $actionID * @access public - * @return void + * @return string|array */ - public function getToListTest($objectType) + public function getToListTest(string $objectType, string $objectID, int $actionID): string|array { global $tester; - $table = $tester->config->objectTables[$objectType]; - $object = $tester->dao->select('*')->from($table)->where('id')->eq('1')->fetch(); - $objects = $this->objectModel->getToList($object, $objectType); + $table = $tester->config->objectTables[$objectType]; + $object = $tester->dao->select('*')->from($table)->where('id')->eq($objectID)->fetch(); + $toList = $this->objectModel->getToList($object, $objectType, $actionID); if(dao::isError()) return dao::getError(); - return $objects; + return trim($toList, ','); } /** diff --git a/module/message/test/model/gettolist.php b/module/message/test/model/gettolist.php index 13ff95f71f..04f6f0dfe0 100755 --- a/module/message/test/model/gettolist.php +++ b/module/message/test/model/gettolist.php @@ -10,8 +10,10 @@ zdTable('testtask')->gen(1); zdTable('meeting')->config('meeting')->gen(1); zdTable('mr')->gen(1); zdTable('release')->gen(1); -zdTable('task')->gen(1); +zdTable('task')->config('task')->gen(9); +zdTable('taskteam')->config('taskteam')->gen(9); zdTable('story')->gen(1); +zdTable('action')->gen(2); /** @@ -19,20 +21,20 @@ title=测试 messageModel->getToList(); cid=1 pid=1 -通过一条todo数据展示 >> admin -通过一条testtask数据展示 >> user3 -通过一条meeting数据展示 >> admin,admin, -通过一条mr数据展示 >> admin,admin -通过一条release数据展示 >> admin -通过一条task数据展示 >> 0 - */ $message = new messageTest(); -r($message->getToListTest('todo')) && p() && e('admin'); //通过一条todo数据展示$toList -r($message->getToListTest('testtask')) && p() && e('user3'); //通过一条testtask数据展示$toList -r($message->getToListTest('meeting')) && p() && e('admin,admin,'); //通过一条meeting数据展示$toList -r($message->getToListTest('mr')) && p() && e('admin,admin'); //通过一条mr数据展示$toList -r($message->getToListTest('release')) && p() && e('po1'); //通过一条release数据展示$toList -r($message->getToListTest('task')) && p() && e('0'); //通过一条task数据展示$toList +$objectType = array('todo', 'testtask', 'meeting', 'mr', 'release', 'task', 'story'); +$objectID = array(1, 9); +$actionID = array(0, 2); + +r($message->getToListTest($objectType[0], $objectID[0], $actionID[0])) && p() && e('admin'); // 测试获取 todo 1 action 0 的 toList +r($message->getToListTest($objectType[1], $objectID[0], $actionID[0])) && p() && e('user3'); // 测试获取 testtask 1 action 0 的 toList +r($message->getToListTest($objectType[2], $objectID[0], $actionID[0])) && p() && e('admin,admin'); // 测试获取 meeting 1 action 0 的 toList +r($message->getToListTest($objectType[3], $objectID[0], $actionID[0])) && p() && e('admin,admin'); // 测试获取 mr 1 action 0 的 toList +r($message->getToListTest($objectType[4], $objectID[0], $actionID[0])) && p() && e('po1'); // 测试获取 release 1 action 0 的 toList +r($message->getToListTest($objectType[5], $objectID[0], $actionID[0])) && p() && e('dev1'); // 测试获取 task 1 action 0 的 toList +r($message->getToListTest($objectType[5], $objectID[1], $actionID[0])) && p() && e('user1,user2'); // 测试获取 task 9 action 0 的 toList +r($message->getToListTest($objectType[6], $objectID[0], $actionID[0])) && p() && e('admin'); // 测试获取 story 1 action 0 的 toList +r($message->getToListTest($objectType[6], $objectID[0], $actionID[1])) && p() && e('admin'); // 测试获取 story 1 action 0 的 toList diff --git a/module/message/test/yaml/task.yaml b/module/message/test/yaml/task.yaml index 86b6d9b526..ad7cecf018 100644 --- a/module/message/test/yaml/task.yaml +++ b/module/message/test/yaml/task.yaml @@ -1,7 +1,51 @@ -title: table_task +title: zt_task desc: "任务" author: Mengyi Liu version: "1.0" fields: + - field: id + range: 1-100 + - field: project + range: 1 + - field: execution + range: 3 + - field: module + range: 0{3},1{3},2{3},3{3} + - field: story + range: 1,0{9} + - field: consumed + range: 0,2{4},0{3},3 + - field: parent + range: "0{5},`-1`,6,0{2}" + - field: status + range: "wait,doing,done,cancel,closed,wait{3},doing" + - field: mode + range: "[]{7},linear,multi" + - field: deleted + range: 0{9},1{3} - field: assignedTo - range: user1,user2,dev1,dev2 + range: "dev1{4},dev2{4},[]" + - field: mailto + fields: + - field: mailto1 + range: "[]{3},admin,[]{2}" + postfix: "," + - field: mailto2 + range: "[]{2},user1{3}" + - field: estStarted + range: "20201101 000000:1D" + type: timestamp + format: "YYYY-MM-DD" + - field: deadline + range: "20210101 000000:1D" + type: timestamp + format: "YYYY-MM-DD" + postfix: "\t" + - field: finishedBy + range: "[]{4},admin,[]{4}" + - field: finishedDate + range: "20210101 000000:1D" + type: timestamp + format: "YYYY-MM-DD" + - field: closedReason + range: "[]{4},done,[]{4}" diff --git a/module/message/test/yaml/taskteam.yaml b/module/message/test/yaml/taskteam.yaml new file mode 100755 index 0000000000..65e29bc7ac --- /dev/null +++ b/module/message/test/yaml/taskteam.yaml @@ -0,0 +1,21 @@ +title: zt_taskteam +desc: "任务团队" +author: Mengyi Liu +version: "1.0" +fields: +- field: task + range: 8{3},9{3} +- field: left + range: 1-10 +- field: estimate + range: 1-10 +- field: consumed + range: 0 +- field: account + fields: + - field: account1 + range: admin,user{2} + - field: account2 + range: "[],1-2" +- field: status + range: "wait{4},done{2}"