Beispiel #1
0
    /**
     * Split/merge
     *
     * @param int $topic_id
     * @param string $mode Either split_topic or move_posts
     * @return Response|RedirectResponse
     */
    public function split_topic($topic_id, $mode)
    {
        // Auth check
        if (!$this->auth->acl_get('u_titania_mod_post_mod')) {
            return $this->controller_helper->needs_auth();
        }
        $this->user->add_lang('mcp');
        $subject = $this->request->variable('subject', '', true);
        $new_topic_id = $this->request->variable('new_topic_id', 0);
        $post_ids = $this->request->variable('post_ids', array(0));
        $submit = $this->request->is_set_post('split');
        $range = $this->request->variable('from', '');
        $topic = $this->load_topic($topic_id);
        $errors = array();
        if ($topic->topic_type != TITANIA_SUPPORT) {
            return $this->controller_helper->message('SPLIT_NOT_ALLOWED');
        }
        $page_title = $mode == 'split_topic' ? 'SPLIT_TOPIC' : 'MERGE_POSTS';
        $page_title = $this->user->lang($page_title) . ' - ' . $topic->topic_subject;
        if ($submit) {
            // Check for errors
            if (!check_form_key('split_topic')) {
                $errors[] = $this->user->lang['FORM_INVALID'];
            }
            if ($mode == 'split_topic' && utf8_clean_string($subject) == '') {
                $errors[] = $this->user->lang['NO_SUBJECT'];
            } else {
                if ($mode == 'move_posts' && !$new_topic_id) {
                    $errors[] = $this->user->lang['NO_FINAL_TOPIC_SELECTED'];
                }
            }
            if (empty($post_ids)) {
                $errors[] = $this->user->lang['NO_POST_SELECTED'];
            }
            if ($new_topic_id == $topic->topic_id) {
                $errors[] = $this->user->lang['ERROR_MERGE_SAME_TOPIC'];
            }
            if (empty($errors)) {
                if ($mode == 'move_posts') {
                    // Load the topic
                    $new_topic = $this->load_topic($new_topic_id);
                    if (!$new_topic) {
                        $errors[] = $this->user->lang['NO_TOPIC'];
                    }
                    // Only allow support posts to be moved to the same contrib
                    if ($new_topic->parent_id != $topic->parent_id || $new_topic->topic_type != TITANIA_SUPPORT) {
                        $errors[] = $this->user->lang['ERROR_NOT_SAME_PARENT'];
                    }
                    // Ensure that we don't have a range
                    $range = false;
                } else {
                    $sql_extra = 'post_id = ' . (int) $post_ids[0];
                    // Get info from first post
                    $sql = 'SELECT post_id, post_access, post_approved, post_time
						FROM ' . TITANIA_POSTS_TABLE . '
						WHERE post_type = ' . TITANIA_SUPPORT . '
							AND topic_id = ' . (int) $topic->topic_id . '
							AND ';
                    $result = $this->db->sql_query_limit($sql . $sql_extra, 1);
                    $first_post = $this->db->sql_fetchrow($result);
                    $this->db->sql_freeresult($result);
                    if (!$first_post) {
                        $errors[] = $this->user->lang['NO_POST_SELECTED'];
                    } else {
                        if ($range == 'from') {
                            // Get info from last post
                            $sql_extra = 'post_time >= ' . (int) $first_post['post_time'] . '
								ORDER BY post_time DESC';
                            $result = $this->db->sql_query_limit($sql . $sql_extra, 1);
                            $last_post = $this->db->sql_fetchrow($result);
                            $this->db->sql_freeresult($result);
                            $range = array('min' => $first_post['post_time'], 'max' => $last_post['post_time']);
                        } else {
                            $range = false;
                        }
                        // Create the new \topic with some basic info.
                        $data = array('parent_id' => $topic->parent_id, 'topic_type' => $topic->topic_type, 'topic_access' => $first_post['post_access'], 'topic_approved' => 1, 'topic_status' => ITEM_UNLOCKED, 'topic_time' => $first_post['post_time'], 'topic_subject' => $subject, 'topic_url' => $topic->topic_url);
                        $new_topic = new \titania_topic();
                        $new_topic->__set_array($data);
                        $new_topic->submit();
                        // Use new subject as the first post's subject to avoid issues when it gets approved
                        if (!$first_post['post_approved']) {
                            $sql = 'UPDATE ' . TITANIA_POSTS_TABLE . '
								SET post_subject = "' . $this->db->sql_escape($subject) . '"
								WHERE post_id = ' . (int) $first_post['post_id'];
                            $this->db->sql_query($sql);
                        }
                    }
                }
                // If there aren't any errors, go ahead and transfer the posts.
                if (empty($errors)) {
                    $new_topic->acquire_posts($topic, $post_ids, $range);
                    return new RedirectResponse($new_topic->get_url());
                }
            }
        }
        if (!$submit || !empty($errors)) {
            $errors = implode('<br />', $errors);
            $this->template->assign_vars(array('ERRORS' => $errors, 'TOPIC_SUBJECT' => $topic->topic_subject, 'S_SPLIT' => $mode == 'split_topic', 'SUBJECT' => $subject, 'TO_ID' => $new_topic_id));
            // Setup the sort tool
            $topic_sort = \posts_overlord::build_sort();
            $topic_sort->request();
            $topic_sort->url_parameters = array('action' => $mode);
            // Display topic
            \posts_overlord::display_topic($topic, $topic_sort);
            \posts_overlord::assign_common();
            add_form_key('split_topic');
        }
        return $this->controller_helper->render('posting/split_merge_topic_body.html', $page_title);
    }
    function main($id, $mode)
    {
        global $phpbb_root_path;
        define('PHPBB_INCLUDED', true);
        define('USE_PHPBB_TEMPLATE', true);
        define('IN_TITANIA', true);
        if (!defined('PHP_EXT')) {
            define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
        }
        require TITANIA_ROOT . 'common.' . PHP_EXT;
        // Need a few hacks to be used from within phpBB
        titania_url::decode_url(titania::$config->phpbb_script_path);
        titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone');
        titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone');
        $this->p_master->assign_tpl_vars(phpbb::append_sid('ucp'));
        // Include some files
        titania::_include('functions_display', 'titania_topic_folder_img');
        // Setup the sort tool
        $sort = new titania_sort();
        $sort->default_limit = phpbb::$config['topics_per_page'];
        $sort->request();
        // Start initial var setup
        $url = $this->u_action;
        add_form_key('ucp_front_subscription');
        // User wants to unsubscribe?
        if (isset($_POST['unsubscribe'])) {
            if (check_form_key('ucp_front_subscription')) {
                $sections = request_var('sections', array(0 => array(0 => 0)));
                $items = request_var('items', array(0 => array(0 => 0)));
                $subscriptions = $sections + $items;
                if (sizeof($subscriptions)) {
                    foreach ($subscriptions as $type => $type_id) {
                        $object_ids = array_keys($type_id);
                        foreach ($object_ids as $object_id) {
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_user_id = ' . phpbb::$user->data['user_id'] . '
								AND watch_object_type = ' . $type . '
								AND watch_object_id = ' . $object_id;
                            phpbb::$db->sql_query($sql);
                        }
                    }
                } else {
                    $msg = phpbb::$user->lang['NO_SUBSCRIPTIONS_SELECTED'];
                }
            } else {
                $msg = phpbb::$user->lang['FORM_INVALID'];
            }
            if (isset($msg)) {
                meta_refresh(3, $url);
                $message = $msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
                trigger_error($message);
            }
        }
        switch ($mode) {
            case 'subscription_items':
                $array_items = array(TITANIA_CONTRIB, TITANIA_TOPIC);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
						AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_CONTRIB . ' THEN c.contrib_last_update
							WHEN ' . TITANIA_TOPIC . ' THEN t.topic_last_post_time
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_CONTRIB . ')
								AND c.contrib_id = w.watch_object_id'), array('FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . '
								AND t.topic_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                // Additional tracking for support topics
                titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc');
                titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                // Tracking for contributions
                titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = $rows = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    titania_tracking::store_from_db($row);
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        $user_ids[] = $row['topic_first_post_user_id'];
                        $user_ids[] = $row['topic_last_post_user_id'];
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $user_ids[] = $row['contrib_user_id'];
                        }
                    }
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                foreach ($rows as $row) {
                    $folder_img = $folder_alt = '';
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        if (!$row['topic_id']) {
                            // Topic was deleted
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_object_type = ' . (int) $row['watch_object_type'] . '
									AND watch_object_id = ' . (int) $row['watch_object_id'];
                            phpbb::$db->sql_query($sql);
                            continue;
                        }
                        $topic = new titania_topic();
                        $topic->__set_array($row);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
                        $tpl_block = 'items';
                        $subscription_target = '';
                        if ($row['topic_type'] == TITANIA_QUEUE_DISCUSSION) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE_VALIDATION'];
                        }
                        if ($row['topic_type'] == TITANIA_QUEUE) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE'];
                        }
                        if ($row['topic_type'] == TITANIA_SUPPORT) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_SUPPORT_TOPIC'];
                        }
                        // Tracking check
                        $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id, true);
                        $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id));
                        $topic->unread = $topic->topic_last_post_time > $last_read_mark ? true : false;
                        // Get the folder image
                        $topic->topic_folder_img($folder_img, $folder_alt);
                        $vars = array('LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $topic->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($topic->get_url(), array('p' => $topic->topic_last_post_id, '#p' => $topic->topic_last_post_id)), 'S_ACCESS_TEAMS' => $row['topic_access'] == TITANIA_ACCESS_TEAMS || $row['topic_type'] == TITANIA_QUEUE ? true : false, 'S_ACCESS_AUTHORS' => $row['topic_access'] == TITANIA_ACCESS_AUTHORS ? true : false, 'S_TOPIC' => true);
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $tpl_block = 'items';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update));
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_CONTRIB_TYPE' => titania_types::$types[$contrib->contrib_type]->lang, 'SUBSCRIPTION_DOWNLOADS' => $row['contrib_downloads'], 'SUBSCRIPTION_ID' => $row['contrib_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_CONTRIB'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'SUBSCRIPTION_VIEWS' => $row['contrib_views'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url(), 'S_CONTRIB' => true);
                        }
                    }
                    phpbb::$template->assign_block_vars($tpl_block, array_merge($vars, array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'))));
                }
                break;
            case 'subscription_sections':
                $array_items = array(TITANIA_SUPPORT, TITANIA_QUEUE, TITANIA_ATTENTION);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
					AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_SUPPORT . ' THEN c.contrib_last_update
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_SUPPORT . ')
								AND c.contrib_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    $user_ids[] = $row['contrib_user_id'];
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                if (isset($rows)) {
                    foreach ($rows as $row) {
                        if ($row['watch_object_type'] == TITANIA_SUPPORT) {
                            $tpl_block = 'sections';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_SUPPORT'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url('support'));
                        } else {
                            if ($row['watch_object_type'] == TITANIA_ATTENTION) {
                                $tpl_block = 'sections';
                                $vars = array('SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_ATTENTION'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_ATTENTION' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::build_url('manage/attention'));
                            } else {
                                if ($row['watch_object_type'] == TITANIA_QUEUE) {
                                    $tpl_block = 'sections';
                                    $queue_id = $row['watch_object_id'];
                                    // Setup the base url we will use
                                    $base_url = titania_url::build_url('manage/queue');
                                    $vars = array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => titania_types::$types[$queue_id]->lang, 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_id]->url)));
                                }
                            }
                        }
                        phpbb::$template->assign_block_vars($tpl_block, $vars);
                    }
                }
                break;
        }
        phpbb::$template->assign_vars(array('S_ACTION' => $url, 'TITANIA_THEME_PATH' => titania::$absolute_path . 'styles/' . titania::$config->style . '/theme/'));
        titania::page_header(phpbb::$user->lang['SUBSCRIPTION_TITANIA']);
        titania::page_footer(true, 'manage/' . $mode . '.html');
    }
