forked from FreePBX/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.advancedsettings.php
157 lines (146 loc) · 7.49 KB
/
page.advancedsettings.php
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php /* $Id */
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
$getvars = array('action', 'keyword', 'value');
foreach ($getvars as $v){
$var[$v] = isset($_POST[$v]) ? $_POST[$v] : 0;
}
if($var['action'] === 'setkey') {
header("Content-type: application/json");
$keyword = $var['keyword'];
if ($freepbx_conf->conf_setting_exists($keyword)) {
//special cron manager detections
if($keyword == 'CRONMAN_UPDATES_CHECK') {
$cm =& cronmanager::create($db);
if($var['value']) {
$cm->enable_updates();
} else {
$cm->disable_updates();
}
}
$freepbx_conf->set_conf_values(array($keyword => trim($var['value'])),true,$amp_conf['AS_OVERRIDE_READONLY']);
$status = $freepbx_conf->get_last_update_status();
if ($status[$keyword]['saved']) {
freepbx_log(FPBX_LOG_INFO,sprintf(_("Advanced Settings changed freepbx_conf setting: [$keyword] => [%s]"),$var['value']));
needreload();
}
echo json_encode($status[$keyword]);
exit;
}
exit;
}
$amportal_canwrite = $freepbx_conf->amportal_canwrite() ? 'true' : 'false';
echo '<script type="text/javascript">';
echo 'can_write_amportalconf = ' . $amportal_canwrite . '; ';
echo 'amportalconf_error = "' . _("You must run 'amportal restart' from the Linux command line before you can save setting here.") . '";';
echo 'msgUnsavedChanges = "' . _("You have un-saved changes, press OK to disregard changes and reload page or Cancel to abort.") . '";';
echo 'msgChangesRefresh = "' . _("Your Display settings have been changed, click on 'Refresh Page' to view the affects of your changes once you have saved other outstanding changes that are still un-confirmed.") . '";';
echo '</script>';
echo '<div id="main_page">';
echo "<h2>"._("FreePBX Advanced Settings")."</h2>";
echo '<p>'._("<b>IMPORTANT:</b> Use extreme caution when making changes!").'</p>'._("Some of these settings can render your system inoperable. You are urged to backup before making any changes. Readonly settings are usually more volatile, they can be changed by changing 'Override Readonly Settings' to true. Once changed you must save the setting by checking the green check box that appears. You can restore the default setting by clicking on the icon to the right of the values if not set at default.");
$conf = $freepbx_conf->get_conf_settings();
$display_level = 10; // TO confusing with multiple levels $conf['AS_DISPLAY_DETAIL_LEVEL']['value'];
$display_hidden = $conf['AS_DISPLAY_HIDDEN_SETTINGS']['value'];
$display_readonly = $conf['AS_DISPLAY_READONLY_SETTINGS']['value'];
$display_friendly_name = $conf['AS_DISPLAY_FRIENDLY_NAME']['value'];
$current_category = '';
$row = 0;
echo '<input type="image" src="images/spinner.gif" style="display:none">';
echo '<table class="alt_table">';
foreach ($conf as $c){
if ($c['level'] > $display_level || $c['hidden'] && !$display_hidden || $c['readonly'] && !$display_readonly) {
continue;
}
if ($current_category != $c['category']) {
$current_category = $c['category'];
// TODO: Temp fix until someone much better at styling then me can actually properly fix this :)
// it's only purpose is to get the headings so they are not shaded and so the stripped shading
// starts consistent for each section.
//
if ($row % 2) {
echo '<tr></tr>';
$row++;
}
$current_category_loc = modgettext::_($current_category, $c['module']);
echo '<tr><td colspan="3"><br><h4 class="category">'._("$current_category_loc").'</h4></td></tr>';
$row++;
}
$name_label_raw = $c['name'];
$description_raw = $c['description'];
$name_label = modgettext::_($name_label_raw, $c['module']);
$tt_description = modgettext::_($description_raw, $c['module']);
if (!$display_friendly_name) {
$tr_friendly_name = $name_label;
$name_label = $c['keyword'];
}
$row++;
$dv = $c['type'] == CONF_TYPE_BOOL ? ($c['defaultval'] ? _("True") : _("False")) : $c['defaultval'];
$default_val = $dv == '' ? _("No Default Provided") : sprintf(_("Default Value: %s"),$dv);
if ($c['emptyok'] && $c['type'] != CONF_TYPE_BOOL && $c['type'] != CONF_TYPE_SELECT && $c['type'] != CONF_TYPE_FSELECT) {
$default_val.= ', '._("field can be left blank");
}
if ($c['type'] == CONF_TYPE_INT && $c['options']) {
$range = explode(',',$c['options']);
$default_val .= '<br />'.sprintf(_("Acceptable Values: %s - %s"),$range[0],$range[1]);
}
if ($display_friendly_name) {
$default_val .= '<br />'.sprintf(_("Internal Name: %s"),$c['keyword']);
} else {
$default_val .= '<br />'.sprintf(_("Friendly Name: %s"),$tr_friendly_name);
}
echo '<tr><td><a href="javascript:void(null)" class="info">'.$name_label.'<span>'.$tt_description.'<br /><br >'.$default_val.'</span></a></td>';
echo '<td>';
switch ($c['type']) {
case CONF_TYPE_TEXT:
case CONF_TYPE_DIR:
case CONF_TYPE_INT:
$readonly = !$c['readonly'] || $amp_conf['AS_OVERRIDE_READONLY'] && !$c['hidden'] ? '' : 'readonly="readonly"';
echo '<input class="valueinput" id="'.$c['keyword'].'" type="text" size="60" value="'.htmlspecialchars($amp_conf[$c['keyword']]).'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'" '.$readonly.'/>';
break;
case CONF_TYPE_SELECT:
echo '<select class="valueinput" id="'.$c['keyword'].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'">';
$opt = explode(',',$c['options']);
foreach($opt as $o) {
$selected = ($amp_conf[$c['keyword']] == $o) ? ' selected ' : '';
echo '<option value="'.$o.'"'.$selected.'>'.$o.'</option>';
}
echo '</select>';
break;
case CONF_TYPE_FSELECT:
echo '<select class="valueinput" id="'.$c['keyword'].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'">';
$opt = $c['options'];
foreach($opt as $o => $l) {
$selected = ($amp_conf[$c['keyword']] == $o) ? ' selected ' : '';
echo '<option value="'.$o.'"'.$selected.'>'.modgettext::_($l, $c['module']).'</option>';
}
echo '</select>';
break;
case CONF_TYPE_BOOL:
?>
<span class="radioset"><input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']] ? 1 : 0 ?>" id="<?php echo $c['keyword'] ?>-true" type="radio" name="<?php echo $c['keyword'] ?>" value="1" <?php echo $amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/>
<label for="<?php echo $c['keyword'] ?>-true"><?php echo _("True") ?></label>
<input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']] ? 1 : 0 ?>" id="<?php echo $c['keyword'] ?>-false" type="radio" name="<?php echo $c['keyword'] ?>" value="0" <?php echo !$amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/>
<label for="<?php echo $c['keyword'] ?>-false"><?php echo _("False") ?></label></span>
<?php
break;
}
echo '</td>';
if(!$c['readonly'] || $amp_conf['AS_OVERRIDE_READONLY'] && !$c['hidden']){
echo '<td><input type="image" class="adv_set_default" src="images/default-option.png" data-key="'.$c['keyword'].'" data-default="'.$c['defaultval'].'" title="'._('Revert to Default').'"'
. ' data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" '
. (($amp_conf[$c['keyword']] == $c['defaultval']) ? ' style="display:none" ' : '')
.'></td>';
echo '<td class="savetd"><input type="image" class="save" src="images/accept.png" data-key="'
. $c['keyword']
. '" title="' . _('Save') . '"'
. ' data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" '
. '></td>';
}
echo '</tr>';
}
echo '</table>';
// Provide enough padding at the bottom (<br />) so that the tooltip from the last setting does not get cut off.
?>
<br /><br /> <br />
<input type="button" id="page_reload" value="<?php echo _("Refresh Page");?>"/>
<br /><br /><br /><br /></div>