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
|
|
|
//require_once __DIR__ . '/setup.php'; |
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* |
24
|
|
|
* Prepares system prior to attempting to install module |
25
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
26
|
|
|
* |
27
|
|
|
* @return bool true if ready to install, false if not |
28
|
|
|
*/ |
29
|
|
|
function xoops_module_pre_install_contact(XoopsModule $module) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
32
|
|
|
$classUtility = ucfirst($moduleDirName) . 'Utility'; |
33
|
|
|
if (!class_exists($classUtility)) { |
34
|
|
|
xoops_load('utility', $moduleDirName); |
35
|
|
|
} |
36
|
|
|
//check for minimum XOOPS version |
37
|
|
|
if (!$classUtility::checkVerXoops($module)) { |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// check for minimum PHP version |
42
|
|
|
if (!$classUtility::checkVerPhp($module)) { |
43
|
|
|
return false; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$mod_tables =& $module->getInfo('tables'); |
47
|
|
|
foreach ($mod_tables as $table) { |
48
|
|
|
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return true; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
* Performs tasks required during installation of the module |
57
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
58
|
|
|
* |
59
|
|
|
* @return bool true if installation successful, false if not |
60
|
|
|
*/ |
61
|
|
|
function xoops_module_install_contact(XoopsModule $module) |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
require_once __DIR__ . '/../../../mainfile.php'; |
64
|
|
|
require_once __DIR__ . '/../include/config.php'; |
65
|
|
|
|
66
|
|
|
if (!isset($moduleDirName)) { |
|
|
|
|
67
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
|
|
|
71
|
|
|
} else { |
72
|
|
|
$moduleHelper = Xmf\Module\Helper::getHelper('system'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// Load language files |
76
|
|
|
$moduleHelper->loadLanguage('admin'); |
77
|
|
|
$moduleHelper->loadLanguage('modinfo'); |
78
|
|
|
|
79
|
|
|
$configurator = new ContactConfigurator(); |
80
|
|
|
$classUtility = ucfirst($moduleDirName) . 'Utility'; |
81
|
|
|
if (!class_exists($classUtility)) { |
82
|
|
|
xoops_load('utility', $moduleDirName); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
// default Permission Settings ---------------------- |
86
|
|
|
global $xoopsModule; |
|
|
|
|
87
|
|
|
$moduleId = $xoopsModule->getVar('mid'); |
88
|
|
|
$moduleId2 = $moduleHelper->getModule()->mid(); |
|
|
|
|
89
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
90
|
|
|
// access rights ------------------------------------------ |
91
|
|
|
$gpermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
92
|
|
|
$gpermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
93
|
|
|
$gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
94
|
|
|
$gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
95
|
|
|
$gpermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
96
|
|
|
|
97
|
|
|
// --- CREATE FOLDERS --------------- |
98
|
|
View Code Duplication |
if (count($configurator->uploadFolders) > 0) { |
|
|
|
|
99
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
|
|
|
100
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
101
|
|
|
$classUtility::createFolder($configurator->uploadFolders[$i]); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
// --- COPY blank.png FILES --------------- |
106
|
|
View Code Duplication |
if (count($configurator->blankFiles) > 0) { |
|
|
|
|
107
|
|
|
$file = __DIR__ . '/../assets/images/blank.png'; |
108
|
|
|
foreach (array_keys($configurator->blankFiles) as $i) { |
109
|
|
|
$dest = $configurator->blankFiles[$i] . '/blank.png'; |
110
|
|
|
$classUtility::copyFile($file, $dest); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
//delete .html entries from the tpl table |
114
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
115
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
116
|
|
|
|
117
|
|
|
return true; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.