1: <?php
2: /**
3: * Private Message
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14: * @package pm
15: * @since 2.3.0
16: * @author Taiwen Jiang <phppp@users.sourceforge.net>
17: */
18:
19: $path = dirname(dirname(dirname(__DIR__)));
20: require_once $path . '/include' . '/cp_header.php';
21:
22: /**
23: * @param $module
24: * @param null $oldversion
25: * @return bool
26: */
27: /**
28: * @param $module
29: * @param null $oldversion
30: * @return bool
31: */
32: function xoops_module_update_pm(XoopsModule $module, $oldversion = null)
33: {
34: global $xoopsDB;
35: if ($oldversion <= '1.0.0') {
36: // Check pm table version
37: $sql = 'SHOW COLUMNS FROM ' . $xoopsDB->prefix('priv_msgs');
38: $result = $xoopsDB->queryF($sql);
39: if (!$xoopsDB->isResultSet($result)) {
40: return false;
41: }
42: // Migrate from existent pm module
43: if (($rows = $xoopsDB->getRowsNum($result)) == 12) {
44: return true;
45: } elseif ($rows == 8) {
46: return $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/sql/mysql.upgrade.sql');
47: } else {
48: return false;
49: }
50: }
51:
52: if ($oldversion < '1.1.0') {
53: // remove old html template files
54: $templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/';
55: $template_list = array_diff(scandir($templateDirectory), array('..', '.'));
56: foreach ($template_list as $k => $v) {
57: $fileinfo = new SplFileInfo($templateDirectory . $v);
58: if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') {
59: @unlink($templateDirectory . $v);
60: }
61: }
62:
63: xoops_load('xoopsfile');
64: //remove /images directory
65: $imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/';
66: $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory);
67: $folderHandler->delete($imagesDirectory);
68: //delete .html entries from the tpl table
69: $sql = 'DELETE FROM ' . $xoopsDB->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
70: $xoopsDB->queryF($sql);
71: }
72:
73: return true;
74: }
75: