/** * Run tool. * * @return array */ public function run() { $i = 1; $changes_made = $this->fix_tree($i, 'category_id', $this->categories_table); $message = $changes_made ? 'LEFT_RIGHT_IDS_FIX_SUCCESS' : 'LEFT_RIGHT_IDS_NO_CHANGE'; // Purge the cache so the next time a page with modules is viewed it is not getting // an old version from the cache $this->cache->purge(); return $this->get_result($message, null, false); }
/** * Load tags */ protected function load_tags() { if (!empty($this->tags)) { return; } foreach ($this->cache->get_tags() as $children) { foreach ($children as $id => $row) { $this->tags[$id] = $row; } } }
/** * Assign breadcrumbs to template. * * @return null */ protected function generate_breadcrumbs() { // Search for a category with the same name as the contrib type. This is a bit ugly, but there really isn't any better option $categories = $this->cache->get_categories(); $category = new \titania_category(); foreach ($categories as $category_id => $category_row) { $category->__set_array($category_row); $name = $category->get_name(); if ($name == $this->contrib->type->lang || $name == $this->contrib->type->langs) { // Generate the main breadcrumbs $this->display->generate_breadcrumbs(array($name => $category->get_url())); } } }
/** * Get category URL's. * * @return array */ protected function get_category_urls() { $category = new \titania_category(); $url = $this->get_index_url($this->params); $urls = array(0 => $this->request->is_ajax() ? str_replace('&', '&', $url) : $url); foreach ($this->cache->get_categories() as $data) { if (!$category->category_visible) { continue; } $category->__set_array($data); $url = $category->get_url($this->params); $urls[$category->category_id] = $this->request->is_ajax() ? str_replace('&', '&', $url) : $url; } return $urls; }
/** * Generate query for contribution search. * * @param array $versions Supported phpBB versions to limit search to. * @param array $categories Categories to filter by. * @param bool $search_subcategories Whether to search a category children. * * @return null */ protected function generate_contrib_query($versions, $categories, $search_subcategories) { if (!empty($categories) && (sizeof($categories) != 1 || $categories[0] != 0)) { // Grab the children if ($search_subcategories) { foreach ($categories as $category_id) { $categories = array_merge($categories, array_keys($this->cache->get_category_children($category_id))); } } $this->engine->where_in_set('categories', $categories); } if (!empty($versions)) { $this->engine->where_in_set('phpbb_versions', $versions); } $this->engine->set_type(TITANIA_CONTRIB); }
/** * Display author's support topics page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function support() { if (!$this->is_owner) { return $this->helper->needs_auth(); } // Mark all topics read if ($this->request->variable('mark', '') == 'topics') { foreach ($this->cache->get_author_contribs($this->author->user_id, $this->types, $this->user) as $contrib_id) { $this->tracking->track(TITANIA_SUPPORT, $contrib_id); } } \topics_overlord::display_forums_complete('author_support', $this->author); // Mark all topics read $this->template->assign_var('U_MARK_TOPICS', $this->author->get_url('support', array('mark' => 'topics'))); return $this->helper->render('contributions/contribution_support.html', $this->get_title('AUTHOR_SUPPORT')); }
/** * Generate the category select (much is from the make_jumpbox function) * * @param array|bool $selected Array of selected categories. Defaults to false. * @param bool $is_manage Whether in category management, in which case all are listed * @param bool $disable_parents Whether to disable categories that do not have a contribution type * @param bool|int $category_type Category type to limit list to * @return void */ public function generate_category_select($selected = false, $is_manage = false, $disable_parents = true, $category_type = false) { if (!is_array($selected)) { $selected = array($selected); } $right = $padding = 0; $padding_store = array('0' => 0); $categories = $this->cache->get_categories(); $hidden_categories = array(); $category = new \titania_category(); foreach ($categories as $row) { $type = $this->types->get($row['category_type']); if ($type && (!$type->acl_get('submit') || $category_type && $type->id != $category_type)) { continue; } $category->__set_array($row); if ($row['left_id'] < $right) { $padding++; $padding_store[$row['parent_id']] = $padding; } else { if ($row['left_id'] > $right + 1) { $padding = isset($padding_store[$row['parent_id']]) ? $padding_store[$row['parent_id']] : $padding; } } $right = $row['right_id']; if (!$is_manage) { // Non-postable category with no children, don't display $not_postable = $row['category_type'] == 0 && $row['left_id'] + 1 == $row['right_id']; $hidden = !$row['category_visible'] || in_array($row['parent_id'], $hidden_categories); $team_only_restriction = $category->is_option_set('team_only') && !$type->acl_get('moderate'); if ($not_postable || $hidden || $team_only_restriction) { if ($hidden) { $hidden_categories[] = $row['category_id']; } continue; } } $this->template->assign_block_vars('category_select', array('S_SELECTED' => in_array($row['category_id'], $selected), 'S_DISABLED' => $row['category_type'] == 0 && $disable_parents, 'VALUE' => $row['category_id'], 'TYPE' => $row['category_type'], 'NAME' => $category->get_name())); for ($i = 0; $i < $padding; $i++) { $this->template->assign_block_vars('category_select.level', array()); } } }
/** * Unset stored demo in cache */ public function clear_cache() { unset($this->demo_cache[$this->contrib_id]); $this->cache->put('_titania_bbcode_demo', $this->demo_cache); }