Révision 5721e759
Ajouté par Assos Assos il y a presque 10 ans
drupal7/sites/all/modules/token_insert/token_insert.inc | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
/** |
3 | 3 |
* @file |
4 |
* wysiwyg plugin hook.
|
|
4 |
* Helper functions for token_insert.module.
|
|
5 | 5 |
*/ |
6 | 6 |
|
7 | 7 |
function token_insert_get_tokens() { |
8 | 8 |
global $user; |
9 | 9 |
$roles['global'] = 'global'; |
10 |
if(variable_get('token_insert_use_tokens_per_role', 0)){
|
|
10 |
if (variable_get('token_insert_use_tokens_per_role', 0)) {
|
|
11 | 11 |
$roles += $user->roles; |
12 | 12 |
} |
13 | 13 |
$all_tokens = token_get_info(); |
14 |
foreach($roles as $rid => $role){
|
|
14 |
foreach ($roles as $rid => $role) {
|
|
15 | 15 |
foreach ($all_tokens['tokens'] as $category => $tokens) { |
16 |
$allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array()); |
|
16 |
// Check to see if all tokens are enabled for this category. |
|
17 |
$allow_all = variable_get('token_insert_' . $rid . '_all_tokens_' . $category, FALSE); |
|
18 |
if (!$allow_all) { |
|
19 |
$allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array()); |
|
20 |
} |
|
17 | 21 |
foreach ($tokens as $token => $description) { |
18 |
if (!empty ($allowed_options)) { |
|
19 |
if (isset($allowed_options[$token]) && $allowed_options[$token] === $token) { |
|
20 |
$options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE); |
|
22 |
$full_token = '[' . $category . ':' . $token . ']'; |
|
23 |
if ($allow_all) { |
|
24 |
$options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE); |
|
25 |
} |
|
26 |
else { |
|
27 |
if (!empty ($allowed_options)) { |
|
28 |
if (isset($allowed_options[$full_token]) && $allowed_options[$full_token]) { |
|
29 |
$options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE); |
|
30 |
} |
|
31 |
else { |
|
32 |
$all_options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE); |
|
33 |
} |
|
21 | 34 |
} |
22 | 35 |
else { |
23 |
$all_options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
|
|
36 |
$all_options[$full_token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
|
|
24 | 37 |
} |
25 | 38 |
} |
26 |
else{ |
|
27 |
$all_options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE); |
|
28 |
} |
|
29 | 39 |
} |
30 | 40 |
} |
31 | 41 |
} |
... | ... | |
33 | 43 |
$options = $all_options; |
34 | 44 |
} |
35 | 45 |
return $options; |
36 |
|
|
37 |
|
|
38 | 46 |
} |
39 | 47 |
|
48 |
function token_insert_get_allowed_token_types() { |
|
49 |
global $user; |
|
50 |
$roles['global'] = 'global'; |
|
51 |
if (variable_get('token_insert_use_tokens_per_role', 0)) { |
|
52 |
$roles += $user->roles; |
|
53 |
} |
|
54 |
$all_tokens = token_get_info(); |
|
55 |
foreach ($roles as $rid => $role) { |
|
56 |
foreach ($all_tokens['tokens'] as $category => $tokens) { |
|
57 |
// Check to see if all tokens are enabled for this category. |
|
58 |
$allow_all = variable_get('token_insert_' . $rid . '_all_tokens_' . $category, FALSE); |
|
59 |
if (!$allow_all) { |
|
60 |
$allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array()); |
|
61 |
} |
|
62 |
foreach ($tokens as $token => $description) { |
|
63 |
$full_token = '[' . $category . ':' . $token . ']'; |
|
64 |
if ($allow_all) { |
|
65 |
$options[$category] = $category; |
|
66 |
break; |
|
67 |
} |
|
68 |
else { |
|
69 |
if (!empty ($allowed_options)) { |
|
70 |
if (isset($allowed_options[$full_token]) && $allowed_options[$full_token]) { |
|
71 |
$options[$category] = $category; |
|
72 |
break; |
|
73 |
} |
|
74 |
else { |
|
75 |
$all_options[$category] = $category; |
|
76 |
break; |
|
77 |
} |
|
78 |
} |
|
79 |
else { |
|
80 |
$all_options[$category] = $category; |
|
81 |
break; |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
if (empty($options)) { |
|
88 |
$options = $all_options; |
|
89 |
} |
|
90 |
return $options; |
|
91 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules