From ad7cfe467e32e5da6525dce661e0563acd058d56 Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 30 Mar 2018 10:15:48 +0800 Subject: [PATCH 1/6] * Adjust codes. --- module/bug/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/bug/model.php b/module/bug/model.php index df4d824248..4fcb436d39 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -90,7 +90,7 @@ class bugModel extends model empty($bug->case) ? $this->loadModel('score')->create('bug', 'create', $bugID) : $this->loadModel('score')->create('bug', 'createFormCase', $bug->case); /* Callback the callable method to process the related data for object that is transfered to bug. */ - if(is_callable(array($this, $this->config->bug->fromObjects[$from]['callback']))) call_user_func(array($this, $this->config->bug->fromObjects[$from]['callback']), $bugID); + if($from && is_callable(array($this, $this->config->bug->fromObjects[$from]['callback']))) call_user_func(array($this, $this->config->bug->fromObjects[$from]['callback']), $bugID); return array('status' => 'created', 'id' => $bugID); } From 070454933b3ba3b3ba1e0e4909cf0d83ea87c969 Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 30 Mar 2018 10:48:16 +0800 Subject: [PATCH 2/6] * Compatible extension if there is a object to transfer story. --- module/story/control.php | 62 +++++++++++++++++++++++++++++++++++++--- module/story/model.php | 6 +++- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index 429b928d68..31525fc11a 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -38,17 +38,43 @@ class story extends control * @param int $bugID * @param int $planID * @param int $todoID + * @param string $extra for example feedbackID=0 * @access public * @return void */ - public function create($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $projectID = 0, $bugID = 0, $planID = 0, $todoID = 0) + public function create($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $projectID = 0, $bugID = 0, $planID = 0, $todoID = 0, $extra = '') { + /* Whether there is a object to transfer story, for example feedback. */ + $extra = str_replace(array(',', ' '), array('&', ''), $extra); + parse_str($extra, $output); + foreach($output as $paramKey => $paramValue) + { + if(isset($this->config->story->fromObjects[$paramKey])) + { + $fromObjectIDKey = $paramKey; + $fromObjectID = $paramValue; + $fromObjectName = $this->config->story->fromObjects[$fromObjectIDKey]['name']; + $fromObjectAction = $this->config->story->fromObjects[$fromObjectIDKey]['action']; + break; + } + } + + /* If there is a object to transfer story, get it by getById function and set objectID,object in views. */ + if(isset($fromObjectID)) + { + $fromObject = $this->loadModel($fromObjectName)->getById($fromObjectID); + if(!$fromObject) die(js::error($this->lang->notFound) . js::locate('back', 'parent')); + + $this->view->$fromObjectIDKey = $fromObjectID; + $this->view->$fromObjectName = $fromObject; + } + if(!empty($_POST)) { $response['result'] = 'success'; $response['message'] = ''; - $storyResult = $this->story->create($projectID, $bugID); + $storyResult = $this->story->create($projectID, $bugID, $from = isset($fromObjectIDKey) ? $fromObjectIDKey : ''); if(!$storyResult or dao::isError()) { $response['result'] = 'fail'; @@ -71,8 +97,14 @@ class story extends control $this->send($response); } - $action = $bugID == 0 ? 'Opened' : 'Frombug'; - $extra = $bugID == 0 ? '' : $bugID; + $action = $bugID == 0 ? 'Opened' : 'Frombug'; + $extra = $bugID == 0 ? '' : $bugID; + /* Record related action, for example FromFeedback. */ + if($fromObjectID) + { + $action = $fromObjectAction; + $extra = $fromObjectID; + } $actionID = $this->action->create('story', $storyID, $action, '', $extra); if($todoID > 0) @@ -171,6 +203,28 @@ class story extends control $pri = $todo->pri; } + /* Replace the value of story that needs to be replaced with the value of the object that is transferred to story. */ + if(isset($fromObject)) + { + if(isset($this->config->story->fromObjects[$fromObjectIDKey]['source'])) + { + $sourceField = $this->config->story->fromObjects[$fromObjectIDKey]['source']; + $sourceUser = $this->loadModel('user')->getById($fromObject->{$sourceField}); + $source = $sourceUser->role; + $sourceNote = $sourceUser->realname; + } + else + { + $source = $fromObjectName; + $sourceNote = $fromObjectID; + } + + foreach($this->config->story->fromObjects[$fromObjectIDKey]['fields'] as $storyField => $fromObjectField) + { + $$storyField = $fromObject->{$fromObjectField}; + } + } + /* Set Custom*/ foreach(explode(',', $this->config->story->list->customCreateFields) as $field) $customFields[$field] = $this->lang->story->$field; $this->view->customFields = $customFields; diff --git a/module/story/model.php b/module/story/model.php index a6ea673cfe..572833a758 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -140,7 +140,7 @@ class storyModel extends model * @access public * @return int|bool the id of the created story or false when error. */ - public function create($projectID = 0, $bugID = 0) + public function create($projectID = 0, $bugID = 0, $from = '') { $now = helper::now(); $story = fixer::input('post') @@ -232,6 +232,10 @@ class storyModel extends model } $this->setStage($storyID); if(!dao::isError()) $this->loadModel('score')->create('story', 'create',$storyID); + + /* Callback the callable method to process the related data for object that is transfered to story. */ + if($from && is_callable(array($this, $this->config->story->fromObjects[$from]['callback']))) call_user_func(array($this, $this->config->story->fromObjects[$from]['callback']), $storyID); + return array('status' => 'created', 'id' => $storyID); } return false; From 9c2e3c326b12620780ab28983fa456943fc7649b Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 30 Mar 2018 11:07:26 +0800 Subject: [PATCH 3/6] * Remove useless codes. --- module/productplan/control.php | 1 - 1 file changed, 1 deletion(-) diff --git a/module/productplan/control.php b/module/productplan/control.php index 7d4a7e1e0f..d6f5008f8b 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -523,7 +523,6 @@ class productplan extends control $this->view->planBugs = $this->bug->getPlanBugs($planID); $this->view->products = $products; $this->view->plan = $plan; - $this->view->plans = $this->dao->select('id, end')->from(TABLE_PRODUCTPLAN)->fetchPairs(); $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->browseType = $browseType; $this->view->param = $param; From 959dfe94b813d0594eb2a47beae3c62b42354fae Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 30 Mar 2018 11:20:48 +0800 Subject: [PATCH 4/6] * Optimize codes. --- module/task/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/task/model.php b/module/task/model.php index ec34c23a50..6c244028a3 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -966,15 +966,15 @@ class taskModel extends model if($left != 0 || $task->assignedTo != $teams[count($teams) - 1]) { $newTask->status = 'doing'; - if($task->assignedTo != $teams[count($teams) - 1] && $left == 0) + if($left == 0) { $newTask->assignedTo = $this->getNextUser($teams, $task->assignedTo); $newTask->assignedDate = $now; } - $task->status = $oldStatus; $this->dao->update(TABLE_TASK)->data($newTask)->where('id')->eq((int)$taskID)->exec(); + $task->status = $oldStatus; $changes = common::createChanges($task, $newTask); if(!empty($actionID)) $this->action->logHistory($actionID, $changes); return $changes; From 288b985be6ca49a60a009540e134e7ab7146735f Mon Sep 17 00:00:00 2001 From: JackWuLieHao Date: Fri, 30 Mar 2018 13:35:32 +0800 Subject: [PATCH 5/6] * Finish Task #3786 --- db/update9.8.2.sql | 1 + db/zentao.sql | 2 +- module/upgrade/model.php | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/update9.8.2.sql b/db/update9.8.2.sql index f4fa1b6dc5..bef6bbb008 100644 --- a/db/update9.8.2.sql +++ b/db/update9.8.2.sql @@ -1,2 +1,3 @@ ALTER TABLE `zt_team` DROP PRIMARY KEY; ALTER TABLE `zt_team` ADD PRIMARY KEY (`root`, `type`, `account`); +ALTER TABLE `zt_team` CHANGE `team` `team` varchar(90) NOT NULL; diff --git a/db/zentao.sql b/db/zentao.sql index d810827238..1c6dbc5d9d 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -486,7 +486,7 @@ CREATE TABLE IF NOT EXISTS `zt_project` ( `PM` varchar(30) NOT NULL default '', `QD` varchar(30) NOT NULL default '', `RD` varchar(30) NOT NULL default '', - `team` varchar(30) NOT NULL, + `team` varchar(90) NOT NULL, `acl` enum('open','private','custom') NOT NULL default 'open', `whitelist` text NOT NULL, `order` mediumint(8) unsigned NOT NULL, diff --git a/module/upgrade/model.php b/module/upgrade/model.php index dceb19bdcb..5ef63f22c4 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -212,6 +212,8 @@ class upgradeModel extends model $this->fixTaskAssignedTo(); $this->fixProjectClosedInfo(); $this->resetProductLine(); + case '9_8_2': + $this->execSQL($this->getUpgradeFile('9.8.2')); } $this->deletePatch(); @@ -317,6 +319,7 @@ class upgradeModel extends model case '9_7': $confirmContent .= file_get_contents($this->getUpgradeFile('9.7')); case '9_8': case '9_8_1': $confirmContent .= file_get_contents($this->getUpgradeFile('9.8.1')); + case '9_8_2': $confirmContent .= file_get_contents($this->getUpgradeFile('9.8.2')); } return str_replace('zt_', $this->config->db->prefix, $confirmContent); } From b76b50e22f5e70d786870d238caf3dc01a3ca56e Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 30 Mar 2018 14:18:54 +0800 Subject: [PATCH 6/6] * Add ditto when module is ditto. --- module/task/js/batchcreate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js index 374037f345..768ff306a2 100755 --- a/module/task/js/batchcreate.js +++ b/module/task/js/batchcreate.js @@ -13,7 +13,7 @@ function setStories(moduleID, projectID, num) var storyID = $('#story' + num).val(); if(!stories) stories = ''; $('#story' + num).replaceWith(stories); - if(moduleID == 0) $('#story' + num).append(""); + if(moduleID == 0 || moduleID == 'ditto') $('#story' + num).append(""); $('#story' + num).val(storyID); if($('#zeroTaskStory').hasClass('zeroTask')) {