1 | <?php |
||
2 | /* |
||
3 | * You may not change or alter any portion of this comment or credits |
||
4 | * of supporting developers from this source code or any supporting source code |
||
5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | * |
||
7 | * This program is distributed in the hope that it will be useful, |
||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * @copyright XOOPS Project http://xoops.org/ |
||
14 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
15 | * @package |
||
16 | * @since |
||
17 | * @author XOOPS Development Team, Kazumi Ono (AKA onokazu) |
||
18 | */ |
||
19 | use Xmf\Request; |
||
20 | |||
21 | // Check users rights |
||
22 | if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
||
23 | exit(_NOPERM); |
||
24 | } |
||
25 | |||
26 | if (isset($_REQUEST)) { |
||
27 | foreach ($_REQUEST as $k => $v) { |
||
28 | ${$k} = $v; |
||
29 | } |
||
30 | } |
||
31 | // Get Action type |
||
32 | $op = Request::getString('op', 'default'); |
||
33 | // Setting type |
||
34 | $confcat_id = Request::getInt('confcat_id', 0); |
||
35 | // Define main template |
||
36 | $GLOBALS['xoopsOption']['template_main'] = 'system_preferences.tpl'; |
||
37 | // Call Header |
||
38 | xoops_cp_header(); |
||
39 | // Define Stylesheet |
||
40 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/admin.css'); |
||
41 | // Define scripts |
||
42 | $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
43 | $xoTheme->addScript('modules/system/js/admin.js'); |
||
44 | |||
45 | $xoBreadCrumb->addLink(_AM_SYSTEM_PREFERENCES_NAV_MAIN, system_adminVersion('preferences', 'adminpath')); |
||
46 | |||
47 | //Display part |
||
48 | switch ($op) { |
||
49 | |||
50 | case 'show': |
||
51 | if (empty($confcat_id)) { |
||
52 | $confcat_id = 1; |
||
53 | } |
||
54 | $confcat_handler = xoops_getHandler('configcategory'); |
||
55 | $confcat = $confcat_handler->get($confcat_id); |
||
56 | if (!is_object($confcat)) { |
||
57 | redirect_header('admin.php?fct=preferences', 1); |
||
58 | } |
||
59 | $xoBreadCrumb->addLink(constant($confcat->getVar('confcat_name'))); |
||
60 | $xoBreadCrumb->addHelp(system_adminVersion('preferences', 'help')); |
||
61 | $xoBreadCrumb->render(); |
||
62 | $xoopsTpl->assign('breadcrumb', 1); |
||
63 | |||
64 | $form = new XoopsThemeForm(constant($confcat->getVar('confcat_name')), 'pref_form', 'admin.php?fct=preferences', 'post', true); |
||
65 | /* @var XoopsConfigHandler $config_handler */ |
||
66 | $config_handler = xoops_getHandler('config'); |
||
67 | $criteria = new CriteriaCompo(); |
||
68 | $criteria->add(new Criteria('conf_modid', 0)); |
||
69 | $criteria->add(new Criteria('conf_catid', $confcat_id)); |
||
70 | $config = $config_handler->getConfigs($criteria); |
||
71 | $confcount = count($config); |
||
72 | for ($i = 0; $i < $confcount; ++$i) { |
||
73 | $title = constant($config[$i]->getVar('conf_title')); |
||
74 | $desc = ($config[$i]->getVar('conf_desc') != '') ? constant($config[$i]->getVar('conf_desc')) : ''; |
||
75 | |||
76 | switch ($config[$i]->getVar('conf_formtype')) { |
||
77 | |||
78 | case 'textarea': |
||
79 | $myts = MyTextSanitizer::getInstance(); |
||
80 | if ($config[$i]->getVar('conf_valuetype') === 'array') { |
||
81 | // this is exceptional.. only when value type is arrayneed a smarter way for this |
||
82 | $ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50); |
||
83 | } else { |
||
84 | $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput()), 5, 50); |
||
85 | } |
||
86 | break; |
||
87 | |||
88 | case 'select': |
||
89 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
90 | $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
||
91 | $opcount = count($options); |
||
92 | for ($j = 0; $j < $opcount; ++$j) { |
||
93 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
||
94 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
||
95 | $ele->addOption($optval, $optkey); |
||
96 | } |
||
97 | break; |
||
98 | |||
99 | case 'select_multi': |
||
100 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
||
101 | $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
||
102 | $opcount = count($options); |
||
103 | for ($j = 0; $j < $opcount; ++$j) { |
||
104 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
||
105 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
||
106 | $ele->addOption($optval, $optkey); |
||
107 | } |
||
108 | break; |
||
109 | |||
110 | case 'yesno': |
||
111 | $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
||
112 | break; |
||
113 | |||
114 | case 'theme': |
||
115 | case 'theme_multi': |
||
116 | $ele = ($config[$i]->getVar('conf_formtype') !== 'theme_multi') ? new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()) : new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
||
117 | require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
118 | $dirlist = XoopsLists::getThemesList(); |
||
119 | if (!empty($dirlist)) { |
||
120 | asort($dirlist); |
||
121 | $ele->addOptionArray($dirlist); |
||
122 | } |
||
123 | $valueForOutput = $config[$i]->getConfValueForOutput(); |
||
124 | $form->addElement(new XoopsFormHidden('_old_theme', (is_array($valueForOutput) ? $valueForOutput[0] : $valueForOutput))); |
||
125 | break; |
||
126 | |||
127 | case 'tplset': |
||
128 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
129 | $tplset_handler = xoops_getHandler('tplset'); |
||
130 | $tplsetlist = $tplset_handler->getList(); |
||
131 | asort($tplsetlist); |
||
132 | foreach ($tplsetlist as $key => $name) { |
||
133 | $ele->addOption($key, $name); |
||
134 | } |
||
135 | // old theme value is used to determine whether to update cache or not. kind of dirty way |
||
136 | $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput())); |
||
137 | break; |
||
138 | |||
139 | case 'cpanel': |
||
140 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
141 | xoops_load('cpanel', 'system'); |
||
142 | $list = XoopsSystemCpanel::getGuis(); |
||
143 | $ele->addOptionArray($list); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
144 | break; |
||
145 | |||
146 | case 'timezone': |
||
147 | $ele = new XoopsFormSelectTimezone($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
148 | break; |
||
149 | |||
150 | case 'language': |
||
151 | $ele = new XoopsFormSelectLang($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
152 | break; |
||
153 | |||
154 | case 'startpage': |
||
155 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
156 | $module_handler = xoops_getHandler('module'); |
||
157 | $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
||
158 | $criteria->add(new Criteria('isactive', 1)); |
||
159 | $moduleslist = $module_handler->getList($criteria, true); |
||
160 | $moduleslist['--'] = _MD_AM_NONE; |
||
161 | $ele->addOptionArray($moduleslist); |
||
162 | break; |
||
163 | |||
164 | case 'group': |
||
165 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
||
166 | break; |
||
167 | |||
168 | case 'group_multi': |
||
169 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), true, $config[$i]->getConfValueForOutput(), 5, true); |
||
170 | break; |
||
171 | |||
172 | // RMV-NOTIFY - added 'user' and 'user_multi' |
||
173 | case 'user': |
||
174 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
||
175 | break; |
||
176 | |||
177 | case 'user_multi': |
||
178 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
||
179 | break; |
||
180 | |||
181 | case 'module_cache': |
||
182 | $module_handler = xoops_getHandler('module'); |
||
183 | $modules = $module_handler->getObjects(new Criteria('hasmain', 1), true); |
||
184 | $currrent_val = $config[$i]->getConfValueForOutput(); |
||
185 | $cache_options = array( |
||
186 | '0' => _NOCACHE, |
||
187 | '30' => sprintf(_SECONDS, 30), |
||
188 | '60' => _MINUTE, |
||
189 | '300' => sprintf(_MINUTES, 5), |
||
190 | '1800' => sprintf(_MINUTES, 30), |
||
191 | '3600' => _HOUR, |
||
192 | '18000' => sprintf(_HOURS, 5), |
||
193 | '86400' => _DAY, |
||
194 | '259200' => sprintf(_DAYS, 3), |
||
195 | '604800' => _WEEK); |
||
196 | if (count($modules) > 0) { |
||
197 | $ele = new XoopsFormElementTray($title, '<br>'); |
||
198 | foreach (array_keys($modules) as $mid) { |
||
199 | $c_val = isset($currrent_val[$mid]) ? (int)$currrent_val[$mid] : null; |
||
200 | $selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name') . "[$mid]", $c_val); |
||
201 | $selform->addOptionArray($cache_options); |
||
202 | $ele->addElement($selform); |
||
203 | unset($selform); |
||
204 | } |
||
205 | } else { |
||
206 | $ele = new XoopsFormLabel($title, _MD_AM_NOMODULE); |
||
207 | } |
||
208 | break; |
||
209 | |||
210 | case 'site_cache': |
||
211 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
212 | $ele->addOptionArray(array( |
||
213 | '0' => _NOCACHE, |
||
214 | '30' => sprintf(_SECONDS, 30), |
||
215 | '60' => _MINUTE, |
||
216 | '300' => sprintf(_MINUTES, 5), |
||
217 | '1800' => sprintf(_MINUTES, 30), |
||
218 | '3600' => _HOUR, |
||
219 | '18000' => sprintf(_HOURS, 5), |
||
220 | '86400' => _DAY, |
||
221 | '259200' => sprintf(_DAYS, 3), |
||
222 | '604800' => _WEEK)); |
||
223 | break; |
||
224 | |||
225 | case 'password': |
||
226 | $myts = MyTextSanitizer::getInstance(); |
||
227 | $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
228 | break; |
||
229 | |||
230 | case 'color': |
||
231 | $myts = MyTextSanitizer::getInstance(); |
||
232 | $ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
233 | break; |
||
234 | |||
235 | case 'hidden': |
||
236 | $myts = MyTextSanitizer::getInstance(); |
||
237 | $ele = new XoopsFormHidden($config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
238 | break; |
||
239 | |||
240 | case 'textbox': |
||
241 | default: |
||
242 | $myts = MyTextSanitizer::getInstance(); |
||
243 | $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
244 | break; |
||
245 | |||
246 | } |
||
247 | $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
||
248 | $ele->setDescription($desc); |
||
249 | $form->addElement($ele); |
||
250 | $form->addElement($hidden); |
||
251 | unset($ele, $hidden); |
||
252 | } |
||
253 | $form->addElement(new XoopsFormHidden('op', 'save')); |
||
254 | $form->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); |
||
255 | $form->display(); |
||
256 | break; |
||
257 | |||
258 | case 'showmod': |
||
259 | |||
260 | /* @var XoopsConfigHandler $config_handler */ |
||
261 | $config_handler = xoops_getHandler('config'); |
||
262 | $mod = isset($_REQUEST['mod']) ? (int)$_REQUEST['mod'] : 0; |
||
263 | if ($mod <= 0) { |
||
264 | header('Location: admin.php?fct=preferences'); |
||
265 | exit(); |
||
266 | } |
||
267 | $config = $config_handler->getConfigs(new Criteria('conf_modid', $mod)); |
||
268 | $count = count($config); |
||
269 | if ($count < 1) { |
||
270 | redirect_header('admin.php?fct=preferences', 1); |
||
271 | } |
||
272 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
273 | $form = new XoopsThemeForm(_MD_AM_MODCONFIG, 'pref_form', 'admin.php?fct=preferences', 'post', true); |
||
274 | $module_handler = xoops_getHandler('module'); |
||
275 | $module = $module_handler->get($mod); |
||
276 | |||
277 | xoops_loadLanguage('modinfo', $module->getVar('dirname')); |
||
278 | |||
279 | // if has comments feature, need comment lang file |
||
280 | if ($module->getVar('hascomments') == 1) { |
||
281 | xoops_loadLanguage('comment'); |
||
282 | } |
||
283 | // RMV-NOTIFY |
||
284 | // if has notification feature, need notification lang file |
||
285 | if ($module->getVar('hasnotification') == 1) { |
||
286 | xoops_loadLanguage('notification'); |
||
287 | } |
||
288 | |||
289 | $modname = $module->getVar('name'); |
||
290 | if (!empty($_REQUEST['redirect'])) { |
||
291 | $myts = MyTextSanitizer::getInstance(); |
||
292 | $form->addElement(new XoopsFormHidden('redirect', $myts->htmlSpecialChars($_REQUEST['redirect']))); |
||
293 | } elseif ($module->getInfo('adminindex')) { |
||
294 | $form->addElement(new XoopsFormHidden('redirect', XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $module->getInfo('adminindex'))); |
||
295 | } |
||
296 | for ($i = 0; $i < $count; ++$i) { |
||
297 | $title = constant($config[$i]->getVar('conf_title')); |
||
298 | $description = defined($config[$i]->getVar('conf_desc')) ? constant($config[$i]->getVar('conf_desc')) : ''; |
||
299 | switch ($config[$i]->getVar('conf_formtype')) { |
||
300 | |||
301 | case 'textarea': |
||
302 | $myts = MyTextSanitizer::getInstance(); |
||
303 | if ($config[$i]->getVar('conf_valuetype') === 'array') { |
||
304 | // this is exceptional.. only when value type is arrayneed a smarter way for this |
||
305 | $ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50); |
||
306 | } else { |
||
307 | $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput()), 5, 50); |
||
308 | } |
||
309 | break; |
||
310 | |||
311 | case 'select': |
||
312 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
||
313 | $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
||
314 | $opcount = count($options); |
||
315 | for ($j = 0; $j < $opcount; ++$j) { |
||
316 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
||
317 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
||
318 | $ele->addOption($optval, $optkey); |
||
319 | } |
||
320 | break; |
||
321 | |||
322 | case 'select_multi': |
||
323 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
||
324 | $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
||
325 | $opcount = count($options); |
||
326 | for ($j = 0; $j < $opcount; ++$j) { |
||
327 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
||
328 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
||
329 | $ele->addOption($optval, $optkey); |
||
330 | } |
||
331 | break; |
||
332 | |||
333 | case 'yesno': |
||
334 | $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
||
335 | break; |
||
336 | |||
337 | case 'group': |
||
338 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
339 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
||
340 | break; |
||
341 | |||
342 | case 'group_multi': |
||
343 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
344 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
||
345 | break; |
||
346 | |||
347 | // RMV-NOTIFY: added 'user' and 'user_multi' |
||
348 | case 'user': |
||
349 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
350 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
||
351 | break; |
||
352 | |||
353 | case 'user_multi': |
||
354 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
355 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
||
356 | break; |
||
357 | |||
358 | case 'password': |
||
359 | $myts = MyTextSanitizer::getInstance(); |
||
360 | $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
361 | break; |
||
362 | |||
363 | case 'color': |
||
364 | $myts = MyTextSanitizer::getInstance(); |
||
365 | $ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
366 | break; |
||
367 | |||
368 | case 'hidden': |
||
369 | $myts = MyTextSanitizer::getInstance(); |
||
370 | $ele = new XoopsFormHidden($config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
371 | break; |
||
372 | |||
373 | case 'line_break': |
||
374 | $myts = MyTextSanitizer::getInstance(); |
||
375 | $form->insertBreak('<div style="text-align:center">' . $title . '</div>', $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
376 | break; |
||
377 | |||
378 | case 'textbox': |
||
379 | default: |
||
380 | $myts = MyTextSanitizer::getInstance(); |
||
381 | $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); |
||
382 | break; |
||
383 | |||
384 | } |
||
385 | if (isset($ele)) { |
||
386 | $ele->setDescription($description); |
||
387 | $form->addElement($ele); |
||
388 | } |
||
389 | $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
||
390 | $form->addElement($hidden); |
||
391 | unset($ele, $hidden); |
||
392 | } |
||
393 | $form->addElement(new XoopsFormHidden('op', 'save')); |
||
394 | $form->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); |
||
395 | if ($module->getVar('name') === 'System') { |
||
396 | // Define Breadcrumb |
||
397 | $xoBreadCrumb->addLink(_AM_SYSTEM_PREFERENCES_SETTINGS); |
||
398 | $xoBreadCrumb->render(); |
||
399 | $xoopsTpl->assign('breadcrumb', 1); |
||
400 | } else { |
||
401 | if ($module->getInfo('adminindex')) { |
||
402 | echo '<a href="' . XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $module->getInfo('adminindex') . '">' . $module->getVar('name') . '</a> <span style="font-weight:bold;">»</span> ' . _PREFERENCES . '<br><br>'; |
||
403 | } else { |
||
404 | echo $module->getVar('name') . ' <span style="font-weight:bold;">»</span> ' . _PREFERENCES . '<br><br>'; |
||
405 | } |
||
406 | } |
||
407 | $form->display(); |
||
408 | break; |
||
409 | |||
410 | case 'save': |
||
411 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
412 | redirect_header('admin.php?fct=preferences', 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||
413 | } |
||
414 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
415 | $xoopsTpl = new XoopsTpl(); |
||
416 | $count = count($conf_ids); |
||
417 | $tpl_updated = false; |
||
418 | $theme_updated = false; |
||
419 | $startmod_updated = false; |
||
420 | $lang_updated = false; |
||
421 | if ($count > 0) { |
||
422 | for ($i = 0; $i < $count; ++$i) { |
||
423 | $config = $config_handler->getConfig($conf_ids[$i]); |
||
424 | $new_value =& ${$config->getVar('conf_name')}; |
||
425 | if (is_array($new_value) || $new_value != $config->getVar('conf_value')) { |
||
426 | // if language has been changed |
||
427 | if (!$lang_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') === 'language') { |
||
428 | $xoopsConfig['language'] = ${$config->getVar('conf_name')}; |
||
429 | $lang_updated = true; |
||
430 | } |
||
431 | |||
432 | // if default theme has been changed |
||
433 | if (!$theme_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') === 'theme_set') { |
||
434 | /* @var XoopsMemberHandler $member_handler */ |
||
435 | $member_handler = xoops_getHandler('member'); |
||
436 | $member_handler->updateUsersByField('theme', ${$config->getVar('conf_name')}); |
||
437 | $theme_updated = true; |
||
438 | } |
||
439 | //todo: remove this code since it is not used anymore. |
||
440 | // if default template set has been changed |
||
441 | if (!$tpl_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') === 'template_set') { |
||
442 | // clear cached/compiled files and regenerate them if default theme has been changed |
||
443 | if ($xoopsConfig['template_set'] != ${$config->getVar('conf_name')}) { |
||
444 | $newtplset = ${$config->getVar('conf_name')}; |
||
445 | |||
446 | // clear all compiled and cachedfiles |
||
447 | $xoopsTpl->clear_compiled_tpl(); |
||
448 | |||
449 | // generate compiled files for the new theme |
||
450 | // block files only for now.. |
||
451 | $tplfile_handler = xoops_getHandler('tplfile'); |
||
452 | $dtemplates = $tplfile_handler->find('default', 'block'); |
||
453 | $dcount = count($dtemplates); |
||
454 | |||
455 | // need to do this to pass to xoops_template_touch function |
||
456 | $GLOBALS['xoopsConfig']['template_set'] = $newtplset; |
||
457 | |||
458 | for ($j = 0; $j < $dcount; ++$j) { |
||
459 | $found = $tplfile_handler->find($newtplset, 'block', $dtemplates[$j]->getVar('tpl_refid'), null); |
||
460 | if (count($found) > 0) { |
||
461 | // template for the new theme found, compile it |
||
462 | xoops_template_touch($found[0]->getVar('tpl_id')); |
||
463 | } else { |
||
464 | // not found, so compile 'default' template file |
||
465 | xoops_template_touch($dtemplates[$j]->getVar('tpl_id')); |
||
466 | } |
||
467 | } |
||
468 | |||
469 | // generate image cache files from image binary data, save them under cache/ |
||
470 | $image_handler = xoops_getHandler('imagesetimg'); |
||
471 | $imagefiles = $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true); |
||
472 | foreach (array_keys($imagefiles) as $j) { |
||
473 | if (!$fp = fopen(XOOPS_CACHE_PATH . '/' . $newtplset . '_' . $imagefiles[$j]->getVar('imgsetimg_file'), 'wb')) { |
||
474 | } else { |
||
475 | fwrite($fp, $imagefiles[$j]->getVar('imgsetimg_body')); |
||
476 | fclose($fp); |
||
477 | } |
||
478 | } |
||
479 | } |
||
480 | $tpl_updated = true; |
||
481 | } |
||
482 | |||
483 | // add read permission for the start module to all groups |
||
484 | if (!$startmod_updated && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') === 'startpage') { |
||
485 | /* @var XoopsMemberHandler $member_handler */ |
||
486 | $member_handler = xoops_getHandler('member'); |
||
487 | $groups = $member_handler->getGroupList(); |
||
488 | /* @var XoopsGroupPermHandler $moduleperm_handler */ |
||
489 | $moduleperm_handler = xoops_getHandler('groupperm'); |
||
490 | $module_handler = xoops_getHandler('module'); |
||
491 | $module = $module_handler->getByDirname($new_value); |
||
492 | foreach ($groups as $groupid => $groupname) { |
||
493 | if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groupid)) { |
||
494 | $moduleperm_handler->addRight('module_read', $module->getVar('mid'), $groupid); |
||
495 | } |
||
496 | } |
||
497 | $startmod_updated = true; |
||
498 | } |
||
499 | |||
500 | $config->setConfValueForInput($new_value); |
||
501 | $config_handler->insertConfig($config); |
||
502 | } |
||
503 | unset($new_value); |
||
504 | } |
||
505 | } |
||
506 | |||
507 | if (!empty($use_mysession) && $xoopsConfig['use_mysession'] == 0 && $session_name != '') { |
||
508 | setcookie($session_name, session_id(), time() + (60 * (int)$session_expire), '/', XOOPS_COOKIE_DOMAIN, 0); |
||
509 | } |
||
510 | |||
511 | // Clean cached files, may take long time |
||
512 | // User register_shutdown_function to keep running after connection closes so that cleaning cached files can be finished |
||
513 | // Cache management should be performed on a separate page |
||
514 | require_once XOOPS_ROOT_PATH . '/modules/system/class/maintenance.php'; |
||
515 | $maintenance = new SystemMaintenance(); |
||
516 | $options = array(1,2,3); // smarty_cache and Smarty_compile |
||
517 | register_shutdown_function(array(&$maintenance, 'CleanCache'), $options); |
||
518 | |||
519 | if ($lang_updated) { |
||
520 | // Flush cache files for cpanel GUIs |
||
521 | xoops_load('cpanel', 'system'); |
||
522 | XoopsSystemCpanel::flush(); |
||
523 | } |
||
524 | |||
525 | if (isset($redirect) && $redirect != '') { |
||
526 | redirect_header($redirect, 2, _AM_SYSTEM_DBUPDATED); |
||
527 | } else { |
||
528 | redirect_header('admin.php?fct=preferences', 2, _AM_SYSTEM_DBUPDATED); |
||
529 | } |
||
530 | break; |
||
531 | |||
532 | default: |
||
533 | // Display setting cats |
||
534 | $xoBreadCrumb->addTips(_AM_SYSTEM_PREFERENCES_NAV_TIPS); |
||
535 | $xoBreadCrumb->addHelp(system_adminVersion('preferences', 'help')); |
||
536 | $xoBreadCrumb->render(); |
||
537 | |||
538 | $confcat_handler = xoops_getHandler('configcategory'); |
||
539 | $confcats = $confcat_handler->getObjects(); |
||
540 | $image = system_adminVersion('preferences', 'configcat'); |
||
541 | $count_prefs = 1; |
||
542 | $nbcolonnes_pref = 5; |
||
543 | foreach (array_keys($confcats) as $i) { |
||
544 | $preferences['id'] = $confcats[$i]->getVar('confcat_id'); |
||
545 | $preferences['image'] = system_AdminIcons('xoops/' . $image[$i]); |
||
546 | $preferences['name'] = constant($confcats[$i]->getVar('confcat_name')); |
||
547 | ++$count_prefs; |
||
548 | $preferences['newline'] = ($count_prefs % $nbcolonnes_pref == 1);// ? true : false; |
||
549 | $xoopsTpl->assign('newline', $preferences['newline']); |
||
550 | |||
551 | $xoopsTpl->append_by_ref('preferences', $preferences); |
||
552 | unset($preferences); |
||
553 | } |
||
554 | $xoopsTpl->assign('menu', 1); |
||
555 | $xoopsTpl->assign('breadcrumb', 1); |
||
556 | break; |
||
557 | } |
||
558 | // Call Footer |
||
559 | xoops_cp_footer(); |
||
560 |