[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ctools/plugins/relationships/ -> user_from_node.inc (source)

   1  <?php
   2  // $Id: user_from_node.inc,v 1.3.2.2 2010/01/29 20:18:26 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   * Plugin to provide an relationship handler for node from user.
   7   */
   8  
   9  /**
  10   * Plugins are described by creating a $plugin array which will be used
  11   * by the system that includes this file.
  12   */
  13  $plugin = array(
  14    'title' => t('Node author'),
  15    'keyword' => 'user',
  16    'description' => t('Creates the author of a node as a user context.'),
  17    'required context' => new ctools_context_required(t('Node'), 'node'),
  18    'context' => 'ctools_user_from_node_context',
  19  );
  20  
  21  /**
  22   * Return a new context based on an existing context.
  23   */
  24  function ctools_user_from_node_context($context, $conf) {
  25    // If unset it wants a generic, unfilled context, which is just NULL.
  26    if (empty($context->data) || !isset($context->data->uid)) {
  27      return ctools_context_create_empty('user', NULL);
  28    }
  29  
  30    if (isset($context->data->uid)) {
  31      // Load the user that is the author of the node.
  32      $uid = $context->data->uid;
  33      $account = user_load(array('uid' => $uid));
  34  
  35      // Send it to ctools.
  36      return ctools_context_create('user', $account);
  37    }
  38  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7