function _me_load_arguments in me aliases 8
Same name and namespace in other branches
- 6.2 me.module \_me_load_arguments()
- 6 me.module \_me_load_arguments()
- 7 me.module \_me_load_arguments()
Helper function to set up arguments in meun _load callbacks.
3 calls to _me_load_arguments()
- me_category_load in ./
me.module - Menu load callback in place of user_category_load().
- me_load in ./
me.module - Menu load callback in place of user_load().
- me_uid_optional_load in ./
me.module - Menu load callback in place of user_uid_optional_load().
File
- ./
me.module, line 338 - Provides 'me' aliases to allow users to enter 'me' in common paths instead of their user id.
Code
function _me_load_arguments($uid, &$map = NULL, $index = NULL, $map_index = FALSE, $args = array(), $function = 'user_load', $reset = FALSE) {
global $user;
static $cache = array();
if ($reset) {
$cache = array();
}
// We need to get all the arguments, remove our custom ones,
// put %map in the right place, then call the menu load callack.
array_splice($args, 0, min(4, count($args)));
if (!is_null($map) && FALSE !== $map_index) {
$insert = array(
&$map,
);
array_splice($args, $map_index, 0, $insert);
$map[$index] = _me_check_arg($uid);
}
array_unshift($args, _me_check_arg($uid));
// If we have a valid function to call, call it.
$result = FALSE;
if (function_exists($function)) {
if ($function == 'user_load' || $function == 'user_category_load') {
if (!isset($cache[$function][$args[0]])) {
// Call user_load and store in cache:
$cache[$function][$args[0]] = call_user_func_array($function, $args);
}
// Use cached user's object:
$result = $cache[$function][$args[0]];
}
else {
$result = call_user_func_array($function, $args);
}
}
return $result;
}