/** * * Force the role to have the given permission. * * @param $permissionName */ public function forcePermission($permissionName) { // If the role has not been given a the said permission if (null == $this->perms()->where('name', $permissionName)->first()) { // Load the given permission and attach it to the role. $permToForce = Permission::where('name', $permissionName)->first(); $this->perms()->attach($permToForce->id); } }
/** * compose permissions variable. */ private function composeAllPermissions() { View::composer(['manage.role.show'], function ($view) { $groups = Permission::distinct()->lists('group'); foreach ($groups as $group) { $permission_groups[$group] = Permission::where('group', $group)->get(); } $view->with(['permission_groups' => $permission_groups]); }); }
public static function addPermission($name, $label = null, $description = null) { $permission = Permission::where('name', $name)->first(); if (!$permission) { $permission = new Permission(['name' => $name]); } $permission->label = $label; $permission->description = $description; $permission->save(); return $permission; }
public function addMenuAction(Request $request) { if ($request->action == 'update') { try { $fun = Permission::where('id', $request->col0)->update(['name' => $request->col1, 'display_name' => $request->col2, 'description' => $request->col3, 'link' => $request->col4, 'parent' => $request->col5, 'icon' => $request->col6]); Log::info($fun); if ($fun) { return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json'); } else { return response('There is no data changes!!', 400)->header('Content-Type', 'application/json'); } } catch (PDOException $exception) { Log::info($exception->getMessage()); return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json'); } } if ($request->action == 'insert') { try { $fun = new Permission(); $fun->name = $request->col1; $fun->display_name = $request->col2; $fun->description = $request->col3; $fun->link = $request->col4; $fun->parent = $request->col5; $fun->icon = $request->col6; if ($fun->save()) { $request->merge(array('col0' => $fun->id)); return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json'); } else { return response('There is no data changes!!', 400)->header('Content-Type', 'application/json'); } } catch (PDOException $exception) { Log::info($exception->getMessage()); return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json'); } } if ($request->action == 'delete') { try { $fun = Permission::where('ID', $request->col0); if ($fun->delete()) { return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json'); } else { return response('There is no data changes!!', 400)->header('Content-Type', 'application/json'); } } catch (PDOException $exception) { Log::info($exception->getMessage()); return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json'); } } //return response(array('sukses bisa bro!!'), 200) return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store($user, Request $request) { $uperms = Permission::where('user_id', '=', $user)->delete(); $perms = $request->except('_token'); foreach ($perms as $kk => $perm) { if (substr($kk, 0, 3) != "new") { $soc = substr($kk, 0, strpos($kk, '_')); $key = substr($kk, 1 + strpos($kk, '_')); $data[$soc][$key] = $perm; } } if (isset($data)) { foreach ($data as $ss => $dat) { $newp = new Permission(); $newp->society_id = $ss; $newp->user_id = $user; foreach ($dat as $kkk => $vvv) { $newp->{$kkk} = $vvv; } $newp->save(); } } if ($request->new_society != 0) { $news = new Permission(); $news->society_id = $request->new_society; $news->user_id = $user; if (isset($request->new_admin)) { $news->admin = $request->new_admin; } if (isset($request->new_email)) { $news->email = $request->new_email; } if (isset($request->new_sms)) { $news->sms = $request->new_sms; } if (isset($request->new_edit)) { $news->edit = $request->new_edit; } if (isset($request->new_preaching)) { $news->preaching = $request->new_preaching; } if (isset($request->new_view)) { $news->view = $request->new_view; } if (isset($request->new_worship)) { $news->worship = $request->new_worship; } $news->save(); } return redirect()->route('users.permissions.index', $user); }
public function deleteRolesPermissions() { $role = Role::where('name', 'master')->first(); if ($role) { $role->delete(); } $permission = Permission::where('name', 'user-create')->first(); $permission->delete(); $permission = Permission::where('name', 'user-edit')->first(); $permission->delete(); $permission = Permission::where('name', 'user-delete')->first(); $permission->delete(); // $role->forceDelete(); return redirect()->route('access.test'); }
public function welcome() { if (!Schema::hasTable('settings')) { $data['firsttime'] = "yes"; return view('firsttime', $data)->with('okmessage', 'Please create a user before you can use Connexion'); } $user = Auth::user(); if ($user and $user->individual_id) { $today = date('d-m-Y'); $data['tasks'] = Task::where('donedate', '=', '')->where('project_id', '<>', 0)->where('individual_id', $user->individual_id)->orderBy('duedate')->get(); $data['personal'] = Task::where('donedate', '=', '')->where('project_id', '=', 0)->where('individual_id', $user->individual_id)->orderBy('duedate')->get(); $data['individuals'] = Individual::orderBy('surname')->get(); $data['projects'] = Project::with('undonetask')->where('individual_id', $user->individual_id)->orderBy('project')->get(); $data['projectselect'] = Project::orderBy('project')->lists('project', 'id'); $data['page_title'] = Helpers::getSetting('circuit_name') . " Circuit"; $data['page_description'] = "Administrator home page"; $socs = Permission::where('user_id', '=', $user->id)->select('society_id')->get(); foreach ($socs as $soc) { $thissoc = Society::where('id', '=', $soc->society_id)->get(); $dum['googleCalendarId'] = $thissoc[0]->society_calendar; $dum['color'] = $thissoc[0]->calendar_colour; $data['cals'][] = $dum; } $dum['googleCalendarId'] = Helpers::getSetting('circuit_calendar'); $dum['color'] = 'black'; $data['cals'][] = $dum; if (Helpers::is_online() and $user->googlecalendar != "") { $privatecal = new GoogleCalendar(); $pcals = $privatecal->getTen($user->googlecalendar); foreach ($pcals as $pcal) { $pcal['color'] = $user->calendar_colour; $data['pcals'][] = $pcal; } } else { $data['pcals'] = array(); } if (!count($socs)) { $soc = strtolower($user->individual->household->society->society); return redirect()->action('SocietiesController@show', $soc); } else { return view('home', $data); } } elseif ($user) { return view('shared.registered'); } else { return view('landingwebpage'); } }
/** * Run the database seeds. * * @return void */ public function run() { Role::create(['name' => 'Admin', 'display_name' => '超级管理员']); Role::create(['name' => 'Editor', 'display_name' => '编辑']); Role::create(['name' => 'Demo', 'display_name' => '演示']); Role::get()->each(function ($role) { if ($role->name === 'Admin') { $permissions = Permission::get()->pluck('id')->all(); $role->perms()->sync($permissions); } if ($role->name === 'Editor') { $permissions = Permission::where('name', 'manage_contents')->first(); $role->perms()->sync([$permissions->id]); } }); }
public function search() { $input = Input::all(); $data['q'] = $input['q']; $perms = array_flatten(Permission::where('user_id', '=', Auth::user()->id)->select('society_id')->get()->toArray()); $individuals = Individual::where('surname', 'like', '%' . $input['q'] . '%')->orWhere('firstname', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->orderBy('surname')->get(); foreach ($individuals as $indiv) { if ($indiv->household) { if (in_array($indiv->household->society_id, $perms)) { $ids[] = $indiv->id; } } } $data['individuals'] = Individual::wherein('id', $ids)->get(); $data['groups'] = Group::where('groupname', 'like', '%' . $input['q'] . '%')->whereIn('society_id', $perms)->whereNull('deleted_at')->get(); $data['projects'] = Project::where('project', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->get(); return view('home', $data); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('roles')->delete(); /** * Role Attributes * * name: Unique name for the permission, used for looking up permission information in the * application layer. For example: "create-post", "edit-user", "post-payment", "mailing-list-subscribe". * * display_name: Human readable name for the permission. Not necessarily unique, and is optional. * For example "Create Posts", "Edit Users", "Post Payments", "Subscribe to mailing list". * * description: A more detailed explanation of the Role. This is also optional. * * permissions: A list of permission names to assign to the user. Optional. */ $roles = array(array('name' => 'owner', 'display_name' => 'Owner', 'description' => 'Owner of the management system. Has access to all aspects of the system.', 'permissions' => PermissionNames::AllGlobalPermissions())); foreach ($roles as $r) { $entry = new Role(); $entry->name = $r['name']; if (array_key_exists('permissions', $r)) { $permissions = $r['permissions']; unset($r['permissions']); } if (array_key_exists('display_name', $r)) { $entry->display_name = $r['display_name']; } if (array_key_exists('description', $r)) { $entry->description = $r['description']; } $entry->save(); if (isset($permissions)) { foreach ($permissions as $p) { $entry->attachPermission(Permission::where('name', $p)->get()->first()); } unset($permissions); } } $rolePermissions = Permission::whereIn('name', PermissionNames::AllGlobalPermissions())->get(); RoleCreate::createPermissionRoles($rolePermissions); }
public function composeMessage($society, $type) { $today = date('d-m-Y'); $data['society'] = $society; $soc = Society::find($society); if ($type == "sms") { $username = $soc->sms_username; $pword = $soc->sms_password; if ($soc->sms_provider == "bulksms") { if (Helpers::is_online()) { $data['credits'] = SMSfunctions::BS_get_credits($username, $pword); } else { $data['credits'] = "Bulk SMS is offline"; } } elseif ($soc->sms_provider == "smsfactory") { if (Helpers::is_online()) { $data['credits'] = intval(SMSfunctions::SF_checkCredits($username, $pword)); } else { $data['credits'] = "Bulk SMS is offline"; } } else { $data['credits'] = "SMS credentials are not set up yet"; } $data['perms'] = Permission::where('user_id', '=', Auth::user()->id)->where('sms', '=', 1)->select('society_id')->get()->toArray(); } else { $data['perms'] = Permission::where('user_id', '=', Auth::user()->id)->where('email', '=', 1)->select('society_id')->get()->toArray(); } foreach ($data['perms'] as $perm) { $psoc[] = $perm['society_id']; } $data['indivs'] = Individual::orderBy('surname')->orderBy('firstname')->get(); $data['groups'] = Group::with('individual')->wherein('society_id', $psoc)->orderBy('groupname')->get(); $view = "messages." . $type; if ($type == "sms" and (Helpers::perm('admin', $society) or Helpers::perm('sms', $society))) { return view('messages.sms', $data); } elseif ($type == "email" and (Helpers::perm('admin', $society) or Helpers::perm('email', $society))) { return view('messages.email', $data); } else { return view('shared.unauthorised'); } }
public function destroyRbacRules() { $permissions = $this->getPermissionsArray(); $members = GroupMember::where('group_id', '=', $this->id)->get(); $roles = Role::where('name', '=', "group_{$this->id}_owner")->orWhere('name', '=', "group_{$this->id}_editor")->orWhere('name', '=', "group_{$this->id}_staff")->get(); foreach ($roles as $role) { foreach ($members as $member) { $user = User::where('id', '=', $member->user_id)->first(); $user->detachRole($role); } if ($role instanceof Role) { $role->delete(); } } foreach ($permissions as $permData) { $perm = Permission::where('name', '=', $permData['name'])->first(); if ($perm instanceof Permission) { $perm->delete(); } } }
/** * Run the database seeds. * * @return void */ public function run() { // TODO: Remove this before release... // Look for and delete route named 'do-not-pre-load' if it exist. // That route is used to test a failure with the Authorization middleware and should not be loaded automatically. $routeToDelete = Route::where('name', 'test-acl.do-not-pre-load')->get()->first(); if ($routeToDelete) { Route::destroy($routeToDelete->id); } $testUserOne = User::create(['username' => 'user1', 'first_name' => 'User', 'last_name' => 'One', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserTwo = User::create(['username' => 'user2', 'first_name' => 'User', 'last_name' => 'Two', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserThree = User::create(['username' => 'user3', 'first_name' => 'User', 'last_name' => 'Three', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFour = User::create(['username' => 'user4', 'first_name' => 'User', 'last_name' => 'Four', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFive = User::create(['username' => 'user5', 'first_name' => 'User', 'last_name' => 'Five', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserSix = User::create(['username' => 'user6', 'first_name' => 'User', 'last_name' => 'Six', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserSeven = User::create(['username' => 'user7', 'first_name' => 'User', 'last_name' => 'Seven', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserEight = User::create(['username' => 'user8', 'first_name' => 'User', 'last_name' => 'Eight', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserNine = User::create(['username' => 'user9', 'first_name' => 'User', 'last_name' => 'Nine', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserTen = User::create(['username' => 'user10', 'first_name' => 'User', 'last_name' => 'Ten', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserEleven = User::create(['username' => 'user11', 'first_name' => 'User', 'last_name' => 'Eleven', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserTwelve = User::create(['username' => 'user12', 'first_name' => 'User', 'last_name' => 'Twelve', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserThirteen = User::create(['username' => 'user13', 'first_name' => 'User', 'last_name' => 'Thirteen', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFourteen = User::create(['username' => 'user14', 'first_name' => 'User', 'last_name' => 'Fourteen', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); $testUserFifteen = User::create(['username' => 'user15', 'first_name' => 'User', 'last_name' => 'Fifteen', 'email' => '*****@*****.**', "password" => "Password1", "auth_type" => "internal", "enabled" => true]); ///////// // Create a few test permissions for the flash-test pages. $permTestLevelSuccess = Permission::create(['name' => 'test-level-success', 'display_name' => 'Test level success', 'description' => 'Testing level success', 'enabled' => true]); $permTestLevelInfo = Permission::create(['name' => 'test-level-info', 'display_name' => 'Test level info', 'description' => 'Testing level info', 'enabled' => true]); $permTestLevelWarning = Permission::create(['name' => 'test-level-warning', 'display_name' => 'Test level warning', 'description' => 'Testing level warning', 'enabled' => true]); $permTestLevelError = Permission::create(['name' => 'test-level-error', 'display_name' => 'Test level error', 'description' => 'Testing level error', 'enabled' => true]); //////////////////////////////////// // Create some roles for the flash test pages. //////////////////////////////////// // Success $roleFlashSuccessViewer = Role::create(["name" => "flash-success-viewer", "display_name" => "Flash success viewer", "description" => "Can see the success flash test page.", "enabled" => true]); // Assign permission TestLevelSuccess $roleFlashSuccessViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashSuccessViewer->users()->attach($testUserTwo->id); // Info $roleFlashInfoViewer = Role::create(["name" => "flash-info-viewer", "display_name" => "Flash info viewer", "description" => "Can see the info flash test page.", "enabled" => true]); // Assign permission Info and Success to the InfoViewer role. $roleFlashInfoViewer->perms()->attach($permTestLevelInfo->id); $roleFlashInfoViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashInfoViewer->users()->attach($testUserThree->id); // Warning $roleFlashWarningViewer = Role::create(["name" => "flash-warning-viewer", "display_name" => "Flash warning viewer", "description" => "Can see the warning flash test page.", "enabled" => true]); // Assign permission Warning, Info and Success to the WarningViewer role. $roleFlashWarningViewer->perms()->attach($permTestLevelWarning->id); $roleFlashWarningViewer->perms()->attach($permTestLevelInfo->id); $roleFlashWarningViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashWarningViewer->users()->attach($testUserFour->id); // Error $roleFlashErrorViewer = Role::create(["name" => "flash-error-viewer", "display_name" => "Flash error viewer", "description" => "Can see the error flash test page.", "enabled" => true]); // Assign permission Error, Warning, Info and Success to the ErrorViewer role. $roleFlashErrorViewer->perms()->attach($permTestLevelError->id); $roleFlashErrorViewer->perms()->attach($permTestLevelWarning->id); $roleFlashErrorViewer->perms()->attach($permTestLevelInfo->id); $roleFlashErrorViewer->perms()->attach($permTestLevelSuccess->id); // Assign user membership to role $roleFlashErrorViewer->users()->attach($testUserFive->id); ///////// // Find basic-authenticated permission. $permBasicAuthenticated = Permission::where('name', 'basic-authenticated')->first(); // Find guest-only permission. $permGuestOnly = Permission::where('name', 'guest-only')->first(); // Find open-to-all permission. $permOpenToAll = Permission::where('name', 'open-to-all')->first(); // Find admin-settings permission. $permAdminSettings = Permission::where('name', 'admin-settings')->first(); //////////////////////////////////// // Associate some permission to acl test routes $routeTestACLHome = Route::where('name', 'test-acl.home')->get()->first(); $routeTestACLHome->permission()->associate($permOpenToAll); $routeTestACLHome->save(); // $routeTestACLAdmins = Route::where('name', 'test-acl.admins')->get()->first(); $routeTestACLAdmins->permission()->associate($permAdminSettings); $routeTestACLAdmins->save(); // $routeTestACLBasicAuthenticated = Route::where('name', 'test-acl.basic-authenticated')->get()->first(); $routeTestACLBasicAuthenticated->permission()->associate($permBasicAuthenticated); $routeTestACLBasicAuthenticated->save(); // $routeTestACLGuestOnly = Route::where('name', 'test-acl.guest-only')->get()->first(); $routeTestACLGuestOnly->permission()->associate($permGuestOnly); $routeTestACLGuestOnly->save(); // $routeTestACLOpenToAll = Route::where('name', 'test-acl.open-to-all')->get()->first(); $routeTestACLOpenToAll->permission()->associate($permOpenToAll); $routeTestACLOpenToAll->save(); //////////////////////////////////// // Associate some permission to flash test routes $routeFlashHome = Route::where('name', 'test-flash.home')->get()->first(); $routeFlashHome->permission()->associate($permOpenToAll); $routeFlashHome->save(); // $routeFlashSuccess = Route::where('name', 'test-flash.success')->get()->first(); $routeFlashSuccess->permission()->associate($permTestLevelSuccess); $routeFlashSuccess->save(); // $routeFlashInfo = Route::where('name', 'test-flash.info')->get()->first(); $routeFlashInfo->permission()->associate($permTestLevelInfo); $routeFlashInfo->save(); // $routeFlashWarning = Route::where('name', 'test-flash.warning')->get()->first(); $routeFlashWarning->permission()->associate($permTestLevelWarning); $routeFlashWarning->save(); // $routeFlashError = Route::where('name', 'test-flash.error')->get()->first(); $routeFlashError->permission()->associate($permTestLevelError); $routeFlashError->save(); //////////////////////////////////// // Associate some permission to menu test routes $routeTestMenusHome = Route::where('name', 'test-menus.home')->get()->first(); $routeTestMenusHome->permission()->associate($permOpenToAll); $routeTestMenusHome->save(); // $routeTestMenusOne = Route::where('name', 'test-menus.one')->get()->first(); $routeTestMenusOne->permission()->associate($permOpenToAll); $routeTestMenusOne->save(); // $routeTestMenusTwo = Route::where('name', 'test-menus.two')->get()->first(); $routeTestMenusTwo->permission()->associate($permBasicAuthenticated); $routeTestMenusTwo->save(); // $routeTestMenusTwoA = Route::where('name', 'test-menus.two-a')->get()->first(); $routeTestMenusTwoA->permission()->associate($permTestLevelSuccess); $routeTestMenusTwoA->save(); // $routeTestMenusTwoB = Route::where('name', 'test-menus.two-b')->get()->first(); $routeTestMenusTwoB->permission()->associate($permTestLevelInfo); $routeTestMenusTwoB->save(); // $routeTestMenusThree = Route::where('name', 'test-menus.three')->get()->first(); $routeTestMenusThree->permission()->associate($permTestLevelWarning); $routeTestMenusThree->save(); ///////// // Find home menu. $menuHome = Menu::where('name', 'home')->first(); ///////// // Create Test ACL menu folder $menuTestACL = Menu::create(['name' => 'test-acl.home', 'label' => 'Test ACL', 'position' => 20, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => '/test-acl/home', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => null, 'permission_id' => $permOpenToAll->id]); // Create DoNotPreLoad menu $menuDoNotPreLoad = Menu::create(['name' => 'test-acl.do-not-pre-load', 'label' => 'Do not pre-load', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => '/test-acl/do-not-pre-load', 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => null, 'permission_id' => null]); // Create NoPerm menu $menuNoPerm = Menu::create(['name' => 'test-acl.no-perm', 'label' => 'No perm', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => '/test-acl/no-perm', 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => null, 'permission_id' => null]); // Create GuestOnly menu $menuGuestOnly = Menu::create(['name' => 'test-acl.guest-only', 'label' => 'Guest Only', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLGuestOnly->id, 'permission_id' => null]); // Create OpenToAll menu $menuOpenToAll = Menu::create(['name' => 'test-acl.open-to-all', 'label' => 'Open to all', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLOpenToAll->id, 'permission_id' => null]); // Create BasicAuthenticated menu $menuBasicAuthenticated = Menu::create(['name' => 'test-acl.basic-authenticated', 'label' => 'Basic authenticated', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLBasicAuthenticated->id, 'permission_id' => null]); // Create Admins menu $menuAdmins = Menu::create(['name' => 'test-acl.admins', 'label' => 'Admins', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => $routeTestACLAdmins->id, 'permission_id' => null]); // Create PowerUsers menu $menuPowerUsers = Menu::create(['name' => 'test-acl.power-users', 'label' => 'Power users', 'position' => 0, 'icon' => 'fa fa-file', 'separator' => false, 'url' => '/test-acl/power-users', 'enabled' => true, 'parent_id' => $menuTestACL->id, 'route_id' => null, 'permission_id' => null]); ///////// // Create Test flash menu folder $menuTestFlashHome = Menu::create(['name' => 'test-flash.home', 'label' => 'Test Flash', 'position' => 20, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => '/test-flash/home', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => null, 'permission_id' => $permBasicAuthenticated->id]); // Create Flash success menu $menuFlashSuccess = Menu::create(['name' => 'test-flash.success', 'label' => 'Flash success', 'position' => 0, 'icon' => 'fa fa-check fa-colour-green', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashSuccess->id, 'permission_id' => null]); // Create Flash info menu $menuFlashInfo = Menu::create(['name' => 'test-flash.info', 'label' => 'Flash info', 'position' => 10, 'icon' => 'fa fa-info fa-colour-blue', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashInfo->id, 'permission_id' => null]); // Create Flash warning menu $menuFlashWarning = Menu::create(['name' => 'test-flash.warning', 'label' => 'Flash warning', 'position' => 20, 'icon' => 'fa fa-warning fa-colour-orange', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashWarning->id, 'permission_id' => null]); // Create Flash error menu $menuFlashError = Menu::create(['name' => 'test-flash.error', 'label' => 'Flash error', 'position' => 30, 'icon' => 'fa fa-ban fa-colour-red', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestFlashHome->id, 'route_id' => $routeFlashError->id, 'permission_id' => null]); ///////// // Create Test menu folder $menuTestMenusHome = Menu::create(['name' => 'test-menus.home', 'label' => 'Test Menus', 'position' => 30, 'icon' => 'fa fa-bolt', 'separator' => false, 'url' => '/test-menus/home', 'enabled' => true, 'parent_id' => $menuHome->id, 'route_id' => null, 'permission_id' => $permOpenToAll->id]); // Create Menu 1 menu $menuTestMenusOne = Menu::create(['name' => 'test-menus.one', 'label' => 'Menu One', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusHome->id, 'route_id' => $routeTestMenusOne->id, 'permission_id' => null]); // Create Menu 2 menu $menuTestMenusTwo = Menu::create(['name' => 'test-menus.two', 'label' => 'Menu Two', 'position' => 10, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusHome->id, 'route_id' => $routeTestMenusTwo->id, 'permission_id' => null]); // Create Menu 2a menu $menuTestMenusTwo2a = Menu::create(['name' => 'test-menus.two-a', 'label' => 'Menu Two A', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => $routeTestMenusTwoA->id, 'permission_id' => null]); // Create Menu 2b menu $menuTestMenusTwo2b = Menu::create(['name' => 'test-menus.two-b', 'label' => 'Menu Two B', 'position' => 10, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => $routeTestMenusTwoB->id, 'permission_id' => null]); // Create Menu 2a alias by URL $menuTestMenusTwo2a = Menu::create(['name' => 'test-menus.two-a-alias-url', 'label' => 'Menu Two A alias by URL', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => '/test-menus/two-a', 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => null, 'permission_id' => $permBasicAuthenticated->id]); // Create Menu 2a alias by ROUTE $menuTestMenusTwo2a = Menu::create(['name' => 'test-menus.two-a-alias-route', 'label' => 'Menu Two A alias by route', 'position' => 0, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusTwo->id, 'route_id' => Route::where('name', 'like', "test-menus.two_a")->get()->first()->id, 'permission_id' => null]); // Create Menu 3 menu $menuTestMenusTwo3 = Menu::create(['name' => 'test-menus.three', 'label' => 'Menu Three', 'position' => 20, 'icon' => 'fa fa-bars', 'separator' => false, 'url' => null, 'enabled' => true, 'parent_id' => $menuTestMenusHome->id, 'route_id' => $routeTestMenusThree->id, 'permission_id' => null]); }
public function delete(Request $request) { $del = ParentFrontpage::find($request->input('id')); $permission = Permission::where('name', $del->name)->get(); if (count($permission) > 0) { foreach ($permission as $key => $p) { $p->delete(); } } $del->delete(); return $del == true ? 'success' : 'fail'; }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit($society, $id) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $data['society'] = $society; $data['categories'] = array('forms', 'preaching'); $data['download'] = Download::find($id); $data['chosensoc'] = explode(',', $data['download']->societies); $allsoc = Permission::where('user_id', '=', Auth::user()->id)->get(); foreach ($allsoc as $asoc) { $data['societies'][$asoc->society_id] = $asoc->society->society; } return view('downloads.edit', $data); } else { return View::make("shared.unauthorised"); } }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit($society, $id) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $data['society'] = $society; $data['blog'] = Blog::find($id); $data['chosensoc'] = explode(',', $data['blog']->societies); if (count($data['blog']->subject)) { foreach ($data['blog']->subject as $subj) { $data['blogsubjects'][] = $subj->id; } } else { $data['blogsubjects'][0] = 0; } $data['author'] = Individual::where('slug', '<>', '')->orderBy('surname')->orderBy('firstname')->get(); $data['subjects'] = Subject::orderBy('subject')->get(); $allsoc = Permission::where('user_id', '=', Auth::user()->id)->get(); foreach ($allsoc as $asoc) { $data['societies'][$asoc->society_id] = $asoc->society->society; } return view('blogs.edit', $data); } else { return View::make("shared.unauthorised"); } }
/** * Locate module permission and delete it. * * @param $string */ protected static function destroyPermission($name) { $permUseActiveDirectoryInspector = Permission::where('name', $name)->first(); if ($permUseActiveDirectoryInspector) { Permission::destroy($permUseActiveDirectoryInspector->id); } }
public function run() { DB::table('Roles')->delete(); $role = new Role(); $role->name = 'admin'; $role->display_name = 'Administrateur du système'; $role->description = 'Cet usager a tous les droits sur le système, c\'est le super admin'; $role->save(); $permission = Permission::where('name', '=', 'ajout-prof')->first(); $role->attachPermission($permission); $permission = Permission::where('name', '=', 'ajout-etudiant')->first(); $role->attachPermission($permission); $permission = Permission::where('name', '=', 'ajout-classe')->first(); $role->attachPermission($permission); $permission = Permission::where('name', '=', 'passer-test')->first(); $role->attachPermission($permission); $permission = Permission::where('name', '=', 'enseigner')->first(); $role->attachPermission($permission); $role = new Role(); $role->name = 'professeur'; $role->display_name = 'Professeur'; $role->description = 'Les professeurs en charge des étudiants'; $role->save(); $permission = Permission::where('name', '=', 'ajout-etudiant')->first(); $role->attachPermission($permission); $permission = Permission::where('name', '=', 'passer-test')->first(); $role->attachPermission($permission); $permission = Permission::where('name', '=', 'enseigner')->first(); $role->attachPermission($permission); $role = new Role(); $role->name = 'etudiant'; $role->display_name = 'Étudiants'; $role->description = 'Les étudiants qui sont gérés par les professeurs'; $role->save(); $permission = Permission::where('name', '=', 'passer-test')->first(); $role->attachPermission($permission); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($yy, $qq, $aa) { $fin = array(); $fm = Helpers::getSetting('first_month'); $m1 = $qq * 3 - 3 + $fm; $y1 = $yy; $m2 = $qq * 3 - 2 + $fm; $y2 = $yy; $m3 = $qq * 3 - 1 + $fm; $y3 = $yy; if ($m2 > 12) { $m2 = $m2 - 12; $y2 = $y2 + 1; } if ($m3 > 12) { $m3 = $m3 - 12; $y3 = $y3 + 1; } if ($aa == "edit") { $perms = Permission::where('user_id', '=', Auth::user()->id)->get(); foreach ($perms as $perm) { if ($perm->preaching or $perm->admin) { $data['authsoc'][] = $perm['society_id']; } } if (!isset($data['authsoc'])) { $aa = "view"; } } $firstDateTime = mktime(0, 0, 0, $m1, 1, $y1); $firstDay = date("N", $firstDateTime); $firstSunday = date("d M Y", mktime(0, 0, 0, $m1, 8 - $firstDay, $y1)); $lastSunday = strtotime($firstSunday); $lastDay = mktime(23, 59, 59, $m3, cal_days_in_month(CAL_GREGORIAN, $m3, $y3), $y3); $extras = Weekday::where('servicedate', '>=', $firstDateTime)->where('servicedate', '<=', $lastDay)->orderBy('servicedate')->get()->toArray(); $data['meetings'] = Meeting::where('meetingdatetime', '<', $lastDay)->where('meetingdatetime', '>', $firstDateTime)->orderBy('meetingdatetime')->get(); $dum['dt'] = $lastSunday; $dum['yy'] = intval(date("Y", $lastSunday)); $dum['mm'] = intval(date("n", $lastSunday)); $dum['dd'] = intval(date("j", $lastSunday)); $sundays[] = $dum; $data['societies'] = Society::orderBy('society')->with('service')->get(); $data['ministers'] = Minister::has('individual')->get(); $data['preachers'] = Preacher::has('individual')->get(); $data['guests'] = Guest::where('active', '=', 1)->get(); while (date($lastSunday + 604800 <= $lastDay)) { $lastSunday = $lastSunday + 604800; $dum['dt'] = $lastSunday; $dum['yy'] = intval(date("Y", $lastSunday)); $dum['mm'] = intval(date("n", $lastSunday)); $dum['dd'] = intval(date("j", $lastSunday)); $sundays[] = $dum; } if (count($extras)) { $xco = 0; for ($q = 0; $q < count($sundays); $q++) { if ($xco < count($extras) and $extras[$xco]['servicedate'] < $sundays[$q]['dt']) { $dum['dt'] = $extras[$xco]['servicedate']; $dum['yy'] = intval(date("Y", $extras[$xco]['servicedate'])); $dum['mm'] = intval(date("n", $extras[$xco]['servicedate'])); $dum['dd'] = intval(date("j", $extras[$xco]['servicedate'])); $data['sundays'][] = $dum; $xco++; $q = $q - 1; } else { $data['sundays'][] = $sundays[$q]; } } } else { $data['sundays'] = $sundays; } $pm1 = Plan::where('planyear', '=', $y1)->where('planmonth', '=', $m1)->get(); foreach ($pm1 as $p1) { $soc = Society::find($p1->society_id)->society; $ser = Service::find($p1->service_id)->servicetime; if ($p1->preachable) { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['preacher'] = substr($p1->preachable_type, 11, 1) . "_" . $p1->preachable->id); if ($p1->preachable_type == "App\\Models\\Guest") { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['pname'] = substr($p1->preachable->firstname, 0, 1) . " " . $p1->preachable->surname); } else { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['pname'] = substr($p1->preachable->individual->firstname, 0, 1) . " " . $p1->preachable->individual->surname); } } else { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['preacher'] = ""); } if ($p1->tag_id) { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tag'] = $p1->tag_id); @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tname'] = Tag::find($p1->tag_id)->abbr); } else { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tag'] = ""); } } $pm2 = Plan::where('planyear', '=', $y2)->where('planmonth', '=', $m2)->get(); foreach ($pm2 as $p2) { $soc = Society::find($p2->society_id)->society; $ser = Service::find($p2->service_id)->servicetime; if ($p2->preachable) { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['preacher'] = substr($p2->preachable_type, 11, 1) . "_" . $p2->preachable->id); if ($p2->preachable_type == "App\\Models\\Guest") { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['pname'] = substr($p2->preachable->firstname, 0, 1) . " " . $p2->preachable->surname); } else { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['pname'] = substr($p2->preachable->individual->firstname, 0, 1) . " " . $p2->preachable->individual->surname); } } else { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['preacher'] = ""); } if ($p2->tag_id) { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tag'] = $p2->tag_id); @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tname'] = Tag::find($p2->tag_id)->abbr); } else { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tag'] = ""); } } $pm3 = Plan::where('planyear', '=', $y3)->where('planmonth', '=', $m3)->get(); foreach ($pm3 as $p3) { $soc = Society::find($p3->society_id)->society; $ser = Service::find($p3->service_id)->servicetime; if ($p3->preachable) { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['preacher'] = substr($p3->preachable_type, 11, 1) . "_" . $p3->preachable->id); if ($p3->preachable_type == "App\\Models\\Guest") { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['pname'] = substr($p3->preachable->firstname, 0, 1) . " " . $p3->preachable->surname); } else { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['pname'] = substr($p3->preachable->individual->firstname, 0, 1) . " " . $p3->preachable->individual->surname); } } else { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['preacher'] = ""); } if ($p3->tag_id) { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tag'] = $p3->tag_id); @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tname'] = Tag::find($p3->tag_id)->abbr); } else { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tag'] = ""); } } $data['tags'] = Tag::orderBy('abbr')->get(); if ($qq == 1) { $data['prev'] = "plan/" . strval($yy - 1) . "/4"; } else { $data['prev'] = "plan/{$yy}/" . strval($qq - 1); } if ($qq == 4) { $data['next'] = "plan/" . strval($yy + 1) . "/1"; } else { $data['next'] = "plan/{$yy}/" . strval($qq + 1); } if ($aa == "edit") { return View::make('plans.edit', $data); } else { $data['pb'] = Helpers::getSetting('presiding_bishop'); if (!$data['pb']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the Presiding Bishop'); } $data['gs'] = Helpers::getSetting('general_secretary'); if (!$data['gs']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the General Secretary'); } $data['db'] = Helpers::getSetting('district_bishop'); if (!$data['db']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the District Bishop'); } $data['super'] = Individual::find(Helpers::getSetting('superintendent')); if (!$data['super']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please specify who the Circuit Superintendent is'); } $this->report($data); } }
public function delete($resourceName) { Permission::where('resource', $resourceName)->delete(); }