2007-09-10 13:14:38 +00:00
< ? php
// $Id$
/**
* @ file
* User page callback file for the user module .
*/
/**
2007-12-04 18:34:44 +00:00
* Menu callback ; Retrieve a JSON object containing autocomplete suggestions for existing users .
2007-09-10 13:14:38 +00:00
*/
function user_autocomplete ( $string = '' ) {
$matches = array ();
if ( $string ) {
2008-08-21 19:36:39 +00:00
$result = db_query_range ( " SELECT name FROM { users} WHERE LOWER(name) LIKE LOWER(:name) " , array ( ':name' => $string . '%' ), 0 , 10 );
2007-09-10 13:14:38 +00:00
while ( $user = db_fetch_object ( $result )) {
$matches [ $user -> name ] = check_plain ( $user -> name );
}
}
drupal_json ( $matches );
}
/**
* Form builder ; Request a password reset .
*
* @ ingroup forms
2008-01-08 10:35:43 +00:00
* @ see user_pass_validate ()
* @ see user_pass_submit ()
2007-09-10 13:14:38 +00:00
*/
function user_pass () {
$form [ 'name' ] = array (
'#type' => 'textfield' ,
'#title' => t ( 'Username or e-mail address' ),
'#size' => 60 ,
'#maxlength' => max ( USERNAME_MAX_LENGTH , EMAIL_MAX_LENGTH ),
'#required' => TRUE ,
);
$form [ 'submit' ] = array ( '#type' => 'submit' , '#value' => t ( 'E-mail new password' ));
return $form ;
}
function user_pass_validate ( $form , & $form_state ) {
$name = trim ( $form_state [ 'values' ][ 'name' ]);
2008-01-02 12:57:37 +00:00
// Try to load by email.
$account = user_load ( array ( 'mail' => $name , 'status' => 1 ));
if ( ! $account ) {
// No success, try to load by name.
2007-09-10 13:14:38 +00:00
$account = user_load ( array ( 'name' => $name , 'status' => 1 ));
}
if ( isset ( $account -> uid )) {
form_set_value ( array ( '#parents' => array ( 'account' )), $account , $form_state );
}
else {
form_set_error ( 'name' , t ( 'Sorry, %name is not recognized as a user name or an e-mail address.' , array ( '%name' => $name )));
}
}
function user_pass_submit ( $form , & $form_state ) {
global $language ;
$account = $form_state [ 'values' ][ 'account' ];
// Mail one time login URL and instructions using current language.
_user_mail_notify ( 'password_reset' , $account , $language );
watchdog ( 'user' , 'Password reset instructions mailed to %name at %email.' , array ( '%name' => $account -> name , '%email' => $account -> mail ));
drupal_set_message ( t ( 'Further instructions have been sent to your e-mail address.' ));
$form_state [ 'redirect' ] = 'user' ;
return ;
}
/**
* Menu callback ; process one time login link and redirects to the user page on success .
*/
function user_pass_reset ( & $form_state , $uid , $timestamp , $hashed_pass , $action = NULL ) {
global $user ;
// Check if the user is already logged in. The back button is often the culprit here.
if ( $user -> uid ) {
drupal_set_message ( t ( 'You have already used this one-time login link. It is not necessary to use this link to login anymore. You are already logged in.' ));
drupal_goto ();
}
else {
// Time out, in seconds, until login URL expires. 24 hours = 86400 seconds.
$timeout = 86400 ;
2008-09-17 07:11:59 +00:00
$current = REQUEST_TIME ;
2007-09-10 13:14:38 +00:00
// Some redundant checks for extra security ?
if ( $timestamp < $current && $account = user_load ( array ( 'uid' => $uid , 'status' => 1 )) ) {
// No time out for first time login.
if ( $account -> login && $current - $timestamp > $timeout ) {
drupal_set_message ( t ( 'You have tried to use a one-time login link that has expired. Please request a new one using the form below.' ));
drupal_goto ( 'user/password' );
}
2008-10-12 04:30:09 +00:00
elseif ( $account -> uid && $timestamp > $account -> login && $timestamp < $current && $hashed_pass == user_pass_rehash ( $account -> pass , $timestamp , $account -> login )) {
2007-09-10 13:14:38 +00:00
// First stage is a confirmation form, then login
if ( $action == 'login' ) {
watchdog ( 'user' , 'User %name used one-time login link at time %timestamp.' , array ( '%name' => $account -> name , '%timestamp' => $timestamp ));
2007-12-13 12:53:47 +00:00
// Set the new user.
2007-09-10 13:14:38 +00:00
$user = $account ;
2007-12-13 12:53:47 +00:00
// user_authenticate_finalize() also updates the login timestamp of the
// user, which invalidates further use of the one-time login link.
user_authenticate_finalize ( $form_state [ 'values' ]);
2007-09-10 13:14:38 +00:00
drupal_set_message ( t ( 'You have just used your one-time login link. It is no longer necessary to use this link to login. Please change your password.' ));
2008-04-14 17:48:46 +00:00
drupal_goto ( 'user/' . $user -> uid . '/edit' );
2007-09-10 13:14:38 +00:00
}
else {
2008-07-16 21:59:29 +00:00
$form [ 'message' ] = array ( '#markup' => t ( '<p>This is a one-time login for %user_name and will expire on %expiration_date.</p><p>Click on this button to login to the site and change your password.</p>' , array ( '%user_name' => $account -> name , '%expiration_date' => format_date ( $timestamp + $timeout ))));
$form [ 'help' ] = array ( '#markup' => '<p>' . t ( 'This login can be used only once.' ) . '</p>' );
2007-09-10 13:14:38 +00:00
$form [ 'submit' ] = array ( '#type' => 'submit' , '#value' => t ( 'Log in' ));
$form [ '#action' ] = url ( " user/reset/ $uid / $timestamp / $hashed_pass /login " );
return $form ;
}
}
else {
drupal_set_message ( t ( 'You have tried to use a one-time login link which has either been used or is no longer valid. Please request a new one using the form below.' ));
drupal_goto ( 'user/password' );
}
}
else {
// Deny access, no more clues.
// Everything will be in the watchdog's URL for the administrator to check.
drupal_access_denied ();
}
}
}
/**
* Menu callback ; logs the current user out , and redirects to the home page .
*/
function user_logout () {
global $user ;
watchdog ( 'user' , 'Session closed for %name.' , array ( '%name' => $user -> name ));
// Destroy the current session:
session_destroy ();
2008-10-06 11:30:12 +00:00
module_invoke_all ( 'user_logout' , NULL , $user );
2007-09-10 13:14:38 +00:00
// Load the anonymous user
$user = drupal_anonymous_user ();
drupal_goto ();
}
/**
* Menu callback ; Displays a user or user profile page .
*/
function user_view ( $account ) {
2008-10-13 00:33:05 +00:00
drupal_set_title ( $account -> name );
2007-09-10 13:14:38 +00:00
// Retrieve all profile fields and attach to $account->content.
user_build_content ( $account );
2007-12-31 08:54:37 +00:00
// To theme user profiles, copy modules/user/user_profile.tpl.php
// to your theme directory, and edit it as instructed in that file's comments.
2007-09-10 13:14:38 +00:00
return theme ( 'user_profile' , $account );
}
/**
* Process variables for user - profile . tpl . php .
*
* The $variables array contains the following arguments :
* - $account
*
* @ see user - picture . tpl . php
*/
function template_preprocess_user_profile ( & $variables ) {
$variables [ 'profile' ] = array ();
2007-10-25 10:30:40 +00:00
// Sort sections by weight
uasort ( $variables [ 'account' ] -> content , 'element_sort' );
2008-12-30 16:43:20 +00:00
// Provide keyed variables so themers can print each section independently.
2007-09-10 13:14:38 +00:00
foreach ( element_children ( $variables [ 'account' ] -> content ) as $key ) {
$variables [ 'profile' ][ $key ] = drupal_render ( $variables [ 'account' ] -> content [ $key ]);
}
// Collect all profiles to make it easier to print all items at once.
$variables [ 'user_profile' ] = implode ( $variables [ 'profile' ]);
}
/**
* Process variables for user - profile - item . tpl . php .
*
* The $variables array contains the following arguments :
* - $element
*
* @ see user - profile - item . tpl . php
*/
function template_preprocess_user_profile_item ( & $variables ) {
$variables [ 'title' ] = $variables [ 'element' ][ '#title' ];
2008-07-16 21:59:29 +00:00
$variables [ 'value' ] = $variables [ 'element' ][ '#markup' ];
2007-09-10 13:14:38 +00:00
$variables [ 'attributes' ] = '' ;
if ( isset ( $variables [ 'element' ][ '#attributes' ])) {
$variables [ 'attributes' ] = drupal_attributes ( $variables [ 'element' ][ '#attributes' ]);
}
}
/**
* Process variables for user - profile - category . tpl . php .
*
* The $variables array contains the following arguments :
* - $element
*
* @ see user - profile - category . tpl . php
*/
function template_preprocess_user_profile_category ( & $variables ) {
2007-11-28 10:29:21 +00:00
$variables [ 'title' ] = check_plain ( $variables [ 'element' ][ '#title' ]);
2007-09-10 13:14:38 +00:00
$variables [ 'profile_items' ] = $variables [ 'element' ][ '#children' ];
$variables [ 'attributes' ] = '' ;
if ( isset ( $variables [ 'element' ][ '#attributes' ])) {
$variables [ 'attributes' ] = drupal_attributes ( $variables [ 'element' ][ '#attributes' ]);
}
}
/**
* Form builder ; Present the form to edit a given user or profile category .
*
* @ ingroup forms
2008-01-08 10:35:43 +00:00
* @ see user_edit_validate ()
* @ see user_edit_submit ()
2007-09-10 13:14:38 +00:00
*/
function user_edit ( $account , $category = 'account' ) {
2008-10-13 00:33:05 +00:00
drupal_set_title ( $account -> name );
2007-09-10 13:14:38 +00:00
return drupal_get_form ( 'user_profile_form' , $account , $category );
}
/**
* Form builder ; edit a user account or one of their profile categories .
*
* @ ingroup forms
* @ see user_profile_form_validate ()
2008-01-08 10:35:43 +00:00
* @ see user_profile_form_submit ()
2009-01-08 08:42:13 +00:00
* @ see user_cancel_confirm_form_submit ()
2007-09-10 13:14:38 +00:00
*/
function user_profile_form ( $form_state , $account , $category = 'account' ) {
2009-01-08 08:42:13 +00:00
global $user ;
2007-09-10 13:14:38 +00:00
$edit = ( empty ( $form_state [ 'values' ])) ? ( array ) $account : $form_state [ 'values' ];
$form = _user_forms ( $edit , $account , $category );
$form [ '_category' ] = array ( '#type' => 'value' , '#value' => $category );
$form [ '_account' ] = array ( '#type' => 'value' , '#value' => $account );
$form [ 'submit' ] = array ( '#type' => 'submit' , '#value' => t ( 'Save' ), '#weight' => 30 );
2009-01-08 08:42:13 +00:00
if (( $account -> uid == $user -> uid && user_access ( 'cancel account' )) || user_access ( 'administer users' )) {
$form [ 'cancel' ] = array (
2007-09-10 13:14:38 +00:00
'#type' => 'submit' ,
2009-01-08 08:42:13 +00:00
'#value' => t ( 'Cancel account' ),
2007-09-10 13:14:38 +00:00
'#weight' => 31 ,
2009-01-08 08:42:13 +00:00
'#submit' => array ( 'user_edit_cancel_submit' ),
2007-09-10 13:14:38 +00:00
);
}
2008-11-24 00:40:45 +00:00
$form [ '#attributes' ][ 'enctype' ] = 'multipart/form-data' ;
2007-09-10 13:14:38 +00:00
return $form ;
}
/**
* Validation function for the user account and profile editing form .
*/
function user_profile_form_validate ( $form , & $form_state ) {
user_module_invoke ( 'validate' , $form_state [ 'values' ], $form_state [ 'values' ][ '_account' ], $form_state [ 'values' ][ '_category' ]);
// Validate input to ensure that non-privileged users can't alter protected data.
2007-12-17 17:06:16 +00:00
if (( ! user_access ( 'administer users' ) && array_intersect ( array_keys ( $form_state [ 'values' ]), array ( 'uid' , 'init' , 'session' ))) || ( ! user_access ( 'administer permissions' ) && isset ( $form_state [ 'values' ][ 'roles' ]))) {
2007-09-10 13:14:38 +00:00
watchdog ( 'security' , 'Detected malicious attempt to alter protected user fields.' , array (), WATCHDOG_WARNING );
// set this to a value type field
form_set_error ( 'category' , t ( 'Detected malicious attempt to alter protected user fields.' ));
}
}
/**
* Submit function for the user account and profile editing form .
*/
function user_profile_form_submit ( $form , & $form_state ) {
$account = $form_state [ 'values' ][ '_account' ];
$category = $form_state [ 'values' ][ '_category' ];
2009-01-08 08:42:13 +00:00
unset ( $form_state [ 'values' ][ '_account' ], $form_state [ 'values' ][ 'op' ], $form_state [ 'values' ][ 'submit' ], $form_state [ 'values' ][ 'cancel' ], $form_state [ 'values' ][ 'form_token' ], $form_state [ 'values' ][ 'form_id' ], $form_state [ 'values' ][ '_category' ], $form_state [ 'values' ][ 'form_build_id' ]);
2007-09-10 13:14:38 +00:00
user_module_invoke ( 'submit' , $form_state [ 'values' ], $account , $category );
user_save ( $account , $form_state [ 'values' ], $category );
// Clear the page cache because pages can contain usernames and/or profile information:
cache_clear_all ();
drupal_set_message ( t ( 'The changes have been saved.' ));
return ;
}
/**
2009-01-08 08:42:13 +00:00
* Submit function for the 'Cancel account' button on the user edit form .
2007-09-10 13:14:38 +00:00
*/
2009-01-08 08:42:13 +00:00
function user_edit_cancel_submit ( $form , & $form_state ) {
2007-09-10 13:14:38 +00:00
$destination = '' ;
if ( isset ( $_REQUEST [ 'destination' ])) {
$destination = drupal_get_destination ();
unset ( $_REQUEST [ 'destination' ]);
}
2009-01-08 08:42:13 +00:00
// Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear.
$form_state [ 'redirect' ] = array ( " user/ " . $form_state [ 'values' ][ '_account' ] -> uid . " /cancel " , $destination );
2007-09-10 13:14:38 +00:00
}
/**
2009-01-08 08:42:13 +00:00
* Form builder ; confirm form for cancelling user account .
2007-09-10 13:14:38 +00:00
*
* @ ingroup forms
2009-01-08 08:42:13 +00:00
* @ see user_edit_cancel_submit ()
2007-09-10 13:14:38 +00:00
*/
2009-01-08 08:42:13 +00:00
function user_cancel_confirm_form ( & $form_state , $account ) {
global $user ;
2007-09-10 13:14:38 +00:00
$form [ '_account' ] = array ( '#type' => 'value' , '#value' => $account );
2009-01-08 08:42:13 +00:00
// Display account cancellation method selection, if allowed.
$default_method = variable_get ( 'user_cancel_method' , 'user_cancel_block' );
$admin_access = user_access ( 'administer users' );
$can_select_method = $admin_access || user_access ( 'select account cancellation method' );
$form [ 'user_cancel_method' ] = array (
'#type' => 'item' ,
'#title' => ( $account -> uid == $user -> uid ? t ( 'When cancelling your account' ) : t ( 'When cancelling the account' )),
'#access' => $can_select_method ,
);
$form [ 'user_cancel_method' ] += user_cancel_methods ();
// Allow user administrators to skip the account cancellation confirmation
// mail (by default), as long as they do not attempt to cancel their own
// account.
$override_access = $admin_access && ( $account -> uid != $user -> uid );
$form [ 'user_cancel_confirm' ] = array (
'#type' => 'checkbox' ,
'#title' => t ( 'Require e-mail confirmation to cancel account.' ),
'#default_value' => ( $override_access ? FALSE : TRUE ),
'#access' => $override_access ,
'#description' => t ( 'When enabled, the user must confirm the account cancellation via e-mail.' ),
);
// Also allow to send account canceled notification mail, if enabled.
$default_notify = variable_get ( 'user_mail_status_canceled_notify' , FALSE );
$form [ 'user_cancel_notify' ] = array (
'#type' => 'checkbox' ,
'#title' => t ( 'Notify user when account is canceled.' ),
'#default_value' => ( $override_access ? FALSE : $default_notify ),
'#access' => $override_access && $default_notify ,
'#description' => t ( 'When enabled, the user will receive an e-mail notification after the account has been cancelled.' ),
);
// Prepare confirmation form page title and description.
if ( $account -> uid == $user -> uid ) {
$question = t ( 'Are you sure you want to cancel your account?' );
}
else {
$question = t ( 'Are you sure you want to cancel the account %name?' , array ( '%name' => $account -> name ));
}
$description = '' ;
if ( $can_select_method ) {
$description = t ( 'Select the method to cancel the account above.' );
foreach ( element_children ( $form [ 'user_cancel_method' ]) as $element ) {
unset ( $form [ 'user_cancel_method' ][ $element ][ '#description' ]);
}
}
else {
// The radio button #description is used as description for the confirmation
// form.
foreach ( element_children ( $form [ 'user_cancel_method' ]) as $element ) {
if ( $form [ 'user_cancel_method' ][ $element ][ '#default_value' ] == $form [ 'user_cancel_method' ][ $element ][ '#return_value' ]) {
$description = $form [ 'user_cancel_method' ][ $element ][ '#description' ];
}
unset ( $form [ 'user_cancel_method' ][ $element ][ '#description' ]);
}
}
2007-09-10 13:14:38 +00:00
return confirm_form ( $form ,
2009-01-08 08:42:13 +00:00
$question ,
2008-04-14 17:48:46 +00:00
'user/' . $account -> uid ,
2009-01-08 08:42:13 +00:00
$description . ' ' . t ( 'This action cannot be undone.' ),
t ( 'Cancel account' ), t ( 'Cancel' ));
}
/**
* Submit handler for the account cancellation confirm form .
*
* @ see user_cancel_confirm_form ()
* @ see user_multiple_cancel_confirm_submit ()
*/
function user_cancel_confirm_form_submit ( $form , & $form_state ) {
global $user ;
$account = $form_state [ 'values' ][ '_account' ];
// Cancel account immediately, if the current user has administrative
// privileges, no confirmation mail shall be sent, and the user does not
// attempt to cancel the own account.
if ( user_access ( 'administer users' ) && empty ( $form_state [ 'values' ][ 'user_cancel_confirm' ]) && $account -> uid != $user -> uid ) {
user_cancel ( $form_state [ 'values' ], $account -> uid , $form_state [ 'values' ][ 'user_cancel_method' ]);
if ( ! isset ( $_REQUEST [ 'destination' ])) {
$form_state [ 'redirect' ] = 'admin/user/user' ;
}
}
else {
// Store cancelling method and whether to notify the user in $account for
// user_cancel_confirm().
$edit = array (
'user_cancel_method' => $form_state [ 'values' ][ 'user_cancel_method' ],
'user_cancel_notify' => $form_state [ 'values' ][ 'user_cancel_notify' ],
);
$account = user_save ( $account , $edit );
_user_mail_notify ( 'cancel_confirm' , $account );
drupal_set_message ( t ( 'A confirmation request to cancel your account has been sent to your e-mail address.' ));
2009-01-22 04:43:32 +00:00
watchdog ( 'user' , 'Sent account cancellation request to %name %email.' , array ( '%name' => $account -> name , '%email' => '<' . $account -> mail . '>' ), WATCHDOG_NOTICE );
2009-01-08 08:42:13 +00:00
if ( ! isset ( $_REQUEST [ 'destination' ])) {
$form_state [ 'redirect' ] = " user/ $account->uid " ;
}
}
2007-09-10 13:14:38 +00:00
}
/**
2009-01-08 08:42:13 +00:00
* Helper function to return available account cancellation methods .
*
* Please refer to the documentation of hook_user_cancel_methods_alter () .
*
* @ return
* An array containing all account cancellation methods as form elements .
*
* @ see hook_user_cancel_methods_alter ()
* @ see user_admin_settings ()
* @ see user_cancel_confirm_form ()
* @ see user_multiple_cancel_confirm ()
2007-09-10 13:14:38 +00:00
*/
2009-01-08 08:42:13 +00:00
function user_cancel_methods () {
$methods = array (
'user_cancel_block' => array (
'title' => t ( 'Disable the account and keep all content.' ),
'description' => t ( 'Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your user name.' ),
),
'user_cancel_block_unpublish' => array (
'title' => t ( 'Disable the account and unpublish all content.' ),
'description' => t ( 'Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.' ),
),
'user_cancel_reassign' => array (
'title' => t ( 'Delete the account and make all content belong to the %anonymous-name user.' , array ( '%anonymous-name' => variable_get ( 'anonymous' , t ( 'Anonymous' )))),
'description' => t ( 'Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.' , array ( '%anonymous-name' => variable_get ( 'anonymous' , t ( 'Anonymous' )))),
),
'user_cancel_delete' => array (
'title' => t ( 'Delete the account and all content.' ),
'description' => t ( 'Your account will be removed and all account information deleted. All of your content will also be deleted.' ),
'access' => user_access ( 'administer users' ),
),
);
// Allow modules to customize account cancellation methods.
drupal_alter ( 'user_cancel_methods' , $methods );
// Turn all methods into real form elements.
$default_method = variable_get ( 'user_cancel_method' , 'user_cancel_block' );
$form = array ();
foreach ( $methods as $name => $method ) {
$form [ $name ] = array (
'#type' => 'radio' ,
'#title' => $method [ 'title' ],
'#description' => ( isset ( $method [ 'description' ]) ? $method [ 'description' ] : NULL ),
'#return_value' => $name ,
'#default_value' => $default_method ,
'#parents' => array ( 'user_cancel_method' ),
'#required' => TRUE ,
);
}
return $form ;
}
2007-10-27 14:01:12 +00:00
2009-01-08 08:42:13 +00:00
/**
* Menu callback ; Cancel a user account via e - mail confirmation link .
*
* @ see user_cancel_confirm_form ()
* @ see user_cancel_url ()
*/
function user_cancel_confirm ( $account , $timestamp = 0 , $hashed_pass = '' ) {
// Time out in seconds until cancel URL expires; 24 hours = 86400 seconds.
$timeout = 86400 ;
$current = REQUEST_TIME ;
// Basic validation of arguments.
if ( isset ( $account -> user_cancel_method ) && ! empty ( $timestamp ) && ! empty ( $hashed_pass )) {
// Validate expiration and hashed password/login.
if ( $timestamp <= $current && $current - $timestamp < $timeout && $account -> uid && $timestamp >= $account -> login && $hashed_pass == user_pass_rehash ( $account -> pass , $timestamp , $account -> login )) {
$edit = array (
'user_cancel_notify' => isset ( $account -> user_cancel_notify ) ? $account -> user_cancel_notify : variable_get ( 'user_mail_status_canceled_notify' , FALSE ),
);
user_cancel ( $edit , $account -> uid , $account -> user_cancel_method );
// Since user_cancel() is not invoked via Form API, batch processing needs
// to be invoked manually and should redirect to the front page after
// completion.
batch_process ( '' );
}
else {
drupal_set_message ( t ( 'You have tried to use an account cancellation link that has expired. Please request a new one using the form below.' ));
drupal_goto ( " user/ $account->uid /cancel " );
}
2007-09-10 13:14:38 +00:00
}
2009-01-08 08:42:13 +00:00
drupal_access_denied ();
2007-09-10 13:14:38 +00:00
}
function user_edit_validate ( $form , & $form_state ) {
user_module_invoke ( 'validate' , $form_state [ 'values' ], $form_state [ 'values' ][ '_account' ], $form_state [ 'values' ][ '_category' ]);
// Validate input to ensure that non-privileged users can't alter protected data.
2007-12-17 17:06:16 +00:00
if (( ! user_access ( 'administer users' ) && array_intersect ( array_keys ( $form_state [ 'values' ]), array ( 'uid' , 'init' , 'session' ))) || ( ! user_access ( 'administer permissions' ) && isset ( $form_state [ 'values' ][ 'roles' ]))) {
2007-09-10 13:14:38 +00:00
watchdog ( 'security' , 'Detected malicious attempt to alter protected user fields.' , array (), WATCHDOG_WARNING );
// set this to a value type field
form_set_error ( 'category' , t ( 'Detected malicious attempt to alter protected user fields.' ));
}
}
function user_edit_submit ( $form , & $form_state ) {
$account = $form_state [ 'values' ][ '_account' ];
$category = $form_state [ 'values' ][ '_category' ];
2009-01-08 08:42:13 +00:00
unset ( $form_state [ 'values' ][ '_account' ], $form_state [ 'values' ][ 'op' ], $form_state [ 'values' ][ 'submit' ], $form_state [ 'values' ][ 'cancel' ], $form_state [ 'values' ][ 'form_token' ], $form_state [ 'values' ][ 'form_id' ], $form_state [ 'values' ][ '_category' ], $form_state [ 'values' ][ 'form_build_id' ]);
2007-09-10 13:14:38 +00:00
user_module_invoke ( 'submit' , $form_state [ 'values' ], $account , $category );
user_save ( $account , $form_state [ 'values' ], $category );
// Clear the page cache because pages can contain usernames and/or profile information:
cache_clear_all ();
drupal_set_message ( t ( 'The changes have been saved.' ));
return ;
}
/**
* Access callback for path / user .
*
* Displays user profile if user is logged in , or login form for anonymous
* users .
*/
function user_page () {
global $user ;
if ( $user -> uid ) {
2008-04-14 17:48:46 +00:00
menu_set_active_item ( 'user/' . $user -> uid );
2007-09-10 13:14:38 +00:00
return menu_execute_active_handler ();
}
else {
return drupal_get_form ( 'user_login' );
}
}