english/libraries/joomla/database/table/user.php
/**
	 * Validation and filtering
	 *
	 * @return  boolean  True is satisfactory
	 *
	 * @since   11.1
	 */
Validation and filtering
@return  boolean  True is satisfactory


Validation and filtering @return boolean True is satisfactory
function check()
	{
		jimport('joomla.mail.helper');
		if (trim($this->name) == '') {
			$this->setError(JText::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_YOUR_NAME'));
			return false;
		}
		if (trim($this->username) == '') {
			$this->setError(JText::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_A_USER_NAME'));
			return false;
		}
		if (preg_match( "#[<>\"'%;()&]#i", $this->username) || strlen(utf8_decode($this->username )) < 2) {
			$this->setError( JText::sprintf( 'JLIB_DATABASE_ERROR_VALID_AZ09', 2 ));
			return false;
		}
		if ((trim($this->email) == "") || ! JMailHelper::isEmailAddress($this->email)) {
			$this->setError(JText::_('JLIB_DATABASE_ERROR_VALID_MAIL'));
			return false;
		}
		if ($this->registerDate == null || $this->registerDate == $this->_db->getNullDate() ) {
			$this->registerDate = JFactory::getDate()->toMySQL();
		}
		$query = 'SELECT id'
		. ' FROM #__users '
		. ' WHERE username = ' . $this->_db->Quote($this->username)
		. ' AND id != '. (int) $this->id;
		;
		$this->_db->setQuery($query);
		$xid = intval($this->_db->loadResult());
		if ($xid && $xid != intval($this->id)) {
			$this->setError( JText::_('JLIB_DATABASE_ERROR_USERNAME_INUSE'));
			return false;
		}
		$query = 'SELECT id'
			. ' FROM #__users '
			. ' WHERE email = '. $this->_db->Quote($this->email)
			. ' AND id != '. (int) $this->id
			;
		$this->_db->setQuery($query);
		$xid = intval($this->_db->loadResult());
		if ($xid && $xid != intval($this->id)) {
			$this->setError(JText::_('JLIB_DATABASE_ERROR_EMAIL_INUSE'));
			return false;
		}
		$config		= JFactory::getConfig();
		$rootUser	= $config->get('root_user');
		if (!is_numeric($rootUser))
		{
			$query = $this->_db->getQuery(true);
			$query->select('id');
			$query->from('#__users');
			$query->where('username = '.$this->_db->quote($rootUser));
			$this->_db->setQuery($query);
			$xid = intval($this->_db->loadResult());
			if ($rootUser==$this->username && (!$xid || $xid && $xid != intval($this->id))  || $xid && $xid == intval($this->id) && $rootUser!=$this->username) {
				$this->setError( JText::_('JLIB_DATABASE_ERROR_USERNAME_CANNOT_CHANGE'));
				return false;
			}
		}
		return true;
	}
function check ( ) { jimport ( 'joomla.mail.helper' ) ; if ( trim ( $ this -> name ) == '' ) { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_PLEASE_ENTER_YOUR_NAME' ) ) ; return false ; } if ( trim ( $ this -> username ) == '' ) { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_PLEASE_ENTER_A_USER_NAME' ) ) ; return false ; } if ( preg_match ( " #[<> \" '%;()&]#i " , $ this -> username ) || strlen ( utf8_decode ( $ this -> username ) ) < 2 ) { $ this -> setError ( JText :: sprintf ( 'JLIB_DATABASE_ERROR_VALID_AZ09' , 2 ) ) ; return false ; } if ( ( trim ( $ this -> email ) == " " ) || ! JMailHelper :: isEmailAddress ( $ this -> email ) ) { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_VALID_MAIL' ) ) ; return false ; } if ( $ this -> registerDate == null || $ this -> registerDate == $ this -> _db -> getNullDate ( ) ) { $ this -> registerDate = JFactory :: getDate ( ) -> toMySQL ( ) ; } $ query = 'SELECT id' . ' FROM #__users ' . ' WHERE username = ' . $ this -> _db -> Quote ( $ this -> username ) . ' AND id != ' . ( int ) $ this -> id ; ; $ this -> _db -> setQuery ( $ query ) ; $ xid = intval ( $ this -> _db -> loadResult ( ) ) ; if ( $ xid && $ xid != intval ( $ this -> id ) ) { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_USERNAME_INUSE' ) ) ; return false ; } $ query = 'SELECT id' . ' FROM #__users ' . ' WHERE email = ' . $ this -> _db -> Quote ( $ this -> email ) . ' AND id != ' . ( int ) $ this -> id ; $ this -> _db -> setQuery ( $ query ) ; $ xid = intval ( $ this -> _db -> loadResult ( ) ) ; if ( $ xid && $ xid != intval ( $ this -> id ) ) { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_EMAIL_INUSE' ) ) ; return false ; } $ config = JFactory :: getConfig ( ) ; $ rootUser = $ config -> get ( 'root_user' ) ; if ( ! is_numeric ( $ rootUser ) ) { $ query = $ this -> _db -> getQuery ( true ) ; $ query -> select ( 'id' ) ; $ query -> from ( '#__users' ) ; $ query -> where ( 'username = ' . $ this -> _db -> quote ( $ rootUser ) ) ; $ this -> _db -> setQuery ( $ query ) ; $ xid = intval ( $ this -> _db -> loadResult ( ) ) ; if ( $ rootUser == $ this -> username && ( ! $ xid || $ xid && $ xid != intval ( $ this -> id ) ) || $ xid && $ xid == intval ( $ this -> id ) && $ rootUser != $ this -> username ) { $ this -> setError ( JText :: _ ( 'JLIB_DATABASE_ERROR_USERNAME_CANNOT_CHANGE' ) ) ; return false ; } } return true ; }
Validation and filtering
 @return  boolean  True is satisfactory
Validation and filtering @return boolean True is satisfactory
// Validate user information // Set the registration timestamp // check for existing username // check for existing email // check for root_user != username