function _me_check_arg in me aliases 6
Same name and namespace in other branches
- 8 me.module \_me_check_arg()
- 6.2 me.module \_me_check_arg()
- 7 me.module \_me_check_arg()
A Helper function to check for the 'me' alias.
Parameters
$arg: The argument to check.
$username: If TRUE, will return the username instead of the users id.
$redirect: When TRUE, anonymous users will be redirected if a path is available.
Return value
mixed The current user id if a match is found, or the given argument if no match.
2 calls to _me_check_arg()
- _me_load_arguments in ./
me.module - Helper function to set up arguments in meun _load callbacks.
- _me_views_set_argument in includes/
me.views.inc - Helper function to set the views user arguments we override.
File
- ./
me.module, line 430 - Provides 'me' aliases to allow users to enter 'me' in common paths instead of their user id.
Code
function _me_check_arg($arg, $username = FALSE, $redirect = TRUE) {
$return = _me_is_alias($arg) ? $username ? $GLOBALS['user']->name : $GLOBALS['user']->uid : $arg;
$redirect_path = me_variable_get('me_redirect_anonymous');
if ($redirect && $GLOBALS['user']->uid == 0 && !empty($redirect_path)) {
// Copied from menu_get_item(). We can't call that here as it might cause a recursion loop.
$original_map = arg(NULL, $_GET['q']);
$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
list($ancestors, $placeholders) = menu_get_ancestors($parts);
if (($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN (' . implode(',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1))) && $router_item['page_callback'] == 'me_handler') {
// Not unsetting the destination can cause evil redirect loops.
unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
drupal_goto($redirect_path);
}
}
return $return;
}