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->setStyle('padding:3px;display:block;float:left;width:' . $width . 'px;');
75:
76: return $label->render();
77: }
78:
79: 80: 81: 82: 83: 84: 85: 86: 87:
88: function renderTextProperty($name, $value, $label) {
89: global $auth;
90:
91: $textbox = new cHTMLTextbox($name, $value, '50', '96');
92:
93: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
94: $textbox->updateAttribute('disabled', 'true');
95: }
96: $return = array();
97: $return['input'] = $textbox->render();
98: $return['label'] = renderLabel($label, $name);
99:
100: return $return;
101: }
102:
103: $page = new cGuiPage('system_configuration', '', '1');
104:
105:
106: $propertyTypes = cXmlReader::xmlStringToArray(cFileHandler::read($cfg['path']['xml'] . 'system.xml'));
107: $propertyTypes = $propertyTypes['properties'];
108:
109:
110: $settings = getSystemProperties();
111:
112: $reloadHeader = false;
113:
114: if (isset($_POST['action']) && $_POST['action'] == 'edit_sysconf' && $perm->have_perm_area_action($area, 'edit_sysconf')) {
115: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
116: $page->displayError(i18n('You don\'t have the permission to make changes here.'));
117: } else {
118: $stored = false;
119: foreach ($propertyTypes as $type => $properties) {
120: foreach ($properties as $name => $infos) {
121:
122: $fieldName = $type . '{_}' . $name;
123: if (isset($_POST[$fieldName])) {
124: $value = $_POST[$fieldName];
125: } else {
126: $value = (isset($infos['values'][1])) ? $infos['values'][1] : 'false';
127: }
128:
129: $storedValue = $settings[$type][$name];
130: if ($storedValue != $value && (is_array($infos['values']) && $value != '' || !is_array($infos['values']))) {
131: if ($type == 'update' && $name == 'check_period' && $value < 60) {
132: $page->displayError(i18n('Update check period must be at least 60 minutes.'));
133: $stored = false;
134:
135: break 2;
136: } else {
137: setSystemProperty($type, $name, $value);
138:
139: $settings[$type][$name] = $value;
140: $stored = true;
141:
142: if (($type == 'debug' && $name == 'debug_to_screen') || ($type == 'system' && $name == 'clickmenu')) {
143: $reloadHeader = true;
144: }
145: }
146: }
147: }
148: }
149: if ($stored) {
150: $page->displayInfo(i18n('Changes saved'));
151: }
152: }
153: }
154:
155:
156: $form = new cGuiTableForm('system_configuration');
157: $form->addHeader(i18n('System configuration'));
158: $form->setVar('area', $area);
159: $form->setVar('frame', $frame);
160: $form->setVar('action', 'edit_sysconf');
161:
162:
163: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
164: $form->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok_off.gif', i18n("You are not sysadmin. You can't change these settings."), 's');
165: }
166:
167: $groups = array();
168: $currentGroup = '';
169: $leftContent = '';
170:
171: foreach ($propertyTypes as $type => $properties) {
172: foreach ($properties as $name => $infos) {
173:
174:
175: if (!isset($groups[$infos['group']])) {
176: $groups[$infos['group']] = '';
177: }
178:
179:
180: if (isset($settings[$type][$name])) {
181: $value = $settings[$type][$name];
182: } else {
183: $value = '';
184: }
185:
186:
187: $fieldName = $type . '{_}' . $name;
188: if (is_array($infos['values'])) {
189: $htmlElement = renderSelectProperty($fieldName, $infos['values'], $value, i18n($infos['label']));
190: } else {
191: $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']));
192: }
193:
194: $groups[$infos['group']] .= new cHTMLDiv($htmlElement['label'] . $htmlElement['input'], 'systemSetting');
195: }
196: }
197:
198:
199: foreach ($groups as $groupName => $groupSettings) {
200: $groupName = i18n($groupName);
201: $form->add(renderLabel($groupName, '', 150, ''), $groupSettings);
202: }
203:
204:
205: if ($perm->have_perm_area_action($area, 'edit_sysconf')) {
206: $page->set('s', 'RELOAD_HEADER', ($reloadHeader) ? 'true' : 'false');
207: $page->set('s', 'FORM', $form->render());
208: } else {
209: $page->displayCriticalError(i18n('Access denied'));
210: }
211:
212: $page->render();
213:
214: