|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ExtGallery functions |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
13
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
14
|
|
|
* @author Zoullou (http://www.zoullou.net) |
|
15
|
|
|
* @package ExtGallery |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param XoopsModule $xoopsModule |
|
20
|
|
|
* @param null $oldVersion |
|
21
|
|
|
* @return bool |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
use XoopsModules\Extgallery; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param \XoopsModule $xoopsModule |
|
28
|
|
|
* @param null $oldVersion |
|
|
|
|
|
|
29
|
|
|
* @return bool |
|
30
|
|
|
*/ |
|
31
|
|
|
function xoops_module_update_extgallery(\XoopsModule $xoopsModule, $oldVersion = null) |
|
32
|
|
|
{ |
|
33
|
|
|
$catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory'); |
|
34
|
|
|
$catHandler->rebuild(); |
|
35
|
|
|
|
|
36
|
|
|
if ($oldVersion < 101) { |
|
37
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
38
|
|
|
// Remove the UNIQUE key on the rating table. This constraint is software cheked now |
|
39
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publicrating') . '` DROP INDEX `photo_rate` ;'; |
|
40
|
|
|
$db->query($sql); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if ($oldVersion < 102) { |
|
44
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
45
|
|
|
|
|
46
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publiccat') . '` ADD `cat_imgurl` VARCHAR(150) NOT NULL AFTER `cat_nb_photo` ;'; |
|
47
|
|
|
$db->query($sql); |
|
48
|
|
|
|
|
49
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publicphoto') . '` ADD `photo_title` VARCHAR(150) NOT NULL AFTER `photo_id` ;'; |
|
50
|
|
|
$db->query($sql); |
|
51
|
|
|
|
|
52
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publicphoto') . '` ADD `photo_weight` INT(11) NOT NULL AFTER `photo_extra` ;'; |
|
53
|
|
|
$db->query($sql); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if ($oldVersion < 104) { |
|
57
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
58
|
|
|
|
|
59
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publicphoto') . "` ADD `dohtml` BOOL NOT NULL DEFAULT '0';"; |
|
60
|
|
|
$db->query($sql); |
|
61
|
|
|
|
|
62
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publicphoto') . '` CHANGE `photo_desc` `photo_desc` TEXT;'; |
|
63
|
|
|
$db->query($sql); |
|
64
|
|
|
|
|
65
|
|
|
// Set display parmission for all XOOPS base Groups |
|
66
|
|
|
$sql = 'SELECT cat_id FROM `' . $db->prefix('extgallery_publiccat') . '`;'; |
|
67
|
|
|
$result = $db->query($sql); |
|
68
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
69
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
70
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
71
|
|
|
while (false !== ($cat = $db->fetchArray($result))) { |
|
72
|
|
|
$grouppermHandler->addRight('public_displayed', $cat['cat_id'], XOOPS_GROUP_ADMIN, $module_id); |
|
|
|
|
|
|
73
|
|
|
$grouppermHandler->addRight('public_displayed', $cat['cat_id'], XOOPS_GROUP_USERS, $module_id); |
|
74
|
|
|
$grouppermHandler->addRight('public_displayed', $cat['cat_id'], XOOPS_GROUP_ANONYMOUS, $module_id); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
if ($oldVersion < 106) { |
|
79
|
|
|
if (!is_file(XOOPS_ROOT_PATH . '/uploads/extgallery/index.html')) { |
|
80
|
|
|
$indexFile = XOOPS_ROOT_PATH . '/modules/extgallery/include/index.html'; |
|
81
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/index.html'); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
if (!is_file(XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/index.html')) { |
|
85
|
|
|
$indexFile = XOOPS_ROOT_PATH . '/modules/extgallery/include/index.html'; |
|
86
|
|
|
copy($indexFile, XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/index.html'); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
if ($oldVersion < 107) { |
|
91
|
|
|
// Fix extension Bug if it's installed |
|
92
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/class/textsanitizer/gallery/gallery.php')) { |
|
93
|
|
|
$conf = require XOOPS_ROOT_PATH . '/class/textsanitizer/config.php'; |
|
94
|
|
|
$conf['extensions']['gallery'] = 1; |
|
95
|
|
|
file_put_contents(XOOPS_ROOT_PATH . '/class/textsanitizer/config.custom.php', "<?php\rreturn \$config = " . var_export($conf, true) . "\r?>", LOCK_EX); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
if ($oldVersion < 109) { |
|
100
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
101
|
|
|
|
|
102
|
|
|
$sql = 'ALTER TABLE `' . $db->prefix('extgallery_publiccat') . "` CHANGE `cat_weight` `cat_weight` INT( 11 ) NOT NULL DEFAULT '0' ;"; |
|
103
|
|
|
$db->query($sql); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return true; |
|
107
|
|
|
} |
|
108
|
|
|
|