diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php
index 81193aeab2..25fcd2b9cd 100755
--- a/lib/dao/dao.class.php
+++ b/lib/dao/dao.class.php
@@ -240,6 +240,24 @@ class dao
return $this;
}
+ /**
+ * The count method, call sql::select() and from().
+ * use as $this->dao->count(TABLE_BUG)->where('')->fetch('count');
+ *
+ * @param int $tabel
+ * @access public
+ * @return void
+ */
+ public function count($table)
+ {
+ $this->setMode('raw');
+ $this->setMethod('select');
+ $this->sqlobj = sql::select('count(*) as count');
+ $this->setTable($table);
+ $this->sqlobj->from($table);
+ return $this;
+ }
+
/**
* The select method, call sql::update().
*
diff --git a/module/admin/control.php b/module/admin/control.php
index 6b423dcc40..33b0d415cf 100644
--- a/module/admin/control.php
+++ b/module/admin/control.php
@@ -140,7 +140,7 @@ class admin extends control
if(!$result) die(js::alert($this->lang->admin->clearDataFailed));
- js::alert($this->lang->admin->clearDataSuccessfully);
+ echo js::alert($this->lang->admin->clearDataSuccessfully);
die(js::locate(inLink('index'), 'parent'));
}
diff --git a/module/bug/control.php b/module/bug/control.php
index 5014729bba..7fd8cf5192 100644
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -219,7 +219,14 @@ class bug extends control
$response['result'] = 'success';
$response['message'] = '';
- $bugID = $this->bug->create();
+ $bugResult = $this->bug->create();
+ $bugID = $bugResult['id'];
+ if($bugResult['status'] == 'existed')
+ {
+ $response['locate'] = $this->createLink('bug', 'view', "bugID=$bugID");
+ $this->send($response);
+ }
+
if(dao::isError())
{
$response['result'] = 'fail';
diff --git a/module/bug/model.php b/module/bug/model.php
index 5de3d31ee9..dba5241189 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -54,12 +54,17 @@ class bugModel extends model
->join('mailto', ',')
->remove('files, labels')
->get();
+
+ /* Check repeat bug. */
+ $bugID = $this->loadModel('common')->checkRepeat('bug', 'check', $bug->title, "product={$bug->product}");
+ if($bugID) return array('status' => 'existed', 'id' => $bugID);
+
$this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
if(!dao::isError())
{
$bugID = $this->dao->lastInsertID();
$this->loadModel('file')->saveUpload('bug', $bugID);
- return $bugID;
+ return array('status' => 'created', 'id' => $bugID);
}
return false;
}
@@ -74,10 +79,11 @@ class bugModel extends model
public function batchCreate($productID)
{
$this->loadModel('action');
- $now = helper::now();
- $actions = array();
- $data = fixer::input('post')->get();
- $batchNum = count(reset($data));
+ $now = helper::now();
+ $actions = array();
+ $data = fixer::input('post')->get();
+ $batchNum = count(reset($data));
+ $latestBugs = $this->loadModel('common')->checkRepeat('bug', 'get', '', "product=$productID");
for($i = 0; $i < $batchNum; $i++)
{
@@ -124,8 +130,11 @@ class bugModel extends model
$bug->assignedDate = $now;
}
+ if($latestBugs and in_array($bug->title, $latestBugs)) continue;
+
$this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
$bugID = $this->dao->lastInsertID();
+ $latestBugs[$bugID] = $bug->title;
if(dao::isError()) die(js::error('bug#' . ($i+1) . dao::getError(true)));
$actions[$bugID] = $this->action->create('bug', $bugID, 'Opened');
diff --git a/module/common/model.php b/module/common/model.php
index 3f2ace4de6..ccd093e2c3 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -739,4 +739,47 @@ class commonModel extends model
$this->session->set($objectType . 'OrderBy', '');
}
}
+
+ /**
+ * Check repeat for story,task,bug,case,doc.
+ *
+ * @param string $type
+ * @param string $mode
+ * @param string $title
+ * @param string $condition
+ * @access public
+ * @return bool|array
+ */
+ public function checkRepeat($type, $mode = 'check', $title = '', $condition = '')
+ {
+ $table = $this->config->objectTables[$type];
+ $field = $type == 'task' ? 'name' : 'title';
+ $date = date(DT_DATETIME1, time() - 1 * 60);
+
+ if($mode == 'check' and empty($title)) return false;
+ if($mode == 'check')
+ {
+ $repeatObject = $this->dao->select('*')->from($table)
+ ->where('deleted')->eq(0)
+ ->andWhere($field)->eq($title)
+ ->beginIF($type == 'doc')->andWhere('addedDate')->ge($date)->fi()
+ ->beginIF($type != 'doc')->andWhere('openedDate')->ge($date)->fi()
+ ->beginIF($condition)->andWhere($condition)->fi()
+ ->fetch();
+
+ if($repeatObject) return $repeatObject->id;
+ return false;
+ }
+ elseif($mode == 'get')
+ {
+ return $this->dao->select("id,$field")->from($table)
+ ->where('deleted')->eq(0)
+ ->beginIF($type == 'doc')->andWhere('addedDate')->ge($date)->fi()
+ ->beginIF($type != 'doc')->andWhere('openedDate')->ge($date)->fi()
+ ->beginIF($condition)->andWhere($condition)->fi()
+ ->fetchPairs();
+ }
+
+ return false;
+ }
}
diff --git a/module/custom/control.php b/module/custom/control.php
index b80c365c94..044809ba13 100644
--- a/module/custom/control.php
+++ b/module/custom/control.php
@@ -39,18 +39,25 @@ class custom extends control
$fieldList = $this->lang->$module->$field;
if(!empty($_POST))
{
- $lang = $_POST['lang'];
- $this->custom->deleteItems("lang=$lang&module=$module§ion=$field");
- foreach($_POST['keys'] as $index => $key)
+ if($module == 'story' && $field == 'review')
{
- $value = $_POST['values'][$index];
- if(!$value or !$key) continue;
- $system = $_POST['systems'][$index];
+ $this->loadModel('setting')->setItem('system.common.storyReview.needReview', $_POST['needReview']);
+ }
+ else
+ {
+ $lang = $_POST['lang'];
+ $this->custom->deleteItems("lang=$lang&module=$module§ion=$field");
+ foreach($_POST['keys'] as $index => $key)
+ {
+ $value = $_POST['values'][$index];
+ if(!$value or !$key) continue;
+ $system = $_POST['systems'][$index];
- /* the length of role is 20, check it when save. */
- if($module == 'user' and $field == 'roleList' and strlen($key) > 20) die(js::alert($this->lang->custom->notice->userRole));
+ /* the length of role is 20, check it when save. */
+ if($module == 'user' and $field == 'roleList' and strlen($key) > 20) die(js::alert($this->lang->custom->notice->userRole));
- $this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $value);
+ $this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $value);
+ }
}
if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
@@ -59,6 +66,7 @@ class custom extends control
$this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->$module->common;
$this->view->position[] = $this->lang->custom->common;
$this->view->position[] = $this->lang->$module->common;
+ $this->view->needReview = isset($this->config->storyReview->needReview) ? $this->config->storyReview->needReview : 1;
$this->view->fieldList = $fieldList;
$this->view->dbFields = $this->custom->getItems("lang=$currentLang,all&module=$module§ion=$field");
$this->view->field = $field;
diff --git a/module/custom/lang/en.php b/module/custom/lang/en.php
index 47cbec20d6..b871626fca 100644
--- a/module/custom/lang/en.php
+++ b/module/custom/lang/en.php
@@ -21,6 +21,7 @@ $lang->custom->story->fields['reasonList'] = 'Closed reason';
$lang->custom->story->fields['reviewResultList'] = 'Reviewed result';
$lang->custom->story->fields['stageList'] = 'Stage';
$lang->custom->story->fields['statusList'] = 'Status';
+$lang->custom->story->fields['review'] = 'Review';
$lang->custom->task = new stdClass();
$lang->custom->task->fields['priList'] = 'Priority';
@@ -64,3 +65,7 @@ $lang->custom->confirmRestore = 'Are you sure to restore the default lang settin
$lang->custom->notice = new stdclass();
$lang->custom->notice->userRole = 'The length of key must be less than 20!';
+
+$lang->custom->storyReview = 'Story review';
+$lang->custom->reviewList[1] = 'Open';
+$lang->custom->reviewList[0] = 'Close';
diff --git a/module/custom/lang/zh-cn.php b/module/custom/lang/zh-cn.php
index 2edeb44bac..b505c34f1f 100644
--- a/module/custom/lang/zh-cn.php
+++ b/module/custom/lang/zh-cn.php
@@ -21,6 +21,7 @@ $lang->custom->story->fields['reasonList'] = '关闭原因';
$lang->custom->story->fields['reviewResultList'] = '评审结果';
$lang->custom->story->fields['stageList'] = '阶段';
$lang->custom->story->fields['statusList'] = '状态';
+$lang->custom->story->fields['review'] = '评审';
$lang->custom->task = new stdClass();
$lang->custom->task->fields['priList'] = '优先级';
@@ -64,3 +65,7 @@ $lang->custom->confirmRestore = '是否要恢复默认语言配置?';
$lang->custom->notice = new stdclass();
$lang->custom->notice->userRole = '键的长度必须小于20个字符!';
+
+$lang->custom->storyReview = '需求评审';
+$lang->custom->reviewList[1] = '开启';
+$lang->custom->reviewList[0] = '关闭';
diff --git a/module/custom/view/set.html.php b/module/custom/view/set.html.php
index 3f28999418..b20c97d25f 100644
--- a/module/custom/view/set.html.php
+++ b/module/custom/view/set.html.php
@@ -60,6 +60,15 @@ EOT;
custom->object[$module] . ' >> ' . $lang->custom->$module->fields[$field]?>
+
+
+
+ | custom->storyReview;?> |
+ custom->reviewList, $needReview);?> |
+ |
+
+
+
| custom->key;?> |
@@ -92,6 +101,7 @@ EOT;
+
diff --git a/module/doc/control.php b/module/doc/control.php
index 2d3516f830..aefd03d82a 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -249,7 +249,10 @@ class doc extends control
$projectID = (int)$projectID;
if(!empty($_POST))
{
- $docID = $this->doc->create();
+ $docResult = $this->doc->create();
+ $docID = $docResult['id'];
+
+ if($docResult['status'] == 'existed') die(js::locate($this->createLink('doc', 'view', "docID=$docID"), 'parent'));
if(dao::isError()) die(js::error(dao::getError()));
$this->action->create('doc', $docID, 'Created');
diff --git a/module/doc/model.php b/module/doc/model.php
index 232290e2e8..a9bd48f81c 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -189,6 +189,10 @@ class docModel extends model
->remove('files, labels')
->get();
$condition = "lib = '$doc->lib' AND module = $doc->module";
+
+ $docID = $this->loadModel('common')->checkRepeat('doc', 'check', $doc->title, $condition);
+ if($docID) return array('status' => 'existed', 'id' => $docID);
+
$this->dao->insert(TABLE_DOC)
->data($doc)
->autoCheck()
diff --git a/module/project/model.php b/module/project/model.php
index d3bb09b804..922c3186ae 100644
--- a/module/project/model.php
+++ b/module/project/model.php
@@ -929,40 +929,43 @@ class projectModel extends model
public function importBug($projectID)
{
$this->loadModel('bug');
- $bugLang = $this->app->loadLang('bug');
$this->loadModel('task');
$this->loadModel('story');
- $now = helper::now();
- $BugToTasks = fixer::input('post')->get();
- foreach($BugToTasks->import as $key => $value)
+ $now = helper::now();
+ $modules = $this->loadModel('tree')->getTaskOptionMenu($projectID);
+
+ $bugToTasks = fixer::input('post')->get();
+ $bugs = $this->bug->getByList(array_keys($bugToTasks->import));
+ foreach($bugToTasks->import as $key => $value)
{
- $bug = $this->bug->getById($key);
+ $bug = $bugs[$key];
$task = new stdClass();
$task->project = $projectID;
$task->story = $bug->story;
- $task->storyVersion = $bug->story;
+ $task->storyVersion = $bug->storyVersion;
+ $task->module = isset($modules[$bug->module]) ? $bug->module : 0;
$task->fromBug = $key;
$task->name = $bug->title;
$task->type = 'devel';
- $task->pri = $BugToTasks->pri[$key];
+ $task->pri = $bugToTasks->pri[$key];
$task->consumed = 0;
$task->status = 'wait';
- $task->desc = $bugLang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID=$key"), sprintf('%03d', $key));
+ $task->desc = $this->lang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID=$key"), sprintf('%03d', $key));
$task->openedDate = $now;
$task->openedBy = $this->app->user->account;
- if(!empty($BugToTasks->estimate[$key]))
+ if(!empty($bugToTasks->estimate[$key]))
{
- $task->estimate = $BugToTasks->estimate[$key];
+ $task->estimate = $bugToTasks->estimate[$key];
$task->left = $task->estimate;
}
- if(!empty($BugToTasks->assignedTo[$key]))
+ if(!empty($bugToTasks->assignedTo[$key]))
{
- $task->assignedTo = $BugToTasks->assignedTo[$key];
+ $task->assignedTo = $bugToTasks->assignedTo[$key];
$task->assignedDate = $now;
}
if(!$bug->confirmed) $this->dao->update(TABLE_BUG)->set('confirmed')->eq(1)->where('id')->eq($bug->id)->exec();
- $this->dao->insert(TABLE_TASK)->data($task)->checkIF($BugToTasks->estimate[$key] != '', 'estimate', 'float')->exec();
+ $this->dao->insert(TABLE_TASK)->data($task)->checkIF($bugToTasks->estimate[$key] != '', 'estimate', 'float')->exec();
if(dao::isError())
{
diff --git a/module/story/control.php b/module/story/control.php
index 00d3e6abb3..fa64fcbdec 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -42,7 +42,21 @@ class story extends control
$response['result'] = 'success';
$response['message'] = '';
- $storyID = $this->story->create($projectID, $bugID);
+ $storyResult = $this->story->create($projectID, $bugID);
+ $storyID = $storyResult['id'];
+ if($storyResult['status'] == 'existed')
+ {
+ if($projectID == 0)
+ {
+ $response['locate'] = $this->createLink('story', 'view', "storyID={$storyID}");
+ }
+ else
+ {
+ $response['locate'] = $this->createLink('project', 'story', "projectID=$projectID");
+ }
+ $this->send($response);
+ }
+
if(dao::isError())
{
$response['result'] = 'fail';
@@ -164,6 +178,7 @@ class story extends control
$this->view->verify = $verify;
$this->view->keywords = $keywords;
$this->view->mailto = $mailto;
+ $this->view->needReview = ($projectID > 0 || (isset($this->config->storyReview->needReview) && $this->config->storyReview->needReview == 0 )) ? "checked='checked'" : "";
$this->display();
}
@@ -422,6 +437,7 @@ class story extends control
$this->view->title = $this->lang->story->change . "STORY" . $this->lang->colon . $this->view->story->title;
$this->view->users = $this->user->getPairs('nodeleted|pofirst', $this->view->story->assignedTo);
$this->view->position[] = $this->lang->story->change;
+ $this->view->needReview = (isset($this->config->storyReview->needReview) && $this->config->storyReview->needReview == 0) ? "checked='checked'" : "";
$this->display();
}
diff --git a/module/story/model.php b/module/story/model.php
index 01d0e00024..561bfa5aae 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -137,6 +137,10 @@ class storyModel extends model
->remove('files,labels,spec,verify,needNotReview,newStory')
->get();
+ /* Check repeat story. */
+ $storyID = $this->loadModel('common')->checkRepeat('story', 'check', $story->title, "product={$story->product}");
+ if($storyID) return array('status' => 'existed', 'id' => $storyID);
+
$this->dao->insert(TABLE_STORY)->data($story)->autoCheck()->batchCheck($this->config->story->create->requiredFields, 'notempty')->exec();
if(!dao::isError())
{
@@ -193,7 +197,7 @@ class storyModel extends model
}
}
}
- return $storyID;
+ return array('status' => 'created', 'id' => $storyID);
}
return false;
}
@@ -206,9 +210,10 @@ class storyModel extends model
*/
public function batchCreate($productID = 0)
{
- $now = helper::now();
- $stories = fixer::input('post')->get();
- $batchNum = count(current($stories));
+ $now = helper::now();
+ $stories = fixer::input('post')->get();
+ $batchNum = count(reset($stories));
+ $latestStories = $this->loadModel('common')->checkRepeat('story', 'get', '', "product={$productID}");
for($i = 0; $i < $batchNum; $i++)
{
@@ -226,6 +231,8 @@ class storyModel extends model
$data[$i]->openedDate = $now;
$data[$i]->version = 1;
+ if($latestStories and in_array($data[$i]->title, $latestStories)) continue;
+
$this->dao->insert(TABLE_STORY)
->data($data[$i])
->autoCheck()
@@ -238,6 +245,7 @@ class storyModel extends model
}
$storyID = $this->dao->lastInsertID();
+ $latestStories[$storyID] = $data[$i]->title;
$this->setStage($storyID);
$specData[$i] = new stdclass();
diff --git a/module/story/view/change.html.php b/module/story/view/change.html.php
index c42d129dc8..576749a46a 100644
--- a/module/story/view/change.html.php
+++ b/module/story/view/change.html.php
@@ -27,7 +27,7 @@
assignedTo, 'class="form-control chosen"');?>
- story->needNotReview, '', "id='needNotReview'");?>
+ story->needNotReview, '', "id='needNotReview' {$needReview}");?>
diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php
index 6ed9a92181..2ea9485a67 100644
--- a/module/story/view/create.html.php
+++ b/module/story/view/create.html.php
@@ -93,7 +93,7 @@
| story->reviewedBy;?> |
|
- story->needNotReview, '', "id='needNotReview'" . ($projectID > 0 ? " checked='checked'" : ""));?> |
+ story->needNotReview, '', "id='needNotReview' {$needReview}");?> |
| story->mailto;?> |
diff --git a/module/task/control.php b/module/task/control.php
index c7005acdc3..e12df4f95c 100644
--- a/module/task/control.php
+++ b/module/task/control.php
@@ -80,6 +80,10 @@ class task extends control
$this->loadModel('action');
foreach($tasksID as $taskID)
{
+ /* if status is existed then this task has existed not new create. */
+ if($taskID['status'] == 'existed') continue;
+
+ $taskID = $taskID['id'];
$actionID = $this->action->create('task', $taskID, 'Opened', '');
$this->sendmail($taskID, $actionID);
}
diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js
index 33b7b30fab..6c2e32aef2 100755
--- a/module/task/js/batchcreate.js
+++ b/module/task/js/batchcreate.js
@@ -37,6 +37,7 @@ function setStoryRelated(num)
$.get(link, function(moduleID)
{
$('#module' + num).val(moduleID);
+ $('#module' + num).trigger("chosen:updated");
});
}
}
diff --git a/module/task/model.php b/module/task/model.php
index b814b91e72..877f870ec5 100644
--- a/module/task/model.php
+++ b/module/task/model.php
@@ -22,8 +22,9 @@ class taskModel extends model
*/
public function create($projectID)
{
- $tasksID = array();
- $taskFile = '';
+ $tasksID = array();
+ $taskFile = '';
+ $latestTasks = $this->loadModel('common')->checkRepeat('task', 'get', '', "project=$projectID");
foreach($this->post->assignedTo as $assignedTo)
{
if($this->post->type == 'affair' and empty($assignedTo)) continue;
@@ -45,6 +46,13 @@ class taskModel extends model
if($assignedTo) $task->assignedDate = helper::now();
+ /* Check repeat story. */
+ if($latestTasks and $taskID = array_search($task->name, $latestTasks))
+ {
+ $tasksID[$assignedTo] = array('status' => 'existed', 'id' => $taskID);
+ continue;
+ }
+
$this->dao->insert(TABLE_TASK)->data($task)
->autoCheck()
->batchCheck($this->config->task->create->requiredFields, 'notempty')
@@ -67,7 +75,7 @@ class taskModel extends model
$taskFile = $this->dao->select('*')->from(TABLE_FILE)->where('id')->eq(key($taskFileTitle))->fetch();
unset($taskFile->id);
}
- $tasksID[$assignedTo] = $taskID;
+ $tasksID[$assignedTo] = array('status' => 'created', 'id' => $taskID);
}
else
{
@@ -87,10 +95,11 @@ class taskModel extends model
public function batchCreate($projectID)
{
$this->loadModel('action');
- $now = helper::now();
- $mails = array();
- $tasks = fixer::input('post')->get();
- $batchNum = count(current($tasks));
+ $now = helper::now();
+ $mails = array();
+ $tasks = fixer::input('post')->get();
+ $batchNum = count(reset($tasks));
+ $latestTasks = $this->loadModel('common')->checkRepeat('task', 'get', '', "project=$projectID");
/* check estimate. */
for($i = 0; $i < $batchNum; $i++)
@@ -123,6 +132,8 @@ class taskModel extends model
if($tasks->story[$i] != '') $data[$i]->storyVersion = $this->loadModel('story')->getVersion($data[$i]->story);
if($tasks->assignedTo[$i] != '') $data[$i]->assignedDate = $now;
+ if($latestTasks and in_array($data[$i]->name, $latestTasks)) continue;
+
$this->dao->insert(TABLE_TASK)->data($data[$i])
->autoCheck()
->batchCheck($this->config->task->create->requiredFields, 'notempty')
@@ -132,6 +143,7 @@ class taskModel extends model
if(dao::isError()) die(js::error(dao::getError()));
$taskID = $this->dao->lastInsertID();
+ $latestTasks[$taskID] = $data[$i]->name;
if($tasks->story[$i] != false) $this->story->setStage($tasks->story[$i]);
$actionID = $this->action->create('task', $taskID, 'Opened', '');
diff --git a/module/testcase/control.php b/module/testcase/control.php
index 4a2a4cdb07..2c171aa5ec 100644
--- a/module/testcase/control.php
+++ b/module/testcase/control.php
@@ -226,7 +226,14 @@ class testcase extends control
$response['result'] = 'success';
$response['message'] = '';
- $caseID = $this->testcase->create($bugID);
+ $caseResult = $this->testcase->create($bugID);
+ $caseID = $caseResult['id'];
+ if($caseResult['status'] == 'existed')
+ {
+ $response['locate'] = $this->createLink('testcase', 'view', "caseID=$caseID");
+ $this->send($response);
+ }
+
if(dao::isError())
{
$response['result'] = 'fail';
diff --git a/module/testcase/model.php b/module/testcase/model.php
index c20ca8f452..8abaacac19 100644
--- a/module/testcase/model.php
+++ b/module/testcase/model.php
@@ -53,6 +53,10 @@ class testcaseModel extends model
->setDefault('story', 0)
->join('stage', ',')
->get();
+
+ $caseID = $this->loadModel('common')->checkRepeat('case', 'check', $case->title, "product={$case->product}");
+ if($caseID) return array('status' => 'existed', 'id' => $caseID);
+
$this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->exec();
if(!$this->dao->isError())
{
@@ -68,7 +72,7 @@ class testcaseModel extends model
$step->expect = htmlspecialchars($this->post->expects[$stepID]);
$this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec();
}
- return $caseID;
+ return array('status' => 'created', 'id' => $caseID);
}
}
@@ -82,9 +86,10 @@ class testcaseModel extends model
*/
function batchCreate($productID, $storyID)
{
- $now = helper::now();
- $cases = fixer::input('post')->get();
- $batchNum = count(current($cases));
+ $now = helper::now();
+ $cases = fixer::input('post')->get();
+ $batchNum = count(reset($cases));
+ $latestCases = $this->loadModel('common')->checkRepeat('case', 'get', '', "product=$productID");
for($i = 0; $i < $batchNum; $i++)
{
@@ -113,6 +118,8 @@ class testcaseModel extends model
$data[$i]->storyVersion = $this->loadModel('story')->getVersion($this->post->story);
}
+ if($latestCases and in_array($data[$i]->title, $latestCases)) continue;
+
$this->dao->insert(TABLE_CASE)->data($data[$i])
->autoCheck()
->batchCheck($this->config->testcase->create->requiredFields, 'notempty')
@@ -125,6 +132,7 @@ class testcaseModel extends model
}
$caseID = $this->dao->lastInsertID();
+ $latestCases[$caseID] = $data[$i]->title;
$actionID = $this->loadModel('action')->create('case', $caseID, 'Opened');
}
else
diff --git a/module/tree/model.php b/module/tree/model.php
index d04140e670..e994727b61 100644
--- a/module/tree/model.php
+++ b/module/tree/model.php
@@ -439,8 +439,7 @@ class treeModel extends model
if($linkStory)
{
/* Get story paths of this project. */
- $paths = $this->dao->select('t3.' . $field)
- ->from(TABLE_PROJECTSTORY)->alias('t1')
+ $paths = $this->dao->select('DISTINCT t3.' . $field)->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_MODULE)->alias('t3')->on('t2.module = t3.id')
->where('t1.project')->eq($projectID)
@@ -461,6 +460,14 @@ class treeModel extends model
->andWhere('type')->eq('task')
->fetchPairs();
+ /* Add task paths of this project for has existed. */
+ $paths += $this->dao->select('DISTINCT t1.' . $field)->from(TABLE_MODULE)->alias('t1')
+ ->leftJoin(TABLE_TASK)->alias('t2')->on('t1.id=t2.module')
+ ->where('t2.module')->ne(0)
+ ->andWhere('t2.deleted')->eq(0)
+ ->andWhere('t1.type')->eq('story')
+ ->fetchPairs();
+
/* Get all modules from paths. */
foreach($paths as $path)
{