1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
30: function renderSelectProperty($name, $possibleValues, $value, $label) {
31: global $auth;
32:
33: if (count($possibleValues) === 2 && (in_array('true', $possibleValues) && in_array('false', $possibleValues) || in_array('enabled', $possibleValues) && in_array('disabled', $possibleValues) || in_array('0', $possibleValues) && in_array('1', $possibleValues))) {
34:
35: $checked = $value == 'true' || $value == '1' || $value == 'enabled';
36: $html = new cHTMLCheckbox($name, $possibleValues[0], $name, $checked);
37: $html->setLabelText($label);
38: } else {
39:
40: $html = new cHTMLSelectElement('');
41: foreach ($possibleValues as $possibleValue) {
42: $element = new cHTMLOptionElement($possibleValue, $possibleValue);
43: if ($possibleValue == $value) {
44: $element->setSelected(true);
45: }
46: $html->appendOptionElement($element);
47: }
48: }
49:
50:
51: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
52: $html->updateAttribute('disabled', 'true');
53: }
54:
55: $return = array();
56: $return['input'] = $html->render();
57: $return['label'] = '';
58:
59: return $return;
60: }
61:
62: 63: 64: 65: 66: 67: 68: 69: 70: 71:
72: function renderLabel($text, $name, $width = 250, $seperator = ':') {
73: $label = new cHTMLLabel($text . $seperator, $name);
74: $label->setClass("sys_config_txt_lbl");
75: $label->setStyle('width:' . $width . 'px;');
76:
77: return $label->render();
78: }
79:
80: 81: 82: 83: 84: 85: 86: 87: 88: 89:
90: function renderTextProperty($name, $value, $label, $password = false) {
91: global $auth;
92:
93: $textbox = new cHTMLTextbox($name, conHtmlSpecialChars($value), '50', '96');
94:
95: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
96: $textbox->updateAttribute('disabled', 'true');
97: }
98: if ($password === true) {
99: $textbox->updateAttribute('type', 'password');
100: }
101:
102: $return = array();
103: $return['input'] = $textbox->render();
104: $return['label'] = renderLabel($label, $name);
105:
106: return $return;
107: }
108:
109: $page = new cGuiPage('system_configuration', '', '1');
110:
111:
112: $propertyTypes = cXmlReader::xmlStringToArray(cFileHandler::read($cfg['path']['xml'] . 'system.xml'));
113: $propertyTypes = $propertyTypes['properties'];
114:
115:
116: $settings = getSystemProperties();
117:
118: $reloadHeader = false;
119:
120: if (isset($_POST['action']) && $_POST['action'] == 'edit_sysconf' && $perm->have_perm_area_action($area, 'edit_sysconf')) {
121: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
122: $page->displayError(i18n('You don\'t have the permission to make changes here.'));
123: } else {
124:
125: if (defined('CON_STRIPSLASHES')) {
126: $post = cString::stripSlashes($_POST);
127: } else {
128: $post = $_POST;
129: }
130: $stored = false;
131: foreach ($propertyTypes as $type => $properties) {
132: foreach ($properties as $name => $infos) {
133:
134: $fieldName = $type . '{_}' . $name;
135: if (isset($post[$fieldName])) {
136: $value = $post[$fieldName];
137: } else {
138: $value = (isset($infos['values'][1])) ? $infos['values'][1] : 'false';
139: }
140:
141: $storedValue = $settings[$type][$name];
142: if ($storedValue != $value && (is_array($infos['values']) && $value != '' || !is_array($infos['values']))) {
143: if ($type == 'update' && $name == 'check_period' && $value < 60) {
144: $page->displayError(i18n('Update check period must be at least 60 minutes.'));
145: $stored = false;
146:
147: break 2;
148: } else {
149: setSystemProperty($type, $name, $value);
150:
151: $settings[$type][$name] = $value;
152: $stored = true;
153:
154: if (($type == 'debug' && $name == 'debug_to_screen') || ($type == 'system' && $name == 'clickmenu')) {
155: $reloadHeader = true;
156: }
157: }
158: }
159: }
160: }
161: if ($stored) {
162: $page->displayInfo(i18n('Changes saved'));
163: }
164: }
165: }
166:
167:
168: $form = new cGuiTableForm('system_configuration');
169: $form->addHeader(i18n('System configuration'));
170: $form->setVar('area', $area);
171: $form->setVar('frame', $frame);
172: $form->setVar('action', 'edit_sysconf');
173:
174:
175: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
176: $form->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok_off.gif', i18n("You are not sysadmin. You can't change these settings."), 's');
177: }
178:
179: $groups = array();
180: $currentGroup = '';
181: $leftContent = '';
182:
183: foreach ($propertyTypes as $type => $properties) {
184: foreach ($properties as $name => $infos) {
185:
186:
187: if (!isset($groups[$infos['group']])) {
188: $groups[$infos['group']] = '';
189: }
190:
191:
192: if (isset($settings[$type][$name])) {
193: $value = $settings[$type][$name];
194: } else {
195: $value = '';
196: }
197:
198:
199: $fieldName = $type . '{_}' . $name;
200: if (is_array($infos['values'])) {
201: $htmlElement = renderSelectProperty($fieldName, $infos['values'], $value, i18n($infos['label']));
202: } else {
203: if (strlen($name) > 5 && substr($name, -5) === '_pass') {
204: $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']), true);
205: } else {
206: $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']));
207: }
208: }
209:
210: $groups[$infos['group']] .= new cHTMLDiv($htmlElement['label'] . $htmlElement['input'], 'systemSetting');
211: }
212: }
213:
214:
215: foreach ($groups as $groupName => $groupSettings) {
216: $groupName = i18n($groupName);
217: $form->add(renderLabel($groupName, '', 150, ''), $groupSettings);
218: }
219:
220:
221: if ($perm->have_perm_area_action($area, 'edit_sysconf')) {
222: $page->set('s', 'RELOAD_HEADER', ($reloadHeader) ? 'true' : 'false');
223: $page->set('s', 'FORM', $form->render());
224: } else {
225: $page->displayCriticalError(i18n('Access denied'));
226: }
227:
228: $page->render();
229:
230: