35 include_once XOOPS_ROOT_PATH .
'/class/xoopsblock.php';
36 include_once XOOPS_ROOT_PATH .
'/modules/system/admin/modulesadmin/modulesadmin.php';
39 foreach (
$_POST as $k => $v ) {
48 if (in_array(
$op, array(
'confirm',
'submit',
'install_ok',
'update_ok',
'uninstall_ok'))) {
49 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
53 $myts =& MyTextsanitizer::getInstance();
63 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
66 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
67 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.ui.js');
68 $xoTheme->addScript(
'modules/system/js/admin.js');
69 $xoTheme->addScript(
'modules/system/js/module.js');
84 $install_mods = array();
89 $listed_mods[
$i][
'version'] = round( $module->getVar(
'version') / 100, 2 );
91 $listed_mods[
$i][
'author'] = $module->getInfo(
'author');
92 $listed_mods[
$i][
'credits'] = $module->getInfo(
'credits');
93 $listed_mods[
$i][
'license'] = $module->getInfo(
'license');
94 $listed_mods[
$i][
'description'] = $module->getInfo(
'description');
95 if ( round( $module->getInfo(
'version' ), 2 ) != $listed_mods[
$i][
'version']){
96 $listed_mods[
$i][
'warning_update'] =
true;
98 $listed_mods[
$i][
'warning_update'] =
false;
100 $install_mods[] = $module->getInfo(
'dirname');
105 $dirlist = XoopsLists::getModulesList();
106 $toinstall_mods = array();
109 if ( file_exists( XOOPS_ROOT_PATH .
'/modules/' . $file .
'/xoops_version.php' ) ) {
112 if ( !in_array($file, $install_mods) ) {
119 $xoopsTpl->assign(
'install_mods', $listed_mods);
120 $xoopsTpl->assign(
'mods_popup', $listed_mods);
132 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
135 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
136 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.ui.js');
137 $xoTheme->addScript(
'modules/system/js/admin.js');
149 $install_mods[] = $module->getInfo(
'dirname');
152 $dirlist = XoopsLists::getModulesList();
153 $toinstall_mods = array();
156 if ( file_exists( XOOPS_ROOT_PATH .
'/modules/' . $file .
'/xoops_version.php' ) ) {
159 if ( !in_array($file, $install_mods) ) {
161 $module->loadInfo($file);
162 $toinstall_mods[
$i][
'name'] = $module->getInfo(
'name');
163 $toinstall_mods[
$i][
'dirname'] = $module->getInfo(
'dirname');
164 $toinstall_mods[
$i][
'image'] = $module->getInfo(
'image');
165 $toinstall_mods[
$i][
'version'] = round($module->getInfo(
'version'), 2);
166 $toinstall_mods[
$i][
'author'] = $module->getInfo(
'author');
167 $toinstall_mods[
$i][
'credits'] = $module->getInfo(
'credits');
168 $toinstall_mods[
$i][
'license'] = $module->getInfo(
'license');
169 $toinstall_mods[
$i][
'description'] = $module->getInfo(
'description');
170 $toinstall_mods[
$i][
'mid'] =
$i;
176 $xoopsTpl->assign(
'toinstall_mods', $toinstall_mods);
177 $xoopsTpl->assign(
'mods_popup', $toinstall_mods);
186 if ( isset(
$_POST[
'mod']) ) {
188 foreach (
$_POST[
'mod'] as $order) {
192 if ($module->getVar(
'weight') != 0) {
193 $module->setVar(
'weight', $i);
207 $xoopsOption[
'template_main'] =
'system_modules_confirm.html';
211 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
225 if ( count(
$error) > 0 ) {
233 $modifs_mods = array();
234 $module = empty(
$_POST[
'module']) ? array() :
$_POST[
'module'];
235 foreach ($module as
$mid) {
237 $modifs_mods[
$i][
'mid'] =
$mid;
238 $modifs_mods[
$i][
'oldname'] =
$myts->htmlspecialchars(
$myts->stripSlashesGPC($oldname[$mid]));
239 $modifs_mods[
$i][
'newname'] =
$myts->htmlspecialchars(trim(
$myts->stripslashesGPC($newname[$mid])));
240 $modifs_mods[
$i][
'newstatus'] = (isset($newstatus[$mid])) ?
$myts->htmlspecialchars($newstatus[$mid]) : 0;
243 $xoopsTpl->assign(
'modifs_mods', $modifs_mods);
255 $old = $module->getVar(
'isactive');
257 $module->setVar(
'isactive', !$old );
262 $bcount = count($blocks);
263 for ($i = 0; $i < $bcount; $i++) {
264 $blocks[
$i]->setVar(
'isactive', !$old);
265 $blocks[
$i]->store();
272 case 'display_in_menu':
278 $old = $module->getVar(
'weight');
280 $module->setVar(
'weight', !$old );
290 $module = empty(
$_POST[
'module']) ? array() :
$_POST[
'module'];
291 foreach ($module as $mid) {
292 if (isset($newstatus[$mid]) && $newstatus[$mid] ==1) {
293 if ($oldstatus[$mid] == 0) {
297 if ($oldstatus[$mid] == 1) {
301 $newname[
$mid] = trim($newname[$mid]);
302 if ($oldname[$mid] != $newname[$mid] ) {
316 $xoopsOption[
'template_main'] =
'system_modules_confirm.html';
320 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
326 if ( count(
$ret) > 0 ) {
334 $module =
$myts->htmlspecialchars($module);
338 $mod->loadInfoAsVar($module);
340 if ($mod->getInfo(
'image') !=
false && trim($mod->getInfo(
'image')) !=
'') {
341 $msgs =
'<img src="' . XOOPS_URL .
'/modules/' . $mod->getVar(
'dirname',
'n') .
'/' . trim($mod->getInfo(
'image')) .
'" alt="" />';
347 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
372 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
378 if (count(
$ret) > 0) {
390 $module =
$myts->htmlspecialchars($module);
395 if ($mod->getInfo(
'image') !=
false && trim($mod->getInfo(
'image')) !=
'') {
396 $msgs =
'<img src="' . XOOPS_URL .
'/modules/' . $mod->getVar(
'dirname',
'n') .
'/' . trim($mod->getInfo(
'image')) .
'" alt="" />';
402 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
427 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
433 if (count(
$ret) > 0) {
434 foreach (
$ret as $msg) {
445 $module =
$myts->htmlspecialchars($module);
450 if ($mod->getInfo(
'image') !=
false && trim($mod->getInfo(
'image')) !=
'') {
451 $msgs =
'<img src="' . XOOPS_URL .
'/modules/' . $mod->getVar(
'dirname',
'n') .
'/' . trim($mod->getInfo(
'image')) .
'" alt="" />';
457 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
474 $prev_version = $module->getVar(
'version');
478 $temp_name = $module->getVar(
'name');
480 $module->setVar(
'name', $temp_name);
481 $module->setVar(
'last_update', time() );
488 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css');
495 echo
'<p>Could not update '.$module->getVar(
'name').
'</p>';
498 $newmid = $module->getVar(
'mid');
500 $msgs[] =
'<div id="xo-module-log"><div class="header">';
502 if ($module->getInfo(
'image') !=
false && trim($module->getInfo(
'image')) !=
'') {
503 $msgs[] =
'<img src="' . XOOPS_URL .
'/modules/' .
$dirname .
'/' . trim($module->getInfo(
'image')) .
'" alt="" />';
505 $msgs[] =
'<strong>' .
_VERSION .
':</strong> ' . $module->getInfo(
'version');
506 if ($module->getInfo(
'author') !=
false && trim($module->getInfo(
'author')) !=
'') {
507 $msgs[] =
'<strong>' .
_AUTHOR .
':</strong> ' .
$myts->htmlspecialchars(trim($module->getInfo(
'author')));
509 $msgs[] =
'</div><div class="logger">';
512 $deltpl = $tplfile_handler->find(
'default',
'module', $module->getVar(
'mid'));
514 if (is_array($deltpl)) {
516 $dcount = count($deltpl);
517 for ($i = 0; $i < $dcount; $i++) {
518 if ( !$tplfile_handler->delete( $deltpl[$i] ) ) {
519 $delng[] = $deltpl[
$i]->getVar(
'tpl_file');
523 $templates = $module->getInfo(
'templates');
524 if ($templates !=
false) {
526 foreach ($templates as
$tpl) {
527 $tpl[
'file'] = trim($tpl[
'file']);
528 if (!in_array($tpl[
'file'], $delng)) {
529 $type = (isset($tpl[
'type']) ? $tpl[
'type'] :
'module');
531 $tplfile =& $tplfile_handler->create();
532 $tplfile->setVar(
'tpl_refid', $newmid);
533 $tplfile->setVar(
'tpl_lastimported', 0);
534 $tplfile->setVar(
'tpl_lastmodified', time());
536 if (preg_match(
"/\.css$/i", $tpl[
'file'])) {
537 $tplfile->setVar(
'tpl_type',
'css');
539 $tplfile->setVar(
'tpl_type',
$type );
541 $tplfile->setVar(
'tpl_source', $tpldata,
true);
542 $tplfile->setVar(
'tpl_module',
$dirname);
543 $tplfile->setVar(
'tpl_tplset',
'default');
544 $tplfile->setVar(
'tpl_file', $tpl[
'file'],
true);
545 $tplfile->setVar(
'tpl_desc', $tpl[
'description'],
true);
546 if (!$tplfile_handler->insert($tplfile)) {
549 $newid = $tplfile->getVar(
'tpl_id');
565 $blocks = $module->getInfo(
'blocks');
567 if ($blocks !=
false) {
568 $showfuncs = array();
569 $funcfiles = array();
570 foreach ($blocks as $i => $block) {
571 if (isset($block[
'show_func']) && $block[
'show_func'] !=
'' && isset($block[
'file']) && $block[
'file'] !=
'') {
572 $editfunc = isset($block[
'edit_func']) ? $block[
'edit_func'] :
'';
573 $showfuncs[] = $block[
'show_func'];
574 $funcfiles[] = $block[
'file'];
576 if ((isset($block[
'template']) && trim($block[
'template']) !=
'')) {
582 $template = $block[
'template'];
585 if (!empty($block[
'options'])) {
588 $sql =
"SELECT bid, name FROM ".$xoopsDB->prefix(
'newblocks').
" WHERE mid=".$module->getVar(
'mid').
" AND func_num=".$i.
" AND show_func='".addslashes($block[
'show_func']).
"' AND func_file='".addslashes($block[
'file']).
"'";
591 while ($fblock =
$xoopsDB->fetchArray($fresult)) {
593 $sql =
"UPDATE ".$xoopsDB->prefix(
"newblocks").
" SET name='".addslashes($block[
'name']).
"', edit_func='".addslashes($editfunc).
"', content='', template='".$template.
"', last_modified=".time().
" WHERE bid=".$fblock[
'bid'];
599 if ($template !=
'') {
600 $tplfile = $tplfile_handler->find(
'default',
'block', $fblock[
'bid']);
601 if (count($tplfile) == 0) {
602 $tplfile_new =& $tplfile_handler->create();
603 $tplfile_new->setVar(
'tpl_module',
$dirname);
604 $tplfile_new->setVar(
'tpl_refid', $fblock[
'bid']);
605 $tplfile_new->setVar(
'tpl_tplset',
'default');
606 $tplfile_new->setVar(
'tpl_file', $block[
'template'],
true);
607 $tplfile_new->setVar(
'tpl_type',
'block');
609 $tplfile_new = $tplfile[0];
611 $tplfile_new->setVar(
'tpl_source',
$content,
true);
612 $tplfile_new->setVar(
'tpl_desc', $block[
'description'],
true);
613 $tplfile_new->setVar(
'tpl_lastmodified', time());
614 $tplfile_new->setVar(
'tpl_lastimported', 0);
615 if (!$tplfile_handler->insert($tplfile_new)) {
633 $block_name = addslashes($block[
'name']);
634 $block_type = ($module->getVar(
'dirname') ==
'system') ?
'S' :
'M';
635 $sql =
"INSERT INTO ".$xoopsDB->prefix(
"newblocks").
" (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES (".$newbid.
", ".$module->getVar(
'mid').
", ".$i.
",'".addslashes(
$options).
"','".$block_name.
"', '".$block_name.
"', '', 0, 0, 0, '{$block_type}', 1, '".addslashes(
$dirname).
"', '".addslashes($block[
'file']).
"', '".addslashes($block[
'show_func']).
"', '".addslashes($editfunc).
"', '".$template.
"', ".time().
")";
640 if (empty($newbid)) {
643 if ($module->getInfo(
'hasMain')) {
644 $groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
646 $groups = array(XOOPS_GROUP_ADMIN);
649 foreach (
$groups as $mygroup) {
651 $bperm->setVar(
'gperm_groupid', $mygroup);
652 $bperm->setVar(
'gperm_itemid', $newbid);
653 $bperm->setVar(
'gperm_name',
'block_read');
654 $bperm->setVar(
'gperm_modid', 1);
662 if ($template !=
'') {
663 $tplfile =& $tplfile_handler->create();
664 $tplfile->setVar(
'tpl_module',
$dirname);
665 $tplfile->setVar(
'tpl_refid', $newbid);
666 $tplfile->setVar(
'tpl_source',
$content,
true);
667 $tplfile->setVar(
'tpl_tplset',
'default');
668 $tplfile->setVar(
'tpl_file', $block[
'template'],
true);
669 $tplfile->setVar(
'tpl_type',
'block');
670 $tplfile->setVar(
'tpl_lastimported', time());
671 $tplfile->setVar(
'tpl_lastmodified', time());
672 $tplfile->setVar(
'tpl_desc', $block[
'description'],
true);
673 if (!$tplfile_handler->insert($tplfile)) {
676 $newid = $tplfile->getVar(
'tpl_id');
688 $sql =
'INSERT INTO '.$xoopsDB->prefix(
'block_module_link').
' (block_id, module_id) VALUES ('.$newbid.
', -1)';
695 foreach ($block_arr as $block) {
696 if (!in_array($block->getVar(
'show_func'), $showfuncs) || !in_array($block->getVar(
'func_file'), $funcfiles)) {
697 $sql = sprintf(
"DELETE FROM %s WHERE bid = %u",
$xoopsDB->prefix(
'newblocks'), $block->getVar(
'bid'));
701 $msgs[] =
' Block <strong>'.$block->getVar(
'name').
' deleted. Block ID: <strong>'.$block->getVar(
'bid').
'</strong>';
702 if ($block->getVar(
'template') !=
'') {
703 $tplfiles = $tplfile_handler->find(null,
'block', $block->getVar(
'bid'));
704 if (is_array($tplfiles)) {
705 $btcount = count($tplfiles);
706 for ($k = 0; $k < $btcount; $k++) {
707 if (!$tplfile_handler->delete($tplfiles[$k])) {
708 $msgs[] =
' <span style="color:#ff0000;">'._AM_SYSTEM_MODULES_BLOCK_DEPRECATED_ERROR.
'(ID: <strong>'.$tplfiles[$k]->getVar(
'tpl_id').
'</strong>)</span>';
727 $config_delng = array();
728 if ($confcount > 0) {
730 for ($i = 0; $i < $confcount; $i++) {
732 $msgs[] =
' <span style="color:#ff0000;">'._AM_SYSTEM_MODULES_GONFIG_DATA_DELETE_ERROR. sprintf(
_AM_SYSTEM_MODULES_GONFIG_ID,
"<strong>".
$configs[$i]->getvar(
'conf_id').
"</strong>").
'</span>';
734 $config_delng[] =
$configs[
$i]->getvar(
'conf_name');
736 $config_old[
$configs[
$i]->getvar(
'conf_name')][
'value'] = $configs[
$i]->getvar(
'conf_value',
'N');
737 $config_old[$configs[
$i]->getvar(
'conf_name')][
'formtype'] = $configs[
$i]->getvar(
'conf_formtype');
738 $config_old[$configs[
$i]->getvar(
'conf_name')][
'valuetype'] = $configs[
$i]->getvar(
'conf_valuetype');
739 $msgs[] =
" "._AM_SYSTEM_MODULES_GONFIG_DATA_DELETE. sprintf(
_AM_SYSTEM_MODULES_GONFIG_ID,
"<strong>".$configs[$i]->getVar(
'conf_id').
"</strong>");
745 $configs = $module->getInfo(
'config');
746 if ($configs !=
false) {
747 if ($module->getVar(
'hascomments') != 0) {
748 include_once(XOOPS_ROOT_PATH.
'/include/comment_constants.php');
749 array_push($configs, array(
'name' =>
'com_rule',
'title' =>
'_CM_COMRULES',
'description' =>
'',
'formtype' =>
'select',
'valuetype' =>
'int',
'default' => 1,
'options' => array(
'_CM_COMNOCOM' =>
XOOPS_COMMENT_APPROVENONE,
'_CM_COMAPPROVEALL' =>
XOOPS_COMMENT_APPROVEALL,
'_CM_COMAPPROVEUSER' =>
XOOPS_COMMENT_APPROVEUSER,
'_CM_COMAPPROVEADMIN' =>
XOOPS_COMMENT_APPROVEADMIN)));
750 array_push($configs, array(
'name' =>
'com_anonpost',
'title' =>
'_CM_COMANONPOST',
'description' =>
'',
'formtype' =>
'yesno',
'valuetype' =>
'int',
'default' => 0));
753 if ($module->getVar(
'hascomments') != 0) {
755 include_once(XOOPS_ROOT_PATH.
'/include/comment_constants.php');
757 $configs[] = array(
'name' =>
'com_anonpost',
'title' =>
'_CM_COMANONPOST',
'description' =>
'',
'formtype' =>
'yesno',
'valuetype' =>
'int',
'default' => 0);
761 if ($module->getVar(
'hasnotification') != 0) {
762 if (empty($configs)) {
766 include_once XOOPS_ROOT_PATH .
'/include/notification_constants.php';
767 include_once XOOPS_ROOT_PATH .
'/include/notification_functions.php';
775 $configs[] = array (
'name' =>
'notification_enabled',
'title' =>
'_NOT_CONFIG_ENABLE',
'description' =>
'_NOT_CONFIG_ENABLEDSC',
'formtype' =>
'select',
'valuetype' =>
'int',
'default' =>
XOOPS_NOTIFICATION_ENABLEBOTH,
'options'=>
$options);
781 foreach ($categories as $category) {
783 foreach ($events as $event) {
784 if (!empty($event[
'invisible'])) {
787 $option_name = $category[
'title'] .
' : ' . $event[
'title'];
788 $option_value = $category[
'name'] .
'-' . $event[
'name'];
789 $options[$option_name] = $option_value;
793 $configs[] = array (
'name' =>
'notification_events',
'title' =>
'_NOT_CONFIG_EVENTS',
'description' =>
'_NOT_CONFIG_EVENTSDSC',
'formtype' =>
'select_multi',
'valuetype' =>
'array',
'default' => array_values(
$options),
'options' =>
$options);
796 if ($configs !=
false) {
797 $msgs[] =
'Adding module config data...';
800 foreach ($configs as
$config) {
802 if (!in_array($config[
'name'], $config_delng)) {
804 $confobj->setVar(
'conf_modid', $newmid);
805 $confobj->setVar(
'conf_catid', 0);
806 $confobj->setVar(
'conf_name', $config[
'name']);
807 $confobj->setVar(
'conf_title', $config[
'title'],
true);
808 $confobj->setVar(
'conf_desc', $config[
'description'],
true);
809 $confobj->setVar(
'conf_formtype', $config[
'formtype']);
810 if (isset( $config[
'valuetype']))
811 $confobj->setVar(
'conf_valuetype', $config[
'valuetype']);
812 if (isset($config_old[$config[
'name']][
'value']) && $config_old[$config[
'name']][
'formtype'] == $config[
'formtype'] && $config_old[$config[
'name']][
'valuetype'] == $config[
'valuetype']) {
815 $confobj->setVar(
'conf_value', $config_old[$config[
'name']][
'value'],
true);
817 $confobj->setConfValueForInput($config[
'default'],
true);
821 $confobj->setVar(
'conf_order', $order);
823 if (isset($config[
'options']) && is_array($config[
'options'])) {
824 foreach ($config[
'options'] as $key => $value) {
826 $confop->setVar(
'confop_name', $key,
true);
827 $confop->setVar(
'confop_value', $value,
true);
828 $confobj->setConfOptions($confop);
847 $update_script = $module->getInfo(
'onUpdate');
848 if (
false != $update_script && trim($update_script) !=
'') {
849 include_once XOOPS_ROOT_PATH.
'/modules/'.
$dirname.
'/'.trim($update_script);
850 if (function_exists(
'xoops_module_update_'.
$dirname)) {
851 $func =
'xoops_module_update_'.$dirname;
852 if (!$func($module, $prev_version)) {
854 $msgs = array_merge($msgs, $module->getErrors());
857 $msgs += $module->getErrors();
862 $msgs[] =
'</div></div>';
864 foreach ($msgs as $msg) {
874 require_once XOOPS_ROOT_PATH .
'/modules/system/class/maintenance.php';
876 $folder = array(1,3);
877 $maintenance->CleanCache($folder);