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

@return      boolean True on success.
Method to activate user records . @param array $pks The ids of the items to activate . @return boolean True on success .
function activate(&$pks)
	{
		$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 ($table->load($pk)) {
				$old	= $table->getProperties();
				$allow	= $user->authorise('core.edit.state', 'com_users');
				$allow = (!$iAmSuperAdmin && JAccess::check($pk, 'core.admin')) ? false : $allow;
				if (empty($table->activation)) {
					unset($pks[$i]);
				}
				else if ($allow) {
					$table->block		= 0;
					$table->activation	= '';
					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;
					}
				}
				else {
					unset($pks[$i]);
					JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
				}
			}
		}
		return true;
	}
function activate ( & $ pks ) { $ 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 ( $ table -> load ( $ pk ) ) { $ old = $ table -> getProperties ( ) ; $ allow = $ user -> authorise ( 'core.edit.state' , 'com_users' ) ; $ allow = ( ! $ iAmSuperAdmin && JAccess :: check ( $ pk , 'core.admin' ) ) ? false : $ allow ; if ( empty ( $ table -> activation ) ) { unset ( $ pks [ $ i ] ) ; } else if ( $ allow ) { $ table -> block = 0 ; $ table -> activation = '' ; 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 ; } } else { unset ( $ pks [ $ i ] ) ; JError :: raiseWarning ( 403 , JText :: _ ( 'JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED' ) ) ; } } } return true ; }
Method to activate user records.
Method to activate user records .
// Initialise variables. // Check if I am a Super Admin // Access checks. // Don't allow non-super-admin to delete a super admin // Ignore activated accounts. // 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. // Fire the onAftereStoreUser event // Prune items that you can't change.