コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $roles = $this->role->all();
     if (Request::ajax()) {
         $roles = Role::where('role', 'like', '%' . Input::get('term', '') . '%')->get(array('id', 'role'));
         return $roles;
     }
     return View::make('roles.index', compact('roles'));
 }
コード例 #2
0
 /**
  * Get list Permission filter by group
  * @return mixed
  */
 public function group()
 {
     $perms = $this->model->all(['name', 'id', 'display_name']);
     $group = [];
     foreach ($perms as $perm) {
         $p = explode('.', $perm->name);
         $group[$p[0]][$perm->id] = $perm->display_name;
     }
     return $group;
 }
コード例 #3
0
ファイル: UserRoleTest.php プロジェクト: alexhouse/trust
 /** @test */
 public function it_can_attach_and_detach_roles()
 {
     // add a single role to a user
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'Does not have admin role yet');
     $this->assertFalse($user->hasRole('Editor'), 'Does not have editor role yet');
     $this->assertFalse($user->hasRole('Blogger'), 'Does not have blogger role yet');
     $user->attachRoles(Role::all());
     $user = User::find(3);
     $this->assertTrue($user->hasRole('Admin'), 'Has admin role now');
     $this->assertTrue($user->hasRole('Editor'), 'Has editor role now');
     $this->assertTrue($user->hasRole('Blogger'), 'Has blogger role now');
     $user->detachRoles(1);
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'no admin role now');
     $this->assertTrue($user->hasRole('Editor'), 'Has editor role now');
     $this->assertTrue($user->hasRole('Blogger'), 'Has blogger role now');
     $user->detachRoles([2, 3]);
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'Does not have admin role yet');
     $this->assertFalse($user->hasRole('Editor'), 'Does not have editor role yet');
     $this->assertFalse($user->hasRole('Blogger'), 'Does not have blogger role yet');
     $user->attachRoles(Role::find(2));
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'Does not have admin role yet');
     $this->assertTrue($user->hasRole('Editor'), 'Does have editor role yet');
     $this->assertFalse($user->hasRole('Blogger'), 'Does not have blogger role yet');
 }
コード例 #4
0
ファイル: RolesCollection.php プロジェクト: mermetbt/biome
 public function getRoles()
 {
     if (empty($this->roles)) {
         $this->roles = Role::all();
     }
     return $this->roles;
 }
コード例 #5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = User::find($id);
     $userRole = $user->roles()->first();
     $user['rol'] = $userRole;
     return View::make('users.edit', array('user' => $user, 'roles' => Role::all()->lists('name', 'id')));
 }
コード例 #6
0
 public function edit($id)
 {
     $user = User::with('AssigmentRole')->with('Neighbors')->findOrFail($id);
     $status = Status::all();
     $roles = Role::all();
     return View::make('dashboard.users.edit', ['row' => $user, 'status' => $status, 'roles' => $roles]);
 }
コード例 #7
0
ファイル: CreateRole.php プロジェクト: krues8dr/madison
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if ($this->argument('name')) {
         $name = trim($this->argument('name'));
         $role = Role::where('name', '=', $name)->first();
         if ($role) {
             $this->info("Role '{$name}' already exists.");
             exit;
         }
         $role = new Role();
         $role->name = $name;
         $role->save();
         $this->info('Role saved successfully.');
     } else {
         $roles = Role::all();
         $this->info('Existing Roles:');
         foreach ($roles as $role) {
             $this->info($role->name);
         }
         $continue = $this->ask("Would you still like to add a new role? (yes/no)");
         if ('yes' === trim(strtolower($continue))) {
             $name = $this->ask("What's the new role's name?");
             $role = new Role();
             $role->name = trim($name);
             $role->save();
             $this->info('Role saved successfully.');
         }
     }
 }
コード例 #8
0
 public static function create()
 {
     $roles = Role::all();
     if (count($roles) <= 0) {
         flash()->error(':(', 'Rooleja ei löytynyt');
         Redirect::to('/roles/create');
     }
     View::make('importances-create.html', array('roles' => $roles));
 }
コード例 #9
0
 public function index()
 {
     $active = 'user';
     if (Auth::user()) {
         $user = User::with('role')->where('user_id', Auth::user()->user_id)->first();
         $users = User::nonAdministrator()->get();
         $roles = Role::all();
         return View::make('user', compact('user', 'active', 'users', 'roles'));
     } else {
         return View::make('login');
     }
 }
