1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright XOOPS Project http://xoops.org/ |
14
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* |
21
|
|
|
* Prepares system prior to attempting to install module |
22
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
23
|
|
|
* |
24
|
|
|
* @return bool true if ready to install, false if not |
25
|
|
|
*/ |
26
|
|
|
function xoops_module_pre_install_adslight(XoopsModule $module) |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
29
|
|
|
$className = ucfirst($moduleDirName) . 'Utilities'; |
30
|
|
|
if (!class_exists($className)) { |
31
|
|
|
xoops_load('utilities', $moduleDirName); |
32
|
|
|
} |
33
|
|
|
//check for minimum XOOPS version |
34
|
|
|
if (!$className::checkXoopsVer($module)) { |
35
|
|
|
return false; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
// check for minimum PHP version |
39
|
|
|
if (!$className::checkPhpVer($module)) { |
40
|
|
|
return false; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$mod_tables =& $module->getInfo('tables'); |
44
|
|
|
foreach ($mod_tables as $table) { |
45
|
|
|
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return true; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* |
53
|
|
|
* Performs tasks required during installation of the module |
54
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
55
|
|
|
* |
56
|
|
|
* @return bool true if installation successful, false if not |
57
|
|
|
*/ |
58
|
|
|
function xoops_module_install_adslight(XoopsModule $module) |
59
|
|
|
{ |
60
|
|
|
include_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; |
61
|
|
|
|
62
|
|
|
// $moduleDirName = $xoopsModule->getVar('dirname'); |
|
|
|
|
63
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
64
|
|
|
xoops_loadLanguage('admin', $moduleDirName); |
65
|
|
|
xoops_loadLanguage('modinfo', $moduleDirName); |
66
|
|
|
|
67
|
|
|
$configurator = include __DIR__ . '/config.php'; |
68
|
|
|
$classUtilities = ucfirst($moduleDirName) . 'Utilities'; |
69
|
|
|
if (!class_exists($classUtilities)) { |
70
|
|
|
xoops_load('utilities', $moduleDirName); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
// --- CREATE FOLDERS --------------- |
74
|
|
View Code Duplication |
if (count($configurator['uploadFolders']) > 0) { |
|
|
|
|
75
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
|
|
|
76
|
|
|
foreach (array_keys($configurator['uploadFolders']) as $i) { |
77
|
|
|
$classUtilities::createFolder($configurator['uploadFolders'][$i]); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// --- COPY blank.png FILES --------------- |
82
|
|
View Code Duplication |
if (count($configurator['copyBlankFiles']) > 0) { |
|
|
|
|
83
|
|
|
$file = __DIR__ . '/../assets/images/blank.png'; |
84
|
|
|
foreach (array_keys($configurator['copyBlankFiles']) as $i) { |
85
|
|
|
$dest = $configurator['copyBlankFiles'][$i] . '/blank.png'; |
86
|
|
|
$classUtilities::copyFile($file, $dest); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
return true; |
90
|
|
|
} |
91
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: