Source for file controller.php

Documentation is available at controller.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  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.  * Base controller class for Users.
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_users
  17.  * @since       1.5
  18.  */
  19. {
  20.     /**
  21.      * Method to display a view.
  22.      *
  23.      * @param   boolean            If true, the view output will be cached
  24.      * @param   array  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  25.      *
  26.      * @return  JController        This object to support chaining.
  27.      * @since   1.5
  28.      */
  29.     public function display($cachable false$urlparams false)
  30.     {
  31.         // Get the document object.
  32.         $document    JFactory::getDocument();
  33.  
  34.         // Set the default view name and format from the Request.
  35.         $vName   $this->input->getCmd('view''login');
  36.         $vFormat $document->getType();
  37.         $lName   $this->input->getCmd('layout''default');
  38.  
  39.         if ($view $this->getView($vName$vFormat))
  40.         {
  41.             // Do any specific processing by view.
  42.             switch ($vName)
  43.             {
  44.                 case 'registration':
  45.                     // If the user is already logged in, redirect to the profile page.
  46.                     $user JFactory::getUser();
  47.                     if ($user->get('guest'!= 1)
  48.                     {
  49.                         // Redirect to profile page.
  50.                         $this->setRedirect(JRoute::_('index.php?option=com_users&view=profile'false));
  51.                         return;
  52.                     }
  53.  
  54.                     // Check if user registration is enabled
  55.                     if (JComponentHelper::getParams('com_users')->get('allowUserRegistration'== 0)
  56.                     {
  57.                         // Registration is disabled - Redirect to login page.
  58.                         $this->setRedirect(JRoute::_('index.php?option=com_users&view=login'false));
  59.                         return;
  60.                     }
  61.  
  62.                     // The user is a guest, load the registration model and show the registration page.
  63.                     $model $this->getModel('Registration');
  64.                     break;
  65.  
  66.                 // Handle view specific models.
  67.                 case 'profile':
  68.  
  69.                     // If the user is a guest, redirect to the login page.
  70.                     $user JFactory::getUser();
  71.                     if ($user->get('guest'== 1)
  72.                     {
  73.                         // Redirect to login page.
  74.                         $this->setRedirect(JRoute::_('index.php?option=com_users&view=login'false));
  75.                         return;
  76.                     }
  77.                     $model $this->getModel($vName);
  78.                     break;
  79.  
  80.                 // Handle the default views.
  81.                 case 'login':
  82.                     $model $this->getModel($vName);
  83.                     break;
  84.  
  85.                 case 'reset':
  86.                     // If the user is already logged in, redirect to the profile page.
  87.                     $user JFactory::getUser();
  88.                     if ($user->get('guest'!= 1)
  89.                     {
  90.                         // Redirect to profile page.
  91.                         $this->setRedirect(JRoute::_('index.php?option=com_users&view=profile'false));
  92.                         return;
  93.                     }
  94.  
  95.                     $model $this->getModel($vName);
  96.                     break;
  97.  
  98.                 case 'remind':
  99.                     // If the user is already logged in, redirect to the profile page.
  100.                     $user JFactory::getUser();
  101.                     if ($user->get('guest'!= 1)
  102.                     {
  103.                         // Redirect to profile page.
  104.                         $this->setRedirect(JRoute::_('index.php?option=com_users&view=profile'false));
  105.                         return;
  106.                     }
  107.  
  108.                     $model $this->getModel($vName);
  109.                     break;
  110.  
  111.                 default:
  112.                     $model $this->getModel('Login');
  113.                     break;
  114.             }
  115.  
  116.             // Push the model into the view (as default).
  117.             $view->setModel($modeltrue);
  118.             $view->setLayout($lName);
  119.  
  120.             // Push document object into the view.
  121.             $view->document $document;
  122.  
  123.             $view->display();
  124.         }
  125.     }
  126. }

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