Beispiel #3
0
 /**
  * Display queue topic review.
  *
  * @return null
  */
 protected function display_topic_review()
 {
     // Setup the sort tool
     $topic_sort = \posts_overlord::build_sort();
     $topic_sort->set_defaults(false, false, 'd');
     // Load the topic
     $topic = new \titania_topic();
     $topic->load($this->queue->queue_topic_id);
     // Display the posts for review
     \posts_overlord::display_topic($topic, $topic_sort);
 }
Beispiel #4
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;
    }
Beispiel #5
0
 /**
  * Display "forum" like section for support/tracker/etc
  *
  * @param string $type The type (support, review, queue, tracker, author_support, author_tracker) author_ for displaying posts from the areas the given author is involved in (either an author/co-author)
  * @param object|boolean $object The object (for contrib related (support, review, queue, tracker) and author_ modes)
  * @param object|boolean $sort The sort object (includes/tools/sort.php)
  * @param array $options Some special options
  * @param string $contrib_type The type of the support topic list
  */
 public static function display_forums($type, $object = false, $sort = false, $options = array())
 {
     if ($sort === false) {
         // Setup the sort tool
         $sort = self::build_sort();
     }
     $sort->request();
     $topic_ids = array();
     $switch_on_sticky = true;
     // Display the extra block after stickies end?  Not used when not sorting with stickies first
     $sql_ary = array('SELECT' => 't.*, u.username as topic_first_post_username, u.user_colour as topic_first_post_user_colour, ul.username as topic_last_post_username, ul.user_colour as topic_last_post_user_colour', 'FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'WHERE' => self::sql_permissions('t.', false, true), 'ORDER_BY' => 't.topic_sticky DESC, ' . $sort->get_order_by());
     $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 't.topic_first_post_user_id = u.user_id');
     $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'ul'), 'ON' => 't.topic_last_post_user_id = ul.user_id');
     titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
     // Setup the contribution/topic we will use for parsing the output (before the switch so we are able to do type specific things for it)
     $topic = new titania_topic();
     $contrib = new titania_contribution();
     // type specific things
     switch ($type) {
         case 'tracker':
             $page_url = $object->get_url('tracker');
             $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id;
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER;
             if (isset($options['category'])) {
                 $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['category'];
             }
             break;
         case 'queue':
             $page_url = titania_url::build_url('manage/queue');
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE;
             break;
         case 'queue_discussion':
             $page_url = titania_url::build_url('manage/queue_discussion', array('queue' => titania_types::$types[$options['topic_category']]->url));
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE_DISCUSSION;
             // Only display those in which the users are authed
             $authed = titania_types::find_authed('queue_discussion');
             if (!sizeof($authed)) {
                 return compact('sort');
             }
             if (isset($options['topic_category'])) {
                 if (!in_array((int) $options['topic_category'], $authed)) {
                     return compact('sort');
                 }
                 $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['topic_category'];
             } else {
                 $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.topic_category', $authed);
             }
             // Additional tracking for all queue discussion topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
             $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
             // Additional tracking for marking items as read in each contribution
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tst');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
             break;
         case 'author_support':
             $page_url = $object->get_url('support');
             $contrib_ids = titania::$cache->get_author_contribs($object->user_id, true);
             $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids));
             // We also display the queue discussion topic between validators and authors in the support area
             $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')';
             // Additional tracking for marking items as read in each contribution
             titania_tracking::get_tracks(TITANIA_SUPPORT, $contrib_ids);
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
             // Additional tracking for all support topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0, 'type_match' => true);
             // Track the queue discussion too if applicable
             if (titania_types::find_authed('queue_discussion')) {
                 titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                 $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
             }
             // Try to grab the category/contrib name
             $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type';
             $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id')));
             // Do not order stickies first
             $sql_ary['ORDER_BY'] = $sort->get_order_by();
             $switch_on_sticky = false;
             break;
         case 'author_tracker':
             $page_url = $object->get_url('tracker');
             $contrib_ids = titania::$cache->get_author_contribs($object->user_id);
             $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids));
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER;
             break;
         case 'all_support':
             // Try to grab the category/contrib name
             $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type';
             $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id')));
             if (isset(titania_types::$types[$options['contrib_type']])) {
                 $page_url = titania_url::build_url('support/' . titania_types::$types[$options['contrib_type']]->url);
                 $sql_ary['WHERE'] .= ' AND contrib.contrib_type = ' . $options['contrib_type'];
             } else {
                 $page_url = titania_url::build_url('support/all');
             }
             // Additional tracking field (to allow marking all support/discussion as read)
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT;
             // Additional tracking for all support topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
             // Do not order stickies first
             $sql_ary['ORDER_BY'] = $sort->get_order_by();
             $switch_on_sticky = false;
             break;
         case 'support':
         default:
             $page_url = $object->get_url('support');
             $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id;
             // We also display the queue discussion topic between validators and authors in the support area
             if ($object->is_author || $object->is_active_coauthor || titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) {
                 $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')';
             } else {
                 $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT;
             }
             // Additional tracking for marking items as read in each contribution
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, $object->contrib_id, 'tst');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
             // Additional tracking for all support topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
             // Track the queue discussion too if applicable
             if (titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) {
                 titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                 $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
             }
             break;
     }
     // Main SQL Query
     $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
     // Handle pagination
     if (!$sort->sql_count($sql_ary, 't.topic_id')) {
         // No results...no need to query more...
         return compact('sort');
     }
     $sort->build_pagination($page_url);
     $last_was_sticky = false;
     // Get the data
     $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
     while ($row = phpbb::$db->sql_fetchrow($result)) {
         // Store the tracking info we grabbed from the DB
         titania_tracking::store_from_db($row);
         self::$topics[$row['topic_id']] = $row;
         $topic->__set_array($row);
         $contrib->__set_array($row);
         phpbb::$template->assign_block_vars('topics', array_merge($topic->assign_details(), array('S_TOPIC_TYPE_SWITCH' => $switch_on_sticky && $last_was_sticky && !$topic->topic_sticky ? true : false, 'CONTRIB_TYPE' => isset($row['contrib_type']) && $row['contrib_type'] ? titania_types::$types[$row['contrib_type']]->lang : '', 'TOPIC_CONTRIB_NAME' => isset($row['contrib_name']) && $row['contrib_name'] ? censor_text($row['contrib_name']) : '', 'U_VIEW_TOPIC_CONTRIB' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url() : '', 'U_VIEW_TOPIC_CONTRIB_SUPPORT' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url('support') : '')));
         $last_was_sticky = $topic->topic_sticky;
     }
     phpbb::$db->sql_freeresult($result);
     unset($topic);
     return compact('sort');
 }
