You are here

function og_is_pending_member in Organic groups 6.2

Determine the moderated groups a user has petitioned to join.

Parameters

gid: An integer or a node object representing the group node.

$uid: Pass a user id, or pass NULL in order to check current user.

$reset: If TRUE, the cached user object (if any) will be reset for the given $uid (or the current $user if $uid is NULL).

Return value

Whether the user is a pending member of the specified group. If no $gid is specified, will return an array of all pending groups.

2 calls to og_is_pending_member()
OgSubscribe::assertOgPendingMember in tests/og.subscribe.test
Assert the specified user is a pending member of the specified group.
theme_og_subscribe_link in ./og.module
Generate a link to join or request to join the specified group.

File

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

Code

function og_is_pending_member($gid = NULL, $uid = NULL, $reset = FALSE) {
  static $pending;
  if (!isset($uid)) {
    $uid = $GLOBALS['user']->uid;
  }
  if (empty($pending[$uid]) || $reset) {
    $pending[$uid] = array();
    $groups = array_diff_assoc(og_get_subscriptions($uid, 0, $reset), og_get_subscriptions($uid, 1));
    foreach ($groups as $group_nid => $group) {
      $pending[$uid][$group_nid] = $group_nid;
    }
  }
  return !empty($gid) ? in_array($gid, $pending[$uid]) : $pending[$uid];
}