You are here

function panels_user_from_node_context in Panels 5.2

Same name and namespace in other branches
  1. 6.2 relationships/user_from_node.inc \panels_user_from_node_context()

Return a new context based on an existing context

1 string reference to 'panels_user_from_node_context'
panels_user_from_node_panels_relationships in relationships/user_from_node.inc
Plugin to provide an relationship handler for node from user

File

relationships/user_from_node.inc, line 21

Code

function panels_user_from_node_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->uid)) {

    // Load the user that is the author of the node
    $uid = $context->data->uid;
    $account = user_load(array(
      'uid' => $uid,
    ));

    // Send it to panels
    return panels_context_create('user', $account);
  }
  else {
    return panels_context_create_empty('user', NULL);
  }
}