* Add id for checking unique field.

This commit is contained in:
daitingting
2022-05-09 17:02:23 +08:00
committed by wangyuting2
parent a607161591
commit d577d57a33
16 changed files with 73 additions and 6 deletions
-2
View File
@@ -42,8 +42,6 @@ class control extends baseControl
/* Code for task #9224. Set requiredFields for workflow. */
if($this->dbh and (defined('IN_USE') or (defined('RUN_MODE') and RUN_MODE == 'api')))
{
$this->checkRequireFlowField();
if(isset($this->config->{$this->moduleName}) and strpos($this->methodName, 'export') !== false)
{
if(isset($this->config->{$this->moduleName}->exportFields) or isset($this->config->{$this->moduleName}->list->exportFields))
+3 -3
View File
@@ -47,14 +47,14 @@ class dao extends baseDAO
$module = $app->getmodulename();
$method = $app->getmethodname();
$flowaction = $this->dbh->query("select * from " . table_workflowaction . " where `module` = '{$module}' and `action` = '{$method}' and `buildin` = '1' and `extensiontype` = 'extend'")->fetch(pdo::fetch_obj);
$flowaction = $this->dbh->query("select * from " . TABLE_WORKFLOWACTION . " where `module` = '{$module}' and `action` = '{$method}' and `buildin` = '1' and `extensiontype` = 'extend'")->fetch(PDO::FETCH_OBJ);
if(!$flowaction) return $this;
$flowfields = $this->dbh->query("select t2.name,t2.rules,t2.control,t2.field,t1.layoutrules from " . table_workflowlayout . " as t1 left join " . table_workflowfield . " as t2 on t1.module = t2.module and t1.field = t2.field where t1.module = '{$module}' and t1.action = '{$method}' and t1.readonly = '0'")->fetchall();
$flowfields = $this->dbh->query("select t2.name,t2.rules,t2.control,t2.field,t1.layoutrules from " . TABLE_WORKFLOWLAYOUT . " as t1 left join " . TABLE_WORKFLOWFIELD . " as t2 on t1.module = t2.module and t1.field = t2.field where t1.module = '{$module}' and t1.action = '{$method}' and t1.readonly = '0'")->fetchall();
if(!$flowfields) return $this;
$rules = array();
$rawrules = $this->dbh->query("select * from " . table_workflowrule)->fetchall();
$rawrules = $this->dbh->query("select * from " . TABLE_WORKFLOWRULE)->fetchall();
foreach($rawrules as $rule) $rules[$rule->id] = $rule;
foreach($flowfields as $key => $field)
+7
View File
@@ -675,6 +675,7 @@ class bugModel extends model
}
$now = helper::now();
$bug = fixer::input('post')
->add('id', $bugID)
->cleanInt('product,module,severity,project,execution,story,task,branch')
->stripTags($this->config->bug->editor->edit['id'], $this->config->allowedTags)
->setDefault('product,module,execution,story,task,duplicateBug,branch', 0)
@@ -789,6 +790,7 @@ class bugModel extends model
$oldBug = $oldBugs[$bugID];
$bug = new stdclass();
$bug->id = $bugID;
$bug->lastEditedBy = $this->app->user->account;
$bug->lastEditedDate = $now;
$bug->type = $data->types[$bugID];
@@ -930,6 +932,7 @@ class bugModel extends model
$now = helper::now();
$oldBug = $this->getById($bugID);
$bug = fixer::input('post')
->add('id', $bugID)
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
->setDefault('assignedDate', $now)
@@ -963,6 +966,7 @@ class bugModel extends model
$oldBug = $this->getById($bugID);
$bug = fixer::input('post')
->add('id', $bugID)
->setDefault('confirmed', 1)
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
@@ -1028,6 +1032,7 @@ class bugModel extends model
$now = helper::now();
$oldBug = $this->getById($bugID);
$bug = fixer::input('post')
->add('id', $bugID)
->add('status', 'resolved')
->add('confirmed', 1)
->setDefault('lastEditedBy', $this->app->user->account)
@@ -1312,6 +1317,7 @@ class bugModel extends model
->setDefault('lastEditedDate', $now)
->setDefault('activatedDate', $now)
->setDefault('activatedCount', (int)$oldBug->activatedCount)
->add('id', $bugID)
->add('resolution', '')
->add('status', 'active')
->add('resolvedDate', '0000-00-00')
@@ -1363,6 +1369,7 @@ class bugModel extends model
$now = helper::now();
$oldBug = $this->getById($bugID);
$bug = fixer::input('post')
->add('id', $bugID)
->add('assignedTo', 'closed')
->add('status', 'closed')
->add('confirmed', 1)
+1
View File
@@ -325,6 +325,7 @@ class buildModel extends model
$buildID = (int)$buildID;
$oldBuild = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($buildID)->fetch();
$build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags)
->add('id', $buildID)
->setIF(!isset($_POST['branch']), 'branch', $oldBuild->branch)
->setDefault('product', $oldBuild->product)
->cleanInt('product,branch,execution')
+1
View File
@@ -94,6 +94,7 @@ class caselibModel extends model
$oldLib = $this->dao->select("*")->from(TABLE_TESTSUITE)->where('id')->eq((int)$libID)->fetch();
$lib = fixer::input('post')
->stripTags($this->config->caselib->editor->edit['id'], $this->config->allowedTags)
->add('id', $libID)
->add('lastEditedBy', $this->app->user->account)
->add('lastEditedDate', helper::now())
->remove('uid')
+7
View File
@@ -469,6 +469,7 @@ class executionModel extends model
/* Get the data from the post. */
$execution = fixer::input('post')
->add('id', $executionID)
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', helper::now())
->setIF(helper::isZeroDate($this->post->begin), 'begin', '')
@@ -621,6 +622,7 @@ class executionModel extends model
$executionID = (int)$executionID;
$executions[$executionID] = new stdClass();
$executions[$executionID]->id = $executionID;
$executions[$executionID]->name = $executionName;
$executions[$executionID]->code = $executionCode;
$executions[$executionID]->PM = $data->PMs[$executionID];
@@ -759,6 +761,7 @@ class executionModel extends model
$now = helper::now();
$execution = fixer::input('post')
->add('id', $executionID)
->setDefault('status', 'doing')
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
@@ -791,6 +794,7 @@ class executionModel extends model
$now = helper::now();
$execution = fixer::input('post')
->add('id', $executionID)
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
->remove('comment')
@@ -820,6 +824,7 @@ class executionModel extends model
$now = helper::now();
$execution = fixer::input('post')
->add('id', $executionID)
->setDefault('status', 'suspended')
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
@@ -846,6 +851,7 @@ class executionModel extends model
$now = helper::now();
$execution = fixer::input('post')
->add('id', $executionID)
->setDefault('realEnd', '')
->setDefault('status', 'doing')
->setDefault('lastEditedBy', $this->app->user->account)
@@ -915,6 +921,7 @@ class executionModel extends model
$now = helper::now();
$execution = fixer::input('post')
->add('id', $executionID)
->setDefault('status', 'closed')
->setDefault('closedBy', $this->app->user->account)
->setDefault('closedDate', $now)
+3
View File
@@ -683,6 +683,7 @@ class productModel extends model
if($oldProduct->bind) $this->config->product->edit->requiredFields = 'name';
$product = fixer::input('post')
->add('id', $productID)
->callFunc('name', 'trim')
->setDefault('line', 0)
->setIF(!isset($_POST['whitelist']), 'whitelist', '')
@@ -764,6 +765,7 @@ class productModel extends model
$products[$productID]->status = $data->statuses[$productID];
$products[$productID]->desc = strip_tags($this->post->descs[$productID], $this->config->allowedTags);
$products[$productID]->acl = $data->acls[$productID];
$products[$productID]->id = $productID;
foreach($extendFields as $extendField)
{
@@ -820,6 +822,7 @@ class productModel extends model
$oldProduct = $this->getById($productID);
$now = helper::now();
$product= fixer::input('post')
->add('id', $productID)
->setDefault('status', 'closed')
->remove('comment')->get();
+2
View File
@@ -475,6 +475,7 @@ class productplanModel extends model
$plan = fixer::input('post')->stripTags($this->config->productplan->editor->edit['id'], $this->config->allowedTags)
->setIF($this->post->future or empty($_POST['begin']), 'begin', $this->config->productplan->future)
->setIF($this->post->future or empty($_POST['end']), 'end', $this->config->productplan->future)
->add('id', $planID)
->remove('delta,uid,future')
->get();
@@ -638,6 +639,7 @@ class productplanModel extends model
$plan->end = isset($data->end[$planID]) ? $data->end[$planID] : '';
$plan->status = isset($data->status[$planID]) ? $data->status[$planID] : $oldPlans[$planID]->status;
$plan->parent = $oldPlans[$planID]->parent;
$plan->id = $planID;
if(empty($plan->title)) return print(js::alter(sprintf($this->lang->productplan->errorNoTitle, $planID)));
if($plan->begin > $plan->end and !empty($plan->end)) return print(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID)));
+1
View File
@@ -689,6 +689,7 @@ class programModel extends model
$oldProgram = $this->dao->findById($programID)->from(TABLE_PROGRAM)->fetch();
$program = fixer::input('post')
->add('id', $programID)
->setDefault('team', $this->post->name)
->setDefault('end', '')
->setIF($this->post->begin == '0000-00-00', 'begin', '')
+7
View File
@@ -1066,6 +1066,7 @@ class projectModel extends model
$_POST['products'] = isset($_POST['products']) ? array_filter($_POST['products']) : $linkedProducts;
$project = fixer::input('post')
->add('id', $projectID)
->callFunc('name', 'trim')
->setDefault('team', substr($this->post->name, 0, 30))
->setDefault('lastEditedBy', $this->app->user->account)
@@ -1237,6 +1238,7 @@ class projectModel extends model
$projects[$projectID] = new stdClass();
if(isset($data->parents[$projectID])) $projects[$projectID]->parent = $data->parents[$projectID];
$projects[$projectID]->id = $projectID;
$projects[$projectID]->name = $projectName;
$projects[$projectID]->PM = $data->PMs[$projectID];
$projects[$projectID]->begin = $data->begins[$projectID];
@@ -1319,6 +1321,7 @@ class projectModel extends model
$now = helper::now();
$project = fixer::input('post')
->add('id', $projectID)
->setDefault('status', 'doing')
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
@@ -1350,6 +1353,7 @@ class projectModel extends model
$now = helper::now();
$project = fixer::input('post')
->add('id', $projectID)
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
->remove('comment')
@@ -1374,6 +1378,7 @@ class projectModel extends model
{
$oldProject = $this->getById($projectID);
$project = fixer::input('post')
->add('id', $projectID)
->setDefault('status', 'suspended')
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', helper::now())
@@ -1401,6 +1406,7 @@ class projectModel extends model
$now = helper::now();
$project = fixer::input('post')
->add('id', $projectID)
->setDefault('realEnd','')
->setDefault('status', 'doing')
->setDefault('lastEditedBy', $this->app->user->account)
@@ -1471,6 +1477,7 @@ class projectModel extends model
$now = helper::now();
$project = fixer::input('post')
->add('id', $projectID)
->setDefault('status', 'closed')
->setDefault('closedBy', $this->app->user->account)
->setDefault('closedDate', $now)
+3
View File
@@ -192,6 +192,7 @@ class releaseModel extends model
->autoCheck()
->batchCheck($this->config->release->create->requiredFields, 'notempty')
->check('name', 'unique', "product = '{$release->product}' AND branch = '{$release->branch}' AND deleted = '0'");
->checkFlow()
if(dao::isError())
{
@@ -248,6 +249,7 @@ class releaseModel extends model
$branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq((int)$this->post->build)->fetch('branch');
$release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags)
->add('id', $releaseID)
->add('branch', (int)$branch)
->join('mailto', ',')
->setIF(!$this->post->marker, 'marker', 0)
@@ -269,6 +271,7 @@ class releaseModel extends model
->autoCheck()
->batchCheck($this->config->release->edit->requiredFields, 'notempty')
->check('name', 'unique', "id != '$releaseID' AND product = '{$release->product}' AND branch = '$branch' AND deleted = '0'")
->checkFlow()
->where('id')->eq((int)$releaseID)
->exec();
if(!dao::isError())
+13
View File
@@ -676,6 +676,7 @@ class storyModel extends model
$story = fixer::input('post')
->callFunc('title', 'trim')
->setDefault('lastEditedBy', $this->app->user->account)
->add('id', $storyID)
->add('lastEditedDate', $now)
->setIF($specChanged, 'version', $oldStory->version + 1)
->setIF($specChanged and $oldStory->status == 'active' and $this->post->needNotReview == false, 'status', 'changed')
@@ -772,6 +773,7 @@ class storyModel extends model
->cleanFloat('estimate')
->setDefault('assignedDate', $oldStory->assignedDate)
->setDefault('lastEditedBy', $this->app->user->account)
->add('id', $storyID)
->add('lastEditedDate', $now)
->setDefault('plan,notifyEmail', '')
->setDefault('status', $oldStory->status)
@@ -1209,6 +1211,7 @@ class storyModel extends model
$oldStory = $oldStories[$storyID];
$story = new stdclass();
$story->id = $storyID;
$story->lastEditedBy = $this->app->user->account;
$story->lastEditedDate = $now;
$story->status = $oldStory->status;
@@ -1330,6 +1333,7 @@ class storyModel extends model
->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'duplicate', 'duplicateStory')
->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'subdivided', 'childStories')
->add('reviewedBy', $oldStory->reviewedBy . ',' . $this->app->user->account)
->add('id', $storyID)
->remove('result,preVersion,comment')
->get();
@@ -1549,6 +1553,7 @@ class storyModel extends model
$oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
$now = helper::now();
$story = fixer::input('post')
->add('id', $storyID)
->add('assignedTo', 'closed')
->add('status', 'closed')
->add('stage', 'closed')
@@ -1981,6 +1986,13 @@ class storyModel extends model
$story->assignedTo = $assignedTo;
$story->assignedDate = $now;
$story = fixer::input('post')
->add('id', $storyID)
->add('lastEditedBy', $this->app->user->account)
->add('lastEditedDate', $now)
->add('assignedDate', $now)
->get();
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
if(!dao::isError()) return common::createChanges($oldStory, $story);
return false;
@@ -2029,6 +2041,7 @@ class storyModel extends model
$oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
$now = helper::now();
$story = fixer::input('post')
->add('id', $storyID)
->add('closedBy', '')
->add('closedReason', '')
->add('closedDate', '0000-00-00')
+9
View File
@@ -908,6 +908,7 @@ class taskModel extends model
$now = helper::now();
$task = fixer::input('post')
->add('id', $taskID)
->setDefault('story, estimate, left, consumed', 0)
->setDefault('realStarted', '0000-00-00 00:00:00')
->setIF(is_numeric($this->post->estimate), 'estimate', (float)$this->post->estimate)
@@ -1170,6 +1171,7 @@ class taskModel extends model
$oldTask = $oldTasks[$taskID];
$task = new stdclass();
$task->id = $taskID;
$task->color = $data->colors[$taskID];
$task->name = $data->names[$taskID];
$task->module = isset($data->modules[$taskID]) ? $data->modules[$taskID] : 0;
@@ -1437,6 +1439,7 @@ class taskModel extends model
$now = helper::now();
$task = fixer::input('post')
->add('id', $taskID)
->cleanFloat('left')
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
@@ -1502,6 +1505,7 @@ class taskModel extends model
$now = helper::now();
$task = fixer::input('post')
->add('id', $taskID)
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', $now)
->setDefault('status', 'doing')
@@ -1727,6 +1731,7 @@ class taskModel extends model
}
$task = fixer::input('post')
->add('id', $taskID)
->setIF(is_numeric($this->post->consumed), 'consumed', (float)$this->post->consumed)
->setIF(!$this->post->realStarted and helper::isZeroDate($oldTask->realStarted), 'realStarted', $now)
->setDefault('left', 0)
@@ -1857,6 +1862,7 @@ class taskModel extends model
$oldTask = $this->getById($taskID);
$task = fixer::input('post')
->add('id', $taskID)
->setDefault('status', 'pause')
->setDefault('lastEditedBy', $this->app->user->account)
->setDefault('lastEditedDate', helper::now())
@@ -1890,6 +1896,7 @@ class taskModel extends model
$now = helper::now();
$task = fixer::input('post')
->add('id', $taskID)
->setDefault('status', 'closed')
->setDefault('assignedTo', 'closed')
->setDefault('assignedDate', $now)
@@ -1935,6 +1942,7 @@ class taskModel extends model
$now = helper::now();
$task = fixer::input('post')
->add('id', $taskID)
->setDefault('status', 'cancel')
->setDefault('assignedTo', $oldTask->openedBy)
->setDefault('assignedDate', $now)
@@ -1995,6 +2003,7 @@ class taskModel extends model
$oldTask = $this->getById($taskID);
if($oldTask->parent == '-1') $this->config->task->activate->requiredFields = '';
$task = fixer::input('post')
->add('id', $taskID)
->setIF(is_numeric($this->post->left), 'left', (float)$this->post->left)
->setDefault('left', 0)
->setDefault('status', 'doing')
+3
View File
@@ -715,6 +715,7 @@ class testcaseModel extends model
$version = $stepChanged ? $oldCase->version + 1 : $oldCase->version;
$case = fixer::input('post')
->add('id', $caseID)
->add('version', $version)
->setIF($this->post->story != false and $this->post->story != $oldCase->story, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story))
->setIF(!$this->post->linkCase, 'linkCase', '')
@@ -835,6 +836,7 @@ class testcaseModel extends model
$now = helper::now();
$status = $this->getStatus('review', $oldCase);
$case = fixer::input('post')
->add('id', $caseID)
->remove('result,comment')
->setDefault('reviewedDate', substr($now, 0, 10))
->setDefault('lastEditedBy', $this->app->user->account)
@@ -947,6 +949,7 @@ class testcaseModel extends model
foreach($caseIDList as $caseID)
{
$case = new stdclass();
$case->id = $caseID;
$case->lastEditedBy = $this->app->user->account;
$case->lastEditedDate = $now;
$case->pri = $data->pris[$caseID];
+1
View File
@@ -149,6 +149,7 @@ class testsuiteModel extends model
$oldSuite = $this->dao->select("*")->from(TABLE_TESTSUITE)->where('id')->eq((int)$suiteID)->fetch();
$suite = fixer::input('post')
->stripTags($this->config->testsuite->editor->edit['id'], $this->config->allowedTags)
->add('id', $suiteID)
->add('lastEditedBy', $this->app->user->account)
->add('lastEditedDate', helper::now())
->remove('uid')
+12 -1
View File
@@ -733,14 +733,22 @@ class testtaskModel extends model
public function update($taskID)
{
$oldTask = $this->dao->select("*")->from(TABLE_TESTTASK)->where('id')->eq((int)$taskID)->fetch();
$task = fixer::input('post')->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)->join('mailto', ',')->join('type', ',')->remove('files,labels,uid,comment,contactListMenu')->get();
$task = fixer::input('post')
->add('id')
->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)
->join('mailto', ',')
->join('type', ',')
->remove('files,labels,uid,comment,contactListMenu')
->get();
$task = $this->loadModel('file')->processImgURL($task, $this->config->testtask->editor->edit['id'], $this->post->uid);
$this->dao->update(TABLE_TESTTASK)->data($task)
->autoCheck()
->batchcheck($this->config->testtask->edit->requiredFields, 'notempty')
->checkIF($task->end != '', 'end', 'ge', $task->begin)
->where('id')->eq($taskID)
->exec();
if(!dao::isError())
{
$this->file->updateObjectID($this->post->uid, $taskID, 'testtask');
@@ -760,6 +768,7 @@ class testtaskModel extends model
{
$oldTesttask = $this->getById($taskID);
$testtask = fixer::input('post')
->add('id', $taskID)
->setDefault('status', 'doing')
->remove('comment')->get();
@@ -781,6 +790,7 @@ class testtaskModel extends model
{
$oldTesttask = $this->getById($taskID);
$testtask = fixer::input('post')
->add('id', $taskID)
->setDefault('status', 'done')
->stripTags($this->config->testtask->editor->close['id'], $this->config->allowedTags)
->join('mailto', ',')
@@ -822,6 +832,7 @@ class testtaskModel extends model
{
$oldTesttask = $this->getById($taskID);
$testtask = fixer::input('post')
->add('id', $taskID)
->setDefault('status', 'blocked')
->remove('comment')->get();