function drupal_valid_path
Checks a path exists and the current user has access to it.
Parameters
$path: The path to check.
$dynamic_allowed: Whether paths with menu wildcards (like user/%) should be allowed.
Return value
TRUE if it is a valid path AND the current user has access permission, FALSE otherwise.
4 calls to drupal_valid_path()
- form_process_autocomplete in includes/
form.inc  - Process function to prepare autocomplete data.
 - menu_edit_item_validate in modules/
menu/ menu.admin.inc  - Validate form values for a menu link being added or edited.
 - path_admin_form_validate in modules/
path/ path.admin.inc  - Form validation handler for path_admin_form().
 - system_site_information_settings_validate in modules/
system/ system.admin.inc  - Validates the submitted site-information form.
 
File
- 
              includes/
path.inc, line 558  
Code
function drupal_valid_path($path, $dynamic_allowed = FALSE) {
  global $menu_admin;
  // We indicate that a menu administrator is running the menu access check.
  $menu_admin = TRUE;
  if ($path == '<front>' || url_is_external($path)) {
    $item = array(
      'access' => TRUE,
    );
  }
  elseif ($dynamic_allowed && preg_match('/\\/\\%/', $path)) {
    // Path is dynamic (ie 'user/%'), so check directly against menu_router table.
    if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(
      ':path' => $path,
    ))->fetchAssoc()) {
      $item['link_path'] = $item['path'];
      $item['link_title'] = $item['title'];
      $item['external'] = FALSE;
      $item['options'] = '';
      _menu_link_translate($item);
    }
  }
  else {
    $item = menu_get_item($path);
  }
  $menu_admin = FALSE;
  return $item && $item['access'];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.