This repository was archived by the owner on Mar 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegrated_support.admin.inc
More file actions
101 lines (89 loc) · 3.63 KB
/
integrated_support.admin.inc
File metadata and controls
101 lines (89 loc) · 3.63 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
function integrated_support_admin_form($form, &$state) {
$form = array(
'integrated_support' => array(
'#type' => 'fieldset',
'#title' => t('Service status'),
'#collapsible' => FALSE,
'services' => array(
'#markup' => integrated_support_status(),
),
),
'create_webhooks' => array(
'#type' => 'checkboxes',
'#title' => t('(Re) Deploy remote webhooks'),
'#description' => t('These webbhooks can be configured remotely. Check those that you wish to enable.')
) ,
'integrated_support_force_cache' => array(
'#type' => 'textfield',
'#title' => t('Force API caching'),
'#description' => t('Integrated Support makes frequent API calls. This setting will force those results to be cached for a number of seconds, regardless of what the API service\'s cache control headers say.'),
'#default_value' => variable_get('integrated_support_force_cache', FALSE),
),
'integrated_support_in_planning' => array(
'#type' => 'checkbox',
'#title' => t('In Planning Week'),
'#description' => t('Are we in planning week? If so change "In Development" to "Last Release" and make planning the default.'),
'#default_value' => variable_get('integrated_support_in_planning', FALSE),
),
'integrated_support_planning_text' => array(
'#type' => 'textarea',
'#title' => t('Text to describe the planning tab.'),
'#description' => t('Shows at the top of the planning tab, maybe has a link to a google doc or somthing.'),
'#default_value' => variable_get('integrated_support_planning_text', FALSE),
),
);
$info = module_invoke_all('integrated_support_info');
foreach ($info as $name => $def) {
if (is_callable($def['setup function'])) {
$form['create_webhooks']['#options'][$name] = $def['name'] . ' - ' . $def['description'];
}
}
//list of user mappings between services
$modules = module_implements('integrated_support_info');
$user_rows = array();
$usermap = variable_get('integrated_support_usernames', array());
foreach ($usermap as $accounts) {
$row = array();
foreach ($modules as $m) {
$row[] = (isset($accounts[$m])) ? $accounts[$m] : NULL;
}
$user_rows[] = $row;
}
// variable_set('integrated_support_usernames', array(array('desk_integration' => 'jsagotsky', 'github_integration' => 'sagotsky')));
$table = array(
'header' => $modules,
'rows' => $user_rows,
);
$form['usermap'] = array(
'#prefix' => '<label>User name mappings between services.</label> Configure via "integrated_support_usernames" variable.',
'#markup' => theme('table', $table),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Enable'),
);
return $form;
}
/**
* Enable the web hooks from admin form
*/
function integrated_support_admin_form_submit($form, &$state) {
$info = module_invoke_all('integrated_support_info');
$events = array_filter($state['values']['create_webhooks']);
foreach ($events as $event) {
if ($func = $info[$event]['setup function']) {
$func();
}
}
if (isset($state['values']['integrated_support_force_cache'])) {
variable_set('integrated_support_force_cache', $state['values']['integrated_support_force_cache']);
}
if (isset($state['values']['integrated_support_in_planning'])) {
variable_set('menu_rebuild_needed', TRUE);
variable_set('integrated_support_in_planning', $state['values']['integrated_support_in_planning']);
}
if (isset($state['values']['integrated_support_planning_text'])) {
variable_set('integrated_support_planning_text', $state['values']['integrated_support_planning_text']);
}
}