Source for file registration.php
Documentation is available at registration.php
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
require_once JPATH_COMPONENT.
'/controller.php';
* Registration controller class for Users.
* Method to activate a user.
* @return boolean True on success, false on failure.
// If the user is logged in, return them back to the homepage.
// If user registration or account activation is disabled, throw a 403.
if ($uParams->get('useractivation') ==
0 ||
$uParams->get('allowUserRegistration') ==
0)
$model =
$this->getModel('Registration', 'UsersModel');
$token =
$input->getAlnum('token');
// Check that the token is in a valid format.
if ($token ===
null ||
strlen($token) !==
32)
// Attempt to activate the user.
$return =
$model->activate($token);
// Redirect back to the homepage.
$useractivation =
$uParams->get('useractivation');
// Redirect to the login screen.
if ($useractivation ==
0)
elseif ($useractivation ==
1)
elseif ($return->getParam('activate'))
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
* Method to register a user.
* @return boolean True on success, false on failure.
// Check for request forgeries.
// If registration is disabled - Redirect to login page.
if (JComponentHelper::getParams('com_users')->get('allowUserRegistration') ==
0)
$model =
$this->getModel('Registration', 'UsersModel');
$requestData =
$this->input->post->get('jform', array(), 'array');
// Validate the posted data.
$form =
$model->getForm();
$data =
$model->validate($form, $requestData);
// Check for validation errors.
// Get the validation messages.
$errors =
$model->getErrors();
// Push up to three validation messages out to the user.
for ($i =
0, $n =
count($errors); $i <
$n &&
$i <
3; $i++
)
if ($errors[$i] instanceof
Exception)
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
$app->enqueueMessage($errors[$i], 'warning');
// Save the data in the session.
$app->setUserState('com_users.registration.data', $requestData);
// Redirect back to the registration screen.
// Attempt to save the data.
$return =
$model->register($data);
// Save the data in the session.
$app->setUserState('com_users.registration.data', $data);
// Redirect back to the edit screen.
// Flush the data from the session.
$app->setUserState('com_users.registration.data', null);
// Redirect to the profile screen.
if ($return ===
'adminactivate'){
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
} elseif ($return ===
'useractivate')
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
Documentation generated on Tue, 19 Nov 2013 15:11:42 +0100 by phpDocumentor 1.4.3