function bakery_register_return in Bakery Single Sign-On System 7.2
Same name and namespace in other branches
- 6.2 bakery.module \bakery_register_return()
- 7.3 bakery.module \bakery_register_return()
Custom return for slave registration process.
Redirects to the homepage on success or to the register page if there was a problem.
1 string reference to 'bakery_register_return'
- bakery_menu in ./
bakery.module - Implements hook_menu().
File
- ./
bakery.module, line 788 - Module file for the Bakery.
Code
function bakery_register_return() {
$cookie = bakery_taste_oatmeal_cookie();
if ($cookie) {
// Valid cookie, now destroy it.
_bakery_eat_cookie('OATMEAL');
// Destination in cookie was set before user left this site, extract it to
// be sure destination workflow is followed.
if (empty($cookie['data']['destination'])) {
$destination = '<front>';
}
else {
$destination = $cookie['data']['destination'];
}
$errors = $cookie['data']['errors'];
if (empty($errors)) {
drupal_set_message(t('Registration successful. You are now logged in.'));
// Redirect to destination.
drupal_goto($destination);
}
else {
if (!empty($errors['register'])) {
drupal_set_message(t('Registration is not enabled on @master. Please contact a site administrator.', array(
'@master' => variable_get('bakery_master', 'http://drupal.org/'),
)), 'error');
watchdog('bakery', 'Master Bakery site user registration is disabled', array(), WATCHDOG_ERROR);
}
if (!empty($errors['validate'])) {
// If the user must validate their email then we need to create an
// account for them on the slave site.
$new = array(
'name' => $cookie['name'],
'mail' => $cookie['data']['mail'],
'init' => _bakery_init_field($cookie['data']['uid']),
'status' => 1,
'pass' => user_password(),
);
$account = user_save(new stdClass(), $new);
// Notify the user that they need to validate their email.
_user_mail_notify('register_no_approval_required', $account);
unset($_SESSION['bakery']['register']);
drupal_set_message(t('A welcome message with further instructions has been sent to your e-mail address.'));
}
if (!empty($errors['name'])) {
drupal_set_message(t('Name is already taken.'), 'error');
}
if (!empty($errors['mail'])) {
drupal_set_message(t('E-mail address is already registered.'), 'error');
}
if (!empty($errors['mail_denied'])) {
drupal_set_message(t('The e-mail address has been denied access..'), 'error');
}
if (!empty($errors['name_denied'])) {
drupal_set_message(t('The name has been denied access..'), 'error');
}
// There are errors so keep user on registration page.
drupal_goto('user/register');
}
}
drupal_access_denied();
}