function _notify_switch_user in Notify 5.2
Same name and namespace in other branches
- 5 notify.module \_notify_switch_user()
- 6 notify.module \_notify_switch_user()
Switch from original user to mail submision user and back.
NOTE: Copied from mailhandler
Note: You first need to run _notify_switch_user without argument to store the current user. Call _notify_switch_user without argument to set the user back to the original user.
Parameters
$uid The user ID to switch to:
1 call to _notify_switch_user()
- _notify_send in ./notify.module 
- Helper function to send the notification email.
File
- ./notify.module, line 554 
Code
function _notify_switch_user($uid = NULL) {
  global $user;
  static $orig_user = array();
  if (isset($uid)) {
    $user = user_load(array(
      'uid' => $uid,
    ));
  }
  else {
    if (count($orig_user)) {
      $user = array_shift($orig_user);
      array_unshift($orig_user, $user);
    }
    else {
      $orig_user[] = $user;
    }
  }
}