You are here

function userreference_user_from_userref_context in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 5 userreference.module \userreference_user_from_userref_context()
  2. 6.3 modules/userreference/panels/relationships/user_from_userref.inc \userreference_user_from_userref_context()

Return a new ctools context based on an existing context.

1 string reference to 'userreference_user_from_userref_context'
userreference_user_from_userref_ctools_relationships in modules/userreference/panels/relationships/user_from_userref.inc
Implementation of hook_ctools_relationships().

File

modules/userreference/panels/relationships/user_from_userref.inc, line 26
Implements the user reference relationship for Panels.

Code

function userreference_user_from_userref_context($context, $conf) {

  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data)) {
    return ctools_context_create_empty('user', NULL);
  }

  // Prevent whitescreens on stale data.
  if (empty($conf)) {
    return ctools_context_create_empty('user', NULL);
  }
  if (isset($context->data->{$conf['field_name']}[0]['uid']) && ($uid = $context->data->{$conf['field_name']}[0]['uid'])) {
    if ($account = user_load(array(
      'uid' => $uid,
    ))) {
      return ctools_context_create('user', $account);
    }
  }
}