Révision c304a780
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/ctools/plugins/access/string_equal.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Plugin to provide access control/visibility based on specified context string matching user-specified string |
|
5 |
* Plugin to provide access control/visibility based on specified context string matching user-specified string.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
$plugin = array( |
... | ... | |
16 | 16 |
); |
17 | 17 |
|
18 | 18 |
/** |
19 |
* Settings form |
|
19 |
* Settings form.
|
|
20 | 20 |
*/ |
21 | 21 |
function ctools_string_equal_ctools_access_settings($form, &$form_state, $conf) { |
22 | 22 |
$form['settings']['operator'] = array( |
... | ... | |
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
/** |
50 |
* Check for access |
|
50 |
* Check for access.
|
|
51 | 51 |
*/ |
52 | 52 |
function ctools_string_equal_ctools_access_check($conf, $context) { |
53 | 53 |
if (empty($context) || empty($context->data)) { |
... | ... | |
66 | 66 |
switch ($conf['operator']) { |
67 | 67 |
case '=': |
68 | 68 |
return $string === $value; |
69 |
|
|
69 | 70 |
case '!=': |
70 | 71 |
return $string !== $value; |
72 |
|
|
71 | 73 |
case 'regex': |
72 | 74 |
return preg_match($value, $string); |
75 |
|
|
73 | 76 |
case '!regex': |
74 | 77 |
return !preg_match($value, $string); |
75 | 78 |
} |
76 | 79 |
} |
77 | 80 |
|
78 | 81 |
/** |
79 |
* Provide a summary description based upon the specified context |
|
82 |
* Provide a summary description based upon the specified context.
|
|
80 | 83 |
*/ |
81 | 84 |
function ctools_string_equal_ctools_access_summary($conf, $context) { |
82 | 85 |
$values = array('@identifier' => $context->identifier, '@value' => $conf['value']); |
83 | 86 |
switch ($conf['operator']) { |
84 | 87 |
case '=': |
85 | 88 |
return t('@identifier is "@value"', $values); |
89 |
|
|
86 | 90 |
case '!=': |
87 | 91 |
return t('@identifier is not "@value"', $values); |
92 |
|
|
88 | 93 |
case 'regex': |
89 | 94 |
return t('@identifier matches "@value"', $values); |
95 |
|
|
90 | 96 |
case '!regex': |
91 | 97 |
return t('@identifier does not match "@value"', $values); |
92 | 98 |
} |
93 | 99 |
} |
94 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules