-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathhook.php
More file actions
executable file
·108 lines (82 loc) · 3.35 KB
/
hook.php
File metadata and controls
executable file
·108 lines (82 loc) · 3.35 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
99
100
101
102
103
104
105
106
107
108
<?php
/*
-------------------------------------------------------------------------
Webhook plugin for GLPI
Copyright (C) 2020-2022 by Eric Feron.
-------------------------------------------------------------------------
LICENSE
This file is part of Webhook.
Webhook is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
at your option any later version.
Webhook is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Webhook. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
function plugin_webhook_install() {
global $DB;
// include_once (Plugin::getPhpDir("webhook")."/inc/profile.class.php");
if (!$DB->TableExists("glpi_plugin_webhook_configs")) {
$DB->runFile(Plugin::getPhpDir("webhook")."/sql/empty-1.0.4.sql");
}
else {
if ($DB->TableExists("glpi_plugin_webhook_secrettypes")) {
$query = "SELECT name FROM glpi_plugin_webhook_secrettypes WHERE id=2";
$result = $DB->query($query);
while ($data = $DB->fetchRow($result)) {
if ($data[0] == "Encoded Basic Authentication") {
$DB->runFile(Plugin::getPhpDir("webhook")."/sql/update-1.0.2.sql");
Session::addMessageAfterRedirect('<font color="red"><b>'.__('!! Authentication types have been modified !!<br/>!! You should review them in Webhooks configuration !!').'</b></font>');
}
}
}
if (!$DB->FieldExists("glpi_plugin_webhook_configs","debug")) {
$DB->runFile(Plugin::getPhpDir("webhook")."/sql/update-1.0.3.sql");
}
}
Config::setConfigurationValues('core', ['notifications_webhook' => 0]);
Config::setConfigurationValues('plugin:webhook', ['webhook_max_retries' => '6',
'webhook_retry_time' => '5'
]
);
PluginWebhookProfile::initProfile();
PluginWebhookProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
function plugin_webhook_uninstall() {
global $DB;
$config = new Config();
$config->deleteConfigurationValues('core', ['notifications_webhook']);
$tables = ["glpi_plugin_webhook_configs", "glpi_plugin_webhook_secrettypes", "glpi_plugin_webhook_operationtypes"];
foreach($tables as $table)
$DB->query("DROP TABLE IF EXISTS `$table`;");
$tables_glpi = ["glpi_displaypreferences",
"glpi_documents_items",
"glpi_savedsearches",
"glpi_logs",
"glpi_items_tickets",
"glpi_notepads",
"glpi_dropdowntranslations"];
foreach($tables_glpi as $table_glpi)
$DB->query("DELETE FROM `$table_glpi` WHERE `itemtype` LIKE 'PluginWebhook%' ;");
return true;
}
// Define Dropdown tables to be managed in GLPI :
function plugin_webhook_getDropdown() {
$plugin = new Plugin();
if ($plugin->isActivated("webhook"))
return ["PluginWebhookSecrettype"=>PluginWebhookSecrettype::getTypeName(2)];
else
return [];
}
////// SEARCH FUNCTIONS ///////() {
function plugin_webhook_getAddSearchOptions($itemtype) {
$sopt=[];
return $sopt;
}
?>