-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
82 lines (71 loc) · 2.06 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
require_once __DIR__ . "/classes/plugin.php";
$iolaPlugin = IOLA_CLASS_Plugin::getInstance()->getPlugin();
$dbPrefix = OW_DB_PREFIX;
$sql = [
"CREATE TABLE IF NOT EXISTS `{$dbPrefix}iola_subscription_event` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`timeOffset` bigint(20) NULL,
`data` text NOT NULL,
PRIMARY KEY (`id`),
KEY `timeOffset` (`timeOffset`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
"CREATE TABLE IF NOT EXISTS `{$dbPrefix}iola_subscription` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`streamId` varchar(255) NOT NULL,
`query` text NOT NULL,
`variables` text NOT NULL,
PRIMARY KEY (`id`),
KEY `streamId` (`streamId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
];
foreach ( $sql as $query ) {
try {
OW::getDbo()->query($query);
} catch ( Exception $e ) {
// Skip...
}
}
/**
* Configure the plugin settings page
*/
OW::getPluginManager()->addPluginSettingsRouteName($iolaPlugin->getKey(), "iola.admin-settings");
/**
* Import language dump
*/
try {
BOL_LanguageService::getInstance()->importPrefixFromZip(
__DIR__ . "/langs.zip",
$iolaPlugin->getKey()
);
} catch ( Exception $e ) {
// Skip...
}
/**
* Apply install patches
*/
require_once __DIR__ . "/patches/install.php";
/**
* The code below makes sure that the plugin will always init before other non-system plugins
*/
$firstNonSystemPluginId = OW::getDbo()->queryForColumn(
"SELECT id FROM `{$dbPrefix}base_plugin` WHERE `isSystem`=0 ORDER BY `id` LIMIT 1"
);
$maxPluginId = OW::getDbo()->queryForColumn(
"SELECT MAX(`id`) FROM `{$dbPrefix}base_plugin`"
);
OW::getDbo()->update(
"UPDATE `{$dbPrefix}base_plugin` SET `id`=:toId WHERE `id`=:fromId",
[
"toId" => $maxPluginId + 1,
"fromId" => $firstNonSystemPluginId
]
);
OW::getDbo()->update(
"UPDATE `{$dbPrefix}base_plugin` SET `id`=:toId WHERE `id`=:fromId",
[
"toId" => $firstNonSystemPluginId,
"fromId" => $iolaPlugin->getDto()->getId()
]
);