Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / install / update_031_04.php @ b67d8923

Historique | Voir | Annoter | Télécharger (19,6 ko)

1
<?php
2
/*
3
 * @version $Id: update_031_04.php 7763 2009-01-06 18:44:50Z moyo $
4
 -------------------------------------------------------------------------
5
 GLPI - Gestionnaire Libre de Parc Informatique
6
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
7

8
 http://indepnet.net/   http://glpi-project.org
9
 -------------------------------------------------------------------------
10

11
 LICENSE
12

13
 This file is part of GLPI.
14

15
 GLPI is free software; you can redistribute it and/or modify
16
 it under the terms of the GNU General Public License as published by
17
 the Free Software Foundation; either version 2 of the License, or
18
 (at your option) any later version.
19

20
 GLPI is distributed in the hope that it will be useful,
21
 but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 GNU General Public License for more details.
24

25
 You should have received a copy of the GNU General Public License
26
 along with GLPI; if not, write to the Free Software
27
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 --------------------------------------------------------------------------
29
 */
30

    
31
// ----------------------------------------------------------------------
32
// Original Author of file:
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36
/// Update from 0.31 to 0.4
37
function update031to04(){
38
        global $DB,$LANG;
39

    
40
        //0.4 Prefixage des tables : 
41
        echo "<p class='center'>Version 0.4 </p>";
42

    
43
        if(!TableExists("glpi_computers")) {
44

    
45
                $query = "ALTER TABLE computers RENAME glpi_computers";
46
                $DB->query($query) or die($LANG["update"][90].$DB->error());
47
                $query = "ALTER TABLE connect_wire RENAME glpi_connect_wire";
48
                $DB->query($query) or die($LANG["update"][90].$DB->error());
49
                $query = "ALTER TABLE dropdown_gfxcard RENAME glpi_dropdown_gfxcard";
50
                $DB->query($query) or die($LANG["update"][90].$DB->error());
51
                $query = "ALTER TABLE dropdown_hdtype RENAME glpi_dropdown_hdtype";
52
                $DB->query($query) or die($LANG["update"][90].$DB->error());
53
                $query = "ALTER TABLE dropdown_iface RENAME glpi_dropdown_iface";
54
                $DB->query($query) or die($LANG["update"][90].$DB->error());
55
                $query = "ALTER TABLE dropdown_locations RENAME glpi_dropdown_locations";
56
                $DB->query($query) or die($LANG["update"][90].$DB->error());
57
                $query = "ALTER TABLE dropdown_moboard RENAME glpi_dropdown_moboard";
58
                $DB->query($query) or die($LANG["update"][90].$DB->error());
59
                $query = "ALTER TABLE dropdown_network RENAME glpi_dropdown_network";
60
                $DB->query($query) or die($LANG["update"][90].$DB->error());
61
                $query = "ALTER TABLE dropdown_os RENAME glpi_dropdown_os";
62
                $DB->query($query) or die($LANG["update"][90].$DB->error());
63
                $query = "ALTER TABLE dropdown_processor RENAME glpi_dropdown_processor";
64
                $DB->query($query) or die($LANG["update"][90].$DB->error());
65
                $query = "ALTER TABLE dropdown_ram RENAME glpi_dropdown_ram";
66
                $DB->query($query) or die($LANG["update"][90].$DB->error());
67
                $query = "ALTER TABLE dropdown_sndcard RENAME glpi_dropdown_sndcard";
68
                $DB->query($query) or die($LANG["update"][90].$DB->error());
69
                $query = "ALTER TABLE event_log RENAME glpi_event_log";
70
                $DB->query($query) or die($LANG["update"][90].$DB->error());
71
                $query = "ALTER TABLE followups RENAME glpi_followups";
72
                $DB->query($query) or die($LANG["update"][90].$DB->error());
73
                $query = "ALTER TABLE inst_software RENAME glpi_inst_software";
74
                $DB->query($query) or die($LANG["update"][90].$DB->error());
75
                $query = "ALTER TABLE licenses RENAME glpi_licenses";
76
                $DB->query($query) or die($LANG["update"][90].$DB->error());
77
                $query = "ALTER TABLE monitors RENAME glpi_monitors";
78
                $DB->query($query) or die($LANG["update"][90].$DB->error());
79
                $query = "ALTER TABLE networking RENAME glpi_networking";
80
                $DB->query($query) or die($LANG["update"][90].$DB->error());
81
                $query = "ALTER TABLE networking_ports RENAME glpi_networking_ports";
82
                $DB->query($query) or die($LANG["update"][90].$DB->error());
83
                $query = "ALTER TABLE networking_wire RENAME glpi_networking_wire";
84
                $DB->query($query) or die($LANG["update"][90].$DB->error());
85
                if(TableExists("prefs")&&!TableExists("glpi_prefs")) {
86
                        $query = "ALTER TABLE prefs RENAME glpi_prefs";
87
                        $DB->query($query) or die($LANG["update"][90].$DB->error());
88
                }
89
                $query = "ALTER TABLE printers RENAME glpi_printers";
90
                $DB->query($query) or die($LANG["update"][90].$DB->error());
91
                $query = "ALTER TABLE software RENAME glpi_software";
92
                $DB->query($query) or die($LANG["update"][90].$DB->error());
93
                $query = "ALTER TABLE templates RENAME glpi_templates";
94
                $DB->query($query) or die($LANG["update"][90].$DB->error());
95
                $query = "ALTER TABLE tracking RENAME glpi_tracking";
96
                $DB->query($query) or die($LANG["update"][90].$DB->error());
97
                $query = "ALTER TABLE type_computers RENAME glpi_type_computers";
98
                $DB->query($query) or die($LANG["update"][90].$DB->error());
99
                $query = "ALTER TABLE type_monitors RENAME glpi_type_monitors";
100
                $DB->query($query) or die($LANG["update"][90].$DB->error());
101
                $query = "ALTER TABLE type_networking RENAME glpi_type_networking";
102
                $DB->query($query) or die($LANG["update"][90].$DB->error());
103
                $query = "ALTER TABLE type_printers RENAME glpi_type_printers";
104
                $DB->query($query) or die($LANG["update"][90].$DB->error());
105
                $query = "ALTER TABLE users RENAME glpi_users";
106
                $DB->query($query) or die($LANG["update"][90].$DB->error()); 
107

    
108
        }        
109

    
110
        //Ajout d'un champs ID dans la table users
111
        if(!FieldExists("glpi_users", "ID")) {
112
                $query = "ALTER TABLE `glpi_users` DROP PRIMARY KEY";
113
                $DB->query($query) or die($LANG["update"][90].$DB->error());
114
                $query = "ALTER TABLE `glpi_users` ADD UNIQUE (`name`)";
115
                $DB->query($query) or die($LANG["update"][90].$DB->error());
116
                $query = "ALTER TABLE `glpi_users` ADD INDEX (`name`)";
117
                $DB->query($query) or die($LANG["update"][90].$DB->error());
118
                $query = " ALTER TABLE `glpi_users` ADD `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
119
                $DB->query($query) or die($LANG["update"][90].$DB->error());
120

    
121
        }
122
        //Mise a jour des ID pour les tables dropdown et type. cl� primaires sur les tables dropdown et type, et mise a jour des champs li�
123
        if(!FieldExists("glpi_dropdown_os", "ID")) {
124
                changeVarcharToID("glpi_computers", "glpi_dropdown_os", "os");
125
                changeVarcharToID("glpi_computers", "glpi_dropdown_hdtype", "hdtype");
126
                changeVarcharToID("glpi_computers", "glpi_dropdown_sndcard", "sndcard");
127
                changeVarcharToID("glpi_computers", "glpi_dropdown_moboard", "moboard");
128
                changeVarcharToID("glpi_computers", "glpi_dropdown_gfxcard", "gfxcard");
129
                changeVarcharToID("glpi_computers", "glpi_dropdown_network", "network");
130
                changeVarcharToID("glpi_computers", "glpi_dropdown_ram", "ramtype");
131
                changeVarcharToID("glpi_computers", "glpi_dropdown_locations", "location");
132
                changeVarcharToID("glpi_computers", "glpi_dropdown_processor", "processor");
133
                changeVarcharToID("glpi_monitors", "glpi_dropdown_locations", "location");
134
                changeVarcharToID("glpi_networking", "glpi_dropdown_locations", "location");
135
                changeVarcharToID("glpi_networking_ports", "glpi_dropdown_iface", "iface");
136
                changeVarcharToID("glpi_printers", "glpi_dropdown_locations", "location");
137
                changeVarcharToID("glpi_software", "glpi_dropdown_locations", "location");
138
                changeVarcharToID("glpi_software", "glpi_dropdown_os", "platform");
139
                changeVarcharToID("glpi_templates", "glpi_dropdown_os", "os");
140
                changeVarcharToID("glpi_templates", "glpi_dropdown_hdtype", "hdtype");
141
                changeVarcharToID("glpi_templates", "glpi_dropdown_sndcard", "sndcard");
142
                changeVarcharToID("glpi_templates", "glpi_dropdown_moboard", "moboard");
143
                changeVarcharToID("glpi_templates", "glpi_dropdown_gfxcard", "gfxcard");
144
                changeVarcharToID("glpi_templates", "glpi_dropdown_network", "network");
145
                changeVarcharToID("glpi_templates", "glpi_dropdown_ram", "ramtype");
146
                changeVarcharToID("glpi_templates", "glpi_dropdown_locations", "location");
147
                changeVarcharToID("glpi_templates", "glpi_dropdown_processor", "processor");
148
                changeVarcharToID("glpi_users", "glpi_dropdown_locations", "location");
149

    
150
                changeVarcharToID("glpi_monitors", "glpi_type_monitors", "type");
151
                changeVarcharToID("glpi_printers", "glpi_type_printers", "type");
152
                changeVarcharToID("glpi_networking", "glpi_type_networking", "type");
153
                changeVarcharToID("glpi_computers", "glpi_type_computers", "type");
154
                changeVarcharToID("glpi_templates", "glpi_type_computers", "type");
155

    
156
        }
157

    
158
        if(!TableExists("glpi_type_peripherals")) {
159

    
160
                $query = "CREATE TABLE `glpi_type_peripherals` (
161
                        `ID` int(11) NOT NULL auto_increment,
162
                        `name` varchar(255),
163
                        PRIMARY KEY  (`ID`)
164
                                ) TYPE=MyISAM;";
165
                $DB->query($query)or die("0A ".$LANG["update"][90].$DB->error());
166
        }
