/**
  * 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'));
         }
     }
 }
Exemple #2
0
 /**
  * Function get for users record.
  *
  * @return void
  */
 public function get()
 {
     $input = JFactory::getApplication()->input;
     // If we have an id try to fetch the user
     if ($id = $input->get('id')) {
         $user = JUser::getInstance($id);
         if (!$user->id) {
             $this->plugin->setResponse($this->getErrorResponse(404, 'User not found'));
             return;
         }
         $this->plugin->setResponse($user);
     } else {
         $model = new UsersModelUsers();
         $users = $model->getItems();
         foreach ($users as $k => $v) {
             unset($users[$k]->password);
         }
         $this->plugin->setResponse($users);
     }
 }
Exemple #3
0
 /**
  * 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);
 }
Exemple #4
0
	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'));
	}