Beispiel #6
0
     // Build the preview message
     titania::add_lang('contributions');
     $revision = $queue->get_revision();
     $public_notes_preview = false;
     if (titania_types::$types[$contrib->contrib_type]->update_public) {
         $public_notes_preview = $action == 'deny' ? false : sprintf(phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->update_public], $revision->revision_version) . ($public_notes ? sprintf(phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->update_public . '_NOTES'], $public_notes) : '');
         $uid = $bitfield = $options = false;
         generate_text_for_storage($public_notes_preview, $uid, $bitfield, $options, true, true, true);
         $public_notes_preview = titania_generate_text_for_display($public_notes_preview, $uid, $bitfield, $options);
     }
     phpbb::$template->assign_vars(array('ERROR' => implode('<br />', $error), 'L_TOPIC_REVIEW' => phpbb::$user->lang['QUEUE_REVIEW'], 'PAGE_TITLE_EXPLAIN' => phpbb::$user->lang[($action == 'approve' ? 'APPROVE_QUEUE' : 'DENY_QUEUE') . '_CONFIRM'], 'PUBLIC_MESSAGE' => $public_notes, 'PUBLIC_PREVIEW_SUBJECT' => isset($_POST['preview']) ? 'Re: ' . $contrib->contrib_name : false, 'PUBLIC_PREVIEW_MESSAGE' => isset($_POST['preview']) ? $public_notes_preview : false, 'S_CONTRIB_APPROVE' => $action == 'approve' ? true : false, 'S_STYLE_DEMO_INSTALL' => $action == 'approve' && $contrib->contrib_type == TITANIA_TYPE_STYLE && titania::$config->demo_style_path ? true : false, 'S_STYLE_DEMO_INSTALL_CHECKED' => isset($_POST['style_demo_install']) ? true : false, 'S_PUBLIC_NOTES' => $action == 'approve' && titania_types::$types[$contrib->contrib_type]->update_public ? true : false, 'TOPIC_TITLE' => $contrib->contrib_name));
     // Setup the sort tool
     $topic_sort = posts_overlord::build_sort();
     $topic_sort->set_defaults(false, false, 'd');
     // Load the topic
     $topic = new titania_topic();
     $topic->load($queue->queue_topic_id);
     // Display the posts for review
     posts_overlord::display_topic($topic, $topic_sort);
     titania::page_header(phpbb::$user->lang[$action == 'approve' ? 'APPROVE_QUEUE' : 'DENY_QUEUE'] . ': ' . $contrib->contrib_name);
     titania::page_footer(false, 'manage/queue_validate.html');
     break;
 case 'notes':
     $queue = queue_overlord::get_queue_object($queue_id, true);
     // Load the message object
     $message_object = new titania_message($queue);
     $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 discussion topic redirect.
     *
     * @return Returns \Symfony\Component\HttpFoundation\Response if no
     *	topic was found, otherwise redirects to topic.
     */
    protected function queue_discussion()
    {
        $sql = 'SELECT *
			FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION . '
			AND parent_id = ' . $this->contrib->contrib_id;
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($row) {
            $topic = new \titania_topic();
            $topic->__set_array($row);
            redirect($topic->get_url());
        }
        return $this->helper->error('NO_QUEUE_DISCUSSION_TOPIC', 404);
    }
 /**
  * Get topic template row.
  *
  * @param array $row
  * @return array
  */
 protected function get_topic_tpl_row($row)
 {
     $topic = new \titania_topic();
     $topic->__set_array($row);
     $additional_unread_fields = array(array('type' => TITANIA_SUPPORT, 'id' => 0), array('type' => TITANIA_SUPPORT, 'parent_match' => true), array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true));
     $topic->additional_unread_fields = array_merge($topic->additional_unread_fields, $additional_unread_fields);
     $subscription_target = '';
     $type_lang = array(TITANIA_QUEUE_DISCUSSION => 'SUBSCRIPTION_QUEUE_VALIDATION', TITANIA_QUEUE => 'SUBSCRIPTION_QUEUE', TITANIA_SUPPORT => 'SUBSCRIPTION_SUPPORT_TOPIC');
     if (isset($type_lang[$row['topic_type']])) {
         $subscription_target = $this->user->lang($type_lang[$row['topic_type']]);
     }
     // Tracking check
     $last_read_mark = $this->tracking->get_track(TITANIA_TOPIC, $topic->topic_id, true);
     $last_read_mark = max($last_read_mark, $this->tracking->find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id));
     $topic->unread = $topic->topic_last_post_time > $last_read_mark;
     // Get the folder image
     $topic->topic_folder_img($folder_img, $folder_alt);
     return array('FOLDER_STYLE' => $folder_img, 'LAST_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => \users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => \users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => $this->user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => $this->user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $this->get_real_url($topic->get_url()), 'U_VIEW_LAST_POST' => $this->get_real_url($topic->get_url(false, array('p' => $topic->topic_last_post_id, '#' => 'p' . $topic->topic_last_post_id))), 'S_ACCESS_TEAMS' => $row['topic_access'] == access::TEAM_LEVEL || $row['topic_type'] == TITANIA_QUEUE, 'S_ACCESS_AUTHORS' => $row['topic_access'] == access::AUTHOR_LEVEL, 'S_TOPIC' => true);
 }
