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
|
|
|
/** |
12
|
|
|
* Prepares system prior to attempting to uninstall module |
13
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
14
|
|
|
* |
15
|
|
|
* @return bool true if ready to uninstall, false if not |
16
|
|
|
*/ |
17
|
|
|
function xoops_module_pre_uninstall_soapbox(\XoopsModule $module) |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
// Do some synchronization |
20
|
|
|
return true; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Performs tasks required during uninstallation of the module |
25
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
26
|
|
|
* |
27
|
|
|
* @return bool true if uninstallation successful, false if not |
28
|
|
|
*/ |
29
|
|
|
function xoops_module_uninstall_soapbox(\XoopsModule $module) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
return true; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
//======================================================= |
35
|
|
|
|
36
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param \XoopsModule $module |
40
|
|
|
* |
41
|
|
|
* @return bool |
42
|
|
|
*/ |
43
|
|
|
function xoops_module_uninstall_XXXX(\XoopsModule $module) |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
// global $xoopsDB,$xoopsConfig; |
46
|
|
|
// |
47
|
|
|
// nothing to do yet |
48
|
|
|
return true; |
49
|
|
|
//routine to delete a cache directory |
50
|
|
|
/* |
51
|
|
|
$cacheDir = XOOPS_ROOT_PATH . '/uploads/shoutbox'; |
52
|
|
|
//Always check if a directory exists prior to creation |
53
|
|
|
if (!is_dir($cacheDir)) { |
54
|
|
|
return true; |
55
|
|
|
} else { |
56
|
|
|
return rmdirr($cacheDir); // see the function below |
57
|
|
|
} |
58
|
|
|
*/ |
59
|
|
|
|
60
|
|
|
//------------- example from user log -------------- |
61
|
|
|
/* |
62
|
|
|
$logsetObj = UserlogSetting::getInstance(); |
63
|
|
|
|
64
|
|
|
return $logsetObj->cleanCache(); // delete all settings caches |
65
|
|
|
|
66
|
|
|
*/ |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Delete a file, or a folder and its contents |
71
|
|
|
* |
72
|
|
|
* @author Aidan Lister <[email protected]> |
73
|
|
|
* @param string $dirname The directory to delete |
74
|
|
|
* @return bool Returns true on success, false on failure |
75
|
|
|
*/ |
76
|
|
|
function rmdirr($dirname) |
77
|
|
|
{ |
78
|
|
|
// Simple delete for a file |
79
|
|
|
if (is_file($dirname)) { |
80
|
|
|
return unlink($dirname); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
// Loop through the folder |
84
|
|
|
$dir = dir($dirname); |
85
|
|
|
while (false !== $entry = $dir->read()) { |
86
|
|
|
// Skip pointers |
87
|
|
|
if ('.' === $entry || '..' === $entry) { |
88
|
|
|
continue; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
// Deep delete directories |
92
|
|
|
if (is_dir("$dirname/$entry")) { |
93
|
|
|
rmdirr("$dirname/$entry"); |
94
|
|
|
} else { |
95
|
|
|
unlink("$dirname/$entry"); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
// Clean up |
100
|
|
|
$dir->close(); |
101
|
|
|
|
102
|
|
|
return rmdir($dirname); |
103
|
|
|
} |
104
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.