1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
*
|
6 |
|
|
* Plugin to provide an argument handler for a user id
|
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("User: ID"),
|
15 |
|
|
// keyword to use for %substitution
|
16 |
|
|
'keyword' => 'user',
|
17 |
|
|
'description' => t('Creates a user context from a user ID argument.'),
|
18 |
|
|
'context' => 'ctools_argument_uid_context',
|
19 |
|
|
'placeholder form' => array(
|
20 |
|
|
'#type' => 'textfield',
|
21 |
|
|
'#description' => t('Enter the user ID of a user for this argument'),
|
22 |
|
|
),
|
23 |
|
|
'default' => array('to_arg' => TRUE),
|
24 |
|
|
'path placeholder' => '%pm_uid_arg', // This is in pagemanager.
|
25 |
|
|
'path placeholder to_arg' => TRUE,
|
26 |
|
|
'no ui' => 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($arg);
|
48 |
|
|
if (!$account) {
|
49 |
|
|
return NULL;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
return ctools_context_create('user', $account);
|
53 |
|
|
} |