📄 main.php
字号:
if (!$gperm_handler->insert($bperm)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not add block access right. Block ID: <b>'.$newbid.'</b> Group ID: <b>'.$mygroup.'</b></span>';
} else {
$msgs[] = ' Added block access right. Block ID: <b>'.$newbid.'</b> Group ID: <b>'.$mygroup.'</b>';
}
}
if ($template != '') {
$tplfile =& $tplfile_handler->create();
$tplfile->setVar('tpl_module', $dirname);
$tplfile->setVar('tpl_refid', $newbid);
$tplfile->setVar('tpl_source', $content, true);
$tplfile->setVar('tpl_tplset', 'default');
$tplfile->setVar('tpl_file', $block['template'], true);
$tplfile->setVar('tpl_type', 'block');
$tplfile->setVar('tpl_lastimported', 0);
$tplfile->setVar('tpl_lastmodified', time());
$tplfile->setVar('tpl_desc', $block['description'], true);
if (!$tplfile_handler->insert($tplfile)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert template <b>'.$block['template'].'</b> to the database.</span>';
} else {
$newid = $tplfile->getVar('tpl_id');
$msgs[] = ' Template <b>'.$block['template'].'</b> added to the database.';
if ($xoopsConfig['template_set'] == 'default') {
if (!xoops_template_touch($newid)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Template <b>'.$block['template'].'</b> recompile failed.</span>';
} else {
$msgs[] = ' Template <b>'.$block['template'].'</b> recompiled.';
}
}
}
}
$msgs[] = ' Block <b>'.$block['name'].'</b> created. Block ID: <b>'.$newbid.'</b>';
$sql = 'INSERT INTO '.$xoopsDB->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newbid.', -1)';
$xoopsDB->query($sql);
}
}
}
}
$block_arr = XoopsBlock::getByModule($module->getVar('mid'));
foreach ($block_arr as $block) {
if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
$sql = sprintf("DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix('newblocks'), $block->getVar('bid'));
if(!$xoopsDB->query($sql)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete block <b>'.$block->getVar('name').'</b>. Block ID: <b>'.$block->getVar('bid').'</b></span>';
} else {
$msgs[] = ' Block <b>'.$block->getVar('name').' deleted. Block ID: <b>'.$block->getVar('bid').'</b>';
if ($block->getVar('template') != '') {
$tplfiles =& $tplfile_handler->find(null, 'block', $block->getVar('bid'));
if (is_array($tplfiles)) {
$btcount = count($tplfiles);
for ($k = 0; $k < $btcount; $k++) {
if (!$tplfile_handler->delete($tplfiles[$k])) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not remove deprecated block template. (ID: <b>'.$tplfiles[$k]->getVar('tpl_id').'</b>)</span>';
} else {
$msgs[] = ' Block template <b>'.$tplfiles[$k]->getVar('tpl_file').'</b> deprecated.';
}
}
}
}
}
}
}
}
// first delete all config entries
$config_handler =& xoops_gethandler('config');
$configs =& $config_handler->getConfigs(new Criteria('conf_modid', $module->getVar('mid')));
$confcount = count($configs);
$config_delng = array();
if ($confcount > 0) {
$msgs[] = 'Deleting module config options...';
for ($i = 0; $i < $confcount; $i++) {
if (!$config_handler->deleteConfig($configs[$i])) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete config data from the database. Config ID: <b>'.$configs[$i]->getvar('conf_id').'</b></span>';
// save the name of config failed to delete for later use
$config_delng[] = $configs[$i]->getvar('conf_name');
} else {
$config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N');
$config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype');
$config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype');
$msgs[] = ' Config data deleted from the database. Config ID: <b>'.$configs[$i]->getVar('conf_id').'</b>';
}
}
}
// now reinsert them with the new settings
$configs = $module->getInfo('config');
if ($configs != false) {
if ($module->getVar('hascomments') != 0) {
include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');
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)));
array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
}
} else {
if ($module->getVar('hascomments') != 0) {
$configs = array();
include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');
$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));
$configs[] = array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0);
}
}
// RMV-NOTIFY
if ($module->getVar('hasnotification') != 0) {
if (empty($configs)) {
$configs = array();
}
// Main notification options
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
$options = array();
$options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
$options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
$options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
$options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
//$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);
$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLE', 'description' => '_NOT_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options'=>$options);
// Event specific notification options
// FIXME: for some reason the default doesn't come up properly
// initially is ok, but not when 'update' module..
$options = array();
$categories =& notificationCategoryInfo('',$module->getVar('mid'));
foreach ($categories as $category) {
$events =& notificationEvents ($category['name'], false, $module->getVar('mid'));
foreach ($events as $event) {
if (!empty($event['invisible'])) {
continue;
}
$option_name = $category['title'] . ' : ' . $event['title'];
$option_value = $category['name'] . '-' . $event['name'];
$options[$option_name] = $option_value;
//$configs[] = array ('name' => notificationGenerateConfig($category,$event,'name'), 'title' => notificationGenerateConfig($category,$event,'title_constant'), 'description' => notificationGenerateConfig($category,$event,'description_constant'), 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);
}
}
$configs[] = array ('name' => 'notification_events', 'title' => '_NOT_CONFIG_EVENTS', 'description' => '_NOT_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options);
}
if ($configs != false) {
$msgs[] = 'Adding module config data...';
$config_handler =& xoops_gethandler('config');
$order = 0;
foreach ($configs as $config) {
// only insert ones that have been deleted previously with success
if (!in_array($config['name'], $config_delng)) {
$confobj =& $config_handler->createConfig();
$confobj->setVar('conf_modid', $newmid);
$confobj->setVar('conf_catid', 0);
$confobj->setVar('conf_name', $config['name']);
$confobj->setVar('conf_title', $config['title'], true);
$confobj->setVar('conf_desc', $config['description'], true);
$confobj->setVar('conf_formtype', $config['formtype']);
$confobj->setVar('conf_valuetype', $config['valuetype']);
if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) {
// preserver the old value if any
// form type and value type must be the same
$confobj->setVar('conf_value', $config_old[$config['name']]['value'], true);
} else {
$confobj->setConfValueForInput($config['default'], true);
//$confobj->setVar('conf_value', $config['default'], true);
}
$confobj->setVar('conf_order', $order);
$confop_msgs = '';
if (isset($config['options']) && is_array($config['options'])) {
foreach ($config['options'] as $key => $value) {
$confop =& $config_handler->createConfigOption();
$confop->setVar('confop_name', $key, true);
$confop->setVar('confop_value', $value, true);
$confobj->setConfOptions($confop);
$confop_msgs .= '<br /> Config option added. Name: <b>'.$key.'</b> Value: <b>'.$value.'</b>';
unset($confop);
}
}
$order++;
if (false != $config_handler->insertConfig($confobj)) {
$msgs[] = ' Config <b>'.$config['name'].'</b> added to the database.'.$confop_msgs;
} else {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert config <b>'.$config['name'].'</b> to the database.</span>';
}
unset($confobj);
}
}
unset($configs);
}
// execute module specific update script if any
$update_script = $module->getInfo('onUpdate');
if (false != $update_script && trim($update_script) != '') {
include_once XOOPS_ROOT_PATH.'/modules/'.$dirname.'/'.trim($update_script);
if (function_exists('xoops_module_update_'.$dirname)) {
$func = 'xoops_module_update_'.$dirname;
if (!$func($module, $prev_version)) {
$msgs[] = 'Failed to execute '.$func;
} else {
$msgs[] = '<b>'.$func.'</b> executed successfully.';
}
}
}
foreach ($msgs as $msg) {
echo '<code>'.$msg.'</code><br />';
}
echo "<p>".sprintf(_MD_AM_OKUPD, "<b>".$module->getVar('name')."</b>")."</p>";
}
echo "<br /><a href='admin.php?fct=modulesadmin'>"._MD_AM_BTOMADMIN."</a>";
xoops_cp_footer();
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -