コード例 #1
0
 /**
  * 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);
     }
 }
コード例 #2
0
ファイル: UserGroup.php プロジェクト: jrafaelca/Doptor
 public static function all_groups()
 {
     $groups = array();
     foreach (Sentry::findAllGroups() as $group) {
         $groups[$group->id] = $group->name;
     }
     return $groups;
 }
コード例 #3
0
 /**
  * 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'));
 }
コード例 #4
0
ファイル: SentryHelper.php プロジェクト: l4mod/sentryuser
 public static function getGroupsArray()
 {
     $groups = Sentry::findAllGroups();
     $arrGroups = array();
     foreach ($groups as $group) {
         $arrGroups[$group->id] = $group->name;
     }
     return $arrGroups;
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 /**
  * 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');
     }
 }
コード例 #7
0
ファイル: Groups.php プロジェクト: jalbertbowden/core
 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;
 }
コード例 #8
0
 /**
  * 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]);
 }
コード例 #9
0
ファイル: UserController.php プロジェクト: jalbertbowden/core
 /**
  * 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);
 }
コード例 #10
0
 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);
         }
     }
 }
コード例 #11
0
 /**
  * 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);
 }
コード例 #12
0
 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();
 }
コード例 #13
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     return View::make('admin.groups.index')->with('groups', Sentry::findAllGroups());
 }
コード例 #14
0
ファイル: form.blade.php プロジェクト: eldalo/jarvix
						<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>
コード例 #15
0
ファイル: routes.php プロジェクト: thomaswelton/laravel
});
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());
});
コード例 #16
0
 /**
  * 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()));
 }
コード例 #17
0
ファイル: UserController.php プロジェクト: l4mod/sentryuser
 /**
  * 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);
 }
コード例 #18
0
 /**
  * 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) {
     }
 }
コード例 #19
0
 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);
     }
 }
コード例 #20
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $roles = \Sentry::findAllGroups();
     return View::make('users.create')->with('roles', $roles);
 }
コード例 #21
0
 public function groupList()
 {
     $groups = Sentry::findAllGroups();
     return Response::json($groups, 200);
 }
コード例 #22
0
ファイル: Eloquent.php プロジェクト: minhliem86/liemphan-cms
 public function findAllGroup()
 {
     return \Sentry::findAllGroups();
 }
コード例 #23
0
 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()]);
 }
コード例 #24
0
 /**
  * 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');
     }
 }
コード例 #25
0
 /**
  * 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);
     }
 }
コード例 #26
0
 /**
  * Display a listing of the resource.
  * GET /roles
  *
  * @return Response
  */
 public function index()
 {
     $groups = Sentry::findAllGroups();
     return View::make('roles.index', compact('groups'));
 }