0); if (isset($valid_callbacks[$callback]['dependencies']) && is_array($valid_callbacks[$callback]['dependencies'])) { foreach ($valid_callbacks[$callback]['dependencies'] as $dependency) { if (!drupal_load('module', $dependency)) { // Do a boot up till SESSION to be sure the drupal_set_message() // function works. drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // Create an error message with information for the user to be able // to fix the dependency. $error = t( 'The dependency :dependency for the callback :callback in :module is not installed.', array( ':dependency' => $dependency, ':callback' => $callback, ':module' => $module, ) ); // Let the user know what's wrong and throw an exception to stop the // callback. drupal_set_message($error, 'error'); throw new Exception($error); } $modules[$dependency] = 0; } } // Reset module list. module_list(FALSE, TRUE, FALSE, $modules); // Ensure the language variable is set, if not it might cause problems (e.g. // entity info). global $language; if (!isset($language)) { $language = language_default(); } // If access arguments are passed, boot to SESSION and validate if the user // has access to this callback. if (!empty($valid_callbacks[$callback]['access arguments']) || !empty($valid_callbacks[$callback]['access callback'])) { drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // If no callback is provided, default to user_access. if (!isset($valid_callbacks[$callback]['access callback'])) { $valid_callbacks[$callback]['access callback'] = 'user_access'; } if ($valid_callbacks[$callback]['access callback'] == 'user_access') { // Ensure the user module is available. drupal_load('module', 'user'); } if (!call_user_func_array($valid_callbacks[$callback]['access callback'], !empty($valid_callbacks[$callback]['access arguments']) ? $valid_callbacks[$callback]['access arguments'] : array())) { return JS_MENU_ACCESS_DENIED; } } // Invoke implementations of hook_init() if the callback doesn't indicate it // should be skipped. if (!isset($valid_callbacks[$callback]['skip_hook_init']) || $valid_callbacks[$callback]['skip_hook_init'] == FALSE) { module_invoke_all('init'); } } // If there are page arguments defined add them to the callback call. if (isset($valid_callbacks[$callback]['page arguments'])) { // Get the original args again and strip first arguments 'js' and 'module'. $args = array_slice(explode('/', $_GET['q']), 2); // Overwrite the arguments $args = array_intersect_key($args, array_flip($valid_callbacks[$callback]['page arguments'])); } // Invoke callback function. return call_user_func_array($valid_callbacks[$callback]['callback'], $args); }