You are here

function og_get_subscriptions in Organic groups 6.2

Same name and namespace in other branches
  1. 5.8 og.module \og_get_subscriptions()
  2. 5 og.module \og_get_subscriptions()
  3. 5.2 og.module \og_get_subscriptions()
  4. 5.3 og.module \og_get_subscriptions()
  5. 5.7 og.module \og_get_subscriptions()
  6. 6 og.module \og_get_subscriptions()

Load all memberships for a given user.

Since a user's memberships are loaded into $user object, this function is only occasionally useful to get group memberships for users other than the current user. Even then, it often makes sense to call user_load() instead of this function.

Parameters

$uid: User ID of the user.

$min_is_active: (Default: 1) Include active users. 0 to include blocked users also.

$reset: (Default: FALSE) Set to TRUE to reset the static cache.

Return value

array

11 calls to og_get_subscriptions()
OgSubscribe::_checkOgMembershipStatus in tests/og.subscribe.test
Check the group membership status of the specified user.
og_access_alter_nongroup_form in modules/og_access/og_access.module
og_access_node_grants in modules/og_access/og_access.module
Implementation of hook_node_grants().
og_activity_access_grants in includes/og.activity.inc
Implementation of hook_activity_access_grants().
og_confirm_unsubscribe_submit in ./og.pages.inc
Confirm og unsubscription submit handler

... See full list

File

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

Code

function og_get_subscriptions($uid, $min_is_active = 1, $reset = FALSE) {

  // Anonymous users are not able to subscribe to groups.
  if (!$uid) {
    return array();
  }
  static $subscriptions = array();
  if ($reset) {
    unset($subscriptions[$uid]);
  }
  if (!isset($subscriptions[$uid][$min_is_active])) {
    list($types, $in) = og_get_sql_args();
    array_unshift($types, $min_is_active);
    array_unshift($types, $uid);
    $sql = "SELECT n.title, n.type, n.status, ou.* FROM {og_uid} ou INNER JOIN {node} n ON ou.nid = n.nid WHERE ou.uid = %d AND ou.is_active >= %d AND n.type {$in} ORDER BY n.title";
    $result = db_query($sql, $types);
    while ($row = db_fetch_array($result)) {
      $subscriptions[$uid][$min_is_active][$row['nid']] = $row;
    }
    if (!isset($subscriptions[$uid][$min_is_active])) {
      $subscriptions[$uid][$min_is_active] = array();
    }
  }
  return $subscriptions[$uid][$min_is_active];
}