Source for file controller.php

Documentation is available at controller.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. /**
  13.  * Users master display controller.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * Checks whether a user can see this view.
  22.      *
  23.      * @param   string    $view    The view name.
  24.      *
  25.      * @return  boolean 
  26.      * @since   1.6
  27.      */
  28.     protected function canView($view)
  29.     {
  30.         $canDo    UsersHelper::getActions();
  31.  
  32.         switch ($view)
  33.         {
  34.             // Special permissions.
  35.             case 'groups':
  36.             case 'group':
  37.             case 'levels':
  38.             case 'level':
  39.                 return $canDo->get('core.admin');
  40.                 break;
  41.  
  42.             // Default permissions.
  43.             default:
  44.                 return true;
  45.         }
  46.     }
  47.  
  48.     /**
  49.      * Method to display a view.
  50.      *
  51.      * @param   boolean            If true, the view output will be cached
  52.      * @param   array  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  53.      *
  54.      * @return  JController        This object to support chaining.
  55.      * @since   1.5
  56.      */
  57.     public function display($cachable false$urlparams false)
  58.     {
  59.         $view   $this->input->get('view''users');
  60.         $layout $this->input->get('layout''default');
  61.         $id     $this->input->getInt('id');
  62.  
  63.         if (!$this->canView($view))
  64.         {
  65.             JError::raiseWarning(404JText::_('JERROR_ALERTNOAUTHOR'));
  66.  
  67.             return;
  68.         }
  69.  
  70.         // Check for edit form.
  71.         if ($view == 'user' && $layout == 'edit' && !$this->checkEditId('com_users.edit.user'$id))
  72.         {
  73.             // Somehow the person just went to the form - we don't allow that.
  74.             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID'$id));
  75.             $this->setMessage($this->getError()'error');
  76.             $this->setRedirect(JRoute::_('index.php?option=com_users&view=users'false));
  77.  
  78.             return false;
  79.         }
  80.         elseif ($view == 'group' && $layout == 'edit' && !$this->checkEditId('com_users.edit.group'$id))
  81.         {
  82.             // Somehow the person just went to the form - we don't allow that.
  83.             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID'$id));
  84.             $this->setMessage($this->getError()'error');
  85.             $this->setRedirect(JRoute::_('index.php?option=com_users&view=groups'false));
  86.  
  87.             return false;
  88.         }
  89.         elseif ($view == 'level' && $layout == 'edit' && !$this->checkEditId('com_users.edit.level'$id))
  90.         {
  91.             // Somehow the person just went to the form - we don't allow that.
  92.             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID'$id));
  93.             $this->setMessage($this->getError()'error');
  94.             $this->setRedirect(JRoute::_('index.php?option=com_users&view=levels'false));
  95.  
  96.             return false;
  97.         }
  98.         elseif ($view == 'note' && $layout == 'edit' && !$this->checkEditId('com_users.edit.note'$id))
  99.         {
  100.             // Somehow the person just went to the form - we don't allow that.
  101.             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID'$id));
  102.             $this->setMessage($this->getError()'error');
  103.             $this->setRedirect(JRoute::_('index.php?option=com_users&view=notes'false));
  104.  
  105.             return false;
  106.         }
  107.  
  108.         return parent::display();
  109.     }
  110. }

Documentation generated on Tue, 19 Nov 2013 14:57:33 +0100 by phpDocumentor 1.4.3