Beispiel #9
0
include TITANIA_ROOT . 'common.' . PHP_EXT;
// Setup some vars
$page = basename(request_var('page', ''));
// Add common lang
titania::add_lang('contributions');
// Go to the queue discussion for this contribution item (saves us from having to figure out the URL to the topic every time we generate it)
if ($page == 'queue_discussion') {
    load_contrib();
    $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION . '
			AND parent_id = ' . titania::$contrib->contrib_id;
    $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);
        redirect($topic->get_url());
    }
    trigger_error('NO_QUEUE_DISCUSSION_TOPIC');
}
// And now to load the appropriate page...
switch ($page) {
    case 'faq':
    case 'support':
    case 'manage':
    case 'revision':
    case 'revision_edit':
        include TITANIA_ROOT . 'contributions/' . $page . '.' . PHP_EXT;
        break;
    case 'report':
Beispiel #10
0
    /**
     * Display a single queue item
     *
     * @param int $queue_id
     * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic)
     */
    public static function display_queue_item($queue_id)
    {
        titania::add_lang('contributions');
        $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . '
				AND r.revision_id = q.revision_id
				AND t.topic_id = q.queue_topic_id');
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$row) {
            trigger_error('NO_QUEUE_ITEM');
        }
        self::$queue[$queue_id] = $row;
        // Load the contribution
        $contrib = new titania_contribution();
        $contrib->load((int) $row['contrib_id']);
        $contrib->get_download($row['revision_id']);
        $contrib->get_revisions();
        $contrib->get_screenshots();
        $contrib->assign_details();
        // Load the topic (with the already selected data)
        $topic = new titania_topic();
        $topic->__set_array($row);
        // Bit of a hack for the posting
        $_REQUEST['t'] = $topic->topic_id;
        // Some quick-actions
        $quick_actions = array();
        if ($row['queue_status'] > 0) {
            if ($row['queue_progress'] == phpbb::$user->data['user_id']) {
                $quick_actions['MARK_NO_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'no_progress')), 'class' => 'queue_progress');
            } else {
                if (!$row['queue_progress']) {
                    $quick_actions['MARK_IN_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'in_progress')), 'class' => 'queue_progress');
                }
            }
            $tags = titania::$cache->get_tags(TITANIA_QUEUE);
            unset($tags[$row['queue_status']]);
            $quick_actions['CHANGE_STATUS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'move')), 'class' => 'change_status', 'tags' => $tags);
            if (titania_types::$types[$contrib->contrib_type]->acl_get('moderate')) {
                $quick_actions['REPACK'] = array('url' => titania_url::append_url($contrib->get_url('revision'), array('repack' => $row['revision_id'])), 'class' => 'repack');
            }
            // This allows you to alter the author submitted notes to the validation team, not really useful as the field's purpose was changed, so commenting out
            /*$quick_actions['ALTER_NOTES'] = array(
            			'url'		=> titania_url::append_url(titania_url::$current_page_url, array('action' => 'notes')),
            		);*/
            // Misc actions
            $subactions = array();
            if (titania_types::$types[$contrib->contrib_type]->mpv_test) {
                $subactions['RETEST_MPV'] = array('url' => titania_url::build_url('', array('action' => 'mpv', 'revision' => $row['revision_id'])));
            }
            if (titania_types::$types[$contrib->contrib_type]->automod_test) {
                $subactions['RETEST_AUTOMOD'] = array('url' => titania_url::build_url('', array('action' => 'automod', 'revision' => $row['revision_id'])));
            }
            $subactions['REBUILD_FIRST_POST'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'rebuild')));
            $quick_actions['CAT_MISC'] = array('subactions' => $subactions, 'class' => 'misc');
            // Validation
            if (titania_types::$types[$contrib->contrib_type]->acl_get('validate')) {
                $quick_actions['APPROVE'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'approve', 'start' => '*destroy*')), 'class' => 'approve');
                $quick_actions['DENY'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'deny', 'start' => '*destroy*')), 'class' => 'deny');
            }
        }
        foreach ($quick_actions as $lang_key => $data) {
            phpbb::$template->assign_block_vars('queue_actions', array('NAME' => isset(phpbb::$user->lang[$lang_key]) ? phpbb::$user->lang[$lang_key] : $lang_key, 'CLASS' => isset($data['class']) ? $data['class'] : '', 'U_VIEW' => isset($data['url']) ? $data['url'] : ''));
            if (isset($data['tags'])) {
                foreach ($data['tags'] as $tag_id => $tag_row) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => isset(phpbb::$user->lang[$tag_row['tag_field_name']]) ? phpbb::$user->lang[$tag_row['tag_field_name']] : $tag_row['tag_field_name'], 'U_ACTION' => titania_url::append_url($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions')))));
                }
            }
            if (isset($data['subactions'])) {
                foreach ($data['subactions'] as $sublang_key => $subdata) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => isset(phpbb::$user->lang[$sublang_key]) ? phpbb::$user->lang[$sublang_key] : $sublang_key, 'U_ACTION' => $subdata['url']));
                }
            }
        }
        if ($row['queue_status'] == -2) {
            $current_status = phpbb::$user->lang['REVISION_DENIED'];
        } else {
            if ($row['queue_status'] == -1) {
                $current_status = phpbb::$user->lang['REVISION_APPROVED'];
            } else {
                $current_status = titania_tags::get_tag_name($row['queue_status']);
            }
        }
        phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'reply', 't' => $topic->topic_id)), 'U_NEW_REVISION' => false));
        // Subscriptions
        titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, titania_url::$current_page_url);
        return compact('row', 'contrib', 'topic');
    }
    /**
     * Delete this contribution
     */
    public function delete()
    {
        // Delete Revisions
        $revision = new titania_revision($this);
        $sql = 'SELECT * FROM ' . TITANIA_REVISIONS_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $revision->__set_array($row);
            $revision->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Delete Support/Discussion/Queue Discussion Topics
        $topic = new titania_topic();
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('topic_type', array(TITANIA_SUPPORT, TITANIA_QUEUE_DISCUSSION)) . '
				AND parent_id = ' . $this->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $topic->__set_array($row);
            $topic->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Change the status to new (handles resetting counts)
        $this->change_status(TITANIA_CONTRIB_NEW);
        // Remove any attention items
        $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
			WHERE attention_object_type = ' . TITANIA_CONTRIB . '
				AND attention_object_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        // Delete the release topic
        if ($this->contrib_release_topic_id) {
            phpbb::_include('functions_admin', 'delete_topics');
            delete_topics('topic_id', $this->contrib_release_topic_id);
        }
        // Delete from categories
        $this->update_category_count('-');
        $sql = ' DELETE FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        repository::trigger_cron($this->config);
        // Self delete
        parent::delete();
    }
