[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ctools/plugins/arguments/ -> uid.inc (source)

   1  <?php
   2  // $Id: uid.inc,v 1.9.2.2 2010/01/29 20:18:25 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   *
   7   * Plugin to provide an argument handler for a user id
   8   */
   9  
  10  /**
  11   * Plugins are described by creating a $plugin array which will be used
  12   * by the system that includes this file.
  13   */
  14  $plugin = array(
  15    'title' => t("User: ID"),
  16    // keyword to use for %substitution
  17    'keyword' => 'user',
  18    'description' => t('Creates a user context from a user ID argument.'),
  19    'context' => 'ctools_argument_uid_context',
  20    'placeholder form' => array(
  21      '#type' => 'textfield',
  22      '#description' => t('Enter the user ID of a user for this argument'),
  23    ),
  24    'default' => array('to_arg' => TRUE),
  25    'path placeholder' => '%pm_uid_arg', // This is in pagemanager.
  26    'path placeholder to_arg' => TRUE,
  27  );
  28  
  29  /**
  30   * Discover if this argument gives us the user we crave.
  31   */
  32  function ctools_argument_uid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
  33    // If unset it wants a generic, unfilled context.
  34    if ($empty) {
  35      return ctools_context_create_empty('user');
  36    }
  37  
  38    // We can accept either a node object or a pure nid.
  39    if (is_object($arg)) {
  40      return ctools_context_create('user', $arg);
  41    }
  42  
  43    if (!is_numeric($arg)) {
  44      return NULL;
  45    }
  46  
  47    $account = user_load(array('uid' => $arg));
  48    if (!$account) {
  49      return NULL;
  50    }
  51  
  52    return ctools_context_create('user', $account);
  53  }


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