You are here

function og_details_links in Organic groups 6.2

Create group-contextual links, such as the group details block.

Parameters

$node: Node object providing group context for links.

Return value

array

See also

og_block_details()

1 call to og_details_links()
og_block_details in ./og.module
Content for Group Details block.

File

./og.module, line 2639
Code for the Organic Groups module.

Code

function og_details_links($node = NULL) {
  global $user;
  if (empty($node)) {
    $node = og_get_group_context();
  }
  $links = array();

  // Only display the group details links if we have a group context.
  if ($node && node_access('view', $node)) {
    $account = user_load($node->uid);
    list($txt, $subscription) = og_subscriber_count_link($node);
    if ($subscription == 'active' || user_access('administer nodes')) {
      $links = module_invoke_all('og_create_links', $node);

      // We want to open this up for OG_INVITE_ONLY but we need to handle invitation workflow much better. See http://drupal.org/node/170332
      if ($node->og_selective < OG_INVITE_ONLY) {
        $links['invite'] = l(t('Invite friend'), "og/invite/{$node->nid}");
      }
      $links['subscribers'] = $txt;
      $links['manager'] = t('Manager: !name', array(
        '!name' => theme('username', $account),
      ));

      // Site admins get a Join link if they are not yet subscribed.
      $subscribe = isset($subscription) && og_is_group_member($node->nid, FALSE) ? l(t('My membership'), "og/manage/{$node->nid}") : theme('og_subscribe_link', $node);
      if (isset($subscribe)) {
        $links['my_membership'] = $subscribe;
      }
    }
    elseif ($subscription == 'requested') {
      $links['approval'] = t('Your membership request awaits approval.');
      $links['delete'] = l(t('Delete request'), "og/unsubscribe/{$node->nid}/{$user->uid}", array(
        'query' => 'destination=og',
      ));
    }
    elseif (!$user->uid) {
      $dest = drupal_get_destination();
      if (variable_get('user_register', 1) == 0) {
        $links['must_login'] = t('You must <a href="!login">login</a> in order to post into this group.', array(
          '!login' => url("user/login", array(
            'query' => $dest,
          )),
        ));
      }
      else {
        $links['must_login'] = t('You must <a href="!register">register</a> or <a href="!login">login</a> in order to post into this group.', array(
          '!register' => url("user/register", array(
            'query' => $dest,
          )),
          '!login' => url("user/login", array(
            'query' => $dest,
          )),
        ));
      }
    }
    elseif ($node->og_selective < OG_INVITE_ONLY) {
      $links['subscribe'] = theme('og_subscribe_link', $node);
    }
    elseif ($node->og_selective == OG_INVITE_ONLY) {
      $links['closed'] = t('This is an <em>invite only</em> group. The group administrators add/remove members as needed.');
    }
    elseif ($node->og_selective == OG_CLOSED) {
      $links['closed'] = t('This is a <em>closed</em> group. The group administrators add/remove members as needed.');
    }

    // Modify these links by reference. If you want control of the whole block, see og_block_details().
    drupal_alter('og_links', $links, $node);
  }
  return $links;
}