167

    
168
        if(!TableExists("glpi_peripherals")) {
169

    
170
                $query = "CREATE TABLE `glpi_peripherals` (
171
                        `ID` int(11) NOT NULL auto_increment,
172
                        `name` varchar(255) NOT NULL default '',
173
                        `date_mod` datetime NOT NULL default '0000-00-00 00:00:00',
174
                        `contact` varchar(255) NOT NULL default '',
175
                        `contact_num` varchar(255) NOT NULL default '',
176
                        `comments` text NOT NULL,
177
                        `serial` varchar(255) NOT NULL default '',
178
                        `otherserial` varchar(255) NOT NULL default '',
179
                        `date_fin_garantie` date default NULL,
180
                        `achat_date` date NOT NULL default '0000-00-00',
181
                        `maintenance` int(2) default '0',
182
                        `location` int(11) NOT NULL default '0',
183
                        `type` int(11) NOT NULL default '0',
184
                        `brand` varchar(255) NOT NULL default '',
185
                        PRIMARY KEY  (`ID`)
186
                                ) TYPE=MyISAM;";
187

    
188
                $DB->query($query) or die("0 ".$LANG["update"][90].$DB->error());
189
        }
190

    
191
        if(TableExists("glpi_prefs")&&!FieldExists("glpi_prefs", "ID")) {
192
                $query = "Alter table glpi_prefs drop primary key";
193
                $DB->query($query) or die("1 ".$LANG["update"][90].$DB->error());
194
                $query = "Alter table glpi_prefs add ID INT(11) not null auto_increment primary key";
195
                $DB->query($query) or die("3 ".$LANG["update"][90].$DB->error());
196
        }
