* Remove duplicated loadModel for gitlab related after CR.

This commit is contained in:
dingguodong
2021-07-15 13:53:04 +08:00
parent 4c58d0bbe4
commit bb7f7cf142
8 changed files with 130 additions and 90 deletions
+14 -8
View File
@@ -558,9 +558,13 @@ class bug extends control
$this->view->showFields = $this->config->bug->custom->createFields;
/* Set gitlabProjects. */
$allGitlabs = $this->loadModel('gitlab')->getPairs();
$gitlabProjects = $this->loadModel('gitlab')->getProjectsByExecution($executionID);
foreach($allGitlabs as $id => $name) if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
$this->loadModel('gitlab');
$allGitlabs = $this->gitlab->getPairs();
$gitlabProjects = $this->gitlab->getProjectsByExecution($executionID);
foreach($allGitlabs as $id => $name)
{
if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
}
$this->view->gitlabList = $allGitlabs;
$this->view->gitlabProjects = $gitlabProjects;
@@ -1462,13 +1466,14 @@ class bug extends control
$_POST = array();
$bugs = $this->bug->getByList($bugIDList);
$this->loadModel('gitlab');
foreach($bugs as $bugID => $bug)
{
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug);
}
if($bug->status != 'resolved')
@@ -1555,8 +1560,9 @@ class bug extends control
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue('bug', $bugID, $relation->issueID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if(!empty($relation)) $this->gitlab->deleteIssue('bug', $bugID, $relation->issueID);
$this->bug->delete(TABLE_BUG, $bugID);
if($bug->toTask != 0)
+33 -24
View File
@@ -282,14 +282,14 @@ class bugModel extends model
* @param object $bug
* @param int $executionID
* @access public
* @return int
* @return int|bool
*/
public function createBugFromGitlabIssue($bug, $executionID)
{
$bug->openedBy = $this->app->user->account;
$bug->openedDate = helper::now(); // TODO(dingguodong) use from issue->created_at ?
$bug->assignedDate = isset($bug->assignedTo) ? helper::now() : 0;
$bug->openedBuild = 1;
$bug->openedBuild = 'trunk';
$bug->story = 0;
$bug->task = 0;
$bug->pri = 3;
@@ -368,7 +368,7 @@ class bugModel extends model
*/
public function checkDelayBug($bug)
{
// Delayed or not?.
/* Delayed or not? */
if(!helper::isZeroDate($bug->deadline))
{
if($bug->resolvedDate and !helper::isZeroDate($bug->resolvedDate))
@@ -677,8 +677,9 @@ class bugModel extends model
if(!empty($bug))
{
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
}
return common::createChanges($oldBug, $bug);
}
@@ -803,8 +804,9 @@ class bugModel extends model
$allChanges[$bugID] = common::createChanges($oldBug, $bug);
/* update bug to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
}
else
{
@@ -857,12 +859,13 @@ class bugModel extends model
}
/* Update bugs. */
$this->loadModel('gitlab');
foreach($activateBugs as $bugID => $bug)
{
if(!empty($bug))
{
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', (Object)$bug, $bugID);
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', (Object)$bug, $bugID);
}
$oldBug = $bugs[$bugID];
@@ -899,13 +902,14 @@ class bugModel extends model
->autoCheck()
->where('id')->eq($bugID)->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
$bug = $this->getById($bugID); // get full bug object to update issue.
$bug->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $bug->assignedTo);
$bug->assignee_id = $this->gitlab->getGitlabUserID($relation->gitlabID, $bug->assignedTo);
if($bug->assignee_id != '')
{
// TODO(dingguodong) we should alert to operator when can not find the user, and the operator should reconfigure user binding.
$this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
/* TODO(dingguodong) we should alert to operator when can not find the user, and the operator should reconfigure user binding. */
$this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
}
if(!dao::isError()) return common::createChanges($oldBug, $bug);
@@ -952,6 +956,7 @@ class bugModel extends model
{
$now = helper::now();
$bugs = $this->getByList($bugIDList);
$this->loadModel('gitlab');
foreach($bugIDList as $bugID)
{
if($bugs[$bugID]->confirmed) continue;
@@ -964,8 +969,8 @@ class bugModel extends model
if(!empty($bug))
{
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
}
$this->dao->update(TABLE_BUG)->data($bug)->where('id')->eq($bugID)->exec();
@@ -1059,8 +1064,9 @@ class bugModel extends model
/* Link bug to build and release. */
$this->linkBugToBuild($bugID, $bug->resolvedBuild);
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
return common::createChanges($oldBug, $bug);
}
@@ -1192,8 +1198,9 @@ class bugModel extends model
$this->executeHooks($bugID);
/* batch resolve issure bugs.*/
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$changes[$bugID] = common::createChanges($oldBug, $bug);
}
@@ -1254,8 +1261,9 @@ class bugModel extends model
if(!empty($bug))
{
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
}
$bug->activatedCount += 1;
@@ -1287,11 +1295,12 @@ class bugModel extends model
$this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('bug', $bugID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('bug', $bugID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $bug, $bugID);
}
return common::createChanges($oldBug, $bug);
}
+3 -2
View File
@@ -2514,8 +2514,9 @@ class execution extends control
foreach($storyIdList as $storyID)
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue('story', $storyID, $relation->issueID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->deleteIssue('story', $storyID, $relation->issueID);
$this->execution->unlinkStory($executionID, $storyID);
}
+6 -4
View File
@@ -230,12 +230,13 @@ class repoModel extends model
if(!dao::isError()) $this->rmClientVersionFile();
$this->loadModel('gitlab');
if($this->post->SCM == 'Gitlab')
{
$this->loadModel("gitlab")->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
$this->gitlab->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
/* create webhook for zentao */
$this->loadModel("gitlab")->initWebhooks($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
$this->gitlab->initWebhooks($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
}
return $this->dao->lastInsertID();
}
@@ -293,12 +294,13 @@ class repoModel extends model
$this->rmClientVersionFile();
if($repo->SCM == 'Gitlab') $this->loadModel("gitlab")->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
$this->loadModel('gitlab');
if($repo->SCM == 'Gitlab') $this->gitlab->saveProjectRelation($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
if($repo->path != $data->path)
{
$this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($id)->exec();
$this->dao->delete()->from(TABLE_REPOFILES)->where('repo')->eq($id)->exec();
if($repo->SCM == 'Gitlab') $this->loadModel("gitlab")->initWebhooks($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
if($repo->SCM == 'Gitlab') $this->gitlab->initWebhooks($this->post->product, $this->post->gitlabHost, $this->post->gitlabProject);
return false;
}
+6 -4
View File
@@ -295,9 +295,10 @@ class story extends control
$this->view->customFields = $customFields;
$this->view->showFields = $this->config->story->custom->createFields;
$allGitlabs = $this->loadModel('gitlab')->getPairs();
$this->loadModel('gitlab');
$allGitlabs = $this->gitlab->getPairs();
$executionID = $objectID;
$gitlabProjects = $this->loadModel('gitlab')->getProjectsByExecution($executionID);
$gitlabProjects = $this->gitlab->getProjectsByExecution($executionID);
foreach($allGitlabs as $id => $name) if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
$this->view->gitlabList = $allGitlabs;
$this->view->gitlabProjects = $gitlabProjects;
@@ -991,8 +992,9 @@ class story extends control
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue('story', $storyID, $relation->issueID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->deleteIssue('story', $storyID, $relation->issueID);
$this->story->delete(TABLE_STORY, $storyID);
if($story->parent > 0)
+31 -22
View File
@@ -700,8 +700,9 @@ class storyModel extends model
$this->file->updateObjectID($this->post->uid, $storyID, 'story');
/* update story to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
return common::createChanges($oldStory, $story);
}
@@ -883,8 +884,9 @@ class storyModel extends model
}
/* update story to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if($relation) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
unset($oldStory->parent);
unset($story->parent);
@@ -1217,8 +1219,9 @@ class storyModel extends model
if($oldStory->plan != $story->plan) $this->updateStoryOrderOfPlan($storyID, $story->plan, $oldStory->plan);
/* update story to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->executeHooks($storyID);
if($story->type == 'story') $this->batchChangeStage(array($storyID), $story->stage);
@@ -1485,12 +1488,13 @@ class storyModel extends model
->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty')
->where('id')->eq($storyID)->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
}
/* Update parent story status. */
@@ -1560,11 +1564,12 @@ class storyModel extends model
$this->setStage($storyID);
$allChanges[$storyID] = common::createChanges($oldStory, $story);
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
}
}
else
@@ -1843,9 +1848,10 @@ class storyModel extends model
if(!dao::isError())
{
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
$story->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
$story->assignee_id = $this->gitlab->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($story->assignee_id != '') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
return common::createChanges($oldStory, $story);
}
return false;
@@ -1878,13 +1884,15 @@ class storyModel extends model
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
if(!dao::isError())
{
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
$story->assignee_id = $this->loadModel('gitlab')->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($story->assignee_id != '') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
$story->assignee_id = $this->gitlab->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($story->assignee_id != '') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
/* Push this story to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
}
}
return $allChanges;
@@ -1921,8 +1929,9 @@ class storyModel extends model
if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent);
/* Push this story to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
return common::createChanges($oldStory, $story);
}
+8 -5
View File
@@ -217,8 +217,9 @@ class task extends control
foreach(explode(',', $this->config->task->customCreateFields) as $field) $customFields[$field] = $this->lang->task->$field;
if($execution->type == 'ops') unset($customFields['story']);
$allGitlabs = $this->loadModel('gitlab')->getPairs();
$gitlabProjects = $this->loadModel('gitlab')->getProjectsByExecution($executionID);
$this->loadModel('gitlab');
$allGitlabs = $this->gitlab->getPairs();
$gitlabProjects = $this->gitlab->getProjectsByExecution($executionID);
foreach($allGitlabs as $id => $name) if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
$this->view->gitlabList = $allGitlabs;
$this->view->gitlabProjects = $gitlabProjects;
@@ -577,7 +578,8 @@ class task extends control
$task = $this->task->getByID($taskID);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if($relation)$this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$members = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted');
@@ -1298,8 +1300,9 @@ class task extends control
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue('task', $taskID, $relation->issueID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->gitlab->deleteIssue('task', $taskID, $relation->issueID);
$this->task->delete(TABLE_TASK, $taskID);
if($task->parent > 0)
+29 -21
View File
@@ -982,8 +982,9 @@ class taskModel extends model
->where('id')->eq((int)$taskID)->exec();
/* update task to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
if(!dao::isError())
{
@@ -1218,12 +1219,13 @@ class taskModel extends model
$tasks[$taskID] = $task;
}
$issues = $this->loadModel('gitlab')->getIssueListByObjects('task', $taskID);
$this->loadModel('gitlab');
$issues = $this->gitlab->getIssueListByObjects('task', $taskID);
foreach($tasks as $taskID => $task)
{
$issue = zget($issues, $taskID, 0);
if(!$issue) continue;
$this->loadModel('gitlab')->apiUpdateIssue($issue->gitlabID, $issue->projectID, $issue->issueID, $task);
$this->gitlab->apiUpdateIssue($issue->gitlabID, $issue->projectID, $issue->issueID, $task);
}
/* Check field not empty. */
@@ -1297,8 +1299,9 @@ class taskModel extends model
$allChanges[$taskID] = common::createChanges($oldTask, $task);
/* update task to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
}
else
{
@@ -1386,8 +1389,9 @@ class taskModel extends model
->where('id')->eq($taskID)->exec();
$task = $this->getById($taskID);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
if(!dao::isError()) return common::createChanges($oldTask, $task);
}
@@ -1432,7 +1436,7 @@ class taskModel extends model
$task->status = 'done';
$task->finishedBy = $this->app->user->account;
$task->finishedDate = helper::now();
$task->assignedTo = $oldTask->openedBy; // Fix bug#1341
$task->assignedTo = $oldTask->openedBy;
}
/* Record consumed and left. */
@@ -1724,11 +1728,12 @@ class taskModel extends model
->where('id')->eq((int)$taskID)
->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
}
if($oldTask->parent > 0) $this->updateParentStatus($taskID);
@@ -1787,11 +1792,12 @@ class taskModel extends model
$this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $task, $taskID);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $task, $taskID);
}
if(!dao::isError())
@@ -1837,12 +1843,13 @@ class taskModel extends model
$this->dao->update(TABLE_TASK)->set('assignedTo=openedBy')->where('parent')->eq((int)$taskID)->exec();
}
if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
}
if(!dao::isError()) return common::createChanges($oldTask, $task);
@@ -1910,8 +1917,9 @@ class taskModel extends model
}
if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
if(!dao::isError()) return common::createChanges($oldTask, $task);
}