1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* News functions |
5
|
|
|
* |
6
|
|
|
* You may not change or alter any portion of this comment or credits |
7
|
|
|
* of supporting developers from this source code or any supporting source code |
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
* This program is distributed in the hope that it will be useful, |
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
* |
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
15
|
|
|
* @author Voltan |
16
|
|
|
* @return bool |
17
|
|
|
*/ |
18
|
|
|
function xoops_module_pre_install_news(\XoopsModule $module) |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
// Check if this XOOPS version is supported |
21
|
|
|
$minSupportedVersion = explode('.', '2.5.0'); |
22
|
|
|
$currentVersion = explode('.', mb_substr(XOOPS_VERSION, 6)); |
23
|
|
|
|
24
|
|
|
if ($currentVersion[0] > $minSupportedVersion[0]) { |
25
|
|
|
return true; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
if ($currentVersion[0] == $minSupportedVersion[0]) { |
29
|
|
|
if ($currentVersion[1] > $minSupportedVersion[1]) { |
30
|
|
|
return true; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
if ($currentVersion[1] == $minSupportedVersion[1]) { |
34
|
|
|
if ($currentVersion[2] > $minSupportedVersion[2]) { |
35
|
|
|
return true; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if ($currentVersion[2] == $minSupportedVersion[2]) { |
39
|
|
|
return true; |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return false; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param \XoopsModule $module |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
|
|
function xoops_module_install_news(\XoopsModule $module) |
52
|
|
|
{ |
53
|
|
|
$module_id = $module->getVar('mid'); |
54
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
55
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
56
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
57
|
|
|
$configHandler = xoops_getHandler('config'); |
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Default public category permission mask |
61
|
|
|
*/ |
62
|
|
|
|
63
|
|
|
// Access right |
64
|
|
|
$grouppermHandler->addRight('news_approve', 1, XOOPS_GROUP_ADMIN, $module_id); |
|
|
|
|
65
|
|
|
$grouppermHandler->addRight('news_submit', 1, XOOPS_GROUP_ADMIN, $module_id); |
66
|
|
|
$grouppermHandler->addRight('news_view', 1, XOOPS_GROUP_ADMIN, $module_id); |
67
|
|
|
|
68
|
|
|
$grouppermHandler->addRight('news_view', 1, XOOPS_GROUP_USERS, $module_id); |
69
|
|
|
$grouppermHandler->addRight('news_view', 1, XOOPS_GROUP_ANONYMOUS, $module_id); |
70
|
|
|
|
71
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/news'; |
72
|
|
|
// if (!is_dir($dir)) { |
73
|
|
|
// mkdir($dir, 0777); |
74
|
|
|
// } |
75
|
|
|
|
76
|
|
|
if (!@mkdir($dir) && !is_dir($dir)) { |
77
|
|
|
throw new \RuntimeException('The directory ' . $dir . ' could not be created.'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
chmod($dir, 0777); |
81
|
|
|
|
82
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/news/file'; |
83
|
|
|
if (!@mkdir($dir) && !is_dir($dir)) { |
84
|
|
|
throw new \RuntimeException('The directory ' . $dir . ' could not be created.'); |
85
|
|
|
} |
86
|
|
|
chmod($dir, 0777); |
87
|
|
|
|
88
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/news/image'; |
89
|
|
|
if (!@mkdir($dir) && !is_dir($dir)) { |
90
|
|
|
throw new \RuntimeException('The directory ' . $dir . ' could not be created.'); |
91
|
|
|
} |
92
|
|
|
chmod($dir, 0777); |
93
|
|
|
|
94
|
|
|
// Copy index.html files on uploads folders |
95
|
|
|
$indexFile = XOOPS_ROOT_PATH . '/modules/news/include/index.php'; |
96
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/news/index.php'); |
97
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/news/file/index.php'); |
98
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/news/image/index.php'); |
99
|
|
|
|
100
|
|
|
return true; |
101
|
|
|
} |
102
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.