|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* **************************************************************************** |
|
4
|
|
|
* marquee - MODULE FOR XOOPS |
|
5
|
|
|
* Copyright (c) Hervé Thouzard (http://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 (http://www.herve-thouzard.com) |
|
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
|
16
|
|
|
* @package marquee |
|
17
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com) |
|
18
|
|
|
* |
|
19
|
|
|
* Version : |
|
20
|
|
|
* **************************************************************************** |
|
21
|
|
|
* |
|
22
|
|
|
* @param XoopsModule|\XoopsObject $module |
|
23
|
|
|
* @param null $oldversion |
|
24
|
|
|
* @return mixed |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
//function xoops_module_update_marquee() |
|
|
|
|
|
|
28
|
|
|
//{ |
|
29
|
|
|
// $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
30
|
|
|
// $sql = "ALTER TABLE `" . $db->prefix('marquee') . "` MODIFY `marquee_bgcolor` varchar(7) NOT NULL default '';"; |
|
31
|
|
|
// $db->query($sql); |
|
32
|
|
|
// |
|
33
|
|
|
// return true; |
|
34
|
|
|
//} |
|
35
|
|
|
|
|
36
|
|
|
function xoops_module_update_marquee(XoopsObject $module, $oldversion = null) |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
39
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('marquee') . "` MODIFY `marquee_bgcolor` VARCHAR(7) NOT NULL DEFAULT '';"; |
|
40
|
|
|
$db->query($sql); |
|
41
|
|
|
|
|
42
|
|
|
if ($oldversion < 250) { |
|
43
|
|
|
|
|
44
|
|
|
// delete old block html template files |
|
45
|
|
|
$templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/blocks/'; |
|
46
|
|
|
$template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
|
47
|
|
|
foreach ($template_list as $k => $v) { |
|
48
|
|
|
$fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
49
|
|
|
if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
|
50
|
|
|
// @unlink($templateDirectory . $v); |
|
51
|
|
|
if (false === @unlink($templateDirectory . $v)) { |
|
52
|
|
|
throw new \RuntimeException('The file ' . $templateDirectory . $v . ' could not be deleted.'); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
// Load class XoopsFile |
|
57
|
|
|
xoops_load('xoopsfile'); |
|
58
|
|
|
//delete /images directory |
|
59
|
|
|
$imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/'; |
|
60
|
|
|
$folderHandler = XoopsFile::getHandler('folder', $imagesDirectory); |
|
61
|
|
|
$folderHandler->delete($imagesDirectory); |
|
62
|
|
|
//delete /js directory |
|
63
|
|
|
$jsDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/js/'; |
|
64
|
|
|
$folderHandler = XoopsFile::getHandler('folder', $jsDirectory); |
|
65
|
|
|
$folderHandler->delete($jsDirectory); |
|
66
|
|
|
//delete /templates/style.css file |
|
67
|
|
|
$deleteFile = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/admin/marquee.php'; |
|
68
|
|
|
$folderHandler = XoopsFile::getHandler('file', $deleteFile); |
|
69
|
|
|
$folderHandler->delete($deleteFile); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
|
73
|
|
|
|
|
74
|
|
|
return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
|
75
|
|
|
} |
|
76
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.