/** * Repack a revision * * @param titania_revision $old_revision titania_revision object */ public function repack($old_revision) { if (!$this->revision_id) { throw new exception('Submit the revision before repacking'); } titania::add_lang('manage'); // Get the old and new queue objects $old_queue = $old_revision->get_queue(); $queue = $this->get_queue(); if ($old_queue === false) { throw new exception('Old queue missing. Revision ID: ' . $old_revision->revision_id); } // Reply to the queue topic to say that it's been repacked and have the old mpv/automod results listed in it as well $repack_message = phpbb::$user->lang['REVISION_REPACKED'] . "\n\n"; // Add the MPV results if ($old_queue->mpv_results) { $mpv_results = $old_queue->mpv_results; titania_decode_message($mpv_results, $old_queue->mpv_results_uid); $repack_message .= '[quote="' . phpbb::$user->lang['OLD_VALIDATION_MPV'] . '"]' . $mpv_results . "[/quote]\n"; } // Add the Automod results if ($old_queue->automod_results) { $repack_message .= '[quote="' . phpbb::$user->lang['OLD_VALIDATION_AUTOMOD'] . '"]' . $old_queue->automod_results . "[/quote]\n"; } // Reply $old_queue->topic_reply($repack_message); // Update the old queue with the new results $old_queue->revision_id = $queue->revision_id; $old_queue->mpv_results = $queue->mpv_results; $old_queue->mpv_results_bitfield = $queue->mpv_results_bitfield; $old_queue->mpv_results_uid = $queue->mpv_results_uid; $old_queue->automod_results = $queue->automod_results; $old_queue->submit(); // Delete the new queue we made for this revision $queue->delete(); // Unlink the old queue_id from the old revision and set it to repacked $old_revision->change_status(TITANIA_REVISION_REPACKED); $old_revision->revision_queue_id = 0; $old_revision->submit(); // Update the queue_id for this revision to point to the old queue_id $this->revision_queue_id = $old_queue->queue_id; $this->submit(); // Move any translations $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . ' SET object_id = ' . $this->revision_id . ' WHERE object_type = ' . TITANIA_TRANSLATION . ' AND object_id = ' . $old_revision->revision_id; phpbb::$db->sql_query($sql); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); }
function phpbb_com_titania_post_edit($hook, &$post_object) { if (defined('IN_TITANIA_CONVERT') || !$post_object->phpbb_post_id) { return; } $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->post_type); if (!$forum_id) { return; } titania::_include('functions_posting', 'phpbb_posting'); $post_text = $post_object->post_text; titania_decode_message($post_text, $post_object->post_text_uid); $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url()); $options = array('post_id' => $post_object->phpbb_post_id, 'topic_title' => $post_object->post_subject, 'post_text' => $post_text); phpbb_posting('edit', $options); }
/** * 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); }
/** * Update the release topic for this contribution */ public function update_release_topic() { if (titania_types::$types[$this->contrib_type]->forum_robot && titania_types::$types[$this->contrib_type]->forum_database && titania_types::$types[$this->contrib_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; } $phpbb_version = $this->revisions[$this->download['revision_id']]['phpbb_versions'][0]; $contrib_description = $this->contrib_desc; titania_decode_message($contrib_description, $this->contrib_desc_uid); // Global body and options $body = sprintf(phpbb::$user->lang[titania_types::$types[$this->contrib_type]->create_public], $this->contrib_name, titania_url::remove_sid($this->author->get_url()), users_overlord::get_user($this->author->user_id, '_username'), $contrib_description, $this->download['revision_version'], titania_url::build_clean_url('download', array('id' => $this->download['attachment_id'])), $this->download['real_filename'], $this->download['filesize'], titania_url::remove_sid($this->get_url()), titania_url::remove_sid($this->get_url('support')), $phpbb_version['phpbb_version_branch'][0] . '.' . $phpbb_version['phpbb_version_branch'][1] . '.' . $phpbb_version['phpbb_version_revision']); $options = array('poster_id' => titania_types::$types[$this->contrib_type]->forum_robot, 'forum_id' => titania_types::$types[$this->contrib_type]->forum_database); if ($this->contrib_release_topic_id) { // We edit the first post of contrib release topic $options_edit = array('topic_id' => $this->contrib_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); $this->contrib_release_topic_id = phpbb_posting('post', $options_post); $sql = 'UPDATE ' . $this->sql_table . ' SET contrib_release_topic_id = ' . $this->contrib_release_topic_id . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); } } }
/** * Send the approve/deny notification */ private function send_approve_deny_notification($approve = true) { titania::add_lang('manage'); phpbb::_include('functions_privmsgs', 'submit_pm'); // Generate the authors list to send it to $authors = array($this->submitter_user_id => 'to'); $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . ' WHERE contrib_id = ' . (int) $this->contrib_id . ' AND active = 1'; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $authors[$row['user_id']] = 'to'; } phpbb::$db->sql_freeresult($result); // Need some stuff $contrib = new titania_contribution(); $contrib->load((int) $this->contrib_id); $revision = new titania_revision($contrib, $this->revision_id); $revision->load(); // Subject $subject = sprintf(phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->validation_subject], $contrib->contrib_name, $revision->revision_version); // Message $notes = $this->queue_validation_notes; titania_decode_message($notes, $this->queue_validation_notes_uid); if ($approve) { $message = titania_types::$types[$contrib->contrib_type]->validation_message_approve; } else { $message = titania_types::$types[$contrib->contrib_type]->validation_message_deny; } $message = sprintf(phpbb::$user->lang[$message], $notes); // Replace empty quotes if there are no notes if (!$notes) { $message = str_replace('[quote][/quote]', phpbb::$user->lang['NO_NOTES'], $message); } // Parse the message $message_uid = $message_bitfield = $message_options = false; generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true); $data = array('address_list' => array('u' => $authors), 'from_user_id' => phpbb::$user->data['user_id'], 'from_username' => phpbb::$user->data['username'], 'icon_id' => 0, 'from_user_ip' => phpbb::$user->ip, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $message, 'bbcode_bitfield' => $message_bitfield, 'bbcode_uid' => $message_uid); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $data, $this); // Submit Plz submit_pm('post', $subject, $data, false); }
/** * Parse text for edit * * @return array of the items to be used in the message parser class */ public function generate_text_for_edit() { // Add the object type and object id $for_edit = array('object_type' => is_string($this->object_type) && isset($this->{$this->object_type}) ? $this->{$this->object_type} : $this->object_type, 'object_id' => $this->{$this->sql_id_field}); $message = $message_uid = $message_bitfield = $message_options = false; $this->get_message_fields($message, $message_uid, $message_bitfield, $message_options); titania_decode_message($message, $message_uid); $for_edit = array_merge($for_edit, array('allow_bbcode' => $message_options & OPTION_FLAG_BBCODE ? 1 : 0, 'allow_smilies' => $message_options & OPTION_FLAG_SMILIES ? 1 : 0, 'allow_urls' => $message_options & OPTION_FLAG_LINKS ? 1 : 0, 'text' => $message, 'message' => $message)); // Add any of the marked fields to the array foreach ($this->object_config as $field => $options) { if (isset($options['message_field'])) { $for_edit[$options['message_field']] = $this->{$field}; } } return $for_edit; }