diff --git a/db/update17.0.sql b/db/update17.0.sql new file mode 100644 index 0000000000..7cf03128bf --- /dev/null +++ b/db/update17.0.sql @@ -0,0 +1,3 @@ +DELETE FROM `zt_workflowaction` WHERE `module`='story' AND `action`='browse'; +DELETE FROM `zt_workflowaction` WHERE `module`='task' AND `action`='browse'; +DELETE FROM `zt_workflowaction` WHERE `module`='build' AND `action`='browse'; diff --git a/framework/helper.class.php b/framework/helper.class.php index ddc4aecb30..c944daa477 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -285,7 +285,7 @@ function formatTime($time, $format = '') { $time = str_replace('0000-00-00', '', $time); $time = str_replace('00:00:00', '', $time); - if(trim($time) == '') return ; + if(trim($time) == '') return ''; if($format) return date($format, strtotime($time)); return trim($time); } diff --git a/framework/model.class.php b/framework/model.class.php index aa59671506..caf535c15a 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -103,10 +103,10 @@ class model extends baseModel if($action->extensionType == 'override') return $this->loadModel('flow')->buildActionMenu($moduleName, $action, $data, $type); $conditions = json_decode($action->conditions); - if($action->extensionType == 'extend' && $conditions) + if($action->extensionType == 'extend') { - $enabled = $this->loadModel('flow')->checkConditions($conditions, $data); - $label = $action->name; + $title = $action->name; + if($conditions) $enabled = $this->loadModel('flow')->checkConditions($conditions, $data); } else { diff --git a/lib/front/front.class.php b/lib/front/front.class.php index d9078b82f8..6913efb848 100644 --- a/lib/front/front.class.php +++ b/lib/front/front.class.php @@ -91,7 +91,7 @@ class html extends baseHTML $string .= "'; } return $string; @@ -391,6 +391,19 @@ class html extends baseHTML */ class js extends baseJS { + /** + * Open a new app window. + * + * @param string $app + * @param string $url + * @static + * @access public + * @return string + */ + static public function openEntry($app, $url) + { + return self::start() . "$.apps.open('$url', '$app')" . self::end(); + } } /** diff --git a/module/bug/model.php b/module/bug/model.php index 49427c5fa2..723d90e267 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -938,10 +938,12 @@ class bugModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('assignedDate', $now) + ->stripTags($this->config->bug->editor->assignto['id'], $this->config->allowedTags) ->remove('comment,showModule') ->join('mailto', ',') ->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->assignto['id'], $this->post->uid); $this->dao->update(TABLE_BUG) ->data($bug) ->autoCheck() @@ -973,10 +975,12 @@ class bugModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('assignedDate', $now) + ->stripTags($this->config->bug->editor->confirmbug['id'], $this->config->allowedTags) ->remove('comment') ->join('mailto', ',') ->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->confirmbug['id'], $this->post->uid); $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq($bugID)->exec(); if(!dao::isError()) @@ -1044,8 +1048,10 @@ class bugModel extends model ->setDefault('resolvedDate', $now) ->setDefault('assignedTo', $oldBug->openedBy) ->removeIF($this->post->resolution != 'duplicate', 'duplicateBug') + ->stripTags($this->config->bug->editor->resolve['id'], $this->config->allowedTags) ->remove('files,labels') ->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->resolve['id'], $this->post->uid); /* Set comment lang for alert error. */ $this->lang->bug->comment = $this->lang->comment; @@ -1319,6 +1325,7 @@ class bugModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('activatedDate', $now) ->setDefault('activatedCount', (int)$oldBug->activatedCount) + ->stripTags($this->config->bug->editor->activate['id'], $this->config->allowedTags) ->add('id', $bugID) ->add('resolution', '') ->add('status', 'active') @@ -1334,6 +1341,7 @@ class bugModel extends model ->remove('comment,files,labels') ->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->activate['id'], $this->post->uid); $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq((int)$bugID)->exec(); $this->dao->update(TABLE_BUG)->set('activatedCount = activatedCount + 1')->where('id')->eq((int)$bugID)->exec(); @@ -1380,9 +1388,11 @@ class bugModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('closedBy', $this->app->user->account) ->setDefault('closedDate', $now) + ->stripTags($this->config->bug->editor->close['id'], $this->config->allowedTags) ->remove('comment') ->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->close['id'], $this->post->uid); $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq((int)$bugID)->exec(); if($oldBug->execution) { diff --git a/module/common/model.php b/module/common/model.php index 54a3c34a61..5f392554d1 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1920,7 +1920,7 @@ EOD; if(strtolower($key) == 'closeddate' && $value == '') continue; if(strtolower($key) == 'actualcloseddate' && $value == '') continue; - if(isset($old->$key) and $value != stripslashes($old->$key)) + if(array_key_exists($key, $old) and $value != stripslashes($old->$key)) { $diff = ''; if(substr_count($value, "\n") > 1 or diff --git a/module/execution/model.php b/module/execution/model.php index 2e19ffa8a4..e39021bc1f 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -818,9 +818,11 @@ class executionModel extends model ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->stripTags($this->config->execution->editor->start['id'], $this->config->allowedTags) ->remove('comment') ->get(); + $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->start['id'], $this->post->uid); $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() ->check($this->config->execution->start->requiredFields, 'notempty') @@ -849,6 +851,7 @@ class executionModel extends model $execution = fixer::input('post') ->add('id', $executionID) + ->stripTags($this->config->execution->editor->putoff['id'], $this->config->allowedTags) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->remove('comment') @@ -857,6 +860,7 @@ class executionModel extends model if($this->config->systemMode == 'new') $this->checkBeginAndEndDate($oldExecution->project, $execution->begin, $execution->end); if(dao::isError()) return false; + $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->putoff['id'], $this->post->uid); $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() ->checkFlow() @@ -884,8 +888,10 @@ class executionModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('suspendedDate', helper::today()) + ->stripTags($this->config->execution->editor->suspend['id'], $this->config->allowedTags) ->remove('comment')->get(); + $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->suspend['id'], $this->post->uid); $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() ->checkFlow() @@ -913,6 +919,7 @@ class executionModel extends model ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->stripTags($this->config->execution->editor->activate['id'], $this->config->allowedTags) ->remove('comment,readjustTime,readjustTask') ->get(); @@ -922,6 +929,7 @@ class executionModel extends model unset($execution->end); } + $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->activate['id'], $this->post->uid); $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() ->checkFlow() @@ -995,11 +1003,13 @@ class executionModel extends model ->setDefault('closedDate', $now) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->stripTags($this->config->execution->editor->close['id'], $this->config->allowedTags) ->remove('comment') ->get(); $this->lang->error->ge = $this->lang->execution->ge; + $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->close['id'], $this->post->uid); $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() ->check($this->config->execution->close->requiredFields,'notempty') diff --git a/module/product/model.php b/module/product/model.php index 2d9261812f..f20a1b7d27 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -872,11 +872,14 @@ class productModel extends model { $oldProduct = $this->getById($productID); $now = helper::now(); - $product= fixer::input('post') + $product = fixer::input('post') ->add('id', $productID) ->setDefault('status', 'closed') - ->remove('comment')->get(); + ->stripTags($this->config->product->editor->close['id'], $this->config->allowedTags) + ->remove('comment') + ->get(); + $product = $this->loadModel('file')->processImgURL($product, $this->config->product->editor->close['id'], $this->post->uid); $this->dao->update(TABLE_PRODUCT)->data($product) ->autoCheck() ->checkFlow() diff --git a/module/project/model.php b/module/project/model.php index e46187d781..70d521562f 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1582,13 +1582,18 @@ class projectModel extends model $oldProject = $this->getById($projectID, $type); $now = helper::now(); + $editorIdList = $this->config->project->editor->start['id']; + if($this->app->rawModule == 'program') $editorIdList = $this->config->program->editor->start['id']; + $project = fixer::input('post') ->add('id', $projectID) ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->stripTags($editorIdList, $this->config->allowedTags) ->remove('comment')->get(); + $project = $this->loadModel('file')->processImgURL($project, $editorIdList, $this->post->uid); $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() ->check($this->config->project->start->requiredFields, 'notempty') @@ -1640,15 +1645,20 @@ class projectModel extends model */ public function suspend($projectID) { + $editorIdList = $this->config->project->editor->suspend['id']; + if($this->app->rawModule == 'program') $editorIdList = $this->config->program->editor->suspend['id']; + $oldProject = $this->getById($projectID); - $project = fixer::input('post') + $project = fixer::input('post') ->add('id', $projectID) ->setDefault('status', 'suspended') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) ->setDefault('suspendedDate', helper::today()) + ->stripTags($editorIdList, $this->config->allowedTags) ->remove('comment')->get(); + $project = $this->loadModel('file')->processImgURL($project, $editorIdList, $this->post->uid); $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() ->checkFlow() @@ -1670,6 +1680,9 @@ class projectModel extends model $oldProject = $this->getById($projectID); $now = helper::now(); + $editorIdList = $this->config->project->editor->activate['id']; + if($this->app->rawModule == 'program') $editorIdList = $this->config->program->editor->activate['id']; + $project = fixer::input('post') ->add('id', $projectID) ->setDefault('realEnd','') @@ -1677,6 +1690,7 @@ class projectModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setIF($oldProject->realBegan == '0000-00-00', 'realBegan', helper::today()) + ->stripTags($editorIdList, $this->config->allowedTags) ->remove('comment,readjustTime,readjustTask') ->get(); @@ -1686,6 +1700,7 @@ class projectModel extends model unset($project->end); } + $project = $this->loadModel('file')->processImgURL($project, $editorIdList, $this->post->uid); $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() ->checkFlow() @@ -1742,6 +1757,9 @@ class projectModel extends model $oldProject = $this->getById($projectID); $now = helper::now(); + $editorIdList = $this->config->project->editor->close['id']; + if($this->app->rawModule == 'program') $editorIdList = $this->config->program->editor->close['id']; + $project = fixer::input('post') ->add('id', $projectID) ->setDefault('status', 'closed') @@ -1749,11 +1767,14 @@ class projectModel extends model ->setDefault('closedDate', $now) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->stripTags($editorIdList, $this->config->allowedTags) ->remove('comment') ->get(); $this->lang->error->ge = $this->lang->project->ge; + $project = $this->loadModel('file')->processImgURL($project, $editorIdList, $this->post->uid); + $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() ->check($this->config->project->close->requiredFields, 'notempty') diff --git a/module/story/model.php b/module/story/model.php index 4d755e19d9..010b5ac810 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -830,7 +830,6 @@ class storyModel extends model if(isset($story->stage) and $oldStory->stage != $story->stage) $story->stagedBy = (strpos('tested|verified|released|closed', $story->stage) !== false) ? $this->app->user->account : ''; $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->edit['id'], $this->post->uid); - if(isset($_POST['reviewer'])) { $_POST['reviewer'] = array_filter($_POST['reviewer']); @@ -1327,6 +1326,7 @@ class storyModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('status', $oldStory->status) ->setDefault('reviewedDate', $date) + ->stripTags($this->config->story->editor->review['id'], $this->config->allowedTags) ->setIF($this->post->result == 'revert', 'version', $this->post->preVersion) ->setIF($this->post->result == 'clarify', 'assignedTo', $oldStory->lastEditedBy ? $oldStory->lastEditedBy : $oldStory->openedBy) ->removeIF($this->post->result != 'reject', 'closedReason, duplicateStory, childStories') @@ -1336,6 +1336,7 @@ class storyModel extends model ->add('id', $storyID) ->remove('result,preVersion,comment') ->get(); + $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->review['id'], $this->post->uid); /* Fix bug #671. */ $this->lang->story->closedReason = $this->lang->story->rejectedReason; @@ -1563,6 +1564,7 @@ class storyModel extends model ->setDefault('closedDate', $now) ->setDefault('closedBy', $this->app->user->account) ->setDefault('assignedDate', $now) + ->stripTags($this->config->story->editor->close['id'], $this->config->allowedTags) ->removeIF($this->post->closedReason != 'duplicate', 'duplicateStory') ->removeIF($this->post->closedReason != 'subdivided', 'childStories') ->get(); @@ -1578,6 +1580,7 @@ class storyModel extends model } $this->lang->story->comment = $this->lang->comment; + $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->close['id'], $this->post->uid); $this->dao->update(TABLE_STORY)->data($story, 'comment') ->autoCheck() ->batchCheck($this->config->story->close->requiredFields, 'notempty') @@ -1991,9 +1994,11 @@ class storyModel extends model ->add('lastEditedBy', $this->app->user->account) ->add('lastEditedDate', $now) ->add('assignedDate', $now) + ->stripTags($this->config->story->editor->assignto['id'], $this->config->allowedTags) ->remove('comment') ->get(); + $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->assignto['id'], $this->post->uid); $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->checkFlow()->where('id')->eq((int)$storyID)->exec(); if(!dao::isError()) return common::createChanges($oldStory, $story); return false; @@ -2054,8 +2059,10 @@ class storyModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('assignedDate', $now) ->setDefault('activatedDate', $now) + ->stripTags($this->config->story->editor->activate['id'], $this->config->allowedTags) ->remove('comment') ->get(); + $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->activate['id'], $this->post->uid); $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->checkFlow()->where('id')->eq($storyID)->exec(); if($this->post->status == 'active') $this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->exec(); diff --git a/module/task/model.php b/module/task/model.php index 8d295377cd..a434100c1d 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -113,7 +113,7 @@ class taskModel extends model } } - $task = $this->file->processImgURL($task, $this->config->task->editor->create['id'], $this->post->uid); + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->create['id'], $this->post->uid); /* Fix Bug #1525 */ $executionType = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($executionID)->fetch('type'); @@ -1465,6 +1465,7 @@ class taskModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('assignedDate', $now) + ->stripTags($this->config->task->editor->assignto['id'], $this->config->allowedTags) ->remove('comment,showModule') ->get(); if($oldTask->status != 'done' and $oldTask->status != 'closed' and isset($task->left) and $task->left == 0) @@ -1489,6 +1490,7 @@ class taskModel extends model if($oldTask->parent > 0) $this->updateParentStatus($taskID); + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->assignto['id'], $this->post->uid); $this->dao->update(TABLE_TASK) ->data($task) ->autoCheck() @@ -1525,6 +1527,8 @@ class taskModel extends model } if(dao::isError()) return false; + $editorIdList = $this->config->task->editor->start['id']; + if($this->app->getMethodName() == 'restart') $editorIdList = $this->config->task->editor->restart['id']; $now = helper::now(); $task = fixer::input('post') ->add('id', $taskID) @@ -1532,9 +1536,11 @@ class taskModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('status', 'doing') ->setIF($oldTask->assignedTo != $this->app->user->account, 'assignedDate', $now) + ->stripTags($editorIdList, $this->config->allowedTags) ->removeIF(!empty($oldTask->team), 'consumed,left') ->remove('comment')->get(); + $task = $this->loadModel('file')->processImgURL($task, $editorIdList, $this->post->uid); if($this->post->left == 0) { if(isset($task->consumed) and $task->consumed == 0) @@ -1763,6 +1769,7 @@ class taskModel extends model ->setDefault('status', 'done') ->setDefault('finishedBy, lastEditedBy', $this->app->user->account) ->setDefault('finishedDate, lastEditedDate', $now) + ->stripTags($this->config->task->editor->finish['id'], $this->config->allowedTags) ->removeIF(!empty($oldTask->team), 'finishedBy,status,left') ->remove('comment,files,labels,currentConsumed') ->get(); @@ -1857,6 +1864,7 @@ class taskModel extends model if($task->finishedDate == substr($now, 0, 10)) $task->finishedDate = $now; + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->finish['id'], $this->post->uid); $this->dao->update(TABLE_TASK)->data($task) ->autoCheck() ->checkFlow() @@ -1896,9 +1904,11 @@ class taskModel extends model ->setDefault('status', 'pause') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) + ->stripTags($this->config->task->editor->pause['id'], $this->config->allowedTags) ->remove('comment') ->get(); + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->pause['id'], $this->post->uid); $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq((int)$taskID)->exec(); if($oldTask->parent > 0) $this->updateParentStatus($taskID); @@ -1932,12 +1942,14 @@ class taskModel extends model ->setDefault('assignedDate', $now) ->setDefault('closedBy, lastEditedBy', $this->app->user->account) ->setDefault('closedDate, lastEditedDate', $now) + ->stripTags($this->config->task->editor->close['id'], $this->config->allowedTags) ->setIF($oldTask->status == 'done', 'closedReason', 'done') ->setIF($oldTask->status == 'cancel', 'closedReason', 'cancel') ->remove('_recPerPage') ->remove('comment') ->get(); + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->close['id'], $this->post->uid); $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq((int)$taskID)->exec(); if(!dao::isError()) @@ -1980,9 +1992,11 @@ class taskModel extends model ->setDefault('finishedDate', '0000-00-00') ->setDefault('canceledBy, lastEditedBy', $this->app->user->account) ->setDefault('canceledDate, lastEditedDate', $now) + ->stripTags($this->config->task->editor->cancel['id'], $this->config->allowedTags) ->remove('comment') ->get(); + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->cancel['id'], $this->post->uid); $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq((int)$taskID)->exec(); if($oldTask->fromBug) $this->dao->update(TABLE_BUG)->set('toTask')->eq(0)->where('id')->eq($oldTask->fromBug)->exec(); if($oldTask->parent > 0) $this->updateParentStatus($taskID); @@ -2044,6 +2058,7 @@ class taskModel extends model ->setDefault('lastEditedDate', helper::now()) ->setDefault('assignedDate', helper::now()) ->setDefault('activatedDate', helper::now()) + ->stripTags($this->config->task->editor->activate['id'], $this->config->allowedTags) ->remove('comment') ->get(); @@ -2064,6 +2079,7 @@ class taskModel extends model $task = $this->computeHours4Multiple($oldTask, $task); } + $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->activate['id'], $this->post->uid); $this->dao->update(TABLE_TASK)->data($task) ->autoCheck() ->batchCheck($this->config->task->activate->requiredFields, 'notempty') diff --git a/module/testcase/model.php b/module/testcase/model.php index e66df373fa..44d49ed6f8 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -61,6 +61,7 @@ class testcaseModel extends model ->setIF($this->config->systemMode == 'new' and $this->app->tab == 'project', 'project', $this->session->project) ->setIF($this->app->tab == 'execution', 'execution', $this->session->execution) ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion((int)$this->post->story)) + ->stripTags($this->config->testcase->editor->create['id'], $this->config->allowedTags) ->remove('steps,expects,files,labels,stepType,forceNotReview') ->setDefault('story', 0) ->cleanInt('story,product,branch,module') @@ -77,6 +78,7 @@ class testcaseModel extends model /* Value of story may be showmore. */ $case->story = (int)$case->story; + $case = $this->loadModel('file')->processImgURL($case, $this->config->testcase->editor->create['id'], $this->post->uid); $this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->checkFlow()->exec(); if(!$this->dao->isError()) { @@ -768,6 +770,7 @@ class testcaseModel extends model ->join('linkCase', ',') ->setForce('status', $status) ->cleanInt('story,product,branch,module') + ->stripTags($this->config->testcase->editor->edit['id'], $this->config->allowedTags) ->remove('comment,steps,expects,files,labels,stepType') ->get(); @@ -780,6 +783,7 @@ class testcaseModel extends model array_splice($requiredFieldsArr, $fieldIndex, 1); $requiredFields = implode(',', $requiredFieldsArr); } + $case = $this->loadModel('file')->processImgURL($case, $this->config->testcase->editor->edit['id'], $this->post->uid); $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($requiredFields, 'notempty')->checkFlow()->where('id')->eq((int)$caseID)->exec(); if(!$this->dao->isError()) { @@ -883,10 +887,12 @@ class testcaseModel extends model ->setDefault('reviewedDate', substr($now, 0, 10)) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->stripTags($this->config->testcase->editor->review['id'], $this->config->allowedTags) ->setForce('status', $status) ->join('reviewedBy', ',') ->get(); + $case = $this->loadModel('file')->processImgURL($case, $this->config->testcase->editor->review['id'], $this->post->uid); $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->checkFlow()->where('id')->eq($caseID)->exec(); if(dao::isError()) return false; @@ -1268,11 +1274,26 @@ class testcaseModel extends model ->fetchGroup('case'); $oldCases = $this->dao->select('*')->from(TABLE_CASE)->where('id')->in($_POST['id'])->fetchAll('id'); } + + $cases = array(); + $line = 1; + $fieldNames = array(); $storyVersionPairs = $this->story->getVersions($data->story); - $cases = array(); - $line = 1; - $fieldNames = array(); + if($this->config->edition != 'open') + { + $extendFields = $this->getFlowExtendFields(); + $notEmptyRule = $this->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty'); + + foreach($extendFields as $extendField) + { + if(strpos(",$extendField->rules,", ",$notEmptyRule->id,") !== false) + { + $this->config->testcase->create->requiredFields .= ',' . $extendField->field; + } + } + } + foreach($data->product as $key => $product) { $caseData = new stdclass(); @@ -1289,6 +1310,18 @@ class testcaseModel extends model $caseData->frequency = 1; $caseData->precondition = $data->precondition[$key]; + if($this->config->edition != 'open') + { + foreach($extendFields as $extendField) + { + $dataArray = $_POST[$extendField->field]; + $caseData->{$extendField->field} = $dataArray[$key]; + if(is_array($caseData->{$extendField->field})) $caseData->{$extendField->field} = join(',', $caseData->{$extendField->field}); + + $caseData->{$extendField->field} = htmlSpecialString($caseData->{$extendField->field}); + } + } + if(isset($this->config->testcase->create->requiredFields)) { $requiredFields = explode(',', $this->config->testcase->create->requiredFields); @@ -1300,16 +1333,6 @@ class testcaseModel extends model } } - if(isset($this->config->testcase->appendFields)) - { - foreach(explode(',', $this->config->testcase->appendFields) as $appendField) - { - if(empty($appendField)) continue; - $caseData->$appendField = zget($_POST[$appendField], $key, ''); - if(is_array($caseData->$appendField)) $caseData->$appendField = join(',', $caseData->$appendField); - } - } - $cases[$key] = $caseData; $line++; } @@ -1382,34 +1405,38 @@ class testcaseModel extends model $caseData->lastEditedBy = $this->app->user->account; $caseData->lastEditedDate = $now; if($stepChanged and !$forceNotReview) $caseData->status = 'wait'; - $this->dao->update(TABLE_CASE)->data($caseData)->where('id')->eq($caseID)->autoCheck()->exec(); - if($stepChanged) + $this->dao->update(TABLE_CASE)->data($caseData)->where('id')->eq($caseID)->autoCheck()->checkFlow()->exec(); + + if(!dao::isError()) { - $parentStepID = 0; - foreach($steps as $id => $step) + if($stepChanged) { - $step = (array)$step; - if(empty($step['desc'])) continue; - $stepData = new stdclass(); - $stepData->type = ($step['type'] == 'item' and $parentStepID == 0) ? 'step' : $step['type']; - $stepData->parent = ($stepData->type == 'item') ? $parentStepID : 0; - $stepData->case = $caseID; - $stepData->version = $version; - $stepData->desc = $step['desc']; - $stepData->expect = $step['expect']; - $this->dao->insert(TABLE_CASESTEP)->data($stepData)->autoCheck()->exec(); - if($stepData->type == 'group') $parentStepID = $this->dao->lastInsertID(); - if($stepData->type == 'step') $parentStepID = 0; + $parentStepID = 0; + foreach($steps as $id => $step) + { + $step = (array)$step; + if(empty($step['desc'])) continue; + $stepData = new stdclass(); + $stepData->type = ($step['type'] == 'item' and $parentStepID == 0) ? 'step' : $step['type']; + $stepData->parent = ($stepData->type == 'item') ? $parentStepID : 0; + $stepData->case = $caseID; + $stepData->version = $version; + $stepData->desc = $step['desc']; + $stepData->expect = $step['expect']; + $this->dao->insert(TABLE_CASESTEP)->data($stepData)->autoCheck()->exec(); + if($stepData->type == 'group') $parentStepID = $this->dao->lastInsertID(); + if($stepData->type == 'step') $parentStepID = 0; + } } + $oldCase->steps = $this->joinStep($oldStep); + $caseData->steps = $this->joinStep($steps); + $changes = common::createChanges($oldCase, $caseData); + + $this->updateCase2Project($oldCase, $caseData, $caseID); + + $actionID = $this->action->create('case', $caseID, 'Edited'); + $this->action->logHistory($actionID, $changes); } - $oldCase->steps = $this->joinStep($oldStep); - $caseData->steps = $this->joinStep($steps); - $changes = common::createChanges($oldCase, $caseData); - - $this->updateCase2Project($oldCase, $caseData, $caseID); - - $actionID = $this->action->create('case', $caseID, 'Edited'); - $this->action->logHistory($actionID, $changes); } } else @@ -1421,7 +1448,7 @@ class testcaseModel extends model $caseData->branch = isset($data->branch[$key]) ? $data->branch[$key] : $branch; if($caseData->story) $caseData->storyVersion = zget($storyVersionPairs, $caseData->story, 1); $caseData->status = !$forceNotReview ? 'wait' : 'normal'; - $this->dao->insert(TABLE_CASE)->data($caseData)->autoCheck()->exec(); + $this->dao->insert(TABLE_CASE)->data($caseData)->autoCheck()->checkFlow()->exec(); if(!dao::isError()) { @@ -2123,7 +2150,13 @@ class testcaseModel extends model if(!$case->needconfirm) { - if(!isonlybody()) $menu .= $this->buildMenu('testcase', 'edit', $params, $case, 'view', '', '', 'showinonlybody'); + if(!isonlybody()) + { + $editParams = $params; + if($this->app->tab == 'project') $editParams .= "&comment=false&projectID={$this->session->project}"; + if($this->app->tab == 'execution') $editParams .= "&comment=false&executionID={$this->session->execution}"; + $menu .= $this->buildMenu('testcase', 'edit', $editParams, $case, 'view', '', '', 'showinonlybody'); + } if(!$case->isLibCase && $case->auto != 'unit') { $menu .= $this->buildMenu('testcase', 'create', "productID=$case->product&branch=$case->branch&moduleID=$case->module&from=testcase¶m=$case->id", $case, 'view', 'copy'); @@ -2161,7 +2194,12 @@ class testcaseModel extends model $menu .= $this->buildMenu('testtask', 'results', "runID=0&$params", $case, 'browse', '', '', 'iframe', true, "data-width='95%'"); $menu .= $this->buildMenu('testtask', 'runCase', "runID=0&$params&version=$case->version", $case, 'browse', 'play', '', 'runCase iframe', false, "data-width='95%'"); - $menu .= $this->buildMenu('testcase', 'edit', "caseID=$case->id", $case, 'browse'); + + $editParams = $params; + if($this->app->tab == 'project') $editParams .= "&comment=false&projectID={$this->session->project}"; + if($this->app->tab == 'execution') $editParams .= "&comment=false&executionID={$this->session->execution}"; + $menu .= $this->buildMenu('testcase', 'edit', $editParams, $case, 'browse'); + if($this->config->testcase->needReview || !empty($this->config->testcase->forceReview)) { common::printIcon('testcase', 'review', $params, $case, 'browse', 'glasses', '', 'iframe'); diff --git a/module/testcase/view/showimport.html.php b/module/testcase/view/showimport.html.php index 0a66864f54..44d00ea281 100644 --- a/module/testcase/view/showimport.html.php +++ b/module/testcase/view/showimport.html.php @@ -45,11 +45,19 @@ $(function()
| testcase->stageList, !empty($case->stage) ? $case->stage : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->stage : ''), "multiple='multiple' class='form-control chosen'")?> | precondition) ? htmlSpecialString($case->precondition) : "", "class='form-control'")?> | keywords) ? $case->keywords : '', "class='form-control'")?> | - - loadModel('flow');?> - -flow->buildControl($appendField, zget($case, $appendField->field, ''), "{$appendField->field}[$key]");?> | - - + loadModel('flow'); + foreach($appendFields as $field) + { + if(!$field->show) continue; + $value = $field->defaultValue ? $field->defaultValue : zget($case, $field->field, ''); + echo '' . $this->flow->buildControl($field, $value, "$field->field[$key]", true) . ' | '; + } + } + ?>
|