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