/** * Send the approve/deny notification */ private function send_approve_deny_notification($approve = true) { $this->user->add_lang_ext('phpbb/titania', 'manage'); phpbb::_include('functions_privmsgs', 'submit_pm'); // Need some stuff $contrib = new titania_contribution(); $contrib->load((int) $this->contrib_id); $revision = new titania_revision($contrib, $this->revision_id); $revision->load(); // Generate the authors list to send it to $authors = array($contrib->contrib_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); // Subject $subject = sprintf(phpbb::$user->lang[$contrib->type->validation_subject], $contrib->contrib_name, $revision->revision_version); // Message $notes = $this->validation_notes; message::decode($notes, $this->validation_notes_uid); if ($approve) { $message = $contrib->type->validation_message_approve; } else { $message = $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, true); }
/** * Quick Edit a post * * @param int $post_id * @return JsonResponse * @throws http_exception Throws http_exception when form token is invalid. */ public function quick_edit($post_id) { if ($this->request->header('X-PHPBB-USING-PLUPLOAD', false)) { return $this->edit($post_id); } $submit = $this->request->is_set_post('submit'); $full_editor = $this->request->is_set_post('full_editor'); // AJAX output if (!$submit && !$full_editor) { $this->user->add_lang('viewtopic'); // Load the stuff we need $post = $this->load_post($post_id); // Check permissions $this->quick_edit_auth_check($post); $post_message = $post->post_text; message::decode($post_message, $post->post_text_uid); add_form_key('postform'); $this->template->assign_vars(array('SUBJECT' => $post->post_subject, 'MESSAGE' => $post_message, 'U_QR_ACTION' => $post->get_url('quick_edit')))->set_filenames(array('quick_edit' => 'posting/quickedit_editor.html')); return new JsonResponse(array('form' => $this->template->assign_display('quick_edit'))); } if ($full_editor) { return $this->edit($post_id); } // Load the stuff we need $post = $this->load_post($post_id); // Check permissions $this->quick_edit_auth_check($post); if (!check_form_key('postform')) { throw new http_exception(200, 'FORM_INVALID'); } // Grab some data $for_edit = $post->generate_text_for_edit(); // Set the post text $post->post_subject = $this->request->variable('subject', '', true); $post->post_text = $this->request->variable('message', '', true); // Generate for storage based on previous options $post->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_urls'], $for_edit['allow_smilies']); // If u_titania_mod_post_mod permission then no edit info // Update edit info if user is editing his post, which is not the last within the topic. if (!$this->auth->acl_get('u_titania_mod_post_mod') && $post->topic->topic_last_post_id != $post->post_id) { $post->post_edit_time = time(); $post->post_edit_user = $this->user->data['user_id']; } // Submit $post->submit(); // Parse the message $message = $post->generate_text_for_display(); // Parse attachments $this->attachments->configure($post->post_type, $post->post_id)->load()->parse_attachments($message); return new JsonResponse(array('subject' => censor_text($post->post_subject), 'message' => $message)); }
/** * 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); } } } }
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'); $path_helper = phpbb::$container->get('path_helper'); $post_text = $post_object->post_text; phpbb_com_handle_attachments($post_object, $post_text); message::decode($post_text, $post_object->post_text_uid); $post_text .= "\n\n" . $path_helper->strip_url_params($post_object->get_url(), 'sid'); $options = array('post_id' => $post_object->phpbb_post_id, 'topic_title' => $post_object->post_subject, 'post_text' => $post_text); phpbb_posting('edit', $options); }
/** * Display topic section for support/tracker/etc * * @param object $topic The topic object * @param \phpbb\titania\sort $sort The sort object */ public static function display_topic($topic, $sort = false) { $tracking = phpbb::$container->get('phpbb.titania.tracking'); if ($sort === false) { // Setup the sort tool $sort = self::build_sort(); } $sort->request(); $total_posts = $topic->get_postcount(); // Make sure the start parameter falls within the post count limit if ($total_posts <= $sort->start) { $sort->start = (ceil($total_posts / $sort->limit) - 1) * $sort->limit; } $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; } $topic_action = isset($sort->url_parameters['action']) ? $sort->url_parameters['action'] : false; unset($sort->url_parameters['action']); $sort->build_pagination($topic->get_url($topic_action)); // 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 = $tracking->get_track(TITANIA_TOPIC, $topic->topic_id); // Store tracking data $tracking->track(TITANIA_TOPIC, $topic->topic_id, $last_post_time); // load the user data users_overlord::load($user_ids); $cp = phpbb::$container->get('profilefields.manager'); $post = new titania_post($topic->topic_type, $topic); $attachments = phpbb::$container->get('phpbb.titania.attachment.operator'); // Grab all attachments $attachments_set = $attachments->configure($topic->topic_type, false)->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_all(); if (isset($attachments_set[$post_id])) { $attachments->store($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); message::decode($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_data(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' => $topic->get_url(false, 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))); $contact_fields = array(array('ID' => 'pm', 'NAME' => phpbb::$user->lang['SEND_PRIVATE_MESSAGE'], 'U_CONTACT' => users_overlord::get_user($post->post_user_id, '_u_pm')), array('ID' => 'email', 'NAME' => phpbb::$user->lang['SEND_EMAIL'], 'U_CONTACT' => users_overlord::get_user($post->post_user_id, '_u_email')), array('ID' => 'jabber', 'NAME' => phpbb::$user->lang['JABBER'], 'U_CONTACT' => users_overlord::get_user($post->post_user_id, '_jabber'))); foreach ($contact_fields as $field) { if ($field['U_CONTACT']) { phpbb::$template->assign_block_vars('posts.contact', $field); } } // 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); if ($field_data['S_PROFILE_CONTACT']) { phpbb::$template->assign_block_vars('posts.contact', array('ID' => $field_data['PROFILE_FIELD_IDENT'], 'NAME' => $field_data['PROFILE_FIELD_NAME'], 'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'])); } } } //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); }
/** * 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); message::decode($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; }
/** * Repack a revision * * @param titania_revision $old_revision titania_revision object * @param titania_queue $old_queue Old queue object */ public function repack($old_revision, $old_queue) { if (!$this->revision_id) { throw new exception('Submit the revision before repacking'); } $this->user->add_lang_ext('phpbb/titania', 'manage'); // Get the old and new queue objects $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 ($queue->mpv_results) { message::decode($queue->mpv_results, $queue->mpv_results_uid); $repack_message .= '[quote="' . $this->user->lang['VALIDATION_PV'] . '"]' . $queue->mpv_results . "[/quote]\n"; } // Add the Automod results if ($queue->automod_results) { $repack_message .= '[quote="' . phpbb::$user->lang['VALIDATION_AUTOMOD'] . '"]' . $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->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); }