Source for file debuguser.php

Documentation is available at debuguser.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_users
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. require_once JPATH_COMPONENT '/helpers/debug.php';
  13.  
  14. /**
  15.  * Methods supporting a list of user records.
  16.  *
  17.  * @package     Joomla.Administrator
  18.  * @subpackage  com_users
  19.  * @since       1.6
  20.  */
  21. {
  22.     /**
  23.      * Get a list of the actions.
  24.      *
  25.      * @return  array 
  26.      * @since   1.6
  27.      */
  28.     public function getDebugActions()
  29.     {
  30.         $component $this->getState('filter.component');
  31.  
  32.         return UsersHelperDebug::getDebugActions($component);
  33.     }
  34.  
  35.     /**
  36.      * Override getItems method.
  37.      *
  38.      * @return  array 
  39.      * @since   1.6
  40.      */
  41.     public function getItems()
  42.     {
  43.         $userId $this->getState('filter.user_id');
  44.  
  45.         if (($assets parent::getItems()) && $userId)
  46.         {
  47.  
  48.             $actions $this->getDebugActions();
  49.  
  50.             foreach ($assets as &$asset)
  51.             {
  52.                 $asset->checks array();
  53.  
  54.                 foreach ($actions as $action)
  55.                 {
  56.                     $name $action[0];
  57.                     $level $action[1];
  58.  
  59.                     // Check that we check this action for the level of the asset.
  60.                     if ($level === null || $level >= $asset->level)
  61.                     {
  62.                         // We need to test this action.
  63.                         $asset->checks[$nameJAccess::check($userId$name$asset->name);
  64.                     }
  65.                     else
  66.                     {
  67.                         // We ignore this action.
  68.                         $asset->checks[$name'skip';
  69.                     }
  70.                 }
  71.             }
  72.         }
  73.  
  74.         return $assets;
  75.     }
  76.  
  77.     /**
  78.      * Method to auto-populate the model state.
  79.      *
  80.      * Note. Calling getState in this method will result in recursion.
  81.      *
  82.      * @return  void 
  83.      * @since   1.6
  84.      */
  85.     protected function populateState($ordering null$direction null)
  86.     {
  87.         $app JFactory::getApplication('administrator');
  88.  
  89.         // Adjust the context to support modal layouts.
  90.         $layout $app->input->get('layout''default');
  91.         if ($layout)
  92.         {
  93.             $this->context .= '.' $layout;
  94.         }
  95.  
  96.         // Load the filter state.
  97.         $search $this->getUserStateFromRequest($this->context . '.filter.search''filter_search');
  98.         $this->setState('filter.search'$search);
  99.  
  100.         $value $this->getUserStateFromRequest($this->context . '.filter.user_id''user_id'0'int');
  101.         $this->setState('filter.user_id'$value);
  102.  
  103.         $levelStart $this->getUserStateFromRequest($this->context . '.filter.level_start''filter_level_start'0'int');
  104.         $this->setState('filter.level_start'$levelStart);
  105.  
  106.         $value $this->getUserStateFromRequest($this->context . '.filter.level_end''filter_level_end'0'int');
  107.         if ($value && $value $levelStart)
  108.         {
  109.             $value $levelStart;
  110.         }
  111.         $this->setState('filter.level_end'$value);
  112.  
  113.         $component $this->getUserStateFromRequest($this->context . '.filter.component''filter_component');
  114.         $this->setState('filter.component'$component);
  115.  
  116.         // Load the parameters.
  117.         $params JComponentHelper::getParams('com_users');
  118.         $this->setState('params'$params);
  119.  
  120.         // List state information.
  121.         parent::populateState('a.lft''asc');
  122.     }
  123.  
  124.     /**
  125.      * Method to get a store id based on model configuration state.
  126.      *
  127.      * This is necessary because the model is used by the component and
  128.      * different modules that might need different sets of data or different
  129.      * ordering requirements.
  130.      *
  131.      * @param   string  $id    A prefix for the store id.
  132.      *
  133.      * @return  string  A store id.
  134.      * @since   1.6
  135.      */
  136.     protected function getStoreId($id '')
  137.     {
  138.         // Compile the store id.
  139.         $id .= ':' $this->getState('filter.search');
  140.         $id .= ':' $this->getState('filter.user_id');
  141.         $id .= ':' $this->getState('filter.level_start');
  142.         $id .= ':' $this->getState('filter.level_end');
  143.         $id .= ':' $this->getState('filter.component');
  144.  
  145.         return parent::getStoreId($id);
  146.     }
  147.  
  148.     /**
  149.      * Get the user being debugged.
  150.      *
  151.      * @return  JUser 
  152.      * @since   1.6
  153.      */
  154.     public function getUser()
  155.     {
  156.         $userId $this->getState('filter.user_id');
  157.  
  158.         return JFactory::getUser($userId);
  159.     }
  160.  
  161.     /**
  162.      * Build an SQL query to load the list data.
  163.      *
  164.      * @return  JDatabaseQuery 
  165.      * @since   1.6
  166.      */
  167.     protected function getListQuery()
  168.     {
  169.         // Create a new query object.
  170.         $db $this->getDbo();
  171.         $query $db->getQuery(true);
  172.  
  173.         // Select the required fields from the table.
  174.         $query->select(
  175.             $this->getState(
  176.                 'list.select',
  177.                 'a.id, a.name, a.title, a.level, a.lft, a.rgt'
  178.             )
  179.         );
  180.         $query->from($db->quoteName('#__assets'' AS a');
  181.  
  182.         // Filter the items over the group id if set.
  183.         if ($groupId $this->getState('filter.group_id'))
  184.         {
  185.             $query->join('LEFT''#__user_usergroup_map AS map2 ON map2.user_id = a.id')
  186.                 ->where('map2.group_id = ' . (int) $groupId);
  187.         }
  188.  
  189.         // Filter the items over the search string if set.
  190.         if ($this->getState('filter.search'))
  191.         {
  192.             // Escape the search token.
  193.             $token $db->quote('%' $db->escape($this->getState('filter.search')) '%');
  194.  
  195.             // Compile the different search clauses.
  196.             $searches array();
  197.             $searches['a.name LIKE ' $token;
  198.             $searches['a.title LIKE ' $token;
  199.  
  200.             // Add the clauses to the query.
  201.             $query->where('(' implode(' OR '$searches')');
  202.         }
  203.  
  204.         // Filter on the start and end levels.
  205.         $levelStart = (int) $this->getState('filter.level_start');
  206.         $levelEnd = (int) $this->getState('filter.level_end');
  207.         if ($levelEnd && $levelEnd $levelStart)
  208.         {
  209.             $levelEnd $levelStart;
  210.         }
  211.         if ($levelStart 0)
  212.         {
  213.             $query->where('a.level >= ' $levelStart);
  214.         }
  215.         if ($levelEnd 0)
  216.         {
  217.             $query->where('a.level <= ' $levelEnd);
  218.         }
  219.  
  220.         // Filter the items over the component if set.
  221.         if ($this->getState('filter.component'))
  222.         {
  223.             $component $this->getState('filter.component');
  224.             $query->where('(a.name = ' $db->quote($component' OR a.name LIKE ' $db->quote($component '.%'')');
  225.         }
  226.  
  227.         // Add the list ordering clause.
  228.         $query->order($db->escape($this->getState('list.ordering''a.lft')) ' ' $db->escape($this->getState('list.direction''ASC')));
  229.  
  230.         return $query;
  231.     }
  232. }

Documentation generated on Tue, 19 Nov 2013 14:58:05 +0100 by phpDocumentor 1.4.3