197
        if(!FieldExists("glpi_config", "ID")) {
198

    
199
                $query = "ALTER TABLE `glpi_config` CHANGE `config_id` `ID` INT(11) NOT NULL AUTO_INCREMENT ";
200
                $DB->query($query) or die("4 ".$LANG["update"][90].$DB->error());
201
        }
202

    
203
        if(!isIndex("glpi_computers", "location")) {
204
                $query = "ALTER TABLE `glpi_computers` ADD INDEX (`location`) ";
205
                $DB->query($query) or die("5 ".$LANG["update"][90].$DB->error());
206
        }
207

    
208
        if(!isIndex("glpi_computers", "os")) {
209
                $query = "ALTER TABLE `glpi_computers` ADD INDEX (`os`) ";
210
                $DB->query($query) or die("6 ".$LANG["update"][90].$DB->error());
211
        }
212

    
213
        if(!isIndex("glpi_computers", "type")) {
214
                $query = "ALTER TABLE `glpi_computers` ADD INDEX (`type`) ";
215
                $DB->query($query) or die("7 ".$LANG["update"][90].$DB->error());
216
        }
217

    
218
        if(!isIndex("glpi_followups", "tracking")) {
219
                $query = "ALTER TABLE `glpi_followups` ADD INDEX (`tracking`) ";
220
                $DB->query($query) or die("12 ".$LANG["update"][90].$DB->error());
221
        }
