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 {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
//from extgallery |
19
|
|
|
|
20
|
|
|
//error_reporting(E_ALL); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param \XoopsObject $xoopsModule |
24
|
|
|
* @return bool |
25
|
|
|
*/ |
26
|
|
|
function xoops_module_install_lexikon(\XoopsObject $xoopsModule) |
27
|
|
|
{ |
28
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
29
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
30
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
31
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
32
|
|
|
$configHandler = xoops_getHandler('config'); |
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Default public category permission mask |
36
|
|
|
*/ |
37
|
|
|
|
38
|
|
|
// Access right |
39
|
|
|
$grouppermHandler->addRight('lexikon_view', 1, XOOPS_GROUP_ADMIN, $module_id); |
|
|
|
|
40
|
|
|
$grouppermHandler->addRight('lexikon_view', 1, XOOPS_GROUP_USERS, $module_id); |
41
|
|
|
$grouppermHandler->addRight('lexikon_view', 1, XOOPS_GROUP_ANONYMOUS, $module_id); |
42
|
|
|
|
43
|
|
|
// Public submit |
44
|
|
|
$grouppermHandler->addRight('lexikon_submit', 1, XOOPS_GROUP_ADMIN, $module_id); |
45
|
|
|
$grouppermHandler->addRight('lexikon_submit', 1, XOOPS_GROUP_USERS, $module_id); |
46
|
|
|
|
47
|
|
|
// Public request |
48
|
|
|
$grouppermHandler->addRight('lexikon_request', 1, XOOPS_GROUP_ADMIN, $module_id); |
49
|
|
|
$grouppermHandler->addRight('lexikon_request', 1, XOOPS_GROUP_USERS, $module_id); |
50
|
|
|
$grouppermHandler->addRight('lexikon_request', 1, XOOPS_GROUP_ANONYMOUS, $module_id); |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Create default upload directories |
54
|
|
|
*/ |
55
|
|
|
// Copy base file |
56
|
|
|
$indexFile = XOOPS_UPLOAD_PATH . '/index.html'; |
57
|
|
|
$blankFile = XOOPS_UPLOAD_PATH . '/blank.gif'; |
58
|
|
|
// Making of uploads/lexikon folder |
59
|
|
|
$p_lexikon = XOOPS_UPLOAD_PATH . '/lexikon'; |
60
|
|
|
if (!is_dir($p_lexikon)) { |
61
|
|
|
if (!mkdir($p_lexikon, 0777) && !is_dir($p_lexikon)) { |
62
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $p_lexikon)); |
63
|
|
|
} |
64
|
|
|
chmod($p_lexikon, 0777); |
65
|
|
|
} |
66
|
|
|
copy($indexFile, $p_lexikon . '/index.html'); |
67
|
|
|
// Making of categories folder |
68
|
|
|
$pl_categories = $p_lexikon . '/categories'; |
69
|
|
|
if (!is_dir($pl_categories)) { |
70
|
|
|
if (!mkdir($pl_categories, 0777) && !is_dir($pl_categories)) { |
71
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $pl_categories)); |
72
|
|
|
} |
73
|
|
|
chmod($pl_categories, 0777); |
74
|
|
|
} |
75
|
|
|
copy($indexFile, $pl_categories . '/index.html'); |
76
|
|
|
|
77
|
|
|
$plc_images = $pl_categories . '/images'; |
78
|
|
|
if (!is_dir($plc_images)) { |
79
|
|
|
if (!mkdir($plc_images, 0777) && !is_dir($plc_images)) { |
80
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $plc_images)); |
81
|
|
|
} |
82
|
|
|
chmod($plc_images, 0777); |
83
|
|
|
} |
84
|
|
|
copy($indexFile, $plc_images . '/index.html'); |
85
|
|
|
copy($blankFile, $plc_images . '/blank.gif'); |
86
|
|
|
// Making of entries folder |
87
|
|
|
$pl_entries = $p_lexikon . '/entries'; |
88
|
|
|
if (!is_dir($pl_entries)) { |
89
|
|
|
if (!mkdir($pl_entries, 0777) && !is_dir($pl_entries)) { |
90
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $pl_entries)); |
91
|
|
|
} |
92
|
|
|
chmod($pl_entries, 0777); |
93
|
|
|
} |
94
|
|
|
copy($indexFile, $pl_entries . '/index.html'); |
95
|
|
|
|
96
|
|
|
$ple_images = $pl_entries . '/images'; |
97
|
|
|
if (!is_dir($ple_images)) { |
98
|
|
|
if (!mkdir($ple_images, 0777) && !is_dir($ple_images)) { |
99
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $ple_images)); |
100
|
|
|
} |
101
|
|
|
chmod($ple_images, 0777); |
102
|
|
|
} |
103
|
|
|
copy($indexFile, $ple_images . '/index.html'); |
104
|
|
|
copy($blankFile, $ple_images . '/blank.gif'); |
105
|
|
|
|
106
|
|
|
return true; |
107
|
|
|
} |
108
|
|
|
|