|
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
|
|
|
* @package extcal |
|
16
|
|
|
* @since |
|
17
|
|
|
* @author XOOPS Development Team, |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use XoopsModules\Extcal\Helper; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param \XoopsModule $xoopsModule |
|
24
|
|
|
* @param null $previousVersion |
|
|
|
|
|
|
25
|
|
|
* |
|
26
|
|
|
* @return bool |
|
27
|
|
|
*/ |
|
28
|
|
|
function xoops_module_update_extcal(\XoopsModule $xoopsModule, $previousVersion = null) |
|
29
|
|
|
{ |
|
30
|
|
|
$helper = Helper::getInstance(); |
|
31
|
|
|
$newVersion = $helper->getModule()->getVar('version') * 100; |
|
32
|
|
|
if ($newVersion == $previousVersion) { |
|
33
|
|
|
return true; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
//---------------------------------------------------------- |
|
37
|
|
|
// Create eXtCal upload directory |
|
38
|
|
|
$indexFile = __DIR__ . '/index.html'; |
|
39
|
|
|
|
|
40
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extcal'; |
|
41
|
|
|
if (!is_dir($dir)) { |
|
42
|
|
|
if (!mkdir($dir, 0777) && !is_dir($dir)) { |
|
43
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); |
|
44
|
|
|
} |
|
45
|
|
|
copy($indexFile, $dir . '/index.html'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$dir = XOOPS_ROOT_PATH . '/uploads/extcal/location'; |
|
49
|
|
|
if (!is_dir($dir)) { |
|
50
|
|
|
if (!mkdir($dir, 0777) && !is_dir($dir)) { |
|
51
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir)); |
|
52
|
|
|
} |
|
53
|
|
|
copy($indexFile, $dir . '/index.html'); |
|
54
|
|
|
} |
|
55
|
|
|
//------------------------------------------------------------ |
|
56
|
|
|
|
|
57
|
|
|
$fld = XOOPS_ROOT_PATH . '/modules/' . $helper->getModule()->getVar('dirname') . '/versions/'; |
|
58
|
|
|
$cls = 'extcal_%1$s'; |
|
59
|
|
|
|
|
60
|
|
|
$version = [ |
|
61
|
|
|
'2_04' => 204, |
|
62
|
|
|
'2_15' => 215, |
|
63
|
|
|
'2_21' => 221, |
|
64
|
|
|
'2_28' => 228, |
|
65
|
|
|
'2_29' => 229, |
|
66
|
|
|
'2_33' => 233, |
|
67
|
|
|
'2_34' => 234, |
|
68
|
|
|
'2_35' => 235, |
|
69
|
|
|
'2_37' => 237, |
|
70
|
|
|
]; |
|
71
|
|
|
|
|
72
|
|
|
// while (list($key, $val) = each($version)) { |
|
73
|
|
|
foreach ($version as $key => $val) { |
|
74
|
|
|
if ($previousVersion < $val) { |
|
75
|
|
|
$name = sprintf($cls, $key); |
|
76
|
|
|
$f = $fld . $name . '.php'; |
|
77
|
|
|
//ext_echo ("<hr>{$f}<hr>"); |
|
78
|
|
|
if (is_readable($f)) { |
|
79
|
|
|
echo "_AM_EXTCAL_UPDATE_VERSION {$key} = {$val}<br>"; |
|
80
|
|
|
require_once $f; |
|
81
|
|
|
$cl = new $name($xoopsModule, ['previousVersion' => $previousVersion]); |
|
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/* |
|
87
|
|
|
//$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
88
|
|
|
$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
89
|
|
|
|
|
90
|
|
|
$sql = "ALTER TABLE `".$db->prefix('extcal_event')."` ADD `event_organisateur` varchar( 255 ) NOT NULL AFTER `event_desc` ;"; |
|
91
|
|
|
$db->query($sql); |
|
92
|
|
|
/////////// |
|
93
|
|
|
// Create eXtcal upload directory |
|
94
|
|
|
$dir = XOOPS_ROOT_PATH."/uploads/extcal/location"; |
|
95
|
|
|
if(!is_dir($dir)) |
|
96
|
|
|
mkdir($dir, 0777); |
|
97
|
|
|
chmod($dir, 0777); |
|
98
|
|
|
|
|
99
|
|
|
// Copy index.html files on uploads folders |
|
100
|
|
|
$indexFile = XOOPS_ROOT_PATH."/modules/extcal/include/index.html"; |
|
101
|
|
|
copy($indexFile, XOOPS_ROOT_PATH."/uploads/extcal/location/index.html"); |
|
102
|
|
|
|
|
103
|
|
|
*/ |
|
104
|
|
|
|
|
105
|
|
|
return true; |
|
106
|
|
|
} |
|
107
|
|
|
|