1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* wysiwyg plugin hook.
|
5
|
*/
|
6
|
|
7
|
function token_insert_get_tokens() {
|
8
|
global $user;
|
9
|
$roles['global'] = 'global';
|
10
|
if(variable_get('token_insert_use_tokens_per_role', 0)){
|
11
|
$roles += $user->roles;
|
12
|
}
|
13
|
$all_tokens = token_get_info();
|
14
|
foreach($roles as $rid => $role){
|
15
|
foreach ($all_tokens['tokens'] as $category => $tokens) {
|
16
|
$allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category, array());
|
17
|
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);
|
21
|
}
|
22
|
else {
|
23
|
$all_options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
|
24
|
}
|
25
|
}
|
26
|
else{
|
27
|
$all_options[$category . ':' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description['description'], 60, TRUE, TRUE);
|
28
|
}
|
29
|
}
|
30
|
}
|
31
|
}
|
32
|
if (empty($options)) {
|
33
|
$options = $all_options;
|
34
|
}
|
35
|
return $options;
|
36
|
|
37
|
|
38
|
}
|
39
|
|