/** * Setup the layout used by the controller. * * @return void */ protected function setupLayout() { View::share("h4ss2_groups", Sentry::findAllGroups()); if (!is_null($this->layout)) { $this->layout = View::make($this->layout); } }
public static function all_groups() { $groups = array(); foreach (Sentry::findAllGroups() as $group) { $groups[$group->id] = $group->name; } return $groups; }
/** * Display a listing of groups * * @return Response */ public function index() { if (!Sentry::getUser()) { return Redirect::route('sessions.create'); } $groups = Sentry::findAllGroups(); return View::make('groups.index', compact('groups')); }
public static function getGroupsArray() { $groups = Sentry::findAllGroups(); $arrGroups = array(); foreach ($groups as $group) { $arrGroups[$group->id] = $group->name; } return $arrGroups; }
public function getModificar($id = null) { if ($id == null) { $data['grupo'] = new \Grupo(); $permisosGlobales = \Grupo::$permisos; try { $sentryGroup = \Sentry::findAllGroups(); } catch (Exception $ex) { $sentryGroup = null; } if (is_object($sentryGroup)) { $data['permisos'] = array(); foreach ($permisosGlobales as $key => $permiso) { $data['permisos'][$key] = array('Descripcion' => array_values($permiso)[0]); $tiene = false; foreach ($permiso as $per => $descripcion) { if ($sentryGroup->hasAccess($per)) { $data['permisos'][$key][$per] = $descripcion; $tiene = true; } } if (!$tiene) { unset($data['permisos'][$key]); } } } else { $data['permisos'] = array('' => array()); } return \View::make('administracion.seguridad.creargrupos', $data); } $data['grupo'] = \Grupo::find($id); $permisosGlobales = \Grupo::$permisos; try { $sentryGroup = \Sentry::findGroupById($id); } catch (Exception $ex) { $sentryGroup = null; } if (is_object($sentryGroup)) { $data['permisos'] = array(); foreach ($permisosGlobales as $key => $permiso) { $data['permisos'][$key] = array('Descripcion' => array_values($permiso)[0]); $tiene = false; foreach ($permiso as $per => $descripcion) { if ($sentryGroup->hasAccess($per)) { $data['permisos'][$key][$per] = $descripcion; $tiene = true; } } if (!$tiene) { unset($data['permisos'][$key]); } } } else { $data['permisos'] = array('' => array()); } return \View::make('administracion.seguridad.gruposform', $data); }
/** * admin.groups.index * */ public function getAdminIndex() { if (Sentry::hasAnyAccess(['groups_index'])) { $groups = Sentry::findAllGroups(); return View::make('groups.admin.index', ['groups' => $groups]); } else { return Redirect::route('pages.error'); } }
public function export($identifier = null) { // Request all the group $sentry_data = \Sentry::findAllGroups(); // Push them in an array $groups = array(); foreach ($sentry_data as $g) { array_push($groups, $g->toArray()); } return $groups; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $user = $this->user->find($id); $groups = Sentry::findAllGroups(); $user_group = $user->getGroups()->first()->id; $array_groups = []; foreach ($groups as $group) { $array_groups = array_add($array_groups, $group->id, $group->name); } return View::make('protected.admin.edit_user', ['user' => $user, 'groups' => $array_groups, 'user_group' => $user_group]); }
/** * Admin.user.view */ public function getIndex() { // Set permission Auth::requirePermissions('admin.user.view'); // Get all users $users = \Sentry::findAllUsers(); // Get all groups $groups = \Sentry::findAllGroups(); // Get error $error = Flash::get(); $view = \View::make('ui.users.list')->with('title', 'User management | The Datatank')->with('users', $users)->with('groups', $groups)->with('error', $error); return \Response::make($view); }
public function PUT_updateUser($id) { $theme = Theme::uses('notebook')->layout('main'); $theme->setMenu('user.user'); try { $user = Sentry::findUserById($id); $user->email = Input::get('email'); $user->first_name = Input::get('full_name'); if (Input::has('password')) { $user->password = Input::get('password'); } $all_groups = Sentry::findAllGroups(); if (is_array($all_groups)) { foreach ($all_groups as $key => $all_group) { $findGroup = Sentry::findGroupById($all_group->id); $user->removeGroup($findGroup); } } $groups = Input::get('groups'); if (is_array($groups)) { foreach ($groups as $key => $group) { $adminGroup = Sentry::findGroupById($group); $user->addGroup($adminGroup); } } if ($user->save()) { $success = 'User information was updated'; } else { $failed = 'User information was not updated'; } } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { $failed = 'Login field is required.'; } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { $failed = 'Password field is required.'; } catch (Cartalyst\Sentry\Users\UserExistsException $e) { $failed = 'User with this login already exists.'; } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) { $failed = 'Group was not found.'; } if (!empty($failed)) { return Redirect::to(route('user.list'))->with('STATUS_FAIL', $failed); } else { if (!empty($success)) { return Redirect::to(route('user.list'))->with('STATUS_OK', $success); } } }
/** * Admin.group.view */ public function getIndex() { // Set permission Auth::requirePermissions('admin.group.view'); // Get all users $users = \Sentry::findAllUsers(); // Get all groups $groups = \Sentry::findAllGroups(); // Get all permissions $permission_groups = \Config::get('permissions'); $input_permission_groups = \Config::get('tdt/input::permissions'); if (!empty($input_permission_groups)) { $permission_groups = array_merge($permission_groups, $input_permission_groups); } // Get error $error = Flash::get(); return \View::make('ui.groups.list')->with('title', 'Group management | The Datatank')->with('users', $users)->with('groups', $groups)->with('permission_groups', $permission_groups)->with('error', $error); return \Response::make($view); }
public function GET_assignGroupForm() { $theme = Theme::uses('notebook')->layout('main'); $theme->asset()->container('post-scripts')->usePath()->add('laravel', 'js/laravel.js'); $theme->setMenu('user.group'); $routes = Route::getRoutes(); $groups = Sentry::findAllGroups(); $permits = array(); if (is_array($groups)) { foreach ($groups as $group) { $findGroup = Sentry::findGroupById($group->id); $permissions = $findGroup->getPermissions(); $permits[$group->name] = array(); foreach ($permissions as $key => $permission) { $permits[$group->name][] = $key; } } } $params = array('routes' => $routes, 'groups' => $groups, 'permits' => $permits); return $theme->scope('user.group-assign', $params)->render(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // return View::make('admin.groups.index')->with('groups', Sentry::findAllGroups()); }
<div class="icon-object border-success text-success"><i class="icon-plus3"></i></div> <h5 class="content-group-lg">Nuevo Usuario <small class="display-block">Todos los campos son obligatorios</small></h5> </div> <div class="form-group has-feedback"> <?php $readonly = !empty($user) ? 'readonly' : ''; ?> <input type="text" name="username" class="form-control" placeholder="Usuario" required value="{{ $user->username or '' }}" {{ $readonly }}> <div class="form-control-feedback"> <i class="icon-user-plus text-muted"></i> </div> </div> <div class="form-group has-feedback"> <select class="form-control" name="group" id="group" required> <?php $groups = Sentry::findAllGroups(); ?> <?php $userGroup = !empty($user) ? $user->getGroups() : 0; ?> <option value="">Seleccionar Perfil</option> @foreach ( $groups as $item ) <?php $selected = ''; ?> @if ( $userGroup ) <?php $selected = $userGroup['0']['id'] == $item->id ? 'selected' : ''; ?> @endif <option value="{{ $item->id }}" {{ $selected }}>{{ $item->name }}</option>
}); Route::get('/login', 'AuthController@getLogin'); Route::get('/logout', 'AuthController@getLogout'); Route::post('/login', 'AuthController@postLogin'); Route::get('/password', 'AuthController@getForgot'); Route::post('/password', 'AuthController@postForgot'); Route::controller('/password', 'AuthController'); Route::controller('/', 'HomeController'); /* |-------------------------------------------------------------------------- | View Composers |-------------------------------------------------------------------------- */ // View composer for all admin views View::composer('admin.*', function ($view) { $adminUser = false; if (Sentry::check()) { $user = Sentry::getUser(); if ($user->hasAccess('admin')) { $adminUser = $user; } } $view->with('adminUser', $adminUser); }); View::composer(array('admin.layouts.default', 'layouts.bootstrap'), function ($view) { $rjs_config = File::exists(public_path() . '/assets/scripts/config.js') ? File::get(public_path() . '/assets/scripts/config.js') : ''; $view->with('rjs_config', $rjs_config); }); View::composer('admin.user.form', function ($view) { $view->with('groups', Sentry::findAllGroups()); });
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($lang, $id) { try { $user = Sentry::findUserById($id); $user->first_name = Input::get('first_name', ''); $user->last_name = Input::get('last_name', ''); $user->email = Input::get('email'); $groups = Sentry::findAllGroups(); $groups_arr = Input::get('groups', array()); foreach ($groups as $group) { if (in_array($group->id, $groups_arr)) { $user->addGroup($group); } else { if ($user->inGroup($group)) { $user->removeGroup($group); } } } if (Input::get('password_change') == 'change') { $user->password = (string) Input::get('password'); } $user->activated = Input::get('activated') == 'activated' ? 1 : 0; $user->updated_at = time(); if ($user->save()) { Session::flash('message', trans('kuu-validation.user_information_was_updated')); } else { Session::flash('error_message', trans('kuu-validation.user_information_was_not_updated')); } } catch (Cartalyst\Sentry\Users\UserExistsException $e) { Session::flash('error_message', trans('kuu-validation.user_with_this_login_already_exists')); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { Session::flash('error_message', trans('kuu-validation.user_was_not_found') . ' ' . $id); } //return Redirect::to('/admin/user'); return Redirect::route('admin.user', array('lang' => App::getLocale())); }
/** * Returning the user add form view. */ public function handleUserAdd() { // checking the access for the user PermApi::access_check('create_users'); // get all sentry groups $roles = Sentry::findAllGroups(); $this->layout->content = View::make('sentryuser::add-user')->with('roles', $roles); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // try { $permission = Permission::find($id); $groups = Sentry::findAllGroups(); foreach ($groups as $group) { if ($group->hasAccess(array($permission->name))) { $group->permissions = array("{$permission->name}" => 0); $group->save(); } } Permission::destroy($id); } catch (Exception $e) { } }
private function onAddGroupToUser($user, $groupIDs) { $allGroups = \Sentry::findAllGroups(); foreach ($allGroups as $group) { $flushGroup = \Sentry::findGroupById($group->id); $user->removeGroup($flushGroup); } foreach ($groupIDs as $id) { $group = \Sentry::findGroupById($id); $user->addGroup($group); } }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $roles = \Sentry::findAllGroups(); return View::make('users.create')->with('roles', $roles); }
public function groupList() { $groups = Sentry::findAllGroups(); return Response::json($groups, 200); }
public function findAllGroup() { return \Sentry::findAllGroups(); }
public function edit($id) { $thisUser = Sentry::findUserById($id); $userGroup = $thisUser->getGroups()[0]; return View::make('backend.users.edit', ['user' => $this->user, 'isAdmin' => $this->isAdmin, 'configs' => $this->configs, 'logged_in_for' => $this->logged_in_for, 'activeParent' => $this->activeParent, 'active' => 'profile', 'thisUser' => $thisUser, 'userGroup' => $userGroup, 'allGroups' => Sentry::findAllGroups()]); }
/** * admin.users.role.post * */ public function postAdminRole($id) { if (Sentry::hasAnyAccess(['users_update'])) { $sentry = Sentry::findUserById($id); $groups_1 = Sentry::findAllGroups(); $groups = Input::get('groups'); foreach ($groups_1 as $group_1) { $sentry->groups()->detach($group_1); } if (isset($groups)) { foreach ($groups as $group) { $sentry->groups()->attach($group); } } return Redirect::route('admin.users.role', $id)->with(['message' => 'Fue un exito la operación!', 'class' => 'success']); } else { return Redirect::route('pages.error'); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //GET if ($id == "groups") { $this->layout->title = APPNAME; $groups = Sentry::findAllGroups(); $this->layout->content = View::make('main.admin.groups')->with('groups', $groups); } elseif ($id == "users") { $this->layout->title = APPNAME; $users = Sentry::findAllUsers(); $this->layout->content = View::make('main.admin.users')->with('users', $users); } }
/** * Display a listing of the resource. * GET /roles * * @return Response */ public function index() { $groups = Sentry::findAllGroups(); return View::make('roles.index', compact('groups')); }