public function display_list() { $this->user->add_lang_ext('phpbb/titania', 'faq', false, true); /** * From phpBB faq.php */ // Pull the array data from the lang pack $switch_column = $found_switch = false; $help_blocks = array(); foreach ($this->user->help as $help_ary) { if ($help_ary[0] == '--') { if ($help_ary[1] == '--') { $switch_column = true; $found_switch = true; continue; } $this->template->assign_block_vars('faq_block', array('BLOCK_TITLE' => $help_ary[1], 'SWITCH_COLUMN' => $switch_column)); if ($switch_column) { $switch_column = false; } continue; } $this->template->assign_block_vars('faq_block.faq_row', array('FAQ_QUESTION' => $help_ary[0], 'FAQ_ANSWER' => $help_ary[1])); } // Lets build a page ... $this->template->assign_vars(array('L_FAQ_TITLE' => $this->user->lang['FAQ_EXPLAIN'], 'L_BACK_TO_TOP' => $this->user->lang['BACK_TO_TOP'], 'SWITCH_COLUMN_MANUALLY' => !$found_switch)); $this->display->assign_global_vars(); return $this->helper->render('faq_body.html', 'FAQ_EXPLAIN'); }
/** * Perform search and output results. * * @param string $sort_url Base sort url. * @return \Symfony\Component\HttpFoundation\Response */ protected function show_results($sort_url) { // Setup the sort tool $this->sort->set_defaults($this->config['posts_per_page'])->request(); // Do the search $results = $this->query_index(); // Grab the users \users_overlord::load_users($results['user_ids']); $this->display->assign_global_vars(); $this->assign_doc_vars($results['documents']); $this->assign_result_vars($this->sort->total); $parameters = array(); $expected_parameters = array('versions' => array(array(''), false), 'c' => array(array(0), false), 'sc' => array(false, false), 'keywords' => array('', true), 'sf' => array('', false), 'author' => array('', true), 'u' => array(0, false), 'type' => array(0, false), 'contrib' => array(0, false)); foreach ($expected_parameters as $name => $properties) { if ($this->request->is_set($name)) { list($default_value, $multibyte) = $properties; $value = $this->request->variable($name, $default_value, $multibyte); // Clean up URL by not including default values. if ($value !== $default_value) { $parameters[$name] = $value; } } } $this->sort->build_pagination($sort_url, $parameters); return $this->helper->render('search_results.html', $this->user->lang['SEARCH']); }
/** * Display a category, its children, and its contributions. * * @return \Symfony\Component\HttpFoundation\Response */ public function display_category($category1, $category2, $category3, $category4) { $categories = array($category1, $category2, $category3, $category4); try { $this->load_category($categories); } catch (\Exception $e) { // If the category does not exist, check whether this is an old link // that may have been caught by the route matcher. $rerouter = new \phpbb\titania\controller\legacy_rerouter($this->helper); $url = '/' . implode('/', array_filter($categories, 'strlen')); return $rerouter->redirect($url); } $this->set_branch($this->get_branch($categories)); $children = $this->get_children_ids(); // Include the current category in the ones selected $children[] = $this->id; $sort = $this->list_contributions($children, $this->category->get_url()); $this->params = $this->get_params($sort); $title = $this->category->get_name() . ' - ' . $this->user->lang['CUSTOMISATION_DATABASE']; $this->display->assign_global_vars(); $this->generate_breadcrumbs(); if ($this->request->is_ajax()) { return $this->get_ajax_response($title, $sort); } $this->display->display_categories($this->id, 'categories', false, true, $this->params); $this->template->assign_vars(array('CATEGORY_ID' => $this->id, 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => $this->helper->route('phpbb.titania.search.contributions.results'), 'U_QUEUE_STATS' => $this->get_queue_stats_url(), 'U_CREATE_CONTRIBUTION' => $this->get_create_contrib_url(), 'U_ALL_CONTRIBUTIONS' => $this->get_index_url($this->params))); $this->assign_sorting($sort); $this->assign_branches(); return $this->helper->render('index_body.html', $title); }
/** * Display support topics from all contributions or of a specific type. * * @param string $type Contribution type's string identifier * @return \Symfony\Component\HttpFoundation\Response */ public function display_topics($type) { $type_id = $this->get_type_id($type); if ($type_id === false) { return $this->helper->error('NO_PAGE', 404); } if ($type == 'all') { // Mark all topics read if ($this->request->variable('mark', '') == 'topics') { $this->tracking->track(TITANIA_ALL_SUPPORT, self::ALL_SUPPORT); } // Mark all topics read $this->template->assign_var('U_MARK_TOPICS', $this->helper->route('phpbb.titania.support', array('type' => 'all', 'mark' => 'topics'))); } $this->display->assign_global_vars(); $u_all_support = $this->helper->route('phpbb.titania.support', array('type' => 'all')); $this->template->assign_var('U_ALL_SUPPORT', $u_all_support); // Generate the main breadcrumbs $this->display->generate_breadcrumbs(array('ALL_SUPPORT' => $u_all_support)); // Links to the support topic lists foreach ($this->types->get_all() as $id => $class) { $this->template->assign_block_vars('support_types', array('U_SUPPORT' => $this->helper->route('phpbb.titania.support', array('type' => $class->url)), 'TYPE_SUPPORT' => $class->langs)); } $data = \topics_overlord::display_forums_complete('all_support', false, array('contrib_type' => $type_id)); // Canonical URL $data['sort']->set_url($this->helper->route('phpbb.titania.support', array('type' => $type))); $this->template->assign_var('U_CANONICAL', $data['sort']->build_canonical()); return $this->helper->render('all_support.html', 'CUSTOMISATION_DATABASE'); }
/** * Display new contribution page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function create() { if (!$this->is_owner && !$this->auth->acl_get('u_titania_contrib_submit')) { return $this->helper->needs_auth(); } $this->user->add_lang_ext('phpbb/titania', 'contributions'); $contrib = new \titania_contribution(); $contrib->contrib_user_id = $this->user->data['user_id']; $contrib->author = $this->author; $contrib->get_options(); // Set some main vars up $message = $this->setup_message($contrib); $submit = $this->request->is_set_post('submit'); $preview = $this->request->is_set_post('preview'); $error = array(); $settings = array('type' => $this->request->variable('contrib_type', 0), 'permalink' => $this->request->variable('permalink', '', true), 'categories' => $this->request->variable('contrib_category', array(0)), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true)); if ($preview || $submit) { $contrib->post_data($message); $contrib->__set_array(array('contrib_type' => $settings['type'], 'contrib_name_clean' => $settings['permalink'], 'contrib_visible' => 1)); } if ($preview) { $message->preview(); } else { if ($submit) { $authors = $contrib->get_authors_from_usernames(array('active_coauthors' => $settings['coauthors']['active'], 'nonactive_coauthors' => $settings['coauthors']['nonactive'])); $authors['author'] = array($this->user->data['username'] => $this->user->data['user_id']); $error = $contrib->validate($settings['categories'], $authors, $settings['custom']); if (($form_key_error = $message->validate_form_key()) !== false) { $error[] = $form_key_error; } if (empty($error)) { $contrib->set_type($contrib->contrib_type); $contrib->set_custom_fields($settings['custom']); $contrib->contrib_categories = implode(',', $settings['categories']); $contrib->contrib_creation_time = time(); $contrib->submit(); $contrib->set_coauthors($authors['active_coauthors'], $authors['nonactive_coauthors'], true); // Create relations $contrib->put_contrib_in_categories($settings['categories']); if ($this->ext_config->support_in_titania) { $active_authors = array_merge($authors['author'], $authors['active_coauthors']); foreach ($active_authors as $author) { $this->subscriptions->subscribe(TITANIA_SUPPORT, $contrib->contrib_id, $author); } } redirect($contrib->get_url('revision')); } } } // Generate some stuff $this->display->generate_type_select($contrib->contrib_type); $this->display->generate_category_select($settings['categories']); $contrib->assign_details(); $message->display(); foreach ($this->types->get_all() as $type) { $this->display->generate_custom_fields($type->contribution_fields, $settings['custom'], $type->id); } $this->template->assign_vars(array('S_POST_ACTION' => $this->author->get_url('create'), 'S_CREATE' => true, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'CONTRIB_PERMALINK' => $settings['permalink'], 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $settings['coauthors']['active'], 'NONACTIVE_COAUTHORS' => $settings['coauthors']['nonactive'])); return $this->helper->render('contributions/contribution_manage.html', 'NEW_CONTRIBUTION'); }
/** * Run tool. * * @return \Symfony\Component\HttpFoundation\Response */ public function run_tool() { $type = $this->request->variable('type', 'queue'); $start = $this->request->variable('start', 0); $continue_start = null; switch ($type) { case 'queue': $continue_start = $this->sync_queue_topics($start); if ($continue_start === null) { $type = 'contrib'; $continue_start = 0; } break; case 'contrib': $continue_start = $this->sync_contrib_topics($start); break; } if ($continue_start !== null) { $params = array('tool' => 'rebuild_topic_urls', 'type' => $type, 'submit' => 1, 'hash' => generate_link_hash('manage'), 'start' => $continue_start); meta_refresh(2, $this->controller_helper->route('phpbb.titania.administration.tool', $params)); } $msg = $continue_start !== null ? 'PLEASE_WAIT_FOR_TOOL' : 'DONE'; $this->template->assign_vars(array('MESSAGE_TEXT' => $this->user->lang($msg), 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'))); return $this->controller_helper->render('message_body.html', $msg); }
/** * Display queue stats. * * @param string $contrib_type Contribution type URL value. * @return \Symfony\Component\HttpFoundation\Response */ public function display_stats($contrib_type) { $this->user->add_lang_ext('phpbb/titania', array('queue_stats', 'contributions')); $this->set_type($contrib_type); if (!$this->stats_supported()) { return $this->helper->error('NO_QUEUE_STATS'); } $this->stats->set_queue_type($this->type->id); if (!$this->generate_stats()) { return $this->helper->error('NO_QUEUE_STATS'); } $this->generate_history(); $this->display->assign_global_vars(); $page_title = $this->user->lang['QUEUE_STATS'] . ' - ' . $this->type->langs; $this->display->generate_breadcrumbs(array($page_title => $this->helper->route('phpbb.titania.queue_stats', array('contrib_type' => $this->type->url)))); return $this->helper->render('queue_stats_body.html', $page_title); }
/** * Split/merge * * @param int $topic_id * @param string $mode Either split_topic or move_posts * @return Response|RedirectResponse */ public function split_topic($topic_id, $mode) { // Auth check if (!$this->auth->acl_get('u_titania_mod_post_mod')) { return $this->controller_helper->needs_auth(); } $this->user->add_lang('mcp'); $subject = $this->request->variable('subject', '', true); $new_topic_id = $this->request->variable('new_topic_id', 0); $post_ids = $this->request->variable('post_ids', array(0)); $submit = $this->request->is_set_post('split'); $range = $this->request->variable('from', ''); $topic = $this->load_topic($topic_id); $errors = array(); if ($topic->topic_type != TITANIA_SUPPORT) { return $this->controller_helper->message('SPLIT_NOT_ALLOWED'); } $page_title = $mode == 'split_topic' ? 'SPLIT_TOPIC' : 'MERGE_POSTS'; $page_title = $this->user->lang($page_title) . ' - ' . $topic->topic_subject; if ($submit) { // Check for errors if (!check_form_key('split_topic')) { $errors[] = $this->user->lang['FORM_INVALID']; } if ($mode == 'split_topic' && utf8_clean_string($subject) == '') { $errors[] = $this->user->lang['NO_SUBJECT']; } else { if ($mode == 'move_posts' && !$new_topic_id) { $errors[] = $this->user->lang['NO_FINAL_TOPIC_SELECTED']; } } if (empty($post_ids)) { $errors[] = $this->user->lang['NO_POST_SELECTED']; } if ($new_topic_id == $topic->topic_id) { $errors[] = $this->user->lang['ERROR_MERGE_SAME_TOPIC']; } if (empty($errors)) { if ($mode == 'move_posts') { // Load the topic $new_topic = $this->load_topic($new_topic_id); if (!$new_topic) { $errors[] = $this->user->lang['NO_TOPIC']; } // Only allow support posts to be moved to the same contrib if ($new_topic->parent_id != $topic->parent_id || $new_topic->topic_type != TITANIA_SUPPORT) { $errors[] = $this->user->lang['ERROR_NOT_SAME_PARENT']; } // Ensure that we don't have a range $range = false; } else { $sql_extra = 'post_id = ' . (int) $post_ids[0]; // Get info from first post $sql = 'SELECT post_id, post_access, post_approved, post_time FROM ' . TITANIA_POSTS_TABLE . ' WHERE post_type = ' . TITANIA_SUPPORT . ' AND topic_id = ' . (int) $topic->topic_id . ' AND '; $result = $this->db->sql_query_limit($sql . $sql_extra, 1); $first_post = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!$first_post) { $errors[] = $this->user->lang['NO_POST_SELECTED']; } else { if ($range == 'from') { // Get info from last post $sql_extra = 'post_time >= ' . (int) $first_post['post_time'] . ' ORDER BY post_time DESC'; $result = $this->db->sql_query_limit($sql . $sql_extra, 1); $last_post = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $range = array('min' => $first_post['post_time'], 'max' => $last_post['post_time']); } else { $range = false; } // Create the new \topic with some basic info. $data = array('parent_id' => $topic->parent_id, 'topic_type' => $topic->topic_type, 'topic_access' => $first_post['post_access'], 'topic_approved' => 1, 'topic_status' => ITEM_UNLOCKED, 'topic_time' => $first_post['post_time'], 'topic_subject' => $subject, 'topic_url' => $topic->topic_url); $new_topic = new \titania_topic(); $new_topic->__set_array($data); $new_topic->submit(); // Use new subject as the first post's subject to avoid issues when it gets approved if (!$first_post['post_approved']) { $sql = 'UPDATE ' . TITANIA_POSTS_TABLE . ' SET post_subject = "' . $this->db->sql_escape($subject) . '" WHERE post_id = ' . (int) $first_post['post_id']; $this->db->sql_query($sql); } } } // If there aren't any errors, go ahead and transfer the posts. if (empty($errors)) { $new_topic->acquire_posts($topic, $post_ids, $range); return new RedirectResponse($new_topic->get_url()); } } } if (!$submit || !empty($errors)) { $errors = implode('<br />', $errors); $this->template->assign_vars(array('ERRORS' => $errors, 'TOPIC_SUBJECT' => $topic->topic_subject, 'S_SPLIT' => $mode == 'split_topic', 'SUBJECT' => $subject, 'TO_ID' => $new_topic_id)); // Setup the sort tool $topic_sort = \posts_overlord::build_sort(); $topic_sort->request(); $topic_sort->url_parameters = array('action' => $mode); // Display topic \posts_overlord::display_topic($topic, $topic_sort); \posts_overlord::assign_common(); add_form_key('split_topic'); } return $this->controller_helper->render('posting/split_merge_topic_body.html', $page_title); }