Some of my scheduled task needs to run as the user who triggered them (not anonymous neither admin); so I thought of writing two actions: - One to impersonate a user, which will receive uid as an argument. - Another to undo the impersonate. All the called actions should be between them.
Anybody see any fault in this idea or the actions code? Thanks. function wu_action_impersonate($uid) { global $user; if (!array_key_exists('wu_action_impersonate', $_SESSION)) { $_SESSION['wu_action_impersonate'] = array(); } array_push($_SESSION['wu_action_impersonate'], $user); session_save_session(FALSE); $user = user_load($uid); user_load($uid); } function wu_action_unimpersonate() { global $user; if (array_key_exists('wu_action_impersonate', $_SESSION)) { if (!empty($_SESSION['wu_action_impersonate'])) { $user = array_pop($_SESSION['wu_action_impersonate']); } if (empty($_SESSION['wu_action_impersonate'])) { unset($_SESSION['wu_action_impersonate']); } } session_save_session(TRUE); } -- *Ser freak no és imprescindible per ser informàtic, però ajuda. *La vida no ha de ser feliç, ha de ser plena. *Abans d'imprimir aquest missatge, pensa en el medi ambient.