Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Config::get('validator.admin.role'));
     if ($validator->passes()) {
         $role = new Role();
         $role->name = Input::get('name');
         $role->deletable = 1;
         // Was the blog post created?
         if ($role->save()) {
             //Set all permission to deny
             $resources = Resource::where('in_admin_ui', '=', 1)->get();
             $data = array();
             foreach ($resources as $resource) {
                 foreach (Action::all() as $action) {
                     $data[] = array('role_id' => $role->id, 'type' => 'deny', 'action_id' => $action->id, 'resource_id' => $resource->id);
                 }
             }
             DB::table('permissions')->insert($data);
             //track user
             parent::track('create', 'Role', $role->id);
             return Redirect::to('admin/role_permission')->with('success', Lang::get('admin.role_save_success'));
         }
         // Redirect to the blog post create role
         return Redirect::to('admin/role/create')->with('error', Lang::get('admin.role_save_fail'));
     }
     // Form validation failed
     return Redirect::to('admin/role/create')->withInput()->withErrors($validator);
 }
 public function destroy($idMenu, $id)
 {
     $adminMenu = AdministrationMenu::find($idMenu);
     $role = Role::find($id);
     foreach (Action::all() as $action) {
         DB::table('actions_roles_menu')->where('action_id', '=', $action->id)->where('role_id', '=', $role->id)->where('menu_admin_id', '=', $adminMenu->id)->softDeletes();
     }
     // redirect
     Session::flash('message', 'Successfully deleted the menu!');
     return Redirect::to('admin/access/' . $adminMenu->id);
 }
Exemplo n.º 3
0
 /**
  * [policyRBACEditFrmAction Show form for edit rbac-policy]
  * @param  [integer] $id policy id
  * @return [none] redirect to view
  */
 public function policyRBACEditFrmAction($id)
 {
     $data['policy'] = Policy::find($id);
     $data['role'] = Roles::all();
     $data['data'] = Data::all();
     $data['condition'] = Condition::all();
     $data['action'] = Action::all();
     $data['purpose'] = Purpose::all();
     $data['obligation'] = Obligation::all();
     // print '<pre>';
     // print_r(self::policyRBACEditAction($id));
     // exit();
     return View::make('rbac.editrbac')->with('results', $data)->with('rbac_data', self::policyRBACEditAction($id));
 }
Exemplo n.º 4
0
        <!-- if there are creation errors, they will show here -->
        {{ HTML::ul($errors->all()) }}

        {{ Form::open(array('url' => 'admin/access/'.$adminMenu->id.'/update/'.$role->id, 'method'=>'post')) }}
        {{ Form::token() }}
        <div class="form-group">
            {{ Form::label('role', 'Actual Role:') }}
            <input type="hidden" value="{{$role->id}}" name="oldRole" id="oldRole" />
            {{ Form::select('role', ['' => ''] + Role::all()->lists('name', 'id'),$role->id) }}
        </div>

        <div class="form-group">
            {{ Form::label('action', 'Action:') }}
            <br> 
            <?php 
foreach (Action::all() as $action) {
    $find = false;
    foreach ($role->actions()->getResults() as $checkboxAction) {
        if ($checkboxAction->id === $action->id) {
            $find = true;
            break;
        }
    }
    if ($find) {
        echo Form::checkbox('actions[]', $checkboxAction->id, true, array("style", "padding-left:1.5em"));
        echo '<label style="padding-right:0.5em" >' . $checkboxAction->name . '</label>';
    } else {
        echo Form::checkbox('actions[]', $action->id, false, array("style", "padding-left:1.5em"));
        echo '<label style="padding-right:0.5em" >' . $action->name . '</label>';
    }
}