コード例 #10
0
 /**
  * Remove user.
  *
  * @param $user
  * @return Response
  */
 public function delete($user)
 {
     if ($user->id) {
         $roles = $this->role->all();
         $permissions = $this->permission->all();
         // Title
         $title = Lang::get('admin/user/title.user_delete');
         return View::make('admin/user/delete', compact('user', 'roles', 'permissions', 'title'));
     } else {
         return Redirect::to('admin/user')->with('error', Lang::get('admin/user/messages.does_not_exist'));
     }
 }
コード例 #11
0
 public function getEdit($user)
 {
     if ($user->id) {
         $roles = $this->role->all();
         $profiles = $user->profiles;
         $permissions = $this->permission->all();
         $title = Lang::get('admin/users/title.user_update');
         $mode = 'edit';
         return View::make('admin/users/create_edit', compact('user', 'roles', 'permissions', 'title', 'mode', 'profiles'));
     } else {
         return Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.does_not_exist'));
     }
 }
コード例 #12
0
 /**
  * edit user
  *
  * @return Response
  */
 public function getEdit($user)
 {
     if ($user->id) {
         $roles = $this->role->all();
         $profiles = $user->profiles;
         $permissions = $this->permission->all();
         $title = Lang::get('admin/users/title.user_update');
         $mode = 'edit';
         $last_login = Activity::whereRaw('user_id = ? AND content_type="login"', array($user->id))->select(array('details'))->orderBy('id', 'DESC')->first();
         return Theme::make('admin/users/create_edit', compact('user', 'roles', 'permissions', 'title', 'mode', 'profiles', 'last_login'));
     } else {
         return Api::to(array('error', Lang::get('admin/users/messages.does_not_exist'))) ?: Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.does_not_exist'));
     }
 }
コード例 #13
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param $role
  * @return Response
  */
 public function edit($id)
 {
     $role = Role::find($id);
     $roles = $this->role->all();
     $permissions = Permission::all();
     // Title
     $title = Lang::get('admin/role/title.role_update');
     //Título de sección:
     $title_section = "Modificar rol: ";
     //Subtítulo de sección:
     $subtitle_section = $role->name;
     // Show the page
     return View::make('admin/role/edit', compact('role', 'roles', 'permissions', 'title', 'title_section', 'subtitle_section'));
 }
コード例 #14
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param $id
  * @throws \Acme\Core\Exceptions\EntityNotFoundException
  * @return Response
  */
 public function edit($id)
 {
     $user = $this->userRepository->findById($id);
     if ($user) {
         $roles = $this->role->all();
         $permissions = $this->permission->all();
         // Title
         $title = Lang::get('admin/users/title.user_update');
         // mode
         $mode = 'edit';
         $this->render('admin.users.edit', compact('user', 'roles', 'permissions', 'title', 'mode'));
     } else {
         return Redirect::to('admin.users')->with('error', Lang::get('admin.users.messages.does_not_exist'));
     }
 }
コード例 #15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function editRole($id)
 {
     $data['user'] = Auth::user();
     //Interface
     $data['noAriane'] = true;
     $data['buttonLabel'] = Lang::get('button.update');
     $data['glyphicon'] = 'ok';
     $data['u'] = AuthUser::find($id);
     //Role
     $data['roles'] = Role::all();
     if (empty($data['u'])) {
         return Redirect::back()->with('error', Lang::get('admin.auth_empty'));
     }
     return View::make('theme::' . 'admin.auth.edit_role', $data);
 }
コード例 #16
0
ファイル: Operator.php プロジェクト: Crocodile26/php-1
 public static function format($data, $single = false)
 {
     $roles = Role::all(true);
     if ($single) {
         $data = [$data];
     }
     foreach ($data as $key => &$row) {
         $role = $roles[$row['rid']];
         $row['rname'] = $role['name'];
         $row['dname'] = $role['dname'];
         $row['is_freeze'] = $row['status'] == self::STATUS_FREEZE;
         $row['status_text'] = $row['is_freeze'] ? '已冻结' : '正常';
     }
     return $single ? $data[0] : $data;
 }
コード例 #17
0
 public static function edit($id)
 {
     $user = User::find($id);
     if ($user == null) {
         flash()->error('User was not found!');
         Redirect::to('/users');
     }
     $roles = Role::all();
     // Jos rooleja ei löydy niin luodaan rooli ensin
     if ($roles == null || empty($roles)) {
         flash()->error('No Roles found!');
         Redirect::to('/roles/create');
     }
     View::make('users-edit.html', array('user' => $user, 'roles' => $roles));
 }
