Ejemplo n.º 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 = $this->tracking->get_track(TITANIA_TOPIC, $this->topic_id, true);
     $last_read_mark = max($last_read_mark, $this->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 = count::from_db($this->topic_posts, count::get_flags(access::PUBLIC_LEVEL, false, false));
     $total = count::from_db($this->topic_posts, count::get_flags(access::PUBLIC_LEVEL, false, true));
     $u_new_post = '';
     if ($this->unread) {
         $u_new_post = $this->get_url(false, array('view' => 'unread', '#' => 'unread'));
     }
     $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' => $u_new_post, 'U_VIEW_TOPIC' => $this->get_url(), 'U_VIEW_LAST_POST' => $this->get_url(false, 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 == access::TEAM_LEVEL ? true : false, 'S_ACCESS_AUTHORS' => $this->topic_access == access::AUTHOR_LEVEL ? true : false, 'FOLDER_STYLE' => $folder_img, '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;
 }
Ejemplo n.º 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 = count::get_flags(access::PUBLIC_LEVEL);
        if (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 = access::AUTHOR_LEVEL;
            $flags = count::get_flags(access::AUTHOR_LEVEL);
            if (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 = access::TEAM_LEVEL;
            }
        }
        // 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
        $this->search_manager->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();
        // Update topics posted table
        $this->topic->update_posted_status('remove', $this->post_user_id);
        // Check if the topic is empty
        $flags = count::get_flags(access::TEAM_LEVEL, true, true);
        if (count::from_db($this->topic->topic_posts, $flags) <= 0) {
            $this->topic->delete();
        }
    }
Ejemplo n.º 3
0
 /**
  * Assign navigation tabs.
  *
  * @param string $page	Current active page.
  * @return null
  */
 protected function generate_navigation($page)
 {
     // Count the number of FAQ items to display
     $flags = count::get_flags($this->access->get_level());
     $faq_count = count::from_db($this->contrib->contrib_faq_count, $flags);
     $is_disabled = in_array($this->contrib->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED));
     /**
      * 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' => $this->contrib->get_url()), 'faq' => array('title' => 'CONTRIB_FAQ', 'url' => $this->contrib->get_url('faq'), 'auth' => !$this->access->is_public() || $faq_count, 'count' => $faq_count), 'support' => array('title' => 'CONTRIB_SUPPORT', 'url' => $this->contrib->get_url('support'), 'auth' => $this->ext_config->support_in_titania || $this->access->get_level() < access::PUBLIC_LEVEL), 'demo' => array('title' => 'CONTRIB_DEMO', 'url' => '', 'auth' => !empty($this->contrib->contrib_demo)), 'manage' => array('title' => 'CONTRIB_MANAGE', 'url' => $this->contrib->get_url('manage'), 'auth' => $this->is_author && $this->auth->acl_get('u_titania_post_edit_own') && !$is_disabled || $this->auth->acl_get('u_titania_mod_contrib_mod') || $this->contrib->type->acl_get('moderate')));
     if ($this->contrib->contrib_demo) {
         $demo_menu = array();
         $allowed_branches = $this->contrib->type->get_allowed_branches(true);
         krsort($allowed_branches);
         $is_external = $this->contrib->contrib_status != TITANIA_CONTRIB_APPROVED || !$this->contrib->options['demo'];
         foreach ($allowed_branches as $branch => $name) {
             $demo_url = $this->contrib->get_demo_url($branch, !$is_external);
             if ($demo_url) {
                 $demo_menu[] = array('url' => $demo_url, 'title' => $name, 'external' => $is_external);
             }
         }
         if (sizeof($demo_menu) == 1) {
             $nav_ary['demo']['url'] = $demo_menu[0]['url'];
             $nav_ary['demo']['external'] = $demo_menu[0]['external'];
         } else {
             if (!empty($demo_menu)) {
                 $nav_ary['demo']['sub_menu'] = $demo_menu;
             } else {
                 unset($nav_ary['demo']);
             }
         }
     }
     $this->display->generate_nav($nav_ary, $page, 'details');
 }