function mailhandler_switch_user in Mailhandler 7
Same name and namespace in other branches
- 5 mailhandler.module \mailhandler_switch_user()
- 6 mailhandler.retrieve.inc \mailhandler_switch_user()
Switch from original user to mail submision user and back.
Note: You first need to run mailhandler_switch_user without argument to store the current user. Call mailhandler_switch_user without argument to set the user back to the original user.
Parameters
$uid The user ID to switch to:
1 call to mailhandler_switch_user()
File
- ./
mailhandler.retrieve.inc, line 289
Code
function mailhandler_switch_user($uid = NULL) {
global $user;
static $orig_user = array();
if (isset($uid)) {
session_save_session(FALSE);
$user = user_load(array(
'uid' => $uid,
));
}
else {
if (count($orig_user)) {
$user = array_shift($orig_user);
session_save_session(TRUE);
array_unshift($orig_user, $user);
}
else {
$orig_user[] = $user;
}
}
}