-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuservoice.module
More file actions
61 lines (57 loc) · 1.55 KB
/
uservoice.module
File metadata and controls
61 lines (57 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Implementation of hook_menu for settings page
*/
function uservoice_menu() {
$items = array();
$items['admin/config/uservoice'] = array(
'title' => 'UserVoice settings',
'description' => 'Administer UserVoice settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('uservoice_settings'),
'access arguments' => array('administer site configuration'),
'file' => 'uservoice.admin.inc',
);
return $items;
}
/**
* Implements hook_init().
*/
function uservoice_init() {
_uservoice_check_api_key();
if (!path_is_admin(current_path())) {
_uservoice_include_misc();
}
}
/**
* Include uservoice JS SDk, settings
*/
function _uservoice_include_misc() {
$keys = array(
'api_key',
'accent_color',
'trigger_color',
'trigger_background_color',
'trigger_style',
'trigger_position',
'mode',
'locale'
);
foreach ($keys as $name) {
$settings[$name] = variable_get('uservoice_'. $name, NULL);
}
$settings['locale'] = drupal_strtolower($settings['locale']);
drupal_add_js(drupal_get_path('module', 'uservoice'). '/js/uservoice.js');
drupal_add_js(array('UserVoice' => $settings), 'setting');
}
/**
* Check if uservoice api key has been setup
*/
function _uservoice_check_api_key() {
if (!variable_get('uservoice_api_key', NULL)) {
$msg = t('UserVoice setup is not complete. Go to !link and add your API Key.',
array('!link' => l('The settings page', 'admin/config/uservoice'))
);
drupal_set_message($msg, 'error');
}
}