public function delete() { // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); // Delete the queue item $queue = $this->get_queue(); if ($queue !== false) { $queue->delete(); } // Delete the attachment $attachment = new titania_attachment(TITANIA_CONTRIB); $attachment->attachment_id = $this->attachment_id; $attachment->load(); $attachment->delete(); // Delete translations // $translations = new titania_attachment(TITANIA_TRANSLATION, $this->revision_id); // $attachment->delete_all(); // Self-destruct parent::delete(); }
titania::$contrib->load(utf8_normalize_nfc(request_var('c', '', true))); // Reload the contrib (to make sure the authors list is updated) $submit = false; // Set submit as false to keep the main stuff from being resubmitted again redirect(titania::$contrib->get_url()); } } /** * ---------------------------- Main Page ---------------------------- */ // Load the message object $message = new titania_message(titania::$contrib); $message->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'), 'edit_subject' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate'))); $message->set_settings(array('display_error' => false, 'display_subject' => false, 'subject_name' => 'name')); // Screenshots $screenshot = new titania_attachment(TITANIA_SCREENSHOT, titania::$contrib->contrib_id); $screenshot->load_attachments(); $screenshot->upload(175); $error = array_merge($error, $screenshot->error); if ($screenshot->uploaded || isset($_POST['preview']) || $submit) { titania::$contrib->post_data($message); titania::$contrib->__set_array(array('contrib_demo' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? $contrib_demo : titania::$contrib->contrib_demo, 'contrib_local_name' => utf8_normalize_nfc(request_var('contrib_local_name', '', true)), 'contrib_iso_code' => request_var('contrib_iso_code', ''))); } if (isset($_POST['preview'])) { $message->preview(); } else { if ($submit) { // Handle the deletion routine if (isset($_POST['delete']) && phpbb::$auth->acl_get('u_titania_admin')) { titania::$contrib->delete(); redirect(titania_url::build_url(''));
/** * 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(); }
load_contrib(); // Editing a revision can only be done by moderators if (!titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) { titania::needs_auth(); } // Setup some variables $revision_id = request_var('revision', 0); $error = $revision_phpbb_versions = array(); $phpbb_versions = titania::$cache->get_phpbb_versions(); // Load the revision $revision = new titania_revision(titania::$contrib, $revision_id); if (!$revision->load()) { trigger_error('NO_REVISION'); } // Translations $translation = new titania_attachment(TITANIA_TRANSLATION, $revision_id); $translation->load_attachments(); $translation->upload(); $error = array_merge($error, $translation->error); // Revision phpBB versions $revision->load_phpbb_versions(); foreach ($revision->phpbb_versions as $row) { $revision_phpbb_versions[] = $phpbb_versions[$row['phpbb_version_branch'] . $row['phpbb_version_revision']]; } // Revision Status $revision_status = request_var('revision_status', (int) $revision->revision_status); $status_list = array(TITANIA_REVISION_NEW => 'REVISION_NEW', TITANIA_REVISION_APPROVED => 'REVISION_APPROVED', TITANIA_REVISION_DENIED => 'REVISION_DENIED', TITANIA_REVISION_PULLED_SECURITY => 'REVISION_PULLED_FOR_SECURITY', TITANIA_REVISION_PULLED_OTHER => 'REVISION_PULLED_FOR_OTHER', TITANIA_REVISION_REPACKED => 'REVISION_REPACKED', TITANIA_REVISION_RESUBMITTED => 'REVISION_RESUBMITTED'); if ($translation->uploaded || isset($_POST['submit'])) { $revision_license = utf8_normalize_nfc(request_var('revision_license', '', true)); $revision->__set_array(array('revision_name' => utf8_normalize_nfc(request_var('revision_name', $revision->revision_name, true)), 'revision_license' => $revision_license != phpbb::$user->lang['CUSTOM_LICENSE'] ? $revision_license : utf8_normalize_nfc(request_var('revision_custom_license', '', true)))); // Stuff that can be done by moderators only
// Load the message object $message = new titania_message(titania::$contrib); $message->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'), 'edit_subject' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate'))); $message->set_settings(array('display_error' => false, 'display_subject' => false, 'subject_name' => 'name')); // Screenshots $screenshot = new titania_attachment(TITANIA_SCREENSHOT, titania::$contrib->contrib_id); $screenshot->load_attachments(); $screenshot->upload(175); $error = array_merge($error, $screenshot->error); if ($screenshot->uploaded || isset($_POST['preview']) || $submit) { titania::$contrib->post_data($message); titania::$contrib->__set_array(array('contrib_demo' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? $contrib_demo : titania::$contrib->contrib_demo, 'contrib_local_name' => utf8_normalize_nfc(request_var('contrib_local_name', '', true)), 'contrib_iso_code' => request_var('contrib_iso_code', ''))); } // ColorizeIt sample if (strlen(titania::$config->colorizeit) && titania_types::$types[titania::$contrib->contrib_type]->acl_get('colorizeit')) { $clr_sample = new titania_attachment(TITANIA_CLR_SCREENSHOT, titania::$contrib->contrib_id); $clr_sample->load_attachments(); $clr_sample->upload(); $error = array_merge($error, $clr_sample->error); if ($clr_sample->uploaded || isset($_POST['preview']) || $submit) { titania::$contrib->post_data($message); } } if (isset($_POST['preview'])) { $message->preview(); } else { if ($submit) { // Handle the deletion routine if (isset($_POST['delete']) && phpbb::$auth->acl_get('u_titania_admin')) { titania::$contrib->delete(); redirect(titania_url::build_url(''));
titania::$contrib->author->load(); // Set some main vars up $submit = isset($_POST['submit']) ? true : false; $contrib_categories = request_var('contrib_category', array(0)); $contrib_iso_code = request_var('contrib_iso_code', ''); $contrib_local_name = utf8_normalize_nfc(request_var('contrib_local_name', '', true)); $contrib_demo = utf8_normalize_nfc(request_var('demo_url', '', true)); $active_coauthors = $active_coauthors_list = utf8_normalize_nfc(request_var('active_coauthors', '', true)); $nonactive_coauthors = $nonactive_coauthors_list = utf8_normalize_nfc(request_var('nonactive_coauthors', '', true)); $error = array(); // Load the message object $message = new titania_message(titania::$contrib); $message->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'))); $message->set_settings(array('display_error' => false, 'display_subject' => false, 'subject_name' => 'name')); // Screenshots $screenshot = new titania_attachment(TITANIA_SCREENSHOT, titania::$contrib->contrib_id); $screenshot->load_attachments(); $screenshot->upload(175); $error = array_merge($error, $screenshot->error); if ($screenshot->uploaded || isset($_POST['preview']) || $submit) { titania::$contrib->post_data($message); titania::$contrib->__set_array(array('contrib_type' => request_var('contrib_type', 0), 'contrib_name_clean' => utf8_normalize_nfc(request_var('permalink', '', true)), 'contrib_visible' => 1, 'contrib_demo' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? $contrib_demo : titania::$contrib->contrib_demo, 'contrib_iso_code' => $contrib_iso_code, 'contrib_local_name' => $contrib_local_name)); } if (isset($_POST['preview'])) { $message->preview(); } else { if ($submit) { $error = array_merge($error, titania::$contrib->validate($contrib_categories)); if (($validate_form_key = $message->validate_form_key()) !== false) { $error[] = $validate_form_key; }
$faq->move($row, $action, 1); redirect(titania::$contrib->get_url('faq')); 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();
/** * 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); }
/*$allowed_branches = get_allowed_phpbb_branches(); foreach ($phpbb_versions as $version => $name) { if (!isset($allowed_branches[substr($version, 0, 2)])) { continue; } $template->assign_block_vars('phpbb_versions', array( 'VERSION' => $name, 'S_SELECTED' => (in_array($name, $revision_phpbb_versions)) ? true : false, )); }*/ // Display the main page if ($display_main || sizeof($error)) { if (sizeof($error)) { if ($revision_attachment !== false) { $revision_attachment->delete(); } if ($revision !== false) { $revision->delete(); } } $revision_attachment = new titania_attachment(TITANIA_CONTRIB, titania::$contrib->contrib_id); phpbb::$template->assign_vars(array('REVISION_NAME' => utf8_normalize_nfc(request_var('revision_name', '', true)), 'REVISION_VERSION' => utf8_normalize_nfc(request_var('revision_version', '', true)), 'REVISION_LICENSE' => utf8_normalize_nfc(request_var('revision_license', '', true)), 'REVISION_CUSTOM_LICENSE' => utf8_normalize_nfc(request_var('revision_custom_license', '', true)), 'QUEUE_ALLOW_REPACK' => request_var('queue_allow_repack', 0), 'NEXT_STEP' => 1, 'S_CUSTOM_LICENSE' => utf8_normalize_nfc(request_var('revision_license', '', true)) == phpbb::$user->lang['CUSTOM_LICENSE'] ? true : false, 'S_ALLOW_CUSTOM_LICENSE' => titania_types::$types[titania::$contrib->contrib_type]->license_allow_custom ? true : false)); // Assign separately so we can output some data first phpbb::$template->assign_var('REVISION_UPLOADER', $revision_attachment->parse_uploader('posting/attachments/revisions.html')); } add_form_key('postform'); titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['NEW_REVISION']); titania::page_footer(true, 'contributions/contribution_revision.html');
$revision_id = request_var('revision', 0); titania::add_lang('contributions'); // Get the revision, contribution, attachment, and queue $revision = new titania_revision(false, $revision_id); if (!$revision->load()) { trigger_error('NO_REVISION'); } $contrib = new titania_contribution(); if (!$contrib->load($revision->contrib_id)) { trigger_error('CONTRIB_NOT_FOUND'); } $revision->contrib = $contrib; if (!titania_types::$types[$contrib->contrib_type]->acl_get('view')) { titania::needs_auth(); } $revision_attachment = new titania_attachment(TITANIA_CONTRIB); $revision_attachment->attachment_id = $revision->attachment_id; if (!$revision_attachment->load()) { trigger_error('ERROR_NO_ATTACHMENT'); } $queue = $revision->get_queue(); $zip_file = titania::$config->upload_path . '/' . utf8_basename($revision_attachment->attachment_directory) . '/' . utf8_basename($revision_attachment->physical_filename); $download_package = titania_url::build_url('download', array('id' => $revision_attachment->attachment_id)); if ($action == 'mpv') { // Start up the machine $contrib_tools = new titania_contrib_tools($zip_file); // Run MPV $mpv_results = $contrib_tools->mpv($download_package); if ($mpv_results === false) { // Too lazy to write another one...teams only anyways trigger_error('MPV_TEST_FAILED');
/** * Check if ColorizeIt is available */ public function has_colorizeit($force_update = false) { if ($force_update || $this->clr_sample === false) { // get sample id from database $attachment = new titania_attachment(TITANIA_CLR_SCREENSHOT, $this->contrib_id); $this->clr_sample = $attachment->get_preview(); } return is_array($this->clr_sample) && strlen($this->contrib_clr_colors) > 0; }