english/administrator/components/com_users/models/user.php
/**
	 * Method to delete rows.
	 *
	 * @param	array	$pks	An array of item ids.
	 *
	 * @return	boolean	Returns true on success, false on failure.
	 * @since	1.6
	 */
Method to delete rows.
@param       array   $pks    An array of item ids.

@return      boolean Returns true on success, false on failure.
Method to delete rows . @param array $pks An array of item ids . @return boolean Returns true on success false on failure .
public function delete(&$pks)
	{
		$user	= JFactory::getUser();
		$table	= $this->getTable();
		$pks	= (array) $pks;
		$iAmSuperAdmin	= $user->authorise('core.admin');
		JPluginHelper::importPlugin('user');
		$dispatcher = JDispatcher::getInstance();
		if (in_array($user->id, $pks)) {
			$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_DELETE_SELF'));
			return false;
		}
		foreach ($pks as $i => $pk)
		{
			if ($table->load($pk)) {
				$allow = $user->authorise('core.delete', 'com_users');
				$allow = (!$iAmSuperAdmin && JAccess::check($pk, 'core.admin')) ? false : $allow;
				if ($allow) {
					$user_to_delete = JFactory::getUser($pk);
					$dispatcher->trigger('onUserBeforeDelete', array($table->getProperties()));
					if (!$table->delete($pk)) {
						$this->setError($table->getError());
						return false;
					} else {
						$dispatcher->trigger('onUserAfterDelete', array($user_to_delete->getProperties(), true, $this->getError()));
					}
				}
				else {
					unset($pks[$i]);
					JError::raiseWarning(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
				}
			}
			else {
				$this->setError($table->getError());
				return false;
			}
		}
		return true;
	}
public function delete ( & $ pks ) { $ user = JFactory :: getUser ( ) ; $ table = $ this -> getTable ( ) ; $ pks = ( array ) $ pks ; $ iAmSuperAdmin = $ user -> authorise ( 'core.admin' ) ; JPluginHelper :: importPlugin ( 'user' ) ; $ dispatcher = JDispatcher :: getInstance ( ) ; if ( in_array ( $ user -> id , $ pks ) ) { $ this -> setError ( JText :: _ ( 'COM_USERS_USERS_ERROR_CANNOT_DELETE_SELF' ) ) ; return false ; } foreach ( $ pks as $ i => $ pk ) { if ( $ table -> load ( $ pk ) ) { $ allow = $ user -> authorise ( 'core.delete' , 'com_users' ) ; $ allow = ( ! $ iAmSuperAdmin && JAccess :: check ( $ pk , 'core.admin' ) ) ? false : $ allow ; if ( $ allow ) { $ user_to_delete = JFactory :: getUser ( $ pk ) ; $ dispatcher -> trigger ( 'onUserBeforeDelete' , array ( $ table -> getProperties ( ) ) ) ; if ( ! $ table -> delete ( $ pk ) ) { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } else { $ dispatcher -> trigger ( 'onUserAfterDelete' , array ( $ user_to_delete -> getProperties ( ) , true , $ this -> getError ( ) ) ) ; } } else { unset ( $ pks [ $ i ] ) ; JError :: raiseWarning ( 403 , JText :: _ ( 'JERROR_CORE_DELETE_NOT_PERMITTED' ) ) ; } } else { $ this -> setError ( $ table -> getError ( ) ) ; return false ; } } return true ; }
Method to delete rows.
Method to delete rows .
// Initialise variables. // Check if I am a Super Admin // Trigger the onUserBeforeSave event. // Iterate the items to delete each one. // Access checks. // Don't allow non-super-admin to delete a super admin // Get users data for the users to delete. // Fire the onUserBeforeDelete event. // Trigger the onUserAfterDelete event. // Prune items that you can't change.