Example #1
0
 public function show($groupName)
 {
     $group = Group::name($groupName)->with('creator')->firstOrFail();
     $group->checkAccess();
     $stats = ['contents' => intval(Content::where('group_id', $group->getKey())->count()), 'comments' => intval(Content::where('group_id', $group->getKey())->sum('comments')), 'entries' => intval(Entry::where('group_id', $group->getKey())->count()), 'banned' => intval(GroupBan::where('group_id', $group->getKey())->count()), 'subscribers' => $group->subscribers, 'moderators' => intval(GroupModerator::where('group_id', $group->getKey())->count())];
     return array_merge($group->toArray(), ['stats' => $stats]);
 }
Example #2
0
 public function removeBan()
 {
     $ban = GroupBan::findOrFail(request('id'));
     if (!user()->isModerator($ban->group)) {
         abort(403, 'Access denied');
     }
     $ban->delete();
     return response()->json(['status' => 'ok']);
 }
Example #3
0
 /**
  * @param  Group  $group
  * @return \Illuminate\View\View
  */
 public function showSettings($group)
 {
     if (!user()->isAdmin($group)) {
         abort(403, 'Access denied');
     }
     $filename = $group->style ?: Str::lower($group->urlname) . '.css';
     $disk = Storage::disk('styles');
     $data['group'] = $group;
     $data['css'] = $disk->exists($filename) ? $disk->get($filename) : '';
     $data['moderators'] = GroupModerator::with('user')->where('group_id', $group->getKey())->get();
     $data['bans'] = GroupBan::with('user')->where('group_id', $group->getKey())->get();
     return view('group.settings', $data);
 }
Example #4
0
 public function banUser(User $user, $reason = '')
 {
     if ($user->isBanned($this)) {
         return false;
     }
     $ban = new GroupBan();
     $ban->group()->associate($this);
     $ban->user()->associate($user);
     $ban->moderator()->associate(Auth::user());
     $ban->reason = Input::get('reason');
     $ban->save();
 }
Example #5
0
 public function removeBan()
 {
     $ban = GroupBan::findOrFail(Input::get('id'));
     if (!Auth::user()->isModerator($ban->group)) {
         App::abort(403, 'Access denied');
     }
     $ban->delete();
     return Response::json(['status' => 'ok']);
 }