| 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 | |
|---|
| 32 | |
|---|
| 33 | $config_handler =& xoops_gethandler('config'); |
|---|
| 34 | |
|---|
| 35 | if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|---|
| 36 | exit("Access Denied"); |
|---|
| 37 | } else { |
|---|
| 38 | $op = 'list'; |
|---|
| 39 | if ( !empty($_POST['op']) ) { $op = $_POST['op']; } |
|---|
| 40 | if (isset($_GET['op'])) { |
|---|
| 41 | $op = trim($_GET['op']); |
|---|
| 42 | } |
|---|
| 43 | if (isset($_GET['confcat_id'])) { |
|---|
| 44 | $confcat_id = intval($_GET['confcat_id']); |
|---|
| 45 | } |
|---|
| 46 | /* if ($op == 'list') { |
|---|
| 47 | $confcat_handler =& xoops_gethandler('configcategory'); |
|---|
| 48 | $confcats =& $confcat_handler->getObjects(); |
|---|
| 49 | $catcount = count($confcats); |
|---|
| 50 | xoops_cp_header(); |
|---|
| 51 | echo '<h4 style="text-align:left">'._MD_AM_SITEPREF.'</h4><ul>'; |
|---|
| 52 | for ($i = 0; $i < $catcount; $i++) { |
|---|
| 53 | echo '<li>'.constant($confcats[$i]->getVar('confcat_name')).' [<a href="admin.php?fct=preferences&op=show&confcat_id='.$confcats[$i]->getVar('confcat_id').'">'._EDIT.'</a>]</li>'; |
|---|
| 54 | } |
|---|
| 55 | echo '</ul>'; |
|---|
| 56 | xoops_cp_footer(); |
|---|
| 57 | exit(); |
|---|
| 58 | } */ |
|---|
| 59 | |
|---|
| 60 | /* if ($op == 'show') { |
|---|
| 61 | if (empty($confcat_id)) { |
|---|
| 62 | $confcat_id = 1; |
|---|
| 63 | } |
|---|
| 64 | $confcat_handler =& xoops_gethandler('configcategory'); |
|---|
| 65 | $confcat =& $confcat_handler->get($confcat_id); |
|---|
| 66 | if (!is_object($confcat)) { |
|---|
| 67 | redirect_header('admin.php?fct=preferences', 1); |
|---|
| 68 | } |
|---|
| 69 | include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|---|
| 70 | include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|---|
| 71 | $form = new XoopsThemeForm(constant($confcat->getVar('confcat_name')), 'pref_form', 'admin.php?fct=preferences'); |
|---|
| 72 | $config_handler =& xoops_gethandler('config'); |
|---|
| 73 | $criteria = new CriteriaCompo(); |
|---|
| 74 | $criteria->add(new Criteria('conf_modid', 0)); |
|---|
| 75 | $criteria->add(new Criteria('conf_catid', $confcat_id)); |
|---|
| 76 | $config =& $config_handler->getConfigs($criteria); |
|---|
| 77 | $confcount = count($config); |
|---|
| 78 | for ($i = 0; $i < $confcount; $i++) { |
|---|
| 79 | $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>'; |
|---|
| 80 | switch ($config[$i]->getVar('conf_formtype')) { |
|---|
| 81 | case 'textarea': |
|---|
| 82 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 83 | if ($config[$i]->getVar('conf_valuetype') == 'array') { |
|---|
| 84 | // this is exceptional.. only when value type is arrayneed a smarter way for this |
|---|
| 85 | $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); |
|---|
| 86 | } else { |
|---|
| 87 | $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50); |
|---|
| 88 | } |
|---|
| 89 | break; |
|---|
| 90 | case 'select': |
|---|
| 91 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|---|
| 92 | $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|---|
| 93 | $opcount = count($options); |
|---|
| 94 | for ($j = 0; $j < $opcount; $j++) { |
|---|
| 95 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|---|
| 96 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|---|
| 97 | $ele->addOption($optval, $optkey); |
|---|
| 98 | } |
|---|
| 99 | break; |
|---|
| 100 | case 'select_multi': |
|---|
| 101 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
|---|
| 102 | $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|---|
| 103 | $opcount = count($options); |
|---|
| 104 | for ($j = 0; $j < $opcount; $j++) { |
|---|
| 105 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|---|
| 106 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|---|
| 107 | $ele->addOption($optval, $optkey); |
|---|
| 108 | } |
|---|
| 109 | break; |
|---|
| 110 | case 'yesno': |
|---|
| 111 | $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
|---|
| 112 | break; |
|---|
| 113 | case 'theme': |
|---|
| 114 | case 'theme_multi': |
|---|
| 115 | $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); |
|---|
| 116 | $handle = opendir(XOOPS_THEME_PATH.'/'); |
|---|
| 117 | $dirlist = array(); |
|---|
| 118 | while (false !== ($file = readdir($handle))) { |
|---|
| 119 | if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/",$file) && strtolower($file) != 'cvs') { |
|---|
| 120 | $dirlist[$file]=$file; |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | closedir($handle); |
|---|
| 124 | if (!empty($dirlist)) { |
|---|
| 125 | asort($dirlist); |
|---|
| 126 | $ele->addOptionArray($dirlist); |
|---|
| 127 | } |
|---|
| 128 | //$themeset_handler =& xoops_gethandler('themeset'); |
|---|
| 129 | //$themesetlist =& $themeset_handler->getList(); |
|---|
| 130 | //asort($themesetlist); |
|---|
| 131 | //foreach ($themesetlist as $key => $name) { |
|---|
| 132 | // $ele->addOption($key, $name.' ('._MD_AM_THEMESET.')'); |
|---|
| 133 | //} |
|---|
| 134 | // old theme value is used to determine whether to update cache or not. kind of dirty way |
|---|
| 135 | $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput())); |
|---|
| 136 | break; |
|---|
| 137 | case 'tplset': |
|---|
| 138 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|---|
| 139 | $tplset_handler =& xoops_gethandler('tplset'); |
|---|
| 140 | $tplsetlist =& $tplset_handler->getList(); |
|---|
| 141 | asort($tplsetlist); |
|---|
| 142 | foreach ($tplsetlist as $key => $name) { |
|---|
| 143 | $ele->addOption($key, $name); |
|---|
| 144 | } |
|---|
| 145 | // old theme value is used to determine whether to update cache or not. kind of dirty way |
|---|
| 146 | $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput())); |
|---|
| 147 | break; |
|---|
| 148 | case 'timezone': |
|---|
| 149 | $ele = new XoopsFormSelectTimezone($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|---|
| 150 | break; |
|---|
| 151 | case 'language': |
|---|
| 152 | $ele = new XoopsFormSelectLang($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|---|
| 153 | break; |
|---|
| 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 | case 'group': |
|---|
| 164 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|---|
| 165 | break; |
|---|
| 166 | case 'group_multi': |
|---|
| 167 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|---|
| 168 | break; |
|---|
| 169 | // RMV-NOTIFY - added 'user' and 'user_multi' |
|---|
| 170 | case 'user': |
|---|
| 171 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|---|
| 172 | break; |
|---|
| 173 | case 'user_multi': |
|---|
| 174 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|---|
| 175 | break; |
|---|
| 176 | case 'module_cache': |
|---|
| 177 | $module_handler =& xoops_gethandler('module'); |
|---|
| 178 | $modules =& $module_handler->getObjects(new Criteria('hasmain', 1), true); |
|---|
| 179 | $currrent_val = $config[$i]->getConfValueForOutput(); |
|---|
| 180 | $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); |
|---|
| 181 | if (count($modules) > 0) { |
|---|
| 182 | $ele = new XoopsFormElementTray($title, '<br />'); |
|---|
| 183 | foreach (array_keys($modules) as $mid) { |
|---|
| 184 | $c_val = isset($currrent_val[$mid]) ? intval($currrent_val[$mid]) : null; |
|---|
| 185 | $selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name')."[$mid]", $c_val); |
|---|
| 186 | $selform->addOptionArray($cache_options); |
|---|
| 187 | $ele->addElement($selform); |
|---|
| 188 | unset($selform); |
|---|
| 189 | } |
|---|
| 190 | } else { |
|---|
| 191 | $ele = new XoopsFormLabel($title, _MD_AM_NOMODULE); |
|---|
| 192 | } |
|---|
| 193 | break; |
|---|
| 194 | case 'site_cache': |
|---|
| 195 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|---|
| 196 | $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)); |
|---|
| 197 | break; |
|---|
| 198 | case 'password': |
|---|
| 199 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 200 | $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|---|
| 201 | break; |
|---|
| 202 | case 'textbox': |
|---|
| 203 | default: |
|---|
| 204 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 205 | $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|---|
| 206 | break; |
|---|
| 207 | } |
|---|
| 208 | $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
|---|
| 209 | $form->addElement($ele); |
|---|
| 210 | $form->addElement($hidden); |
|---|
| 211 | unset($ele); |
|---|
| 212 | unset($hidden); |
|---|
| 213 | } |
|---|
| 214 | $form->addElement(new XoopsFormHidden('op', 'save')); |
|---|
| 215 | $xoopsGTicket->addTicketXoopsFormElement( $form , __LINE__ ) ; |
|---|
| 216 | $form->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); |
|---|
| 217 | xoops_cp_header(); |
|---|
| 218 | echo '<a href="admin.php?fct=preferences">'. _MD_AM_PREFMAIN .'</a> <span style="font-weight:bold;">»»</span> '.constant($confcat->getVar('confcat_name')).'<br /><br />'; |
|---|
| 219 | $form->display(); |
|---|
| 220 | xoops_cp_footer(); |
|---|
| 221 | exit(); |
|---|
| 222 | } */ |
|---|
| 223 | |
|---|
| 224 | if ($op == 'showmod') { |
|---|
| 225 | $mod = isset($_GET['mod']) ? intval($_GET['mod']) : 0; |
|---|
| 226 | if (empty($mod)) { |
|---|
| 227 | header('Location: admin.php?fct=preferences'); |
|---|
| 228 | exit(); |
|---|
| 229 | } |
|---|
| 230 | $config =& $config_handler->getConfigs(new Criteria('conf_modid', $mod)); |
|---|
| 231 | $count = count($config); |
|---|
| 232 | if ($count < 1) { |
|---|
| 233 | redirect_header('admin.php?fct=preferences', 1); |
|---|
| 234 | } |
|---|
| 235 | include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|---|
| 236 | $form = new XoopsThemeForm(_MD_AM_MODCONFIG, 'pref_form', 'admin.php?fct=preferences'); |
|---|
| 237 | $module_handler =& xoops_gethandler('module'); |
|---|
| 238 | $module =& $module_handler->get($mod); |
|---|
| 239 | if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$module->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php')) { |
|---|
| 240 | include_once XOOPS_ROOT_PATH.'/modules/'.$module->getVar('dirname').'/language/'.$xoopsConfig['language'].'/modinfo.php'; |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | // if has comments feature, need comment lang file |
|---|
| 244 | if ($module->getVar('hascomments') == 1) { |
|---|
| 245 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/comment.php'; |
|---|
| 246 | } |
|---|
| 247 | // RMV-NOTIFY |
|---|
| 248 | // if has notification feature, need notification lang file |
|---|
| 249 | if ($module->getVar('hasnotification') == 1) { |
|---|
| 250 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/notification.php'; |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | $modname = $module->getVar('name'); |
|---|
| 254 | $button_tray = new XoopsFormElementTray(""); |
|---|
| 255 | if ($module->getInfo('adminindex')) { |
|---|
| 256 | // $form->addElement(new XoopsFormHidden('redirect', XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$module->getInfo('adminindex'))); |
|---|
| 257 | $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 |
|---|
| 258 | } |
|---|
| 259 | for ($i = 0; $i < $count; $i++) { |
|---|
| 260 | $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 |
|---|
| 261 | $title = '' ; // GIJ |
|---|
| 262 | switch ($config[$i]->getVar('conf_formtype')) { |
|---|
| 263 | case 'textarea': |
|---|
| 264 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 265 | if ($config[$i]->getVar('conf_valuetype') == 'array') { |
|---|
| 266 | // this is exceptional.. only when value type is arrayneed a smarter way for this |
|---|
| 267 | $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); |
|---|
| 268 | } else { |
|---|
| 269 | $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50); |
|---|
| 270 | } |
|---|
| 271 | break; |
|---|
| 272 | case 'select': |
|---|
| 273 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|---|
| 274 | $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|---|
| 275 | $opcount = count($options); |
|---|
| 276 | for ($j = 0; $j < $opcount; $j++) { |
|---|
| 277 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|---|
| 278 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|---|
| 279 | $ele->addOption($optval, $optkey); |
|---|
| 280 | } |
|---|
| 281 | break; |
|---|
| 282 | case 'select_multi': |
|---|
| 283 | $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
|---|
| 284 | $options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|---|
| 285 | $opcount = count($options); |
|---|
| 286 | for ($j = 0; $j < $opcount; $j++) { |
|---|
| 287 | $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|---|
| 288 | $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|---|
| 289 | $ele->addOption($optval, $optkey); |
|---|
| 290 | } |
|---|
| 291 | break; |
|---|
| 292 | case 'yesno': |
|---|
| 293 | $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
|---|
| 294 | break; |
|---|
| 295 | case 'group': |
|---|
| 296 | include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|---|
| 297 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|---|
| 298 | break; |
|---|
| 299 | case 'group_multi': |
|---|
| 300 | include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|---|
| 301 | $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|---|
| 302 | break; |
|---|
| 303 | // RMV-NOTIFY: added 'user' and 'user_multi' |
|---|
| 304 | case 'user': |
|---|
| 305 | include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|---|
| 306 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|---|
| 307 | break; |
|---|
| 308 | case 'user_multi': |
|---|
| 309 | include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|---|
| 310 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|---|
| 311 | break; |
|---|
| 312 | case 'password': |
|---|
| 313 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 314 | $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|---|
| 315 | break; |
|---|
| 316 | case 'textbox': |
|---|
| 317 | default: |
|---|
| 318 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 319 | $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|---|
| 320 | break; |
|---|
| 321 | } |
|---|
| 322 | $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
|---|
| 323 | $ele_tray = new XoopsFormElementTray( $title4tray , '' ) ; |
|---|
| 324 | $ele_tray->addElement($ele); |
|---|
| 325 | $ele_tray->addElement($hidden); |
|---|
| 326 | $form->addElement( $ele_tray ) ; |
|---|
| 327 | unset($ele_tray); |
|---|
| 328 | unset($ele); |
|---|
| 329 | unset($hidden); |
|---|
| 330 | } |
|---|
| 331 | $button_tray->addElement(new XoopsFormHidden('op', 'save')); |
|---|
| 332 | $xoopsGTicket->addTicketXoopsFormElement( $button_tray , __LINE__ , 1800 , 'mymenu' ) ; |
|---|
| 333 | $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); |
|---|
| 334 | $form->addElement( $button_tray ) ; |
|---|
| 335 | xoops_cp_header(); |
|---|
| 336 | // GIJ patch start |
|---|
| 337 | include( './mymenu.php' ) ; |
|---|
| 338 | echo "<h3 style='text-align:left;'>".$module->getvar('name').' '._PREFERENCES."</h3>\n" ; |
|---|
| 339 | // GIJ patch end |
|---|
| 340 | $form->display(); |
|---|
| 341 | xoops_cp_footer(); |
|---|
| 342 | exit(); |
|---|
| 343 | } |
|---|
| 344 | |
|---|
| 345 | if ($op == 'save') { |
|---|
| 346 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|---|
| 347 | // exit('Invalid referer'); |
|---|
| 348 | //} |
|---|
| 349 | if ( ! $xoopsGTicket->check( true , 'mymenu' ) ) { |
|---|
| 350 | redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|---|
| 351 | } |
|---|
| 352 | require_once(XOOPS_ROOT_PATH.'/class/template.php'); |
|---|
| 353 | $xoopsTpl = new XoopsTpl(); |
|---|
| 354 | $xoopsTpl->clear_all_cache(); |
|---|
| 355 | // regenerate admin menu file |
|---|
| 356 | xoops_module_write_admin_menu(xoops_module_get_admin_menu()); |
|---|
| 357 | if ( !empty($_POST['conf_ids']) ) { $conf_ids = $_POST['conf_ids']; } |
|---|
| 358 | $count = count($conf_ids); |
|---|
| 359 | $tpl_updated = false; |
|---|
| 360 | $theme_updated = false; |
|---|
| 361 | $startmod_updated = false; |
|---|
| 362 | $lang_updated = false; |
|---|
| 363 | if ($count > 0) { |
|---|
| 364 | for ($i = 0; $i < $count; $i++) { |
|---|
| 365 | $config =& $config_handler->getConfig($conf_ids[$i]); |
|---|
| 366 | $new_value =& $_POST[$config->getVar('conf_name')]; |
|---|
| 367 | if (is_array($new_value) || $new_value != $config->getVar('conf_value')) { |
|---|
| 368 | // if language has been changed |
|---|
| 369 | if (!$lang_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'language') { |
|---|
| 370 | // regenerate admin menu file |
|---|
| 371 | $xoopsConfig['language'] = $_POST[$config->getVar('conf_name')]; |
|---|
| 372 | xoops_module_write_admin_menu(xoops_module_get_admin_menu()); |
|---|
| 373 | $lang_updated = true; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | // if default theme has been changed |
|---|
| 377 | if (!$theme_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'theme_set') { |
|---|
| 378 | $member_handler =& xoops_gethandler('member'); |
|---|
| 379 | $member_handler->updateUsersByField('theme', $_POST[$config->getVar('conf_name')]); |
|---|
| 380 | $theme_updated = true; |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | // if default template set has been changed |
|---|
| 384 | if (!$tpl_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'template_set') { |
|---|
| 385 | // clear cached/compiled files and regenerate them if default theme has been changed |
|---|
| 386 | if ($xoopsConfig['template_set'] != $_POST[$config->getVar('conf_name')]) { |
|---|
| 387 | $newtplset = $_POST[$config->getVar('conf_name')]; |
|---|
| 388 | |
|---|
| 389 | // clear all compiled and cachedfiles |
|---|
| 390 | $xoopsTpl->clear_compiled_tpl(); |
|---|
| 391 | |
|---|
| 392 | // generate compiled files for the new theme |
|---|
| 393 | // block files only for now.. |
|---|
| 394 | $tplfile_handler =& xoops_gethandler('tplfile'); |
|---|
| 395 | $dtemplates =& $tplfile_handler->find('default', 'block'); |
|---|
| 396 | $dcount = count($dtemplates); |
|---|
| 397 | |
|---|
| 398 | // need to do this to pass to xoops_template_touch function |
|---|
| 399 | $GLOBALS['xoopsConfig']['template_set'] = $newtplset; |
|---|
| 400 | |
|---|
| 401 | for ($i = 0; $i < $dcount; $i++) { |
|---|
| 402 | $found =& $tplfile_handler->find($newtplset, 'block', $dtemplates[$i]->getVar('tpl_refid'), null); |
|---|
| 403 | if (count($found) > 0) { |
|---|
| 404 | // template for the new theme found, compile it |
|---|
| 405 | xoops_template_touch($found[0]->getVar('tpl_id')); |
|---|
| 406 | } else { |
|---|
| 407 | // not found, so compile 'default' template file |
|---|
| 408 | xoops_template_touch($dtemplates[$i]->getVar('tpl_id')); |
|---|
| 409 | } |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | // generate image cache files from image binary data, save them under cache/ |
|---|
| 413 | $image_handler =& xoops_gethandler('imagesetimg'); |
|---|
| 414 | $imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true); |
|---|
| 415 | foreach (array_keys($imagefiles) as $i) { |
|---|
| 416 | if (!$fp = fopen(XOOPS_CACHE_PATH.'/'.$newtplset.'_'.$imagefiles[$i]->getVar('imgsetimg_file'), 'wb')) { |
|---|
| 417 | } else { |
|---|
| 418 | fwrite($fp, $imagefiles[$i]->getVar('imgsetimg_body')); |
|---|
| 419 | fclose($fp); |
|---|
| 420 | } |
|---|
| 421 | } |
|---|
| 422 | } |
|---|
| 423 | $tpl_updated = true; |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | // add read permission for the start module to all groups |
|---|
| 427 | if (!$startmod_updated && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'startpage') { |
|---|
| 428 | $member_handler =& xoops_gethandler('member'); |
|---|
| 429 | $groups =& $member_handler->getGroupList(); |
|---|
| 430 | $moduleperm_handler =& xoops_gethandler('groupperm'); |
|---|
| 431 | $module_handler =& xoops_gethandler('module'); |
|---|
| 432 | $module =& $module_handler->getByDirname($new_value); |
|---|
| 433 | foreach ($groups as $groupid => $groupname) { |
|---|
| 434 | if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groupid)) { |
|---|
| 435 | $moduleperm_handler->addRight('module_read', $module->getVar('mid'), $groupid); |
|---|
| 436 | } |
|---|
| 437 | } |
|---|
| 438 | $startmod_updated = true; |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | $config->setConfValueForInput($new_value); |
|---|
| 442 | $config_handler->insertConfig($config); |
|---|
| 443 | } |
|---|
| 444 | unset($new_value); |
|---|
| 445 | } |
|---|
| 446 | } |
|---|
| 447 | /* if (!empty($_POST['use_mysession']) && $xoopsConfig['use_mysession'] == 0 && $_POST['session_name'] != '') { |
|---|
| 448 | setcookie($_POST['session_name'], session_id(), time()+(60*intval($_POST['session_expire'])), '/', '', 0); |
|---|
| 449 | } */ |
|---|
| 450 | if ( ! empty( $_POST['redirect'] ) ) { |
|---|
| 451 | redirect_header($_POST['redirect'], 2, _MD_AM_DBUPDATED); |
|---|
| 452 | } else { |
|---|
| 453 | redirect_header("admin.php?fct=preferences",2,_MD_AM_DBUPDATED); |
|---|
| 454 | } |
|---|
| 455 | } |
|---|
| 456 | } |
|---|
| 457 | |
|---|
| 458 | ?> |
|---|