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.fsf.org/copyleft/gpl.html GNU public license} |
9
|
|
|
* @link https://xoops.org XOOPS |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use XoopsModules\Myiframe; |
13
|
|
|
use XoopsModules\Myiframe\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_myiframe(\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_myiframe(\XoopsModule $module) |
34
|
|
|
{ |
35
|
|
|
// return true; |
36
|
|
|
|
37
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
38
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
39
|
|
|
/** @var Myiframe\Helper $helper */ |
40
|
|
|
$helper = Myiframe\Helper::getInstance(); |
41
|
|
|
|
42
|
|
|
/** @var Myiframe\Utility $utility */ |
43
|
|
|
$utility = new Utility(); |
|
|
|
|
44
|
|
|
|
45
|
|
|
$success = true; |
46
|
|
|
$helper->loadLanguage('admin'); |
47
|
|
|
|
48
|
|
|
// Rename uploads folder to BAK and add date to name |
49
|
|
|
$uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName"); |
50
|
|
|
$dirInfo = new \SplFileInfo($uploadDirectory); |
51
|
|
|
if ($dirInfo->isDir()) { |
52
|
|
|
// The directory exists so rename it |
53
|
|
|
$date = date('Y-m-d'); |
54
|
|
|
if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { |
55
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
56
|
|
|
$success = false; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
unset($dirInfo); |
60
|
|
|
/* |
61
|
|
|
//------------ START ---------------- |
62
|
|
|
//------------------------------------------------------------------ |
63
|
|
|
// Remove xsitemap.xml from XOOPS root folder if it exists |
64
|
|
|
//------------------------------------------------------------------ |
65
|
|
|
$xmlfile = $GLOBALS['xoops']->path('xsitemap.xml'); |
66
|
|
|
if (is_file($xmlfile)) { |
67
|
|
|
if (false === ($delOk = unlink($xmlfile))) { |
68
|
|
|
$module->setErrors(sprintf(_AM_MYIFRAME_ERROR_BAD_REMOVE, $xmlfile)); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
// return $success && $delOk; // use this if you're using this routine |
72
|
|
|
*/ |
73
|
|
|
|
74
|
|
|
return $success; |
75
|
|
|
//------------ END ---------------- |
76
|
|
|
} |
77
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.