You are here

function spaces_menu in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces.module \spaces_menu()
  2. 6.3 spaces.module \spaces_menu()
  3. 6 spaces.module \spaces_menu()
  4. 6.2 spaces.module \spaces_menu()
  5. 7.3 spaces.module \spaces_menu()
  6. 7 spaces.module \spaces_menu()

File

./spaces.module, line 51

Code

function spaces_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/spaces',
      'title' => t('Spaces Settings'),
      'description' => t('Spaces feature defaults.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'spaces_features_form',
        0,
      ),
      'access' => user_access('administer group features'),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/spaces/default',
      'title' => t('Default settings'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'spaces_features_form',
        0,
      ),
      'access' => user_access('administer group features'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/spaces/debug',
      'title' => t('Debug'),
      'callback' => 'spaces_admin_debug',
      'access' => user_access('administer group features'),
      'weight' => 10,
      'type' => MENU_LOCAL_TASK,
    );
  }
  else {
    if ($_GET['q'] == 'admin/settings/spaces') {
      include_once drupal_get_path('module', 'spaces') . '/spaces_admin.inc';
    }
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if (og_is_group_type($node->type)) {
        include_once drupal_get_path('module', 'spaces') . '/spaces_admin.inc';
        $items[] = array(
          'path' => 'node/' . $node->nid . '/features',
          'title' => t('Features'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'spaces_features_form',
            $node->nid,
          ),
          'access' => user_access('administer group features') || og_is_node_admin($node),
          'type' => MENU_LOCAL_TASK,
          'weight' => 2,
        );
        $items[] = array(
          'path' => 'node/' . $node->nid . '/labels',
          'title' => t('Labels'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'spaces_features_labels',
            $node->nid,
          ),
          'access' => user_access('administer group features') || og_is_node_admin($node),
          'type' => MENU_LOCAL_TASK,
          'weight' => 2,
        );
        $items[] = array(
          'path' => 'node/' . $node->nid . '/view-headers',
          'title' => t('View Headers'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'spaces_view_headers',
          ),
          'access' => user_access('administer group features') || og_is_node_admin($node),
          'type' => MENU_LOCAL_TASK,
        );
      }
    }

    // Verify that the user should be able to look into this group.
    if ($gid = spaces_gid()) {
      if (spaces_router('menu', $gid)) {
        $group = node_load($gid);

        // Member management
        // TODO: move into spaces_og when ready
        $items[] = array(
          'path' => "member-list",
          'callback' => 'spaces_og_wrapper',
          'callback arguments' => array(
            'member-list',
          ),
          'title' => t('Members'),
          'type' => MENU_CALLBACK,
          'access' => user_access('administer group features') || og_is_node_admin($group),
        );
        $items[] = array(
          'path' => "member-add",
          'callback' => 'spaces_og_wrapper',
          'callback arguments' => array(
            'member-add',
          ),
          'title' => t('Add Members'),
          'type' => MENU_CALLBACK,
          'access' => user_access('administer group features') || og_is_node_admin($group),
        );
      }
      else {
        drupal_access_denied();
        exit;
      }
    }
  }
  return $items;
}