user_from_node.inc in Panels 5.2
File
relationships/user_from_node.inc
View source
<?php
function panels_user_from_node_panels_relationships() {
$args['user_from_node'] = array(
'title' => t("User from node"),
'keyword' => 'user',
'description' => t('Adds a user from node author context'),
'required context' => new panels_required_context(t('Node'), 'node'),
'context' => 'panels_user_from_node_context',
);
return $args;
}
function panels_user_from_node_context($context = NULL, $conf) {
if (empty($context->data)) {
return panels_context_create_empty('user', NULL);
}
if (isset($context->data->uid)) {
$uid = $context->data->uid;
$account = user_load(array(
'uid' => $uid,
));
return panels_context_create('user', $account);
}
else {
return panels_context_create_empty('user', NULL);
}
}