/**
  * Return the GlobalAnnouncements from the individual forums
  *
  * @return DataObjectSet
  */
 function GlobalAnnouncements()
 {
     //dump(ForumHolder::baseForumTable());
     // Get all the forums with global sticky threads
     return ForumThread::get()->filter('IsGlobalSticky', 1)->innerJoin(ForumHolder::baseForumTable(), '"ForumThread"."ForumID"="ForumPage"."ID"', "ForumPage")->where('"ForumPage"."ParentID" = ' . $this->ID)->filterByCallback(function ($thread) {
         if ($thread->canView()) {
             $post = Post::get()->filter('ThreadID', $thread->ID)->sort('Post.Created DESC');
             $thread->Post = $post;
             return true;
         }
     });
 }
Пример #2
0
 /**
  * Note: See {@link testCanModerate()} for detailed permission tests.
  */
 public function testMarkAsSpamLink()
 {
     $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
     $this->assertFalse($spampost->isFirstPost());
     $forum = $spampost->Forum();
     $author = $spampost->Author();
     $moderator = $this->objFromFixture('Member', 'moderator');
     // moderator for "general" forum
     // without a logged-in moderator
     $this->assertFalse($spampost->MarkAsSpamLink(), 'Link not present by default');
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spampost->ID), DataModel::inst());
     $this->assertEquals(403, $response->getStatusCode());
     // with logged-in moderator
     $moderator->logIn();
     $this->assertNotEquals(false, $spampost->MarkAsSpamLink(), 'Link present for moderators on this forum');
     $this->assertNull($author->SuspendedUntil);
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spampost->ID), DataModel::inst());
     $this->assertFalse($response->isError());
     // removes the post
     $this->assertNull(Post::get()->byID($spampost->ID));
     // suspends the member
     $author = Member::get()->byID($author->ID);
     $this->assertNotNull($author->SuspendedUntil);
     // does not effect the thread
     $thread = ForumThread::get()->byID($spampost->Thread()->ID);
     $this->assertEquals('1', $thread->getNumPosts());
     // mark the first post in that now as spam
     $spamfirst = $this->objFromFixture('Post', 'SpamFirstPost');
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spamfirst->ID), DataModel::inst());
     // removes the thread
     $this->assertNull(ForumThread::get()->byID($spamfirst->Thread()->ID));
 }
Пример #3
0
 /**
  * Process's the moving of a given topic. Has to check for admin privledges,
  * passed an old topic id (post id in URL) and a new topic id
  */
 function doAdminFormFeatures($data, $form)
 {
     if (isset($data['ID'])) {
         $thread = ForumThread::get()->byID($data['ID']);
         if ($thread) {
             if (!$thread->canModerate()) {
                 return Security::permissionFailure($this);
             }
             $form->saveInto($thread);
             $thread->write();
         }
     }
     return $this->redirect($this->Link());
 }