* code for task #7302.
This commit is contained in:
@@ -1070,9 +1070,6 @@ class baseDAO
|
||||
$fieldLabel = isset($lang->$table->$fieldName) ? $lang->$table->$fieldName : $fieldName;
|
||||
$value = isset($this->sqlobj->data->$fieldName) ? $this->sqlobj->data->$fieldName : null;
|
||||
|
||||
$moduleName = $table == 'case' ? 'testcase' : $table;
|
||||
$selectFields = isset($config->$moduleName->selectFields) ? $config->$moduleName->selectFields : '';
|
||||
|
||||
/*
|
||||
* 检查唯一性。
|
||||
* Check unique.
|
||||
@@ -1107,13 +1104,6 @@ class baseDAO
|
||||
${"arg$i"} = isset($funcArgs[$i + 2]) ? $funcArgs[$i + 2] : null;
|
||||
}
|
||||
|
||||
/* When check not empty and field is select, then use empty function to check. */
|
||||
if(strtolower($funcName) == 'notempty')
|
||||
{
|
||||
$arg0 = false;
|
||||
if(!empty($selectFields) and strpos(",{$selectFields},", ",{$fieldName},") !== false) $arg0 = true;
|
||||
}
|
||||
|
||||
$checkFunc = 'check' . $funcName;
|
||||
if(validater::$checkFunc($value, $arg0, $arg1, $arg2) === false)
|
||||
{
|
||||
|
||||
@@ -324,17 +324,13 @@ class baseValidater
|
||||
* Not empty checking.
|
||||
*
|
||||
* @param mixed $var
|
||||
* @param bool $useEmpty
|
||||
* @static
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkNotEmpty($var, $useEmpty = false)
|
||||
public static function checkNotEmpty($var)
|
||||
{
|
||||
$var = trim($var);
|
||||
|
||||
if($useEmpty) return !empty($var);
|
||||
return strlen($var) != 0;
|
||||
return !empty($var);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
$config->bug = new stdClass();
|
||||
$config->bug->batchCreate = 10;
|
||||
$config->bug->longlife = 7;
|
||||
$config->bug->selectFields = 'module,project,openedBuild,resolution,pri,severity,type,story,task,os,browser,plan,assignedTo,resolvedBuild';
|
||||
$config->bug->batchCreate = 10;
|
||||
$config->bug->longlife = 7;
|
||||
|
||||
$config->bug->create = new stdclass();
|
||||
$config->bug->edit = new stdclass();
|
||||
|
||||
@@ -145,7 +145,7 @@ class bugModel extends model
|
||||
->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story))
|
||||
->setIF(strpos($this->config->bug->create->requiredFields, 'project') !== false, 'project', $this->post->project)
|
||||
->stripTags($this->config->bug->editor->create['id'], $this->config->allowedTags)
|
||||
->cleanInt('product, module, severity')
|
||||
->cleanInt('product,project,module,severity')
|
||||
->join('openedBuild', ',')
|
||||
->join('mailto', ',')
|
||||
->remove('files, labels,uid,oldTaskID,contactListMenu')
|
||||
@@ -230,10 +230,10 @@ class bugModel extends model
|
||||
$bug = new stdClass();
|
||||
$bug->openedBy = $this->app->user->account;
|
||||
$bug->openedDate = $now;
|
||||
$bug->product = $productID;
|
||||
$bug->branch = $data->branches[$i];
|
||||
$bug->module = $data->modules[$i];
|
||||
$bug->project = $data->projects[$i];
|
||||
$bug->product = (int)$productID;
|
||||
$bug->branch = (int)$data->branches[$i];
|
||||
$bug->module = (int)$data->modules[$i];
|
||||
$bug->project = (int)$data->projects[$i];
|
||||
$bug->openedBuild = implode(',', $data->openedBuilds[$i]);
|
||||
$bug->color = $data->color[$i];
|
||||
$bug->title = $data->title[$i];
|
||||
@@ -637,9 +637,9 @@ class bugModel extends model
|
||||
|
||||
$now = helper::now();
|
||||
$bug = fixer::input('post')
|
||||
->cleanInt('product,module,severity,project,story,task')
|
||||
->cleanInt('product,module,severity,project,story,task,branch')
|
||||
->stripTags($this->config->bug->editor->edit['id'], $this->config->allowedTags)
|
||||
->setDefault('project,module,project,story,task,duplicateBug,branch', 0)
|
||||
->setDefault('product,module,project,story,task,duplicateBug,branch', 0)
|
||||
->setDefault('openedBuild', '')
|
||||
->setDefault('plan', 0)
|
||||
->setDefault('deadline', '0000-00-00')
|
||||
|
||||
@@ -8,5 +8,3 @@ $config->build->edit->requiredFields = 'product,project,name,builder,date';
|
||||
$config->build->editor = new stdclass();
|
||||
$config->build->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->build->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
|
||||
$config->build->selectFields = 'product,project,builder';
|
||||
|
||||
@@ -239,7 +239,7 @@ class buildModel extends model
|
||||
$build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags)
|
||||
->setDefault('product', $oldBuild->product)
|
||||
->setDefault('branch', $oldBuild->branch)
|
||||
->cleanInt('product,branch')
|
||||
->cleanInt('product,branch,project')
|
||||
->remove('allchecker,resolvedBy,files,labels,uid')
|
||||
->get();
|
||||
|
||||
|
||||
@@ -4,5 +4,3 @@ $config->job->create = new stdclass();
|
||||
$config->job->edit = new stdclass();
|
||||
$config->job->create->requiredFields = 'name,repo,jkHost,jkJob,triggerType';
|
||||
$config->job->edit->requiredFields = 'name,repo,jkHost,jkJob,triggerType';
|
||||
|
||||
$config->job->selectFields = 'repo,jkHost,jkJob,triggerType';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
$config->product = new stdclass();
|
||||
$config->product->orderBy = 'isClosed,order_desc';
|
||||
$config->product->selectFields = 'line,PO,QD,RD,type';
|
||||
$config->product->orderBy = 'isClosed,order_desc';
|
||||
|
||||
$config->product->customBatchEditFields = 'line,PO,QD,RD,status,type,desc';
|
||||
|
||||
|
||||
@@ -8,5 +8,3 @@ $config->release->edit->requiredFields = 'name,date,build';
|
||||
$config->release->editor = new stdclass();
|
||||
$config->release->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->release->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
|
||||
$config->release->selectFields = 'build';
|
||||
|
||||
@@ -4,7 +4,6 @@ $config->story = new stdclass();
|
||||
$config->story->batchCreate = 10;
|
||||
$config->story->affectedFixedNum = 7;
|
||||
$config->story->needReview = 1;
|
||||
$config->story->selectFields = 'module,plan,source,pri,closedReason,assignedTo,reviewedBy';
|
||||
|
||||
$config->story->batchClose = new stdclass();
|
||||
$config->story->batchClose->columns = 10;
|
||||
|
||||
+21
-6
@@ -192,8 +192,19 @@ class storyModel extends model
|
||||
if($this->checkForceReview()) $story->status = 'draft';
|
||||
if($story->status == 'draft') $story->stage = $this->post->plan > 0 ? 'planned' : 'wait';
|
||||
$story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->create['id'], $this->post->uid);
|
||||
if($story->type == 'requirement') $this->config->story->create->requiredFields = str_replace('plan,', '', $this->config->story->create->requiredFields);
|
||||
$this->dao->insert(TABLE_STORY)->data($story, 'spec,verify')->autoCheck()->batchCheck($this->config->story->create->requiredFields, 'notempty')->exec();
|
||||
|
||||
$requiredFields = "," . $this->config->story->create->requiredFields . ",";
|
||||
|
||||
if($story->type == 'requirement') $requiredFields = str_replace(',plan,', ',', $requiredFields);
|
||||
if(strpos($requiredFields, ',estimate,') !== false)
|
||||
{
|
||||
if(strlen(trim($story->estimate)) == 0) dao::$errors['estimate'] = sprintf($this->lang->error->notempty, $this->lang->story->estimate);
|
||||
$requiredFields = str_replace(',estimate,', ',', $requiredFields);
|
||||
}
|
||||
|
||||
$requiredFields = trim($requiredFields, ',');
|
||||
|
||||
$this->dao->insert(TABLE_STORY)->data($story, 'spec,verify')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec();
|
||||
if(!dao::isError())
|
||||
{
|
||||
$storyID = $this->dao->lastInsertID();
|
||||
@@ -335,7 +346,13 @@ class storyModel extends model
|
||||
foreach(explode(',', $this->config->story->create->requiredFields) as $field)
|
||||
{
|
||||
$field = trim($field);
|
||||
if($field and empty($story->$field)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->story->$field)));
|
||||
if(empty($field)) continue;
|
||||
|
||||
if(!empty($story->$field)) continue;
|
||||
if($field == 'estimate' and strlen(trim($story->estimate)) != 0) continue;
|
||||
|
||||
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->story->$field);
|
||||
return false;
|
||||
}
|
||||
|
||||
$data[$i] = $story;
|
||||
@@ -343,9 +360,7 @@ class storyModel extends model
|
||||
|
||||
foreach($data as $i => $story)
|
||||
{
|
||||
$this->dao->insert(TABLE_STORY)->data($story)->autoCheck()
|
||||
->batchCheck($this->config->story->create->requiredFields, 'notempty')
|
||||
->exec();
|
||||
$this->dao->insert(TABLE_STORY)->data($story)->autoCheck()->exec();
|
||||
if(dao::isError())
|
||||
{
|
||||
echo js::error(dao::getError());
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
$config->task = new stdclass();
|
||||
$config->task->batchCreate = 10;
|
||||
$config->task->selectFields = 'project,type,story,module,pri,assignedTo';
|
||||
$config->task->batchCreate = 10;
|
||||
|
||||
$config->task->create = new stdclass();
|
||||
$config->task->edit = new stdclass();
|
||||
|
||||
+60
-12
@@ -98,6 +98,13 @@ class taskModel extends model
|
||||
$requiredFields = str_replace(",estStarted,", ',', "$requiredFields");
|
||||
$requiredFields = str_replace(",deadline,", ',', "$requiredFields");
|
||||
}
|
||||
|
||||
if(strpos($requiredFields, ',estimate,') !== false)
|
||||
{
|
||||
if(strlen(trim($task->estimate)) == 0) dao::$errors['estimate'] = sprintf($this->lang->error->notempty, $this->lang->task->estimate);
|
||||
$requiredFields = str_replace(',estimate,', ',', $requiredFields);
|
||||
}
|
||||
|
||||
$requiredFields = trim($requiredFields, ',');
|
||||
|
||||
/* Fix Bug #2466 */
|
||||
@@ -301,10 +308,10 @@ class taskModel extends model
|
||||
}
|
||||
|
||||
/* Fix bug #1525*/
|
||||
$projectType =$this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('type');
|
||||
$requiredFields = explode(',', $this->config->task->create->requiredFields);
|
||||
if($projectType == 'ops') unset($requiredFields[array_search('story', $requiredFields)]);
|
||||
$requiredFields = implode(',', $requiredFields);
|
||||
$projectType = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('type');
|
||||
$requiredFields = ',' . $this->config->task->create->requiredFields . ',';
|
||||
if($projectType == 'ops') $requiredFields = str_replace(',story,', ',', $requiredFields);
|
||||
$requiredFields = trim($requiredFields, ',');
|
||||
|
||||
/* check data. */
|
||||
foreach($data as $i => $task)
|
||||
@@ -314,19 +321,23 @@ class taskModel extends model
|
||||
dao::$errors['message'][] = $this->lang->task->error->deadlineSmall;
|
||||
return false;
|
||||
}
|
||||
|
||||
if($task->estimate and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $task->estimate))
|
||||
{
|
||||
dao::$errors['message'][] = $this->lang->task->error->estimateNumber;
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach(explode(',', $requiredFields) as $field)
|
||||
{
|
||||
$field = trim($field);
|
||||
if($field and empty($task->$field))
|
||||
{
|
||||
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->task->$field);
|
||||
return false;
|
||||
}
|
||||
if(empty($field)) continue;
|
||||
|
||||
if(!empty($task->$field)) continue;
|
||||
if($field == 'estimate' and strlen(trim($task->estimate)) != 0) continue;
|
||||
|
||||
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->task->$field);
|
||||
return false;
|
||||
}
|
||||
if($task->estimate) $task->estimate = (float)$task->estimate;
|
||||
}
|
||||
@@ -337,7 +348,6 @@ class taskModel extends model
|
||||
{
|
||||
$this->dao->insert(TABLE_TASK)->data($task)
|
||||
->autoCheck()
|
||||
->batchCheck($requiredFields, 'notempty')
|
||||
->checkIF($task->estimate != '', 'estimate', 'float')
|
||||
->exec();
|
||||
|
||||
@@ -815,9 +825,25 @@ class taskModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
$projectType = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($task->project)->fetch('type');
|
||||
$requiredFields = "," . $this->config->task->edit->requiredFields . ",";
|
||||
if($projectType == 'ops')
|
||||
{
|
||||
$requiredFields = str_replace(",story,", ',', "$requiredFields");
|
||||
$task->story = 0;
|
||||
}
|
||||
|
||||
if($task->status != 'cancel' and strpos($requiredFields, ',estimate,') !== false)
|
||||
{
|
||||
if(strlen(trim($task->estimate)) == 0) dao::$errors['estimate'] = sprintf($this->lang->error->notempty, $this->lang->task->estimate);
|
||||
$requiredFields = str_replace(',estimate,', ',', $requiredFields);
|
||||
}
|
||||
|
||||
$requiredFields = trim($requiredFields, ',');
|
||||
|
||||
$this->dao->update(TABLE_TASK)->data($task)
|
||||
->autoCheck()
|
||||
->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty')
|
||||
->batchCheckIF($task->status != 'cancel', $requiredFields, 'notempty')
|
||||
->checkIF($task->deadline != '0000-00-00', 'deadline', 'ge', $task->estStarted)
|
||||
|
||||
->checkIF($task->estimate != false, 'estimate', 'float')
|
||||
@@ -930,6 +956,7 @@ class taskModel extends model
|
||||
/* Initialize tasks from the post data.*/
|
||||
$extendFields = $this->getFlowExtendFields();
|
||||
$oldTasks = $taskIDList ? $this->getByList($taskIDList) : array();
|
||||
$tasks = array();
|
||||
foreach($taskIDList as $taskID)
|
||||
{
|
||||
$oldTask = $oldTasks[$taskID];
|
||||
@@ -1028,9 +1055,30 @@ class taskModel extends model
|
||||
}
|
||||
if($task->assignedTo) $task->assignedDate = $now;
|
||||
|
||||
$tasks[$taskID] = $task;
|
||||
}
|
||||
|
||||
/* Check field not empty. */
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
if($task->status == 'cancel') continue;
|
||||
foreach(explode(',', $this->config->task->edit->requiredFields) as $field)
|
||||
{
|
||||
$field = trim($field);
|
||||
if(empty($field)) continue;
|
||||
|
||||
if(!empty($task->$field)) continue;
|
||||
if($field == 'estimate' and strlen(trim($task->estimate)) != 0) continue;
|
||||
|
||||
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->task->$field);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
$this->dao->update(TABLE_TASK)->data($task)
|
||||
->autoCheck()
|
||||
->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty')
|
||||
|
||||
->checkIF($task->estimate != false, 'estimate', 'float')
|
||||
->checkIF($task->consumed != false, 'consumed', 'float')
|
||||
|
||||
@@ -3,7 +3,6 @@ $config->testcase = new stdclass();
|
||||
$config->testcase->defaultSteps = 3;
|
||||
$config->testcase->batchCreate = 10;
|
||||
$config->testcase->needReview = 0;
|
||||
$config->testcase->selectFields = 'lib,stage,type,story,pri,status';
|
||||
|
||||
$config->testcase->create = new stdclass();
|
||||
$config->testcase->edit = new stdclass();
|
||||
|
||||
@@ -8,5 +8,3 @@ $config->testreport->edit->requiredFields = 'title,owner';
|
||||
$config->testreport->editor = new stdclass();
|
||||
$config->testreport->editor->create = array('id' => 'report', 'tools' => 'simpleTools');
|
||||
$config->testreport->editor->edit = array('id' => 'report', 'tools' => 'simpleTools');
|
||||
|
||||
$config->testreport->selectFields = 'owner';
|
||||
|
||||
@@ -5,8 +5,6 @@ $config->testtask->edit = new stdclass();
|
||||
$config->testtask->create->requiredFields = 'project,build,begin,end,name';
|
||||
$config->testtask->edit->requiredFields = 'project,build,begin,end,name';
|
||||
|
||||
$config->testtask->selectFields = 'project,build,owner';
|
||||
|
||||
$config->testtask->importunitresult = new stdclass();
|
||||
$config->testtask->importunitresult->requiredFields = 'project,build,begin,end,name,resultFile';
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ $config->user->contactField = 'mobile,phone,qq,dingding,weixin,skype,whatsapp,sl
|
||||
$config->user->failTimes = 6;
|
||||
$config->user->lockMinutes = 10;
|
||||
$config->user->batchCreate = 10;
|
||||
$config->user->selectFields = 'dept,role';
|
||||
|
||||
Reference in New Issue
Block a user