'user', 'path' => 'user/%dashboard_user_page/dashboard', 'title' => 'Dashboard', 'page callback' => 'dashboard_page', 'access arguments' => array(1), 'file' => 'dashboard.user.inc', ); $dashboard['presets'] = array( 'name' => 'presets', 'path' => 'admin/settings/dashboard/preset/%dashboard_preset', 'title' => 'Dashboard presets', 'page callback' => 'dashboard_page', 'access arguments' => array(4), 'file' => 'dashboard.preset.inc', ); return $dashboard; } /** * Gather all the permissions for various Dashboards. This is an optional way to make the permissions for different dashboards uniform. We could even allow hook_dashboard to define these permissions in a more granular way. */ function dashboard_perm() { $perms = array(); $dashboards = module_invoke_all('dashboard'); foreach ($dashboards as $dashboard) { foreach (array('access', 'edit', 'delete', 'administer') as $item) { $perms[] = $item .' '. $dashboard .' dashboard'; } } } /** * Generate the menu callbacks for all Dashboards. This approach to building the menu will allow us to reuse the dashboard interface in multiple instances. We probably want to combine default values for each item with the data coming from the $dashboard. */ function dashboard_menu() { $items = array(); $dashboards = module_invoke_all('dashboard'); foreach ($dashboards as $dashboard) { $items[$dashboard['path']] = array( // ... ); } return $items; } /** * Define administrative options for dashboard. This demonstrates the types of settings that might be available for any dashboard defined by hook_dashboard(). In general, we want to define the types of gadgets that will be available, the public visibility of individual dashboards, and the maximum allowed content elements per dashboard. We might also have a plug-in system that allowed for the swapping of different user interfaces on a per dashboard basis. */ function dashboard_administer($dashboard) { $form = array(); $form[$dashboard['name'] .'_gadgets'] = array( '#type' => 'checkboxes', '#title'=> t('Allowed gadgets'), '#options' => $gadgets, '#default_value' => dashboard_allowed_gadgets($dashboard['name']), ); return system_settings_form($form); } /** * A simpler way to handle variable defaults. */ function dashboard_variable($name, $all = FALSE) { $vars = array( 'max_pages' => 10, 'max_gadgets' => 10, ); if ($all) { return $vars; } return variable_get('dashboard_'. $name, $vars[$name]); }