1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* uninstall.php - cleanup on module uninstall |
5
|
|
|
* |
6
|
|
|
* @author XOOPS Module Development Team |
7
|
|
|
* @copyright {@link https://xoops.org 2001-2016 XOOPS Project} |
8
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2.0 or later} |
9
|
|
|
* @link https://xoops.org XOOPS |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use XoopsModules\Marquee\{ |
13
|
|
|
Common\Configurator, |
14
|
|
|
Helper, |
15
|
|
|
Utility |
16
|
|
|
}; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Prepares system prior to attempting to uninstall module |
20
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
21
|
|
|
* |
22
|
|
|
* @return bool true if ready to uninstall, false if not |
23
|
|
|
*/ |
24
|
|
|
function xoops_module_pre_uninstall_marquee(\XoopsModule $module) |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
// Do some synchronization |
27
|
|
|
return true; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Performs tasks required during uninstallation of the module |
32
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
33
|
|
|
* |
34
|
|
|
* @return bool true if uninstallation successful, false if not |
35
|
|
|
*/ |
36
|
|
|
function xoops_module_uninstall_marquee(\XoopsModule $module) |
37
|
|
|
{ |
38
|
|
|
// return true; |
39
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
40
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
41
|
|
|
$helper = Helper::getInstance(); |
42
|
|
|
$utility = new Utility(); |
43
|
|
|
$success = true; |
44
|
|
|
$helper->loadLanguage('admin'); |
45
|
|
|
//------------------------------------------------------------------ |
46
|
|
|
// Remove uploads folder (and all subfolders) if they exist |
47
|
|
|
//------------------------------------------------------------------ |
48
|
|
|
$old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")]; |
49
|
|
|
foreach ($old_directories as $old_dir) { |
50
|
|
|
$dirInfo = new \SplFileInfo($old_dir); |
51
|
|
|
if ($dirInfo->isDir()) { |
52
|
|
|
// The directory exists so delete it |
53
|
|
|
if (false === $utility::rrmdir($old_dir)) { |
54
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_DEL_PATH'), $old_dir)); |
55
|
|
|
$success = false; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
unset($dirInfo); |
59
|
|
|
} |
60
|
|
|
/* |
61
|
|
|
//------------ START ---------------- |
62
|
|
|
//------------------------------------------------------------------ |
63
|
|
|
// Remove marquee.xml from XOOPS root folder if it exists |
64
|
|
|
//------------------------------------------------------------------ |
65
|
|
|
$xmlfile = $GLOBALS['xoops']->path('marquee.xml'); |
66
|
|
|
if (\is_file($xmlfile)) { |
67
|
|
|
if (false === ($delOk = unlink($xmlfile))) { |
68
|
|
|
$module->setErrors(sprintf(_AM_MARQUEE_ERROR_BAD_REMOVE, $xmlfile)); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
// return $success && $delOk; // use this if you're using this routine |
72
|
|
|
*/ |
73
|
|
|
return $success; |
74
|
|
|
//------------ END ---------------- |
75
|
|
|
} |
76
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.