Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
         }
     }
     $message_object->display();
     // 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));
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 /**
  * Reply to an existing topic
  *
  * @param mixed $topic_id
  */
 public function reply($topic_id, $quote_post_id = false)
 {
     if (!phpbb::$auth->acl_get('u_titania_post')) {
         titania::needs_auth();
     }
     // Load the stuff we need
     $topic = $this->load_topic($topic_id);
     $post_object = new titania_post($topic->topic_type, $topic);
     // Check permissions
     if (!$post_object->acl_get('reply')) {
         titania::needs_auth();
     }
     // Quoting?
     if ($quote_post_id !== false && $post_object->post_text == '') {
         $quote = $this->load_post($quote_post_id);
         // Permission check
         if (titania::$access_level <= min($quote->post_access, $quote->topic->topic_access) && (phpbb::$auth->acl_get('u_titania_mod_post_mod') || $quote->post_approved && (!$quote->post_deleted || $quote->post_deleted == phpbb::$user->data['user_id']))) {
             $for_edit = $quote->generate_text_for_edit();
             $post_object->post_text = '[quote="' . users_overlord::get_user($quote->post_user_id, '_username', true) . '"]' . $for_edit['text'] . '[/quote]';
         }
     }
     // Load the message object
     $message_object = new titania_message($post_object);
     $message_object->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'), 'lock_topic' => phpbb::$auth->acl_get('u_titania_mod_post_mod') || (phpbb::$auth->acl_get('u_titania_post_mod_own') && is_object(titania::$contrib) && titania::$contrib->contrib_id == $post_object->topic->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) ? true : false, 'attachments' => phpbb::$auth->acl_get('u_titania_post_attach')));
     $message_object->set_settings(array('display_captcha' => !phpbb::$user->data['is_registered'] ? true : false, 'subject_default_override' => 'Re: ' . $post_object->topic->topic_subject));
     // Call our common posting handler
     $this->common_post('reply', $post_object, $message_object);
     // Setup the sort tool
     $topic_sort = posts_overlord::build_sort();
     $topic_sort->set_defaults(false, false, 'd');
     // Display the posts for review
     posts_overlord::display_topic($post_object->topic, $topic_sort);
     // Common stuff
     phpbb::$template->assign_vars(array('S_POST_ACTION' => $post_object->topic->get_url('reply', titania_url::$current_page_url), 'L_POST_A' => phpbb::$user->lang['POST_REPLY'], 'S_DISPLAY_REVIEW' => true));
     titania::page_header('POST_REPLY');
 }