diff --git a/module/story/control.php b/module/story/control.php index ccc7e7beb0..af045d1167 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -908,69 +908,65 @@ class story extends control * * @param int $storyID * @param string $type - * @param string $stories * @param string $browseType * @param int $param * @access public * @return void */ - public function linkStory($storyID, $type = '', $stories = '', $browseType = '', $param = 0) + public function linkStory($storyID, $type = 'linkStories', $browseType = '', $param = 0) { $this->commonAction($storyID); - /* Link stories. */ - if(!empty($_POST)) - { - $stories = $this->story->linkStories($storyID, $type, $stories); - if(isonlybody()) die(js::closeModal('parent.parent', '', "function(){parent.parent.loadLinkedStories('$storyID', '$type', '$stories')}")); - die(js::locate($this->createLink('story', 'edit', "storyID=$storyID"), 'parent')); - } - /* Get story, product, products, and queryID. */ $story = $this->story->getById($storyID); $products = $this->product->getPairs(); $queryID = ($browseType == 'bySearch') ? (int)$param : 0; + /* Link stories. */ + if(!empty($_POST)) + { + $this->story->linkStories($storyID, $type); + if(isonlybody()) die(js::closeModal('parent.parent', '', "function(){parent.parent.loadLinkedStories('$storyID', '$type')}")); + die(js::locate($this->createLink('story', 'edit', "storyID=$storyID"), 'parent')); + } + /* Build search form. */ - $actionURL = $this->createLink('story', 'linkStory', "storyID=$storyID&type=$type&stories=$stories&browseType=bySearch&queryID=myQueryID", '', true); + $actionURL = $this->createLink('story', 'linkStory', "storyID=$storyID&type=$type&browseType=bySearch&queryID=myQueryID", '', true); $this->loadModel('product')->buildSearchForm($story->product, $products, $queryID, $actionURL); - $this->loadModel('search')->setSearchParams($this->config->product->search); /* Get stories to link. */ - $allStories = array(); - if($browseType == 'bySearch') $allStories = $this->story->getBySearch($story->product, $queryID, 'id', null); + $stories2Link = $this->story->getStories2Link($storyID, $type, $browseType, $queryID); /* Assign. */ - $this->view->title = $this->lang->story->linkStory . "STORY" . $this->lang->colon .$this->lang->story->linkStory; - $this->view->position[] = $this->lang->story->linkStory; - $this->view->type = $type; - $this->view->allStories = $allStories; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->actionURL = $this->config->product->search; + $this->view->title = $this->lang->story->linkStory . "STORY" . $this->lang->colon .$this->lang->story->linkStory; + $this->view->position[] = $this->lang->story->linkStory; + $this->view->type = $type; + $this->view->stories2Link = $stories2Link; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); } /** - * AJAX: If type is linkStories, get related stories else get child stories. + * AJAX: if type is linkStories, get related stories else get child stories. * * @param int $storyID * @param string $type - * @param string $linkedStories * @access public * @return string */ - public function ajaxGetLinkedStories($storyID, $type = '', $linkedStories = '') + public function ajaxGetLinkedStories($storyID, $type = '') { - $stories = $this->story->getLinkedStories($linkedStories); - $story = $this->story->getById($storyID); + /* Get linked stories. */ + $stories = $this->story->getLinkedStories($storyID, $type); + /* Build linked stories list. */ $output = ''; foreach($stories as $storyId => $storyTitle) { $output .= '