222

    
223
        if(!isIndex("glpi_networking", "location")) {
224
                $query = "ALTER TABLE `glpi_networking` ADD INDEX (`location`) ";
225
                $DB->query($query) or die("13 ".$LANG["update"][90].$DB->error());
226
        }
227

    
228
        if(!isIndex("glpi_networking_ports", "on_device")) {
229
                $query = "ALTER TABLE `glpi_networking_ports` ADD INDEX (`on_device` , `device_type`)";
230
                $DB->query($query) or die("14 ".$LANG["update"][90].$DB->error());
231
        }
232

    
233
        if(!isIndex("glpi_peripherals", "type")) {
234
                $query = "ALTER TABLE `glpi_peripherals` ADD INDEX (`type`) ";
235
                $DB->query($query) or die("14 ".$LANG["update"][90].$DB->error());
236
        }
237

    
238
        if(!isIndex("glpi_peripherals", "location")) {
239
                $query = "ALTER TABLE `glpi_peripherals` ADD INDEX (`location`) ";
240
                $DB->query($query) or die("15 ".$LANG["update"][90].$DB->error());
241
        }
242

    
243
        if(!isIndex("glpi_printers", "location")) {
244
                $query = "ALTER TABLE `glpi_printers` ADD INDEX (`location`) ";
245
                $DB->query($query) or die("16 ".$LANG["update"][90].$DB->error());
246
        }
247

    
248
        if(!isIndex("glpi_tracking", "computer")) {
249
                $query = "ALTER TABLE `glpi_tracking` ADD INDEX (`computer`) ";
250
                $DB->query($query) or die("17 ".$LANG["update"][90].$DB->error());
251
        }
252

    
253
        if(!isIndex("glpi_tracking", "author")) {
254
                $query = "ALTER TABLE `glpi_tracking` ADD INDEX (`author`) ";
255
                $DB->query($query) or die("18 ".$LANG["update"][90].$DB->error());
256
        }
