You are here

function party_user_get_party in Party 7

Same name and namespace in other branches
  1. 8.2 modules/party_user/party_user.module \party_user_get_party()

Get a User's Party

Parameters

mixed $user The user entity or uid:

Return value

Party a Party Object

6 calls to party_user_get_party()
party_hat_user_party_hat_ctools_access_check in modules/party_hat/plugins/access/user_party_hat.inc
Check for access.
party_user_email_sync in modules/party_user/party_user.module
Synchronise the user email into all relevant fields.
party_user_party_from_user_context in modules/party_user/plugins/relationships/party_from_user.inc
Return a new context based on an existing context.
party_user_rules_get_party in modules/party_user/party_user.rules.inc
Implement the get a party from a user rule.
party_user_username_alter in modules/party_user/party_user.module
Implements hook_username_alter().

... See full list

File

modules/party_user/party_user.module, line 255
Support for linking users to parties

Code

function party_user_get_party($user) {
  if (is_object($user)) {
    if (!empty($user->party_attaching_party)) {
      return party_load($user->party_attaching_party);
    }
    $uid = $user->uid;
  }
  else {
    $uid = $user;
  }
  $result = db_select('party_attached_entity', 'pae')
    ->fields('pae', array(
    'pid',
  ))
    ->condition('eid', $uid, '=')
    ->condition('data_set', 'user')
    ->execute()
    ->fetchCol();
  $party_id = reset($result);
  if (is_object($user)) {
    $user->party_attaching_party = $party_id;
  }
  return party_load($party_id);
}