Merge branch 'sprint214_leiyong_task_60384' into 'master'

Sprint214 leiyong task 60384

See merge request easycorp/zentaopms!4495
This commit is contained in:
王怡栋
2022-07-13 02:25:36 +00:00
6 changed files with 76 additions and 13 deletions
+1 -1
View File
@@ -3963,8 +3963,8 @@ class execution extends control
$projectID = $this->dao->findByID($executionID)->from(TABLE_EXECUTION)->fetch('project');
$planStories = array_keys($planStory);
$this->execution->linkStory($executionID, $planStories, $planProducts, $extra);
if($this->config->systemMode == 'new' and $executionID != $projectID) $this->execution->linkStory($projectID, $planStories, $planProducts);
$this->execution->linkStory($executionID, $planStories, $planProducts, $extra);
}
$moduleName = 'execution';
+9 -1
View File
@@ -280,9 +280,14 @@ class file extends control
$file = $this->file->getById($fileID);
$this->dao->delete()->from(TABLE_FILE)->where('id')->eq($fileID)->exec();
$this->loadModel('action')->create($file->objectType, $file->objectID, 'deletedFile', '', $extra=$file->title);
/* Fix Bug #1518. */
$fileRecord = $this->dao->select('id')->from(TABLE_FILE)->where('pathname')->eq($file->pathname)->fetch();
if(empty($fileRecord)) @unlink($file->realPath);
/* Update test case version for test case synchronization. */
if($file->objectType == 'testcase') $this->file->updateTestcaseVersion($file);
return print(js::reload('parent'));
}
}
@@ -331,9 +336,12 @@ class file extends control
$extension = "." . $file->extension;
$actionID = $this->loadModel('action')->create($file->objectType, $file->objectID, 'editfile', '', $fileName);
$changes[] = array('field' => 'fileName', 'old' => $file->title . $extension, 'new' => $fileName);
$changes[] = array('field' => 'fileName', 'old' => $file->title, 'new' => $fileName);
$this->action->logHistory($actionID, $changes);
/* Update test case version for test case synchronization. */
if($file->objectType == 'testcase' and $file->title != $fileName) $this->file->updateTestcaseVersion($file);
return print(js::reload('parent.parent'));
}
+19
View File
@@ -1046,4 +1046,23 @@ class fileModel extends model
->andWhere('deleted')->eq('0')
->fetchPairs();
}
/**
* Update test case version.
*
* @param object $file
* @access public
* @return void
*/
public function updateTestcaseVersion($file)
{
$oldCase = $this->loadModel('testcase')->getByID($file->objectID);
$isLibCase = ($oldCase->lib and empty($oldCase->product));
if($isLibCase)
{
$fromcaseVersion = $this->dao->select('fromCaseVersion')->from(TABLE_CASE)->where('fromCaseID')->eq($file->objectID)->fetch('fromCaseVersion');
$fromcaseVersion += 1;
$this->dao->update(TABLE_CASE)->set('`fromCaseVersion`')->eq($fromcaseVersion)->where('`fromCaseID`')->eq($file->objectID)->exec();
}
}
}
+5 -3
View File
@@ -162,12 +162,14 @@ class story extends control
$object = $this->dao->findById((int)$objectID)->from(TABLE_PROJECT)->fetch();
if($object->type != 'project')
{
if($this->config->systemMode == 'new') $this->action->create('story', $storyID, 'linked2project', '', $object->project);
$actionType = $object->type == 'kanban' ? 'linked2kanban' : 'linked2execution';
$this->loadModel('action')->create('story', $storyID, $actionType, '', $objectID);
$this->action->create('story', $storyID, $actionType, '', $objectID);
}
else
{
$this->loadModel('action')->create('story', $storyID, 'linked2project', '', $objectID);
$this->action->create('story', $storyID, 'linked2project', '', $objectID);
}
}
@@ -499,8 +501,8 @@ class story extends control
{
$products = array();
foreach($mails as $story) $products[$story->storyID] = $productID;
$this->execution->linkStory($executionID, $stories, $products, $extra, $lanes);
if($executionID != $this->session->project) $this->execution->linkStory($this->session->project, $stories, $products);
$this->execution->linkStory($executionID, $stories, $products, $extra, $lanes);
}
/* If storyID not equal zero, subdivide this story to child stories and close it. */
+24
View File
@@ -1403,10 +1403,33 @@ class testcase extends control
$case = $this->testcase->getById($caseID);
$libCase = $this->testcase->getById($libcaseID);
$version = $case->version + 1;
$this->dao->delete()->from(TABLE_FILE)->where('objectType')->eq('testcase')->andWhere('objectID')->eq($caseID)->exec();
foreach($libCase->files as $fileID => $file)
{
$fileName = pathinfo($file->pathname, PATHINFO_FILENAME);
$datePath = substr($file->pathname, 0, 6);
$realPath = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . "{$datePath}/" . $fileName;
$rand = rand();
$newFileName = $fileName . 'copy' . $rand;
$newFilePath = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . "{$datePath}/" . $newFileName;
copy($realPath, $newFilePath);
$newFileName = $file->pathname;
$newFileName = str_replace('.', "copy$rand.", $newFileName);
unset($file->id, $file->realPath, $file->webPath);
$file->objectID = $caseID;
$file->pathname = $newFileName;
$this->dao->insert(TABLE_FILE)->data($file)->exec();
}
$this->dao->update(TABLE_CASE)
->set('version')->eq($version)
->set('fromCaseVersion')->eq($version)
->set('precondition')->eq($libCase->precondition)
->set('title')->eq($libCase->title)
->where('id')->eq($caseID)
->exec();
@@ -1417,6 +1440,7 @@ class testcase extends control
$step->version = $version;
$this->dao->insert(TABLE_CASESTEP)->data($step)->exec();
}
echo js::locate($this->createLink('testcase', 'view', "caseID=$caseID&version=$version"), 'parent');
}
+18 -8
View File
@@ -799,15 +799,12 @@ class testcaseModel extends model
$this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($requiredFields, 'notempty')->checkFlow()->where('id')->eq((int)$caseID)->exec();
if(!$this->dao->isError())
{
$isLibCase = ($oldCase->lib and empty($oldCase->product));
$titleChanged = ($case->title != $oldCase->title);
if($isLibCase and $titleChanged) $this->dao->update(TABLE_CASE)->set('`title`')->eq($case->title)->where('`fromCaseID`')->eq($caseID)->exec();
$this->updateCase2Project($oldCase, $case, $caseID);
if($stepChanged)
{
$parentStepID = 0;
$isLibCase = ($oldCase->lib and empty($oldCase->product));
if($isLibCase)
{
$fromcaseVersion = $this->dao->select('fromCaseVersion')->from(TABLE_CASE)->where('fromCaseID')->eq($caseID)->fetch('fromCaseVersion');
@@ -1103,6 +1100,11 @@ class testcaseModel extends model
foreach($cases as $caseID => $case)
{
$oldCase = $this->getByID($caseID);
$caseChanged = false;
if($oldCase->title != $case->title) $caseChanged = true;
if($oldCase->precondition != $case->precondition) $caseChanged = true;
$this->dao->update(TABLE_CASE)->data($case)
->autoCheck()
->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')
@@ -1112,11 +1114,7 @@ class testcaseModel extends model
if(!dao::isError())
{
$isLibCase = ($oldCase->lib and empty($oldCase->product));
$titleChanged = ($case->title != $oldCase->title);
$case->product = $oldCase->product;
if($isLibCase and $titleChanged) $this->dao->update(TABLE_CASE)->set('`title`')->eq($case->title)->where('`fromCaseID`')->eq($caseID)->exec();
$this->updateCase2Project($oldCase, $case, $caseID);
$this->executeHooks($caseID);
@@ -1138,6 +1136,14 @@ class testcaseModel extends model
}
}
}
$isLibCase = ($oldCase->lib and empty($oldCase->product));
if($isLibCase and $caseChanged)
{
$fromcaseVersion = $this->dao->select('fromCaseVersion')->from(TABLE_CASE)->where('fromCaseID')->eq($caseID)->fetch('fromCaseVersion');
$fromcaseVersion += 1;
$this->dao->update(TABLE_CASE)->set('`fromCaseVersion`')->eq($fromcaseVersion)->where('`fromCaseID`')->eq($caseID)->exec();
}
}
else
{
@@ -2357,6 +2363,10 @@ class testcaseModel extends model
if(!$this->forceNotReview() and $stepChanged) $status = 'wait';
if(!empty($_POST['title']) and $case->title != $this->post->title) $stepChanged = true;
if(!empty($_post['precondition']) and $case->precondition != $this->post->precondition) $stepchanged = true;
if(!empty($_POST['labels'][0])) $stepChanged = true;
return array($stepChanged, $status);
}