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