1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18:
19:
20: 21: 22: 23: 24:
25:
26: 27: 28: 29: 30:
31: function xoops_module_install($dirname)
32: {
33: global $xoopsUser, $xoopsConfig;
34: $dirname = trim($dirname);
35: $db =& $GLOBALS['xoopsDB'];
36: $reservedTables = array(
37: 'avatar',
38: 'avatar_users_link',
39: 'block_module_link',
40: 'xoopscomments',
41: 'config',
42: 'configcategory',
43: 'configoption',
44: 'image',
45: 'imagebody',
46: 'imagecategory',
47: 'imgset',
48: 'imgset_tplset_link',
49: 'imgsetimg',
50: 'groups',
51: 'groups_users_link',
52: 'group_permission',
53: 'online',
54: 'bannerclient',
55: 'banner',
56: 'bannerfinish',
57: 'priv_msgs',
58: 'ranks',
59: 'session',
60: 'smiles',
61: 'users',
62: 'newblocks',
63: 'modules',
64: 'tplfile',
65: 'tplset',
66: 'tplsource',
67: 'xoopsnotifications',
68: 'banner',
69: 'bannerclient',
70: 'bannerfinish');
71:
72: $module_handler = xoops_getHandler('module');
73: if ($module_handler->getCount(new Criteria('dirname', $dirname)) == 0) {
74: $module = $module_handler->create();
75: $module->loadInfoAsVar($dirname);
76: $module->setVar('weight', 1);
77: $module->setVar('isactive', 1);
78: $module->setVar('last_update', time());
79: $error = false;
80: $errs = array();
81: $msgs = array();
82:
83: $msgs[] = '<div id="xo-module-log"><div class="header">';
84: $msgs[] = $errs[] = '<h4>' . _AM_SYSTEM_MODULES_INSTALLING . $module->getInfo('name', 's') . '</h4>';
85: if ($module->getInfo('image') !== false && trim($module->getInfo('image')) != '') {
86: $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>';
87: }
88: $msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version') . ' ' . $module->getInfo('module_status');
89: if ($module->getInfo('author') !== false && trim($module->getInfo('author')) != '') {
90: $msgs[] = '<strong>' . _AUTHOR . ':</strong> ' . htmlspecialchars(trim($module->getInfo('author')));
91: }
92: $msgs[] = '</div><div class="logger">';
93:
94: $install_script = $module->getInfo('onInstall');
95: if ($install_script && trim($install_script) != '') {
96: include_once XOOPS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($install_script);
97: }
98: $func = "xoops_module_pre_install_{$dirname}";
99:
100: if (function_exists($func)) {
101: $result = $func($module);
102: if (!$result) {
103: $error = true;
104: $errs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_EXECUTE, $func) . '</p>';
105: $errs = array_merge($errs, $module->getErrors());
106: } else {
107: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_SUCESS, "<strong>{$func}</strong>") . '</p>';
108: $msgs += $module->getErrors();
109: }
110: }
111:
112: if ($error === false) {
113: $sqlfile = $module->getInfo('sqlfile');
114: if (is_array($sqlfile) && !empty($sqlfile[XOOPS_DB_TYPE])) {
115: $sql_file_path = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/' . $sqlfile[XOOPS_DB_TYPE];
116: if (!file_exists($sql_file_path)) {
117: $errs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_SQL_NOT_FOUND, "<strong>{$sql_file_path}</strong>");
118: $error = true;
119: } else {
120: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_SQL_FOUND, "<strong>{$sql_file_path}</strong>") . '<br />' . _AM_SYSTEM_MODULES_CREATE_TABLES;
121: include_once XOOPS_ROOT_PATH . '/class/database/sqlutility.php';
122: $sql_query = fread(fopen($sql_file_path, 'r'), filesize($sql_file_path));
123: $sql_query = trim($sql_query);
124: SqlUtility::splitMySqlFile($pieces, $sql_query);
125: $created_tables = array();
126: foreach ($pieces as $piece) {
127:
128:
129: $prefixed_query = SqlUtility::prefixQuery($piece, $db->prefix());
130: if (!$prefixed_query) {
131: $errs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_SQL_NOT_VALID, '<strong>' . $piece . '</strong>');
132: $error = true;
133: break;
134: }
135:
136: if (!in_array($prefixed_query[4], $reservedTables)) {
137:
138: if (!$db->query($prefixed_query[0])) {
139: $errs[] = $db->error();
140: $error = true;
141: break;
142: } else {
143: if (!in_array($prefixed_query[4], $created_tables)) {
144: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TABLE_CREATED, '<strong>' . $db->prefix($prefixed_query[4]) . '</strong>');
145: $created_tables[] = $prefixed_query[4];
146: } else {
147: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_INSERT_DATA, '<strong>' . $db->prefix($prefixed_query[4]) . '</strong>');
148: }
149: }
150: } else {
151:
152: $errs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TABLE_RESERVED, '<strong>' . $prefixed_query[4] . '</strong>');
153: $error = true;
154: break;
155: }
156: }
157:
158: if ($error === true) {
159: foreach ($created_tables as $ct) {
160: $db->query('DROP TABLE ' . $db->prefix($ct));
161: }
162: }
163: }
164: }
165: }
166:
167: if ($error === false) {
168: if (!$module_handler->insert($module)) {
169: $errs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_INSERT_DATA_FAILD, '<strong>' . $module->getVar('name') . '</strong>');
170: foreach ($created_tables as $ct) {
171: $db->query('DROP TABLE ' . $db->prefix($ct));
172: }
173: $ret = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILINS, '<strong>' . $module->name() . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br>';
174: foreach ($errs as $err) {
175: $ret .= ' - ' . $err . '<br>';
176: }
177: $ret .= '</p>';
178: unset($module, $created_tables, $errs, $msgs);
179:
180: return $ret;
181: } else {
182: $newmid = $module->getVar('mid');
183: unset($created_tables);
184: $msgs[] = '<p>' . _AM_SYSTEM_MODULES_INSERT_DATA_DONE . sprintf(_AM_SYSTEM_MODULES_MODULEID, '<strong>' . $newmid . '</strong>');
185: $tplfile_handler = xoops_getHandler('tplfile');
186: $templates = $module->getInfo('templates');
187: if ($templates !== false) {
188: $msgs[] = _AM_SYSTEM_MODULES_TEMPLATES_ADD;
189: foreach ($templates as $tpl) {
190: $tplfile = $tplfile_handler->create();
191: $type = (isset($tpl['type']) ? $tpl['type'] : 'module');
192: $tpldata =& xoops_module_gettemplate($dirname, $tpl['file'], $type);
193: $tplfile->setVar('tpl_source', $tpldata, true);
194: $tplfile->setVar('tpl_refid', $newmid);
195:
196: $tplfile->setVar('tpl_tplset', 'default');
197: $tplfile->setVar('tpl_file', $tpl['file']);
198: $tplfile->setVar('tpl_desc', $tpl['description'], true);
199: $tplfile->setVar('tpl_module', $dirname);
200: $tplfile->setVar('tpl_lastmodified', time());
201: $tplfile->setVar('tpl_lastimported', time());
202: $tplfile->setVar('tpl_type', $type);
203: if (!$tplfile_handler->insert($tplfile)) {
204: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_ERROR, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
205: } else {
206: $newtplid = $tplfile->getVar('tpl_id');
207: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_DATA, '<strong>' . $tpl['file'] . '</strong>') . '(ID: <strong>' . $newtplid . '</strong>)';
208:
209: include_once XOOPS_ROOT_PATH . '/class/template.php';
210: if (!xoops_template_touch($newtplid)) {
211: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_COMPILED_FAILED, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
212: } else {
213: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_COMPILED, '<strong>' . $tpl['file'] . '</strong>');
214: }
215: }
216: unset($tplfile, $tpldata);
217: }
218: }
219: include_once XOOPS_ROOT_PATH . '/class/template.php';
220: xoops_template_clear_module_cache($newmid);
221: $blocks = $module->getInfo('blocks');
222: if ($blocks !== false) {
223: $msgs[] = _AM_SYSTEM_MODULES_BLOCKS_ADD;
224: foreach ($blocks as $blockkey => $block) {
225:
226: if (!isset($block['file']) || !isset($block['show_func'])) {
227: break;
228: }
229: $options = '';
230: if (!empty($block['options'])) {
231: $options = trim($block['options']);
232: }
233: $newbid = $db->genId($db->prefix('newblocks') . '_bid_seq');
234: $edit_func = isset($block['edit_func']) ? trim($block['edit_func']) : '';
235: $template = '';
236: if (isset($block['template']) && trim($block['template']) != '') {
237: $content =& xoops_module_gettemplate($dirname, $block['template'], 'blocks');
238: }
239: if (empty($content)) {
240: $content = '';
241: } else {
242: $template = trim($block['template']);
243: }
244: $block_name = addslashes(trim($block['name']));
245: $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, " . (int)$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() . ')';
246: if (!$db->query($sql)) {
247: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_BLOCK_ADD_ERROR, '<strong>' . $block['name'] . '</strong>') . sprintf(_AM_SYSTEM_MODULES_BLOCK_ADD_ERROR_DATABASE, '<strong>' . $db->error() . '</strong>') . '</span>';
248: } else {
249: if (empty($newbid)) {
250: $newbid = $db->getInsertId();
251: }
252: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_BLOCK_ADD, '<strong>' . $block['name'] . '</strong>') . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $newbid . '</strong>');
253: $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newbid . ', -1)';
254: $db->query($sql);
255: if ($template != '') {
256: $tplfile = $tplfile_handler->create();
257: $tplfile->setVar('tpl_refid', $newbid);
258: $tplfile->setVar('tpl_source', $content, true);
259: $tplfile->setVar('tpl_tplset', 'default');
260: $tplfile->setVar('tpl_file', $block['template']);
261: $tplfile->setVar('tpl_module', $dirname);
262: $tplfile->setVar('tpl_type', 'block');
263: $tplfile->setVar('tpl_desc', $block['description'], true);
264: $tplfile->setVar('tpl_lastimported', 0);
265: $tplfile->setVar('tpl_lastmodified', time());
266: if (!$tplfile_handler->insert($tplfile)) {
267: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_ERROR, '<strong>' . $block['template'] . '</strong>') . '</span>';
268: } else {
269: $newtplid = $tplfile->getVar('tpl_id');
270: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_DATA, '<strong>' . $block['template'] . '</strong>') . ' (ID: <strong>' . $newtplid . '</strong>)';
271:
272: include_once XOOPS_ROOT_PATH . '/class/template.php';
273: if (!xoops_template_touch($newtplid)) {
274: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_COMPILED_FAILED, '<strong>' . $block['template'] . '</strong>') . '</span>';
275: } else {
276: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_COMPILED, '<strong>' . $block['template'] . '</strong>');
277: }
278: }
279: unset($tplfile);
280: }
281: }
282: unset($content);
283: }
284: unset($blocks);
285: }
286: $configs = $module->getInfo('config');
287: if ($configs !== false) {
288: if ($module->getVar('hascomments') != 0) {
289: include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
290: $configs[] = array(
291: 'name' => 'com_rule',
292: 'title' => '_CM_COMRULES',
293: 'description' => '',
294: 'formtype' => 'select',
295: 'valuetype' => 'int',
296: 'default' => 1,
297: 'options' => array(
298: '_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
299: '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
300: '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
301: '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
302: $configs[] = array(
303: 'name' => 'com_anonpost',
304: 'title' => '_CM_COMANONPOST',
305: 'description' => '',
306: 'formtype' => 'yesno',
307: 'valuetype' => 'int',
308: 'default' => 0);
309: }
310: } else {
311: if ($module->getVar('hascomments') != 0) {
312: $configs = array();
313: include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
314: $configs[] = array(
315: 'name' => 'com_rule',
316: 'title' => '_CM_COMRULES',
317: 'description' => '',
318: 'formtype' => 'select',
319: 'valuetype' => 'int',
320: 'default' => 1,
321: 'options' => array(
322: '_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
323: '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
324: '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
325: '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
326: $configs[] = array(
327: 'name' => 'com_anonpost',
328: 'title' => '_CM_COMANONPOST',
329: 'description' => '',
330: 'formtype' => 'yesno',
331: 'valuetype' => 'int',
332: 'default' => 0);
333: }
334: }
335:
336: if ($module->getVar('hasnotification') != 0) {
337: if (empty($configs)) {
338: $configs = array();
339: }
340:
341: include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
342: include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
343: $options = array();
344: $options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
345: $options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
346: $options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
347: $options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
348:
349: $configs[] = array(
350: 'name' => 'notification_enabled',
351: 'title' => '_NOT_CONFIG_ENABLE',
352: 'description' => '_NOT_CONFIG_ENABLEDSC',
353: 'formtype' => 'select',
354: 'valuetype' => 'int',
355: 'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
356: 'options' => $options);
357:
358:
359: $options = array();
360: $categories =& notificationCategoryInfo('', $module->getVar('mid'));
361: foreach ($categories as $category) {
362: $events =& notificationEvents($category['name'], false, $module->getVar('mid'));
363: foreach ($events as $event) {
364: if (!empty($event['invisible'])) {
365: continue;
366: }
367: $option_name = $category['title'] . ' : ' . $event['title'];
368: $option_value = $category['name'] . '-' . $event['name'];
369: $options[$option_name] = $option_value;
370: }
371: unset($events);
372: }
373: unset($categories);
374: $configs[] = array(
375: 'name' => 'notification_events',
376: 'title' => '_NOT_CONFIG_EVENTS',
377: 'description' => '_NOT_CONFIG_EVENTSDSC',
378: 'formtype' => 'select_multi',
379: 'valuetype' => 'array',
380: 'default' => array_values($options),
381: 'options' => $options);
382: }
383:
384: if ($configs !== false) {
385: $msgs[] = _AM_SYSTEM_MODULES_MODULE_DATA_ADD;
386:
387: $config_handler = xoops_getHandler('config');
388: $order = 0;
389: foreach ($configs as $config) {
390: $confobj = $config_handler->createConfig();
391: $confobj->setVar('conf_modid', $newmid);
392: $confobj->setVar('conf_catid', 0);
393: $confobj->setVar('conf_name', $config['name']);
394: $confobj->setVar('conf_title', $config['title'], true);
395: $confobj->setVar('conf_desc', isset($config['description']) ? $config['description'] : '', true);
396: $confobj->setVar('conf_formtype', $config['formtype']);
397: $confobj->setVar('conf_valuetype', $config['valuetype']);
398: $confobj->setConfValueForInput($config['default'], true);
399: $confobj->setVar('conf_order', $order);
400: $confop_msgs = '';
401: if (isset($config['options']) && is_array($config['options'])) {
402: foreach ($config['options'] as $key => $value) {
403: $confop = $config_handler->createConfigOption();
404: $confop->setVar('confop_name', $key, true);
405: $confop->setVar('confop_value', $value, true);
406: $confobj->setConfOptions($confop);
407: $confop_msgs .= '<br> ' . _AM_SYSTEM_MODULES_CONFIG_ADD . _AM_SYSTEM_MODULES_NAME . ' <strong>' . (defined($key) ? constant($key) : $key) . '</strong> ' . _AM_SYSTEM_MODULES_VALUE . ' <strong>' . $value . '</strong> ';
408: unset($confop);
409: }
410: }
411: ++$order;
412: if ($config_handler->insertConfig($confobj) != false) {
413: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_CONFIG_DATA_ADD, '<strong>' . $config['name'] . '</strong>') . $confop_msgs;
414: } else {
415: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_CONFIG_DATA_ADD_ERROR, '<strong>' . $config['name'] . '</strong>') . '</span>';
416: }
417: unset($confobj);
418: }
419: unset($configs);
420: }
421: }
422: $groups = array(XOOPS_GROUP_ADMIN);
423: if ($module->getInfo('hasMain')) {
424: $groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
425: }
426:
427: $blocks = XoopsBlock::getByModule($newmid, false);
428: $msgs[] = _AM_SYSTEM_MODULES_GROUP_SETTINGS_ADD;
429:
430: $gperm_handler = xoops_getHandler('groupperm');
431: foreach ($groups as $mygroup) {
432: if ($gperm_handler->checkRight('module_admin', 0, $mygroup)) {
433:
434: $mperm = $gperm_handler->create();
435: $mperm->setVar('gperm_groupid', $mygroup);
436: $mperm->setVar('gperm_itemid', $newmid);
437: $mperm->setVar('gperm_name', 'module_admin');
438: $mperm->setVar('gperm_modid', 1);
439: if (!$gperm_handler->insert($mperm)) {
440: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_ACCESS_ADMIN_ADD_ERROR, '<strong>' . $mygroup . '</strong>') . '</span>';
441: } else {
442: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_ACCESS_ADMIN_ADD, '<strong>' . $mygroup . '</strong>');
443: }
444: unset($mperm);
445: }
446: $mperm = $gperm_handler->create();
447: $mperm->setVar('gperm_groupid', $mygroup);
448: $mperm->setVar('gperm_itemid', $newmid);
449: $mperm->setVar('gperm_name', 'module_read');
450: $mperm->setVar('gperm_modid', 1);
451: if (!$gperm_handler->insert($mperm)) {
452: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_ACCESS_USER_ADD_ERROR, '<strong>' . $mygroup . '</strong>') . '</span>';
453: } else {
454: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_ACCESS_USER_ADD_ERROR, '<strong>' . $mygroup . '</strong>');
455: }
456: unset($mperm);
457: foreach ($blocks as $blc) {
458:
459: $bperm = $gperm_handler->create();
460: $bperm->setVar('gperm_groupid', $mygroup);
461: $bperm->setVar('gperm_itemid', $blc);
462: $bperm->setVar('gperm_name', 'block_read');
463: $bperm->setVar('gperm_modid', 1);
464: if (!$gperm_handler->insert($bperm)) {
465: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_BLOCK_ACCESS_ERROR . ' Block ID: <strong>' . $blc . '</strong> Group ID: <strong>' . $mygroup . '</strong></span>';
466: } else {
467: $msgs[] = ' ' . _AM_SYSTEM_MODULES_BLOCK_ACCESS . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $blc . '</strong>') . sprintf(_AM_SYSTEM_MODULES_GROUP_ID, '<strong>' . $mygroup . '</strong>');
468: }
469: unset($bperm);
470: }
471: }
472: unset($blocks, $groups);
473:
474:
475: $func = "xoops_module_install_{$dirname}";
476: if (function_exists($func)) {
477: if (!$lastmsg = $func($module)) {
478: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_EXECUTE, $func) . '</p>';
479: } else {
480: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_SUCESS, "<strong>{$func}</strong>") . '</p>';
481: if (is_string($lastmsg)) {
482: $msgs[] = $lastmsg;
483: }
484: }
485: }
486:
487: $msgs[] = sprintf(_AM_SYSTEM_MODULES_OKINS, '<strong>' . $module->getVar('name', 's') . '</strong>');
488: $msgs[] = '</div></div>';
489:
490: $blocks = $module->getInfo('blocks');
491: $redDevider = '<span class="red bold"> | </span>';
492: $msgs[] = '<div class="noininstall center"><a href="admin.php?fct=modulesadmin">' . _AM_SYSTEM_MODULES_BTOMADMIN . '</a> |
493: <a href="admin.php?fct=modulesadmin&op=installlist">' . _AM_SYSTEM_MODULES_TOINSTALL . '</a> | ';
494: $msgs[] = '<br><span class="red bold">' . _AM_SYSTEM_MODULES_MODULE . ' ' . $module->getInfo('name') . ': </span></div>';
495: if ($blocks !== false) {
496: $msgs[] = '<div class="noininstall 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>';
497: }
498: $msgs[] = '<div class="noininstall center"><a href="admin.php?fct=preferences&op=showmod&mod=' . $newmid . '">' . _AM_SYSTEM_PREF . '</a>';
499: $msgs[] = '<a href="' . XOOPS_URL . '/modules/' . $module->getInfo('dirname', 'e') . '/' . $module->getInfo('adminindex') . '">' . _AM_SYSTEM_MODULES_ADMIN . '</a>';
500:
501: $testdataDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getInfo('dirname', 'e') . '/testdata';
502: if (file_exists($testdataDirectory)) {
503: $msgs[] = '<a href="' . XOOPS_URL . '/modules/' . $module->getInfo('dirname', 'e') . '/testdata/index.php?op=load' . '">' . _AM_SYSTEM_MODULES_INSTALL_TESTDATA . '</a></div>';
504: } else {
505: $msgs[] = '</div>';
506: }
507:
508: $ret = implode('<br>', $msgs);
509: unset($blocks, $msgs, $errs, $module);
510:
511: return $ret;
512: } else {
513: $ret = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILINS, '<strong>' . $dirname . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br>' . implode('<br>', $errs) . '</p>';
514: unset($msgs, $errs);
515:
516: return $ret;
517: }
518: } else {
519: return '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILINS, '<strong>' . $dirname . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br> ' . sprintf(_AM_SYSTEM_MODULES_ALEXISTS, $dirname) . '</p>';
520: }
521: }
522:
523: 524: 525: 526: 527: 528: 529:
530: function &xoops_module_gettemplate($dirname, $template, $type = '')
531: {
532: global $xoopsConfig;
533: $ret = '';
534: switch ($type) {
535: case 'blocks':
536: case 'admin':
537: $path = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $type . '/' . $template;
538: break;
539: default:
540: $path = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
541: break;
542: }
543: if (!file_exists($path)) {
544: return $ret;
545: } else {
546: $lines = file($path);
547: }
548: if (!$lines) {
549: return $ret;
550: }
551: $count = count($lines);
552: for ($i = 0; $i < $count; ++$i) {
553: $ret .= str_replace("\n", "\r\n", str_replace("\r\n", "\n", $lines[$i]));
554: }
555:
556: return $ret;
557: }
558:
559: 560: 561: 562: 563:
564: function xoops_module_uninstall($dirname)
565: {
566: global $xoopsConfig;
567: $reservedTables = array(
568: 'avatar',
569: 'avatar_users_link',
570: 'block_module_link',
571: 'xoopscomments',
572: 'config',
573: 'configcategory',
574: 'configoption',
575: 'image',
576: 'imagebody',
577: 'imagecategory',
578: 'imgset',
579: 'imgset_tplset_link',
580: 'imgsetimg',
581: 'groups',
582: 'groups_users_link',
583: 'group_permission',
584: 'online',
585: 'bannerclient',
586: 'banner',
587: 'bannerfinish',
588: 'priv_msgs',
589: 'ranks',
590: 'session',
591: 'smiles',
592: 'users',
593: 'newblocks',
594: 'modules',
595: 'tplfile',
596: 'tplset',
597: 'tplsource',
598: 'xoopsnotifications',
599: 'banner',
600: 'bannerclient',
601: 'bannerfinish');
602: $db = XoopsDatabaseFactory::getDatabaseConnection();
603:
604: $module_handler = xoops_getHandler('module');
605: $module = $module_handler->getByDirname($dirname);
606: include_once XOOPS_ROOT_PATH . '/class/template.php';
607: xoops_template_clear_module_cache($module->getVar('mid'));
608: if ($module->getVar('dirname') === 'system') {
609: return '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILUNINS, '<strong>' . $module->getVar('name') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br> - ' . _AM_SYSTEM_MODULES_SYSNO . '</p>';
610: } elseif ($module->getVar('dirname') == $xoopsConfig['startpage']) {
611: return '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILUNINS, '<strong>' . $module->getVar('name') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br> - ' . _AM_SYSTEM_MODULES_STRTNO . '</p>';
612: } else {
613: $msgs = array();
614: $msgs[] = '<div id="xo-module-log"><div class="header">';
615: $msgs[] = $errs[] = '<h4>' . _AM_SYSTEM_MODULES_UNINSTALL . $module->getInfo('name', 's') . '</h4>';
616: if ($module->getInfo('image') !== false && trim($module->getInfo('image')) != '') {
617: $msgs[] = '<img src="' . XOOPS_URL . '/modules/' . $dirname . '/' . trim($module->getInfo('image')) . '" alt="" />';
618: }
619: $msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version') . ' ' . $module->getInfo('module_status');
620: if ($module->getInfo('author') !== false && trim($module->getInfo('author')) != '') {
621: $msgs[] = '<strong>' . _AUTHOR . ':</strong> ' . htmlspecialchars(trim($module->getInfo('author')));
622: }
623: $msgs[] = '</div><div class="logger">';
624:
625: $uninstall_script = $module->getInfo('onUninstall');
626: if ($uninstall_script && trim($uninstall_script) != '') {
627: include_once XOOPS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($uninstall_script);
628: }
629: $func = "xoops_module_pre_uninstall_{$dirname}";
630:
631: if (function_exists($func)) {
632: $result = $func($module);
633: if (false === $result) {
634: $errs = $module->getErrors();
635: $errs[] = sprintf(_AM_SYSTEM_MODULES_FAILED_EXECUTE, $func);
636:
637: return '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILUNINS, '<strong>' . $module->getVar('name') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br>' . implode('<br>', $errs) . '</p>';
638: } else {
639: $prevErrs = $module->getErrors();
640: array_unshift($prevErrs, '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_SUCESS, "<strong>{$func}</strong>") . '</p>');
641: $msgs = array_merge($msgs, $prevErrs);
642: }
643: }
644:
645: if (false === $module_handler->delete($module)) {
646: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_DELETE_ERROR, $module->getVar('name')) . '</span>';
647: } else {
648:
649:
650: $tplfile_handler = xoops_getHandler('tplfile');
651: $templates = $tplfile_handler->find(null, 'module', $module->getVar('mid'));
652: $tcount = count($templates);
653: if ($tcount > 0) {
654: $msgs[] = _AM_SYSTEM_MODULES_TEMPLATES_DELETE;
655: for ($i = 0; $i < $tcount; ++$i) {
656: if (false === $tplfile_handler->delete($templates[$i])) {
657: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_DELETE_DATA_FAILD, $templates[$i]->getVar('tpl_file')) . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ID, '<strong>' . $templates[$i]->getVar('tpl_id') . '</strong>') . '</span>';
658: } else {
659: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_DELETE_DATA, '<strong>' . $templates[$i]->getVar('tpl_file') . '</strong>') . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ID, '<strong>' . $templates[$i]->getVar('tpl_id') . '</strong>');
660: }
661: }
662: }
663: unset($templates);
664:
665:
666: $block_arr = XoopsBlock::getByModule($module->getVar('mid'));
667: if (is_array($block_arr)) {
668: $bcount = count($block_arr);
669: $msgs[] = _AM_SYSTEM_MODULES_BLOCKS_DELETE;
670: for ($i = 0; $i < $bcount; ++$i) {
671: if (false === $block_arr[$i]->delete()) {
672: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_BLOCK_DELETE_ERROR, '<strong>' . $block_arr[$i]->getVar('name') . '</strong>') . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $block_arr[$i]->getVar('bid') . '</strong>') . '</span>';
673: } else {
674: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_BLOCK_DELETE, '<strong>' . $block_arr[$i]->getVar('name') . '</strong>') . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $block_arr[$i]->getVar('bid') . '</strong>');
675: }
676: if ($block_arr[$i]->getVar('template') != '') {
677: $templates = $tplfile_handler->find(null, 'block', $block_arr[$i]->getVar('bid'));
678: $btcount = count($templates);
679: if ($btcount > 0) {
680: for ($j = 0; $j < $btcount; ++$j) {
681: if (!$tplfile_handler->delete($templates[$j])) {
682: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_BLOCK_DELETE_TEMPLATE_ERROR, $templates[$j]->getVar('tpl_file')) . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ID, '<strong>' . $templates[$j]->getVar('tpl_id') . '</strong>') . '</span>';
683: } else {
684: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_BLOCK_DELETE_DATA, '<strong>' . $templates[$j]->getVar('tpl_file') . '</strong>') . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ID, '<strong>' . $templates[$j]->getVar('tpl_id') . '</strong>');
685: }
686: }
687: }
688: unset($templates);
689: }
690: }
691: }
692:
693:
694: $modtables = $module->getInfo('tables');
695: if ($modtables !== false && is_array($modtables)) {
696: $msgs[] = _AM_SYSTEM_MODULES_DELETE_MOD_TABLES;
697: foreach ($modtables as $table) {
698:
699: if (!in_array($table, $reservedTables)) {
700: $sql = 'DROP TABLE ' . $db->prefix($table);
701: if (!$db->query($sql)) {
702: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TABLE_DROPPED_ERROR, '<strong>' . $db->prefix($table) . '</strong>') . '</span>';
703: } else {
704: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TABLE_DROPPED, '<strong>' . $db->prefix($table) . '</strong>');
705: }
706: } else {
707: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TABLE_DROPPED_FAILDED, '<strong>' . $db->prefix($table) . '</strong>') . '</span>';
708: }
709: }
710: }
711:
712:
713: if ($module->getVar('hascomments') != 0) {
714: $msgs[] = _AM_SYSTEM_MODULES_COMMENTS_DELETE;
715: $comment_handler = xoops_getHandler('comment');
716: if (false === $comment_handler->deleteByModule($module->getVar('mid'))) {
717: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_COMMENTS_DELETE_ERROR . '</span>';
718: } else {
719: $msgs[] = ' ' . _AM_SYSTEM_MODULES_COMMENTS_DELETED;
720: }
721: }
722:
723:
724:
725: if ($module->getVar('hasnotification') != 0) {
726: $msgs[] = _AM_SYSTEM_MODULES_NOTIFICATIONS_DELETE;
727: if (false === xoops_notification_deletebymodule($module->getVar('mid'))) {
728: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_NOTIFICATIONS_DELETE_ERROR . '</span>';
729: } else {
730: $msgs[] = ' ' . _AM_SYSTEM_MODULES_NOTIFICATIONS_DELETED;
731: }
732: }
733:
734:
735: $gperm_handler = xoops_getHandler('groupperm');
736: if (false === $gperm_handler->deleteByModule($module->getVar('mid'))) {
737: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_GROUP_PERMS_DELETE_ERROR . '</span>';
738: } else {
739: $msgs[] = ' ' . _AM_SYSTEM_MODULES_GROUP_PERMS_DELETED;
740: }
741:
742:
743: if ($module->getVar('hasconfig') != 0 || $module->getVar('hascomments') != 0) {
744:
745: $config_handler = xoops_getHandler('config');
746: $configs = $config_handler->getConfigs(new Criteria('conf_modid', $module->getVar('mid')));
747: $confcount = count($configs);
748: if ($confcount > 0) {
749: $msgs[] = _AM_SYSTEM_MODULES_MODULE_DATA_DELETE;
750: for ($i = 0; $i < $confcount; ++$i) {
751: if (false === $config_handler->deleteConfig($configs[$i])) {
752: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_CONFIG_DATA_DELETE_ERROR . sprintf(_AM_SYSTEM_MODULES_GONFIG_ID, '<strong>' . $configs[$i]->getvar('conf_id') . '</strong>') . '</span>';
753: } else {
754: $msgs[] = ' ' . _AM_SYSTEM_MODULES_GONFIG_DATA_DELETE . sprintf(_AM_SYSTEM_MODULES_GONFIG_ID, '<strong>' . $configs[$i]->getvar('conf_id') . '</strong>');
755: }
756: }
757: }
758: }
759:
760:
761: $func = 'xoops_module_uninstall_' . $dirname;
762: if (function_exists($func)) {
763: if (!$func($module)) {
764: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_EXECUTE, $func) . '</p>';
765: } else {
766: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_SUCESS, "<strong>{$func}</strong>") . '</p>';
767: }
768: }
769: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_OKUNINS, '<strong>' . $module->getVar('name') . '</strong>') . '</p>';
770: }
771: $msgs[] = '</div></div>';
772: $msgs[] = '<div class="center"><a href="admin.php?fct=modulesadmin">' . _AM_SYSTEM_MODULES_BTOMADMIN . '</a></div>';
773: $ret = implode('<br>', $msgs);
774:
775: return $ret;
776: }
777: }
778:
779: 780: 781: 782:
783: function xoops_module_update($dirname)
784: {
785: global $xoopsUser, $xoopsConfig, $xoopsTpl;
786: $dirname = trim($dirname);
787: $xoopsDB =& $GLOBALS['xoopsDB'];
788:
789: $myts = MyTextSanitizer::getInstance();
790:
791: $dirname = $myts->htmlspecialchars(trim($dirname));
792:
793: $module_handler = xoops_getHandler('module');
794: $module = $module_handler->getByDirname($dirname);
795:
796: $prev_version = $module->getVar('version');
797: $clearTpl = new XoopsTpl();
798: $clearTpl->clearCache($dirname);
799:
800:
801: $temp_name = $module->getVar('name');
802: $module->loadInfoAsVar($dirname);
803: $module->setVar('name', $temp_name);
804: $module->setVar('last_update', time());
805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819:
820: if (!$module_handler->insert($module)) {
821: echo '<p>Could not update ' . $module->getVar('name') . '</p>';
822: echo "<br><div class='center'><a href='admin.php?fct=modulesadmin'>" . _AM_SYSTEM_MODULES_BTOMADMIN . '</a></div>';
823: } else {
824: $newmid = $module->getVar('mid');
825: $msgs = array();
826: $msgs[] = '<div id="xo-module-log"><div class="header">';
827: $msgs[] = $errs[] = '<h4>' . _AM_SYSTEM_MODULES_UPDATING . $module->getInfo('name', 's') . '</h4>';
828: if ($module->getInfo('image') !== false && trim($module->getInfo('image')) != '') {
829: $msgs[] = '<img src="' . XOOPS_URL . '/modules/' . $dirname . '/' . trim($module->getInfo('image')) . '" alt="" />';
830: }
831: $msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version') . ' ' . $module->getInfo('module_status');
832: if ($module->getInfo('author') !== false && trim($module->getInfo('author')) != '') {
833: $msgs[] = '<strong>' . _AUTHOR . ':</strong> ' . $myts->htmlspecialchars(trim($module->getInfo('author')));
834: }
835: $msgs[] = '</div><div class="logger">';
836:
837: $update_script = $module->getInfo('onUpdate');
838: if (!empty($update_script) && trim($update_script) != '') {
839: include_once XOOPS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($update_script);
840: }
841:
842: if (function_exists('xoops_module_pre_update_' . $dirname)) {
843: $func = 'xoops_module_pre_update_' . $dirname;
844: if (!$func($module, $prev_version)) {
845: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_EXECUTE, $func) . '</p>';
846: $msgs = array_merge($msgs, $module->getErrors());
847: } else {
848: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_SUCESS, '<strong>' . $func . '</strong>') . '</p>';
849: $msgs += $module->getErrors();
850: }
851: }
852: $msgs[] = _AM_SYSTEM_MODULES_MODULE_DATA_UPDATE;
853:
854: $tplfile_handler = xoops_getHandler('tplfile');
855:
856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868:
869:
870: $templates = $module->getInfo('templates');
871: if ($templates !== false) {
872: $msgs[] = _AM_SYSTEM_MODULES_TEMPLATES_UPDATE;
873: foreach ($templates as $tpl) {
874: $tpl['file'] = trim($tpl['file']);
875:
876:
877: $type = (isset($tpl['type']) ? $tpl['type'] : 'module');
878: if (preg_match("/\.css$/i", $tpl['file'])) {
879: $type = 'css';
880: }
881: $criteria = new CriteriaCompo();
882: $criteria->add(new Criteria('tpl_refid', $newmid), 'AND');
883: $criteria->add(new Criteria('tpl_module', $dirname), 'AND');
884: $criteria->add(new Criteria('tpl_tplset', 'default'), 'AND');
885: $criteria->add(new Criteria('tpl_file', $tpl['file']), 'AND');
886: $criteria->add(new Criteria('tpl_type', $type), 'AND');
887: $tplfiles = $tplfile_handler->getObjects($criteria);
888:
889: $tpldata =& xoops_module_gettemplate($dirname, $tpl['file'], $type);
890: $tplfile = empty($tplfiles) ? $tplfile_handler->create() : $tplfiles[0];
891:
892: $tplfile->setVar('tpl_refid', $newmid);
893: $tplfile->setVar('tpl_lastimported', 0);
894: $tplfile->setVar('tpl_lastmodified', time());
895: $tplfile->setVar('tpl_type', $type);
896: $tplfile->setVar('tpl_source', $tpldata, true);
897: $tplfile->setVar('tpl_module', $dirname);
898: $tplfile->setVar('tpl_tplset', 'default');
899: $tplfile->setVar('tpl_file', $tpl['file'], true);
900: $tplfile->setVar('tpl_desc', $tpl['description'], true);
901: if (!$tplfile_handler->insert($tplfile)) {
902: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_ERROR, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
903: } else {
904: $newid = $tplfile->getVar('tpl_id');
905: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_INSERT_DATA, '<strong>' . $tpl['file'] . '</strong>');
906: if ($xoopsConfig['template_set'] === 'default') {
907: if (!xoops_template_touch($newid)) {
908: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE_ERROR, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
909: } else {
910: $msgs[] = ' <span>' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
911: }
912: }
913: }
914: unset($tpldata);
915:
916: 917: 918: 919: 920:
921:
922: }
923: }
924: $blocks = $module->getInfo('blocks');
925: $msgs[] = _AM_SYSTEM_MODULES_BLOCKS_REBUILD;
926: if ($blocks !== false) {
927: $showfuncs = array();
928: $funcfiles = array();
929: foreach ($blocks as $i => $block) {
930: if (isset($block['show_func']) && $block['show_func'] != '' && isset($block['file']) && $block['file'] != '') {
931: $editfunc = isset($block['edit_func']) ? $block['edit_func'] : '';
932: $showfuncs[] = $block['show_func'];
933: $funcfiles[] = $block['file'];
934: $content = '';
935: $template = '';
936: if (isset($block['template']) && trim($block['template']) != '') {
937: $content =& xoops_module_gettemplate($dirname, $block['template'], 'blocks');
938: }
939: if (!$content) {
940: $content = '';
941: } else {
942: $template = $block['template'];
943: }
944: $options = '';
945: if (!empty($block['options'])) {
946: $options = $block['options'];
947: }
948: $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']) . "'";
949: $fresult = $xoopsDB->query($sql);
950: $fcount = 0;
951: while ($fblock = $xoopsDB->fetchArray($fresult)) {
952: ++$fcount;
953: $sql = 'UPDATE ' . $xoopsDB->prefix('newblocks') . " SET name='" . addslashes($block['name']) . "', edit_func='" . addslashes($editfunc) . "', content='', template='" . $template . "', last_modified=" . time() . ' WHERE bid=' . $fblock['bid'];
954: $result = $xoopsDB->query($sql);
955: if (!$result) {
956: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_UPDATE_ERROR, $fblock['name']);
957: } else {
958: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_BLOCK_UPDATE, $fblock['name']) . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $fblock['bid'] . '</strong>');
959: if ($template != '') {
960: $tplfile = $tplfile_handler->find('default', 'block', $fblock['bid']);
961: if (count($tplfile) == 0) {
962: $tplfile_new = $tplfile_handler->create();
963: $tplfile_new->setVar('tpl_module', $dirname);
964: $tplfile_new->setVar('tpl_refid', $fblock['bid']);
965: $tplfile_new->setVar('tpl_tplset', 'default');
966: $tplfile_new->setVar('tpl_file', $block['template'], true);
967: $tplfile_new->setVar('tpl_type', 'block');
968: } else {
969: $tplfile_new = $tplfile[0];
970: }
971: $tplfile_new->setVar('tpl_source', $content, true);
972: $tplfile_new->setVar('tpl_desc', $block['description'], true);
973: $tplfile_new->setVar('tpl_lastmodified', time());
974: $tplfile_new->setVar('tpl_lastimported', 0);
975: $tplfile_new->setVar('tpl_file', $block['template'], true);
976: if (!$tplfile_handler->insert($tplfile_new)) {
977: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_UPDATE_ERROR, '<strong>' . $block['template'] . '</strong>') . '</span>';
978: } else {
979: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_UPDATE, '<strong>' . $block['template'] . '</strong>');
980: if ($xoopsConfig['template_set'] === 'default') {
981: if (!xoops_template_touch($tplfile_new->getVar('tpl_id'))) {
982: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE_ERROR, '<strong>' . $block['template'] . '</strong>') . '</span>';
983: } else {
984: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE, '<strong>' . $block['template'] . '</strong>');
985: }
986: }
987: }
988: }
989: }
990: }
991: if ($fcount == 0) {
992: $newbid = $xoopsDB->genId($xoopsDB->prefix('newblocks') . '_bid_seq');
993: $block_name = addslashes($block['name']);
994: $block_type = ($module->getVar('dirname') === 'system') ? 'S' : 'M';
995: $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() . ')';
996: $result = $xoopsDB->query($sql);
997: if (!$result) {
998: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_SQL_NOT_CREATE, $block['name']);
999: echo $sql;
1000: } else {
1001: if (empty($newbid)) {
1002: $newbid = $xoopsDB->getInsertId();
1003: }
1004: if ($module->getInfo('hasMain')) {
1005: $groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
1006: } else {
1007: $groups = array(XOOPS_GROUP_ADMIN);
1008: }
1009: $gperm_handler = xoops_getHandler('groupperm');
1010: foreach ($groups as $mygroup) {
1011: $bperm = $gperm_handler->create();
1012: $bperm->setVar('gperm_groupid', $mygroup);
1013: $bperm->setVar('gperm_itemid', $newbid);
1014: $bperm->setVar('gperm_name', 'block_read');
1015: $bperm->setVar('gperm_modid', 1);
1016: if (!$gperm_handler->insert($bperm)) {
1017: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_BLOCK_ACCESS_ERROR . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $newbid . '</strong>') . sprintf(_AM_SYSTEM_MODULES_GROUP_ID, '<strong>' . $mygroup . '</strong>') . '</span>';
1018: } else {
1019: $msgs[] = ' ' . _AM_SYSTEM_MODULES_BLOCK_ACCESS . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $newbid . '</strong>') . sprintf(_AM_SYSTEM_MODULES_GROUP_ID, '<strong>' . $mygroup . '</strong>');
1020: }
1021: }
1022:
1023: if ($template != '') {
1024: $tplfile = $tplfile_handler->create();
1025: $tplfile->setVar('tpl_module', $dirname);
1026: $tplfile->setVar('tpl_refid', $newbid);
1027: $tplfile->setVar('tpl_source', $content, true);
1028: $tplfile->setVar('tpl_tplset', 'default');
1029: $tplfile->setVar('tpl_file', $block['template'], true);
1030: $tplfile->setVar('tpl_type', 'block');
1031: $tplfile->setVar('tpl_lastimported', time());
1032: $tplfile->setVar('tpl_lastmodified', time());
1033: $tplfile->setVar('tpl_desc', $block['description'], true);
1034: if (!$tplfile_handler->insert($tplfile)) {
1035: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_ERROR, '<strong>' . $block['template'] . '</strong>') . '</span>';
1036: } else {
1037: $newid = $tplfile->getVar('tpl_id');
1038: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_DATA, '<strong>' . $block['template'] . '</strong>');
1039: if ($xoopsConfig['template_set'] === 'default') {
1040: if (!xoops_template_touch($newid)) {
1041: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE_FAILD, '<strong>' . $block['template'] . '</strong>') . '</span>';
1042: } else {
1043: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE, '<strong>' . $block['template'] . '</strong>');
1044: }
1045: }
1046: }
1047: }
1048: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_BLOCK_CREATED, '<strong>' . $block['name'] . '</strong>') . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $newbid . '</strong>');
1049: $sql = 'INSERT INTO ' . $xoopsDB->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newbid . ', -1)';
1050: $xoopsDB->query($sql);
1051: }
1052: }
1053: }
1054: }
1055: $block_arr = XoopsBlock::getByModule($module->getVar('mid'));
1056:
1057: foreach ($block_arr as $block) {
1058: if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
1059: $sql = sprintf('DELETE FROM %s WHERE bid = %u', $xoopsDB->prefix('newblocks'), $block->getVar('bid'));
1060: if (!$xoopsDB->query($sql)) {
1061: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_BLOCK_DELETE_ERROR, '<strong>' . $block->getVar('name') . '</strong>') . sprintf(_AM_SYSTEM_MODULES_BLOCK_ID, '<strong>' . $block->getVar('bid') . '</strong>') . '</span>';
1062: } else {
1063: $msgs[] = ' Block <strong>' . $block->getVar('name') . '</strong> deleted. Block ID: <strong>' . $block->getVar('bid') . '</strong>';
1064: if ($block->getVar('template') != '') {
1065: $tplfiles = $tplfile_handler->find(null, 'block', $block->getVar('bid'));
1066: if (is_array($tplfiles)) {
1067: $btcount = count($tplfiles);
1068: for ($k = 0; $k < $btcount; $k++) {
1069: if (!$tplfile_handler->delete($tplfiles[$k])) {
1070: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_BLOCK_DEPRECATED_ERROR . '(ID: <strong>' . $tplfiles[$k]->getVar('tpl_id') . '</strong>)</span>';
1071: } else {
1072: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_BLOCK_DEPRECATED, '<strong>' . $tplfiles[$k]->getVar('tpl_file') . '</strong>');
1073: }
1074: }
1075: }
1076: }
1077: }
1078: }
1079: }
1080: }
1081:
1082:
1083:
1084:
1085:
1086:
1087:
1088: $template = $clearTpl;
1089: $template->setCompileId();
1090:
1091:
1092:
1093:
1094:
1095: $config_handler = xoops_getHandler('config');
1096: $configs = $config_handler->getConfigs(new Criteria('conf_modid', $module->getVar('mid')));
1097: $confcount = count($configs);
1098: $config_delng = array();
1099: if ($confcount > 0) {
1100: $msgs[] = _AM_SYSTEM_MODULES_MODULE_DATA_DELETE;
1101: for ($i = 0; $i < $confcount; $i++) {
1102: if (!$config_handler->deleteConfig($configs[$i])) {
1103: $msgs[] = ' <span style="color:#ff0000;">' . _AM_SYSTEM_MODULES_CONFIG_DATA_DELETE_ERROR . sprintf(_AM_SYSTEM_MODULES_GONFIG_ID, '<strong>' . $configs[$i]->getvar('conf_id') . '</strong>') . '</span>';
1104:
1105: $config_delng[] = $configs[$i]->getvar('conf_name');
1106: } else {
1107: $config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N');
1108: $config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype');
1109: $config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype');
1110: $msgs[] = ' ' . _AM_SYSTEM_MODULES_GONFIG_DATA_DELETE . sprintf(_AM_SYSTEM_MODULES_GONFIG_ID, '<strong>' . $configs[$i]->getVar('conf_id') . '</strong>');
1111: }
1112: }
1113: }
1114:
1115:
1116: $configs = $module->getInfo('config');
1117: if ($configs !== false) {
1118: if ($module->getVar('hascomments') != 0) {
1119: include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
1120: array_push($configs, array(
1121: 'name' => 'com_rule',
1122: 'title' => '_CM_COMRULES',
1123: 'description' => '',
1124: 'formtype' => 'select',
1125: 'valuetype' => 'int',
1126: 'default' => 1,
1127: 'options' => array(
1128: '_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
1129: '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
1130: '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
1131: '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
1132: array_push($configs, array(
1133: 'name' => 'com_anonpost',
1134: 'title' => '_CM_COMANONPOST',
1135: 'description' => '',
1136: 'formtype' => 'yesno',
1137: 'valuetype' => 'int',
1138: 'default' => 0));
1139: }
1140: } else {
1141: if ($module->getVar('hascomments') != 0) {
1142: $configs = array();
1143: include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
1144: $configs[] = array(
1145: 'name' => 'com_rule',
1146: 'title' => '_CM_COMRULES',
1147: 'description' => '',
1148: 'formtype' => 'select',
1149: 'valuetype' => 'int',
1150: 'default' => 1,
1151: 'options' => array(
1152: '_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
1153: '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
1154: '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
1155: '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
1156: $configs[] = array(
1157: 'name' => 'com_anonpost',
1158: 'title' => '_CM_COMANONPOST',
1159: 'description' => '',
1160: 'formtype' => 'yesno',
1161: 'valuetype' => 'int',
1162: 'default' => 0);
1163: }
1164: }
1165:
1166: if ($module->getVar('hasnotification') != 0) {
1167: if (empty($configs)) {
1168: $configs = array();
1169: }
1170:
1171: include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
1172: include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
1173: $options = array();
1174: $options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
1175: $options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
1176: $options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
1177: $options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
1178:
1179:
1180: $configs[] = array(
1181: 'name' => 'notification_enabled',
1182: 'title' => '_NOT_CONFIG_ENABLE',
1183: 'description' => '_NOT_CONFIG_ENABLEDSC',
1184: 'formtype' => 'select',
1185: 'valuetype' => 'int',
1186: 'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
1187: 'options' => $options);
1188:
1189:
1190:
1191: $options = array();
1192: $categories =& notificationCategoryInfo('', $module->getVar('mid'));
1193: foreach ($categories as $category) {
1194: $events =& notificationEvents($category['name'], false, $module->getVar('mid'));
1195: foreach ($events as $event) {
1196: if (!empty($event['invisible'])) {
1197: continue;
1198: }
1199: $option_name = $category['title'] . ' : ' . $event['title'];
1200: $option_value = $category['name'] . '-' . $event['name'];
1201: $options[$option_name] = $option_value;
1202:
1203: }
1204: }
1205: $configs[] = array(
1206: 'name' => 'notification_events',
1207: 'title' => '_NOT_CONFIG_EVENTS',
1208: 'description' => '_NOT_CONFIG_EVENTSDSC',
1209: 'formtype' => 'select_multi',
1210: 'valuetype' => 'array',
1211: 'default' => array_values($options),
1212: 'options' => $options);
1213: }
1214:
1215: if ($configs !== false) {
1216: $msgs[] = 'Adding module config data...';
1217:
1218: $config_handler = xoops_getHandler('config');
1219: $order = 0;
1220: foreach ($configs as $config) {
1221:
1222: if (!in_array($config['name'], $config_delng)) {
1223: $confobj = $config_handler->createConfig();
1224: $confobj->setVar('conf_modid', $newmid);
1225: $confobj->setVar('conf_catid', 0);
1226: $confobj->setVar('conf_name', $config['name']);
1227: $confobj->setVar('conf_title', $config['title'], true);
1228: $confobj->setVar('conf_desc', $config['description'], true);
1229: $confobj->setVar('conf_formtype', $config['formtype']);
1230: if (isset($config['valuetype'])) {
1231: $confobj->setVar('conf_valuetype', $config['valuetype']);
1232: }
1233: if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) {
1234:
1235:
1236: $confobj->setVar('conf_value', $config_old[$config['name']]['value'], true);
1237: } else {
1238: $confobj->setConfValueForInput($config['default'], true);
1239:
1240:
1241: }
1242: $confobj->setVar('conf_order', $order);
1243: $confop_msgs = '';
1244: if (isset($config['options']) && is_array($config['options'])) {
1245: foreach ($config['options'] as $key => $value) {
1246: $confop = $config_handler->createConfigOption();
1247: $confop->setVar('confop_name', $key, true);
1248: $confop->setVar('confop_value', $value, true);
1249: $confobj->setConfOptions($confop);
1250: $confop_msgs .= '<br> ' . _AM_SYSTEM_MODULES_CONFIG_ADD . _AM_SYSTEM_MODULES_NAME . ' <strong>' . (defined($key) ? constant($key) : $key) . '</strong> ' . _AM_SYSTEM_MODULES_VALUE . ' <strong>' . $value . '</strong> ';
1251: unset($confop);
1252: }
1253: }
1254: $order++;
1255: if (false !== $config_handler->insertConfig($confobj)) {
1256:
1257: $msgs[] = ' ' . sprintf(_AM_SYSTEM_MODULES_CONFIG_DATA_ADD, '<strong>' . $config['name'] . '</strong>') . $confop_msgs;
1258: } else {
1259: $msgs[] = ' <span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_CONFIG_DATA_ADD_ERROR, '<strong>' . $config['name'] . '</strong>') . '</span>';
1260: }
1261: unset($confobj);
1262: }
1263: }
1264: unset($configs);
1265: }
1266:
1267:
1268: if (function_exists('xoops_module_update_' . $dirname)) {
1269: $func = 'xoops_module_update_' . $dirname;
1270: if (!$func($module, $prev_version)) {
1271: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_EXECUTE, $func) . '</p>';
1272: $msgs = array_merge($msgs, $module->getErrors());
1273: } else {
1274: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILED_SUCESS, '<strong>' . $func . '</strong>') . '</p>';
1275: $msgs += $module->getErrors();
1276: }
1277: }
1278: $msgs[] = sprintf(_AM_SYSTEM_MODULES_OKUPD, '<strong>' . $module->getVar('name', 's') . '</strong>');
1279: $msgs[] = '</div></div>';
1280: $msgs[] = '<div class="center"><a href="admin.php?fct=modulesadmin">' . _AM_SYSTEM_MODULES_BTOMADMIN . '</a> | <a href="' . XOOPS_URL . '/modules/' . $module->getInfo('dirname', 'e') . '/' . $module->getInfo('adminindex') . '">' . _AM_SYSTEM_MODULES_ADMIN . '</a></div>';
1281:
1282:
1283:
1284: }
1285:
1286:
1287:
1288:
1289:
1290:
1291:
1292:
1293:
1294:
1295:
1296:
1297:
1298:
1299:
1300: $ret = implode('<br>', $msgs);
1301:
1302: return $ret;
1303: }
1304:
1305: 1306: 1307: 1308: 1309:
1310: function xoops_module_activate($mid)
1311: {
1312:
1313:
1314: $module_handler = xoops_getHandler('module');
1315: $module = $module_handler->get($mid);
1316: include_once XOOPS_ROOT_PATH . '/class/template.php';
1317: xoops_template_clear_module_cache($module->getVar('mid'));
1318:
1319: $msgs[] = '<div id="xo-module-log">';
1320: $msgs .= xoops_module_log_header($module, _AM_SYSTEM_MODULES_ACTIVATE);
1321:
1322: $module->setVar('isactive', 1);
1323: if (!$module_handler->insert($module)) {
1324: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILACT, '<strong>' . $module->getVar('name', 's') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br>' . $module->getHtmlErrors() . '</p>';
1325: } else {
1326: $blocks = XoopsBlock::getByModule($module->getVar('mid'));
1327: $bcount = count($blocks);
1328: for ($i = 0; $i < $bcount; ++$i) {
1329: $blocks[$i]->setVar('isactive', 1);
1330: $blocks[$i]->store();
1331: }
1332: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_OKACT, '<strong>' . $module->getVar('name', 's') . '</strong>') . '</p></div>';
1333: }
1334:
1335: $msgs[] = '<div class="center"><a href="admin.php?fct=modulesadmin">' . _AM_SYSTEM_MODULES_BTOMADMIN . '</a></div>';
1336: $ret = implode('<br>', $msgs);
1337:
1338: return $ret;
1339: }
1340:
1341: 1342: 1343: 1344: 1345:
1346: function xoops_module_deactivate($mid)
1347: {
1348: global $xoopsConfig;
1349:
1350:
1351: $module_handler = xoops_getHandler('module');
1352: $module = $module_handler->get($mid);
1353: include_once XOOPS_ROOT_PATH . '/class/template.php';
1354: xoops_template_clear_module_cache($mid);
1355:
1356: $msgs[] = '<div id="xo-module-log">';
1357: $msgs .= xoops_module_log_header($module, _AM_SYSTEM_MODULES_DEACTIVATE);
1358:
1359: $module->setVar('isactive', 0);
1360: if ($module->getVar('dirname') === 'system') {
1361: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILDEACT, '<strong>' . $module->getVar('name') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br> - ' . _AM_SYSTEM_MODULES_SYSNO . '</p>';
1362: } elseif ($module->getVar('dirname') == $xoopsConfig['startpage']) {
1363: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILDEACT, '<strong>' . $module->getVar('name') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br> - ' . _AM_SYSTEM_MODULES_STRTNO . '</p>';
1364: } else {
1365: if (!$module_handler->insert($module)) {
1366: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILDEACT, '<strong>' . $module->getVar('name') . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br>' . $module->getHtmlErrors() . '</p>';
1367: } else {
1368: $blocks = XoopsBlock::getByModule($module->getVar('mid'));
1369: $bcount = count($blocks);
1370: for ($i = 0; $i < $bcount; ++$i) {
1371: $blocks[$i]->setVar('isactive', 0);
1372: $blocks[$i]->store();
1373: }
1374: $msgs[] = '<p>' . sprintf(_AM_SYSTEM_MODULES_OKDEACT, '<strong>' . $module->getVar('name') . '</strong>') . '</p>';
1375: }
1376: }
1377: $msgs[] = '<div class="center"><a href="admin.php?fct=modulesadmin">' . _AM_SYSTEM_MODULES_BTOMADMIN . '</a></div>';
1378: $ret = implode('<br>', $msgs);
1379:
1380: return $ret;
1381: }
1382:
1383: 1384: 1385: 1386: 1387: 1388:
1389: function xoops_module_change($mid, $name)
1390: {
1391:
1392: $module_handler = xoops_getHandler('module');
1393: $module = $module_handler->get($mid);
1394: $module->setVar('name', $name);
1395: $myts = MyTextSanitizer::getInstance();
1396: if (!$module_handler->insert($module)) {
1397: $ret = '<p>' . sprintf(_AM_SYSTEM_MODULES_FAILORDER, '<strong>' . $myts->stripSlashesGPC($name) . '</strong>') . ' ' . _AM_SYSTEM_MODULES_ERRORSC . '<br>';
1398: $ret .= $module->getHtmlErrors() . '</p>';
1399:
1400: return $ret;
1401: }
1402:
1403: return '<p>' . sprintf(_AM_SYSTEM_MODULES_OKORDER, '<strong>' . $myts->stripSlashesGPC($name) . '</strong>') . '</p>';
1404: }
1405:
1406: 1407: 1408: 1409: 1410: 1411:
1412: function xoops_module_log_header($module, $title)
1413: {
1414: $msgs[] = '<div class="header">';
1415: $msgs[] = $errs[] = '<h4>' . $title . $module->getInfo('name', 's') . '</h4>';
1416: if ($module->getInfo('image') !== false && trim($module->getInfo('image')) != '') {
1417: $msgs[] = '<img src="' . XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . trim($module->getInfo('image')) . '" alt="" />';
1418: }
1419: $msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version') . ' ' . $module->getInfo('module_status');
1420: if ($module->getInfo('author') !== false && trim($module->getInfo('author')) != '') {
1421: $msgs[] = '<strong>' . _AUTHOR . ':</strong> ' . htmlspecialchars(trim($module->getInfo('author')));
1422: }
1423: $msgs[] = '</div>';
1424:
1425: return $msgs;
1426: }
1427:
1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437:
1438: function xoops_module_delayed_clean_cache($cacheList = null)
1439: {
1440: if (empty($cacheList)) {
1441: $cacheList = array (1,2,3);
1442: }
1443: require_once XOOPS_ROOT_PATH . '/modules/system/class/maintenance.php';
1444: $maintenance = new SystemMaintenance();
1445: register_shutdown_function(array($maintenance, 'CleanCache'), $cacheList);
1446: }
1447: