You are here

function og_menu in Organic groups 5.7

Same name and namespace in other branches
  1. 5.8 og.module \og_menu()
  2. 5 og.module \og_menu()
  3. 5.2 og.module \og_menu()
  4. 5.3 og.module \og_menu()
  5. 6.2 og.module \og_menu()
  6. 6 og.module \og_menu()
  7. 7.2 og.module \og_menu()
  8. 7 og.module \og_menu()

File

./og.module, line 35

Code

function og_menu($may_cache) {
  global $user;
  $items = array();
  $access = $user->uid;

  // login is required
  if ($may_cache) {

    // anon users should be able to get to the join page
    $items[] = array(
      'path' => 'og/subscribe',
      'type' => MENU_CALLBACK,
      'callback' => 'og_menu_check_node_view',
      'access' => TRUE,
      'callback arguments' => array(
        'og_subscribe',
      ),
      'title' => t('Join group'),
    );
    $items[] = array(
      'path' => 'og/opml',
      'type' => MENU_CALLBACK,
      'callback' => 'og_opml',
      'access' => $access,
      'title' => t('OPML'),
    );
    $items[] = array(
      'path' => 'og/unsubscribe',
      'type' => MENU_CALLBACK,
      'callback' => 'og_menu_check_node_view',
      'callback arguments' => array(
        'og_unsubscribe',
      ),
      'access' => $access,
      'title' => t('Leave group'),
    );
    $items[] = array(
      'path' => 'og/approve',
      'type' => MENU_CALLBACK,
      'callback' => 'og_approve',
      'access' => $access,
      'title' => t('Approve membership request'),
    );
    $items[] = array(
      'path' => 'og/deny',
      'type' => MENU_CALLBACK,
      'callback' => 'og_deny',
      'access' => $access,
      'title' => t('Deny membership request'),
    );
    $items[] = array(
      'path' => 'og/create_admin',
      'type' => MENU_CALLBACK,
      'callback' => 'og_create_admin',
      'access' => $access,
      'title' => t('Create group administrator'),
    );
    $items[] = array(
      'path' => 'og/delete_admin',
      'type' => MENU_CALLBACK,
      'callback' => 'og_delete_admin',
      'access' => $access,
      'title' => t('Delete group administrator'),
    );
    $items[] = array(
      'path' => 'og/feed',
      'callback' => 'og_feed',
      'title' => t('Group feed'),
      'type' => MENU_CALLBACK,
      'access' => user_access('access content'),
    );

    // members only
    $items[] = array(
      'path' => "og/invite",
      'callback' => 'og_menu_check',
      'title' => t('Send invitation'),
      'callback arguments' => array(
        'og_invite_page',
      ),
      'type' => MENU_CALLBACK,
      'access' => $access,
    );
    $items[] = array(
      'path' => "og/manage",
      'callback' => 'og_menu_check',
      'title' => t('Manage membership'),
      'callback arguments' => array(
        'og_manage',
      ),
      'type' => MENU_CALLBACK,
      'access' => $access,
    );
    $items[] = array(
      'path' => 'og/activity',
      'title' => t('Group activity'),
      'callback' => 'og_page_activity',
      'access' => user_access('administer organic groups'),
      'weight' => 4,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/og',
      'title' => t('Organic groups'),
      'description' => t('Administer the suite of organic groups modules.'),
      'position' => 'right',
      'weight' => -5,
      'callback' => 'system_admin_menu_block_page',
      'access' => user_access('administer site configuration'),
    );
    $items[] = array(
      'path' => 'admin/og/og',
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'og_admin_settings',
      ),
      'title' => t('Organic groups configuration'),
      'description' => t('Configure the main Organic groups module (og)'),
      'weight' => -5,
    );
  }
  else {
    drupal_add_css(drupal_get_path('module', 'og') . '/og.css');

    // we get a NOTICE if doing this from within og_theme() so I do it here for now.
    $_SESSION['og_last'] = og_get_group_context();

    //membership page and its 'add members' tab
    $gid = arg(2);
    if (arg(0) == 'og' && arg(1) == 'users' && is_numeric($gid)) {
      $items[] = array(
        'path' => "og/users/{$gid}",
        'callback' => 'og_menu_check',
        'title' => t('Members'),
        'callback arguments' => array(
          'og_list_users_page',
          $gid,
        ),
        'type' => MENU_CALLBACK,
        'access' => $access,
      );
      $items[] = array(
        'path' => "og/users/{$gid}/list",
        'title' => t('List'),
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      if (og_is_picture()) {
        $items[] = array(
          'path' => "og/users/{$gid}/faces",
          'title' => t('Faces'),
          'callback' => 'og_menu_check',
          'callback arguments' => array(
            'og_list_users_faces_page',
            $gid,
          ),
          'type' => MENU_LOCAL_TASK,
        );
      }

      // group admin only
      $node = node_load($gid);
      $items[] = array(
        'path' => "og/users/{$gid}/add_user",
        'callback' => 'drupal_get_form',
        'title' => t('Add members'),
        'callback arguments' => array(
          'og_add_users',
          $gid,
        ),
        'type' => MENU_LOCAL_TASK,
        'weight' => 5,
        'access' => og_is_node_admin($node),
      );
    }

    // email tab on group node
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if (og_is_group_type($node->type)) {
        $items[] = array(
          'path' => 'node/' . arg(1) . '/email',
          'title' => t('E-mail'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'og_email_form',
            arg(1),
          ),
          'access' => og_is_node_admin($node),
          'type' => MENU_LOCAL_TASK,
          'weight' => 7,
        );
      }
    }
  }
  return $items;
}