function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public function action_edit($user = null) { $id = $this->request->param('id'); try { $user = $user != null ? $user : Sentry::getUserProvider()->findById($id); $permissions = is_array($user->permissions) ? array_keys($user->permissions) : array(); //split up the user groups $groups = $user->not_in_groups(true); $this->_tpl->content = View::factory('s4k/user/manage/edit', array('user' => $user, 'groups' => $groups, 'permissions' => Permissions::instance()->split($permissions))); } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { Hint::set(Hint::ERROR, 'No corresponding user found'); $this->redirect(Route::url('S4K.users.manage', null, true)); } }
public function action_edit($group = null) { $id = $this->request->param('id'); try { $group = $group == null ? Sentry::getGroupProvider()->findById($id) : $group; //get the permission names of this group $permissions = is_array($group->permissions) ? array_keys($group->permissions) : array(); $this->_tpl->content = View::factory('s4k/groups/edit', array('group' => $group, 'permissions' => Permissions::instance()->split($permissions))); } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) { //set an error message an redirect to the management page Hint::set(Hint::ERROR, 'No corresponding group found'); $this->redirect(Route::url('S4K.groups', null, true)); } }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'Permissions')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return Permissions::instance()->paginate($arguments, $items_per_page, $current_page); } // if }
/** * Return manager instance * * @access protected * @param void * @return Permissions */ function manager() { if (!$this->manager instanceof Permissions) { $this->manager = Permissions::instance(); } return $this->manager; }