示例#1
0
 /**
  * Assign details
  *
  * A little different from those in other classes, this one only returns the info ready for output
  */
 public function assign_details()
 {
     // Tracking check
     $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $this->topic_id, true);
     $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($this->additional_unread_fields, $this->topic_type, $this->parent_id));
     $this->unread = $this->topic_last_post_time > $last_read_mark ? true : false;
     $folder_img = $folder_alt = '';
     $this->topic_folder_img($folder_img, $folder_alt);
     // To find out if we have any posts that need approval
     $approved = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, false));
     $total = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, true));
     $details = array('TOPIC_ID' => $this->topic_id, 'TOPIC_TYPE' => $this->topic_type, 'TOPIC_ACCESS' => $this->topic_access, 'TOPIC_STATUS' => $this->topic_status, 'TOPIC_STICKY' => $this->topic_sticky, 'TOPIC_LOCKED' => $this->topic_locked, 'POSTS_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') && $total > $approved ? false : true, 'TOPIC_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_approved : true, 'TOPIC_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_reported : false, 'TOPIC_ASSIGNED' => $this->topic_assigned, 'TOPIC_REPLIES' => $this->get_postcount() - 1, 'TOPIC_VIEWS' => $this->topic_views, 'TOPIC_SUBJECT' => censor_text($this->topic_subject), 'TOPIC_FIRST_POST_ID' => $this->topic_first_post_id, 'TOPIC_FIRST_POST_USER_ID' => $this->topic_first_post_user_id, 'TOPIC_FIRST_POST_USER_COLOUR' => $this->topic_first_post_user_colour, 'TOPIC_FIRST_POST_USER_FULL' => get_username_string('full', $this->topic_first_post_user_id, $this->topic_first_post_username, $this->topic_first_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_FIRST_POST_TIME' => phpbb::$user->format_date($this->topic_first_post_time), 'TOPIC_LAST_POST_ID' => $this->topic_last_post_id, 'TOPIC_LAST_POST_USER_ID' => $this->topic_last_post_user_id, 'TOPIC_LAST_POST_USER_COLOUR' => $this->topic_last_post_user_colour, 'TOPIC_LAST_POST_USER_FULL' => get_username_string('full', $this->topic_last_post_user_id, $this->topic_last_post_username, $this->topic_last_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_LAST_POST_TIME' => phpbb::$user->format_date($this->topic_last_post_time), 'TOPIC_LAST_POST_SUBJECT' => censor_text($this->topic_last_post_subject), 'U_NEWEST_POST' => $this->unread ? titania_url::append_url($this->get_url(), array('view' => 'unread', '#' => 'unread')) : '', 'U_VIEW_TOPIC' => $this->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($this->get_url(), array('p' => $this->topic_last_post_id, '#p' => $this->topic_last_post_id)), 'S_UNREAD_TOPIC' => $this->unread ? true : false, 'S_ACCESS_TEAMS' => $this->topic_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->topic_access == TITANIA_ACCESS_AUTHORS ? true : false, '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'));
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this);
     return $details;
 }
示例#2
0
    /**
     * Hard delete a post
     */
    public function hard_delete()
    {
        if (!$this->topic->topic_posts) {
            if (!$this->topic->load($this->topic_id)) {
                return false;
            }
        }
        // Update the postcount for the topic
        $this->update_topic_postcount(true);
        // Set the visibility appropriately if no posts are visibile to the public/authors
        $flags = titania_count::get_flags(TITANIA_ACCESS_PUBLIC);
        if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
            // There are no posts visible to the public, change it to authors level access
            $this->topic->topic_access = TITANIA_ACCESS_AUTHORS;
            $flags = titania_count::get_flags(TITANIA_ACCESS_AUTHORS);
            if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
                // There are no posts visible to authors, change it to teams level access
                $this->topic->topic_access = TITANIA_ACCESS_TEAMS;
            }
        }
        // Sync the first topic post if required
        if ($this->post_id == $this->topic->topic_first_post_id) {
            $this->topic->sync_first_post($this->post_id);
        }
        // Sync the last topic post if required
        if ($this->post_id == $this->topic->topic_last_post_id) {
            $this->topic->sync_last_post($this->post_id);
        }
        // Submit the topic to store the updated information
        $this->topic->submit();
        // Remove from the search index
        titania_search::delete($this->post_type, $this->post_id);
        // @todo remove attachments and other things
        // Remove any attention items
        $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
			WHERE attention_object_type = ' . TITANIA_POST . '
				AND attention_object_id = ' . $this->post_id;
        phpbb::$db->sql_query($sql);
        // Decrement the user's postcount if we must
        if (!$this->post_deleted && $this->post_approved && in_array($this->post_type, titania::$config->increment_postcount)) {
            phpbb::update_user_postcount($this->post_user_id, '-');
        }
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
        // Initiate self-destruct mode
        parent::delete();
        // Check if the topic is empty
        $flags = titania_count::get_flags(TITANIA_ACCESS_TEAMS, true, true);
        if (titania_count::from_db($this->topic->topic_posts, $flags) <= 0) {
            // Remove any subscriptions to this topic
            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
				WHERE watch_object_type = ' . TITANIA_TOPIC . '
					AND watch_object_id = ' . $this->topic->topic_id;
            phpbb::$db->sql_query($sql);
            // Remove any tracking for this topic
            titania_tracking::clear_item(TITANIA_TOPIC, $this->topic->topic_id);
            // Delete the now empty topic
            $sql = 'DELETE FROM ' . TITANIA_TOPICS_TABLE . '
				WHERE topic_id = ' . $this->topic->topic_id;
            phpbb::$db->sql_query($sql);
        }
    }
