Exemple #1
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');
 }
Exemple #2
0
 /**
  * Check permissions for quick edit and exit with appropriate error if necessary.
  *
  * @param \titania_post $post	Post being edited
  * @throws http_exception 		Throws http_exception if user is not authorized.
  */
 protected function quick_edit_auth_check(\titania_post $post)
 {
     // User must be logged in...
     if ($this->user->data['user_id'] == ANONYMOUS) {
         throw new http_exception(403, $this->user->lang('LOGIN_EXPLAIN_EDIT'));
     } else {
         if (!$post->acl_get('edit')) {
             throw new http_exception(403, $this->user->lang('NO_AUTH'));
         }
     }
 }
Exemple #3
0
    /**
     * Do everything we need to display the forum like page
     *
     * @param object $topic the topic object
     */
    public static function display_topic_complete($topic)
    {
        phpbb::$user->add_lang('viewtopic');
        // Setup the sort tool
        $sort = self::build_sort();
        $sort->request();
        // if a post_id was given we must start from the appropriate page
        $post_id = request_var('p', 0);
        if ($post_id) {
            $sql = 'SELECT COUNT(p.post_id) as start FROM ' . TITANIA_POSTS_TABLE . ' p
				WHERE p.post_id < ' . $post_id . '
					AND p.topic_id = ' . $topic->topic_id . self::sql_permissions('p.') . '
				ORDER BY ' . $sort->get_order_by();
            phpbb::$db->sql_query($sql);
            $start = phpbb::$db->sql_fetchfield('start');
            phpbb::$db->sql_freeresult();
            $sort->start = $start > 0 ? floor($start / $sort->limit) * $sort->limit : 0;
        }
        // check to see if they want to view the latest unread post
        if (request_var('view', '') == 'unread') {
            $mark_time = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id);
            if ($mark_time > 0) {
                $sql = 'SELECT COUNT(p.post_id) as start FROM ' . TITANIA_POSTS_TABLE . ' p
					WHERE p.post_time <= ' . $mark_time . '
						AND p.topic_id = ' . $topic->topic_id . self::sql_permissions('p.') . '
					ORDER BY post_time ASC';
                phpbb::$db->sql_query($sql);
                $start = phpbb::$db->sql_fetchfield('start');
                phpbb::$db->sql_freeresult();
                $sort->start = $start > 0 ? floor($start / $sort->limit) * $sort->limit : 0;
            }
        }
        /*
        user_topic_show_days
        
        $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
        */
        self::display_topic($topic, $sort);
        self::assign_common();
        // Build Quick Actions
        if ($topic->topic_type != TITANIA_QUEUE) {
            self::build_quick_actions($topic);
        }
        // Display the Quick Reply
        $post_object = new titania_post($topic->topic_type, $topic);
        if ($post_object->acl_get('reply')) {
            $message = new titania_message($topic);
            $message->display_quick_reply();
        }
        phpbb::$template->assign_vars(array('S_IS_LOCKED' => (bool) $topic->topic_locked));
    }