📄 modulesadmin.php
字号:
return $ret; } } else { return "<p>".sprintf(_MD_AM_FAILINS, "<b>".$dirname."</b>")." "._MD_AM_ERRORSC."<br /> ".sprintf(_MD_AM_ALEXISTS, $dirname)."</p>"; }}function &xoops_module_gettemplate($dirname, $template, $block=false){ global $xoopsConfig; if ($block) { $path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/blocks/'.$template; } else { $path = XOOPS_ROOT_PATH.'/modules/'.$dirname.'/templates/'.$template; } if (!file_exists($path)) { return false; } else { $lines = file($path); } if (!$lines) { return false; } $ret = ''; $count = count($lines); for ($i = 0; $i < $count; $i++) { $ret .= str_replace("\n", "\r\n", str_replace("\r\n", "\n", $lines[$i])); } return $ret;}function xoops_module_uninstall($dirname){ global $xoopsConfig; $reservedTables = array('avatar', 'avatar_users_link', 'block_module_link', 'comments', 'config', 'configcategory', 'configoption', 'image', 'imagebody', 'imagecategory', 'imgset', 'imgset_tplset_link', 'imgsetimg', 'groups','groups_users_link','group_permission', 'online', 'bannerclient', 'banner', 'bannerfinish', 'priv_msgs', 'ranks', 'session', 'smiles', 'users', 'newblocks', 'modules', 'tplfile', 'tplset', 'tplsource'); $db =& Database::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($dirname); include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_clear_module_cache($module->getVar('mid')); if ($module->getVar('dirname') == 'system') { return "<p>".sprintf(_MD_AM_FAILUNINS, "<b>".$module->getVar('name')."</b>")." "._MD_AM_ERRORSC."<br /> - "._MD_AM_SYSNO."</p>"; } elseif ($module->getVar('dirname') == $xoopsConfig['startpage']) { return "<p>".sprintf(_MD_AM_FAILUNINS, "<b>".$module->getVar('name')."</b>")." "._MD_AM_ERRORSC."<br /> - "._MD_AM_STRTNO."</p>"; } else { $msgs = array(); if (!$module_handler->delete($module)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete '.$module->getVar('name').'</span>'; } else { // delete template files $tplfile_handler = xoops_gethandler('tplfile'); $templates =& $tplfile_handler->find(null, 'module', $module->getVar('mid')); $tcount = count($templates); if ($tcount > 0) { $msgs[] = 'Deleting templates...'; for ($i = 0; $i < $tcount; $i++) { if (!$tplfile_handler->delete($templates[$i])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法将模板文件 '.$templates[$i]->getVar('tpl_file').' 从数据库删除. 模板 ID: <b>'.$templates[$i]->getVar('tpl_id').'</b></span>'; } else { $msgs[] = ' 模板文件 <b>'.$templates[$i]->getVar('tpl_file').'</b> 已从数据库中删除. 模板 ID: <b>'.$templates[$i]->getVar('tpl_id').'</b>'; } } } unset($templates); // delete blocks and block tempalte files $block_arr =& XoopsBlock::getByModule($module->getVar('mid')); if (is_array($block_arr)) { $bcount = count($block_arr); $msgs[] = 'Deleting block...'; for ($i = 0; $i < $bcount; $i++) { if (!$block_arr[$i]->delete()) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法删除区块 <b>'.$block_arr[$i]->getVar('name').'</b> 区块 ID: <b>'.$block_arr[$i]->getVar('bid').'</b></span>'; } else { $msgs[] = ' 区块 <b>'.$block_arr[$i]->getVar('name').'</b> 已删除. 区块 ID: <b>'.$block_arr[$i]->getVar('bid').'</b>'; } if ($block_arr[$i]->getVar('template') != ''){ $templates =& $tplfile_handler->find(null, 'block', $block_arr[$i]->getVar('bid')); $btcount = count($templates); if ($btcount > 0) { for ($j = 0; $j < $btcount; $j++) { if (!$tplfile_handler->delete($templates[$j])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法将区块模板文件 '.$templates[$j]->getVar('tpl_file').' 从数据库中删除. 模板 ID: <b>'.$templates[$j]->getVar('tpl_id').'</b></span>'; } else { $msgs[] = ' 区块模板文件 <b>'.$templates[$j]->getVar('tpl_file').'</b> 已从数据库中删除. 模板 ID: <b>'.$templates[$j]->getVar('tpl_id').'</b>'; } } } unset($templates); } } } // delete tables used by this module $modtables = $module->getInfo('tables'); if ($modtables != false && is_array($modtables)) { $msgs[] = '删除模块数据表...'; foreach ($modtables as $table) { // prevent deletion of reserved core tables! if (!in_array($table, $reservedTables)) { $sql = 'DROP TABLE '.$db->prefix($table); if (!$db->query($sql)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法删除数据表 <b>'.$db->prefix($table).'<b>.</span>'; } else { $msgs[] = ' 数据表 <b>'.$db->prefix($table).'</b> 已删除.</span>'; } } else { $msgs[] = ' <span style="color:#ff0000;">ERROR: 不允许删除数据表 <b>'.$db->prefix($table).'</b>!</span>'; } } } // delete comments if any if ($module->getVar('hascomments') != 0) { $msgs[] = '删除评论...'; $comment_handler =& xoops_gethandler('comment'); if (!$comment_handler->deleteByModule($module->getVar('mid'))) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法删除评论</span>'; } else { $msgs[] = ' 评论已删除'; } } // RMV-NOTIFY // delete notifications if any if ($module->getVar('hasnotification') != 0) { $msgs[] = '删除通知...'; if (!xoops_notification_deletebymodule($module->getVar('mid'))) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法删除通知</span>'; } else { $msgs[] = ' 通知已删除'; } } // delete permissions if any $gperm_handler =& xoops_gethandler('groupperm'); if (!$gperm_handler->deleteByModule($module->getVar('mid'))) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法删除群组权限</span>'; } else { $msgs[] = ' 群组权限已删除'; } // delete module config options if any if ($module->getVar('hasconfig') != 0 || $module->getVar('hascomments') != 0) { $config_handler =& xoops_gethandler('config'); $configs =& $config_handler->getConfigs(new Criteria('conf_modid', $module->getVar('mid'))); $confcount = count($configs); if ($confcount > 0) { $msgs[] = '删除模块设置参数...'; for ($i = 0; $i < $confcount; $i++) { if (!$config_handler->deleteConfig($configs[$i])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: 无法从数据库中删除参数 ID: <b>'.$configs[$i]->getvar('conf_id').'</b></span>'; } else { $msgs[] = ' 参数数据已从数据库中删除. 参数 ID: <b>'.$configs[$i]->getVar('conf_id').'</b>'; } } } } // execute module specific install script if any $uninstall_script = $module->getInfo('onUninstall'); if (false != $uninstall_script && trim($uninstall_script) != '') { include_once XOOPS_ROOT_PATH.'/modules/'.$dirname.'/'.trim($uninstall_script); if (function_exists('xoops_module_uninstall_'.$dirname)) { $func = 'xoops_module_uninstall_'.$dirname; if (!$func($module)) { $msgs[] = '无法执行 <b>'.$func.'</b>'; } else { $msgs[] = '<b>'.$func.'</b> 已成功执行.'; } } } $msgs[] = '</code><p>'.sprintf(_MD_AM_OKUNINS, "<b>".$module->getVar('name')."</b>").'</p>'; } $ret = '<code>'; foreach ($msgs as $msg) { $ret .= $msg.'<br />'; } return $ret; }}function xoops_module_activate($mid){ $module_handler =& xoops_gethandler('module'); $module =& $module_handler->get($mid); include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_clear_module_cache($module->getVar('mid')); $module->setVar('isactive', 1); if (!$module_handler->insert($module)) { $ret = "<p>".sprintf(_MD_AM_FAILACT, "<b>".$module->getVar('name')."</b>")." "._MD_AM_ERRORSC."<br />".$module->getHtmlErrors(); return $ret."</p>"; } $blocks =& XoopsBlock::getByModule($module->getVar('mid')); $bcount = count($blocks); for ($i = 0; $i < $bcount; $i++) { $blocks[$i]->setVar('isactive', 1); $blocks[$i]->store(); } return "<p>".sprintf(_MD_AM_OKACT, "<b>".$module->getVar('name')."</b>")."</p>";}function xoops_module_deactivate($mid){ global $xoopsConfig; $module_handler =& xoops_gethandler('module'); $module =& $module_handler->get($mid); include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_clear_module_cache($mid); $module->setVar('isactive', 0); if ($module->getVar('dirname') == "system") { return "<p>".sprintf(_MD_AM_FAILDEACT, "<b>".$module->getVar('name')."</b>")." "._MD_AM_ERRORSC."<br /> - "._MD_AM_SYSNO."</p>"; } elseif ($module->getVar('dirname') == $xoopsConfig['startpage']) { return "<p>".sprintf(_MD_AM_FAILDEACT, "<b>".$module->getVar('name')."</b>")." "._MD_AM_ERRORSC."<br /> - "._MD_AM_STRTNO."</p>"; } else { if (!$module_handler->insert($module)) { $ret = "<p>".sprintf(_MD_AM_FAILDEACT, "<b>".$module->getVar('name')."</b>")." "._MD_AM_ERRORSC."<br />".$module->getHtmlErrors(); return $ret."</p>"; } $blocks =& XoopsBlock::getByModule($module->getVar('mid')); $bcount = count($blocks); for ($i = 0; $i < $bcount; $i++) { $blocks[$i]->setVar('isactive', 0); $blocks[$i]->store(); } return "<p>".sprintf(_MD_AM_OKDEACT, "<b>".$module->getVar('name')."</b>")."</p>"; }}function xoops_module_change($mid, $weight, $name){ $module_handler =& xoops_gethandler('module'); $module =& $module_handler->get($mid); $module->setVar('weight', $weight); $module->setVar('name', $name); $myts =& MyTextSanitizer::getInstance(); if (!$module_handler->insert($module)) { $ret = "<p>".sprintf(_MD_AM_FAILORDER, "<b>".$myts->stripSlashesGPC($name)."</b>")." "._MD_AM_ERRORSC."<br />"; $ret .= $module->getHtmlErrors()."</p>"; return $ret; } return "<p>".sprintf(_MD_AM_OKORDER, "<b>".$myts->stripSlashesGPC($name)."</b>")."</p>";}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -