This commit is contained in:
Catouse
2014-08-18 18:04:10 +08:00
22 changed files with 229 additions and 51 deletions
+18
View File
@@ -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().
*
+1 -1
View File
@@ -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'));
}
+8 -1
View File
@@ -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';
+14 -5
View File
@@ -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');
+43
View File
@@ -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;
}
}
+17 -9
View File
@@ -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&section=$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&section=$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&section=$field");
$this->view->field = $field;
+5
View File
@@ -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';
+5
View File
@@ -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] = '关闭';
+10
View File
@@ -60,6 +60,15 @@ EOT;
<div class='panel-heading'>
<strong><?php echo $lang->custom->object[$module] . ' >> ' . $lang->custom->$module->fields[$field]?></strong>
</div>
<?php if($field == 'review'):?>
<table class='table table-borderless mw-600px'>
<tr>
<td><?php echo $lang->custom->storyReview;?></td>
<td><?php echo html::radio('needReview', $lang->custom->reviewList, $needReview);?></td>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
<?php else:?>
<table class='table table-borderless active-disabled table-condensed mw-600px'>
<tr class='text-center'>
<th class='w-120px'><?php echo $lang->custom->key;?></th>
@@ -92,6 +101,7 @@ EOT;
</td>
</tr>
</table>
<?php endif;?>
</div>
</form>
</div>
+4 -1
View File
@@ -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');
+4
View File
@@ -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()
+16 -13
View File
@@ -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())
{
+17 -1
View File
@@ -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();
}
+12 -4
View File
@@ -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();
+1 -1
View File
@@ -27,7 +27,7 @@
<div class="input-group w-p35-f">
<?php echo html::select('assignedTo', $users, $story->assignedTo, 'class="form-control chosen"');?>
<span class="input-group-addon">
<?php echo html::checkbox('needNotReview', $lang->story->needNotReview, '', "id='needNotReview'");?>
<?php echo html::checkbox('needNotReview', $lang->story->needNotReview, '', "id='needNotReview' {$needReview}");?>
</span>
</div>
</td>
+1 -1
View File
@@ -93,7 +93,7 @@
<tr>
<th><?php echo $lang->story->reviewedBy;?></th>
<td><?php echo html::select('assignedTo', $users, '', "class='form-control chosen'");?></td>
<td><?php echo html::checkbox('needNotReview', $lang->story->needNotReview, '', "id='needNotReview'" . ($projectID > 0 ? " checked='checked'" : ""));?></td>
<td><?php echo html::checkbox('needNotReview', $lang->story->needNotReview, '', "id='needNotReview' {$needReview}");?></td>
</tr>
<tr>
<th><nobr><?php echo $lang->story->mailto;?></nobr></th>
+4
View File
@@ -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);
}
+1
View File
@@ -37,6 +37,7 @@ function setStoryRelated(num)
$.get(link, function(moduleID)
{
$('#module' + num).val(moduleID);
$('#module' + num).trigger("chosen:updated");
});
}
}
+19 -7
View File
@@ -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', '');
+8 -1
View File
@@ -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';
+12 -4
View File
@@ -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
+9 -2
View File
@@ -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)
{