-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhook.php
More file actions
111 lines (93 loc) · 3.65 KB
/
Copy pathhook.php
File metadata and controls
111 lines (93 loc) · 3.65 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
109
110
111
<?php
/**
* -------------------------------------------------------------------------
* engage plugin for GLPI is a tool designed to facilitate user assignment
* and SLA compliance.
* Copyright (C) 2022 by the engage Development Team.
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Engage.
*
* Engage 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.
*
* Engage 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 Engage. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* @package Engage
* @author Miguel Angel Ruiz (miguelangelrtorresco@gmail.com)
* @copyright Copyright (C) 2022 by the engage plugin team.
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
* @link https://github.com/miguelanruiz/engage
* --------------------------------------------------------------------------
*/
/**
* Plugin install process
*
* @return boolean
*/
function plugin_engage_install()
{
global $CFG_GLPI, $DB;
$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
$default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
$migration = new Migration(PLUGIN_ENGAGE_VERSION);
$table = getTableForItemtype('PluginEngageConfig');
if (!$DB->allow_signed_keys){
$default_key_sign = "unsigned";
$migration->displayMessage("You need consider review config_db, your database should allow SignedKeys, if yes please configure it and reinstall.");
$migration->log("You need consider review config_db, your database should allow SignedKeys, if yes please configure it and reinstall.",true);
}
if (!$DB->tableExists($table)) {
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (
`id` INT {$default_key_sign} NOT NULL auto_increment,
`users_id_tech` INT DEFAULT 0,
`itil_followup` INT DEFAULT 0,
`entities_id` INT DEFAULT NULL,
`is_recursive` INT DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->queryOrDie($query, $DB->error());
$migration->displayMessage("Table `{$table}` was created.");
}
$migration->addField($table,'is_active','boolean',['value' => '1']);
$migration->displayMessage("New feature for disable interaction.");
$migration->addField($table,'ticket_type','int',['value' => '0']);
$migration->displayMessage("New feature for restrict incident or demand ticket.");
$migration->executeMigration();
$migration->displayMessage("Installation of Engage plugin was executed.");
return true;
}
/**
* Plugin uninstall process
*
* @return boolean
*/
function plugin_engage_uninstall()
{
global $DB;
$config = getTableForItemtype('PluginEngageConfig');
$tables = [
$config
];
foreach ($tables as $table) {
$tablename = $table;
if ($DB->tableExists($tablename)) {
$DB->queryOrDie(
"DROP TABLE `$tablename`",
$DB->error()
);
}
}
return true;
}