/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $group = $this->groups->find($id);
     Javascript::put('groups', MemberGroup::all());
     Javascript::put('form', $group);
     return view('backend.forums.membergroups.edit');
 }
Ejemplo n.º 2
0
 public function patchPermissions($id, Request $request)
 {
     $groups = $request->all();
     foreach ($groups as $name => $permissions) {
         if ($group = MemberGroup::byName($name)->first()) {
             $groupPermissions = $group->permissions()->Board($id)->first();
             $groupPermissions->update($permissions);
         }
     }
     return response()->json(['result' => 'Success']);
 }
Ejemplo n.º 3
0
 /**
  * Get the guest group object
  *
  * @return mixed
  */
 public static function guestGroup()
 {
     return MemberGroup::find(1);
 }
 public function getMembers(MemberGroup $group)
 {
     return $group->members();
 }
 /**
  * Creates a new board from form input from create_board partial view
  *
  * @param $request
  * @return bool
  * @internal param $input
  *
  */
 public function createNewBoard($request)
 {
     $this->validateRequest($request);
     $input = $request->all();
     $boardSettings = $this->initData($input);
     $permissions = new BoardPermissions(['permissions']);
     $guestPermissions = array('can_read' => 1, 'can_reply' => 0, 'can_create_thread' => 0, 'can_create_poll' => 0, 'can_moderate' => 0, 'can_sticky' => 0);
     if (isset($boardSettings['sub_child'])) {
         $board = $boardSettings['parent']->children()->create($boardSettings['boardValues']);
     } else {
         $parent = $boardSettings['parent']->parent;
         $board = $parent->children()->create($boardSettings['boardValues']);
     }
     $boardSettings['permissions']['board_id'] = $board->id;
     MemberGroup::defaultGroup()->permissions()->Board($board->id)->create($boardSettings['permissions']);
     $guestPermissions['board_id'] = $board->id;
     if ($boardSettings['permissions']['can_read'] == true) {
         MemberGroup::guestGroup()->permissions()->Board($board->id)->create($guestPermissions);
     } else {
         $guestPermissions['can_read'] = 0;
         MemberGroup::guestGroup()->permissions()->Board($board->id)->create($guestPermissions);
     }
     return true;
 }
Ejemplo n.º 6
0
 public function getDefaultPermissions()
 {
     $defaultGroup = MemberGroup::defaultGroup();
     return $defaultGroup->permissions()->Board($this->id)->firstOrCreate(['board_id' => $this->id]);
     //return $this->permissions()->firstOrCreate([]);
 }