/** * Admin.user.create */ public function postCreate() { // Set permission Auth::requirePermissions('admin.user.create'); try { // Find the group using the group id $group = \Sentry::findGroupById(\Input::get('group')); // Create the user $user = \Sentry::createUser(array('email' => strtolower(\Input::get('name')), 'password' => \Input::get('password'))); // Activate the user $user->activated = 1; $user->save(); // Assign the group to the user $user->addGroup($group); } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) { Flash::set('Username is required'); } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) { Flash::set('A password is required'); } catch (\Cartalyst\Sentry\Users\UserExistsException $e) { Flash::set('A user with that username already exists'); } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) { // Illegal group -> ignore } return \Redirect::to('api/admin/users'); }
/** * Admin.settings.update */ public function postIndex() { // Set permission Auth::requirePermissions('admin.dataset.view'); $settings_allowed = array('catalog_title', 'catalog_description', 'catalog_language', 'catalog_publisher_uri', 'catalog_publisher_name'); $values = \Input::all(); foreach ($values as $key => $value) { if (in_array($key, $settings_allowed)) { if ($key === 'catalog_publisher_uri') { if (!filter_var($values['catalog_publisher_uri'], FILTER_VALIDATE_URL)) { Flash::set('Publisher URI is not a valid URI.'); continue; } } $this->settings->storeValue($key, $value); } } return \Redirect::to('api/admin/settings'); }
/** * Admin.group.update */ public function postUpdate($id = null) { // Set permission Auth::requirePermissions('admin.group.update'); try { if (empty($id)) { $id = \Input::get('id'); } // Find the user using the group id $group = \Sentry::findGroupById($id); $permissions_save = \Input::get('btn_save_permissions'); if (empty($permissions_save)) { // Update group if ($id > 2) { $group->name = \Input::get('name'); } $group->save(); } else { if ($group->id > 2) { // Update permissions $permission_data = \Input::get(); $permissions = array(); // Unset previous permissions $group_permissions = $group->getPermissions(); foreach ($group_permissions as $p => $value) { $permissions[$p] = 0; } // Add new ones foreach ($permission_data as $p => $value) { // Skip extra information if ($p == 'id' || $p == 'btn_save_permissions') { continue; } // Form undo transform $p = str_replace('_', '.', $p); // Permission set $permissions[$p] = 1; } // Save permissions $group->permissions = $permissions; $group->save(); } } } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) { Flash::set('Name is required'); } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { // Ignore and redirect back } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) { // Ignore and redirect back } return \Redirect::to('api/admin/groups'); }