コード例 #18
0
ファイル: user.php プロジェクト: SerdarSanri/gotin
 /**
  * Returns an array with user`s roles
  * array[role_name] => bool
  *
  * @param object  $user
  * @return array
  */
 public static function get_roles($user = null)
 {
     $array = array();
     if ($user != null) {
         foreach ($user->roles as $u_role) {
             $array[] = $u_role->id;
         }
     }
     $out = array();
     foreach (Role::all() as $role) {
         $checked = in_array($role->id, $array) ? 1 : 0;
         $out[] = array('name' => $role->name, 'id' => $role->id, 'checked' => $checked);
     }
     return $out;
 }
コード例 #19
0
 public function get_sub_categories(Request $request, Role $role, Role_user $role_user)
 {
     if (!$this->bool_has_role) {
         return $this->roleHelper->call_redirect();
     } else {
         $validation_rules = ['user_id' => 'required|integer|min:1'];
         $this->validate($request, $validation_rules);
         $arr_all_roles = $role->all();
         $arr_roles_possessed = $role_user->get_roles_possessed($request->user_id);
         $arr_roles_possessed = $role_user->process_roles_possessed_output($arr_roles_possessed);
         $arr_roles_available = $role_user->get_roles_available($request->user_id);
         $data = array('arr_roles_possessed' => $arr_roles_possessed, 'arr_roles_available' => $arr_roles_available);
         return response()->json($data);
     }
 }
コード例 #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $arrayPermissionRoleMapping = Input::get('permissionRoles');
     $permissions = Permission::all();
     $roles = Role::all();
     foreach ($permissions as $permissionkey => $permission) {
         foreach ($roles as $roleKey => $role) {
             //If checkbox is clicked attach the permission
             if (!empty($arrayPermissionRoleMapping[$permissionkey][$roleKey])) {
                 $role->attachPermission($permission);
             } elseif (empty($arrayPermissionRoleMapping[$permissionkey][$roleKey])) {
                 $role->detachPermission($permission);
             }
         }
     }
     return Redirect::route('permission.index')->with('message', trans('messages.success-updating-permission'));
 }
コード例 #21
0
ファイル: UserController.php プロジェクト: strikles/php
 public function getCreate()
 {
     // All roles
     $roles = Role::all();
     // Get all the available permissions
     $permissions = Permission::all();
     // Selected groups
     $selectedRoles = Input::old('roles', array());
     // Selected permissions
     $selectedPermissions = Input::old('permissions', array());
     // Title
     $title = "Create a new promotter";
     // Mode
     $mode = 'create';
     // Show the page
     return View::make('site/user/create', compact('title', 'mode'));
 }
コード例 #22
0
 public function run()
 {
     /**
      * Dashboard
      *
      */
     $page = Page::create(['name' => 'dashboard', 'friendly_name' => 'Dashboard', 'icon' => 'fa fa-tachometer', 'slug' => 'dashboard']);
     $this->attach($page, Role::all());
     /**
      * Servers
      *
      */
     $page = Page::create(['name' => 'servers', 'friendly_name' => 'Servers', 'icon' => 'fa fa-tasks', 'slug' => 'servers']);
     $this->attach($page, Role::all());
     /**
      * Active Plugins
      *
      */
     $page = Page::create(['name' => 'active_plugins', 'friendly_name' => 'Active Plugins', 'icon' => 'fa fa-sitemap', 'slug' => 'active-plugins']);
     $this->attach($page, Role::where('name', '!=', 'guest')->get());
     /**
      * Multi Console
      *
      */
     $page = Page::create(['name' => 'multi_console', 'friendly_name' => 'Multi-Console', 'icon' => 'fa fa-terminal', 'slug' => 'multi-console']);
     $this->attach($page, Role::where('name', 'super_admin')->get());
     /**
      * Admin Activity
      *
      */
     $page = Page::create(['name' => 'admin_activity', 'friendly_name' => 'Admin Activity', 'icon' => 'fa fa-comments', 'slug' => 'admin-activity']);
     $this->attach($page, Role::where('name', 'super_admin')->orWhere('name', 'admin')->get());
     /**
      * Game Types
      *
      */
     $page = Page::create(['name' => 'game_types', 'friendly_name' => 'Game Types', 'icon' => 'fa fa-gamepad', 'slug' => 'game-types']);
     $this->attach($page, Role::all());
     /**
      * Settings
      *
      */
     $page = Page::create(['name' => 'settings', 'friendly_name' => 'Settings', 'icon' => 'fa fa-cogs', 'slug' => 'settings']);
     $this->attach($page, Role::where('name', 'super_admin')->get());
 }
