/** * Run the migrations. * * @return void */ public function up() { $role = Role::admin(); $acl = Foundation::acl(); $actions = ['Manage Roles', 'Manage Acl']; $acl->actions()->attach($actions); $acl->allow($role->name, $actions); }
/** * Attach access policy events. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function attachAccessPolicyEvents(Application $app) { // Orchestra Platform should be able to watch any changes to Role model // and sync the information to "orchestra.acl". Role::observe($app->make(RoleObserver::class)); // Orchestra Platform should be able to determine admin and member roles // dynamically. Role::setDefaultRoles($app->make('config')->get('orchestra/foundation::roles')); }
/** * Handle `orchestra.saved: extension.orchestra/control` event. * * @param \Illuminate\Support\Fluent $input * * @return void */ public function handle(Fluent $input) { $localtime = $input['localtime'] === 'yes'; $this->config->set('orchestra/foundation::roles.admin', (int) $input['admin_role']); $this->config->set('orchestra/foundation::roles.member', (int) $input['member_role']); Role::setDefaultRoles($this->config->get('orchestra/foundation::roles')); $this->synchronizer->handle(); $this->memory->put('extension_orchestra/control.localtime', $localtime); }
/** * Run the migrations. * * @return void */ public function up() { $admin = Role::admin(); $member = Role::member(); $acl = ACL::make('orchestra/story'); $acl->roles()->attach([$member->name, $admin->name]); $acl->actions()->attach(['Create Post', 'Update Post', 'Delete Post', 'Manage Post', 'Create Page', 'Update Page', 'Delete Page', 'Manage Page']); $acl->allow($member->name, ['Create Post', 'Update Post', 'Delete Post', 'Create Page', 'Update Page', 'Delete Page']); $acl->allow($admin->name, ['Create Post', 'Update Post', 'Delete Post', 'Manage Post', 'Create Page', 'Update Page', 'Delete Page', 'Manage Page']); }
/** * Run the migrations. * * @return void */ public function up() { $admin = Role::admin(); $member = Role::member(); $acl = Acl::make('hostbrute/uppy'); $acl->roles()->attach([$admin->name, $member->name]); //set up actions, php 5.4 style baby $adminActions = ['Manage Uppy']; $acl->actions()->attach($adminActions); $acl->allow($admin->name, $adminActions); }
/** * Setup the form. * * @param \Illuminate\Support\Fluent $model * @param \Orchestra\Contracts\Html\Form\Builder $form * * @return void */ protected function form(Fluent $model, FormBuilder $form) { $form->extend(function (FormGrid $form) { $form->fieldset('Role Configuration', function (Fieldset $fieldset) { $roles = Role::lists('name', 'id'); $fieldset->control('select', 'admin_role')->label(trans('orchestra/control::label.roles.admin'))->options($roles); $fieldset->control('select', 'member_role')->label(trans('orchestra/control::label.roles.member'))->options($roles); }); $form->fieldset('Timezone', function (Fieldset $fieldset) { $agreement = ['yes' => 'Yes', 'no' => 'No']; $fieldset->control('select', 'localtime')->attributes(['role' => 'agreement'])->label(trans('orchestra/control::label.enable-timezone'))->options($agreement)->value(function ($row) { return $row->localtime === true ? 'yes' : 'no'; }); }); }); }
/** * Response when updating role succeed. * * @param \Orchestra\Model\Role $role * * @return mixed */ public function destroySucceed(Role $role) { $message = trans('orchestra/control::response.roles.delete', ['name' => $role->getAttribute('name')]); return $this->redirectWithMessage(handles('orchestra::control/roles'), $message); }
/** * Attaches roles depending on the users active directory group. * * @param User $user * @param AdldapUser $adldapUser */ protected function handleLdapUserWasAuthenticated(User $user, AdldapUser $adldapUser) { if ($adldapUser->inGroup('Help Desk')) { $admin = Role::admin(); if ($admin instanceof Role) { $user->attachRole($admin->getKey()); } } }