function _masquerade_drush_get_user in Masquerade Extras 6.2
Same name and namespace in other branches
- 7.2 masquerade_drush/masquerade_drush.drush.inc \_masquerade_drush_get_user()
Retrieves a user account.
@retval stdClass
Parameters
string $account: The user ID, email address, or account name we want to load.
Return value
Loads the base user.
5 calls to _masquerade_drush_get_user()
- _masquerade_drush_list in masquerade_drush/
masquerade_drush.drush.inc - Displays a table of active masquerades in the site.
- _masquerade_drush_sessions in masquerade_drush/
masquerade_drush.drush.inc - Utility command to dump the active sessions table from the site.
- _masquerade_drush_sessions_terminate in masquerade_drush/
masquerade_drush.drush.inc - Ends a user's session.
- _masquerade_drush_start_masquerade in masquerade_drush/
masquerade_drush.drush.inc - Initializes a masquerade on the user's behalf. This is useful when developing and you want the user to start masquerading as soon as they login to the site.
- _masquerade_drush_terminate_masquerade in masquerade_drush/
masquerade_drush.drush.inc - Deletes active masquerades from the database. This is exceptionally useful when an active masquerade is causing a development problem and the user can't end the masquerade.
File
- masquerade_drush/
masquerade_drush.drush.inc, line 160 - Provides some drush commands for masquerade.
Code
function _masquerade_drush_get_user($account) {
// Don't trust user input, even on the command line.
$account_name = db_escape_string($account);
// Start writing a query to find the user.
$query_user = sprintf("SELECT uid\n FROM {users} AS u\n WHERE u.name='%s'\n OR u.mail='%s'", $account_name, $account_name);
// If the account passed to us was a user id...
if (is_int($account)) {
$query_user .= sprintf("OR u.uid='%d'", $account);
}
// Finally, we get to execute the query.
$query_user = db_query($query_user);
$user = db_fetch_object($query_user);
// If the user requested wasn't found, return FALSE.
if (empty($user->uid)) {
return FALSE;
}
// Finally, get the user requested!
return user_load($user->uid);
}