Exemple #1
0
 public function canPostWithSubject(PermissionUser $user, $asReply)
 {
     // If we don't allow subjects and user is not board admin
     $canPostSubject = $this->getConfig('postsAllowSubject') || $user->canEditConfig($this);
     // ... and this is not a new thread and we don't require subjects for new threads
     $canPostSubject = $canPostSubject || !$asReply && $this->getConfig('threadRequireSubject');
     return $canPostSubject;
 }
 /**
  * Narrows query to only roles which can be manipulated by this user.
  *
  * @param  \App\Contracts\PermissionUser $user
  * @param  \App\Board  $board
  * @return Query
  */
 public function scopeWhereLighterThanUser($query, PermissionUser $user, Board $board = null)
 {
     return $query->where(function ($query) use($user, $board) {
         $weight = -1;
         if ($user->canEditConfig(null)) {
             $weight = Role::WEIGHT_ADMIN;
         } else {
             if (!is_null($board) && $user->canEditConfig($board)) {
                 $weight = Role::WEIGHT_OWNER;
             }
         }
         $query->where('weight', '<', $weight);
     });
 }
 public function canEditConfig(PermissionUser $user)
 {
     return $user->canEditConfig($this);
 }