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/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);
}
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;
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;
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'))
{
diff --git a/module/task/model.php b/module/task/model.php
index 34801568a5..aab15e3d4e 100644
--- a/module/task/model.php
+++ b/module/task/model.php
@@ -973,15 +973,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;
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);
}