forked from pluginsGLPI/satisfaction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.php
66 lines (53 loc) · 2.07 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
<?php
/**
* @return bool
*/
function plugin_satisfaction_install() {
global $DB;
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/profile.class.php");
if (!$DB->tableExists("glpi_plugin_satisfaction_surveys")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/empty-1.4.1.sql");
} else {
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveyquestions", "type")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.1.0.sql");
}
//version 1.2.1
if (!$DB->fieldExists("glpi_plugin_satisfaction_surveyquestions", "default_value")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.2.2.sql");
}
//version 1.4.1
if (!$DB->tableExists("glpi_plugin_satisfaction_surveytranslations")) {
$DB->runFile(GLPI_ROOT . "/plugins/satisfaction/install/sql/update-1.4.1.sql");
}
}
PluginSatisfactionProfile::initProfile();
PluginSatisfactionProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
/**
* @return bool
*/
function plugin_satisfaction_uninstall() {
global $DB;
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/profile.class.php");
include_once(GLPI_ROOT . "/plugins/satisfaction/inc/menu.class.php");
$tables = ["glpi_plugin_satisfaction_surveys",
"glpi_plugin_satisfaction_surveyquestions",
"glpi_plugin_satisfaction_surveyanswers"];
foreach ($tables as $table) {
$DB->query("DROP TABLE IF EXISTS `$table`;");
}
$tables_glpi = ["glpi_logs"];
foreach ($tables_glpi as $table_glpi) {
$DB->query("DELETE FROM `$table_glpi`
WHERE `itemtype` = 'PluginSatisfactionSurvey';");
}
//Delete rights associated with the plugin
$profileRight = new ProfileRight();
foreach (PluginSatisfactionProfile::getAllRights() as $right) {
$profileRight->deleteByCriteria(['name' => $right['field']]);
}
PluginSatisfactionProfile::removeRightsFromSession();
PluginSatisfactionMenu::removeRightsFromSession();
return true;
}