This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
hook.php
111 lines (88 loc) · 3.8 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
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
/*
------------------------------------------------------------------------
Surveyticket
Copyright (C) 2012-2017 by the Surveyticket plugin Development Team.
------------------------------------------------------------------------
LICENSE
This file is part of Surveyticket plugin project.
Surveyticket plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Surveyticket plugin 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Surveyticket plugin. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------
@package Surveyticket plugin
@author David Durieux
@author Infotel
@copyright Copyright (c) 2012-2017 Surveyticket plugin team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://github.com/pluginsGLPI/surveyticket
@since 2012
------------------------------------------------------------------------
*/
/**
* @return bool
*/
function plugin_surveyticket_install() {
global $DB;
include_once (GLPI_ROOT . "/plugins/surveyticket/inc/profile.class.php");
if (!$DB->tableExists('glpi_plugin_surveyticket_questions')) {
$DB->runFile(GLPI_ROOT . "/plugins/surveyticket/install/mysql/empty-1.0.7.sql");
}
if (!$DB->fieldExists("glpi_plugin_surveyticket_surveyquestions", "mandatory")) {
include(GLPI_ROOT . "/plugins/surveyticket/install/update13_14.php");
update13to14();
}
if (!$DB->fieldExists("glpi_plugin_surveyticket_answers", "mandatory")) {
include(GLPI_ROOT . "/plugins/surveyticket/install/update14_15.php");
update14to15();
}
if (!$DB->fieldExists("glpi_plugin_surveyticket_answers", "order")) {
include(GLPI_ROOT . "/plugins/surveyticket/install/update15_16.php");
update15to16();
}
if (!$DB->tableExists('glpi_plugin_surveyticket_questions_tickets')) {
include(GLPI_ROOT . "/plugins/surveyticket/install/update16_92.php");
update16to92();
}
PluginSurveyticketProfile::initProfile();
PluginSurveyticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("1.0.5");
$migration->dropTable('glpi_plugin_surveyticket_profiles');
return true;
}
// Uninstall process for plugin : need to return true if succeeded
/**
* @return bool
*/
function plugin_surveyticket_uninstall() {
global $DB;
include_once (GLPI_ROOT . "/plugins/surveyticket/inc/profile.class.php");
include_once (GLPI_ROOT . "/plugins/surveyticket/inc/menu.class.php");
$query = "SHOW TABLES;";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
if (strstr($data[0], "glpi_plugin_surveyticket_")) {
$query_delete = "DROP TABLE `" . $data[0] . "`;";
$DB->query($query_delete) or die($DB->error());
}
}
$query = "DELETE FROM `glpi_displaypreferences`
WHERE `itemtype` LIKE 'PluginSurveyticket%';";
$DB->query($query) or die($DB->error());
//Delete rights associated with the plugin
$profileRight = new ProfileRight();
foreach (PluginSurveyticketProfile::getAllRights() as $right) {
$profileRight->deleteByCriteria(array('name' => $right['field']));
}
PluginSurveyticketMenu::removeRightsFromSession();
PluginSurveyticketProfile::removeRightsFromSession();
return true;
}