english/components/com_users/controllers/registration.php
/**
	 * Method to activate a user.
	 *
	 * @return	boolean		True on success, false on failure.
	 * @since	1.6
	 */
Method to activate a user.
@return      boolean         True on success, false on failure.
Method to activate a user . @return boolean True on success false on failure .
public function activate()
	{
		$user		= JFactory::getUser();
		$uParams	= JComponentHelper::getParams('com_users');
		if ($user->get('id')) {
			$this->setRedirect('index.php');
			return true;
		}
		if ($uParams->get('useractivation') == 0 || $uParams->get('allowUserRegistration') == 0) {
			JError::raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
			return false;
		}
		$model = $this->getModel('Registration', 'UsersModel');
		$token = JRequest::getVar('token', null, 'request', 'alnum');
		if ($token === null || strlen($token) !== 32) {
			JError::raiseError(403, JText::_('JINVALID_TOKEN'));
			return false;
		}
		$return = $model->activate($token);
		if ($return === false) {
			$this->setMessage(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $model->getError()), 'warning');
			$this->setRedirect('index.php');
			return false;
		}
		$useractivation = $uParams->get('useractivation');
		if ($useractivation == 0)
		{
			$this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
			$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
		}
		else if ($useractivation == 1)
		{
			$this->setMessage(JText::_('COM_USERS_REGISTRATION_ACTIVATE_SUCCESS'));
			$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
		}
		else if ($return->getParam('activate'))
		{
			$this->setMessage(JText::_('COM_USERS_REGISTRATION_VERIFY_SUCCESS'));
			$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
		}
		else
		{
			$this->setMessage(JText::_('COM_USERS_REGISTRATION_ADMINACTIVATE_SUCCESS'));
			$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
		}
		return true;
	}
public function activate ( ) { $ user = JFactory :: getUser ( ) ; $ uParams = JComponentHelper :: getParams ( 'com_users' ) ; if ( $ user -> get ( 'id' ) ) { $ this -> setRedirect ( 'index.php' ) ; return true ; } if ( $ uParams -> get ( 'useractivation' ) == 0 || $ uParams -> get ( 'allowUserRegistration' ) == 0 ) { JError :: raiseError ( 403 , JText :: _ ( 'JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN' ) ) ; return false ; } $ model = $ this -> getModel ( 'Registration' , 'UsersModel' ) ; $ token = JRequest :: getVar ( 'token' , null , 'request' , 'alnum' ) ; if ( $ token === null || strlen ( $ token ) !== 32 ) { JError :: raiseError ( 403 , JText :: _ ( 'JINVALID_TOKEN' ) ) ; return false ; } $ return = $ model -> activate ( $ token ) ; if ( $ return === false ) { $ this -> setMessage ( JText :: sprintf ( 'COM_USERS_REGISTRATION_SAVE_FAILED' , $ model -> getError ( ) ) , 'warning' ) ; $ this -> setRedirect ( 'index.php' ) ; return false ; } $ useractivation = $ uParams -> get ( 'useractivation' ) ; if ( $ useractivation == 0 ) { $ this -> setMessage ( JText :: _ ( 'COM_USERS_REGISTRATION_SAVE_SUCCESS' ) ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=com_users&view=login' , false ) ) ; } else if ( $ useractivation == 1 ) { $ this -> setMessage ( JText :: _ ( 'COM_USERS_REGISTRATION_ACTIVATE_SUCCESS' ) ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=com_users&view=login' , false ) ) ; } else if ( $ return -> getParam ( 'activate' ) ) { $ this -> setMessage ( JText :: _ ( 'COM_USERS_REGISTRATION_VERIFY_SUCCESS' ) ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=com_users&view=registration&layout=complete' , false ) ) ; } else { $ this -> setMessage ( JText :: _ ( 'COM_USERS_REGISTRATION_ADMINACTIVATE_SUCCESS' ) ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=com_users&view=registration&layout=complete' , false ) ) ; } return true ; }
Method to activate a user.
Method to activate a user .
// If the user is logged in, return them back to the homepage. // If user registration or account activation is disabled, throw a 403. // Check that the token is in a valid format. // Attempt to activate the user. // Check for errors. // Redirect back to the homepage. // Redirect to the login screen.