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