| 1 |
<?php |
<?php |
| 2 |
// $Id: drupalvb.module,v 1.33 2008/10/18 17:09:35 sun Exp $ |
// $Id: drupalvb.module,v 1.34 2009/02/01 02:00:25 sun Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 472 |
function drupalvb_login() { |
function drupalvb_login() { |
| 473 |
global $user; |
global $user; |
| 474 |
|
|
| 475 |
if ($_REQUEST['name']) { |
if ($_POST['name']) { |
| 476 |
|
$form_state = array('values' => $_POST); |
| 477 |
if ($user->uid) { |
if ($user->uid) { |
| 478 |
// If the user is already logged in to Drupal, we ensure the same for |
// If the user is already logged in to Drupal, we ensure the same for |
| 479 |
// vBulletin. |
// vBulletin. |
| 480 |
if (drupalvb_auth($_REQUEST['name'], trim($_REQUEST['pass']))) { |
if (drupalvb_login_validate(array(), $form_state)) { |
| 481 |
drupal_goto(!empty($_REQUEST['destination']) ? $_REQUEST['destination'] : 'user/'. $user->uid); |
drupal_goto(!empty($_REQUEST['destination']) ? $_REQUEST['destination'] : 'user/'. $user->uid); |
| 482 |
} |
} |
| 483 |
else { |
else { |
| 489 |
} |
} |
| 490 |
else { |
else { |
| 491 |
// Otherwise perform the full login procedure. |
// Otherwise perform the full login procedure. |
| 492 |
user_login_validate($_REQUEST['form_id'], $_REQUEST); |
foreach (user_login_default_validators() as $validator) { |
| 493 |
|
$validator(array(), $form_state); |
| 494 |
|
} |
| 495 |
if (!form_get_errors()) { |
if (!form_get_errors()) { |
| 496 |
$redirect = user_login_submit($_REQUEST['form_id'], $_REQUEST); |
user_login_submit(array(), $form_state); |
| 497 |
|
$redirect = (isset($form_state['redirect']) ? $form_state['redirect'] : ''); |
| 498 |
drupal_goto(!empty($_REQUEST['destination']) ? $_REQUEST['destination'] : $redirect); |
drupal_goto(!empty($_REQUEST['destination']) ? $_REQUEST['destination'] : $redirect); |
| 499 |
} |
} |
| 500 |
else { |
else { |
| 1031 |
// Register this user in Drupal using a temporary password, since we don't |
// Register this user in Drupal using a temporary password, since we don't |
| 1032 |
// know the real one. It will be updated when the user logs in to Drupal |
// know the real one. It will be updated when the user logs in to Drupal |
| 1033 |
// for the first time using its vBulletin credentials. |
// for the first time using its vBulletin credentials. |
| 1034 |
// @see drupalvb_auth() |
// @see drupalvb_login_validate() |
| 1035 |
$userinfo = array( |
$userinfo = array( |
| 1036 |
'name' => $vbuser['username'], |
'name' => $vbuser['username'], |
| 1037 |
'pass' => user_password(), |
'pass' => user_password(), |