functions_post_oo.php
function get_topic($all_posts = false)
	{
		if(!$this->_topic)
		{
			if($this->post_id)
			{
				//existing post, load existing topic
				$this->_topic = topic::get($this->topic_id, $all_posts);

				//insert $this into topic->posts array
				if($all_posts)
				{
					//this post was also loaded from database, replace it with $this
					for($i=0; $i<sizeof($this->_topic->posts); $i++)
					{
						if($this->_topic->posts[$i]->post_id == $this->post_id)
						{
							//found it
							$this->_topic->posts[$i] = &$this;
							break;
						}
					}
				}
				else
				{
					//no posts were loaded in topic::get(), add our post to topic->posts
					$this->_topic->posts[] = &$this;
				}
			}
			else
			{
				//new post, generate topic
				$this->_topic = topic::from_post($this);
			}
		}
		return $this->_topic;
	}
function get_topic($all_posts = false)
	{
		if(!$this->_topic)
		{
			if($this->post_id)
			{
				//existing post, load existing topic
				$this->_topic = topic::get($this->topic_id, $all_posts);

				//insert $this into topic->posts array
				if($all_posts)
				{
					//this post was also loaded from database, replace it with $this
					for($i=0; $i<sizeof($this->_topic->posts); $i++)
					{
						if($this->_topic->posts[$i]->post_id == $this->post_id)
						{
							//found it
							$this->_topic->posts[$i] = &$this;
							break;
						}
					}
				}
				else
				{
					//no posts were loaded in topic::get(), add our post to topic->posts
					$this->_topic->posts[] = &$this;
				}
			}
			else
			{
				//new post, generate topic
				$this->_topic = topic::from_post($this);
			}
		}
		return $this->_topic;
	}
function get_topic ( $ all_posts = false ) { if ( ! $ this -> _topic ) { if ( $ this -> post_id ) { //existing post, load existing topic $ this -> _topic = topic :: get ( $ this -> topic_id , $ all_posts ) ; //insert $this into topic->posts array if ( $ all_posts ) { //this post was also loaded from database, replace it with $this for ( $ i = 0 ; $ i < sizeof ( $ this -> _topic -> posts ) ; $ i ++ ) { if ( $ this -> _topic -> posts [ $ i ] -> post_id == $ this -> post_id ) { //found it $ this -> _topic -> posts [ $ i ] = & $ this ; break ; } } } else { //no posts were loaded in topic::get(), add our post to topic->posts $ this -> _topic -> posts [ ] = & $ this ; } } else { //new post, generate topic $ this -> _topic = topic :: from_post ( $ this ) ; } } return $ this -> _topic ; }
loads and returns the topic for this post
@param all_posts whether to load all other posts of the topic into topic->posts
loads and returns the topic for this post