[ Index ]
 

Code source de XOOPS 2.0.17.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/htdocs/modules/system/admin/preferences/ -> main.php (source)

   1  <?php
   2  // $Id: main.php 987 2007-08-13 07:34:08Z phppp $

   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  
  32  if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
  33      exit("Access Denied");
  34  } else {
  35      $op = 'list';
  36      if (isset($_POST)) {
  37          foreach ( $_POST as $k => $v ) {
  38              ${$k} = $v;
  39          }
  40      }
  41      if (isset($_GET['op'])) {
  42          $op = trim($_GET['op']);
  43      }
  44  
  45      if (isset($_GET['confcat_id'])) {
  46          $confcat_id = intval($_GET['confcat_id']);
  47      }
  48      if ($op == 'list') {
  49          $confcat_handler = xoops_gethandler('configcategory');
  50          $confcats = $confcat_handler->getObjects();
  51          $catcount = count($confcats);
  52          xoops_cp_header();
  53          echo '<h4 style="text-align:left">'._MD_AM_SITEPREF.'</h4><ul>';
  54          for ($i = 0; $i < $catcount; $i++) {
  55              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>';
  56          }
  57          echo '</ul>';
  58          xoops_cp_footer();
  59          exit();
  60      }
  61  
  62      if ($op == 'show') {
  63          if (empty($confcat_id)) {
  64              $confcat_id = 1;
  65          }
  66          $confcat_handler =& xoops_gethandler('configcategory');
  67          $confcat =& $confcat_handler->get($confcat_id);
  68          if (!is_object($confcat)) {
  69              redirect_header('admin.php?fct=preferences', 1);
  70          }
  71          include_once  XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
  72          include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
  73          $form = new XoopsThemeForm(constant($confcat->getVar('confcat_name')), 'pref_form', 'admin.php?fct=preferences', 'post', true);
  74          $config_handler =& xoops_gethandler('config');
  75          $criteria = new CriteriaCompo();
  76          $criteria->add(new Criteria('conf_modid', 0));
  77          $criteria->add(new Criteria('conf_catid', $confcat_id));
  78          $config = $config_handler->getConfigs($criteria);
  79          $confcount = count($config);
  80          for ($i = 0; $i < $confcount; $i++) {
  81              $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>';
  82              switch ($config[$i]->getVar('conf_formtype')) {
  83              case 'textarea':
  84                  $myts =& MyTextSanitizer::getInstance();
  85                  if ($config[$i]->getVar('conf_valuetype') == 'array') {
  86                      // this is exceptional.. only when value type is arrayneed a smarter way for this

  87                      $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);
  88                  } else {
  89                      $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50);
  90                  }
  91                  break;
  92              case 'select':
  93                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
  94                  $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
  95                  $opcount = count($options);
  96                  for ($j = 0; $j < $opcount; $j++) {
  97                      $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
  98                      $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
  99                      $ele->addOption($optval, $optkey);
 100                  }
 101                  break;
 102              case 'select_multi':
 103                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
 104                  $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
 105                  $opcount = count($options);
 106                  for ($j = 0; $j < $opcount; $j++) {
 107                      $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
 108                      $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
 109                      $ele->addOption($optval, $optkey);
 110                  }
 111                  break;
 112              case 'yesno':
 113                  $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
 114                  break;
 115              case 'theme':
 116              case 'theme_multi':
 117                  $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);
 118                  require_once XOOPS_ROOT_PATH."/class/xoopslists.php";
 119                  $dirlist = XoopsLists::getThemesList();
 120                  if (!empty($dirlist)) {
 121                      asort($dirlist);
 122                      $ele->addOptionArray($dirlist);
 123                  }
 124                  //$themeset_handler =& xoops_gethandler('themeset');

 125                  //$themesetlist =& $themeset_handler->getList();

 126                  //asort($themesetlist);

 127                  //foreach ($themesetlist as $key => $name) {

 128                  //  $ele->addOption($key, $name.' ('._MD_AM_THEMESET.')');

 129                  //}

 130                  // old theme value is used to determine whether to update cache or not. kind of dirty way

 131                  $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
 132                  break;
 133              case 'tplset':
 134                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 135                  $tplset_handler =& xoops_gethandler('tplset');
 136                  $tplsetlist = $tplset_handler->getList();
 137                  asort($tplsetlist);
 138                  foreach ($tplsetlist as $key => $name) {
 139                      $ele->addOption($key, $name);
 140                  }
 141                  // old theme value is used to determine whether to update cache or not. kind of dirty way

 142                  $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
 143                  break;
 144              case 'timezone':
 145                  $ele = new XoopsFormSelectTimezone($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 146                  break;
 147              case 'language':
 148                  $ele = new XoopsFormSelectLang($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 149                  break;
 150              case 'startpage':
 151                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 152                  $module_handler =& xoops_gethandler('module');
 153                  $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
 154                  $criteria->add(new Criteria('isactive', 1));
 155                  $moduleslist = $module_handler->getList($criteria, true);
 156                  $moduleslist['--'] = _MD_AM_NONE;
 157                  $ele->addOptionArray($moduleslist);
 158                  break;
 159              case 'group':
 160                  $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
 161                  break;
 162              case 'group_multi':
 163                  $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
 164                  break;
 165              // RMV-NOTIFY - added 'user' and 'user_multi'

 166              case 'user':
 167                  $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
 168                  break;
 169              case 'user_multi':
 170                  $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
 171                  break;
 172              case 'module_cache':
 173                  $module_handler =& xoops_gethandler('module');
 174                  $modules = $module_handler->getObjects(new Criteria('hasmain', 1), true);
 175                  $currrent_val = $config[$i]->getConfValueForOutput();
 176                  $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);
 177                  if (count($modules) > 0) {
 178                      $ele = new XoopsFormElementTray($title, '<br />');
 179                      foreach (array_keys($modules) as $mid) {
 180                          $c_val = isset($currrent_val[$mid]) ? intval($currrent_val[$mid]) : null;
 181                          $selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name')."[$mid]", $c_val);
 182                          $selform->addOptionArray($cache_options);
 183                          $ele->addElement($selform);
 184                          unset($selform);
 185                      }
 186                  } else {
 187                      $ele = new XoopsFormLabel($title, _MD_AM_NOMODULE);
 188                  }
 189                  break;
 190              case 'site_cache':
 191                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 192                  $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));
 193                  break;
 194              case 'password':
 195                  $myts =& MyTextSanitizer::getInstance();
 196                  $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
 197                  break;
 198              case 'color':
 199                  $myts =& MyTextSanitizer::getInstance();
 200                  $ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
 201                  break;
 202              case 'hidden':
 203                  $myts =& MyTextSanitizer::getInstance();
 204                  $ele = new XoopsFormHidden( $config[$i]->getVar('conf_name'), $myts->htmlspecialchars( $config[$i]->getConfValueForOutput() ) );
 205                  break;
 206              case 'textbox':
 207              default:
 208                  $myts =& MyTextSanitizer::getInstance();
 209                  $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
 210                  break;
 211              }
 212              $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id'));
 213              $form->addElement($ele);
 214              $form->addElement($hidden);
 215              unset($ele);
 216              unset($hidden);
 217          }
 218          $form->addElement(new XoopsFormHidden('op', 'save'));
 219          $form->addElement(new XoopsFormButton('', 'button', _GO, 'submit'));
 220          xoops_cp_header();
 221          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 />';
 222          $form->display();
 223          xoops_cp_footer();
 224          exit();
 225      }
 226  
 227      if ($op == 'showmod') {
 228          $config_handler =& xoops_gethandler('config');
 229          $mod = isset($_GET['mod']) ? intval($_GET['mod']) : 0;
 230          if (empty($mod)) {
 231              header('Location: admin.php?fct=preferences');
 232              exit();
 233          }
 234          $config = $config_handler->getConfigs(new Criteria('conf_modid', $mod));
 235          $count = count($config);
 236          if ($count < 1) {
 237              redirect_header('admin.php?fct=preferences', 1);
 238          }
 239          include_once  XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
 240          $form = new XoopsThemeForm(_MD_AM_MODCONFIG, 'pref_form', 'admin.php?fct=preferences', 'post', true);
 241          $module_handler =& xoops_gethandler('module');
 242          $module =& $module_handler->get($mod);
 243          if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$module->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) {
 244              include_once XOOPS_ROOT_PATH.'/modules/'.$module->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php';
 245          }
 246  
 247          // if has comments feature, need comment lang file

 248          if ($module->getVar('hascomments') == 1) {
 249              include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/comment.php';
 250          }
 251          // RMV-NOTIFY

 252          // if has notification feature, need notification lang file

 253          if ($module->getVar('hasnotification') == 1) {
 254              include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/notification.php';
 255          }
 256  
 257          $modname = $module->getVar('name');
 258          if ($module->getInfo('adminindex')) {
 259              $form->addElement(new XoopsFormHidden('redirect', XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$module->getInfo('adminindex')));
 260          }
 261          for ($i = 0; $i < $count; $i++) {
 262              $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>';
 263              switch ($config[$i]->getVar('conf_formtype')) {
 264              case 'textarea':
 265                  $myts =& MyTextSanitizer::getInstance();
 266                  if ($config[$i]->getVar('conf_valuetype') == 'array') {
 267                      // this is exceptional.. only when value type is arrayneed a smarter way for this

 268                      $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);
 269                  } else {
 270                      $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50);
 271                  }
 272                  break;
 273              case 'select':
 274                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 275                  $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
 276                  $opcount = count($options);
 277                  for ($j = 0; $j < $opcount; $j++) {
 278                      $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
 279                      $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
 280                      $ele->addOption($optval, $optkey);
 281                  }
 282                  break;
 283              case 'select_multi':
 284                  $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
 285                  $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
 286                  $opcount = count($options);
 287                  for ($j = 0; $j < $opcount; $j++) {
 288                      $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
 289                      $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
 290                      $ele->addOption($optval, $optkey);
 291                  }
 292                  break;
 293              case 'yesno':
 294                  $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
 295                  break;
 296              case 'group':
 297                  include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
 298                  $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
 299                  break;
 300              case 'group_multi':
 301                  include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
 302                  $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
 303                  break;
 304              // RMV-NOTIFY: added 'user' and 'user_multi'

 305              case 'user':
 306                  include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
 307                  $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
 308                  break;
 309              case 'user_multi':
 310                  include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
 311                  $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
 312                  break;
 313              case 'password':
 314                  $myts =& MyTextSanitizer::getInstance();
 315                  $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
 316                  break;
 317              case 'color':
 318                  $myts =& MyTextSanitizer::getInstance();
 319                  $ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
 320                  break;
 321              case 'hidden':
 322                  $myts =& MyTextSanitizer::getInstance();
 323                  $ele = new XoopsFormHidden( $config[$i]->getVar('conf_name'), $myts->htmlspecialchars( $config[$i]->getConfValueForOutput() ) );
 324                  break;
 325              case 'textbox':
 326              default:
 327                  $myts =& MyTextSanitizer::getInstance();
 328                  $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
 329                  break;
 330              }
 331              $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id'));
 332              $form->addElement($ele);
 333              $form->addElement($hidden);
 334              unset($ele);
 335              unset($hidden);
 336          }
 337          $form->addElement(new XoopsFormHidden('op', 'save'));
 338          $form->addElement(new XoopsFormButton('', 'button', _GO, 'submit'));
 339          xoops_cp_header();
 340          $form->display();
 341          xoops_cp_footer();
 342          exit();
 343      }
 344  
 345      if ($op == 'save') {
 346          if (!$GLOBALS['xoopsSecurity']->check()) {
 347              redirect_header("admin.php?fct=preferences", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
 348          }
 349          require_once(XOOPS_ROOT_PATH.'/class/template.php');
 350          $xoopsTpl = new XoopsTpl();
 351          $count = count($conf_ids);
 352          $tpl_updated = false;
 353          $theme_updated = false;
 354          $startmod_updated = false;
 355          $lang_updated = false;
 356          if ($count > 0) {
 357              for ($i = 0; $i < $count; $i++) {
 358                  $config =& $config_handler->getConfig($conf_ids[$i]);
 359                  $new_value =& ${$config->getVar('conf_name')};
 360                  if (is_array($new_value) || $new_value != $config->getVar('conf_value')) {
 361                      // if language has been changed

 362                      if (!$lang_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'language') {
 363                          $xoopsConfig['language'] = ${$config->getVar('conf_name')};
 364                          $lang_updated = true;
 365                      }
 366  
 367                      // if default theme has been changed

 368                      if (!$theme_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'theme_set') {
 369                          $member_handler =& xoops_gethandler('member');
 370                          $member_handler->updateUsersByField('theme', ${$config->getVar('conf_name')});
 371                          $theme_updated = true;
 372                      }
 373  
 374                      // if default template set has been changed

 375                      if (!$tpl_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'template_set') {
 376                          // clear cached/compiled files and regenerate them if default theme has been changed

 377                          if ($xoopsConfig['template_set'] != ${$config->getVar('conf_name')}) {
 378                              $newtplset = ${$config->getVar('conf_name')};
 379  
 380                              // clear all compiled and cachedfiles

 381                              $xoopsTpl->clear_compiled_tpl();
 382  
 383                              // generate compiled files for the new theme

 384                              // block files only for now..

 385                              $tplfile_handler =& xoops_gethandler('tplfile');
 386                              $dtemplates =& $tplfile_handler->find('default', 'block');
 387                              $dcount = count($dtemplates);
 388  
 389                              // need to do this to pass to xoops_template_touch function

 390                              $GLOBALS['xoopsConfig']['template_set'] = $newtplset;
 391  
 392                              for ($i = 0; $i < $dcount; $i++) {
 393                                  $found =& $tplfile_handler->find($newtplset, 'block', $dtemplates[$i]->getVar('tpl_refid'), null);
 394                                  if (count($found) > 0) {
 395                                      // template for the new theme found, compile it

 396                                      xoops_template_touch($found[0]->getVar('tpl_id'));
 397                                  } else {
 398                                      // not found, so compile 'default' template file

 399                                      xoops_template_touch($dtemplates[$i]->getVar('tpl_id'));
 400                                  }
 401                              }
 402  
 403                              // generate image cache files from image binary data, save them under cache/

 404                              $image_handler =& xoops_gethandler('imagesetimg');
 405                              $imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true);
 406                              foreach (array_keys($imagefiles) as $i) {
 407                                  if (!$fp = fopen(XOOPS_CACHE_PATH.'/'.$newtplset.'_'.$imagefiles[$i]->getVar('imgsetimg_file'), 'wb')) {
 408                                  } else {
 409                                      fwrite($fp, $imagefiles[$i]->getVar('imgsetimg_body'));
 410                                      fclose($fp);
 411                                  }
 412                              }
 413                          }
 414                          $tpl_updated = true;
 415                      }
 416  
 417                      // add read permission for the start module to all groups

 418                      if (!$startmod_updated  && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'startpage') {
 419                          $member_handler =& xoops_gethandler('member');
 420                          $groups =& $member_handler->getGroupList();
 421                          $moduleperm_handler =& xoops_gethandler('groupperm');
 422                          $module_handler =& xoops_gethandler('module');
 423                          $module =& $module_handler->getByDirname($new_value);
 424                          foreach ($groups as $groupid => $groupname) {
 425                              if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groupid)) {
 426                                  $moduleperm_handler->addRight('module_read', $module->getVar('mid'), $groupid);
 427                              }
 428                          }
 429                          $startmod_updated = true;
 430                      }
 431  
 432                      $config->setConfValueForInput($new_value);
 433                      $config_handler->insertConfig($config);
 434                  }
 435                  unset($new_value);
 436              }
 437          }
 438          
 439          if (!empty($use_mysession) && $xoopsConfig['use_mysession'] == 0 && $session_name != '') {
 440              setcookie($session_name, session_id(), time()+(60*intval($session_expire)), '/',  '', 0);
 441          }
 442          
 443          // Clean cached files, may take long time

 444          // User reigister_shutdown_function to keep running after connection closes so that cleaning cached files can be finished

 445          // Cache management should be performed on a separate page

 446          register_shutdown_function( array( &$xoopsTpl, 'clear_all_cache' ) );
 447  
 448          // If language is changed, leave the admin menu file to be regenerated upon next request,

 449          // otherwise regenerate admin menu file for now

 450          if (!$lang_updated) {
 451              // regenerate admin menu file

 452              register_shutdown_function( 'xoops_module_write_admin_menu', xoops_module_get_admin_menu() );
 453          } else {
 454              $redirect = XOOPS_URL . "/admin.php";
 455          }
 456  
 457          if (isset($redirect) && $redirect != '') {
 458              redirect_header($redirect, 2, _MD_AM_DBUPDATED);
 459          } else {
 460              redirect_header("admin.php?fct=preferences",2,_MD_AM_DBUPDATED);
 461          }
 462      }
 463  }
 464  
 465  ?>


Généré le : Sun Nov 25 11:44:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics