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_gbook(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_gbook(XoopsModule $module) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
return true; |
61
|
|
|
} |
62
|
|
|
|
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: