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\Moduleinstaller; |
13
|
|
|
use XoopsModules\Moduleinstaller\Utility; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Prepares system prior to attempting to uninstall module |
17
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
18
|
|
|
* |
19
|
|
|
* @return bool true if ready to uninstall, false if not |
20
|
|
|
*/ |
21
|
|
|
function xoops_module_pre_uninstall_moduleinstaller(\XoopsModule $module) |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
// Do some synchronization |
24
|
|
|
return true; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Performs tasks required during uninstallation of the module |
29
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
30
|
|
|
* |
31
|
|
|
* @return bool true if uninstallation successful, false if not |
32
|
|
|
*/ |
33
|
|
|
function xoops_module_uninstall_moduleinstaller(\XoopsModule $module) |
34
|
|
|
{ |
35
|
|
|
// return true; |
36
|
|
|
|
37
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
38
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
39
|
|
|
$helper = Moduleinstaller\Helper::getInstance(); |
40
|
|
|
|
41
|
|
|
$utility = new Utility(); |
42
|
|
|
$success = true; |
43
|
|
|
$helper->loadLanguage('admin'); |
44
|
|
|
|
45
|
|
|
//------------------------------------------------------------------ |
46
|
|
|
// Remove uploads folder (and all subfolders) if they exist |
47
|
|
|
//------------------------------------------------------------------ |
48
|
|
|
|
49
|
|
|
$old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")]; |
50
|
|
|
foreach ($old_directories as $old_dir) { |
51
|
|
|
$dirInfo = new \SplFileInfo($old_dir); |
52
|
|
|
if ($dirInfo->isDir()) { |
53
|
|
|
// The directory exists so delete it |
54
|
|
|
if (!$utility::rrmdir($old_dir)) { |
55
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_DEL_PATH'), $old_dir)); |
56
|
|
|
$success = false; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
unset($dirInfo); |
60
|
|
|
} |
61
|
|
|
/* |
62
|
|
|
//------------ START ---------------- |
63
|
|
|
//------------------------------------------------------------------ |
64
|
|
|
// Remove xsitemap.xml from XOOPS root folder if it exists |
65
|
|
|
//------------------------------------------------------------------ |
66
|
|
|
$xmlfile = $GLOBALS['xoops']->path('xsitemap.xml'); |
67
|
|
|
if (is_file($xmlfile)) { |
68
|
|
|
if (false === ($delOk = unlink($xmlfile))) { |
69
|
|
|
$module->setErrors(sprintf(_AM_XXXXX_ERROR_BAD_REMOVE, $xmlfile)); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
// return $success && $delOk; // use this if you're using this routine |
73
|
|
|
*/ |
74
|
|
|
|
75
|
|
|
return $success; |
76
|
|
|
//------------ END ---------------- |
77
|
|
|
} |
78
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.