You are here

function spaces_og_subscription_link in Spaces 5.2

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

Custom subscription link - use "join" instead of "subscribe" - make it shorter.

1 call to spaces_og_subscription_link()
spaces_og.module in ./spaces_og.module

File

./spaces_og.module, line 752

Code

function spaces_og_subscription_link() {
  global $user;
  if ($user->uid && is_array($user->og_groups) && ($space = spaces_get_space())) {
    $gid = $space->sid;
    $node = node_load($gid);

    // User is a member
    if ($user->og_groups[$gid]) {

      // Do not let managers leave the group -- TODO: figure out a
      // better workflow for these situations.
      if (!og_is_node_admin($node)) {
        return array(
          'title' => t('Leave this group'),
          'href' => "og/unsubscribe/" . $node->nid,
          'query' => 'destination=' . $_GET['q'],
        );
      }
    }
    else {
      if (db_result(db_query("SELECT count(nid) FROM {og_uid} WHERE nid = %d AND uid = %d AND is_active = 0", $gid, $user->uid))) {
        return array(
          'title' => t('Cancel request to join'),
          'href' => "og/unsubscribe/" . $node->nid,
          'query' => 'destination=' . $_GET['q'],
        );
      }
      else {
        if ($node->og_selective == OG_MODERATED) {
          return array(
            'title' => t('Request to join'),
            'href' => "og/subscribe/" . $node->nid,
            'query' => 'destination=' . $_GET['q'],
          );
        }
        elseif ($node->og_selective == OG_OPEN) {
          return array(
            'title' => t('Join this group'),
            'href' => "og/subscribe/" . $node->nid,
            'query' => 'destination=' . $_GET['q'],
          );
        }
      }
    }
  }
  return;
}