Inheritance: extends Illuminate\Database\Eloquent\Model
Ejemplo n.º 1
0
 public function authorizePost($forum, $topic)
 {
     if (Authorize::canPost(Auth::user(), $forum, $topic) === false) {
         abort(403);
     }
 }
Ejemplo n.º 2
0
Archivo: User.php Proyecto: 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]);
 }
Ejemplo n.º 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];
 }
Ejemplo n.º 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';
 }