Beispiel #12
0
    /**
     * Display a single queue item
     *
     * @param int $queue_id
     * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic)
     */
    public static function display_queue_item($queue_id)
    {
        phpbb::$user->add_lang_ext('phpbb/titania', 'contributions');
        $controller_helper = phpbb::$container->get('phpbb.titania.controller.helper');
        $path_helper = phpbb::$container->get('path_helper');
        $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . '
				AND r.revision_id = q.revision_id
				AND t.topic_id = q.queue_topic_id');
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$row) {
            trigger_error('NO_QUEUE_ITEM');
        }
        self::$queue[$queue_id] = $row;
        $queue = self::get_queue_object($queue_id);
        // Load the contribution
        $contrib = new titania_contribution();
        $contrib->load((int) $row['contrib_id']);
        $contrib->get_download($row['revision_id']);
        $contrib->get_revisions();
        $contrib->get_screenshots();
        $contrib->assign_details();
        // Load the topic (with the already selected data)
        $topic = new titania_topic();
        $topic->__set_array($row);
        // Bit of a hack for the posting
        phpbb::$request->overwrite('t', $topic->topic_id);
        $is_moderator = $contrib->type->acl_get('moderate');
        $is_validator = $contrib->type->acl_get('validate');
        $hash = array('hash' => generate_link_hash('queue_tool'));
        // Misc actions
        $misc_actions = array(array('RETEST_PV', $queue->get_tool_url('mpv', $row['revision_id'], $hash), $contrib->type->mpv_test), array('RETEST_PV', $queue->get_tool_url('epv', $row['revision_id'], $hash), $contrib->type->epv_test), array('RETEST_AUTOMOD', $queue->get_tool_url('automod', $row['revision_id'], $hash), $contrib->type->automod_test));
        // Some quick-actions
        $quick_actions = array();
        $hash = array('hash' => generate_link_hash('queue_action'));
        if ($row['queue_status'] > 0) {
            $misc_actions = array_merge($misc_actions, array(array('REBUILD_FIRST_POST', $queue->get_url('rebuild', $hash), true), array('ALLOW_AUTHOR_REPACK', $queue->get_url('allow_author_repack'), $is_moderator && !$row['allow_author_repack']), array('MARK_TESTED', $queue->get_url('tested', $hash), !$row['queue_tested']), array('MARK_UNTESTED', $queue->get_url('not_tested', $hash), $row['queue_tested'])));
            $tags = titania::$cache->get_tags(TITANIA_QUEUE);
            unset($tags[$row['queue_status']]);
            $quick_actions = array(array('MARK_NO_PROGRESS', $queue->get_url('no_progress', $hash), $row['queue_progress'] == phpbb::$user->data['user_id'], 'queue_progress'), array('MARK_IN_PROGRESS', $queue->get_url('in_progress', $hash), !$row['queue_progress'], 'queue_progress'), array('CHANGE_STATUS', $queue->get_url('move'), true, 'change_status', $tags), array('REPACK', $contrib->get_url('revision', array('page' => 'repack', 'id' => $row['revision_id'])), $is_moderator, 'repack'), array('CAT_MISC', '', true, 'misc', '', $misc_actions), array('APPROVE', $queue->get_url('approve'), $is_validator, 'approve'), array('DENY', $queue->get_url('deny'), $is_validator, 'deny'));
        }
        if (empty($quick_actions) && !empty($misc_actions)) {
            $quick_actions = array(array('CAT_MISC', '', true, 'misc', '', $misc_actions));
        }
        foreach ($quick_actions as $data) {
            $properties = array('name', 'url', 'auth', 'class', 'tags', 'subactions');
            $data = array_pad($data, sizeof($properties), '');
            $data = array_combine($properties, $data);
            if (!$data['auth']) {
                continue;
            }
            phpbb::$template->assign_block_vars('queue_actions', array('NAME' => phpbb::$user->lang($data['name']), 'CLASS' => $data['class'], 'U_VIEW' => $data['url']));
            if ($data['tags']) {
                foreach ($data['tags'] as $tag_id => $tag_row) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => phpbb::$user->lang($tag_row['tag_field_name']), 'U_ACTION' => $path_helper->append_url_params($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions')))));
                }
            }
            if ($data['subactions']) {
                foreach ($data['subactions'] as $subdata) {
                    $subdata = array_pad($subdata, sizeof($properties), '');
                    $subdata = array_combine($properties, $subdata);
                    if (!$subdata['auth']) {
                        continue;
                    }
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => phpbb::$user->lang($subdata['name']), 'U_ACTION' => $subdata['url']));
                }
            }
        }
        if ($row['queue_status'] == -3) {
            $current_status = phpbb::$user->lang('QUEUE_CLOSED');
        } else {
            if ($row['queue_status'] == -2) {
                $current_status = phpbb::$user->lang['REVISION_DENIED'];
            } else {
                if ($row['queue_status'] == -1) {
                    $current_status = phpbb::$user->lang['REVISION_APPROVED'];
                } else {
                    $current_status = phpbb::$container->get('phpbb.titania.tags')->get_tag_name($row['queue_status']);
                }
            }
        }
        phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => $queue->get_url('reply'), 'U_NEW_REVISION' => false));
        // Subscriptions
        phpbb::$container->get('phpbb.titania.subscriptions')->handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, $controller_helper->get_current_url(), 'SUBSCRIBE_TOPIC');
        return compact('row', 'contrib', 'topic');
    }
Beispiel #13
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;
    }