function _me_check_path in me aliases 6
Same name and namespace in other branches
- 8 me.module \_me_check_path()
- 6.2 me.module \_me_check_path()
- 7 me.module \_me_check_path()
Helper function to check if a path can be rewritten or not.
By this stage, the path is already rewritten, so we need to reverse the process.
Parameters
&$link: The link object to check.
2 calls to _me_check_path()
- me_preprocess_menu_item_link in ./
me.module - Implementaiton of moduleName_preprocess_hook() for theme_menu_item_link.
- me_theme_menu_item_link in ./
me.module - Implementation of theme_menu_item_link().
File
- ./
me.module, line 84 - Provides 'me' aliases to allow users to enter 'me' in common paths instead of their user id.
Code
function _me_check_path(&$link) {
// If the link has been rewritten, and we are not supposed to be handling this
// path, then rewite it back to its original.
if (me_variable_get('me_rewrite_link') && !_me_handle_path($link['href'])) {
$path_parts = explode('/', $link['href'], MENU_MAX_PARTS);
// The wildcarded path will either be in $link['path'], or $link['router_path'].
$wild_parts = explode('/', isset($link['path']) ? $link['path'] : $link['router_path'], MENU_MAX_PARTS);
// Go over each of the path parts and if one is equal to the me alias, make sure it is a wildcard,
// and if so, switch it back out.
while (list($key, $val) = each($path_parts)) {
if (_me_is_alias($val) && $wild_parts[$key] == '%') {
$path_parts[$key] = $GLOBALS['user']->uid;
}
}
$link['href'] = implode('/', $path_parts);
}
}