257

    
258
        if(!isIndex("glpi_tracking", "assign")) {
259
                $query = "ALTER TABLE `glpi_tracking` ADD INDEX (`assign`) ";
260
                $DB->query($query) or die("19 ".$LANG["update"][90].$DB->error());
261
        }
262

    
263
        if(!isIndex("glpi_tracking", "date")) {
264
                $query = "ALTER TABLE `glpi_tracking` ADD INDEX (`date`) ";
265
                $DB->query($query) or die("20 ".$LANG["update"][90].$DB->error());
266
        }
267

    
268
        if(!isIndex("glpi_tracking", "closedate")) {
269
                $query = "ALTER TABLE `glpi_tracking` ADD INDEX (`closedate`) ";
270
                $DB->query($query) or die("21 ".$LANG["update"][90].$DB->error());
271
        }
272

    
273
        if(!isIndex("glpi_tracking", "status")) {
274
                $query = "ALTER TABLE `glpi_tracking` ADD INDEX (`status`) ";
275
                $DB->query($query) or die("22 ".$LANG["update"][90].$DB->error());
276
        }
277

    
278

    
279
        if(!TableExists("glpi_dropdown_firmware")) {
280
                $query = " CREATE TABLE `glpi_dropdown_firmware` (`ID` INT NOT NULL AUTO_INCREMENT ,`name` VARCHAR(255) NOT NULL ,PRIMARY KEY (`ID`))";
281
                $DB->query($query) or die("23 ".$LANG["update"][90].$DB->error());
282
        }
283

    
284
        if(!FieldExists("glpi_networking","firmware")) {
285
                $query = "ALTER TABLE `glpi_networking` ADD `firmware` INT(11);";
286
                $DB->query($query) or die("24 ".$LANG["update"][90].$DB->error());
287
        }
288

    
289
        if(!FieldExists("glpi_tracking","realtime")) {
290
                $query = "ALTER TABLE `glpi_tracking` ADD `realtime` FLOAT NOT NULL;";
291
                $DB->query($query) or die("25 ".$LANG["update"][90].$DB->error());
292
        }
293

    
294
        if(!FieldExists("glpi_printers","flags_usb")) {
295
                $query = "ALTER TABLE `glpi_printers` ADD `flags_usb` TINYINT DEFAULT '0' NOT NULL AFTER `flags_par`";
296
                $DB->query($query) or die("26 ".$LANG["update"][90].$DB->error());
297
        }
298

    
299
        if(!FieldExists("glpi_licenses","expire")) {
300
                $query = "ALTER TABLE `glpi_licenses` ADD `expire` date default NULL";
301
                $DB->query($query) or die("27 ".$LANG["update"][90].$DB->error());
302
        }
303

    
304
        if(!isIndex("glpi_licenses", "sID")) {
305
                $query = "ALTER TABLE `glpi_licenses` ADD INDEX (`sID`) ";
306
                $DB->query($query) or die("32 ".$LANG["update"][90].$DB->error());
307
        }
308

    
309
        if(!isIndex("glpi_followups", "author")) {
310
                $query = "ALTER TABLE `glpi_followups` ADD INDEX (`author`) ";
311
                $DB->query($query) or die("33 ".$LANG["update"][90].$DB->error());
312
        }
313

    
314
        if(!isIndex("glpi_monitors", "type")) {
315
                $query = "ALTER TABLE `glpi_monitors` ADD INDEX (`type`) ";
316
                $DB->query($query) or die("34 ".$LANG["update"][90].$DB->error());
317
        }
318

    
319
        if(!isIndex("glpi_monitors", "location")) {
320
                $query = "ALTER TABLE `glpi_monitors` ADD INDEX (`location`) ";
321
                $DB->query($query) or die("35 ".$LANG["update"][90].$DB->error());
322
        }
323

    
324
        if(!isIndex("glpi_monitors", "type")) {
325
                $query = "ALTER TABLE `glpi_monitors` ADD INDEX (`type`) ";
326
                $DB->query($query) or die("37 ".$LANG["update"][90].$DB->error());
327
        }
