/** * Method to build a link to the specified page/action with the provided * data and params. * * @see XenForo_Route_BuilderInterface */ public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams) { // for situations such as an array with thread and node info if (isset($data['node_title'])) { $data['title'] = $data['node_title']; } if ($data && isset($data['node_id']) && $data['depth'] === 0) { if (!XenForo_Application::get('options')->categoryOwnPage) { return new XenForo_Link('#' . XenForo_Link::buildIntegerAndTitleUrlComponent($data['node_id'], $data['title'], true)); } } return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'node_id', 'title'); }
public function actionList() { //######################################## // list //######################################## // get permission if (!XenForo_Visitor::getInstance()->hasPermission('bookmarkGroupID', 'bookmarkID')) { throw $this->getNoPermissionResponseException(); } // get userId $userId = XenForo_Visitor::getUserId(); // get options from Admin CP -> Options -> Bookmark -> Sort By $sortBy = XenForo_Application::get('options')->bookmarkSortBy; // get options from Admin CP -> Options -> Bookmark -> Sort Order $sortOrder = XenForo_Application::get('options')->bookmarkSortOrder; if ($sortBy == 'postDate') { $orderBy = 'xf_post.post_date'; } if ($sortBy == 'bookmarkDate') { $orderBy = 'xf_bookmark.bookmark_id'; } if ($sortOrder == 'desc') { $orderSort = ' DESC'; } if ($sortOrder == 'asc') { $orderSort = ' ASC'; } // get database $db = XenForo_Application::get('db'); // run query $bookmarkResults = $db->fetchAll("\n\t\tSELECT xf_bookmark.bookmark_id,\n\t\txf_post.post_id,\n\t\txf_post.user_id,\n\t\txf_post.username,\n\t\txf_node.node_id AS forum_id,\n\t\txf_node.title AS forum_title,\n\t\txf_thread.title,\t\t\n\t\txf_post.post_date,\n\t\txf_bookmark.note\n\t\tFROM xf_bookmark\n\t\tINNER JOIN xf_post ON xf_post.post_id = xf_bookmark.post_id\n\t\tINNER JOIN xf_thread ON xf_thread.thread_id = xf_post.thread_id\n\t\tINNER JOIN xf_node ON xf_node.node_id = xf_thread.node_id\n\t\tWHERE xf_bookmark.user_id = " . $userId . "\n\t\tAND xf_post.message_state = 'visible'\n\t\tORDER BY " . $orderBy . $orderSort . "\n\t\t"); // declare variable $i = 0; // get child node titles foreach ($bookmarkResults as $k => $v) { // includeTitleInUrls option $forum_link = XenForo_Link::buildIntegerAndTitleUrlComponent($v['forum_id'], $v['forum_title'], true); // merge arrays $bookmarkResults[$i] = array_merge($bookmarkResults[$i], array('forum_link' => $forum_link)); // increment variable $i = $i + 1; } // prepare viewParams $viewParams = array('bookmarkResults' => $bookmarkResults); // send to template return $this->responseView('Andy_Bookmark_ViewPublic_Bookmark', 'andy_bookmark_list', $viewParams); }