1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Bruno Barthez, Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use XoopsModules\Suico\{ |
20
|
|
|
Helper, |
21
|
|
|
Utility |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
/** @var Helper $helper */ |
25
|
|
|
/** @var Utility $utility */ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Prepares system prior to attempting to uninstall module |
29
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
30
|
|
|
* |
31
|
|
|
* @return bool true if ready to uninstall, false if not |
32
|
|
|
*/ |
33
|
|
|
function xoops_module_pre_uninstall_suico( |
34
|
|
|
XoopsModule $module |
|
|
|
|
35
|
|
|
) { |
36
|
|
|
// Do some synchronization if needed |
37
|
|
|
return true; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Performs tasks required during uninstallation of the module |
42
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
43
|
|
|
* |
44
|
|
|
* @return bool true if uninstallation successful, false if not |
45
|
|
|
*/ |
46
|
|
|
function xoops_module_uninstall_suico( |
47
|
|
|
XoopsModule $module |
48
|
|
|
) { |
49
|
|
|
require __DIR__ . '/common.php'; |
50
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
51
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
52
|
|
|
$helper = Helper::getInstance(); |
53
|
|
|
$utility = new Utility(); |
54
|
|
|
// $configurator = new Suico\Common\Configurator(); |
55
|
|
|
// Load language files |
56
|
|
|
$helper->loadLanguage('admin'); |
57
|
|
|
$helper->loadLanguage('common'); |
58
|
|
|
$success = true; |
59
|
|
|
//------------------------------------------------------------------ |
60
|
|
|
// Remove uploads folder (and all subfolders) if they exist |
61
|
|
|
//------------------------------------------------------------------ |
62
|
|
|
$old_directories = [ |
63
|
|
|
$GLOBALS['xoops']->path("uploads/{$moduleDirName}"), |
64
|
|
|
]; |
65
|
|
|
foreach ($old_directories as $old_dir) { |
66
|
|
|
$dirInfo = new SplFileInfo($old_dir); |
67
|
|
|
if ($dirInfo->isDir()) { |
68
|
|
|
// The directory exists so delete it |
69
|
|
|
if (!$utility::rrmdir($old_dir)) { |
70
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir)); |
71
|
|
|
$success = false; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
unset($dirInfo); |
75
|
|
|
} |
76
|
|
|
/* |
77
|
|
|
//------------ START ---------------- |
78
|
|
|
//------------------------------------------------------------------ |
79
|
|
|
// Remove xsitemap.xml from XOOPS root folder if it exists |
80
|
|
|
//------------------------------------------------------------------ |
81
|
|
|
$xmlfile = $GLOBALS['xoops']->path('xsitemap.xml'); |
82
|
|
|
if (is_file($xmlfile)) { |
83
|
|
|
if (false === ($delOk = unlink($xmlfile))) { |
84
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE'), $xmlfile)); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
// return $success && $delOk; // use this if you're using this routine |
88
|
|
|
*/ |
89
|
|
|
return $success; |
90
|
|
|
//------------ END ---------------- |
91
|
|
|
} |
92
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.