2 // $Id: content_profile.panels.inc,v 1.1.2.1 2009/01/04 12:02:19 fago Exp $
10 * Plugin to provide an relationship handler for node from user
12 function content_profile_panels_relationships() {
13 $args['node_from_user'] = array(
14 'title' => t("Profile Node from user"),
15 'keyword' => 'content_profile',
16 'description' => t('Adds a Content Profile from user context'),
17 'required context' => new panels_required_context(t('User'), 'user'),
18 'context' => 'content_profile_panels_context',
19 'settings form' => 'content_profile_panels_settings_form',
20 'settings form validate' => 'content_profile_panels_settings_form_validate',
26 * Return a new context based on an existing context
28 function content_profile_panels_context($context = NULL, $conf) {
29 // If unset it wants a generic, unfilled context, which is just NULL
30 if (empty($context->data)) {
31 return panels_context_create_empty('node', NULL);
34 if (isset($context->data->uid)) {
35 // Load the node for the requested type
36 $uid = $context->data->uid;
37 $content_profile_node = content_profile_load($conf['type'], $uid);
40 return panels_context_create('node', $content_profile_node);
43 return panels_context_create_empty('node', NULL);
48 * Settings form for the relationship
50 function content_profile_panels_settings_form($conf) {
51 $options = content_profile_get_types('names');
52 $form['type'] = array(
54 '#title' => t('Relationship type'),
55 '#options' => $options,
56 '#default_value' => $conf['type']