Exemple #1
0
 /**
  * Quick load a post
  *
  * @param int $post_id
  * @return \titania_post
  * @throws \OutOfBoundsException	Throws exception if the post does not exist.
  */
 public function load_post($post_id)
 {
     $post = new \titania_post();
     $post->post_id = $post_id;
     if ($post->load() === false) {
         throw new \OutOfBoundsException($this->user->lang('NO_POST'));
     }
     $post->topic = $this->load_topic($post->topic_id);
     return $post;
 }
Exemple #2
0
    public function posts($mode, $start = false, $limit = false)
    {
        switch ($mode) {
            case 'index':
                $data = array();
                $post = new titania_post();
                $sql = 'SELECT p.*, t.topic_id, t.topic_type, t.topic_subject_clean, t.parent_id
					FROM ' . TITANIA_POSTS_TABLE . ' p, ' . TITANIA_TOPICS_TABLE . ' t
					WHERE t.topic_id = p.topic_id
					ORDER BY p.post_id ASC';
                if ($start === false || $limit === false) {
                    $result = phpbb::$db->sql_query($sql);
                } else {
                    $result = phpbb::$db->sql_query_limit($sql, (int) $limit, (int) $start);
                }
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $post->__set_array($row);
                    $post->topic->__set_array($row);
                    $data[] = array('object_type' => $post->post_type, 'object_id' => $post->post_id, 'parent_id' => $post->topic->parent_id, 'title' => $post->post_subject, 'text' => $post->post_text, 'text_uid' => $post->post_text_uid, 'text_bitfield' => $post->post_text_bitfield, 'text_options' => $post->post_text_options, 'author' => $post->post_user_id, 'date' => $post->post_time, 'url' => titania_url::unbuild_url($post->get_url()), 'approved' => $post->post_approved, 'access_level' => $post->post_access);
                }
                phpbb::$db->sql_freeresult($result);
                titania_search::mass_index($data);
                break;
        }
    }
Exemple #3
0
    /**
     * Get the queue discussion topic or create one if needed
     *
     * @param bool $check_only Return false if topic does not exist instead of creating it
     *
     * @return titania_topic object
     */
    public function get_queue_discussion_topic($check_only = false)
    {
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE parent_id = ' . $this->contrib_id . '
				AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if ($row) {
            $topic = new titania_topic();
            $topic->__set_array($row);
            $this->queue_discussion_topic_id = $topic->topic_id;
            return $topic;
        } else {
            if ($check_only) {
                return false;
            }
        }
        // No queue discussion topic...so we must create one
        $this->user->add_lang_ext('phpbb/titania', 'posting');
        $contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
        $post = new titania_post(TITANIA_QUEUE_DISCUSSION);
        $post->topic->__set_array(array('parent_id' => $this->contrib_id, 'topic_category' => $contrib->contrib_type, 'topic_url' => serialize(array('contrib_type' => $contrib->type->url, 'contrib' => $contrib->contrib_name_clean)), 'topic_sticky' => true));
        $post->__set_array(array('post_access' => access::AUTHOR_LEVEL, 'post_subject' => sprintf(phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_TITLE'], $contrib->contrib_name), 'post_text' => phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_MESSAGE']));
        $post->generate_text_for_storage(true, true, true);
        $post->submit();
        $this->queue_discussion_topic_id = $post->topic->topic_id;
        return $post->topic;
    }
