english/administrator/components/com_users/models/user.php
/**
	 * Method to block user records.
	 *
	 * @param	array	$pks	The ids of the items to publish.
	 * @param	int		$value	The value of the published state
	 *
	 * @return	boolean	True on success.
	 * @since	1.6
	 */
Method to block user records.
@param       array   $pks    The ids of the items to publish.
@param       int             $value  The value of the published state

@return      boolean True on success.
Method to block user records . @param array $pks The ids of the items to publish . @param int $value The value of the published state @return boolean True on success .
function block(&$pks, $value = 1)
	{
		$app		= JFactory::getApplication();
		$dispatcher	= JDispatcher::getInstance();
		$user		= JFactory::getUser();
		$iAmSuperAdmin	= $user->authorise('core.admin');
		$table		= $this->getTable();
		$pks		= (array) $pks;
		JPluginHelper::importPlugin('user');
		foreach ($pks as $i => $pk)
		{
			if ($value == 1 && $pk == $user->get('id')) {
				unset($pks[$i]);
				JError::raiseWarning(403, JText::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
			}
			else if ($table->load($pk)) {
				$old	= $table->getProperties();
				$allow	= $user->authorise('core.edit.state', 'com_users');
				$allow = (!$iAmSuperAdmin && JAccess::check($pk, 'core.admin')) ? false : $allow;
				$options = array(
					'clientid' => array(0, 1)
				);
				if ($allow) {
					if ($table->block == $value) {
						unset($pks[$i]);
						continue;
					}
					$table->block = (int) $value;
					try
					{
						if (!$table->check()) {
							$this->setError($table->getError());
							return false;
						}
						$result = $dispatcher->trigger('onUserBeforeSave', array($old, false, $table->getProperties()));
						if (in_array(false, $result, true)) {
							return false;
						}
						if (!$table->store()) {
							$this->setError($table->getError());
							return false;
						}
						$dispatcher->trigger('onUserAfterSave', array($table->getProperties(), false, true, null));
					}
					catch (Exception $e)
					{
						$this->setError($e->getMessage());
						return false;
					}
					if ($value) {
						$app->logout($table->id, $options);
					}
				}
				else {
					unset($pks[$i]);
					JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
				}
			}
		}
		return true;
	}
function block ( & $ pks , $ value = 1 ) { $ app = JFactory :: getApplication ( ) ; $ dispatcher = JDispatcher :: getInstance ( ) ; $ user = JFactory :: getUser ( ) ; $ iAmSuperAdmin = $ user -> authorise ( 'core.admin' ) ; $ table = $ this -> getTable ( ) ; $ pks = ( array ) $ pks ; JPluginHelper :: importPlugin ( 'user' ) ; foreach ( $ pks as $ i => $ pk ) { if ( $ value == 1 && $ pk == $ user -> get ( 'id' ) ) { unset ( $ pks [ $ i ] ) ; JError :: raiseWarning ( 403 , JText :: _ ( 'COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF' ) ) ; } else if ( $ table -> load ( $ pk ) ) { $ old = $ table -> getProperties ( ) ; $ allow = $ user -> authorise ( 'core.edit.state' , 'com_users' ) ; $ allow = ( ! $ iAmSuperAdmin && JAccess :: check ( $ pk , 'core.admin' ) ) ? false : $ allow ; $ options = array ( 'clientid' => array ( 0 , 1 ) ) ; if ( $ allow ) { if ( $ table -> block == $ value ) { unset ( $ pks [ $ i ] ) ; continue ; } $ table -> block = ( int ) $ value ; try { if ( ! $ table -> check ( ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } $ result = $ dispatcher -> trigger ( 'onUserBeforeSave' , array ( $ old , false , $ table -> getProperties ( ) ) ) ; if ( in_array ( false , $ result , true ) ) { return false ; } if ( ! $ table -> store ( ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } $ dispatcher -> trigger ( 'onUserAfterSave' , array ( $ table -> getProperties ( ) , false , true , null ) ) ; } catch ( Exception $ e ) { $ this -> setError ( $ e -> getMessage ( ) ) ; return false ; } if ( $ value ) { $ app -> logout ( $ table -> id , $ options ) ; } } else { unset ( $ pks [ $ i ] ) ; JError :: raiseWarning ( 403 , JText :: _ ( 'JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED' ) ) ; } } } return true ; }
Method to block user records.
Method to block user records .
// Initialise variables. // Check if I am a Super Admin // Access checks. // Cannot block yourself. // Don't allow non-super-admin to delete a super admin // Prepare the logout options. // Skip changing of same state // Allow an exception to be thrown. // Trigger the onUserBeforeSave event. // Plugin will have to raise it's own error or throw an exception. // Store the table. // Trigger the onAftereStoreUser event // Log the user out. // Prune items that you can't change.