Skip to content

Commit 0543270

Browse files
authored
Merge pull request #63 from ggoffy/master
uninstall with bak-file creation
2 parents 079928f + d5e553f commit 0543270

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

docs/changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
- code cleaning (goffy)
1010
- added function qualifiers (goffy)
1111
- update to php8 (goffy)
12-
- replaced Common/XoopsConfirm by Common/Confirm(mamba/goffy)
12+
- replaced Common/XoopsConfirm by Common/Confirm (mamba/goffy)
13+
- uninstall with bak-file creation (mamba/goffy)
1314

1415
===================================================================
1516
2021/03/31 Version 1.04 RC1

include/uninstall.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,23 @@ function xoops_module_uninstall_wggithub(\XoopsModule $module)
3737

3838
$helper = Wggithub\Helper::getInstance();
3939

40-
$utility = new Wggithub\Utility();
41-
4240
$success = true;
4341
$helper->loadLanguage('admin');
4442

4543
//------------------------------------------------------------------
46-
// Remove uploads folder (and all subfolders) if they exist
44+
// Rename uploads folder to BAK and add date to name
4745
//------------------------------------------------------------------
48-
49-
$old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
50-
foreach ($old_directories as $old_dir) {
51-
$dirInfo = new \SplFileInfo($old_dir);
52-
if ($dirInfo->isDir()) {
53-
// The directory exists so delete it
54-
if (!$utility::rrmdir($old_dir)) {
55-
$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
56-
$success = false;
57-
}
46+
$uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
47+
$dirInfo = new \SplFileInfo($uploadDirectory);
48+
if ($dirInfo->isDir()) {
49+
// The directory exists so rename it
50+
$date = date('Y-m-d');
51+
if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
52+
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory));
53+
$success = false;
5854
}
59-
unset($dirInfo);
6055
}
56+
unset($dirInfo);
6157
/*
6258
//------------ START ----------------
6359
//------------------------------------------------------------------

0 commit comments

Comments
 (0)