328

    
329
        if(!isIndex("glpi_networking", "type")) {
330
                $query = "ALTER TABLE `glpi_networking` ADD INDEX (`type`) ";
331
                $DB->query($query) or die("38 ".$LANG["update"][90].$DB->error());
332
        }
333

    
334
        if(!isIndex("glpi_networking", "firmware")) {
335
                $query = "ALTER TABLE `glpi_networking` ADD INDEX (`firmware`) ";
336
                $DB->query($query) or die("39 ".$LANG["update"][90].$DB->error());
337
        }
338

    
339
        if(!isIndex("glpi_printers", "type")) {
340
                $query = "ALTER TABLE `glpi_printers` ADD INDEX (`type`) ";
341
                $DB->query($query) or die("42 ".$LANG["update"][90].$DB->error());
342
        }
343

    
344
        if(!isIndex("glpi_software", "platform")) {
345
                $query = "ALTER TABLE `glpi_software` ADD INDEX (`platform`) ";
346
                $DB->query($query) or die("44 ".$LANG["update"][90].$DB->error());
347
        }
348

    
349
        if(!isIndex("glpi_software", "location")) {
350
                $query = "ALTER TABLE `glpi_software` ADD INDEX (`location`) ";
351
                $DB->query($query) or die("45 ".$LANG["update"][90].$DB->error());
352
        }
353

    
354
        if(!TableExists("glpi_dropdown_netpoint")) {
355
                $query = " CREATE TABLE `glpi_dropdown_netpoint` (`ID` INT NOT NULL AUTO_INCREMENT ,`location` INT NOT NULL ,`name` VARCHAR(255) NOT NULL ,PRIMARY KEY (`ID`))";
356
                $DB->query($query) or die("46 ".$LANG["update"][90].$DB->error());
357
        }
358

    
359
        if(!isIndex("glpi_dropdown_netpoint", "location")) {
360
                $query = "ALTER TABLE `glpi_dropdown_netpoint` ADD INDEX (`location`) ";
361
                $DB->query($query) or die("47 ".$LANG["update"][90].$DB->error());
362
        }
363

    
364
        if(!FieldExists("glpi_networking_ports","netpoint")) {
365
                $query = "ALTER TABLE `glpi_networking_ports` ADD `netpoint` INT default NULL";
366
                $DB->query($query) or die("27 ".$LANG["update"][90].$DB->error());
367
        }
368

    
369
        if(!isIndex("glpi_networking_ports", "netpoint")) {
370
                $query = "ALTER TABLE `glpi_networking_ports` ADD INDEX (`netpoint`) ";
371
                $DB->query($query) or die("47 ".$LANG["update"][90].$DB->error());
372
        }
373

    
374
        if(!isIndex("glpi_networking_wire", "end1")) {
375
                $query = "ALTER TABLE `glpi_networking_wire` ADD INDEX (`end1`) ";
376
                $DB->query($query) or die("40 ".$LANG["update"][90].$DB->error());
377

    
378

    
379
                // Clean Table
380
                $query = "SELECT * FROM  `glpi_networking_wire` ORDER BY end1, end2 ";
381
                $result=$DB->query($query);
382
                $curend1=-1;
383
                $curend2=-1;
384
                while($line = $DB->fetch_array($result)) {
385
                        if ($curend1==$line['end1']&&$curend2==$line['end2']){
386
                                $q2="DELETE FROM `glpi_networking_wire` WHERE `ID`='".$line['ID']."' LIMIT 1";
387
                                $DB->query($q2);
388
                        }
389
                        else {$curend1=$line['end1'];$curend2=$line['end2'];}
390
                }        
391
                $DB->free_result($result);
392

    
393
                $query = "ALTER TABLE `glpi_networking_wire` ADD UNIQUE end1_1 (`end1`,`end2`) ";
394
                $DB->query($query) or die("477 ".$LANG["update"][90].$DB->error());
395
        }
