1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18:
19: $path = dirname(dirname(dirname(__DIR__)));
20: require_once $path . '/include' . '/cp_header.php';
21:
22: 23: 24: 25: 26:
27: 28: 29: 30: 31:
32: function xoops_module_update_pm(XoopsModule $module, $oldversion = null)
33: {
34: global $xoopsDB;
35: if ($oldversion <= 100) {
36:
37: $sql = 'SHOW COLUMNS FROM ' . $xoopsDB->prefix('priv_msgs');
38: if (!$result = $xoopsDB->queryF($sql)) {
39: return false;
40: }
41:
42: if (($rows = $xoopsDB->getRowsNum($result)) == 12) {
43: return true;
44: } elseif ($rows == 8) {
45: return $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/sql/mysql.upgrade.sql');
46: } else {
47: return false;
48: }
49: }
50:
51: if ($oldversion < 110) {
52:
53: $templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/';
54: $template_list = array_diff(scandir($templateDirectory), array('..', '.'));
55: foreach ($template_list as $k => $v) {
56: $fileinfo = new SplFileInfo($templateDirectory . $v);
57: if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') {
58: @unlink($templateDirectory . $v);
59: }
60: }
61:
62: xoops_load('xoopsfile');
63:
64: $imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/';
65: $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory);
66: $folderHandler->delete($imagesDirectory);
67:
68: $sql = 'DELETE FROM ' . $xoopsDB->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
69: $xoopsDB->queryF($sql);
70: }
71:
72: return true;
73: }
74: