public function display($tpl_block = 'revisions', $show_queue = false) { titania::_include('functions_display', 'order_phpbb_version_list_from_db'); $ordered_phpbb_versions = order_phpbb_version_list_from_db($this->phpbb_versions); // Get rid of the day of the week if it exists in the dateformat $old_date_format = phpbb::$user->date_format; phpbb::$user->date_format = str_replace('D ', '', phpbb::$user->date_format); phpbb::$template->assign_block_vars($tpl_block, array('REVISION_ID' => $this->revision_id, 'CREATED' => phpbb::$user->format_date($this->revision_time), 'NAME' => $this->revision_name ? censor_text($this->revision_name) : ($this->contrib ? $this->contrib->contrib_name . ' ' . $this->revision_version : ''), 'VERSION' => $this->revision_version, 'VALIDATED_DATE' => $this->validation_date ? phpbb::$user->format_date($this->validation_date) : phpbb::$user->lang['NOT_VALIDATED'], 'REVISION_QUEUE' => $show_queue && $this->revision_queue_id ? titania_url::build_url('manage/queue', array('q' => $this->revision_queue_id)) : '', 'PHPBB_VERSION' => sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '', 'REVISION_LICENSE' => $this->revision_license ? censor_text($this->revision_license) : ($this->contrib && sizeof(titania_types::$types[$this->contrib->contrib_type]->license_options) ? phpbb::$user->lang['UNKNOWN'] : ''), 'U_DOWNLOAD' => $this->get_url(), 'U_EDIT' => $this->contrib && ($this->contrib->is_author || $this->contrib->is_active_coauthor || titania_types::$types[$this->contrib->contrib_type]->acl_get('moderate')) ? $this->contrib->get_url('revision_edit', array('revision' => $this->revision_id)) : '', 'U_VIEW_INSTALL' => titania_types::$types[$this->contrib->contrib_type]->display_install_file && file_exists(titania::$config->modx_storage_path . $this->revision_id) ? titania_url::build_url('view-install', array('id' => $this->revision_id)) : '', 'S_USE_QUEUE' => titania::$config->use_queue && titania_types::$types[$this->contrib->contrib_type]->use_queue ? true : false, 'S_NEW' => $this->revision_status == TITANIA_REVISION_NEW ? true : false, 'S_APPROVED' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'S_DENIED' => $this->revision_status == TITANIA_REVISION_DENIED ? true : false, 'S_PULLED_SECURITY' => $this->revision_status == TITANIA_REVISION_PULLED_SECURITY ? true : false, 'S_PULLED_OTHER' => $this->revision_status == TITANIA_REVISION_PULLED_OTHER ? true : false, 'S_REPACKED' => $this->revision_status == TITANIA_REVISION_REPACKED ? true : false, 'S_RESUBMITTED' => $this->revision_status == TITANIA_REVISION_RESUBMITTED ? true : false)); phpbb::$user->date_format = $old_date_format; // Output phpBB versions foreach ($ordered_phpbb_versions as $version) { phpbb::$template->assign_block_vars($tpl_block . '.phpbb_versions', array('VERSION' => $version)); } // Output translations if (sizeof($this->translations)) { $translations = new titania_attachment(TITANIA_TRANSLATION, $this->revision_id); $translations->store_attachments($this->translations); foreach ($translations->parse_attachments($message = false) as $attachment) { phpbb::$template->assign_block_vars($tpl_block . '.translations', array('DISPLAY_ATTACHMENT' => $attachment)); } } phpbb::$template->assign_var('ICON_EDIT', '<img src="' . titania::$images_path . 'icon_edit.gif" alt="' . phpbb::$user->lang['EDIT'] . '" title="' . phpbb::$user->lang['EDIT'] . '" />'); // Hooks titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $this, $tpl_block); }
break; default: if ($faq_id) { titania::page_header($faq->faq_subject . ' - ' . titania::$contrib->contrib_name); if ($faq->faq_access < titania::$access_level) { trigger_error('NOT_AUTHORISED'); } // increase a FAQ views counter $faq->increase_views_counter(); // tracking titania_tracking::track(TITANIA_FAQ, $faq_id); $message = $faq->generate_text_for_display(); // Grab attachments $attachments = new titania_attachment(TITANIA_FAQ, $faq->faq_id); $attachments->load_attachments(); $parsed_attachments = $attachments->parse_attachments($message); phpbb::$template->assign_vars(array('FAQ_SUBJECT' => $faq->faq_subject, 'FAQ_TEXT' => $message, 'FAQ_VIEWS' => $faq->faq_views, 'S_DETAILS' => true, 'S_ACCESS_TEAMS' => $faq->faq_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $faq->faq_access == TITANIA_ACCESS_AUTHORS ? true : false, 'U_EDIT_FAQ' => titania::$contrib->is_author || phpbb::$auth->acl_get('u_titania_faq_edit') ? $faq->get_url('edit') : false, 'U_CANONICAL' => $faq->get_url())); foreach ($parsed_attachments as $attachment) { phpbb::$template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } else { titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['FAQ_LIST']); titania::_include('functions_display', 'titania_topic_folder_img'); // Setup the sort tool $sort = new titania_sort(); $sort->set_url(titania::$contrib->get_url('faq')); $sort->set_defaults(phpbb::$config['topics_per_page']); $sort->request(); $faqs = array(); $sql_ary = array('SELECT' => 'f.*', 'FROM' => array(TITANIA_CONTRIB_FAQ_TABLE => 'f'), 'WHERE' => 'f.contrib_id = ' . titania::$contrib->contrib_id . ' AND f.faq_access >= ' . titania::$access_level, 'ORDER_BY' => 'f.left_id ASC');
/** * Quick Edit a post * * @param mixed $post_id */ public function quick_edit($post_id) { $submit = isset($_POST['submit']) ? true : false; $full_editor = isset($_POST['full_editor']) ? true : false; // AJAX output if (!$submit && !$full_editor) { phpbb::$user->add_lang('viewtopic'); // Load the stuff we need $post_object = $this->load_post($post_id); // Check permissions if (!$post_object->acl_get('edit')) { echo phpbb::$user->lang['NO_AUTH']; garbage_collection(); exit_handler(); } $post_message = $post_object->post_text; titania_decode_message($post_message, $post_object->post_text_uid); add_form_key('postform'); phpbb::$template->assign_vars(array('MESSAGE' => $post_message, 'U_QR_ACTION' => $post_object->get_url('quick_edit'))); phpbb::$template->set_filenames(array('quick_edit' => 'posting/quickedit_editor.html')); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); phpbb::$template->display('quick_edit'); garbage_collection(); exit_handler(); } if ($full_editor || !check_form_key('postform')) { $this->edit($post_id); return; } // Load the stuff we need $post_object = $this->load_post($post_id); // Check permissions if (!$post_object->acl_get('edit')) { titania::needs_auth(); } // Grab some data $for_edit = $post_object->generate_text_for_edit(); // Set the post text $post_object->post_text = utf8_normalize_nfc(request_var('message', '', true)); // Generate for storage based on previous options $post_object->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_urls'], $for_edit['allow_smilies']); // Submit $post_object->submit(); // Load attachments $attachments = new titania_attachment($post_object->post_type, $post_object->post_id); $attachments->load_attachments(); // Parse the mesage $message = $post_object->generate_text_for_display(); $parsed_attachments = $attachments->parse_attachments($message); // echo the message (returned to the JS to display in the place of the old message) echo $message; garbage_collection(); exit_handler(); }
/** * Display topic section for support/tracker/etc * * @param object $topic The topic object * @param titania_sort $sort The sort object (includes/tools/sort.php) */ public static function display_topic($topic, $sort = false) { if ($sort === false) { // Setup the sort tool $sort = self::build_sort(); } $sort->request(); $sql_ary = array('SELECT' => 'p.*', 'FROM' => array(TITANIA_POSTS_TABLE => 'p'), 'WHERE' => 'p.topic_id = ' . (int) $topic->topic_id . self::sql_permissions('p.'), 'ORDER_BY' => $sort->get_order_by()); // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 'p.post_id')) { // No results...no need to query more... return; } $sort->build_pagination($topic->get_url()); // Get the data $post_ids = $user_ids = array(); $last_post_time = 0; // tracking $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); while ($row = phpbb::$db->sql_fetchrow($result)) { self::$posts[$row['post_id']] = $row; self::$posts[$row['post_id']]['attachments'] = array(); $post_ids[] = $row['post_id']; $user_ids[] = $row['post_user_id']; $user_ids[] = $row['post_edit_user']; $user_ids[] = $row['post_delete_user']; $last_post_time = $row['post_time']; // to set tracking } phpbb::$db->sql_freeresult($result); // Grab the tracking data $last_mark_time = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id); // Store tracking data titania_tracking::track(TITANIA_TOPIC, $topic->topic_id, $last_post_time); // load the user data users_overlord::load($user_ids); phpbb::_include('functions_profile_fields', false, 'custom_profile'); $cp = new custom_profile(); $post = new titania_post($topic->topic_type, $topic); $attachments = new titania_attachment($topic->topic_type, false); // Grab all attachments $attachments_set = $attachments->load_attachments_set($post_ids); // Loop de loop $prev_post_time = 0; foreach ($post_ids as $post_id) { $post->__set_array(self::$posts[$post_id]); $attachments->clear_attachments(); if (isset($attachments_set[$post_id])) { $attachments->store_attachments($attachments_set[$post_id]); } // Parse attachments before outputting the message $message = $post->generate_text_for_display(); $parsed_attachments = $attachments->parse_attachments($message); // Prepare message text for use in javascript $message_decoded = censor_text($post->post_text); titania_decode_message($message_decoded, $post->post_text_uid); $message_decoded = bbcode_nl2br($message_decoded); // Build CP Fields $cp_row = array(); if (isset(users_overlord::$cp_fields[$post->post_user_id])) { $cp_row = $cp->generate_profile_fields_template('show', false, users_overlord::$cp_fields[$post->post_user_id]); } $cp_row['row'] = isset($cp_row['row']) && sizeof($cp_row['row']) ? $cp_row['row'] : array(); // Display edit info $display_username = get_username_string('full', $post->post_user_id, users_overlord::get_user($post->post_user_id, 'username'), users_overlord::get_user($post->post_user_id, 'user_colour'), false, phpbb::append_sid('memberlist', 'mode=viewprofile')); $l_edited_by = $post->post_edit_time ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], $display_username, phpbb::$user->format_date($post->post_edit_time)) : ''; phpbb::$template->assign_block_vars('posts', array_merge($post->assign_details(false), users_overlord::assign_details($post->post_user_id), $cp_row['row'], array('POST_TEXT' => $message, 'POST_TEXT_DECODED' => $message_decoded, 'EDITED_MESSAGE' => $l_edited_by, 'U_MINI_POST' => titania_url::append_url($topic->get_url(), array('p' => $post_id, '#p' => $post_id)), 'MINI_POST_IMG' => $post->post_time > $last_mark_time ? phpbb::$user->img('icon_post_target_unread', 'NEW_POST') : phpbb::$user->img('icon_post_target', 'POST'), 'S_FIRST_UNREAD' => $post->post_time > $last_mark_time && $prev_post_time <= $last_mark_time ? true : false))); // Output CP Fields if (!empty($cp_row['blockrow'])) { foreach ($cp_row['blockrow'] as $field_data) { phpbb::$template->assign_block_vars('posts.custom_fields', $field_data); } } //S_IGNORE_POST //POST_ICON_IMG //MINI_POST_IMG foreach ($parsed_attachments as $attachment) { phpbb::$template->assign_block_vars('posts.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } $prev_post_time = $post->post_time; } unset($post, $attachments); // Increment the topic view count $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET topic_views = topic_views + 1 WHERE topic_id = ' . (int) $topic->topic_id; phpbb::$db->sql_query($sql); }