Source for file users.php

Documentation is available at users.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 list controller class.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * @var    string  The prefix to use with controller messages.
  22.      * @since  1.6
  23.      */
  24.     protected $text_prefix = 'COM_USERS_USERS';
  25.  
  26.     /**
  27.      * Constructor.
  28.      *
  29.      * @param   array  $config  An optional associative array of configuration settings.
  30.      *
  31.      * @return  UsersControllerUsers 
  32.      *
  33.      * @since   1.6
  34.      * @see     JController
  35.      */
  36.     public function __construct($config array())
  37.     {
  38.         parent::__construct($config);
  39.  
  40.         $this->registerTask('block''changeBlock');
  41.         $this->registerTask('unblock''changeBlock');
  42.     }
  43.  
  44.     /**
  45.      * Proxy for getModel.
  46.      *
  47.      * @param   string  $name    The model name. Optional.
  48.      * @param   string  $prefix  The class prefix. Optional.
  49.      * @param   array   $config  Configuration array for model. Optional.
  50.      *
  51.      * @return  object  The model.
  52.      *
  53.      * @since   1.6
  54.      */
  55.     public function getModel($name 'User'$prefix 'UsersModel'$config array('ignore_request' => true))
  56.     {
  57.         return parent::getModel($name$prefix$config);
  58.     }
  59.  
  60.     /**
  61.      * Method to change the block status on a record.
  62.      *
  63.      * @return  void 
  64.      *
  65.      * @since   1.6
  66.      */
  67.     public function changeBlock()
  68.     {
  69.         // Check for request forgeries.
  70.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  71.  
  72.         $ids    $this->input->get('cid'array()'array');
  73.         $values array('block' => 1'unblock' => 0);
  74.         $task   $this->getTask();
  75.         $value  JArrayHelper::getValue($values$task0'int');
  76.  
  77.         if (empty($ids))
  78.         {
  79.             JError::raiseWarning(500JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
  80.         }
  81.         else
  82.         {
  83.             // Get the model.
  84.             $model $this->getModel();
  85.  
  86.             // Change the state of the records.
  87.             if (!$model->block($ids$value))
  88.             {
  89.                 JError::raiseWarning(500$model->getError());
  90.             }
  91.             else
  92.             {
  93.                 if ($value == 1)
  94.                 {
  95.                     $this->setMessage(JText::plural('COM_USERS_N_USERS_BLOCKED'count($ids)));
  96.                 }
  97.                 elseif ($value == 0)
  98.                 {
  99.                     $this->setMessage(JText::plural('COM_USERS_N_USERS_UNBLOCKED'count($ids)));
  100.                 }
  101.             }
  102.         }
  103.  
  104.         $this->setRedirect('index.php?option=com_users&view=users');
  105.     }
  106.  
  107.     /**
  108.      * Method to activate a record.
  109.      *
  110.      * @return  void 
  111.      *
  112.      * @since   1.6
  113.      */
  114.     public function activate()
  115.     {
  116.         // Check for request forgeries.
  117.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  118.  
  119.         $ids $this->input->get('cid'array()'array');
  120.  
  121.         if (empty($ids))
  122.         {
  123.             JError::raiseWarning(500JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
  124.         }
  125.         else
  126.         {
  127.             // Get the model.
  128.             $model $this->getModel();
  129.  
  130.             // Change the state of the records.
  131.             if (!$model->activate($ids))
  132.             {
  133.                 JError::raiseWarning(500$model->getError());
  134.             }
  135.             else
  136.             {
  137.                 $this->setMessage(JText::plural('COM_USERS_N_USERS_ACTIVATED'count($ids)));
  138.             }
  139.         }
  140.  
  141.         $this->setRedirect('index.php?option=com_users&view=users');
  142.     }
  143. }

Documentation generated on Tue, 19 Nov 2013 15:16:36 +0100 by phpDocumentor 1.4.3