You are here

function homebox_menu in Homebox 7.2

Same name and namespace in other branches
  1. 6.3 homebox.module \homebox_menu()
  2. 6 homebox.module \homebox_menu()
  3. 6.2 homebox.module \homebox_menu()
  4. 7.3 homebox.module \homebox_menu()

Implements hook_menu().

File

./homebox.module, line 28
Homebox main file, takes care of global functions settings constants, etc.

Code

function homebox_menu() {
  $items = array();

  // Created Homebox pages
  $pages = homebox_pages();
  if (is_array($pages) && count($pages) > 0) {
    foreach ($pages as $page) {
      $items[$page->settings['path']] = array(
        'title' => $page->settings['title'],
        'title callback' => 'homebox_build_title',
        'page callback' => 'homebox_build',
        'page arguments' => array(
          $page,
        ),
        'access callback' => '_homebox_user_access_view_homebox',
        'access arguments' => array(
          $page,
        ),
        'type' => $page->settings['menu'] ? MENU_NORMAL_ITEM : MENU_CALLBACK,
      );
      $items[$page->settings['path'] . '/block/%'] = array(
        'title' => $page->settings['title'],
        'page callback' => 'homebox_build_block',
        'page arguments' => array(
          $page,
          count(explode('/', $page->settings['path'])) + 1,
        ),
        'access callback' => '_homebox_user_access_view_homebox',
        'access arguments' => array(
          $page,
        ),
        'type' => $page->settings['menu'] ? MENU_NORMAL_ITEM : MENU_CALLBACK,
      );
    }
  }

  // Optionally add a tab to user profiles
  if ($name = variable_get('homebox_user_tab', '')) {
    $page = homebox_get_page($name);
    if ($page) {
      $items['user/%user/' . $page->settings['path']] = array(
        'title callback' => 'homebox_build_title',
        'title arguments' => array(
          $page->settings['title'],
        ),
        'page callback' => 'homebox_build',
        'page arguments' => array(
          $page,
        ),
        'access callback' => '_homebox_user_access_view_user_homebox',
        'access arguments' => array(
          $page,
          1,
        ),
        'weight' => 1,
        'type' => MENU_LOCAL_TASK,
      );
      $items['user/%user/' . $page->settings['path'] . '/block/%'] = array(
        'page callback' => 'homebox_build_block',
        'page arguments' => array(
          $page,
          4,
        ),
        'access callback' => '_homebox_user_access_view_user_homebox',
        'access arguments' => array(
          $page,
          1,
        ),
        'type' => MENU_CALLBACK,
      );
    }
  }

  // Ajax Callbacks
  $items['homebox/%homebox/restore'] = array(
    'title' => 'Restore',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_restore_defaults',
      1,
    ),
    'access callback' => '_homebox_user_access_view_homebox',
    'access arguments' => array(
      1,
      TRUE,
    ),
    'type' => MENU_CALLBACK,
  );
  $items['homebox/js/%homebox/add/%/%'] = array(
    'page callback' => 'homebox_add_block',
    'page arguments' => array(
      2,
      4,
      5,
    ),
    'access callback' => 'homebox_edit_access',
    'access arguments' => array(
      2,
    ),
    'type' => MENU_CALLBACK,
  );
  $items['homebox/js/%homebox/save'] = array(
    'page callback' => 'homebox_js_save_user_settings',
    'page arguments' => array(
      2,
    ),
    'access callback' => '_homebox_user_access_view_homebox',
    'access arguments' => array(
      2,
      TRUE,
    ),
    'type' => MENU_CALLBACK,
  );

  // Admin related tasks
  $items['admin/structure/homebox'] = array(
    'title' => 'Homebox',
    'description' => 'List, edit, or add homebox pages.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_admin_new_page',
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'file' => 'homebox.admin.inc',
  );
  $items['admin/structure/homebox/edit/%homebox'] = array(
    'title' => 'Edit page',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_admin_page',
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'title callback' => '_homebox_admin_page_title',
    'title arguments' => array(
      4,
    ),
    'type' => MENU_CALLBACK,
    'file' => 'homebox.admin.inc',
  );
  $items['admin/structure/homebox/clone/%homebox'] = array(
    'title' => 'Clone homebox',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_clone_page',
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'title callback' => '_homebox_clone_page_title',
    'title arguments' => array(
      4,
    ),
    'type' => MENU_CALLBACK,
    'file' => 'homebox.admin.inc',
  );
  $items['admin/structure/homebox/layout/%homebox'] = array(
    'title' => 'Layout',
    'description' => 'Edit layout.',
    'page callback' => 'homebox_layout',
    'page arguments' => array(
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'file' => 'homebox.admin.inc',
    'type' => MENU_CALLBACK,
  );
  $items['admin/structure/homebox/flush/%homebox'] = array(
    'title' => 'Flush user settings',
    'description' => 'Clear all user\'s settings for a given homebox.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_admin_flush_form',
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'file' => 'homebox.admin.inc',
    'type' => MENU_CALLBACK,
  );
  $items['admin/structure/homebox/settings/%homebox'] = array(
    'title' => 'Settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_configure_form',
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'homebox.admin.inc',
  );
  $items['admin/structure/homebox/export/%homebox'] = array(
    'title' => 'Export',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_export_form',
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'homebox.admin.inc',
  );
  $items['admin/structure/homebox/delete/%homebox'] = array(
    'title' => 'Delete page',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_admin_page_delete_confirm',
      4,
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'homebox.admin.inc',
  );

  // Admin user settings
  $items['admin/people/homebox'] = array(
    'title' => 'User profile Homebox',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'homebox_user_settings_page',
    ),
    'access arguments' => array(
      'administer homebox',
    ),
    'description' => 'Configure the intergration of Homebox and user profiles.',
    'type' => MENU_LOCAL_TASK,
    'file' => 'homebox.admin.inc',
  );
  return $items;
}