Index: masquerade.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/masquerade/masquerade.module,v retrieving revision 1.16.2.30 diff -u -r1.16.2.30 masquerade.module --- masquerade.module 30 Oct 2009 23:07:58 -0000 1.16.2.30 +++ masquerade.module 28 Mar 2010 03:38:50 -0000 @@ -32,16 +32,16 @@ * Implementation of hook_init(). */ function masquerade_init() { - global $user; - - // load from table uid + session id - $uid = db_result(db_query("SELECT uid_from FROM {masquerade} WHERE sid = '%s' AND uid_as = %d", session_id(), $user->uid)); - // using if so that we get unset rather than false if not masqing - if ($uid) { - $_SESSION['masquerading'] = $uid; - } - else { - $_SESSION['masquerading'] = null; + if (user_is_logged_in()) { + // load from table uid + session id + $uid = db_result(db_query("SELECT uid_from FROM {masquerade} WHERE sid = '%s' AND uid_as = %d", session_id(), $GLOBALS['user']->uid)); + // using if so that we get unset rather than false if not masqing + if ($uid) { + $_SESSION['masquerading'] = $uid; + } + else { + $_SESSION['masquerading'] = null; + } } }