/** * Add a related issue * * @param TBGIssue $related_issue * * @return boolean */ public function addChildIssue(TBGIssue $related_issue) { if (!($row = B2DB::getTable('TBGIssueRelationsTable')->getIssueRelation($this->getID(), $related_issue->getID()))) { $res = B2DB::getTable('TBGIssueRelationsTable')->addChildIssue($this->getID(), $related_issue->getID()); $this->_child_issues = null; $related_issue->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('%issuetype% %issue_no% now depends on the solution of this %this_issuetype%', array('%this_issuetype%' => $related_issue->getIssueType()->getName(), '%issuetype%' => $this->getIssueType()->getName(), '%issue_no%' => $this->getFormattedIssueNo()))); $related_issue->addSystemComment(TBGContext::getI18n()->__('Dependancy added'), TBGContext::getI18n()->__('%issuetype% %issue_no% now depends on the solution of this %this_issuetype%', array('%this_issuetype%' => $related_issue->getIssueType()->getName(), '%issuetype%' => $this->getIssueType()->getName(), '%issue_no%' => $this->getFormattedIssueNo())), TBGContext::getUser()->getID()); $this->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('This %this_issuetype% now depends on the solution of %issuetype% %issue_no%', array('%this_issuetype%' => $this->getIssueType()->getName(), '%issuetype%' => $related_issue->getIssueType()->getName(), '%issue_no%' => $related_issue->getFormattedIssueNo()))); $comment = $this->addSystemComment(TBGContext::getI18n()->__('Dependancy added'), TBGContext::getI18n()->__('This %this_issuetype% now depends on the solution of %issuetype% %issue_no%', array('%this_issuetype%' => $this->getIssueType()->getName(), '%issuetype%' => $related_issue->getIssueType()->getName(), '%issue_no%' => $related_issue->getFormattedIssueNo())), TBGContext::getUser()->getID()); return $comment instanceof TBGComment ? $comment : true; } return false; }
/** * Add a related issue * * @param TBGIssue $related_issue * * @return boolean */ public function addChildIssue(TBGIssue $related_issue) { if (!($row = TBGIssueRelationsTable::getTable()->getIssueRelation($this->getID(), $related_issue->getID()))) { $res = TBGIssueRelationsTable::getTable()->addChildIssue($this->getID(), $related_issue->getID()); $this->_child_issues = null; $related_issue->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('%issuetype %issue_no now depends on the solution of this %this_issuetype', array('%this_issuetype' => $related_issue->getIssueType()->getName(), '%issuetype' => $this->getIssueType()->getName(), '%issue_no' => $this->getFormattedIssueNo()))); $this->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('This %this_issuetype now depends on the solution of %issuetype %issue_no', array('%this_issuetype' => $this->getIssueType()->getName(), '%issuetype' => $related_issue->getIssueType()->getName(), '%issue_no' => $related_issue->getFormattedIssueNo()))); return true; } return false; }
/** * View an issue * * @param TBGRequest $request */ public function runViewIssue(TBGRequest $request) { //TBGEvent::listen('core', 'viewissue', array($this, 'listenViewIssuePostError')); TBGLogging::log('Loading issue'); if ($issue_no = TBGContext::getRequest()->getParameter('issue_no')) { $issue = TBGIssue::getIssueFromLink($issue_no); if ($issue instanceof TBGIssue) { if (!$this->selected_project instanceof TBGProject || $issue->getProjectID() != $this->selected_project->getID()) { $issue = null; } } else { TBGLogging::log("Issue no [{$issue_no}] not a valid issue no", 'main', TBGLogging::LEVEL_WARNING_RISK); } } TBGLogging::log('done (Loading issue)'); //$this->getResponse()->setPage('viewissue'); if ($issue instanceof TBGIssue && (!$issue->hasAccess() || $issue->isDeleted())) { $issue = null; } if ($issue instanceof TBGIssue) { if (!array_key_exists('viewissue_list', $_SESSION)) { $_SESSION['viewissue_list'] = array(); } $k = array_search($issue->getID(), $_SESSION['viewissue_list']); if ($k !== false) { unset($_SESSION['viewissue_list'][$k]); } array_push($_SESSION['viewissue_list'], $issue->getID()); if (count($_SESSION['viewissue_list']) > 10) { array_shift($_SESSION['viewissue_list']); } TBGEvent::createNew('core', 'viewissue', $issue)->trigger(); } $message = TBGContext::getMessageAndClear('issue_saved'); $uploaded = TBGContext::getMessageAndClear('issue_file_uploaded'); if ($request->isMethod(TBGRequest::POST) && $issue instanceof TBGIssue && $request->hasParameter('issue_action')) { switch ($request->getParameter('issue_action')) { case 'save': if ($issue->hasUnsavedChanges()) { if (!$issue->hasMergeErrors()) { try { $issue->getWorkflowStep()->getWorkflow()->moveIssueToMatchingWorkflowStep($issue); $issue->save(); TBGContext::setMessage('issue_saved', true); $this->forward(TBGContext::getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo()))); } catch (TBGWorkflowException $e) { $this->error = $e->getMessage(); $this->workflow_error = true; } catch (Exception $e) { $this->error = $e->getMessage(); } } else { $this->issue_unsaved = true; } } else { $this->forward(TBGContext::getRouting()->generate('viewissue', array('project_key' => $issue->getProject()->getKey(), 'issue_no' => $issue->getFormattedIssueNo()))); } break; } } elseif ($message == true) { $this->issue_saved = true; } elseif ($uploaded == true) { $this->issue_file_uploaded = true; } elseif (TBGContext::hasMessage('issue_error')) { $this->error = TBGContext::getMessageAndClear('issue_error'); } elseif (TBGContext::hasMessage('issue_message')) { $this->issue_message = TBGContext::getMessageAndClear('issue_message'); } $issuelist = array(); $issues = TBGContext::getUser()->getStarredIssues(); if (count($issues)) { foreach ($issues as $starred_issue) { if (!$starred_issue instanceof TBGIssue || !$starred_issue->getProject() instanceof TBGProject || !$this->selected_project instanceof TBGProject) { continue; } if ($starred_issue->isOpen() && $starred_issue->getProject()->getID() == $this->selected_project->getID()) { $issuelist[$starred_issue->getID()] = array('url' => TBGContext::getRouting()->generate('viewissue', array('project_key' => $this->selected_project->getKey(), 'issue_no' => $starred_issue->getFormattedIssueNo())), 'title' => $starred_issue->getFormattedTitle(true, true)); } } } if (array_key_exists('viewissue_list', $_SESSION) && is_array($_SESSION['viewissue_list'])) { foreach ($_SESSION['viewissue_list'] as $k => $i_id) { try { $an_issue = new TBGIssue($i_id); array_unshift($issuelist, array('url' => TBGContext::getRouting()->generate('viewissue', array('project_key' => $an_issue->getProject()->getKey(), 'issue_no' => $an_issue->getFormattedIssueNo())), 'title' => $an_issue->getFormattedTitle(true, true))); } catch (Exception $e) { unset($_SESSION['viewissue_list'][$k]); } } } if (count($issuelist) == 1) { $issuelist = null; } $this->issuelist = $issuelist; $this->issue = $issue; $event = TBGEvent::createNew('core', 'viewissue', $issue)->trigger(); $this->listenViewIssuePostError($event); }