You are here

function spaces_og_subscription_link in Spaces 6.3

Same name and namespace in other branches
  1. 5.2 spaces_og.module \spaces_og_subscription_link()
  2. 5 spaces.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.

File

spaces_og/spaces_og.module, line 402

Code

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

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

      // Do not let managers leave the group -- TODO: figure out a
      // better workflow for these situations.
      if (!og_is_group_admin($node) && $node->og_selective != OG_CLOSED) {
        return array(
          'title' => t('Leave this group'),
          'href' => "og/unsubscribe/{$node->nid}/{$user->uid}",
          '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}/{$user->uid}",
          '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;
}