コード例 #23
0
 public function getArea()
 {
     $roles = Role::all();
     $services = Service::orderBy('action')->get();
     $services = $services->toArray();
     $groupedServices = [];
     foreach ($services as $service) {
         $actions = preg_split('/@/', $service['action']);
         if (count($actions) >= 2) {
             $groupedServices[$actions[0]][] = ['id' => $service['id'], 'libelle' => $actions[1]];
         }
     }
     $result = [];
     foreach ($roles as $role) {
         $result[] = ['libelle' => $role->libelle, 'id' => $role->id, 'choices' => $groupedServices];
     }
     return $result;
 }
コード例 #24
0
 /**
  *	Saving the mapping for user to role assignment
  *
  *	@return Response
  */
 public function saveUserRoleAssignment()
 {
     $arrayUserRoleMapping = Input::get('userRoles');
     $users = User::all();
     $roles = Role::all();
     foreach ($users as $userkey => $user) {
         foreach ($roles as $roleKey => $role) {
             //If checkbox is clicked attach the role
             if (!empty($arrayUserRoleMapping[$userkey][$roleKey])) {
                 $user->attachRole($role);
             } elseif (empty($arrayUserRoleMapping[$userkey][$roleKey])) {
                 $user->detachRole($role);
             }
         }
     }
     $url = Session::get('SOURCE_URL');
     return Redirect::to($url)->with('message', trans('messages.success-updating-role'));
 }
コード例 #25
0
ファイル: ProfileHelper.php プロジェクト: ebuzz/SAPE_CAR
 /**
  * Obtiene la información de un perfil 
  *
  * @param Profile $profile perfil del cual obtener los datos
  * @return array arreglo que contiene la información del perfil
  */
 public static function getProfileData($profile)
 {
     $profile->load('city.state.cities', 'city.sports', 'profileValues.field.values.parent', 'profileValues.value');
     $roles = Role::all()->lists('description', 'idRole');
     $states = State::all()->lists('description', 'idState');
     $cities = $profile->city->state->cities->lists('description', 'idCity');
     $sports = $profile->city->sports->filter(function ($sport) {
         return $sport->description != "Otro";
     });
     $sports->add(Sport::where("description", "=", "Otro")->first());
     $sports = $sports->lists('description', 'idSport');
     $fields = array();
     foreach ($profile->profileValues as $profileValue) {
         $parent = $profileValue->value->parent->first();
         self::solveParentValue($fields, $profileValue->field, $parent);
         self::addField($fields, $profileValue->field, $profileValue->value, $parent);
     }
     $data = array('roles' => $roles, 'states' => $states, 'cities' => $cities, 'sports' => $sports, 'fields' => $fields, 'profile' => $profile);
     return $data;
 }
コード例 #26
0
 public function adminPreviewStaffProfile($staffID)
 {
     Larasset::start('footer')->js('bootstrap_editable', 'bootstrap-datepicker');
     Larasset::start('header')->css('bootstrap_editable', 'bootstrap-datepicker');
     //Lets the details of a staff
     $staff = User::find($staffID);
     //Lets get the staff's Activity
     $activity = Usersactivity::where('user_id', '=', $staffID)->take(10)->orderBy('id', 'desc')->get();
     //tt($activity->toArray());
     //Lets get how much the staff's ever sold
     $salesworth = User::find($staffID)->salelogs()->sum('total_unitprice');
     $data['salesworth'] = 0.0;
     $data['role'] = Role::all()->lists('id', 'name');
     //tt($data['role']);
     if (!empty($salesworth) && $salesworth !== null) {
         $data['salesworth'] = $salesworth;
     }
     $data['staff'] = $staff->toArray();
     $data['activities'] = $activity;
     return View::make('admin.previewstaffprofile', $data);
 }