396

    
397
        if(!isIndex("glpi_networking_wire", "end2")) {
398
                $query = "ALTER TABLE `glpi_networking_wire` ADD INDEX (`end2`) ";
399
                $DB->query($query) or die("41 ".$LANG["update"][90].$DB->error());
400
        }
401

    
402
        if(!isIndex("glpi_connect_wire", "end1")) {
403
                $query = "ALTER TABLE `glpi_connect_wire` ADD INDEX (`end1`) ";
404
                $DB->query($query) or die("40 ".$LANG["update"][90].$DB->error());
405

    
406
                // Clean Table
407
                $query = "SELECT * FROM  `glpi_connect_wire` ORDER BY type, end1, end2 ";
408
                $result=$DB->query($query);
409
                $curend1=-1;
410
                $curend2=-1;
411
                $curtype=-1;
412
                while($line = $DB->fetch_array($result)) {
413
                        if ($curend1==$line['end1']&&$curend2==$line['end2']&&$curtype==$line['type']){
414
                                $q2="DELETE FROM `glpi_connect_wire` WHERE `ID`='".$line['ID']."' LIMIT 1";
415
                                $DB->query($q2);
416
                        }
417
                        else{ $curend1=$line['end1'];$curend2=$line['end2'];$curtype=$line['type'];}
418
                }        
419
                $DB->free_result($result);        
420
                $query = "ALTER TABLE `glpi_connect_wire` ADD UNIQUE end1_1 (`end1`,`end2`,`type`) ";
421
                $DB->query($query) or die("478 ".$LANG["update"][90].$DB->error());
422
        }
423

    
424
        if(!isIndex("glpi_connect_wire", "end2")) {
425
                $query = "ALTER TABLE `glpi_connect_wire` ADD INDEX (`end2`) ";
426
                $DB->query($query) or die("40 ".$LANG["update"][90].$DB->error());
427
        }
428

    
429
        if(!isIndex("glpi_connect_wire", "type")) {
430
                $query = "ALTER TABLE `glpi_connect_wire` ADD INDEX (`type`) ";
431
                $DB->query($query) or die("40 ".$LANG["update"][90].$DB->error());
432
        }
433

    
434

    
435

    
436
        if(!FieldExists("glpi_config","ldap_condition")) {
437
                $query = "ALTER TABLE `glpi_config` ADD `ldap_condition` varchar(255) NOT NULL default ''";
438
                $DB->query($query) or die("48 ".$LANG["update"][90].$DB->error());
439
        }
440

    
441
        $query = "ALTER TABLE `glpi_users` CHANGE `type` `type` ENUM('normal', 'admin', 'post-only', 'super-admin') DEFAULT 'normal' NOT NULL";
442
        $DB->query($query) or die("49 ".$LANG["update"][90].$DB->error());
443

    
444
        $ret["adminchange"] = false;
445
        //All "admin" users have to be set as "super-admin"
446
        if(!superAdminExists()) {
447
                $query = "update glpi_users set type = 'super-admin' where type = 'admin'";
448
                $DB->query($query) or die("49 ".$LANG["update"][90].$DB->error());
449
                if($DB->affected_rows() != 0) {
450
                        $ret["adminchange"] = true;
451
                }
452
        }
453

    
454
        if(!FieldExists("glpi_users","password_md5")) {
455
                $query = "ALTER TABLE `glpi_users` ADD `password_md5` VARCHAR(80) NOT NULL AFTER `password` ";
456
                $DB->query($query) or die("glpi_users.Password_md5".$LANG["update"][90].$DB->error());
457
        }
458

    
459
        if(!FieldExists("glpi_config","permit_helpdesk")) {
460
                $query = "ALTER TABLE `glpi_config` ADD `permit_helpdesk` varchar(200) NOT NULL";
461
                $DB->query($query) or die("glpi_config_permit_helpdesk ".$LANG["update"][90].$DB->error());
462
        }
463

    
464
}
465
?>
Redmine Appliance - Powered by TurnKey Linux