|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* **************************************************************************** |
|
4
|
|
|
* marquee - MODULE FOR XOOPS |
|
5
|
|
|
* Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com) |
|
6
|
|
|
* |
|
7
|
|
|
* You may not change or alter any portion of this comment or credits |
|
8
|
|
|
* of supporting developers from this source code or any supporting source code |
|
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright Hervé Thouzard (https://www.herve-thouzard.com) |
|
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
16
|
|
|
* @author Hervé Thouzard (https://www.herve-thouzard.com) |
|
17
|
|
|
* |
|
18
|
|
|
* Version : |
|
19
|
|
|
* **************************************************************************** |
|
20
|
|
|
* |
|
21
|
|
|
* @param \XoopsModule|\XoopsObject $module |
|
22
|
|
|
* @param null $oldversion |
|
|
|
|
|
|
23
|
|
|
* @return mixed |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
//function xoops_module_update_marquee() |
|
27
|
|
|
//{ |
|
28
|
|
|
// $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
29
|
|
|
// $sql = "ALTER TABLE `" . $db->prefix('marquee') . "` MODIFY `marquee_bgcolor` varchar(7) NOT NULL default '';"; |
|
30
|
|
|
// $db->query($sql); |
|
31
|
|
|
// |
|
32
|
|
|
// return true; |
|
33
|
|
|
//} |
|
34
|
|
|
function xoops_module_update_marquee(\XoopsObject $module, $oldversion = null) |
|
35
|
|
|
{ |
|
36
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
37
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('marquee') . "` MODIFY `marquee_bgcolor` VARCHAR(7) NOT NULL DEFAULT '';"; |
|
38
|
|
|
$db->query($sql); |
|
39
|
|
|
if ($oldversion < 250) { |
|
40
|
|
|
// delete old block html template files |
|
41
|
|
|
$templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/blocks/'; |
|
42
|
|
|
$template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
|
43
|
|
|
foreach ($template_list as $k => $v) { |
|
44
|
|
|
$fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
45
|
|
|
if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
|
46
|
|
|
// @unlink($templateDirectory . $v); |
|
47
|
|
|
if (false === @unlink($templateDirectory . $v)) { |
|
48
|
|
|
throw new \RuntimeException('The file ' . $templateDirectory . $v . ' could not be deleted.'); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
// Load class XoopsFile |
|
53
|
|
|
xoops_load('xoopsfile'); |
|
54
|
|
|
//delete /images directory |
|
55
|
|
|
$imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/'; |
|
56
|
|
|
$folderHandler = XoopsFile::getHandler('folder', $imagesDirectory); |
|
57
|
|
|
$folderHandler->delete($imagesDirectory); |
|
58
|
|
|
//delete /js directory |
|
59
|
|
|
$jsDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/js/'; |
|
60
|
|
|
$folderHandler = XoopsFile::getHandler('folder', $jsDirectory); |
|
61
|
|
|
$folderHandler->delete($jsDirectory); |
|
62
|
|
|
//delete /templates/style.css file |
|
63
|
|
|
$deleteFile = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/admin/marquee.php'; |
|
64
|
|
|
$folderHandler = XoopsFile::getHandler('file', $deleteFile); |
|
65
|
|
|
$folderHandler->delete($deleteFile); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
68
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
69
|
|
|
|
|
70
|
|
|
return $grouppermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
|
71
|
|
|
} |
|
72
|
|
|
|