user_from_node.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: user_from_node.inc,v 1.1.2.3 2008/05/27 20:21:14 sdboyer Exp $
00003 
00004 
00005 /**
00006  * Plugin to provide an relationship handler for node from user
00007  */
00008 function panels_user_from_node_panels_relationships() {
00009   $args['user_from_node'] = array(
00010     'title' => t("User from node"),
00011     'keyword' => 'user',
00012     'description' => t('Adds a user from node author context'),
00013     'required context' => new panels_required_context(t('Node'), 'node'),
00014     'context' => 'panels_user_from_node_context',
00015   );
00016   return $args;
00017 }
00018 
00019 /**
00020  * Return a new context based on an existing context
00021  */
00022 function panels_user_from_node_context($context = NULL, $conf) {
00023   // If unset it wants a generic, unfilled context, which is just NULL
00024   if (empty($context->data)) {
00025     return panels_context_create_empty('user', NULL);
00026   }
00027   if (isset($context->data->uid)) {
00028     // Load the user that is the author of the node
00029     $uid = $context->data->uid;
00030     $account = user_load(array('uid' => $uid));
00031 
00032     // Send it to panels
00033     return panels_context_create('user', $account);
00034   }
00035   else {
00036     return panels_context_create_empty('user', NULL);
00037   }
00038 }
00039 

Generated on Sun Feb 5 05:00:14 2012 for Panels 2 by  doxygen 1.5.6