function ctools_user_from_node_context in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 plugins/relationships/user_from_node.inc \ctools_user_from_node_context()
 
Return a new context based on an existing context.
1 string reference to 'ctools_user_from_node_context'
- user_from_node.inc in plugins/
relationships/ user_from_node.inc  - Plugin to provide an relationship handler for node from user.
 
File
- plugins/
relationships/ user_from_node.inc, line 23  - Plugin to provide an relationship handler for node from user.
 
Code
function ctools_user_from_node_context($context, $conf) {
  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data) || !isset($context->data->uid)) {
    return ctools_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 ctools.
    return ctools_context_create('user', $account);
  }
}