1 |
5721e759
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Install and update hooks for the Token Insert module.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Update variable keys to support list tokens.
|
9 |
|
|
*/
|
10 |
|
|
function token_insert_update_7001() {
|
11 |
|
|
$roles = user_roles();
|
12 |
|
|
$roles['global'] = 'global';
|
13 |
|
|
$all_tokens = token_get_info();
|
14 |
|
|
foreach ($roles as $rid => $role) {
|
15 |
|
|
foreach ($all_tokens['tokens'] as $category => $tokens) {
|
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 |
|
|
}
|
21 |
|
|
else {
|
22 |
|
|
variable_set('token_insert_' . $rid . '_used_tokens_' . $category, array());
|
23 |
|
|
continue;
|
24 |
|
|
}
|
25 |
|
|
foreach ($tokens as $token => $description) {
|
26 |
|
|
$full_token = '[' . $category . ':' . $token . ']';
|
27 |
|
|
if (!empty ($allowed_options)) {
|
28 |
|
|
if (isset($allowed_options[$token]) ) {
|
29 |
|
|
$allowed_options[$full_token] = $allowed_options[$token] ? $full_token : 0;
|
30 |
|
|
unset($allowed_options[$token]);
|
31 |
|
|
}
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
variable_set('token_insert_' . $rid . '_used_tokens_' . $category, $allowed_options);
|
35 |
|
|
}
|
36 |
|
|
}
|
37 |
|
|
} |