diff --git a/module/bug/control.php b/module/bug/control.php index 5828b04e5c..6b48550e2e 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -878,6 +878,110 @@ class bug extends control $this->display(); } + /** + * Link related bugs. + * + * @param int $bugID + * @param string $bugs + * @param string $browseType + * @param int $param + * @access public + * @return void + */ + public function linkBugs($bugID, $bugs = '', $browseType = '', $param = 0) + { + /* Link bugs. */ + if(!empty($_POST)) + { + $bugs = $this->bug->linkBugs($bugID, $bugs); + if(isonlybody()) die(js::closeModal('parent.parent', '', "function(){parent.parent.loadLinkedBugs('$bugID', '$bugs')}")); + die(js::locate($this->createLink('bug', 'edit', "bugID=$bugID"), 'parent')); + } + + /* Get bug, productID and queryID. */ + $bug = $this->bug->getById($bugID); + $productID = $this->product->saveState($bug->product, $this->products); + $queryID = ($browseType == 'bysearch') ? (int)$param : 0; + + /* Set the menu. */ + $this->bug->setMenu($this->products, $productID, $bug->branch); + + /* Build the search form. */ + $actionURL = $this->createLink('bug', 'linkBugs', "bugID=$bugID&bugs=$bugs&browseType=bySearch&queryID=myQueryID", '', true); + $this->bug->buildSearchForm($productID, $this->products, $queryID, $actionURL); + $this->loadModel('search')->setSearchParams($this->config->bug->search); + + /* Get bugs to link. */ + $allBugs = array(); + if($browseType == 'bySearch') $allBugs = $this->bug->getBySearch($bug->product, $quueryID, 'id', null); + + /* Assign. */ + $this->view->title = $this->lang->bug->linkBugs . "BUG #$bug->id $bug->title - " . $this->products[$productID]; + $this->view->position[] = html::a($this->createLink('product', 'view', "productID=$productID"), $this->products[$productID]); + $this->view->position[] = html::a($this->createLink('bug', 'view', "bugID=$bugID"), $bug->title); + $this->view->position[] = $this->lang->bug->linkBugs; + $this->view->bug = $bug; + $this->view->allBugs = $allBugs; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + + $this->display(); + } + + /** + * AJAX: get linked bugs. + * + * @param int $bugID + * @param string $linkedBugs + * @access public + * @return string + */ + public function ajaxGetLinkedBugs($bugID, $linkedBugs = '') + { + /* Get bug and linked bugs. */ + $bug = $this->bug->getById($bugID); + $bugs = $this->bug->getLinkedBugs($linkedBugs); + + /* Build linkBug list.*/ + $output = "