-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.php
60 lines (47 loc) · 1.26 KB
/
hook.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
<?php
function plugin_pdu_install() {
global $DB;
if (
(!TableExists("glpi_plugin_pdu_models")) &&
(!TableExists("glpi_plugin_pdu_connections"))
) {
$DB->runFile(dirname(__FILE__) . "/db/mysql.0.0.1.sql") or
Html::displayErrorAndDie(
"Error installing PDUs plugin ". $DB->error()
);
}
return true;
}
function plugin_pdu_uninstall() {
global $DB;
foreach (array("models", "connections") as $table) {
if (TableExists("glpi_plugin_pdu_" . $table)) {
$DB->query("DROP TABLE glpi_plugin_pdu_" . $table) or
print "Cannot remove database table glpi_plugin_pdu_" .
$table;
}
}
return true;
}
function plugin_item_purge_pdu($item) {
global $DB;
$sql = sprintf(
'DELETE FROM `glpi_plugin_pdu_connections` ' .
'WHERE `connected_itemtype` = \'%s\' ' .
'AND `connected_id` = %d',
$item->getType(),
$item->getID()
);
$DB->query($sql);
$PluginPduModel = new PluginPduModel;
if ( $PluginPduModel->isPdu($item->getID()) ) {
$sql = sprintf(
'DELETE FROM `glpi_plugin_pdu_connections`
WHERE `pdu_id` = %d',
$item->getID()
);
}
$DB->query($sql);
return true;
}
?>