/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data = $this->project->find($id);
     $group = Sentry::findGroupByName('Project Manager');
     $users = Sentry::findAllUsersInGroup($group);
     return View::make('projects.edit')->with('projects', $data)->with('users', $users);
 }
Exemplo n.º 2
0
 public function deleteRole($id)
 {
     PermApi::access_check('manage_permissions');
     try {
         DB::beginTransaction();
         // start the DB transaction
         $group = Sentry::findGroupById($id);
         $authenticatedGroup = Sentry::findGroupById(3);
         // super admin group cannot be deleted
         if ($id == 1 || $id == 3) {
             SentryHelper::setMessage('This role cannot be deleted.', 'warning');
             return Redirect::to('user/permission/list');
         }
         // assign authenticated user group
         $users = Sentry::findAllUsersInGroup($group);
         foreach ($users as $user) {
             $user->addGroup($authenticatedGroup);
         }
         // delete group
         $group->delete();
         // clear permission in group mapping
         DB::table('permission_in_group')->where('group_id', $id)->delete();
         DB::table('users_groups')->where('user_id', $id)->update(array('group_id' => $authenticatedGroup->id));
         DB::commit();
         // commit the DB transaction
         SentryHelper::setMessage('Role deleted, all users of this role are now Authenticated users.');
         return Redirect::to('user/permission/list');
     } catch (\Exception $e) {
         DB::rollback();
         // something went wrong
     }
 }
Exemplo n.º 3
0
 public function checkForOtherAdmins($data)
 {
     try {
         $userId = $data['userid'];
         $group = \Sentry::findGroupByName('admin');
         $users = \Sentry::findAllUsersInGroup($group)->toArray();
         if (sizeof($users) == 0) {
             throw new \Exception('this cant be right');
         }
         if (sizeof($users) == 1) {
             if ($users[0]['id'] == $userId) {
                 return false;
             }
         }
         return true;
     } catch (\Exception $e) {
         \Log::error('Something Went Wrong in User Repository - checkForOtherAdmins():' . $e->getMessage());
     }
 }