示例#3
0
/**
* Load contribution
*
* Call this AFTER you have loaded the main object (like the FAQ item if requested for example)
*
* @param mixed $contrib contrib_id (always send if you have loaded an item for this contrib!)
*/
function load_contrib($contrib_id = false)
{
    $contrib = request_var('id', 0) ? request_var('id', 0) : utf8_normalize_nfc(request_var('c', '', true));
    $type = request_var('type', '');
    // Load the contribution
    titania::$contrib = new titania_contribution();
    if (!titania::$contrib->load($contrib)) {
        trigger_error('CONTRIB_NOT_FOUND');
    }
    // Make sure the contrib requested is the same as the contrib loaded
    if ($contrib_id !== false && $contrib_id != titania::$contrib->contrib_id || $type != titania_types::$types[titania::$contrib->contrib_type]->url) {
        // Mismatch, redirect
        redirect(titania::$contrib->get_url(basename(request_var('page', 'details'))));
    }
    // Put the author in titania::$author
    titania::$author = titania::$contrib->author;
    // Check to see if the currently accessing user is an author
    if (titania::$access_level == TITANIA_ACCESS_PUBLIC && phpbb::$user->data['is_registered'] && !phpbb::$user->data['is_bot']) {
        if (titania::$contrib->is_author || titania::$contrib->is_active_coauthor) {
            titania::$access_level = TITANIA_ACCESS_AUTHORS;
        }
    }
    // Count the number of FAQ items to display
    $flags = titania_count::get_flags(titania::$access_level);
    $faq_count = titania_count::from_db(titania::$contrib->contrib_faq_count, $flags);
    /**
     * Menu Array
     *
     * 'filename' => array(
     *	'title'		=> 'nav menu title',
     * 	'url'		=> $page_url,
     *	'auth'		=> ($can_see_page) ? true : false, // Not required, always true if missing
     * ),
     */
    $nav_ary = array('details' => array('title' => 'CONTRIB_DETAILS', 'url' => titania::$contrib->get_url()), 'faq' => array('title' => 'CONTRIB_FAQ', 'url' => titania::$contrib->get_url('faq'), 'auth' => titania::$access_level != TITANIA_ACCESS_PUBLIC || $faq_count ? true : false, 'count' => $faq_count), 'support' => array('title' => 'CONTRIB_SUPPORT', 'url' => titania::$contrib->get_url('support'), 'auth' => titania::$config->support_in_titania || titania::$access_level < TITANIA_ACCESS_PUBLIC ? true : false), 'manage' => array('title' => 'CONTRIB_MANAGE', 'url' => titania::$contrib->get_url('manage'), 'auth' => (titania::$contrib->is_author || titania::$contrib->is_active_coauthor) && phpbb::$auth->acl_get('u_titania_post_edit_own') && !in_array(titania::$contrib->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || phpbb::$auth->acl_get('u_titania_mod_contrib_mod') || titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')));
    // Display nav menu
    $page = request_var('page', '');
    titania::generate_nav($nav_ary, $page, 'details');
    // Search for a category with the same name as the contrib type.  This is a bit ugly, but there really isn't any better option
    $categories_ary = titania::$cache->get_categories();
    foreach ($categories_ary as $category_id => $category_row) {
        $category_row['category_name'] = isset(phpbb::$user->lang[$category_row['category_name']]) ? phpbb::$user->lang[$category_row['category_name']] : $category_row['category_name'];
        if ($category_row['category_name'] == titania_types::$types[titania::$contrib->contrib_type]->lang || $category_row['category_name'] == titania_types::$types[titania::$contrib->contrib_type]->langs) {
            $category_object = new titania_category();
            $category_object->__set_array($categories_ary[$category_id]);
            // Generate the main breadcrumbs
            titania::generate_breadcrumbs(array($category_object->category_name => titania_url::build_url($category_object->get_url())));
            break;
        }
    }
    titania::generate_breadcrumbs(array(titania::$contrib->contrib_name => titania::$contrib->get_url()));
    if ($page) {
        titania::generate_breadcrumbs(array($nav_ary[$page]['title'] => $nav_ary[$page]['url']));
    }
}