|
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
|
|
|
* @package |
|
16
|
|
|
* @since |
|
17
|
|
|
* @author XOOPS Development Team |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* |
|
22
|
|
|
* Prepares system prior to attempting to install module |
|
23
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
|
24
|
|
|
* |
|
25
|
|
|
* @return bool true if ready to install, false if not |
|
26
|
|
|
*/ |
|
27
|
|
|
function xoops_module_pre_install_xfguestbook(XoopsModule $module) |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
30
|
|
|
$classUtil = ucfirst($moduleDirName) . 'Util'; |
|
31
|
|
|
if (!class_exists($classUtil)) { |
|
32
|
|
|
xoops_load('util', $moduleDirName); |
|
33
|
|
|
} |
|
34
|
|
|
//check for minimum XOOPS version |
|
35
|
|
|
if (!$classUtil::checkVerXoops($module)) { |
|
36
|
|
|
return false; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// check for minimum PHP version |
|
40
|
|
|
if (!$classUtil::checkVerPhp($module)) { |
|
41
|
|
|
return false; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$mod_tables =& $module->getInfo('tables'); |
|
45
|
|
|
foreach ($mod_tables as $table) { |
|
46
|
|
|
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return true; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* |
|
54
|
|
|
* Performs tasks required during installation of the module |
|
55
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
|
56
|
|
|
* |
|
57
|
|
|
* @return bool true if installation successful, false if not |
|
58
|
|
|
*/ |
|
59
|
|
|
function xoops_module_install_xfguestbook(XoopsModule $module) |
|
60
|
|
|
{ |
|
61
|
|
|
include_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; |
|
62
|
|
|
include_once dirname(__DIR__) . '/include/config.php'; |
|
63
|
|
|
|
|
64
|
|
|
if (!isset($moduleDirName)) { |
|
|
|
|
|
|
65
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
|
|
|
|
|
69
|
|
|
} else { |
|
70
|
|
|
$moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
// Load language files |
|
74
|
|
|
$moduleHelper->loadLanguage('admin'); |
|
75
|
|
|
$moduleHelper->loadLanguage('modinfo'); |
|
76
|
|
|
|
|
77
|
|
|
$configurator = new ModuleConfigurator(); |
|
78
|
|
|
$classUtil = ucfirst($moduleDirName) . 'Util'; |
|
79
|
|
|
if (!class_exists($classUtil)) { |
|
80
|
|
|
xoops_load('util', $moduleDirName); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// default Permission Settings ---------------------- |
|
84
|
|
|
global $xoopsModule; |
|
|
|
|
|
|
85
|
|
|
$moduleId = $xoopsModule->getVar('mid'); |
|
86
|
|
|
$moduleId2 = $moduleHelper->getModule()->mid(); |
|
|
|
|
|
|
87
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
|
88
|
|
|
// access rights ------------------------------------------ |
|
89
|
|
|
$gpermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
90
|
|
|
$gpermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
91
|
|
|
$gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
92
|
|
|
$gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
93
|
|
|
$gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
94
|
|
|
|
|
95
|
|
|
// --- CREATE FOLDERS --------------- |
|
96
|
|
View Code Duplication |
if (count($configurator->uploadFolders) > 0) { |
|
|
|
|
|
|
97
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
|
|
|
|
|
98
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
|
99
|
|
|
$classUtil::createFolder($configurator->uploadFolders[$i]); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
// --- COPY blank.png FILES --------------- |
|
104
|
|
View Code Duplication |
if (count($configurator->blankFiles) > 0) { |
|
|
|
|
|
|
105
|
|
|
$file = __DIR__ . '/../assets/images/blank.png'; |
|
106
|
|
|
foreach (array_keys($configurator->blankFiles) as $i) { |
|
107
|
|
|
$dest = $configurator->blankFiles[$i] . '/blank.png'; |
|
108
|
|
|
$classUtil::copyFile($file, $dest); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
return true; |
|
113
|
|
|
} |
|
114
|
|
|
|
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: