Ejemplo n.º 1
0
 public function edit($id = 0)
 {
     if ($id == 0) {
         $old = Input::old();
         $data = array();
         if (!empty($old)) {
             $data = $old;
         }
         $data['groups'] = array();
     } else {
         $data = Sentry::findUserById($id);
         $groupscursor = $data->getGroups();
         $groups = array();
         foreach ($groupscursor as $v) {
             $groups[] = $v['id'];
         }
         $data['groups'] = $groups;
     }
     $groups = Groups::get();
     return view('users::edit', array('data' => $data, 'groups' => $groups));
 }
Ejemplo n.º 2
0
 public function deletepermission()
 {
     $input = Input::all();
     $objPermission = new Permission();
     foreach ($input['aids'] as $v) {
         $objPermission->destroy($v);
     }
     $permissions = $objPermission->get();
     $listkey = array();
     foreach ($permissions as $v) {
         $listkey[] = $v['key'];
     }
     $objGroup = new Groups();
     $groups = $objGroup->get();
     foreach ($groups as $v) {
         $group = Sentry::findGroupById($v['id']);
         $groupPermissions = $group->getPermissions();
         foreach ($groupPermissions as $k => $vl) {
             if (!in_array($k, $listkey)) {
                 $groupPermissions[$k] = 0;
             }
         }
         $group->permissions = $groupPermissions;
         $group->save();
     }
     return Response::json('1');
 }