You are here

function userreference_user_from_userref_context in Content Construction Kit (CCK) 5

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

Return a new panels context based on an existing context.

1 string reference to 'userreference_user_from_userref_context'
userreference_panels_relationships in ./userreference.module
Implementation of hook_panels_relationships().

File

./userreference.module, line 463
Defines a field type for referencing a user from a node.

Code

function userreference_user_from_userref_context($context = NULL, $conf) {

  // If unset it wants a generic, unfilled context, which is just NULL
  if (empty($context->data)) {
    return panels_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 panels_context_create('user', $account);
    }
  }
}