Example #1
0
 /**
  * Return the GlobalAnnouncements from the individual forums
  *
  * @return DataObjectSet
  */
 function GlobalAnnouncements()
 {
     /*return DataObject::get(
     			"ForumThread", 
     			"\"ForumThread\".\"IsGlobalSticky\" = 1 AND \"ForumPage\".\"ParentID\"={$this->ID}", 
     			"MAX(\"PostList\".\"Created\") DESC",	
     			"INNER JOIN \"Post\" AS \"PostList\" ON \"PostList\".\"ThreadID\" = \"ForumThread\".\"ID\" 
     		  	 INNER JOIN \"" . ForumHolder::baseForumTable() . "\" \"ForumPage\" ON \"ForumThread\".\"ForumID\"=\"ForumPage\".\"ID\"");
     		*/
     //Get all the forums with global sticky threads, and then get the most recent post for each of these
     $threads = DataObject::get('ForumThread', "\"ForumThread\".\"IsGlobalSticky\"=1 AND \"ForumPage\".\"ParentID\"={$this->ID}", '', "INNER JOIN \"" . ForumHolder::baseForumTable() . "\" AS \"ForumPage\" ON \"ForumThread\".\"ForumID\"=\"ForumPage\".\"ID\"");
     //Now go and get the most recent post for each of these forum threads
     $trimmed = new DataObjectSet();
     if ($threads) {
         foreach ($threads as $thread) {
             if ($thread->canView()) {
                 $post = DataObject::get_one('Post', "\"Post\".\"ThreadID\"={$thread->ID}", "\"Created\" DESC");
                 $thread->Post = $post;
                 $trimmed->Push($thread);
             }
         }
     }
     return $trimmed;
 }