Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit 7265429

Browse files
committed
create new table for user preferences
1 parent 0595009 commit 7265429

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

hook.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
*/
4747
function plugin_mantis_install() {
4848

49-
require_once('inc/mantis.class.php');
50-
PluginMantisMantis::install();
49+
require_once('inc/mantis.class.php');
50+
PluginMantisMantis::install();
5151

5252
global $DB;
5353

@@ -59,28 +59,44 @@ function plugin_mantis_install() {
5959
idTicket int(11) NOT NULL,
6060
idMantis int(11) NOT NULL,
6161
dateEscalade date NOT NULL,
62+
itemType varchar NOT NULL,
6263
user int(11) NOT NULL)";
6364
$DB->query($query) or die($DB->error());
6465
}else{
65-
$mig = new Migration();
66+
$mig = new Migration(200);
6667
$table = 'glpi_plugin_mantis_mantis';
6768
$mig->addField($table, 'itemType', 'string');
6869
$mig->executeMigration();
6970
}
7071

7172

73+
// création de la table du plugin
74+
if (!TableExists("glpi_plugin_mantis_userprefs")) {
75+
$query = "CREATE TABLE glpi_plugin_mantis_userprefs (
76+
id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
77+
users_id int(11) NOT NULL ,
78+
followTask int(11) NOT NULL default '0',
79+
followFollow int(11) NOT NULL default '0',
80+
followAttachment int(11) NOT NULL default '0',
81+
followTitle int(11) NOT NULL default '0',
82+
followDescription int(11) NOT NULL default '0',
83+
followCategorie int(11) NOT NULL default '0',
84+
followLinkedItem int(11) NOT NULL default '0',
85+
UNIQUE KEY (`users_id`))";
86+
$DB->query($query) or die($DB->error());
87+
}
88+
89+
7290

7391

7492
// Création de la table uniquement lors de la première installation
7593
if (!TableExists("glpi_plugin_mantis_profiles")) {
76-
7794
// requete de création de la table
7895
$query = "CREATE TABLE `glpi_plugin_mantis_profiles` (
7996
`id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',
8097
`right` char(1) collate utf8_unicode_ci default NULL,
8198
PRIMARY KEY (`id`)
8299
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
83-
84100
$DB->queryOrDie($query, $DB->error());
85101

86102
//creation du premier accès nécessaire lors de l'installation du plugin
@@ -98,24 +114,26 @@ function plugin_mantis_install() {
98114
pwd varchar(255) NOT NULL default '',
99115
champsUrlGlpi varchar(100) NOT NULL default '',
100116
champsGlpi varchar(100) NOT NULL default '',
101-
enable_assign int(1) NOT NULL default 0,
117+
enable_assign int(3) NOT NULL default 0,
118+
neutralize_escalation int(3) NOT NULL default 0,
119+
status_after_escalation int(3) NOT NULL default 0,
120+
show_option_delete int(3) NOT NULL default 0,
121+
doc_categorie int(3) NOT NULL default 0,
122+
itemType varchar(255) NOT NULL,
102123
etatMantis varchar(100) NOT NULL default '')";
103124
$DB->query($query) or die($DB->error());
104-
105125
//insertion du occcurence dans la table (occurrence par default)
106126
$query = "INSERT INTO glpi_plugin_mantis_configs
107127
(id, host,url,login,pwd)
108128
VALUES (NULL, '','','','')";
109129
$DB->query($query) or die("error in glpi_plugin_mantis_configs table" . $DB->error());
110130
}else{
111-
112-
$mig = new Migration();
131+
$mig = new Migration(200);
113132
$table = 'glpi_plugin_mantis_configs';
114133
$mig->addField($table, 'neutralize_escalation', 'integer',array('value' => 5));
115134
$mig->addField($table, 'status_after_escalation', 'integer');
116135
$mig->addField($table, 'show_option_delete', 'integer',array('value' => 0));
117136
$mig->addField($table, 'doc_categorie', 'integer',array('value' => 0));
118-
119137
$mig->addField($table, 'itemType', 'string');
120138
$mig->executeMigration();
121139
}
@@ -129,15 +147,6 @@ function plugin_mantis_install() {
129147
* @return boolean
130148
*/
131149
function plugin_mantis_uninstall() {
132-
global $DB;
133-
134-
$tables = array("glpi_plugin_mantis_mantis",
135-
"glpi_plugin_mantis_profiles");
136-
137-
Foreach ($tables as $table) {
138-
$DB->query("DROP TABLE IF EXISTS " . $table . ";");
139-
}
140-
141150
require_once('inc/mantis.class.php');
142151
PluginMantisMantis::uninstall();
143152
return true;

0 commit comments

Comments
 (0)