-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhook.php
More file actions
98 lines (84 loc) · 3.57 KB
/
Copy pathhook.php
File metadata and controls
98 lines (84 loc) · 3.57 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
function plugin_holidays_install() : bool {
global $DB;
$migration = new Migration(130);
$countries = array(
'0' => 'Argentina',
'1' => 'Australia',
'2' => 'Austria',
'3' => 'Belgium',
'4' => 'Bosnia',
'5' => 'Brazil',
'6' => 'Canada',
'7' => 'Croatia',
'8' => 'CzechRepublic',
'9' => 'Denmark',
'10' => 'Estonia',
'11' => 'Finland',
'12' => 'France',
'13' => 'Georgia',
'14' => 'Germany',
'15' => 'Greece',
'16' => 'Hungary',
'17' => 'Ireland',
'18' => 'Italy',
'19' => 'Japan',
'20' => 'Latvia',
'21' => 'Lithuania',
'22' => 'Luxembourg',
'23' => 'Netherlands',
'24' => 'NewZealand',
'25' => 'Norway',
'26' => 'Poland',
'27' => 'Portugal',
'28' => 'Romania',
'29' => 'Russia',
'30' => 'Slovakia',
'31' => 'SouthAfrica',
'32' => 'SouthKorea',
'33' => 'Spain',
'34' => 'Sweden',
'35' => 'Switzerland',
'36' => 'Turkey',
'37' => 'Ukraine',
'38' => 'UnitedKingdom',
'39' => 'USA'
);
if (!$DB->tableExists("glpi_plugin_holidays_countrylist")) {
$countrylist = "CREATE TABLE `glpi_plugin_holidays_countrylist` (
`id` INT(11) NOT NULL auto_increment,
`country` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->queryOrDie($countrylist, "erreur lors de la création de la table de configuration ".$DB->error());
foreach ($countries as $country) {
$countrylist = "INSERT INTO `glpi_plugin_holidays_countrylist` (country) VALUES ('$country')";
$DB->queryOrDie($countrylist, $DB->error());
}
} else {
$query = $DB->query("SELECT ENGINE FROM information_schema.TABLES WHERE ENGINE = 'myISAM' AND TABLE_NAME = 'glpi_plugin_holidays_countrylist'");
if($query->num_rows == 1) {
$DB->queryOrDie("ALTER TABLE glpi_plugin_holidays_countrylist ENGINE=InnoDB");
}
}
$migration->executeMigration();
return true;
}
// SELECT Engine FROM glpi_plugin_holidays_countrylist;
function plugin_holidays_uninstall() : bool {
global $DB;
$tables = [
'countrylist',
];
foreach($tables as $table) {
$tablename = 'glpi_plugin_holidays_' . $table;
//Create table only if it doesn't exist yet
if($DB->tableExists($tablename)) {
$DB->queryOrDie(
"DROP TABLE `$tablename`",
$DB->error()
);
}
}
return true;
}