/**
* Copy new posts for queue discussion, queue to the forum
*/
function phpbb_com_titania_queue_update_first_queue_post($hook, &$post_object, $queue_object)
{
    if ($queue_object->queue_status == TITANIA_QUEUE_HIDE || !$queue_object->queue_topic_id) {
        return;
    }
    // First we copy over the queue discussion topic if required
    $sql = 'SELECT topic_id, phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE parent_id = ' . $queue_object->contrib_id . '
			AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
    $result = phpbb::$db->sql_query($sql);
    $topic_row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    // Do we need to create the queue discussion topic or not?
    if ($topic_row['topic_id'] && !$topic_row['phpbb_topic_id']) {
        $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, TITANIA_QUEUE_DISCUSSION);
        $temp_post = new titania_post();
        // Go through any posts in the queue discussion topic and copy them
        $topic_id = false;
        $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $topic_row['topic_id'];
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $temp_post->__set_array($row);
            $post_text = $row['post_text'];
            titania_decode_message($post_text, $row['post_text_uid']);
            $post_text .= "\n\n" . titania_url::remove_sid($temp_post->get_url());
            $options = array('poster_id' => $row['post_user_id'], 'forum_id' => $forum_id, 'topic_title' => $row['post_subject'], 'post_text' => $post_text);
            titania::_include('functions_posting', 'phpbb_posting');
            if ($topic_id) {
                $options = array_merge($options, array('topic_id' => $topic_id));
                phpbb_posting('reply', $options);
            } else {
                switch ($topic_row['topic_category']) {
                    case TITANIA_TYPE_MOD:
                        $options['poster_id'] = titania::$config->forum_mod_robot;
                        break;
                    case TITANIA_TYPE_STYLE:
                        $options['poster_id'] = titania::$config->forum_style_robot;
                        break;
                }
                $topic_id = phpbb_posting('post', $options);
            }
        }
        phpbb::$db->sql_freeresult($result);
        if ($topic_id) {
            $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
				SET phpbb_topic_id = ' . $topic_id . '
				WHERE topic_id = ' . $topic_row['topic_id'];
            phpbb::$db->sql_query($sql);
        }
        unset($temp_post);
    }
    // Does a queue topic already exist?  If so, don't repost.
    $sql = 'SELECT phpbb_topic_id FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . $queue_object->queue_topic_id;
    phpbb::$db->sql_query($sql);
    $phpbb_topic_id = phpbb::$db->sql_fetchfield('phpbb_topic_id');
    phpbb::$db->sql_freeresult();
    if ($phpbb_topic_id) {
        return;
    }
    $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->topic->topic_type);
    if (!$forum_id) {
        return;
    }
    $post_object->submit();
    titania::_include('functions_posting', 'phpbb_posting');
    // Need some stuff
    titania::add_lang('contributions');
    $contrib = new titania_contribution();
    $contrib->load((int) $queue_object->contrib_id);
    $revision = $queue_object->get_revision();
    $contrib->get_download($revision->revision_id);
    switch ($post_object->topic->topic_category) {
        case TITANIA_TYPE_MOD:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_mod_robot;
            $lang_var = 'MOD_QUEUE_TOPIC';
            break;
        case TITANIA_TYPE_STYLE:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_style_robot;
            $lang_var = 'STYLE_QUEUE_TOPIC';
            break;
        default:
            return;
            break;
    }
    $description = $contrib->contrib_desc;
    titania_decode_message($description, $contrib->contrib_desc_uid);
    $post_text = sprintf(phpbb::$user->lang[$lang_var], $contrib->contrib_name, $contrib->author->get_url(), users_overlord::get_user($contrib->author->user_id, '_username'), $description, $revision->revision_version, titania_url::build_url('download', array('id' => $revision->attachment_id)), $contrib->download['real_filename'], $contrib->download['filesize']);
    $post_text .= "\n\n" . $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('poster_id' => $post_object->topic->topic_first_post_user_id, 'forum_id' => $forum_id, 'topic_title' => $post_object->topic->topic_subject, 'post_text' => $post_text);
    $topic_id = phpbb_posting('post', $options);
    $post_object->topic->phpbb_topic_id = $topic_id;
    $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
		SET phpbb_topic_id = ' . (int) $topic_id . '
		WHERE topic_id = ' . $post_object->topic->topic_id;
    phpbb::$db->sql_query($sql);
}
Exemple #5
0
     }
     $message_object->display();
     // Common stuff
     phpbb::$template->assign_vars(array('S_POST_ACTION' => titania_url::$current_page_url, 'L_POST_A' => phpbb::$user->lang['EDIT_VALIDATION_NOTES']));
     titania::page_header('EDIT_VALIDATION_NOTES');
     titania::page_footer(true, 'manage/queue_post.html');
     break;
 case 'rebuild':
     $queue = queue_overlord::get_queue_object($queue_id, true);
     $queue->update_first_queue_post();
     redirect(titania_url::append_url($base_url, array('q' => $queue->queue_id)));
     break;
 case 'allow_author_repack':
     $queue = queue_overlord::get_queue_object($queue_id, true);
     $topic = $queue->get_queue_discussion_topic();
     $post = new titania_post(TITANIA_QUEUE_DISCUSSION, $topic);
     $post->__set_array(array('post_subject' => 'Re: ' . $post->topic->topic_subject));
     // Load the message object
     $message_object = new titania_message($post);
     $message_object->set_auth(array('bbcode' => true, 'smilies' => true));
     $message_object->set_settings(array('display_subject' => false));
     // Submit check...handles running $post->post_data() if required
     $submit = $message_object->submit_check();
     if ($submit) {
         $queue->allow_author_repack = true;
         $contrib = contribs_overlord::get_contrib_object($queue->contrib_id, true);
         $for_edit = $post->generate_text_for_edit();
         $post->post_text = $for_edit['message'] . "\n\n[url=" . titania_url::append_url($contrib->get_url('revision'), array('repack' => $queue->revision_id)) . ']' . phpbb::$user->lang['AUTHOR_REPACK_LINK'] . '[/url]';
         $post->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_smilies'], $for_edit['allow_urls']);
         $post->submit();
         $queue->submit();
Exemple #6
0
 /**
  * Allow author to repack revision action.
  *
  * @return null
  */
 protected function allow_author_repack()
 {
     $topic = $this->queue->get_queue_discussion_topic();
     $post = new \titania_post(TITANIA_QUEUE_DISCUSSION, $topic);
     $post->__set_array(array('post_subject' => 'Re: ' . $post->topic->topic_subject));
     // Load the message object
     $message_object = $this->get_message($post);
     // Submit check...handles running $post->post_data() if required
     $submit = $message_object->submit_check();
     if ($submit) {
         $this->queue->allow_author_repack = true;
         $repack_url = $this->contrib->get_url('revision', array('page' => 'repack', 'id' => $this->queue->revision_id));
         $for_edit = $post->generate_text_for_edit();
         $post->post_text = $for_edit['message'] . "\n\n\n\t\t\t\t[url=" . $repack_url . ']' . $this->user->lang['AUTHOR_REPACK_LINK'] . '[/url]';
         $post->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_smilies'], $for_edit['allow_urls']);
         $post->submit();
         $this->queue->submit();
         $this->queue->topic_reply('QUEUE_REPLY_ALLOW_REPACK');
         $this->queue->submit();
         redirect($this->queue->get_url());
     }
     $message_object->display();
     // Common stuff
     $this->template->assign_vars(array('S_POST_ACTION' => $this->helper->get_current_url(), 'L_POST_A' => $this->user->lang['DISCUSSION_REPLY_MESSAGE']));
     return $this->helper->render('manage/queue_post.html', 'DISCUSSION_REPLY_MESSAGE');
 }
Exemple #7
0
 /**
  * Quick load a post
  *
  * @param mixed $post_id
  * @return object
  */
 public function load_post($post_id)
 {
     $post = new titania_post();
     $post->post_id = $post_id;
     if ($post->load() === false) {
         trigger_error('NO_POST');
     }
     $post->topic = $this->load_topic($post->topic_id);
     return $post;
 }
					AND attention_object_type = ' . (int) $object_type . '
					AND attention_type = ' . ($close ? TITANIA_ATTENTION_REPORTED : TITANIA_ATTENTION_UNAPPROVED);
        }
        phpbb::$db->sql_query($sql);
    }
    add_form_key('attention');
    // Display the current attention items
    $options = array('attention_object_id' => $object_id);
    attention_overlord::display_attention_list($options);
    // Display the old (closed) attention items
    $options['only_closed'] = true;
    $options['template_block'] = 'attention_closed';
    attention_overlord::display_attention_list($options);
    switch ($object_type) {
        case TITANIA_POST:
            $post = new titania_post();
            $post->post_id = $object_id;
            if (!$post->load()) {
                $attention_object->delete();
                trigger_error('NO_POST');
            }
            // Close the report
            if ($close) {
                $post->post_reported = false;
                $post->submit();
                $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE . '
					WHERE topic_id = ' . $post->topic_id . '
						AND post_reported = 1';
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
                phpbb::$db->sql_freeresult();
Exemple #9
0
    /**
     * 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);
    }
Exemple #10
0
    /**
     * Sync posts.
     *
     * @param string $mode
     * @param int|bool $start	For indexing
     * @param int|bool $limit	For indexing
     */
    public function posts($mode, $start = false, $limit = false)
    {
        switch ($mode) {
            case 'index':
                $data = array();
                $post = new \titania_post();
                $sql = 'SELECT p.*, t.topic_id, t.topic_type, t.topic_subject_clean, t.parent_id, q.queue_type, c.contrib_type
					FROM ' . $this->posts_table . ' p, ' . $this->topics_table . ' t
					LEFT JOIN ' . TITANIA_QUEUE_TABLE . ' q
						ON (t.parent_id = q.queue_id AND t.topic_type = ' . TITANIA_QUEUE . ')
					LEFT JOIN ' . $this->contribs_table . ' c
						ON (t.parent_id = c.contrib_id AND t.topic_type <> ' . TITANIA_QUEUE . ')
					WHERE t.topic_id = p.topic_id
					ORDER BY p.post_id ASC';
                if ($start === false || $limit === false) {
                    $result = $this->db->sql_query($sql);
                } else {
                    $result = $this->db->sql_query_limit($sql, (int) $limit, (int) $start);
                }
                while ($row = $this->db->sql_fetchrow($result)) {
                    $post->__set_array($row);
                    $post->topic->__set_array($row);
                    $data[] = array('object_type' => $post->post_type, 'object_id' => $post->post_id, 'parent_id' => $post->topic->parent_id, 'title' => $post->post_subject, 'text' => $post->post_text, 'text_uid' => $post->post_text_uid, 'text_bitfield' => $post->post_text_bitfield, 'text_options' => $post->post_text_options, 'author' => $post->post_user_id, 'date' => $post->post_time, 'url' => serialize($post->get_url_params()), 'approved' => $post->post_approved, 'access_level' => $post->post_access, 'parent_contrib_type' => (int) ($post->post_type == TITANIA_QUEUE) ? $row['queue_type'] : $row['contrib_type']);
                }
                $this->db->sql_freeresult($result);
                $this->search_manager->mass_index($data);
                break;
        }
    }
function titania_move_topic($topic_id, $topic, $topic_type, $contrib_name = '', $revision_version = '')
{
    $post = false;
    // Convert the topics over from the phpBB forums
    if ($topic_id) {
        $sql = 'SELECT * FROM ' . POSTS_TABLE . '
			WHERE topic_id = ' . (int) $topic_id . '
			ORDER BY post_id ASC';
        $post_result = phpbb::$db->sql_query($sql);
        while ($post_row = phpbb::$db->sql_fetchrow($post_result)) {
            $post = new titania_post($topic_type, $topic);
            // Rewrite some URLs
            $contrib_view = 'http://www.phpbb.com/customise/db/contribution/$1/';
            $contrib_view_full = '<a class="postlink" href="' . $contrib_view . '">' . $contrib_view . '</a>';
            // Rewrite the full URLs
            $replace = array('#<a class="postlink" href="http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/index(?:\\.|&\\#46;)php\\?i=queue&amp;mode=overview&amp;contrib_id=([0-9]+)">.+</a>#', '#<a class="postlink" href="http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/index(?:\\.|&\\#46;)php\\?i=misc&amp;mode=display&amp;contrib_id=([0-9]+)">.+</a>#');
            $post_row['post_text'] = preg_replace($replace, $contrib_view_full, $post_row['post_text']);
            // Rewrite the unparsed URLs
            $replace = array('#http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/index(?:\\.|&\\#46;)php\\?i=queue&amp;mode=overview&amp;contrib_id=([0-9]+)#', '#http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/index(?:\\.|&\\#46;)php\\?i=misc&amp;mode=display&amp;contrib_id=([0-9]+)#');
            $post_row['post_text'] = preg_replace($replace, $contrib_view, $post_row['post_text']);
            // Rewrite the download URLs
            $replace = array('#<a class="postlink" href="http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/download/([0-9]+)/?">(.+)</a>#', '#<a class="postlink" href="http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/index(?:\\.|&\\#46;)php\\?i=misc&amp;mode=display&amp;download=1&amp;contrib_id=([0-9]+)">(.+)</a>#');
            $post_row['post_text'] = preg_replace($replace, '<a class="postlink" href="http://www.phpbb.com/customise/db/download/contrib_$1">$2</a>', $post_row['post_text']);
            $replace = array('#http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/download/([0-9]+)/?"#', '#http(?:\\:|&\\#58;)//www(?:\\.|&\\#46;)phpbb(?:\\.|&\\#46;)com/(?:styles|mods)/db/index(?:\\.|&\\#46;)php\\?i=misc&amp;mode=display&amp;download=1&amp;contrib_id=([0-9]+)#');
            $post_row['post_text'] = preg_replace($replace, 'http://www.phpbb.com/customise/db/download/contrib_$1', $post_row['post_text']);
            // Remove selected tags stuff (they are completely useless with Titania)
            $replace = "#\n\\[b:[a-z0-9]+\\]Selected tags:\\[/b:[a-z0-9]+\\]\n\\[list.+\\]\\[/list:o:[a-z0-9]+\\]\n#";
            $post_row['post_text'] = preg_replace($replace, '', $post_row['post_text']);
            $post_row['post_text'] = str_replace("===INT===", '', $post_row['post_text']);
            $post->__set_array(array('post_access' => $topic_type == TITANIA_QUEUE ? TITANIA_ACCESS_TEAMS : TITANIA_ACCESS_AUTHORS, 'post_user_id' => $post_row['poster_id'], 'post_ip' => $post_row['poster_ip'], 'post_time' => $post_row['post_time'], 'post_subject' => $post_row['post_subject'], 'post_text' => $post_row['post_text'], 'post_text_bitfield' => $post_row['bbcode_bitfield'], 'post_text_uid' => $post_row['bbcode_uid'], 'post_text_options' => ($post_row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($post_row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($post_row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0)));
            if ($topic_type == TITANIA_QUEUE_DISCUSSION) {
                $post->topic->topic_sticky = true;
            }
            $post->submit();
        }
        phpbb::$db->sql_freeresult($post_result);
    }
    // We didn't convert any posts?  (Local install perhaps?)
    if ($post === false && $contrib_name) {
        $post = new titania_post($topic_type, $topic);
        $post->__set_array(array('post_access' => TITANIA_ACCESS_TEAMS, 'post_subject' => phpbb::$user->lang['VALIDATION'] . ' - ' . $contrib_name . ' - ' . $revision_version, 'post_text' => 'Converted from Ariel'));
        switch ($post->topic->topic_category) {
            case TITANIA_TYPE_MOD:
                $post->post_user_id = titania::$config->forum_mod_robot;
                break;
            case TITANIA_TYPE_STYLE:
                $post->post_user_id = titania::$config->forum_style_robot;
                break;
        }
        $post->submit();
    }
}
Exemple #12
0
    /**
     * Acquire posts from another topic
     *
     * @param object $donor Object for topic where we'll be obtaining the posts from
     * @param array $post_ids Array of post id's that we want to acquire.
     * @param array $range Range of post times to transfer - array(min => (int), max => (int))
     */
    public function acquire_posts($donor, $post_ids, $range = false)
    {
        if (!$this->topic_id || empty($post_ids)) {
            return;
        }
        $sql_where = 'topic_id = ' . (int) $donor->topic_id . ' AND ';
        if (!empty($range)) {
            $sql_where .= 'post_time >= ' . (int) $range['min'] . ' AND post_time <= ' . (int) $range['max'];
        } else {
            $sql_where .= phpbb::$db->sql_in_set('post_id', $post_ids);
        }
        $sql = 'SELECT *
			FROM ' . TITANIA_POSTS_TABLE . '
			WHERE ' . $sql_where;
        $result = phpbb::$db->sql_query($sql);
        $posts = phpbb::$db->sql_fetchrowset($result);
        phpbb::$db->sql_freeresult($result);
        if (empty($posts)) {
            trigger_error('NO_POSTS');
        }
        // Update posts before resynchronizing topic
        $sql = 'UPDATE ' . TITANIA_POSTS_TABLE . '
			SET topic_id = ' . (int) $this->topic_id . ',
				post_url = "' . phpbb::$db->sql_escape($this->topic_url) . '",
				post_type = ' . (int) $this->topic_type . '
			WHERE ' . $sql_where;
        phpbb::$db->sql_query($sql);
        $new_post = new titania_post();
        $old_post = new titania_post();
        $new_post->topic = $this;
        $old_post->topic = $donor;
        $posters = array();
        // Reindex posts and update topic post counts
        foreach ($posts as $post_data) {
            if (!$post_data['post_deleted'] && $post_data['post_approved']) {
                $posters[] = $post_data['post_user_id'];
            }
            // Reindex the post
            $new_post->__set_array($post_data);
            $new_post->sql_data = $post_data;
            $new_post->topic_id = $this->topic_id;
            $new_post->post_url = $this->topic_url;
            $new_post->post_type = $this->topic_type;
            $new_post->index();
            // Set the post_id to 0 so it's counted as a new reply
            $new_post->post_id = 0;
            $new_post->update_topic_postcount();
            // Decrease count for donor topic
            $old_post->__set_array($post_data);
            $old_post->sql_data = $post_data;
            $old_post->update_topic_postcount(true);
        }
        $posters = array_unique($posters);
        // Update posted status
        foreach ($posters as $user_id) {
            $this->update_posted_status('add', $user_id);
            $donor->update_posted_status('remove', $user_id);
        }
        $donor->topic_posts = $old_post->topic->topic_posts;
        $this->topic_posts = $new_post->topic->topic_posts;
        unset($old_post, $new_post, $posts);
        // Resync topic
        $this->sync_topic_state(true);
        $this->sync_first_post();
        $this->sync_last_post();
        $this->submit();
        // Resync donor topic
        $donor->sync_topic_state(true);
        $donor->sync_first_post();
        $donor->sync_last_post();
        $donor->submit();
    }
Exemple #13
0
    /**
     * Hard delete the stuff for this topic
     */
    public function delete()
    {
        $post = new titania_post();
        $post->topic = $this;
        $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . '
			WHERE topic_id = ' . (int) $this->topic_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $post->__set_array($row);
            $post->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Deleting all the posts results in the last post calling this topic to delete itself
    }
    /**
     * Change the permalink to the contribution
     * Do not change it yourself, always use this function to do so
     *
     * @param string $new_permalink
     */
    public function change_permalink($new_permalink)
    {
        $old_permalink = $this->contrib_name_clean;
        $new_permalink = url::generate_slug($new_permalink);
        if ($this->validate_permalink($new_permalink, $old_permalink)) {
            return false;
        }
        $this->contrib_name_clean = $new_permalink;
        $params = serialize(array('contrib_type' => $this->type->url, 'contrib' => $this->contrib_name_clean));
        // Attention items
        $sql = 'UPDATE ' . TITANIA_ATTENTION_TABLE . '
			SET attention_url = "' . phpbb::$db->sql_escape($params) . '"
			WHERE attention_object_type = ' . TITANIA_CONTRIB . '
				AND attention_object_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        // Update the topics/posts under this
        $topics = $post_ids = array();
        $topic_where_sql = ' WHERE ' . phpbb::$db->sql_in_set('topic_type', array(TITANIA_SUPPORT, TITANIA_QUEUE_DISCUSSION)) . '
				AND parent_id = ' . $this->contrib_id;
        $topic = new titania_topic();
        $sql = 'SELECT *
			FROM ' . TITANIA_TOPICS_TABLE . $topic_where_sql;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $id = (int) $row['topic_id'];
            $topics[$id] = $row;
        }
        phpbb::$db->sql_freeresult($result);
        if (sizeof($topics)) {
            $post = new titania_post();
            $post->topic = $topic;
            $sql = 'SELECT *
				FROM ' . TITANIA_POSTS_TABLE . '
				WHERE ' . phpbb::$db->sql_in_set('topic_id', array_keys($topics));
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                $topic->__set_array($topics[$row['topic_id']]);
                $post->__set_array($row);
                $post->post_url = $params;
                $post_ids[] = (int) $row['post_id'];
                // Need to reindex as well...
                $post->index();
            }
            phpbb::$db->sql_freeresult($result);
            unset($topic, $post);
            // Update the posts table
            $sql = 'UPDATE ' . TITANIA_POSTS_TABLE . '
				SET post_url = "' . phpbb::$db->sql_escape($params) . '"
				WHERE ' . phpbb::$db->sql_in_set('topic_id', array_keys($topics));
            phpbb::$db->sql_query($sql);
            // Update the topics table
            $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
				SET topic_url = "' . phpbb::$db->sql_escape($params) . '"' . $topic_where_sql;
            phpbb::$db->sql_query($sql);
            if (sizeof($post_ids)) {
                // On to attention items for posts
                $sql = 'SELECT attention_id, attention_object_id
					FROM ' . TITANIA_ATTENTION_TABLE . '
					WHERE attention_object_type = ' . TITANIA_POST . '
						AND ' . phpbb::$db->sql_in_set('attention_object_id', $post_ids);
                $result = phpbb::$db->sql_query($sql);
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $sql = 'UPDATE ' . TITANIA_ATTENTION_TABLE . '
						SET attention_url = "' . phpbb::$db->sql_escape($params) . '"
						WHERE attention_id = ' . $row['attention_id'];
                    phpbb::$db->sql_query($sql);
                }
                phpbb::$db->sql_freeresult($result);
            }
        }
        // Finally update the contrib_name_clean
        $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . '
			SET contrib_name_clean = \'' . phpbb::$db->sql_escape($this->contrib_name_clean) . '\'
			WHERE contrib_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
    }
Exemple #15
0
    /**
     * Get the queue discussion topic or create one if needed
     *
     * @return titania_topic object
     */
    public function get_queue_discussion_topic()
    {
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE parent_id = ' . $this->contrib_id . '
				AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if ($row) {
            $topic = new titania_topic();
            $topic->__set_array($row);
            return $topic;
        }
        // No queue discussion topic...so we must create one
        titania::add_lang('posting');
        $contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
        $post = new titania_post(TITANIA_QUEUE_DISCUSSION);
        $post->topic->__set_array(array('parent_id' => $this->contrib_id, 'topic_category' => $contrib->contrib_type, 'topic_url' => titania_types::$types[$contrib->contrib_type]->url . '/' . $contrib->contrib_name_clean . '/support/', 'topic_sticky' => true));
        $post->__set_array(array('post_access' => TITANIA_ACCESS_AUTHORS, 'post_subject' => sprintf(phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_TITLE'], $contrib->contrib_name), 'post_text' => phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_MESSAGE']));
        $post->generate_text_for_storage(true, true, true);
        $post->submit();
        return $post->topic;
    }