Ejemplo n.º 1
0
 public function savegroups()
 {
     $input = Input::all();
     if (isset($input['_id']) && $input['_id'] == '') {
         try {
             Sentry::createGroup(array('name' => $input['name'], 'permissions' => array()));
             Session::flash('message', 'Save success');
         } catch (NameRequiredException $e) {
             Session::flash('message', 'Name field is required');
         } catch (GroupExistsException $e) {
             Session::flash('message', 'Group already exists');
         }
     } else {
         if ($input['_id'] != '') {
             try {
                 $group = Sentry::findGroupById($input['_id']);
                 $group->name = $input['name'];
                 if ($group->save()) {
                     Session::flash('message', 'Group was updated');
                 } else {
                     Session::flash('message', 'Group was not updated');
                 }
             } catch (NameRequiredException $e) {
                 Session::flash('message', 'Name field is required');
             } catch (GroupExistsException $e) {
                 Session::flash('message', 'Group already exists');
             } catch (GroupNotFoundException $e) {
                 Session::flash('message', 'Group was not found.');
             }
         }
     }
     return Response::json('1');
 }
Ejemplo n.º 2
0
 /**
  * Creates a new group.
  * 
  * @param  array  $input
  * @return void
  */
 public function create(array $input)
 {
     //create base group array
     $newGroup = array('name' => $input['name'], 'permissions' => array('superuser' => $input['superuser'], 'titles.edit' => $input['titles_edit'], 'titles.create' => $input['titles_create'], 'titles.delete' => $input['titles_delete'], 'people.create' => $input['people_create'], 'people.edit' => $input['people_edit'], 'people.delete' => $input['people_delete'], 'users.create' => $input['users_create'], 'users.edit' => $input['users_edit'], 'users.delete' => $input['users_delete'], 'slides.create' => $input['slides_create'], 'slides.edit' => $input['slides_edit'], 'slides.delete' => $input['slides_delete'], 'actions.manage' => $input['actions_manage'], 'settings.manage' => $input['settings_manage'], 'ads.manage' => $input['ads_manage'], 'reviews.delete' => $input['reviews_delete'], 'links.approve' => $input['links_approve'], 'links.delete' => $input['links_delete'], 'groups.create' => $input['groups_create'], 'groups.edit' => $input['groups_edit'], 'groups.delete' => $input['groups_delete'], 'production_companies.create' => $input['production_companies_create'], 'production_companies.edit' => $input['production_companies_edit'], 'production_companies.delete' => $input['production_companies_delete'], 'tv_networks.create' => $input['tv_networks_create'], 'tv_networks.edit' => $input['tv_networks_edit'], 'tv_networks.delete' => $input['tv_networks_delete']));
     Sentry::createGroup($newGroup);
     \Cache::flush();
     Event::fire('Groups.Created', array($input, Carbon::now(), 'Created'));
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // Create an Admin group
     Sentry::createGroup(array('name' => 'Admin', 'permissions' => ['dashboard.index' => 1, 'dashboard.grid.save' => 1, 'dashboard.grid.reset' => 1, 'workshop.modules.index' => 1, 'workshop.modules.show' => 1, 'workshop.modules.disable' => 1, 'workshop.modules.enable' => 1, 'user.roles.index' => 1, 'user.roles.create' => 1, 'user.roles.store' => 1, 'user.roles.edit' => 1, 'user.roles.update' => 1, 'user.roles.destroy' => 1, 'user.users.index' => 1, 'user.users.create' => 1, 'user.users.store' => 1, 'user.users.edit' => 1, 'user.users.update' => 1, 'user.users.destroy' => 1, 'menu.menus.index' => 1, 'menu.menus.create' => 1, 'menu.menus.store' => 1, 'menu.menus.edit' => 1, 'menu.menus.update' => 1, 'menu.menus.destroy' => 1, 'menu.menuitem.index' => 1, 'menu.menuitem.create' => 1, 'menu.menuitem.store' => 1, 'menu.menuitem.edit' => 1, 'menu.menuitem.update' => 1, 'menu.menuitem.destroy' => 1, 'media.media.index' => 1, 'media.media.create' => 1, 'media.media.store' => 1, 'media.media.edit' => 1, 'media.media.update' => 1, 'media.media.destroy' => 1, 'media.media-grid.index' => 1, 'media.media-grid.ckIndex' => 1, 'setting.settings.index' => 1, 'setting.settings.store' => 1, 'setting.settings.getModuleSettings' => 1, 'page.pages.index' => 1, 'page.pages.create' => 1, 'page.pages.store' => 1, 'page.pages.edit' => 1, 'page.pages.update' => 1, 'page.pages.destroy' => 1]));
     // Create an Users group
     Sentry::createGroup(array('name' => 'User', 'permissions' => ['dashboard.index' => 1]));
 }
Ejemplo n.º 4
0
 /**
  * @return \Illuminate\Http\JsonResponse
  */
 public function postStore()
 {
     $group = Sentry::createGroup(array('name' => Input::get('name'), 'permissions' => ['member' => 1]));
     if ($group) {
         return Response::json(['status' => 1]);
     } else {
         return Response::json(['status' => 0]);
     }
 }
Ejemplo n.º 5
0
 public function run()
 {
     $groups = ['Administrator' => ['create' => 1, 'update' => 1, 'delete' => 1, 'view' => 1], 'Moderator' => ['create' => 0, 'update' => 1, 'delete' => 0, 'view' => 1], 'General' => ['create' => 0, 'update' => 0, 'delete' => 0, 'view' => 1]];
     foreach ($groups as $key => $group) {
         try {
             // Create the group
             Sentry::createGroup(array('name' => $key, 'permissions' => $group));
         } catch (Exception $e) {
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     try {
         // Create the group
         $group = Sentry::createGroup(array('name' => 'Moderator', 'permissions' => array('admin' => 1, 'users' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
 }
Ejemplo n.º 7
0
 /**
  * Create new group
  *
  * @param array $data
  * @return bool
  */
 public function create(array $data)
 {
     try {
         Sentry::createGroup($data);
     } catch (NameRequiredException $e) {
         $this->error = 'Name field is required';
         return false;
     } catch (GroupExistsException $e) {
         $this->error = 'Group already exists';
         return false;
     }
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Create or update a group through Sentry.
  *
  * If the permissions array is empty it will leave the current permissions intact.
  *
  * @param string $name The name for the group to find or create
  * @param array $permissions The permissions to assign the group.
  *
  * @return mixed
  */
 public function createOrUpdateGroup($name, $permissions = [])
 {
     try {
         /*
          * Group already exists, lets try and update the permissions
          * if we were supplied any
          */
         $group = Sentry::findGroupByName($name);
         if (!empty($permissions)) {
             $group->permissions = $permissions;
             $group->save();
         }
     } catch (GroupNotFoundException $e) {
         /*
          * If the group does not exist, we'll create it and assign
          * the permissions
          */
         $group = Sentry::createGroup(['name' => $name, 'permissions' => $permissions]);
     }
     return $group;
 }
Ejemplo n.º 9
0
 /**
  * Create a role resource
  * @return mixed
  */
 public function create($data)
 {
     unset($data['slug']);
     Sentry::createGroup($data);
 }