root/modules/branches/2.10/core/page.advancedsettings.php

Revision 12445, 8.3 kB (checked in by mbrevda, 2 years ago)

closes #5342 - update skin

Line 
1 <?php /* $Id */
2
3 $getvars = array('action', 'keyword', 'value', 'send_reload');
4 foreach ($getvars as $v){
5     $var[$v] = isset($_POST[$v]) ? $_POST[$v] : 0;
6 }
7
8 if($var['action'] === 'setkey') {
9     header("Content-type: application/json");
10     $keyword = $var['keyword'];
11     if ($freepbx_conf->conf_setting_exists($keyword)) {
12         $freepbx_conf->set_conf_values(array($keyword => trim($var['value'])),true,$amp_conf['AS_OVERRIDE_READONLY']);
13         $status = $freepbx_conf->get_last_update_status();
14         /*if ($var['send_reload'] && $status[$keyword]['saved']) {
15             ob_start();
16             include ('views/freepbx_reloadbar.php');
17             $status[$keyword]['reload_bar'] = ob_get_clean();
18
19             ob_start();
20             include ('views/freepbx_reload.php');
21             $status[$keyword]['reload_header'] = ob_get_clean();
22         }*/
23         if ($status[$keyword]['saved']) {
24             freepbx_log(FPBX_LOG_INFO,sprintf(_("Advanced Settings changed freepbx_conf setting: [$keyword] => [%s]"),$var['value']));
25             needreload();
26             
27             //special case for manager related changes - these need to be applied right away re #5117
28             switch ($keyword) {
29                 case 'ASTMANAGERHOST':
30                 case 'AMPMGRPASS':
31                 case 'ASTMANAGERPORT':
32                 case 'ASTMANAGERPROXYPORT':
33                 case 'AMPMGRUSER':
34                     //$astman->Command('module reload manager');
35                     break;
36             }
37             
38         }
39         echo json_encode($status[$keyword]);
40         exit;
41     }
42     exit;
43 }
44 $amportal_canwrite = $freepbx_conf->amportal_canwrite() ? 'true' : 'false';
45 echo '<script type="text/javascript">';
46 echo 'can_write_amportalconf = ' . $amportal_canwrite . '; ';
47 echo 'amportalconf_error = "' . _("You must run 'amportal restart' from the Linux command line before you can save setting here.") . '";';
48 echo 'msgUnsavedChanges = "' . _("You have un-saved changes, press OK to disregard changes and reload page or Cancel to abort.") . '";';
49 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.") . '";';
50 echo '</script>';
51
52 echo '<div id="main_page">';
53 echo "<h2>"._("FreePBX Advanced Settings")."</h2>";
54 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.");
55
56 $conf                    = $freepbx_conf->get_conf_settings();
57
58 $display_level            = 10; // TO confusing with multiple levels $conf['AS_DISPLAY_DETAIL_LEVEL']['value'];
59 $display_hidden            = $conf['AS_DISPLAY_HIDDEN_SETTINGS']['value'];
60 $display_readonly        = $conf['AS_DISPLAY_READONLY_SETTINGS']['value'];
61 $display_friendly_name    = $conf['AS_DISPLAY_FRIENDLY_NAME']['value'];
62
63 $current_category        = '';
64 $row                    = 0;
65
66 echo '<input type="image" src="images/spinner.gif" style="display:none">';
67 echo '<table class="alt_table">';
68 foreach ($conf as $c){
69     if ($c['level'] > $display_level || $c['hidden'] && !$display_hidden || $c['readonly'] && !$display_readonly) {
70         continue;
71     }
72     if ($current_category != $c['category']) {
73         $current_category = $c['category'];
74
75         // TODO: Temp fix until someone much better at styling then me can actually properly fix this :)
76         //       it's only purpose is to get the headings so they are not shaded and so the stripped shading
77         //       starts consistent for each section.
78         //
79         if ($row % 2) {
80             //echo '<tr><td colspan="3"><br></td></tr>';
81             echo '<tr></tr>';
82             $row++;
83         }
84         if ($c['module'] && extension_loaded('gettext') && is_dir("modules/".$c['module']."/i18n")) {
85             bindtextdomain($c['module'],"modules/".$c['module']."/i18n");
86             bind_textdomain_codeset($c['module'], 'utf8');
87             $current_category_loc = dgettext($c['module'],$current_category);
88             if ($current_category_loc == $current_category) {
89                     $current_cateogry_loc = _($current_category);
90             }
91         } else {
92             $current_category_loc = _($current_category);
93         }
94         echo '<tr><td colspan="3"><br><h4 class="category">'._("$current_category_loc").'</h4></td></tr>';
95         $row++;
96     }
97
98     $name_label_raw = $c['name'];
99     $description_raw = $c['description'];
100     if ($c['module'] && extension_loaded('gettext') && is_dir("modules/".$c['module']."/i18n")) {
101         bindtextdomain($c['module'],"modules/".$c['module']."/i18n");
102         bind_textdomain_codeset($c['module'], 'utf8');
103         $name_label = dgettext($c['module'],$name_label_raw);
104         $tt_description = dgettext($c['module'],$description_raw);
105         if ($name_label == $name_label_raw) {
106             $name_label = _($name_label_raw);
107         }
108         if ($tt_description == $description_raw) {
109             $tt_description = _($description_raw);
110         }
111     } else {
112         $name_label = _($name_label_raw);
113         $tt_description = _($description_raw);
114     }
115     if (!$display_friendly_name) {
116         $tr_friendly_name = $name_label;
117         $name_label = $c['keyword'];
118     }
119
120     $row++;
121     $dv = $c['type'] == CONF_TYPE_BOOL ? ($c['defaultval'] ? _("True") : _("False")) : $c['defaultval'];
122     $default_val = $dv == '' ? _("No Default Provided") : sprintf(_("Default Value: %s"),$dv);
123     if ($c['emptyok'] && $c['type'] != CONF_TYPE_BOOL && $c['type'] != CONF_TYPE_SELECT) {
124         $default_val.= ', '._("field can be left blank");
125     }
126     if ($c['type'] == CONF_TYPE_INT && $c['options']) {
127         $range = explode(',',$c['options']);
128         $default_val .= '<br />'.sprintf(_("Acceptable Values: %s - %s"),$range[0],$range[1]);
129     }
130     if ($display_friendly_name) {
131         $default_val .= '<br />'.sprintf(_("Internal Name: %s"),$c['keyword']);
132     } else {
133         $default_val .= '<br />'.sprintf(_("Friendly Name: %s"),$tr_friendly_name);
134     }
135     echo '<tr><td><a href="javascript:void(null)" class="info">'.$name_label.'<span>'.$tt_description.'<br /><br >'.$default_val.'</span></a></td>';
136     echo '<td>';
137     switch ($c['type']) {
138         case CONF_TYPE_TEXT:
139         case CONF_TYPE_DIR:
140         case CONF_TYPE_INT:
141             $readonly = !$c['readonly'] || $amp_conf['AS_OVERRIDE_READONLY'] && !$c['hidden'] ? '' : 'readonly="readonly"';
142             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.'/>';
143             break;
144         case CONF_TYPE_SELECT:
145             echo '<select class="valueinput" id="'.$c['keyword'].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'">';
146                 $opt = explode(',',$c['options']);
147                 foreach($opt as $o) {
148                     $selected = ($amp_conf[$c['keyword']] == $o) ? ' selected ' : '';
149                     echo '<option value="'.$o.'"'.$selected.'>'.$o.'</option>';
150                 }
151             echo '</select>';
152             break;
153         case CONF_TYPE_BOOL:
154 ?>
155             <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\"":""?>/>
156             <label for="<?php echo $c['keyword'] ?>-true"><?php echo _("True") ?></label>
157             <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\"":""?>/>
158             <label for="<?php echo $c['keyword'] ?>-false"><?php echo _("False") ?></label></span>
159 <?php
160             break;
161     }
162     echo '</td>';
163     if(!$c['readonly'] || $amp_conf['AS_OVERRIDE_READONLY'] && !$c['hidden']){
164         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').'"'
165             . ' data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" '
166             . (($amp_conf[$c['keyword']] == $c['defaultval']) ? ' style="display:none" ' : '')
167             .'"></td>';
168         echo '<td class="savetd"><input type="image" class="save" src="images/accept.png" data-key="'
169             . $c['keyword']
170             . '" title="' . _('Save') . '"'
171             . ' data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" '
172             . '></td>';
173     }
174     echo '</tr>';
175 }
176 echo '</table>';
177
178 // Provide enough padding at the bottom (<br />) so that the tooltip from the last setting does not get cut off.
179 ?>
180 <br /><br /> <br />
181 <input type="button" id="page_reload" value="<?php echo _("Refresh Page");?>"/>
182 <br /><br /><br /><br /></div>
Note: See TracBrowser for help on using the browser.