Projet

Général

Profil

Paste
Télécharger (1,17 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / arguments / user_edit.inc @ c304a780

1
<?php
2

    
3
/**
4
 * @file
5
 * Plugin to provide an argument handler for a Taxonomy term.
6
 */
7

    
8
/**
9
 * Plugins are described by creating a $plugin array which will be used
10
 * by the system that includes this file.
11
 */
12
$plugin = array(
13
  'title' => t("User edit form: User ID"),
14
  // Keyword to use for %substitution.
15
  'keyword' => 'user',
16
  'description' => t('Creates a user edit form context from a user ID argument.'),
17
  'context' => 'ctools_user_edit_context',
18
  'placeholder form' => array(
19
    '#type' => 'textfield',
20
    '#description' => t('Enter the user ID for this argument.'),
21
  ),
22
);
23

    
24
/**
25
 * Discover if this argument gives us the term we crave.
26
 */
27
function ctools_user_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {
28
  // If unset it wants a generic, unfilled context.
29
  if ($empty) {
30
    return ctools_context_create_empty('user_edit_form');
31
  }
32
  if (is_object($arg)) {
33
    return ctools_context_create('user_edit_form', $arg);
34
  }
35
  if (!is_numeric($arg)) {
36
    return FALSE;
37
  }
38

    
39
  $account = user_load($arg);
40
  if (!$account) {
41
    return NULL;
42
  }
43

    
44
  // This will perform a node_access check, so we don't have to.
45
  return ctools_context_create('user_edit_form', $account);
46
}