You are here

function content_profile_node_from_user_ctools_context in Content Profile 6

Return a new context based on an existing context.

1 string reference to 'content_profile_node_from_user_ctools_context'
content_profile_node_from_user_ctools_relationships in panels/relationships/node_from_user.inc
Implementation of specially named hook_ctools_relationships().

File

panels/relationships/node_from_user.inc, line 29
Provides a CTools (Panels) relationship that gets a node context from the user context based on nodes marked as content profiles.

Code

function content_profile_node_from_user_ctools_context($context, $conf) {

  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data) || !isset($context->data->uid)) {
    $new_context = ctools_context_create_empty('node', NULL);
  }
  else {

    // Load the node for the requested type
    $uid = $context->data->uid;
    $content_profile_node = content_profile_load($conf['type'], $uid);

    // Send it to ctools.
    $new_context = ctools_context_create('node', $content_profile_node);
  }

  // Have content profile relationships limit CCK field availability.
  if (isset($new_context->restrictions['type'])) {
    $new_context->restrictions['type'][] = $conf['type'];
  }
  else {
    $new_context->restrictions['type'] = array(
      $conf['type'],
    );
  }
  return $new_context;
}