44 $reservedTables = array(
'avatar',
'avatar_users_link',
'block_module_link',
'xoopscomments',
'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',
'xoopsnotifications',
'banner',
'bannerclient',
'bannerfinish');
51 $module->setVar(
'last_update', time() );
56 $msgs[] =
'<div id="xo-module-log"><div class="header">';
58 if (
$module->getInfo(
'image') !=
false && trim(
$module->getInfo(
'image')) !=
'') {
59 $msgs[] =
'<a href="'.XOOPS_URL.
'/modules/'.
$module->getInfo(
'dirname',
'e').
'/'.
$module->getInfo(
'adminindex').
'"><img src="' . XOOPS_URL .
'/modules/' .
$dirname .
'/' . trim(
$module->getInfo(
'image')) .
'" alt="" /></a>';
61 $msgs[] =
'<strong>' .
_VERSION .
':</strong> ' .
$module->getInfo(
'version');
62 if (
$module->getInfo(
'author') !=
false && trim(
$module->getInfo(
'author')) !=
'') {
63 $msgs[] =
'<strong>' .
_AUTHOR .
':</strong> ' . htmlspecialchars(trim(
$module->getInfo(
'author')));
65 $msgs[] =
'</div><div class="logger">';
67 $install_script =
$module->getInfo(
'onInstall');
68 if ($install_script && trim($install_script) !=
'') {
69 include_once XOOPS_ROOT_PATH .
'/modules/' .
$dirname .
'/' . trim($install_script);
71 $func =
"xoops_module_pre_install_{$dirname}";
73 if (function_exists($func)) {
78 $errs = array_merge($errs,
$module->getErrors());
86 $sqlfile =
$module->getInfo(
'sqlfile');
90 if (!file_exists($sql_file_path)) {
95 include_once XOOPS_ROOT_PATH .
'/class/database/sqlutility.php';
96 $sql_query = fread(fopen($sql_file_path,
'r'), filesize($sql_file_path));
97 $sql_query = trim($sql_query);
99 $created_tables = array();
100 foreach ($pieces as $piece) {
104 if (!$prefixed_query) {
110 if (!in_array($prefixed_query[4], $reservedTables)) {
112 if (!
$db->query($prefixed_query[0])) {
113 $errs[] =
$db->error();
118 if (!in_array($prefixed_query[4], $created_tables)) {
120 $created_tables[] = $prefixed_query[4];
134 foreach ($created_tables as $ct) {
135 $db->query(
"DROP TABLE " .
$db->prefix($ct));
145 foreach ($created_tables as $ct) {
146 $db->query(
"DROP TABLE " .
$db->prefix($ct));
149 foreach ($errs as $err) {
150 $ret .=
" - " . $err .
"<br />";
154 unset($created_tables);
159 $newmid =
$module->getVar(
'mid');
160 unset($created_tables);
163 $templates =
$module->getInfo(
'templates');
164 if ($templates !=
false) {
166 foreach ($templates as
$tpl) {
167 $tplfile =& $tplfile_handler->create();
168 $type = (isset($tpl[
'type']) ? $tpl[
'type'] :
'module');
170 $tplfile->setVar(
'tpl_source', $tpldata,
true);
171 $tplfile->setVar(
'tpl_refid', $newmid);
173 $tplfile->setVar(
'tpl_tplset',
'default');
174 $tplfile->setVar(
'tpl_file', $tpl[
'file']);
175 $tplfile->setVar(
'tpl_desc', $tpl[
'description'],
true);
176 $tplfile->setVar(
'tpl_module',
$dirname);
177 $tplfile->setVar(
'tpl_lastmodified', time());
178 $tplfile->setVar(
'tpl_lastimported', time());
179 $tplfile->setVar(
'tpl_type',
$type);
180 if (!$tplfile_handler->insert($tplfile)) {
183 $newtplid = $tplfile->getVar(
'tpl_id');
186 include_once XOOPS_ROOT_PATH .
'/class/template.php';
193 unset($tplfile, $tpldata);
196 include_once XOOPS_ROOT_PATH .
'/class/template.php';
198 $blocks =
$module->getInfo(
'blocks');
199 if ($blocks !=
false) {
201 foreach ($blocks as $blockkey => $block) {
203 if (!isset($block[
'file']) || !isset($block[
'show_func'])) {
207 if (!empty($block[
'options'])) {
210 $newbid =
$db->genId(
$db->prefix(
'newblocks') .
'_bid_seq');
211 $edit_func = isset($block[
'edit_func']) ? trim($block[
'edit_func']) :
'';
213 if ((isset($block[
'template']) && trim($block[
'template']) !=
'')) {
219 $template = trim($block[
'template']);
221 $block_name = addslashes(trim($block[
'name']));
222 $sql =
"INSERT INTO " .
$db->prefix(
"newblocks") .
" (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified) VALUES ($newbid, $newmid, " . intval($blockkey) .
", '$options', '" . $block_name .
"','" . $block_name .
"', '', 0, 0, 0, 'M', 'H', 1, '" . addslashes(
$dirname) .
"', '" . addslashes(trim($block[
'file'])) .
"', '" . addslashes(trim($block[
'show_func'])) .
"', '" . addslashes($edit_func) .
"', '" . $template .
"', 0, " . time() .
")";
226 if (empty($newbid)) {
227 $newbid =
$db->getInsertId();
230 $sql =
'INSERT INTO ' .
$db->prefix(
'block_module_link') .
' (block_id, module_id) VALUES (' . $newbid .
', -1)';
232 if ($template !=
'') {
233 $tplfile =& $tplfile_handler->create();
234 $tplfile->setVar(
'tpl_refid', $newbid);
235 $tplfile->setVar(
'tpl_source',
$content,
true);
236 $tplfile->setVar(
'tpl_tplset',
'default');
237 $tplfile->setVar(
'tpl_file', $block[
'template']);
238 $tplfile->setVar(
'tpl_module',
$dirname);
239 $tplfile->setVar(
'tpl_type',
'block');
240 $tplfile->setVar(
'tpl_desc', $block[
'description'],
true);
241 $tplfile->setVar(
'tpl_lastimported', 0);
242 $tplfile->setVar(
'tpl_lastmodified', time());
243 if (!$tplfile_handler->insert($tplfile)) {
246 $newtplid = $tplfile->getVar(
'tpl_id');
249 include_once XOOPS_ROOT_PATH .
'/class/template.php';
266 if (
$module->getVar(
'hascomments') != 0) {
267 include_once XOOPS_ROOT_PATH .
'/include/comment_constants.php';
268 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)));
269 array_push(
$configs, array(
'name' =>
'com_anonpost',
'title' =>
'_CM_COMANONPOST',
'description' =>
'',
'formtype' =>
'yesno',
'valuetype' =>
'int',
'default' => 0));
272 if (
$module->getVar(
'hascomments') != 0) {
274 include_once XOOPS_ROOT_PATH .
'/include/comment_constants.php';
276 $configs[] = array(
'name' =>
'com_anonpost',
'title' =>
'_CM_COMANONPOST',
'description' =>
'',
'formtype' =>
'yesno',
'valuetype' =>
'int',
'default' => 0);
280 if (
$module->getVar(
'hasnotification') != 0) {
285 include_once XOOPS_ROOT_PATH .
'/include/notification_constants.php';
286 include_once XOOPS_ROOT_PATH .
'/include/notification_functions.php';
293 $configs[] = array (
'name' =>
'notification_enabled',
'title' =>
'_NOT_CONFIG_ENABLE',
'description' =>
'_NOT_CONFIG_ENABLEDSC',
'formtype' =>
'select',
'valuetype' =>
'int',
'default' =>
XOOPS_NOTIFICATION_ENABLEBOTH,
'options' =>
$options);
298 foreach ($categories as $category) {
300 foreach ($events as $event) {
301 if (!empty($event[
'invisible'])) {
304 $option_name = $category[
'title'] .
' : ' . $event[
'title'];
305 $option_value = $category[
'name'] .
'-' . $event[
'name'];
306 $options[$option_name] = $option_value;
311 $configs[] = array (
'name' =>
'notification_events',
'title' =>
'_NOT_CONFIG_EVENTS',
'description' =>
'_NOT_CONFIG_EVENTSDSC',
'formtype' =>
'select_multi',
'valuetype' =>
'array',
'default' => array_values(
$options),
'options' =>
$options);
320 $confobj->setVar(
'conf_modid', $newmid);
321 $confobj->setVar(
'conf_catid', 0);
322 $confobj->setVar(
'conf_name', $config[
'name']);
323 $confobj->setVar(
'conf_title', $config[
'title'],
true);
324 $confobj->setVar(
'conf_desc', $config[
'description'],
true);
325 $confobj->setVar(
'conf_formtype', $config[
'formtype']);
326 $confobj->setVar(
'conf_valuetype', $config[
'valuetype']);
327 $confobj->setConfValueForInput($config[
'default'],
true);
328 $confobj->setVar(
'conf_order', $order);
330 if (isset($config[
'options']) && is_array($config[
'options'])) {
331 foreach ($config[
'options'] as $key => $value) {
333 $confop->setVar(
'confop_name', $key,
true);
334 $confop->setVar(
'confop_value', $value,
true);
335 $confobj->setConfOptions($confop);
352 if (
$module->getInfo(
'hasMain')) {
353 $groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
355 $groups = array(XOOPS_GROUP_ADMIN);
361 foreach (
$groups as $mygroup) {
364 $mperm->setVar(
'gperm_groupid', $mygroup);
365 $mperm->setVar(
'gperm_itemid', $newmid);
366 $mperm->setVar(
'gperm_name',
'module_admin');
367 $mperm->setVar(
'gperm_modid', 1);
376 $mperm->setVar(
'gperm_groupid', $mygroup);
377 $mperm->setVar(
'gperm_itemid', $newmid);
378 $mperm->setVar(
'gperm_name',
'module_read');
379 $mperm->setVar(
'gperm_modid', 1);
386 foreach ($blocks as $blc) {
388 $bperm->setVar(
'gperm_groupid', $mygroup);
389 $bperm->setVar(
'gperm_itemid', $blc);
390 $bperm->setVar(
'gperm_name',
'block_read');
391 $bperm->setVar(
'gperm_modid', 1);
393 $msgs[] =
' <span style="color:#ff0000;">' .
_AM_SYSTEM_MODULES_BLOCK_ACCESS_ERROR .
' Block ID: <strong>' . $blc .
'</strong> Group ID: <strong>' . $mygroup .
'</strong></span>';
404 $func =
"xoops_module_install_{$dirname}";
405 if (function_exists($func)) {
406 if (!$lastmsg = $func(
$module)) {
410 if (is_string($lastmsg)) {
417 $msgs[] =
'</div></div>';
419 $blocks =
$module->getInfo(
'blocks');
423 if ($blocks !=
false) {
424 $msgs[] =
'<div class="center"><a href="admin.php?fct=blocksadmin&op=list&filter=1&selgen=' . $newmid .
'&selmod=-2&selgrp=-1&selvis=-1&filsave=1">' .
_AM_SYSTEM_BLOCKS .
'</a></div>';
427 $msgs[] =
'<div class="noininstall center"><a href="admin.php?fct=preferences&op=showmod&mod=' . $newmid .
'">' .
_AM_SYSTEM_PREF .
'</a>';
430 $ret = implode(
'<br />', $msgs);
453 case 'blocks':
case 'admin':
454 $path = XOOPS_ROOT_PATH .
'/modules/' .
$dirname .
'/templates/' .
$type .
'/' . $template;
457 $path = XOOPS_ROOT_PATH .
'/modules/' .
$dirname .
'/templates/' . $template;
460 if (!file_exists(
$path)) {
463 $lines = file(
$path);
468 $count = count($lines);
469 for (
$i = 0;
$i < $count;
$i++) {
470 $ret .= str_replace(
"\n",
"\r\n", str_replace(
"\r\n",
"\n", $lines[
$i]));
478 $reservedTables = array(
'avatar',
'avatar_users_link',
'block_module_link',
'xoopscomments',
'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',
'xoopsnotifications',
'banner',
'bannerclient',
'bannerfinish');
482 include_once XOOPS_ROOT_PATH .
'/class/template.php';
484 if (
$module->getVar(
'dirname') ==
'system') {
486 } elseif (
$module->getVar(
'dirname') == $xoopsConfig[
'startpage']) {
490 $msgs[] =
'<div id="xo-module-log"><div class="header">';
492 if (
$module->getInfo(
'image') !=
false && trim(
$module->getInfo(
'image')) !=
'') {
493 $msgs[] =
'<img src="' . XOOPS_URL .
'/modules/' .
$dirname .
'/' . trim(
$module->getInfo(
'image')) .
'" alt="" />';
495 $msgs[] =
'<strong>' .
_VERSION .
':</strong> ' .
$module->getInfo(
'version');
496 if (
$module->getInfo(
'author') !=
false && trim(
$module->getInfo(
'author')) !=
'') {
497 $msgs[] =
'<strong>' .
_AUTHOR .
':</strong> ' . htmlspecialchars(trim(
$module->getInfo(
'author')));
499 $msgs[] =
'</div><div class="logger">';
501 $uninstall_script =
$module->getInfo(
'onUninstall');
502 if ($uninstall_script && trim($uninstall_script) !=
'') {
503 include_once XOOPS_ROOT_PATH .
'/modules/' .
$dirname .
'/' . trim($uninstall_script);
505 $func =
"xoops_module_pre_uninstall_{$dirname}";
507 if (function_exists($func)) {
525 $templates = $tplfile_handler->find(null,
'module',
$module->getVar(
'mid'));
526 $tcount = count($templates);
529 for (
$i = 0;
$i < $tcount;
$i++) {
530 if (
false === $tplfile_handler->delete($templates[
$i])) {
541 if (is_array($block_arr)) {
542 $bcount = count($block_arr);
544 for (
$i = 0;
$i < $bcount;
$i++) {
545 if (
false === $block_arr[
$i]->
delete()) {
550 if ($block_arr[
$i]->getVar(
'template') !=
'') {
551 $templates = $tplfile_handler->find(null,
'block', $block_arr[
$i]->getVar(
'bid'));
552 $btcount = count($templates);
554 for (
$j = 0;
$j < $btcount;
$j++) {
555 if (!$tplfile_handler->delete($templates[
$j])) {
568 $modtables =
$module->getInfo(
'tables');
569 if ($modtables !=
false && is_array($modtables)) {
571 foreach ($modtables as $table) {
573 if (!in_array($table, $reservedTables)) {
574 $sql =
'DROP TABLE ' .
$db->prefix($table);
587 if (
$module->getVar(
'hascomments') != 0) {
599 if (
$module->getVar(
'hasnotification') != 0) {
617 if (
$module->getVar(
'hasconfig') != 0 ||
$module->getVar(
'hascomments') != 0) {
621 if ($confcount > 0) {
623 for (
$i = 0;
$i < $confcount;
$i++) {
634 $func =
'xoops_module_uninstall_' .
$dirname;
635 if (function_exists($func)) {
644 $msgs[] =
'</div></div>';
646 $ret = implode(
"<br />", $msgs);
656 include_once XOOPS_ROOT_PATH .
'/class/template.php';
659 $msgs[] =
'<div id="xo-module-log">';
662 $module->setVar(
'isactive', 1);
667 $bcount = count($blocks);
668 for (
$i = 0;
$i < $bcount;
$i++) {
669 $blocks[
$i]->setVar(
'isactive', 1);
670 $blocks[
$i]->store();
676 $ret = implode(
'<br />', $msgs);
686 include_once XOOPS_ROOT_PATH .
'/class/template.php';
689 $msgs[] =
'<div id="xo-module-log">';
692 $module->setVar(
'isactive', 0);
693 if (
$module->getVar(
'dirname') ==
"system") {
695 } elseif (
$module->getVar(
'dirname') == $xoopsConfig[
'startpage']) {
702 $bcount = count($blocks);
703 for (
$i = 0;
$i < $bcount;
$i++) {
704 $blocks[
$i]->setVar(
'isactive', 0);
705 $blocks[
$i]->store();
711 $ret = implode(
'<br />', $msgs);
719 $module->setVar(
'name', $name);
731 $msgs[] =
'<div class="header">';
732 $msgs[] = $errs[] =
'<h4>' .
$title .
$module->getInfo(
'name',
's') .
'</h4>';
733 if (
$module->getInfo(
'image') !=
false && trim(
$module->getInfo(
'image')) !=
'') {
734 $msgs[] =
'<img src="' . XOOPS_URL .
'/modules/' .
$module->getVar(
'dirname') .
'/' . trim(
$module->getInfo(
'image')) .
'" alt="" />';
736 $msgs[] =
'<strong>' .
_VERSION .
':</strong> ' .
$module->getInfo(
'version');
737 if (
$module->getInfo(
'author') !=
false && trim(
$module->getInfo(
'author')) !=
'') {
738 $msgs[] =
'<strong>' .
_AUTHOR .
':</strong> ' . htmlspecialchars(trim(
$module->getInfo(
'author')));