|
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_extgallery(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_extgallery(XoopsModule $xoopsModule) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
61
|
|
|
/** @var XoopsGroupPermHandler $gpermHandler */ |
|
62
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
|
63
|
|
|
/** @var XoopsConfigHandler $configHandler */ |
|
64
|
|
|
$configHandler = xoops_getHandler('config'); |
|
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Default public category permission mask |
|
68
|
|
|
*/ |
|
69
|
|
|
|
|
70
|
|
|
// Access right |
|
71
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 1, XOOPS_GROUP_ADMIN, $module_id); |
|
72
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 1, XOOPS_GROUP_USERS, $module_id); |
|
73
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 1, XOOPS_GROUP_ANONYMOUS, $module_id); |
|
74
|
|
|
|
|
75
|
|
|
// Public rate |
|
76
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 2, XOOPS_GROUP_ADMIN, $module_id); |
|
77
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 2, XOOPS_GROUP_USERS, $module_id); |
|
78
|
|
|
|
|
79
|
|
|
// Public eCard |
|
80
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 4, XOOPS_GROUP_ADMIN, $module_id); |
|
81
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 4, XOOPS_GROUP_USERS, $module_id); |
|
82
|
|
|
|
|
83
|
|
|
// Public download |
|
84
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 8, XOOPS_GROUP_ADMIN, $module_id); |
|
85
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 8, XOOPS_GROUP_USERS, $module_id); |
|
86
|
|
|
|
|
87
|
|
|
// Public upload |
|
88
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 16, XOOPS_GROUP_ADMIN, $module_id); |
|
89
|
|
|
|
|
90
|
|
|
// Public autoapprove |
|
91
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 32, XOOPS_GROUP_ADMIN, $module_id); |
|
92
|
|
|
|
|
93
|
|
|
// Public display |
|
94
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 128, XOOPS_GROUP_ADMIN, $module_id); |
|
95
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 128, XOOPS_GROUP_USERS, $module_id); |
|
96
|
|
|
$gpermHandler->addRight('extgallery_public_mask', 128, XOOPS_GROUP_ANONYMOUS, $module_id); |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Default User's category permission |
|
100
|
|
|
*/ |
|
101
|
|
|
|
|
102
|
|
|
// Private gallery |
|
103
|
|
|
|
|
104
|
|
|
// Private rate |
|
105
|
|
|
$gpermHandler->addRight('extgallery_private', 2, XOOPS_GROUP_ADMIN, $module_id); |
|
106
|
|
|
$gpermHandler->addRight('extgallery_private', 2, XOOPS_GROUP_USERS, $module_id); |
|
107
|
|
|
|
|
108
|
|
|
// Private eCard |
|
109
|
|
|
$gpermHandler->addRight('extgallery_private', 4, XOOPS_GROUP_ADMIN, $module_id); |
|
110
|
|
|
$gpermHandler->addRight('extgallery_private', 4, XOOPS_GROUP_USERS, $module_id); |
|
111
|
|
|
|
|
112
|
|
|
// Private download |
|
113
|
|
|
$gpermHandler->addRight('extgallery_private', 8, XOOPS_GROUP_ADMIN, $module_id); |
|
114
|
|
|
$gpermHandler->addRight('extgallery_private', 8, XOOPS_GROUP_USERS, $module_id); |
|
115
|
|
|
|
|
116
|
|
|
// Private autoapprove |
|
117
|
|
|
$gpermHandler->addRight('extgallery_private', 16, XOOPS_GROUP_ADMIN, $module_id); |
|
118
|
|
|
|
|
119
|
|
|
/* |
|
120
|
|
|
|
|
121
|
|
|
// Create eXtGallery main upload directory |
|
122
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extgallery'; |
|
123
|
|
|
if (!is_dir($dir)) { |
|
124
|
|
|
mkdir($dir, 0777); |
|
125
|
|
|
} |
|
126
|
|
|
chmod($dir, 0777); |
|
127
|
|
|
// Create directory for photo in public album |
|
128
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo'; |
|
129
|
|
|
if (!is_dir($dir)) { |
|
130
|
|
|
mkdir($dir, 0777); |
|
131
|
|
|
} |
|
132
|
|
|
chmod($dir, 0777); |
|
133
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/original'; |
|
134
|
|
|
if (!is_dir($dir)) { |
|
135
|
|
|
mkdir($dir, 0777); |
|
136
|
|
|
} |
|
137
|
|
|
chmod($dir, 0777); |
|
138
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/large'; |
|
139
|
|
|
if (!is_dir($dir)) { |
|
140
|
|
|
mkdir($dir, 0777); |
|
141
|
|
|
} |
|
142
|
|
|
chmod($dir, 0777); |
|
143
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/medium'; |
|
144
|
|
|
if (!is_dir($dir)) { |
|
145
|
|
|
mkdir($dir, 0777); |
|
146
|
|
|
} |
|
147
|
|
|
chmod($dir, 0777); |
|
148
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/thumb'; |
|
149
|
|
|
if (!is_dir($dir)) { |
|
150
|
|
|
mkdir($dir, 0777); |
|
151
|
|
|
} |
|
152
|
|
|
chmod($dir, 0777); |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
|
|
156
|
|
|
// Create directory for photo in user's album |
|
157
|
|
|
//mkdir(XOOPS_ROOT_PATH."/uploads/extgallery/user-photo"); |
|
158
|
|
|
|
|
159
|
|
|
// Copy index.html files on uploads folders |
|
160
|
|
|
$indexFile = XOOPS_ROOT_PATH . '/modules/extgallery/include/index.html'; |
|
161
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/index.html'); |
|
162
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/index.html'); |
|
163
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/original/index.html'); |
|
164
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/large/index.html'); |
|
165
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/medium/index.html'); |
|
166
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/thumb/index.html'); |
|
167
|
|
|
|
|
168
|
|
|
*/ |
|
169
|
|
|
|
|
170
|
|
|
$moduleDirName = $xoopsModule->getVar('dirname'); |
|
171
|
|
|
include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/config.php'); |
|
172
|
|
|
|
|
173
|
|
|
$classUtilities = ucfirst($moduleDirName) . 'Utilities'; |
|
174
|
|
|
if (!class_exists($classUtilities)) { |
|
175
|
|
|
xoops_load('utilities', $moduleDirName); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
|
|
179
|
|
|
foreach (array_keys($uploadFolders) as $i) { |
|
180
|
|
|
$classUtilities::createFolder($uploadFolders[$i]); |
|
|
|
|
|
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
$file = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; |
|
184
|
|
|
foreach (array_keys($copyFiles) as $i) { |
|
185
|
|
|
$dest = $copyFiles[$i] . '/blank.png'; |
|
|
|
|
|
|
186
|
|
|
$classUtilities::copyFile($file, $dest); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
return true; |
|
190
|
|
|
} |
|
191
|
|
|
|
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: