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, conHtmlSpecialChars($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:
119: if (defined('CON_STRIPSLASHES')) {
120: $post = cString::stripSlashes($_POST);
121: } else {
122: $post = $_POST;
123: }
124: $stored = false;
125: foreach ($propertyTypes as $type => $properties) {
126: foreach ($properties as $name => $infos) {
127:
128: $fieldName = $type . '{_}' . $name;
129: if (isset($post[$fieldName])) {
130: $value = $post[$fieldName];
131: } else {
132: $value = (isset($infos['values'][1])) ? $infos['values'][1] : 'false';
133: }
134:
135: $storedValue = $settings[$type][$name];
136: if ($storedValue != $value && (is_array($infos['values']) && $value != '' || !is_array($infos['values']))) {
137: if ($type == 'update' && $name == 'check_period' && $value < 60) {
138: $page->displayError(i18n('Update check period must be at least 60 minutes.'));
139: $stored = false;
140:
141: break 2;
142: } else {
143: setSystemProperty($type, $name, $value);
144:
145: $settings[$type][$name] = $value;
146: $stored = true;
147:
148: if (($type == 'debug' && $name == 'debug_to_screen') || ($type == 'system' && $name == 'clickmenu')) {
149: $reloadHeader = true;
150: }
151: }
152: }
153: }
154: }
155: if ($stored) {
156: $page->displayInfo(i18n('Changes saved'));
157: }
158: }
159: }
160:
161:
162: $form = new cGuiTableForm('system_configuration');
163: $form->addHeader(i18n('System configuration'));
164: $form->setVar('area', $area);
165: $form->setVar('frame', $frame);
166: $form->setVar('action', 'edit_sysconf');
167:
168:
169: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
170: $form->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok_off.gif', i18n("You are not sysadmin. You can't change these settings."), 's');
171: }
172:
173: $groups = array();
174: $currentGroup = '';
175: $leftContent = '';
176:
177: foreach ($propertyTypes as $type => $properties) {
178: foreach ($properties as $name => $infos) {
179:
180:
181: if (!isset($groups[$infos['group']])) {
182: $groups[$infos['group']] = '';
183: }
184:
185:
186: if (isset($settings[$type][$name])) {
187: $value = $settings[$type][$name];
188: } else {
189: $value = '';
190: }
191:
192:
193: $fieldName = $type . '{_}' . $name;
194: if (is_array($infos['values'])) {
195: $htmlElement = renderSelectProperty($fieldName, $infos['values'], $value, i18n($infos['label']));
196: } else {
197: $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']));
198: }
199:
200: $groups[$infos['group']] .= new cHTMLDiv($htmlElement['label'] . $htmlElement['input'], 'systemSetting');
201: }
202: }
203:
204:
205: foreach ($groups as $groupName => $groupSettings) {
206: $groupName = i18n($groupName);
207: $form->add(renderLabel($groupName, '', 150, ''), $groupSettings);
208: }
209:
210:
211: if ($perm->have_perm_area_action($area, 'edit_sysconf')) {
212: $page->set('s', 'RELOAD_HEADER', ($reloadHeader) ? 'true' : 'false');
213: $page->set('s', 'FORM', $form->render());
214: } else {
215: $page->displayCriticalError(i18n('Access denied'));
216: }
217:
218: $page->render();
219:
220: