/**
  * @param int $offset
  * @param int $limit
  * @return ForumThread[]
  */
 public static function findRecentForActiveUser($offset = 0, $limit = 20)
 {
     if (WebApp::get()->user()->isConnected() && ($sections = ForumUser2Section::findAllByAttributes(['user_id' => WebApp::get()->user()->id, 'banned' => 0]))) {
         return self::_findRecent($sections, $limit, $offset);
     } elseif (WebApp::get()->user()->isGuest()) {
         return self::_findRecent([null], $limit, $offset, 0);
     }
     return [];
 }
Beispiel #2
0
 public function reloadRights()
 {
     if (WebApp::get()->user()->isGuest()) {
         return false;
         // no rights to load if no user is logged in
     }
     Session::get()->delete($this->sessionKey);
     $user2Sections = ForumUser2Section::findAllByAttributes(['user_id' => WebApp::get()->user()->id]);
     $this->user2Sections = [];
     foreach ($user2Sections as $user) {
         $this->user2Sections[$user->section_id] = ['muted' => $user->muted, 'banned' => $user->banned, 'title_id' => $user->title_id, 'title_string' => $user->title ? $user->title->title : '', 'group_id' => $user->group_id, 'group_string' => $user->group->full_name, 'member_since' => $user->member_since, 'groupRights' => ['admin' => $user->group->admin, 'moderator' => $user->group->moderator, 'newthread' => $user->group->newthread, 'threadreply' => $user->group->threadreply, 'canread' => $user->group->canread]];
     }
     Session::get()->set($this->sessionKey, ['user2Sections' => $this->user2Sections, 'userId' => WebApp::get()->user()->id]);
 }