You are here

function og_og_block_details in Organic groups 5

Same name and namespace in other branches
  1. 5.8 og.module \og_og_block_details()
  2. 5.2 og.module \og_og_block_details()
  3. 5.3 og.module \og_og_block_details()
  4. 5.7 og.module \og_og_block_details()
1 call to og_og_block_details()
og_block_details in ./og.module

File

./og.module, line 2607

Code

function og_og_block_details($node) {
  global $user;
  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:') . ' ' . theme('username', $node);
    $subscribe = isset($subscription) ? l(t('My membership'), "og/manage/{$node->nid}") : og_subscribe_link($node);
    if (isset($subscribe)) {
      $links['my_membership'] = $subscribe;
    }
    if (module_exists('search') && user_access('search content')) {
      $post = drupal_get_form('og_search_form', $node);
    }
  }
  elseif ($subscription == 'requested') {
    $links['approval'] = t('Your membership request awaits approval.');
    $links['delete'] = l(t('delete request'), "og/unsubscribe/{$node->nid}", array(), 'destination=og');
  }
  elseif (!$user->uid) {
    $dest = drupal_get_destination();
    $links['must_login'] = t('You must <a href="!register">register</a>/<a href="!login">login</a> in order to post into this group.', array(
      '!register' => url("user/register", $dest),
      '!login' => url("user/login", $dest),
    ));
  }
  elseif ($node->og_selective < OG_INVITE_ONLY) {
    $links['subscribe'] = og_subscribe_link($node);
  }
  elseif ($node->og_selective == OG_INVITE_ONLY) {
    $links['closed'] = t('This is an @invite group. The group administrators add/remove members as needed.', array(
      '@invite' => t('invite only'),
    ));
  }
  elseif ($node->og_selective == OG_CLOSED) {
    $links['closed'] = t('This is a @closed group. The group administrators add/remove members as needed.', array(
      '@closed' => t('closed'),
    ));
  }

  // Modify these links by reference. If you want control of the whole block, see og_block_details().
  foreach (module_implements('og_link_alter') as $module) {
    $function = $module . '_og_link_alter';
    $function($links, $node);
  }
  $block['content'] = theme('item_list', $links) . $post;
  $block['subject'] = l($node->title, "node/{$node->nid}");
  return $block;
}