source: temp/test-xoops.ec-cube.net/html/modules/rssj/include/preferences.inc.php @ 405

Revision 405, 25.0 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: main.php,v 1.23.20.1 2004/07/29 18:22:38 mithyt2 Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27// Author: Kazumi Ono (AKA onokazu)                                          //
28// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
29// Project: The XOOPS Project                                                //
30// ------------------------------------------------------------------------- //
31
32if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
33  exit("Access Denied");
34} else {
35  $op = 'list';
36  if ( !empty($_POST['op']) ) { $op = $_POST['op']; }
37  if (isset($_GET['op'])) {
38    $op = trim($_GET['op']);
39  }
40  if (isset($_GET['confcat_id'])) {
41    $confcat_id = intval($_GET['confcat_id']);
42  }
43/*  if ($op == 'list') {
44    $confcat_handler =& xoops_gethandler('configcategory');
45    $confcats =& $confcat_handler->getObjects();
46    $catcount = count($confcats);
47    xoops_cp_header();
48    echo '<h4 style="text-align:left">'._MD_AM_SITEPREF.'</h4><ul>';
49    for ($i = 0; $i < $catcount; $i++) {
50      echo '<li>'.constant($confcats[$i]->getVar('confcat_name')).' [<a href="admin.php?fct=preferences&amp;op=show&amp;confcat_id='.$confcats[$i]->getVar('confcat_id').'">'._EDIT.'</a>]</li>';
51    }
52    echo '</ul>';
53    xoops_cp_footer();
54    exit();
55  } */
56
57/*   if ($op == 'show') {
58    if (empty($confcat_id)) {
59      $confcat_id = 1;
60    }
61    $confcat_handler =& xoops_gethandler('configcategory');
62    $confcat =& $confcat_handler->get($confcat_id);
63    if (!is_object($confcat)) {
64      redirect_header('admin.php?fct=preferences', 1);
65    }
66    include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
67    include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
68    $form = new XoopsThemeForm(constant($confcat->getVar('confcat_name')), 'pref_form', 'admin.php?fct=preferences');
69    $config_handler =& xoops_gethandler('config');
70    $criteria = new CriteriaCompo();
71    $criteria->add(new Criteria('conf_modid', 0));
72    $criteria->add(new Criteria('conf_catid', $confcat_id));
73    $config =& $config_handler->getConfigs($criteria);
74    $confcount = count($config);
75    for ($i = 0; $i < $confcount; $i++) {
76      $title = (!defined($config[$i]->getVar('conf_desc')) || constant($config[$i]->getVar('conf_desc')) == '') ? constant($config[$i]->getVar('conf_title')) : constant($config[$i]->getVar('conf_title')).'<br /><br /><span style="font-weight:normal;">'.constant($config[$i]->getVar('conf_desc')).'</span>';
77      switch ($config[$i]->getVar('conf_formtype')) {
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      case 'select':
88        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
89        $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
90        $opcount = count($options);
91        for ($j = 0; $j < $opcount; $j++) {
92          $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
93          $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
94          $ele->addOption($optval, $optkey);
95        }
96        break;
97      case 'select_multi':
98        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
99        $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
100        $opcount = count($options);
101        for ($j = 0; $j < $opcount; $j++) {
102          $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
103          $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
104          $ele->addOption($optval, $optkey);
105        }
106        break;
107      case 'yesno':
108        $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
109        break;
110      case 'theme':
111      case 'theme_multi':
112        $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);
113        $handle = opendir(XOOPS_THEME_PATH.'/');
114        $dirlist = array();
115        while (false !== ($file = readdir($handle))) {
116          if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/",$file) && strtolower($file) != 'cvs') {
117            $dirlist[$file]=$file;
118          }
119        }
120        closedir($handle);
121        if (!empty($dirlist)) {
122          asort($dirlist);
123          $ele->addOptionArray($dirlist);
124        }
125        //$themeset_handler =& xoops_gethandler('themeset');
126        //$themesetlist =& $themeset_handler->getList();
127        //asort($themesetlist);
128        //foreach ($themesetlist as $key => $name) {
129        //  $ele->addOption($key, $name.' ('._MD_AM_THEMESET.')');
130        //}
131        // old theme value is used to determine whether to update cache or not. kind of dirty way
132        $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
133        break;
134      case 'tplset':
135        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
136        $tplset_handler =& xoops_gethandler('tplset');
137        $tplsetlist =& $tplset_handler->getList();
138        asort($tplsetlist);
139        foreach ($tplsetlist as $key => $name) {
140          $ele->addOption($key, $name);
141        }
142        // old theme value is used to determine whether to update cache or not. kind of dirty way
143        $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
144        break;
145      case 'timezone':
146        $ele = new XoopsFormSelectTimezone($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
147        break;
148      case 'language':
149        $ele = new XoopsFormSelectLang($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
150        break;
151      case 'startpage':
152        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
153        $module_handler =& xoops_gethandler('module');
154        $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
155        $criteria->add(new Criteria('isactive', 1));
156        $moduleslist =& $module_handler->getList($criteria, true);
157        $moduleslist['--'] = _MD_AM_NONE;
158        $ele->addOptionArray($moduleslist);
159        break;
160      case 'group':
161        $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
162        break;
163      case 'group_multi':
164        $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
165        break;
166      // RMV-NOTIFY - added 'user' and 'user_multi'
167      case 'user':
168        $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
169        break;
170      case 'user_multi':
171        $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
172        break;
173      case 'module_cache':
174        $module_handler =& xoops_gethandler('module');
175        $modules =& $module_handler->getObjects(new Criteria('hasmain', 1), true);
176        $currrent_val = $config[$i]->getConfValueForOutput();
177        $cache_options = array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK);
178        if (count($modules) > 0) {
179          $ele = new XoopsFormElementTray($title, '<br />');
180          foreach (array_keys($modules) as $mid) {
181            $c_val = isset($currrent_val[$mid]) ? intval($currrent_val[$mid]) : null;
182            $selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name')."[$mid]", $c_val);
183            $selform->addOptionArray($cache_options);
184            $ele->addElement($selform);
185            unset($selform);
186          }
187        } else {
188          $ele = new XoopsFormLabel($title, _MD_AM_NOMODULE);
189        }
190        break;
191      case 'site_cache':
192        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
193        $ele->addOptionArray(array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK));
194        break;
195      case 'password':
196        $myts =& MyTextSanitizer::getInstance();
197        $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
198        break;
199      case 'textbox':
200      default:
201        $myts =& MyTextSanitizer::getInstance();
202        $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
203        break;
204      }
205      $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id'));
206      $form->addElement($ele);
207      $form->addElement($hidden);
208      unset($ele);
209      unset($hidden);
210    }
211    $form->addElement(new XoopsFormHidden('op', 'save'));
212    $form->addElement( $xoopsGTicket->getTicketXoopsForm( __LINE__ ) );
213    $form->addElement(new XoopsFormButton('', 'button', _GO, 'submit'));
214    xoops_cp_header();
215    echo '<a href="admin.php?fct=preferences">'. _MD_AM_PREFMAIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.constant($confcat->getVar('confcat_name')).'<br /><br />';
216    $form->display();
217    xoops_cp_footer();
218    exit();
219  } */
220
221  if ($op == 'showmod') {
222    $config_handler =& xoops_gethandler('config');
223    $mod = isset($_GET['mod']) ? intval($_GET['mod']) : 0;
224    if (empty($mod)) {
225      header('Location: admin.php?fct=preferences');
226      exit();
227    }
228    $config =& $config_handler->getConfigs(new Criteria('conf_modid', $mod));
229    $count = count($config);
230    if ($count < 1) {
231      redirect_header('admin.php?fct=preferences', 1);
232    }
233    include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
234    $form = new XoopsThemeForm(_MD_AM_MODCONFIG, 'pref_form', 'admin.php?fct=preferences');
235    $module_handler =& xoops_gethandler('module');
236    $module =& $module_handler->get($mod);
237    if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$module->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) {
238      include_once XOOPS_ROOT_PATH.'/modules/'.$module->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php';
239    }
240
241    // if has comments feature, need comment lang file
242    if ($module->getVar('hascomments') == 1) {
243      include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/comment.php';
244    }
245    // RMV-NOTIFY
246    // if has notification feature, need notification lang file
247    if ($module->getVar('hasnotification') == 1) {
248      include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/notification.php';
249    }
250
251    $modname = $module->getVar('name');
252    $button_tray = new XoopsFormElementTray("");
253    if ($module->getInfo('adminindex')) {
254//      $form->addElement(new XoopsFormHidden('redirect', XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$module->getInfo('adminindex')));
255        $button_tray->addElement(new XoopsFormHidden('redirect', XOOPS_URL.'/modules/'.$module->getVar('dirname').'/admin/admin.php?fct=preferences&op=showmod&mod='.$module->getVar('mid'))); // GIJ Patch
256    }
257    for ($i = 0; $i < $count; $i++) {
258      $title4tray = (!defined($config[$i]->getVar('conf_desc')) || constant($config[$i]->getVar('conf_desc')) == '') ? constant($config[$i]->getVar('conf_title')) : constant($config[$i]->getVar('conf_title')).'<br /><br /><span style="font-weight:normal;">'.constant($config[$i]->getVar('conf_desc')).'</span>'; // GIJ
259      $title = '' ; // GIJ
260      switch ($config[$i]->getVar('conf_formtype')) {
261      case 'textarea':
262        $myts =& MyTextSanitizer::getInstance();
263        if ($config[$i]->getVar('conf_valuetype') == 'array') {
264          // this is exceptional.. only when value type is arrayneed a smarter way for this
265          $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);
266        } else {
267          $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50);
268        }
269        break;
270      case 'select':
271        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
272        $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
273        $opcount = count($options);
274        for ($j = 0; $j < $opcount; $j++) {
275          $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
276          $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
277          $ele->addOption($optval, $optkey);
278        }
279        break;
280      case 'select_multi':
281        $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
282        $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
283        $opcount = count($options);
284        for ($j = 0; $j < $opcount; $j++) {
285          $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
286          $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
287          $ele->addOption($optval, $optkey);
288        }
289        break;
290      case 'yesno':
291        $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
292        break;
293      case 'group':
294        include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
295        $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
296        break;
297      case 'group_multi':
298        include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
299        $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
300        break;
301      // RMV-NOTIFY: added 'user' and 'user_multi'
302      case 'user':
303        include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
304        $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
305        break;
306      case 'user_multi':
307        include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
308        $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
309        break;
310      case 'password':
311        $myts =& MyTextSanitizer::getInstance();
312        $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
313        break;
314      case 'textbox':
315      default:
316        $myts =& MyTextSanitizer::getInstance();
317        $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
318        break;
319      }
320      $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id'));
321      $ele_tray = new XoopsFormElementTray( $title4tray , '' ) ;
322      $ele_tray->addElement($ele);
323      $ele_tray->addElement($hidden);
324      $form->addElement( $ele_tray ) ;
325      unset($ele_tray);
326      unset($ele);
327      unset($hidden);
328    }
329    $button_tray->addElement(new XoopsFormHidden('op', 'save'));
330    $button_tray->addElement( $xoopsGTicket->getTicketXoopsForm( __LINE__ ) );
331    $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit'));
332    $form->addElement( $button_tray ) ;
333    xoops_cp_header();
334    // GIJ patch start
335    include( './mymenu.php' ) ;
336    echo "<h3 style='text-align:left;'>".$module->getvar('name').' &nbsp; '._PREFERENCES."</h3>\n" ;
337    // GIJ patch end
338    $form->display();
339    xoops_cp_footer();
340    exit();
341  }
342
343  if ($op == 'save') {
344    //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) {
345    //  exit('Invalid referer');
346    //}
347    if ( ! $xoopsGTicket->check() ) {
348      redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
349    }
350    require_once(XOOPS_ROOT_PATH.'/class/template.php');
351    $xoopsTpl = new XoopsTpl();
352    $xoopsTpl->clear_all_cache();
353    // regenerate admin menu file
354    xoops_module_write_admin_menu(xoops_module_get_admin_menu());
355    if ( !empty($_POST['conf_ids']) ) { $conf_ids = $_POST['conf_ids']; }
356    $count = count($conf_ids);
357    $tpl_updated = false;
358    $theme_updated = false;
359    $startmod_updated = false;
360    $lang_updated = false;
361    if ($count > 0) {
362      for ($i = 0; $i < $count; $i++) {
363        $config =& $config_handler->getConfig($conf_ids[$i]);
364        $new_value =& $_POST[$config->getVar('conf_name')];
365        if (is_array($new_value) || $new_value != $config->getVar('conf_value')) {
366          // if language has been changed
367          if (!$lang_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'language') {
368            // regenerate admin menu file
369            $xoopsConfig['language'] = $_POST[$config->getVar('conf_name')];
370            xoops_module_write_admin_menu(xoops_module_get_admin_menu());
371            $lang_updated = true;
372          }
373
374          // if default theme has been changed
375          if (!$theme_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'theme_set') {
376            $member_handler =& xoops_gethandler('member');
377            $member_handler->updateUsersByField('theme', $_POST[$config->getVar('conf_name')]);
378            $theme_updated = true;
379          }
380
381          // if default template set has been changed
382          if (!$tpl_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'template_set') {
383            // clear cached/compiled files and regenerate them if default theme has been changed
384            if ($xoopsConfig['template_set'] != $_POST[$config->getVar('conf_name')]) {
385              $newtplset = $_POST[$config->getVar('conf_name')];
386             
387              // clear all compiled and cachedfiles
388              $xoopsTpl->clear_compiled_tpl();
389
390              // generate compiled files for the new theme
391              // block files only for now..
392              $tplfile_handler =& xoops_gethandler('tplfile');
393              $dtemplates =& $tplfile_handler->find('default', 'block');
394              $dcount = count($dtemplates);
395
396              // need to do this to pass to xoops_template_touch function
397              $GLOBALS['xoopsConfig']['template_set'] = $newtplset;
398
399              for ($i = 0; $i < $dcount; $i++) {
400                $found =& $tplfile_handler->find($newtplset, 'block', $dtemplates[$i]->getVar('tpl_refid'), null);
401                if (count($found) > 0) {
402                  // template for the new theme found, compile it
403                  xoops_template_touch($found[0]->getVar('tpl_id'));
404                } else {
405                  // not found, so compile 'default' template file
406                  xoops_template_touch($dtemplates[$i]->getVar('tpl_id'));
407                }
408              }
409
410              // generate image cache files from image binary data, save them under cache/
411              $image_handler =& xoops_gethandler('imagesetimg');
412              $imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true);
413              foreach (array_keys($imagefiles) as $i) {
414                if (!$fp = fopen(XOOPS_CACHE_PATH.'/'.$newtplset.'_'.$imagefiles[$i]->getVar('imgsetimg_file'), 'wb')) {
415                } else {
416                  fwrite($fp, $imagefiles[$i]->getVar('imgsetimg_body'));
417                  fclose($fp);
418                }
419              }
420            }
421            $tpl_updated = true;
422          }
423
424          // add read permission for the start module to all groups
425          if (!$startmod_updated  && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'startpage') {
426            $member_handler =& xoops_gethandler('member');
427            $groups =& $member_handler->getGroupList();
428            $moduleperm_handler =& xoops_gethandler('groupperm');
429            $module_handler =& xoops_gethandler('module');
430            $module =& $module_handler->getByDirname($new_value);
431            foreach ($groups as $groupid => $groupname) {
432              if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groupid)) {
433                $moduleperm_handler->addRight('module_read', $module->getVar('mid'), $groupid);
434              }
435            }
436            $startmod_updated = true;
437          }
438
439          $config->setConfValueForInput($new_value);
440          $config_handler->insertConfig($config);
441        }
442        unset($new_value);
443      }
444    }
445    if (!empty($use_mysession) && $xoopsConfig['use_mysession'] == 0 && $session_name != '') {
446        setcookie($session_name, session_id(), time()+(60*intval($session_expire)), '/',  '', 0);
447    }
448    if ( ! empty( $_POST['redirect'] ) ) {
449      redirect_header($_POST['redirect'], 2, _MD_AM_DBUPDATED);
450    } else {
451      redirect_header("admin.php?fct=preferences",2,_MD_AM_DBUPDATED);
452    }
453  }
454}
455
456?>
Note: See TracBrowser for help on using the repository browser.