Source for file reset.php

Documentation is available at reset.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. require_once JPATH_COMPONENT.'/controller.php';
  13.  
  14. /**
  15.  * Reset controller class for Users.
  16.  *
  17.  * @package     Joomla.Site
  18.  * @subpackage  com_users
  19.  * @since       1.6
  20.  */
  21. {
  22.     /**
  23.      * Method to request a password reset.
  24.      *
  25.      * @since   1.6
  26.      */
  27.     public function request()
  28.     {
  29.         // Check the request token.
  30.         JSession::checkToken('post'or jexit(JText::_('JINVALID_TOKEN'));
  31.  
  32.         $app   JFactory::getApplication();
  33.         $model $this->getModel('Reset''UsersModel');
  34.         $data  $this->input->post->get('jform'array()'array');
  35.  
  36.         // Submit the password reset request.
  37.         $return    $model->processResetRequest($data);
  38.  
  39.         // Check for a hard error.
  40.         if ($return instanceof Exception)
  41.         {
  42.             // Get the error message to display.
  43.             if ($app->getCfg('error_reporting'))
  44.             {
  45.                 $message $return->getMessage();
  46.             else {
  47.                 $message JText::_('COM_USERS_RESET_REQUEST_ERROR');
  48.             }
  49.  
  50.             // Get the route to the next page.
  51.             $itemid UsersHelperRoute::getResetRoute();
  52.             $itemid $itemid !== null '&Itemid='.$itemid '';
  53.             $route    'index.php?option=com_users&view=reset'.$itemid;
  54.  
  55.             // Go back to the request form.
  56.             $this->setRedirect(JRoute::_($routefalse)$message'error');
  57.             return false;
  58.         elseif ($return === false)
  59.         {
  60.             // The request failed.
  61.             // Get the route to the next page.
  62.             $itemid UsersHelperRoute::getResetRoute();
  63.             $itemid $itemid !== null '&Itemid='.$itemid '';
  64.             $route    'index.php?option=com_users&view=reset'.$itemid;
  65.  
  66.             // Go back to the request form.
  67.             $message JText::sprintf('COM_USERS_RESET_REQUEST_FAILED'$model->getError());
  68.             $this->setRedirect(JRoute::_($routefalse)$message'notice');
  69.             return false;
  70.         }
  71.         else
  72.         {
  73.             // The request succeeded.
  74.             // Get the route to the next page.
  75.             $itemid UsersHelperRoute::getResetRoute();
  76.             $itemid $itemid !== null '&Itemid='.$itemid '';
  77.             $route    'index.php?option=com_users&view=reset&layout=confirm'.$itemid;
  78.  
  79.             // Proceed to step two.
  80.             $this->setRedirect(JRoute::_($routefalse));
  81.             return true;
  82.         }
  83.     }
  84.  
  85.     /**
  86.      * Method to confirm the password request.
  87.      *
  88.      * @access    public
  89.      * @since   1.6
  90.      */
  91.     public function confirm()
  92.     {
  93.         // Check the request token.
  94.         JSession::checkToken('request'or jexit(JText::_('JINVALID_TOKEN'));
  95.  
  96.         $app   JFactory::getApplication();
  97.         $model $this->getModel('Reset''UsersModel');
  98.         $data  $this->input->get('jform'array()'array');
  99.  
  100.         // Confirm the password reset request.
  101.         $return    $model->processResetConfirm($data);
  102.  
  103.         // Check for a hard error.
  104.         if ($return instanceof Exception)
  105.         {
  106.             // Get the error message to display.
  107.             if ($app->getCfg('error_reporting'))
  108.             {
  109.                 $message $return->getMessage();
  110.             else {
  111.                 $message JText::_('COM_USERS_RESET_CONFIRM_ERROR');
  112.             }
  113.  
  114.             // Get the route to the next page.
  115.             $itemid UsersHelperRoute::getResetRoute();
  116.             $itemid $itemid !== null '&Itemid='.$itemid '';
  117.             $route    'index.php?option=com_users&view=reset&layout=confirm'.$itemid;
  118.  
  119.             // Go back to the confirm form.
  120.             $this->setRedirect(JRoute::_($routefalse)$message'error');
  121.             return false;
  122.         elseif ($return === false)
  123.         {
  124.             // Confirm failed.
  125.             // Get the route to the next page.
  126.             $itemid UsersHelperRoute::getResetRoute();
  127.             $itemid $itemid !== null '&Itemid='.$itemid '';
  128.             $route    'index.php?option=com_users&view=reset&layout=confirm'.$itemid;
  129.  
  130.             // Go back to the confirm form.
  131.             $message JText::sprintf('COM_USERS_RESET_CONFIRM_FAILED'$model->getError());
  132.             $this->setRedirect(JRoute::_($routefalse)$message'notice');
  133.             return false;
  134.         }
  135.         else
  136.         {
  137.             // Confirm succeeded.
  138.             // Get the route to the next page.
  139.             $itemid UsersHelperRoute::getResetRoute();
  140.             $itemid $itemid !== null '&Itemid='.$itemid '';
  141.             $route    'index.php?option=com_users&view=reset&layout=complete'.$itemid;
  142.  
  143.             // Proceed to step three.
  144.             $this->setRedirect(JRoute::_($routefalse));
  145.             return true;
  146.         }
  147.     }
  148.  
  149.     /**
  150.      * Method to complete the password reset process.
  151.      *
  152.      * @since   1.6
  153.      */
  154.     public function complete()
  155.     {
  156.         // Check for request forgeries
  157.         JSession::checkToken('post'or jexit(JText::_('JINVALID_TOKEN'));
  158.  
  159.         $app   JFactory::getApplication();
  160.         $model $this->getModel('Reset''UsersModel');
  161.         $data  $this->input->post->get('jform'array()'array');
  162.  
  163.         // Complete the password reset request.
  164.         $return    $model->processResetComplete($data);
  165.  
  166.         // Check for a hard error.
  167.         if ($return instanceof Exception)
  168.         {
  169.             // Get the error message to display.
  170.             if ($app->getCfg('error_reporting'))
  171.             {
  172.                 $message $return->getMessage();
  173.             else {
  174.                 $message JText::_('COM_USERS_RESET_COMPLETE_ERROR');
  175.             }
  176.  
  177.             // Get the route to the next page.
  178.             $itemid UsersHelperRoute::getResetRoute();
  179.             $itemid $itemid !== null '&Itemid='.$itemid '';
  180.             $route    'index.php?option=com_users&view=reset&layout=complete'.$itemid;
  181.  
  182.             // Go back to the complete form.
  183.             $this->setRedirect(JRoute::_($routefalse)$message'error');
  184.             return false;
  185.         elseif ($return === false)
  186.         {
  187.             // Complete failed.
  188.             // Get the route to the next page.
  189.             $itemid UsersHelperRoute::getResetRoute();
  190.             $itemid $itemid !== null '&Itemid='.$itemid '';
  191.             $route    'index.php?option=com_users&view=reset&layout=complete'.$itemid;
  192.  
  193.             // Go back to the complete form.
  194.             $message JText::sprintf('COM_USERS_RESET_COMPLETE_FAILED'$model->getError());
  195.             $this->setRedirect(JRoute::_($routefalse)$message'notice');
  196.             return false;
  197.         }
  198.         else
  199.         {
  200.             // Complete succeeded.
  201.             // Get the route to the next page.
  202.             $itemid UsersHelperRoute::getLoginRoute();
  203.             $itemid $itemid !== null '&Itemid='.$itemid '';
  204.             $route    'index.php?option=com_users&view=login'.$itemid;
  205.  
  206.             // Proceed to the login form.
  207.             $message JText::_('COM_USERS_RESET_COMPLETE_SUCCESS');
  208.             $this->setRedirect(JRoute::_($routefalse)$message);
  209.             return true;
  210.         }
  211.     }
  212. }

Documentation generated on Tue, 19 Nov 2013 15:11:53 +0100 by phpDocumentor 1.4.3