/** * Get the post object * * @param <int> $post_id * @return <object|bool> False if the post does not exist in the self::$posts array (load it first!) post object if it exists */ public static function get_post_object($post_id) { if (!isset(self::$posts[$post_id])) { return false; } // One can hope... $topic = topics_overlord::get_topic_object(self::$posts[$post_id]['topic_id']); $post = new titania_post(self::$posts[$post_id]['post_type'], $topic); $post->__set_array(self::$posts[$post_id]); return $post; }
/** * Quick load a topic * * @param int $topic_id * @return \titania_topic * @throws \OutOfBoundsException Throws exception if the topic does not exist. */ public function load_topic($topic_id) { \topics_overlord::load_topic($topic_id); $topic = \topics_overlord::get_topic_object($topic_id); if ($topic === false) { throw new \OutOfBoundsException($this->user->lang('NO_TOPIC')); } return $topic; }
$topic_id = request_var('t', 0); // Load the topic and contrib items if ($post_id) { $topic_id = topics_overlord::load_topic_from_post($post_id, true); // Load the topic into a topic object $topic = topics_overlord::get_topic_object($topic_id); if ($topic === false) { trigger_error('NO_TOPIC'); } // Load the contrib item load_contrib($topic->parent_id); } else { if ($topic_id) { topics_overlord::load_topic($topic_id, true); // Load the topic into a topic object $topic = topics_overlord::get_topic_object($topic_id); if ($topic === false) { trigger_error('NO_TOPIC'); } // Load the contrib item load_contrib($topic->parent_id); } else { // Load the contrib item load_contrib(); } } // Output the simple info on the contrib titania::$contrib->assign_details(true); if (!titania::$config->support_in_titania && titania::$access_level == TITANIA_ACCESS_PUBLIC) { titania::needs_auth(); }
/** * Quick load a topic * * @param mixed $topic_id * @return object */ public function load_topic($topic_id) { topics_overlord::load_topic($topic_id); $topic = topics_overlord::get_topic_object($topic_id); if ($topic === false) { trigger_error('NO_TOPIC'); } return $topic; }
/** * Load topic object. * * @param int $id Topic id. * @throws \Exception Throws exception if no topic found. * @return null */ protected function load_topic($id) { \topics_overlord::load_topic($id, true); $this->topic = \topics_overlord::get_topic_object($id); if ($this->topic === false || $this->topic->parent_id !== $this->contrib->contrib_id) { throw new \Exception($this->user->lang['NO_TOPIC']); } }