/** * Method to auto-populate the model state. * Note. Calling getState in this method will result in recursion. * * @return void */ protected function populateState($ordering = null, $direction = null) { parent::populateState(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $model = $this->getInstance('Form', 'PFprojectsModel', array('ignore_request' => true)); $groups = array(); // Filter - State $this->setState('filter.state', 0); // Filter - Project $pid = PFApplicationHelper::getActiveProjectId('filter_project'); $this->setState('filter.project', $pid); // Override group filter by active project if ($pid) { $tmp_groups = $model->getUserGroups($pid); // Get group ids if (is_array($tmp_groups)) { foreach ($tmp_groups as $group) { $groups[] = (int) $group; } } } else { // No active project. Filter by all accessible projects if (!$user->authorise('core.admin')) { $umodel = $this->getInstance('User', 'PFusersModel'); $projects = $umodel->getProjects(); foreach ($projects as $project) { $tmp_groups = $model->getUserGroups($project); if ($tmp_groups !== false) { // Get group ids if (is_array($tmp_groups)) { foreach ($tmp_groups as $group) { $groups[] = (int) $group; } } } } } } if (count($groups)) { $this->setState('filter.groups', $groups); } else { if (!$user->authorise('core.admin')) { $this->setState('filter.groups', array('1')); } } }
/** * Method to auto-populate the model state. * Note: Calling getState in this method will result in recursion. * * @return void */ protected function populateState($ordering = 'a.username', $direction = 'asc') { // Initialise variables. $app = JFactory::getApplication(); // Adjust the context to support modal layouts. if ($layout = JRequest::getVar('layout')) { $this->context .= '.' . $layout; } // Filter - Search $search = JRequest::getCmd('filter_search'); $this->setState('filter.search', $search); // List state information. parent::populateState($ordering, $direction); }
protected function populateState($ordering = null, $direction = null) { parent::populateState(JRequest::getVar('order_key'), JRequest::getVar('order_filter')); $this->setState('list.ordering',JRequest::getVar('order_key')); $this->setState('list.direction',JRequest::getVar('order_filter')); }