function userreference_user_from_userref_context in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 5 userreference.module \userreference_user_from_userref_context()
- 6.2 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);
}
}
}