Inheritance: extends Illuminate\Database\Eloquent\Model
Example #1
0
 public function authorizePost($forum, $topic)
 {
     if (Authorize::canPost(Auth::user(), $forum, $topic) === false) {
         abort(403);
     }
 }
Example #2
0
File: User.php Project: ppy/osu-web
 public function refreshForumCache($forum = null, $postsChangeCount = 0)
 {
     if ($forum !== null) {
         if (Forum\Authorize::increasesPostsCount($this, $forum) !== true) {
             $postsChangeCount = 0;
         }
         // In case user_posts is 0 and $postsChangeCount is -1.
         $newPostsCount = DB::raw("GREATEST(CAST(user_posts AS SIGNED) + {$postsChangeCount}, 0)");
     } else {
         $newPostsCount = $this->forumPosts()->whereIn('forum_id', Forum\Authorize::postsCountedForums($this))->count();
     }
     $lastPost = $this->forumPosts()->last()->select('post_time')->first();
     // null time will be stored as 0 by the db. Nothing can be done about
     // it, short of changing the column to allow null.
     $lastPostTime = $lastPost !== null ? $lastPost->post_time : null;
     return $this->update(['user_posts' => $newPostsCount, 'user_lastpost_time' => $lastPostTime]);
 }
Example #3
0
 public function canBeRepliedBy($user)
 {
     $key = $user === null ? '-1' : "{$user->user_id}";
     if (!isset($this->_canBeRepliedBy[$key])) {
         $this->_canBeRepliedBy[$key] = Authorize::canPost($user, $this->forum, $this);
     }
     return $this->_canBeRepliedBy[$key];
 }
Example #4
0
 public function checkForumTopicStore($user, $forum)
 {
     $prefix = 'forum.topic.store.';
     $this->ensureLoggedIn($user);
     $this->ensureCleanRecord($user);
     if ($user->isGMT()) {
         return 'ok';
     }
     if (!$this->doCheckUser($user, 'ForumView', $forum)->can()) {
         return $prefix . 'no_forum_access';
     }
     if (!$forum->isOpen()) {
         return $prefix . 'forum_closed';
     }
     if (!ForumAuthorize::aclCheck($user, 'f_post', $forum)) {
         return $prefix . 'no_permission';
     }
     return 'ok';
 }