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'); }
/** * 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); }
public function overwrite_template_vars($event) { if (!$this->in_titania) { return; } $this->template->assign_vars(array('U_FAQ' => $this->controller_helper->route('phpbb.titania.faq'), 'U_SEARCH' => $this->controller_helper->route('phpbb.titania.search'))); if ($this->user->data['user_id'] == ANONYMOUS) { $this->template->assign_vars(array('U_LOGIN_LOGOUT' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", array('mode' => 'login', 'redirect' => urlencode($this->controller_helper->get_current_url()))))); } }
/** * Display contributions from all contribution types. * * @return \Symfony\Component\HttpFoundation\Response */ public function redirect($path) { $rerouter = new rerouter(); $url_data = $rerouter->get_url_data($path); if (!empty($url_data)) { try { $redirect_url = $this->helper->route($url_data['route'], $url_data['params'], false); return new RedirectResponse($redirect_url, 301); } catch (\Exception $e) { } } return $this->helper->error('NO_PAGE_FOUND', 404); }
/** * Download URL */ public function get_url() { if (empty($this->attachment_id)) { return ''; } return $this->controller_helper->route('phpbb.titania.download', array('id' => $this->attachment_id)); }
/** * Run AutoMOD Tests. * * @return \Symfony\Component\HttpFoundation\Response */ protected function automod() { if (!$this->contrib->type->automod_test) { return $this->helper->error('INVALID_TOOl'); } $this->package->ensure_extracted(); // Start up the machine $prevalidator = $this->contrib->type->get_prevalidator(); // Automod testing time $details = ''; $html_results = $bbcode_results = array(); $this->revision->load_phpbb_versions(); foreach ($this->revision->phpbb_versions as $row) { $version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' . $row['phpbb_version_revision']; $phpbb_path = $prevalidator->get_helper()->prepare_phpbb_test_directory($version_string); if ($phpbb_path === false) { continue; } $this->template->assign_vars(array('PHPBB_VERSION' => $version_string, 'TEST_ID' => $row['row_id'])); $html_result = $bbcode_result = ''; $prevalidator->run_automod_test($this->package, $phpbb_path, $details, $html_result, $bbcode_result); $bbcode_results[] = $bbcode_result; } $bbcode_results = $this->get_result_post('VALIDATION_AUTOMOD', implode("\n\n", $bbcode_results)); // Update the queue with the results $post = $this->queue->topic_reply($bbcode_results); $this->package->cleanup(); redirect($post->get_url()); }
/** * Assign details * * A little different from those in other classes, this one only returns the info ready for output */ public function assign_details($output_text = true) { $details = array('POST_ID' => $this->post_id, 'TOPIC_ID' => $this->topic_id, 'POST_TYPE' => $this->post_type, 'POST_ACCESS' => $this->post_access, 'POST_LOCKED' => $this->post_locked, 'POST_ATTACHMENT' => $this->post_attachment, 'POST_USER_ID' => $this->post_user_id, 'POST_IP' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_ip : false, 'POST_TIME' => phpbb::$user->format_date($this->post_time), 'POST_EDIT_REASON' => censor_text($this->post_edit_reason), 'POST_SUBJECT' => censor_text($this->post_subject), 'POST_TEXT' => $output_text ? $this->generate_text_for_display() : '', 'EDITED_MESSAGE' => $this->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($this->post_edit_user, '_full'), phpbb::$user->format_date($this->post_edited)) : '', 'DELETED_MESSAGE' => $this->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($this->post_delete_user, '_full'), phpbb::$user->format_date($this->post_deleted), $this->get_url('undelete')) : '', 'U_VIEW' => $this->get_url(), 'U_EDIT' => $this->acl_get('edit') ? $this->get_url('edit') : '', 'U_QUICKEDIT' => $this->acl_get('edit') ? $this->get_url('quick_edit') : '', 'U_DELETE' => $this->acl_get('delete') && (!$this->post_deleted || phpbb::$auth->acl_get('u_titania_post_hard_delete')) ? $this->get_url('delete') : '', 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_WARN' => false, 'U_INFO' => phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') || $this->types->find_authed('moderate') ? $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => TITANIA_POST, 'id' => $this->post_id)) : '', 'U_QUOTE' => $this->acl_get('post') ? $this->get_url('quote') : '', 'S_UNREAD_POST' => $this->unread ? true : false, 'S_POST_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_approved : true, 'S_POST_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_reported : false, 'S_POST_DELETED' => $this->post_deleted != 0 ? true : false, 'S_ACCESS_TEAMS' => $this->access->is_team($this->post_access), 'S_ACCESS_AUTHORS' => $this->access->is_author($this->post_access)); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this); return $details; }
/** * 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'); }
/** * Build the left "tool" navigation for every page * This is based upon the active tool */ function gen_left_nav() { global $template, $user; // Grep the correct category $tool_list = $this->plugin_list; // Run through the tools and collect all info we need $tpl_data = array(); foreach ($tool_list as $tool) { $class = $this->load_tool($tool); // Can this tool be used? if (method_exists($class, 'tool_active')) { if ($class->tool_active() !== true) { continue; } } // Get the info if (method_exists($class, 'info')) { $info = $class->info(); } else { // For us lazy people $info = array('NAME' => isset($user->lang[strtoupper($tool)]) ? $user->lang[strtoupper($tool)] : strtoupper($tool)); } $tpl_data[$tool] = $info['NAME']; } // Sort the data based on the tool name. This way we'll keep the menu sorted correctly for translations asort($tpl_data); // Now go ahead and build the template foreach ($tpl_data as $tool => $name) { $_s_active = $tool == $this->tool_id ? true : false; // Assign to the template $template->assign_block_vars('tools', array('L_TITLE' => $name, 'TOOL' => $tool, 'S_SELECTED' => $_s_active, 'U_TITLE' => $this->controller_helper->route('phpbb.titania.administration.tool', array('tool' => $tool)))); } }
/** * Retrieve the data on a user * * @param <type> $user_id The user_id * @param <type> $field The field you want (leave blank to return the full row) * @param <type> $query True to query the DB for the user if not already loaded */ public static function get_user($user_id, $field = false, $query = false) { if ($query) { // Load the user if not already done self::load_users(array($user_id)); } // If the user does not exist, use the anonymous uer if (!isset(self::$users[$user_id])) { $user_id = ANONYMOUS; } if (!self::$controller_helper) { self::$controller_helper = phpbb::$container->get('phpbb.titania.controller.helper'); } // Special things... if ($field[0] == '_') { switch ($field) { case '_profile': case '_username': case '_colour': case '_full': case '_no_profile': return get_username_string(substr($field, 1), $user_id, self::$users[$user_id]['username'], self::$users[$user_id]['user_colour'], false, phpbb::append_sid('memberlist', 'mode=viewprofile')); break; case '_unbuilt_titania_profile': return urlencode(self::$users[$user_id]['username_clean']); break; case '_titania_profile': return self::$controller_helper->route('phpbb.titania.author', array('author' => self::get_user($user_id, '_unbuilt_titania_profile'))); break; case '_titania': return '<a href="' . self::get_user($user_id, '_titania_profile') . (self::$users[$user_id]['user_colour'] ? '" style="color: #' . self::$users[$user_id]['user_colour'] . ';" class="username-coloured">' : '">') . get_username_string('no_profile', $user_id, self::$users[$user_id]['username'], self::$users[$user_id]['user_colour']) . '</a>'; break; case '_u_pm': return $user_id != ANONYMOUS && phpbb::$config['allow_privmsg'] && phpbb::$auth->acl_get('u_sendpm') && (self::$users[$user_id]['user_allow_pm'] || phpbb::$auth->acl_gets('a_', 'm_') || phpbb::$auth->acl_getf_global('m_')) ? phpbb::append_sid('ucp', "i=pm&mode=compose&u={$user_id}") : ''; break; case '_u_email': return !empty(self::$users[$user_id]['user_allow_viewemail']) || phpbb::$auth->acl_get('a_email') ? phpbb::$config['board_email_form'] && phpbb::$config['email_enable'] ? phpbb::append_sid('memberlist', "mode=email&u={$user_id}") : (phpbb::$config['board_hide_emails'] && !phpbb::$auth->acl_get('a_email') ? '' : 'mailto:' . self::$users[$user_id]['user_email']) : ''; break; case '_jabber': return self::$users[$user_id]['user_jabber'] && phpbb::$auth->acl_get('u_sendim') ? phpbb::append_sid('memberlist', "mode=contact&action=jabber&u={$user_id}") : ''; break; case '_avatar': // Get avatar (need hacks for this) $avatar = phpbb::$user->optionget('viewavatars') ? get_user_avatar(self::$users[$user_id]['user_avatar'], self::$users[$user_id]['user_avatar_type'], self::$users[$user_id]['user_avatar_width'], self::$users[$user_id]['user_avatar_height']) : ''; return $avatar; break; case '_signature': if (self::$users[$user_id]['user_sig'] && phpbb::$config['allow_sig'] && phpbb::$user->optionget('viewsigs')) { return generate_text_for_display(self::$users[$user_id]['user_sig'], self::$users[$user_id]['user_sig_bbcode_uid'], self::$users[$user_id]['user_sig_bbcode_bitfield'], 7); } return ''; break; } } if ($field) { return self::$users[$user_id][$field]; } return self::$users[$user_id]; }
/** * 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); }
/** * Get URL to attention report. * * @param bool|string $action Optional actional to link to. * @param array $params Additional parameters to add. * * @return string */ public function get_report_url($action = false, $params = array()) { $controller = 'phpbb.titania.manage.attention.item'; $params['id'] = $this->attention_id; if ($action) { $controller .= '.action'; $params['action'] = $action; } return $this->controller_helper->route($controller, $params); }
/** * Build view URL for a category in the Category Management panel * * @param bool|string $action Optional action. Defaults to false. * @param array $params Additional parameters to add to URL. * * @return string */ public function get_manage_url($action = false, $params = array()) { $controller = 'phpbb.titania.manage.categories'; $params['id'] = $this->category_id; if ($action) { $controller .= '.action'; $params['action'] = $action; } return $this->controller_helper->route($controller, $params); }
/** * Handle running tool. * * @return JsonResponse */ public function handle() { $this->user->add_lang_ext('phpbb/titania', 'manage_tools'); $this->check_auth(); $result = $this->run(); $result['message'] = $this->user->lang($result['message']); $next_call = null; if ($result['next_batch'] !== false) { $params = $this->get_next_params($result); $next_call = $this->helper->route($this->tool->get_route(), $params); } if ($this->request->is_ajax()) { return new JsonResponse(array_merge($result, array('next_call' => str_replace('&', '&', $next_call)))); } if ($next_call) { meta_refresh(3, $next_call); } return $this->helper->message($result['message']); }
/** * 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'); }
/** * Get navigation tab options. * * @return array */ protected function get_navigation_options() { /** * Menu Array * * 'filename' => array( * 'title' => 'nav menu title', * 'url' => $page_url, * 'auth' => ($can_see_page) ? true : false, // Not required, always true if missing * ), */ return array('attention' => array('title' => 'ATTENTION', 'url' => $this->helper->route('phpbb.titania.manage.attention'), 'auth' => $this->auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') || $this->types->find_authed('moderate'), 'count' => $this->get_open_attention_count()), 'queue' => array('title' => 'VALIDATION_QUEUE', 'url' => $this->helper->route('phpbb.titania.queue'), 'auth' => $this->types->find_authed('view') && $this->ext_config->use_queue), 'queue_discussion' => array('title' => 'QUEUE_DISCUSSION', 'url' => $this->helper->route('phpbb.titania.queue_discussion'), 'auth' => $this->types->find_authed('queue_discussion') && $this->ext_config->use_queue), 'administration' => array('title' => 'ADMINISTRATION', 'url' => $this->helper->route('phpbb.titania.administration'), 'auth' => $this->auth->acl_get('u_titania_admin'), 'match' => array('categories')), 'categories' => array('title' => 'MANAGE_CATEGORIES', 'url' => $this->helper->route('phpbb.titania.manage.categories'), 'auth' => $this->auth->acl_get('u_titania_admin'), 'display' => false)); }
/** * Get the parent URL for this topic */ public function get_parent_url() { $params = unserialize($this->topic_url); switch ($this->topic_type) { case TITANIA_SUPPORT: case TITANIA_QUEUE_DISCUSSION: $controller = 'phpbb.titania.contrib.support'; break; case TITANIA_QUEUE: $controller = 'phpbb.titania.queue.item'; break; } $base = $append = false; return $this->controller_helper->route($controller, $params); }
/** * Build view URL for a faq * * @param string $action * @param int $faq_id * * @return string */ public function get_url($action = '', $faq_id = false) { $faq_id = $faq_id ? (int) $faq_id : $this->faq_id; $controller = 'phpbb.titania.contrib.faq.item'; $parameters = array('contrib_type' => $this->contrib->type->url, 'contrib' => $this->contrib->contrib_name_clean); if ($action) { if ($action == 'create') { return $this->controller_helper->route('phpbb.titania.contrib.faq.create', $parameters); } $controller .= '.action'; $parameters['action'] = $action; } $parameters['id'] = $faq_id; return $this->controller_helper->route($controller, $parameters); }
protected function common_delete($post_id, $undelete = false) { $this->user->add_lang('posting'); // Load the stuff we need $post = $this->load_post($post_id); // Check permissions if (!$undelete && !$post->acl_get('delete') || $undelete && !$post->acl_get('undelete')) { return $this->controller_helper->needs_auth(); } if (confirm_box(true)) { if (!$undelete) { // Delete the post if ($this->request->is_set_post('hard_delete') || $post->post_deleted) { if (!$this->auth->acl_get('u_titania_post_hard_delete')) { return $this->controller_helper->needs_auth(); } $post->hard_delete(); // Try to redirect to the next or previous post $redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id); if ($redirect_post_id) { return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}"))); } return new RedirectResponse($post->topic->get_parent_url()); } else { $post->soft_delete(); if ($this->auth->acl_get('u_titania_mod_post_mod')) { // They can see the post, redirect back to it return new RedirectResponse($post->get_url()); } else { // They cannot see the post, try to redirect to the next or previous post $redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id); if ($redirect_post_id) { return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}"))); } } } return new RedirectResponse($post->topic->get_url()); } else { $post->undelete(); return new RedirectResponse($post->get_url()); } } else { $s_hard_delete = !$undelete && !$post->post_deleted && $this->auth->acl_get('u_titania_post_hard_delete'); $this->template->assign_var('S_HARD_DELETE', $s_hard_delete); confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', 'posting/delete_confirm.html'); } return new RedirectResponse($post->get_url()); }
/** * Run tool. * * @param bool|false $from_file Rebuild packages using composer.json's * from the revision zip files * @param bool|false $force Force tool to run if a build is already * in progress * @param ProgressHelper|null $progress * @return array */ public function run($from_file = false, $force = false, $progress = null) { $this->repo->prepare_build_dir($force); $batch = $this->get_batch($from_file); $group_count = $group = 1; $last_type = $last_contrib = ''; $packages = array(); foreach ($batch as $contrib_id => $revisions) { $added = false; foreach ($revisions as $index => $revision) { if ($from_file) { $revision = $this->rebuild_from_file($revision); } if ($progress) { $progress->advance(); } if (!$revision['revision_composer_json']) { unset($batch[$contrib_id][$index]); continue; } $added = true; if ($last_type != $revision['contrib_type']) { $group_count = $group = 1; } $last_type = $revision['contrib_type']; $download_url = $this->path_helper->strip_url_params($this->controller_helper->route('phpbb.titania.download', array('id' => (int) $revision['attachment_id'])), 'sid'); $contrib_url = $this->path_helper->strip_url_params($this->controller_helper->route('phpbb.titania.contrib', array('contrib_type' => $this->types->get($revision['contrib_type'])->url, 'contrib_name' => $revision['contrib_name_clean'])), 'sid'); $packages = $this->repo->set_release($packages, $revision['revision_composer_json'], $download_url, $contrib_url); unset($batch[$contrib_id][$index]); } if (!$added) { continue; } if ($group_count % 50 === 0) { $this->dump_include($last_type, $group, $packages); $group_count = 0; $group++; $packages = array(); } $group_count++; } if (!empty($packages)) { $this->dump_include($last_type, $group, $packages); } $this->repo->deploy_build(); return $this->get_result('COMPOSER_PACKAGES_REBUILT', $this->get_total(), false); }
/** * Assign variables to the template */ public function assign_details() { if (!sizeof($this->styles)) { return false; } // Get siblings $prev = $this->sibling($this->default_style, 'prev'); $next = $this->sibling($this->default_style, 'next'); $this->template->assign_vars(array('U_PREV' => $prev['url'], 'PREV_ID' => $prev['id'], 'U_NEXT' => $next['url'], 'NEXT_ID' => $next['id'])); $category = ''; $style = new \titania_contribution(); $style->set_type(TITANIA_TYPE_STYLE); $style->options = array('demo' => true); foreach ($this->styles as $id => $data) { $style->__set_array(array('contrib_id' => $id, 'contrib_name_clean' => $data['contrib_name_clean'], 'contrib_demo' => $data['contrib_demo'])); $preview_img = false; if (isset($data['thumb_id'])) { $parameters = array('id' => $data['thumb_id']); if ($data['thumbnail']) { $parameters += array('mode' => 'view', 'thumb' => 1); } $preview_img = $this->controller_helper->route('phpbb.titania.download', $parameters); } $authors = $this->get_author_profile(array('username_clean' => $data['username_clean'], 'username' => $data['username'], 'user_id' => $data['contrib_user_id'], 'user_colour' => $data['user_colour'])); $authors .= $data['coauthors']; $data['category_name'] = $this->user->lang($data['category_name']); $phpbb_version = $data['phpbb_versions']['branch'][0] . '.' . $data['phpbb_versions']['branch'][1] . '.' . $data['phpbb_versions']['revision']; $current_phpbb_version = $data['phpbb_versions']['branch'][0] . '.' . $data['phpbb_versions']['branch'][1] . '.' . $this->ext_config->phpbb_versions[$data['phpbb_versions']['branch']]['latest_revision']; $vars = array('AUTHORS' => $authors, 'CATEGORY' => $category != $data['category_name'] ? $data['category_name'] : false, 'ID' => $id, 'IFRAME' => $style->get_demo_url($this->phpbb_branch), 'LICENSE' => $data['revision_license'] ? $data['revision_license'] : $this->user->lang['UNKNOWN'], 'NAME' => $data['contrib_name'], 'PHPBB_VERSION' => $phpbb_version, 'PREVIEW' => $preview_img, 'S_OUTDATED' => phpbb_version_compare($phpbb_version, $current_phpbb_version, '<'), 'U_DEMO' => $style->get_demo_url($this->phpbb_branch, true), 'U_DOWNLOAD' => $this->controller_helper->route('phpbb.titania.download', array('id' => $data['attachment_id'])), 'U_VIEW' => $style->get_url()); if ($this->default_style == $id) { $this->template->assign_vars($vars); } $category = $data['category_name']; $this->template->assign_block_vars('stylerow', $vars); unset($this->styles[$id], $vars, $this->coauthors[$id]); } }
/** * Assign result page template variables. * * @param int $match_count Number of matches found. * @return null */ protected function assign_result_vars($match_count) { $this->template->assign_vars(array('SEARCH_WORDS' => $this->request->variable('keywords', '', true), 'SEARCH_MATCHES' => $this->user->lang('FOUND_SEARCH_MATCHES', $match_count), 'U_SEARCH_WORDS' => $this->helper->get_current_url(), 'S_IN_SEARCH' => true, 'S_SEARCH_ACTION' => $this->helper->get_current_url())); }
/** * Get index URL. * * @param array $params * @return string */ protected function get_index_url(array $params = array()) { $suffix = isset($params['branch']) ? '.branch' : ''; return $this->helper->route('phpbb.titania.index' . $suffix, $params); }
/** * Update the release topic for this contribution */ public function update_release_topic() { if ($this->type->forum_robot && $this->type->forum_database && $this->type->create_public) { titania::_include('functions_posting', 'phpbb_posting'); // Get the latest download $this->get_download(); // If there is not a download do not update. if (!$this->download) { return; } // Get the latest revision $this->get_revisions(); // If there is not a revision do not update. if (!$this->revisions) { return; } $contrib_description = $this->contrib_desc; message::decode($contrib_description, $this->contrib_desc_uid); foreach ($this->download as $download) { $phpbb_version = $this->revisions[$download['revision_id']]['phpbb_versions'][0]; $branch = (int) $phpbb_version['phpbb_version_branch']; if (empty($this->type->forum_database[$branch])) { continue; } $u_download = $this->controller_helper->route('phpbb.titania.download', array('id' => $download['attachment_id'])); // Global body and options $body = phpbb::$user->lang($this->type->create_public, $this->contrib_name, $this->path_helper->strip_url_params($this->author->get_url(), 'sid'), users_overlord::get_user($this->author->user_id, '_username'), $contrib_description, $download['revision_version'], $this->path_helper->strip_url_params($u_download, 'sid'), $download['real_filename'], get_formatted_filesize($download['filesize']), $this->path_helper->strip_url_params($this->get_url(), 'sid'), $this->path_helper->strip_url_params($this->get_url('support'), 'sid'), $phpbb_version['phpbb_version_branch'][0] . '.' . $phpbb_version['phpbb_version_branch'][1] . '.' . $phpbb_version['phpbb_version_revision']); $options = array('poster_id' => $this->type->forum_robot, 'forum_id' => $this->type->forum_database[$branch]); $release_topic_id = (int) $this->get_release_topic_id($branch); if ($release_topic_id) { // We edit the first post of contrib release topic $options_edit = array('topic_id' => $release_topic_id, 'topic_title' => $this->contrib_name, 'post_text' => $body); $options_edit = array_merge($options_edit, $options); phpbb_posting('edit_first_post', $options_edit); } else { // We create a new topic in database $options_post = array('topic_title' => $this->contrib_name, 'post_text' => $body); $options_post = array_merge($options_post, $options); $release_topic_id = phpbb_posting('post', $options_post); $this->set_release_topic_id($branch, $release_topic_id); } } } }
/** * Get URL to queue tool. * * @param string $tool Tool. * @param int $revision_id Revision id. * @param array $params Additional parameters to append to the URL. * * @return string */ public function get_tool_url($tool, $revision_id, array $params = array()) { $params += array('tool' => $tool, 'id' => $revision_id); return $this->controller_helper->route('phpbb.titania.queue.tools', $params); }
/** * Get profile url * * @param string $page The page we are on (Ex: faq/support/details) * @param array $parameters Extra parameters. * * @return string */ public function get_url($page = '', $parameters = array()) { $parameters += array('author' => users_overlord::get_user($this->user_id, '_unbuilt_titania_profile'), 'page' => $page); return $this->controller_helper->route('phpbb.titania.author', $parameters); }
/** * Get absolute path to an attachment. * * @param int $id Attachment id. * @return string */ protected function get_file_source($id) { return $this->helper->route('phpbb.titania.download', array('id' => $id), true, false, UrlGeneratorInterface::ABSOLUTE_PATH); }
/** * Get queue item template row. * * @param array $row * @return array */ protected function get_queue_tpl_row($row) { $queue_id = $row['watch_object_id']; $type = $this->types->get($queue_id); return array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => $type->lang, 'SUBSCRIPTION_TIME' => $this->user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => $this->user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => $this->get_real_url($this->helper->route('phpbb.titania.queue.type', array('queue_type' => $type->url)))); }
/** * Get attachment download URL. * * @param array $parameters Optional parameters to add to the URL. * @return string Returns generated URL. */ public function get_url($parameters = array()) { $parameters += array('id' => $this->get_id()); return $this->controller_helper->route('phpbb.titania.download', $parameters); }
/** * Send file to browser * * Copy of send_file_to_browser() from functions_download.php * with some minor modifications to work correctly in Titania. * * @param array $attachment Attachment data. * @param string $filename Full path to the attachment file. * @param int $category Attachment category. * * @return \Symfony\Component\HttpFoundation\Response if error found. Otherwise method exits. */ protected function send_file_to_browser($attachment, $filename, $category) { if (!@file_exists($filename)) { return $this->helper->error('ERROR_NO_ATTACHMENT', 404); } // Correct the mime type - we force application/octetstream for all files, except images // Please do not change this, it is a security precaution if ($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0) { $attachment['mimetype'] = strpos(strtolower($this->user->browser), 'msie') !== false || strpos(strtolower($this->user->browser), 'opera') !== false ? 'application/octetstream' : 'application/octet-stream'; } if (@ob_get_length()) { @ob_end_clean(); } // Now send the File Contents to the Browser $size = @filesize($filename); // To correctly display further errors we need to make sure we are using the correct headers for both (unsetting content-length may not work) // Check if headers already sent or not able to get the file contents. if (headers_sent() || !@file_exists($filename) || !@is_readable($filename)) { // PHP track_errors setting On? if (!empty($php_errormsg)) { return $this->helper->error($this->user->lang['UNABLE_TO_DELIVER_FILE'] . '<br />' . $this->user->lang('TRACKED_PHP_ERROR', $php_errormsg), self::INTERNAL_SERVER_ERROR); } return $this->helper->error('UNABLE_TO_DELIVER_FILE', self::INTERNAL_SERVER_ERROR); } // Make sure the database record for the filesize is correct if ($size > 0 && $size != $attachment['filesize']) { // Update database record $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . ' SET filesize = ' . (int) $size . ' WHERE attachment_id = ' . (int) $attachment['attachment_id']; $this->db->sql_query($sql); } // Now the tricky part... let's dance header('Pragma: public'); // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. header('Content-Type: ' . $attachment['mimetype']); if (phpbb_is_greater_ie_version($this->user->browser, 7)) { header('X-Content-Type-Options: nosniff'); } if ($category == ATTACHMENT_CATEGORY_FLASH && request_var('view', 0) === 1) { // We use content-disposition: inline for flash files and view=1 to let it correctly play with flash player 10 - any other disposition will fail to play inline header('Content-Disposition: inline'); } else { if (empty($this->user->browser) || strpos(strtolower($this->user->browser), 'msie') !== false && !phpbb_is_greater_ie_version($this->user->browser, 7)) { header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); if (empty($this->user->browser) || strpos(strtolower($this->user->browser), 'msie 6.0') !== false) { header('expires: -1'); } } else { header('Content-Disposition: ' . (strpos($attachment['mimetype'], 'image') === 0 ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); if (phpbb_is_greater_ie_version($this->user->browser, 7) && strpos($attachment['mimetype'], 'image') !== 0) { header('X-Download-Options: noopen'); } } } if ($size) { header("Content-Length: {$size}"); } // Close the db connection before sending the file etc. file_gc(false); if (!set_modified_headers($attachment['filetime'], $this->user->browser)) { // Try to deliver in chunks @set_time_limit(0); $fp = @fopen($filename, 'rb'); if ($fp !== false) { // Deliver file partially if requested if ($range = phpbb_http_byte_range($size)) { fseek($fp, $range['byte_pos_start']); send_status_line(206, 'Partial Content'); header('Content-Range: bytes ' . $range['byte_pos_start'] . '-' . $range['byte_pos_end'] . '/' . $range['bytes_total']); header('Content-Length: ' . $range['bytes_requested']); } while (!feof($fp)) { echo fread($fp, 8192); } fclose($fp); } else { @readfile($filename); } flush(); } exit; }