コード例 #27
0
ファイル: UserRole.php プロジェクト: DCgov/dc-madison
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $roles = Role::all();
     $email = $this->ask("User's email address:");
     $user = User::where('email', $email)->first();
     if (!isset($user)) {
         $this->error("No user with email {$email} found!");
         return;
     }
     $roleOptions = "";
     foreach ($roles as $role) {
         $roleOptions .= "{$role->id} - {$role->name}\n";
     }
     $this->info("\nRole Options: \n" . $roleOptions);
     $roleId = $this->ask("Choose role (enter number): ");
     $role = Role::find($roleId);
     if (!isset($role)) {
         $this->error("Role id {$roleId} not found!");
         return;
     }
     $user->attachRole($role);
     $this->info("Role {$role->name} added to user with email {$user->email}");
 }
コード例 #28
0
ファイル: UserSeeder.php プロジェクト: FebriPratama/pop
 public function run()
 {
     $roles = Role::all();
     // Create users
     $users = ['admin' => ['email' => '*****@*****.**', 'roles' => $roles->toArray()], 'jason' => ['email' => '*****@*****.**', 'roles' => []], 'test1' => ['email' => '*****@*****.**', 'roles' => []], 'test2' => ['email' => '*****@*****.**', 'roles' => []]];
     foreach ($users as $username => $data) {
         $user = new User();
         $user->username = $username;
         $user->email = $data['email'];
         $user->password = $user->password_confirmation = 'password';
         $user->created_at = $user->updated_at = new DateTime();
         $user->confirmed = 1;
         $user->status = 1;
         $user->save();
         if ($data['roles']) {
             $r_ids = [];
             foreach ($data['roles'] as $role) {
                 $r_ids[] = $role['id'];
             }
             $user->roles()->sync($r_ids);
         }
     }
 }
コード例 #29
0
 public function update($id)
 {
     $rules = array('username' => 'required', 'password' => 'min:6', 'email' => 'required|email', 'name' => 'required', 'age' => 'required|numeric', 'roles' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('admin/user/' . $id . '/edit')->withErrors($validator)->withInput();
     } else {
         // store
         $user = User::find($id);
         $user->name = Input::get('name');
         $user->username = Input::get('username');
         if (Input::get('password') !== "") {
             $user->password = Hash::make(Input::get('password'));
         }
         $user->email = Input::get('email');
         $user->age = Input::get('age');
         $user->save();
         foreach (Role::all() as $role) {
             $user->roles()->detach($role->id);
         }
         foreach (Input::get('roles') as $roleId) {
             $found = false;
             foreach ($user->roles()->getResults() as $roleMenu) {
                 if ($roleMenu->id === $roleId) {
                     $found = true;
                 }
             }
             if (!$found) {
                 $user->roles()->attach($roleId);
             }
         }
         // redirect
         Session::flash('message', 'Successfully updated user!');
         return Redirect::to('admin/user');
     }
 }
コード例 #30
0
 public function editRole()
 {
     $id = Input::get('editRoleID');
     $role = Role::find($id);
     $rol = Role::all();
     $isAdded = FALSE;
     $validInput = TRUE;
     $regex = "/^[a-zA-Z\\'\\-]+( [a-zA-Z\\'\\-]+)*\$/";
     $regexDesc = "/^[a-zA-Z0-9\\'\\-\\.\\,]+( [a-zA-Z0-9\\,\\'\\-\\.]+)*\$/";
     if (!trim(Input::get('editRoleName')) == '' && !trim(Input::get('editRoleDescription')) == '') {
         $validInput = TRUE;
         if (preg_match($regex, Input::get('editRoleName')) && preg_match($regexDesc, Input::get('editRoleDescription'))) {
             $validInput = TRUE;
         } else {
             $validInput = FALSE;
         }
     } else {
         $validInput = FALSE;
     }
     foreach ($rol as $rol) {
         if (!strcasecmp($rol->strEmpRoleID, trim(Input::get('editRoleID'))) == 0 && strcasecmp($rol->strEmpRoleName, trim(Input::get('editRoleName'))) == 0) {
             $isAdded = TRUE;
         }
     }
     if ($validInput) {
         if (!$isAdded) {
             $role->strEmpRoleName = trim(Input::get('editRoleName'));
             $role->strEmpRoleDesc = trim(Input::get('editRoleDescription'));
             $role->save();
             return Redirect::to('/maintenance/employeeRole?successEdit=true');
         } else {
             return Redirect::to('/maintenance/employeeRole?success=duplicate');
         }
     } else {
         return Redirect::to('/maintenance/employeeRole?input=invalid');
     }
 }