Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

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

Historique | Voir | Annoter | Télécharger (50,3 ko)

1
<?php
2
/*
3
 * @version $Id: update_06_065.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.6 to 0.65
37
function update06to065(){
38
        global $DB,$LANG;
39

    
40
        echo "<p class='center'>Version 0.65 </p>";
41

    
42
        if(!isIndex("glpi_networking_ports", "on_device_2")) {
43
                $query = "ALTER TABLE `glpi_networking_ports` ADD INDEX (`on_device`) ";
44
                $DB->query($query) or die("0.65 ".$LANG["update"][90].$DB->error());
45
        }
46

    
47
        if(!isIndex("glpi_networking_ports", "device_type")) {
48
                $query = "ALTER TABLE `glpi_networking_ports` ADD INDEX (`device_type`) ";
49
                $DB->query($query) or die("0.65 ".$LANG["update"][90].$DB->error());
50
        }
51

    
52
        if(!isIndex("glpi_computer_device", "FK_device")) {
53
                $query = "ALTER TABLE `glpi_computer_device` ADD INDEX (`FK_device`) ";
54
                $DB->query($query) or die("0.65 ".$LANG["update"][90].$DB->error());
55
        }
56

    
57
        // Field for public FAQ
58
        if(!FieldExists("glpi_config","public_faq")) {
59
                $query="ALTER TABLE `glpi_config` ADD `public_faq` ENUM( '0', '1' ) NOT NULL AFTER `auto_assign` ;";
60
                $DB->query($query) or die("0.65 add public_faq in config".$LANG["update"][90].$DB->error());
61
        }
62

    
63
        // Optimize amort_type field
64
        if(FieldExists("glpi_infocoms","amort_type")) {
65
                $query2="UPDATE `glpi_infocoms` SET `amort_type`='0' WHERE `amort_type` = '';";
66
                $DB->query($query2) or die("0.65 update amort_type='' in tracking".$LANG["update"][90].$DB->error());
67

    
68
                $query="ALTER TABLE `glpi_infocoms` CHANGE `amort_type` `amort_type` tinyint(4) NOT NULL DEFAULT '0'";
69
                $DB->query($query) or die("0.65 alter amort_type in infocoms".$LANG["update"][90].$DB->error());
70
        }
71
        if(!TableExists("glpi_display")) {
72
                $query="CREATE TABLE glpi_display (
73
                        ID int(11) NOT NULL auto_increment,
74
                           type smallint(6) NOT NULL default '0',
75
                           num smallint(6) NOT NULL default '0',
76
                           rank smallint(6) NOT NULL default '0',
77
                           PRIMARY KEY  (ID),
78
                           UNIQUE KEY `type_2` (`type`,`num`),
79
                           KEY type (type),
80
                           KEY rank (rank),
81
                           KEY num (num)
82
                                   ) TYPE=MyISAM;";
83
                $DB->query($query) or die("0.65 add glpi_display table".$LANG["update"][90].$DB->error());
84

    
85
                // TEMPORARY : ADD ITEMS TO DISPLAY TABLE : TO DEL OR TO 
86

    
87
                $query="INSERT INTO `glpi_display` VALUES (32, 1, 4, 4),
88
                        (34, 1, 6, 6),
89
                        (33, 1, 5, 5),
90
                        (31, 1, 8, 3),
91
                        (30, 1, 23, 2),
92
                        (86, 12, 3, 1),
93
                        (49, 4, 31, 1),
94
                        (50, 4, 23, 2),
95
                        (51, 4, 3, 3),
96
                        (52, 4, 4, 4),
97
                        (44, 3, 31, 1),
98
                        (38, 2, 31, 1),
99
                        (39, 2, 23, 2),
100
                        (45, 3, 23, 2),
101
                        (46, 3, 3, 3),
102
                        (63, 6, 4, 3),
103
                        (62, 6, 5, 2),
104
                        (61, 6, 23, 1),
105
                        (83, 11, 4, 2),
106
                        (82, 11, 3, 1),
107
                        (57, 5, 3, 3),
108
                        (56, 5, 23, 2),
109
                        (55, 5, 31, 1),
110
                        (29, 1, 31, 1),
111
                        (35, 1, 3, 7),
112
                        (36, 1, 19, 8),
113
                        (37, 1, 17, 9),
114
                        (40, 2, 3, 3),
115
                        (41, 2, 4, 4),
116
                        (42, 2, 11, 6),
117
                        (43, 2, 9, 7),
118
                        (47, 3, 4, 4),
119
                        (48, 3, 9, 6),
120
                        (53, 4, 9, 6),
121
                        (54, 4, 7, 7),
122
                        (58, 5, 4, 4),
123
                        (59, 5, 9, 6),
124
                        (60, 5, 7, 7),
125
                        (64, 7, 3, 1),
126
                        (65, 7, 4, 2),
127
                        (66, 7, 5, 3),
128
                        (67, 7, 6, 4),
129
                        (68, 7, 9, 5),
130
                        (69, 8, 9, 1),
131
                        (70, 8, 3, 2),
132
                        (71, 8, 4, 3),
133
                        (72, 8, 5, 4),
134
                        (73, 8, 10, 5),
135
                        (74, 8, 6, 6),
136
                        (75, 10, 4, 1),
137
                        (76, 10, 3, 2),
138
                        (77, 10, 5, 3),
139
                        (78, 10, 6, 4),
140
                        (79, 10, 7, 5),
141
                        (80, 10, 11, 6),
142
                        (84, 11, 5, 3),
143
                        (85, 11, 6, 4),
144
                        (88, 12, 6, 2),
145
                        (89, 12, 4, 3),
146
                        (90, 12, 5, 4),
147
                        (91, 13, 3, 1),
148
                        (92, 13, 4, 2),
149
                        (93, 13, 7, 3),
150
                        (94, 13, 5, 4),
151
                        (95, 13, 6, 5),
152
                        (96, 15, 3, 1),
153
                        (97, 15, 4, 2),
154
                        (98, 15, 5, 3),
155
                        (99, 15, 6, 4),
156
                        (100, 15, 7, 5),
157
                        (101, 17, 3, 1),
158
                        (102, 17, 4, 2),
159
                        (103, 17, 5, 3),
160
                        (104, 17, 6, 4),
161
                        (105, 2, 40, 5),
162
                        (106, 3, 40, 5),
163
                        (107, 4, 40, 5),
164
                        (108, 5, 40, 5),
165
                        (109, 15, 8, 6),
166
                        (110, 23, 31, 1),
167
                        (111, 23, 23, 2),
168
                        (112, 23, 3, 3),
169
                        (113, 23, 4, 4),
170
                        (114, 23, 40, 5),
171
                        (115, 23, 9, 6),
172
                        (116, 23, 7, 7);";
173

    
174
                $DB->query($query);
175
        }
176

    
177

    
178
        if(!FieldExists("glpi_config","ldap_login")) {
179
                $query="ALTER TABLE `glpi_config` ADD `ldap_login` VARCHAR( 200 ) NOT NULL DEFAULT 'uid' AFTER `ldap_condition`;";
180
                $DB->query($query) or die("0.65 add url in config".$LANG["update"][90].$DB->error());
181
        }
182

    
183
        if(!FieldExists("glpi_config","url_base")) {
184
                $query="ALTER TABLE `glpi_config` ADD `url_base` VARCHAR( 255 ) NOT NULL ;";
185
                $DB->query($query) or die("0.65 add url in config".$LANG["update"][90].$DB->error());
186

    
187
                $query="ALTER TABLE `glpi_config` ADD `url_in_mail` ENUM( '0', '1' ) NOT NULL ;";
188
                $DB->query($query) or die("0.65 add url_in_mail in config".$LANG["update"][90].$DB->error());
189

    
190
                $query="UPDATE glpi_config SET url_base='".ereg_replace("/install.php","",$_SERVER['HTTP_REFERER'])."' WHERE ID='1'";
191
                $DB->query($query) or die(" url ".$LANG["update"][90].$DB->error());
192
        }
193

    
194
        if(!FieldExists("glpi_config","text_login")) {
195
                $query="ALTER TABLE `glpi_config` ADD `text_login` TEXT NOT NULL ;";
196
                $DB->query($query) or die("0.65 add text_login in config".$LANG["update"][90].$DB->error());
197
        }
198

    
199

    
200
        if(!FieldExists("glpi_config","auto_update_check")) {
201
                $query="ALTER TABLE `glpi_config` ADD `auto_update_check` SMALLINT DEFAULT '0' NOT NULL ,
202
                        ADD `last_update_check` DATE DEFAULT '".date("Y-m-d")."' NOT NULL, ADD `founded_new_version` VARCHAR( 10 ) NOT NULL ;";
203
                $DB->query($query) or die("0.65 add auto_login_check in config".$LANG["update"][90].$DB->error());
204
        }
205

    
206
        //// Tracking 
207
        if(FieldExists("glpi_tracking","status")) {
208
                $already_done=false;
209
                if ($result = $DB->query("show fields from glpi_tracking"))
210
                        while ($data=$DB->fetch_array($result)){
211
                                if ($data["Field"]=="status"&&ereg("done",$data["Type"]))
212
                                        $already_done=true;
213
                        }
214

    
215
                if (!$already_done)        {
216
                        $query="ALTER TABLE `glpi_tracking` CHANGE `status` `status` ENUM( 'new', 'old', 'old_done', 'assign', 'plan', 'old_notdone', 'waiting' ) DEFAULT 'new' NOT NULL ;";
217
                        $DB->query($query) or die("0.65 alter status in tracking".$LANG["update"][90].$DB->error());
218

    
219
                        $query2=" UPDATE `glpi_tracking` SET status='old_done' WHERE status <> 'new';";
220
                        $DB->query($query2) or die("0.65 update status=old in tracking".$LANG["update"][90].$DB->error());        
221

    
222
                        $query3=" UPDATE `glpi_tracking` SET status='assign' WHERE status='new' AND assign <> '0';";
223
                        $DB->query($query3) or die("0.65 update status=assign in tracking".$LANG["update"][90].$DB->error());        
224

    
225
                        $query4="ALTER TABLE `glpi_tracking` CHANGE `status` `status` ENUM( 'new', 'old_done', 'assign', 'plan', 'old_notdone', 'waiting' ) DEFAULT 'new' NOT NULL ;";
226
                        $DB->query($query4) or die("0.65 alter status in tracking".$LANG["update"][90].$DB->error());
227
                }
228
        }
229

    
230
        if(!isIndex("glpi_tracking_planning","id_assign")) {
231
                $query="ALTER TABLE `glpi_tracking_planning` ADD INDEX ( `id_assign` ) ;";
232
                $DB->query($query) or die("0.65 add index for id_assign in tracking_planning".$LANG["update"][90].$DB->error());
233
        }
234
        if(FieldExists("glpi_tracking","emailupdates")) {
235
                $query2=" UPDATE `glpi_tracking` SET `emailupdates`='no' WHERE `emailupdates`='';";
236
                $DB->query($query2) or die("0.65 update emailupdate='' in tracking".$LANG["update"][90].$DB->error());
237
                $query="ALTER TABLE `glpi_tracking` CHANGE `emailupdates` `emailupdates` ENUM( 'yes', 'no' ) DEFAULT 'no' NOT NULL;";
238
                $DB->query($query) or die("0.65 alter emailupdates in tracking".$LANG["update"][90].$DB->error());
239
        }
240

    
241
        if(!FieldExists("glpi_followups","private")) {
242
                $query="ALTER TABLE `glpi_followups` ADD `private` INT( 1 ) DEFAULT '0' NOT NULL;";
243
                $DB->query($query) or die("0.65 add private in followups".$LANG["update"][90].$DB->error());
244
        }
245

    
246
        if(!FieldExists("glpi_followups","realtime")) {
247
                $query="ALTER TABLE `glpi_followups` ADD `realtime` FLOAT DEFAULT '0' NOT NULL ;";
248
                $DB->query($query) or die("0.65 add realtime in followups".$LANG["update"][90].$DB->error());
249
        }
250
        if(!FieldExists("glpi_config","mailing_attrib_attrib")) {
251
                $query="ALTER TABLE `glpi_config` ADD `mailing_attrib_attrib` tinyint(4) NOT NULL DEFAULT '1' AFTER `mailing_finish_user` ;";
252
                $DB->query($query) or die("0.65 add mailing_attrib_attrib in config".$LANG["update"][90].$DB->error());
253
        }
254

    
255

    
256

    
257
        if(!FieldExists("glpi_tracking_planning","id_followup")) {
258
                $query="ALTER TABLE `glpi_tracking_planning` ADD `id_followup` INT DEFAULT '0' NOT NULL AFTER `id_tracking` ;";
259
                $DB->query($query) or die("0.65 add id_followup in tracking_planning".$LANG["update"][90].$DB->error());
260
                $query=" ALTER TABLE `glpi_tracking_planning` ADD INDEX ( `id_followup` );";
261
                $DB->query($query) or die("0.65 add index for id_followup in tracking_planning".$LANG["update"][90].$DB->error());
262

    
263
                //// Move Planned item to followup
264
                // Get super-admin ID
265
                $suid=0;
266
                $query0="SELECT ID from glpi_users WHERE type='super-admin'";
267
                $result0=$DB->query($query0);
268
                if ($DB->numrows($result0)>0){
269
                        $suid=$DB->result($result0,0,0);
270
                }
271
                $DB->free_result($result0);
272
                $query="SELECT * FROM glpi_tracking_planning order by id_tracking";
273
                $result = $DB->query($query);
274
                $used_followups=array();
275
                if ($DB->numrows($result)>0)
276
                        while ($data=$DB->fetch_array($result)){
277
                                $found=-1;
278
                                // Is a followup existing ?
279
                                $query2="SELECT * FROM glpi_followups WHERE tracking='".$data["id_tracking"]."'";
280
                                $result2=$DB->query($query2);
281
                                if ($DB->numrows($result2)>0)
282
                                        while ($found<0&&$data2=$DB->fetch_array($result2))
283
                                                if (!in_array($data2['ID'],$used_followups)){
284
                                                        $found=$data2['ID'];
285
                                                }
286
                                $DB->free_result($result2);
287
                                // Followup not founded
288
                                if ($found<0){
289
                                        $query3="INSERT INTO glpi_followups (tracking,date,author,contents) VALUES ('".$data["id_tracking"]."','".date("Y-m-d")."','$suid','Automatic Added followup for compatibility problem in update')";
290
                                        $DB->query($query3);
291
                                        $found=$DB->insert_id();
292
                                } 
293
                                array_push($used_followups,$found);
294
                                $query4="UPDATE glpi_tracking_planning SET id_followup='$found' WHERE ID ='".$data['ID']."';";
295
                                $DB->query($query4);
296
                        }
297
                unset($used_followups);
298
                $DB->free_result($result);
299
                $query=" ALTER TABLE `glpi_tracking_planning` DROP `id_tracking` ;";
300
                $DB->query($query) or die("0.65 add index for id_followup in tracking_planning".$LANG["update"][90].$DB->error());
301
        }
302

    
303
        if(!FieldExists("glpi_config","use_ajax")) {
304
                $query="ALTER TABLE `glpi_config` ADD `dropdown_max` INT DEFAULT '100' NOT NULL ,
305
                        ADD `ajax_wildcard` CHAR( 1 ) DEFAULT '*' NOT NULL ,
306
                        ADD `use_ajax` SMALLINT DEFAULT '0' NOT NULL ,
307
                        ADD `ajax_limit_count` INT DEFAULT '50' NOT NULL ; ";
308
                $DB->query($query) or die("0.65 add ajax fields in config".$LANG["update"][90].$DB->error());
309
        }
310

    
311
        if(!FieldExists("glpi_config","ajax_autocompletion")) {
312
                $query="ALTER TABLE `glpi_config` ADD `ajax_autocompletion` SMALLINT DEFAULT '1' NOT NULL ;";
313
                $DB->query($query) or die("0.65 add ajax_autocompletion field in config".$LANG["update"][90].$DB->error());
314
        }
315

    
316
        if(!FieldExists("glpi_config","auto_add_users")) {
317
                $query="ALTER TABLE `glpi_config` ADD `auto_add_users` SMALLINT DEFAULT '1' NOT NULL ;";
318
                $DB->query($query) or die("0.65 add auto_add_users field in config".$LANG["update"][90].$DB->error());
319
        }
320

    
321
        if(!FieldExists("glpi_config","dateformat")) {
322
                $query="ALTER TABLE `glpi_config` ADD `dateformat` SMALLINT DEFAULT '0' NOT NULL ;";
323
                $DB->query($query) or die("0.65 add dateformat field in config".$LANG["update"][90].$DB->error());
324
        }
325

    
326

    
327
        if(FieldExists("glpi_software","version")) {
328
                $query=" ALTER TABLE `glpi_software` CHANGE `version` `version` VARCHAR( 200 ) NOT NULL;";
329
                $DB->query($query) or die("0.65 alter version field in software".$LANG["update"][90].$DB->error());
330
        }
331

    
332
        if(!FieldExists("glpi_config","nextprev_item")) {
333
                $query="ALTER TABLE `glpi_config` ADD `nextprev_item` VARCHAR( 200 ) DEFAULT 'name' NOT NULL ;";
334
                $DB->query($query) or die("0.65 add nextprev_item field in config".$LANG["update"][90].$DB->error());
335
        }
336

    
337
        if(!FieldExists("glpi_config","view_ID")) {
338
                $query="ALTER TABLE `glpi_config` ADD `view_ID` SMALLINT DEFAULT '0' NOT NULL ;";
339
                $DB->query($query) or die("0.65 add nextprev_item field in config".$LANG["update"][90].$DB->error());
340
        }
341

    
342
        if(FieldExists("glpi_infocoms","comments")) {
343
                $query=" ALTER TABLE `glpi_infocoms` CHANGE `comments` `comments` TEXT";
344
                $DB->query($query) or die("0.65 alter comments in glpi_infocoms".$LANG["update"][90].$DB->error());
345
        }
346

    
347
        $new_model=array("monitors","networking","peripherals","printers");
348

    
349
        foreach ($new_model as $model){
350
                if(!TableExists("glpi_dropdown_model_$model")) {
351
                        // model=type pour faciliter la gestion en post mise �jour : ya plus qu'a deleter les elements non voulu
352
                        // cela conviendra a tout le monde en fonction de l'utilisation du champ type
353

    
354
                        $query = "CREATE TABLE `glpi_dropdown_model_$model` (
355
                                `ID` int(11) NOT NULL auto_increment,
356
                                `name` varchar(255) NOT NULL default '',
357
                                PRIMARY KEY  (`ID`)
358
                                        ) TYPE=MyISAM;";
359

    
360
                        $DB->query($query) or die("0.6 add table glpi_dropdown_model_$model ".$LANG["update"][90].$DB->error());
361

    
362
                        // copie type dans model
363
                        $query="SELECT * FROM glpi_type_$model";
364
                        $result=$DB->query($query);        
365
                        if ($DB->numrows($result)>0)
366
                                while ($data=$DB->fetch_array($result)){
367
                                        $query="INSERT INTO `glpi_dropdown_model_$model` (`ID`,`name`) VALUES ('".$data['ID']."','".addslashes($data['name'])."');";
368
                                        $DB->query($query) or die("0.6 insert value in glpi_dropdown_model_$model ".$LANG["update"][90].$DB->error());                
369
                                }
370
                        $DB->free_result($result);
371
                }
372

    
373
                if (!FieldExists("glpi_$model","model")){
374
                        $query="ALTER TABLE `glpi_$model` ADD `model` INT(11) DEFAULT NULL AFTER `type` ;";
375
                        $DB->query($query) or die("0.6 add model in $model".$LANG["update"][90].$DB->error());
376

    
377
                        $query="UPDATE `glpi_$model` SET `model` = `type` ";
378
                        $DB->query($query) or die("0.6 add model in $model".$LANG["update"][90].$DB->error());
379
                }
380
        }
381

    
382
        // Update pour les cartouches compatibles : type -> model
383
        if(FieldExists("glpi_cartridges_assoc","FK_glpi_type_printer")) {
384
                $query=" ALTER TABLE `glpi_cartridges_assoc` CHANGE `FK_glpi_type_printer` `FK_glpi_dropdown_model_printers` INT( 11 ) DEFAULT '0' NOT NULL ";
385
                $DB->query($query) or die("0.65 alter FK_glpi_type_printer field in cartridges_assoc ".$LANG["update"][90].$DB->error());
386
        }
387

    
388
        if(!FieldExists("glpi_links","data")) {
389
                $query=" ALTER TABLE `glpi_links` ADD `data` TEXT NOT NULL ;";
390
                $DB->query($query) or die("0.65 create data in links ".$LANG["update"][90].$DB->error());
391
        }
392

    
393
        if(!TableExists("glpi_dropdown_auto_update")) {
394
                $query = "CREATE TABLE `glpi_dropdown_auto_update` (
395
                        `ID` int(11) NOT NULL auto_increment,
396
                        `name` varchar(255) NOT NULL default '',
397
                        PRIMARY KEY  (`ID`)
398
                                ) TYPE=MyISAM;";
399

    
400
                $DB->query($query) or die("0.65 add table glpi_dropdown_auto_update ".$LANG["update"][90].$DB->error());
401
        }
402

    
403
        if(!FieldExists("glpi_computers","auto_update")) {
404
                $query="ALTER TABLE `glpi_computers` ADD `auto_update` INT DEFAULT '0' NOT NULL AFTER `os` ;";
405
                $DB->query($query) or die("0.65 alter computers add auto_update ".$LANG["update"][90].$DB->error());        
406
        }
407

    
408
        // Update specificity of computer_device
409
        $query="SELECT glpi_computer_device.ID as ID,glpi_device_processor.specif_default as SPECIF FROM glpi_computer_device LEFT JOIN glpi_device_processor ON (glpi_computer_device.FK_device=glpi_device_processor.ID AND glpi_computer_device.device_type='".PROCESSOR_DEVICE."') WHERE glpi_computer_device.specificity =''";
410
        $result=$DB->query($query);
411
        if ($DB->numrows($result)>0)
412
                while ($data=$DB->fetch_assoc($result)){
413
                        $query2="UPDATE glpi_computer_device SET specificity='".$data["SPECIF"]."' WHERE ID = '".$data["ID"]."'";
414
                        $DB->query($query2);
415
                }
416

    
417
        $query="SELECT glpi_computer_device.ID as ID,glpi_device_processor.specif_default as SPECIF FROM glpi_computer_device LEFT JOIN glpi_device_processor ON (glpi_computer_device.FK_device=glpi_device_processor.ID AND glpi_computer_device.device_type='".PROCESSOR_DEVICE."') WHERE glpi_computer_device.specificity =''";
418
        $result=$DB->query($query);
419
        if ($DB->numrows($result)>0)
420
                while ($data=$DB->fetch_assoc($result)){
421
                        $query2="UPDATE glpi_computer_device SET specificity='".$data["SPECIF"]."' WHERE ID = '".$data["ID"]."'";
422
                        $DB->query($query2);
423
                }
424

    
425
        $query="SELECT glpi_computer_device.ID as ID,glpi_device_ram.specif_default as SPECIF FROM glpi_computer_device LEFT JOIN glpi_device_ram ON (glpi_computer_device.FK_device=glpi_device_ram.ID AND glpi_computer_device.device_type='".RAM_DEVICE."') WHERE glpi_computer_device.specificity =''";
426
        $result=$DB->query($query);
427
        if ($DB->numrows($result)>0)
428
                while ($data=$DB->fetch_assoc($result)){
429
                        $query2="UPDATE glpi_computer_device SET specificity='".$data["SPECIF"]."' WHERE ID = '".$data["ID"]."'";
430
                        $DB->query($query2);
431
                }
432

    
433
        $query="SELECT glpi_computer_device.ID as ID,glpi_device_hdd.specif_default as SPECIF FROM glpi_computer_device LEFT JOIN glpi_device_hdd ON (glpi_computer_device.FK_device=glpi_device_hdd.ID AND glpi_computer_device.device_type='".HDD_DEVICE."') WHERE glpi_computer_device.specificity =''";
434
        $result=$DB->query($query);
435
        if ($DB->numrows($result)>0)
436
                while ($data=$DB->fetch_assoc($result)){
437
                        $query2="UPDATE glpi_computer_device SET specificity='".$data["SPECIF"]."' WHERE ID = '".$data["ID"]."'";
438
                        $DB->query($query2);
439
                }
440

    
441
        $query="SELECT glpi_computer_device.ID as ID,glpi_device_iface.specif_default as SPECIF FROM glpi_computer_device LEFT JOIN glpi_device_iface ON (glpi_computer_device.FK_device=glpi_device_iface.ID AND glpi_computer_device.device_type='".NETWORK_DEVICE."') WHERE glpi_computer_device.specificity =''";
442
        $result=$DB->query($query);
443
        if ($DB->numrows($result)>0)
444
                while ($data=$DB->fetch_assoc($result)){
445
                        $query2="UPDATE glpi_computer_device SET specificity='".$data["SPECIF"]."' WHERE ID = '".$data["ID"]."'";
446
                        $DB->query($query2);
447
                }
448

    
449
        // add field notes in tables
450
        $new_notes=array("computers","software","monitors","networking","peripherals","printers","cartridges_type","consumables_type","contacts","enterprises","contracts","docs");
451

    
452
        foreach ($new_notes as $notes)
453
                if(!FieldExists("glpi_$notes","notes")) {        
454
                        $query="ALTER TABLE `glpi_$notes` ADD   `notes` LONGTEXT NULL ;";
455
                        $DB->query($query) or die("0.65 add notes field in table".$LANG["update"][90].$DB->error());
456

    
457
                }
458

    
459
        if(!FieldExists("glpi_users","active")) {        
460
                $query="ALTER TABLE `glpi_users` ADD `active` INT( 2 ) DEFAULT '1' NOT NULL ";
461
                $DB->query($query) or die("0.65 add active in users ".$LANG["update"][90].$DB->error());
462
        }
463

    
464

    
465
        if(TableExists("glpi_type_docs")){
466
                $query="SELECT * from glpi_type_docs WHERE ext='odt' OR ext='ods' OR ext='odp' OR ext='otp' OR ext='ott' OR ext='ots' OR ext='odf' OR ext='odg' OR ext='otg' OR ext='odb' OR ext='oth' OR ext='odm' OR ext='odc' OR ext='odi'";
467
                $result=$DB->query($query);
468
                if ($DB->numrows($result)==0){
469
                        $query2="INSERT INTO `glpi_type_docs` ( `name` , `ext` , `icon` , `mime` , `upload` , `date_mod` ) VALUES ('Oasis Open Office Writer', 'odt', 'odt-dist.png', '', 'Y', '2006-01-21 17:41:13'),
470
                                ( 'Oasis Open Office Calc', 'ods', 'ods-dist.png', '', 'Y', '2006-01-21 17:41:31'),
471
                                ('Oasis Open Office Impress', 'odp', 'odp-dist.png', '', 'Y', '2006-01-21 17:42:54'),
472
                                ('Oasis Open Office Impress Template', 'otp', 'odp-dist.png', '', 'Y', '2006-01-21 17:43:58'),
473
                                ('Oasis Open Office Writer Template', 'ott', 'odt-dist.png', '', 'Y', '2006-01-21 17:44:41'),
474
                                ('Oasis Open Office Calc Template', 'ots', 'ods-dist.png', '', 'Y', '2006-01-21 17:45:30'),
475
                                ('Oasis Open Office Math', 'odf', 'odf-dist.png', '', 'Y', '2006-01-21 17:48:05'),
476
                                ('Oasis Open Office Draw', 'odg', 'odg-dist.png', '', 'Y', '2006-01-21 17:48:31'),
477
                                ('Oasis Open Office Draw Template', 'otg', 'odg-dist.png', '', 'Y', '2006-01-21 17:49:46'),
478
                                ('Oasis Open Office Base', 'odb', 'odb-dist.png', '', 'Y', '2006-01-21 18:03:34'),
479
                                ('Oasis Open Office HTML', 'oth', 'oth-dist.png', '', 'Y', '2006-01-21 18:05:27'),
480
                                ('Oasis Open Office Writer Master', 'odm', 'odm-dist.png', '', 'Y', '2006-01-21 18:06:34'),
481
                                ('Oasis Open Office Chart', 'odc', NULL, '', 'Y', '2006-01-21 18:07:48'),
482
                                ('Oasis Open Office Image', 'odi', NULL, '', 'Y', '2006-01-21 18:08:18');";
483
                        $DB->query($query2) or die("0.65 add new type docs ".$LANG["update"][90].$DB->error());
484
                }
485
        }
486

    
487

    
488

    
489
        ///// BEGIN  MySQL Compatibility
490
        if(FieldExists("glpi_infocoms","warranty_value")) {        
491
                $query2=" UPDATE `glpi_infocoms` SET `warranty_value`='0' WHERE `warranty_value` IS NULL;";
492
                $DB->query($query2) or die("0.65 update warranty_value='' in tracking".$LANG["update"][90].$DB->error());
493

    
494
                $query="ALTER TABLE `glpi_infocoms` CHANGE `warranty_info` `warranty_info` VARCHAR( 255 ) NULL DEFAULT NULL,
495
                        CHANGE `warranty_value` `warranty_value` FLOAT NOT NULL DEFAULT '0',
496
                        CHANGE `num_commande` `num_commande` VARCHAR( 200 ) NULL DEFAULT NULL,
497
                        CHANGE `bon_livraison` `bon_livraison` VARCHAR( 200 ) NULL DEFAULT NULL,
498
                        CHANGE `facture` `facture` VARCHAR( 200 ) NULL DEFAULT NULL,
499
                        CHANGE `num_immo` `num_immo` VARCHAR( 200 ) NULL DEFAULT NULL;";
500
                $DB->query($query) or die("0.65 alter various fields in infocoms ".$LANG["update"][90].$DB->error());
501
        }
502

    
503
        if(FieldExists("glpi_reservation_item","comments")) {        
504
                $query="ALTER TABLE `glpi_reservation_item` CHANGE `comments` `comments` TEXT NULL ";
505
                $DB->query($query) or die("0.65 alter comments in glpi_reservation_item ".$LANG["update"][90].$DB->error());
506
        }
507

    
508

    
509
        if(FieldExists("glpi_cartridges_type","comments")) {        
510
                $query="ALTER TABLE `glpi_cartridges_type` CHANGE `name` `name` VARCHAR( 255 ) NULL DEFAULT NULL,
511
                        CHANGE `ref` `ref` VARCHAR( 255 ) NULL DEFAULT NULL ,
512
                        CHANGE `comments` `comments` TEXT NULL DEFAULT NULL ";
513
                $DB->query($query) or die("0.65 alter various fields in cartridges_type ".$LANG["update"][90].$DB->error());
514
        }
515

    
516
        if(FieldExists("glpi_computer_device","specificity")) {        
517
                $query="ALTER TABLE `glpi_computer_device` CHANGE `specificity` `specificity` VARCHAR( 250 ) NULL ";
518
                $DB->query($query) or die("0.65 alter specificity in glpi_computer_device ".$LANG["update"][90].$DB->error());
519
        }
520

    
521
        $inv_table=array("computers","monitors","networking","peripherals","printers");
522

    
523
        foreach ($inv_table as $table)
524
                if(FieldExists("glpi_$table","comments")) {        
525
                        $query="UPDATE glpi_$table SET location='0' WHERE location IS NULL;";
526
                        $DB->query($query) or die("0.65 prepare data fro alter various fields in $table ".$LANG["update"][90].$DB->error());
527
                        $query="ALTER TABLE `glpi_$table` CHANGE `name` `name` VARCHAR( 200 ) NULL ,
528
                                CHANGE `serial` `serial` VARCHAR( 200 ) NULL ,
529
                                CHANGE `otherserial` `otherserial` VARCHAR( 200 ) NULL ,
530
                                CHANGE `contact` `contact` VARCHAR( 200 ) NULL ,
531
                                CHANGE `contact_num` `contact_num` VARCHAR( 200 ) NULL ,
532
                                CHANGE `location` `location` INT( 11 ) NOT NULL DEFAULT '0',
533
                                CHANGE `comments` `comments` TEXT NULL ";
534
                        $DB->query($query) or die("0.65 alter various fields in $table ".$LANG["update"][90].$DB->error());
535
                }
536

    
537
        if(FieldExists("glpi_computers","os")) {        
538
                $query="UPDATE glpi_computers SET model='0' WHERE model IS NULL;";
539
                $DB->query($query) or die("0.65 prepare model for alter computers ".$LANG["update"][90].$DB->error());
540
                $query="UPDATE glpi_computers SET type='0' WHERE type IS NULL;";
541
                $DB->query($query) or die("0.65 prepare type for alter computers ".$LANG["update"][90].$DB->error());
542

    
543
                $query="ALTER TABLE `glpi_computers` CHANGE `os` `os` INT( 11 ) NOT NULL DEFAULT '0',
544
                        CHANGE `model` `model` INT( 11 ) NOT NULL DEFAULT '0',
545
                        CHANGE `type` `type` INT( 11 ) NOT NULL DEFAULT '0'";
546
                $DB->query($query) or die("0.65 alter various fields in computers ".$LANG["update"][90].$DB->error());
547

    
548
        }
549
        if(FieldExists("glpi_networking","ram")) {        
550
                $query="ALTER TABLE `glpi_networking` CHANGE `ram` `ram` VARCHAR( 200 ) NULL ,
551
                        CHANGE `ifmac` `ifmac` VARCHAR( 200 ) NULL ,
552
                        CHANGE `ifaddr` `ifaddr` VARCHAR( 200 ) NULL";
553
                $DB->query($query) or die("0.65 alter 2 various fields in networking ".$LANG["update"][90].$DB->error());
554
        }
555

    
556
        if(FieldExists("glpi_peripherals","brand")) {        
557
                $query="ALTER TABLE `glpi_peripherals` CHANGE `brand` `brand` VARCHAR( 200 ) NULL ";
558
                $DB->query($query) or die("0.65 alter 2 various fields in peripherals ".$LANG["update"][90].$DB->error());
559
        }
560

    
561
        if(FieldExists("glpi_printers","ramSize")) {        
562
                $query="ALTER TABLE `glpi_printers` CHANGE `ramSize` `ramSize` VARCHAR( 200 ) NULL ";
563
                $DB->query($query) or die("0.65 alter 2 various fields in printers ".$LANG["update"][90].$DB->error());
564
        }
565
        if(FieldExists("glpi_consumables_type","comments")) {        
566
                $query="ALTER TABLE `glpi_consumables_type` CHANGE `name` `name` VARCHAR( 255 ) NULL ,
567
                        CHANGE `ref` `ref` VARCHAR( 255 ) NULL ,
568
                        CHANGE `comments` `comments` TEXT NULL  ";
569
                $DB->query($query) or die("0.65 alter various fields in consumables_type ".$LANG["update"][90].$DB->error());
570
        }
571

    
572
        if(FieldExists("glpi_contacts","comments")) {        
573
                $query="ALTER TABLE `glpi_contacts` CHANGE `name` `name` VARCHAR( 255 ) NULL ,
574
                        CHANGE `phone` `phone` VARCHAR( 200 ) NULL ,
575
                        CHANGE `phone2` `phone2` VARCHAR( 200 ) NULL ,
576
                        CHANGE `fax` `fax` VARCHAR( 200 ) NULL ,
577
                        CHANGE `email` `email` VARCHAR( 255 ) NULL ,
578
                        CHANGE `comments` `comments` TEXT NULL  ";
579
                $DB->query($query) or die("0.65 alter various fields in contacts ".$LANG["update"][90].$DB->error());
580
        }
581

    
582

    
583
        if(FieldExists("glpi_contracts","comments")) {        
584
                $query="ALTER TABLE `glpi_contracts` CHANGE `name` `name` VARCHAR( 255 ) NULL ,
585
                        CHANGE `num` `num` VARCHAR( 255 ) NULL ,
586
                        CHANGE `comments` `comments` TEXT NULL ,
587
                        CHANGE `compta_num` `compta_num` VARCHAR( 255 ) NULL ";
588
                $DB->query($query) or die("0.65 alter various fields in contracts ".$LANG["update"][90].$DB->error());
589
        }
590

    
591
        $device=array("case","control","drive","gfxcard","hdd","iface","moboard","pci","power","processor","ram","sndcard");
592

    
593
        foreach ($device as $dev){
594
                if(FieldExists("glpi_device_$dev","comment")) {        
595
                        $query="ALTER TABLE `glpi_device_$dev` CHANGE `designation` `designation` VARCHAR( 255 ) NULL ,
596
                                CHANGE `comment` `comment` TEXT NULL ,
597
                                CHANGE `specif_default` `specif_default` VARCHAR( 250 ) NULL ";
598
                        $DB->query($query) or die("0.65 alter various fields in device_$dev ".$LANG["update"][90].$DB->error());
599
                }
600
                if(!isIndex("glpi_device_$dev","designation")) {        
601
                        $query="ALTER TABLE `glpi_device_$dev` ADD INDEX ( `designation` ); ";
602
                        $DB->query($query) or die("0.65 alter various fields in device_$dev ".$LANG["update"][90].$DB->error());
603
                }
604
        }
605

    
606
        if(FieldExists("glpi_docs","comment")) {        
607
                $query="ALTER TABLE `glpi_docs` CHANGE `name` `name` VARCHAR( 255 ) NULL ,
608
                        CHANGE `filename` `filename` VARCHAR( 255 ) NULL ,
609
                        CHANGE `mime` `mime` VARCHAR( 30 ) NULL ,
610
                        CHANGE `comment` `comment` TEXT NULL ,
611
                        CHANGE `link` `link` VARCHAR( 255 ) NULL  ";
612
                $DB->query($query) or die("0.65 alter various fields in docs ".$LANG["update"][90].$DB->error());
613
        }
614

    
615
        if(FieldExists("glpi_enterprises","comments")) {        
616
                $query="ALTER TABLE `glpi_enterprises` CHANGE `name` `name` VARCHAR( 200 ) NULL ,
617
                        CHANGE `address` `address` TEXT NULL ,
618
                        CHANGE `website` `website` VARCHAR( 200 ) NULL ,
619
                        CHANGE `phonenumber` `phonenumber` VARCHAR( 200 ) NULL ,
620
                        CHANGE `comments` `comments` TEXT NULL ,
621
                        CHANGE `fax` `fax` VARCHAR( 255 ) NULL ,
622
                        CHANGE `email` `email` VARCHAR( 255 ) NULL  ";
623
                $DB->query($query) or die("0.65 alter various fields in enterprises ".$LANG["update"][90].$DB->error());
624
        }
625

    
626
        if(FieldExists("glpi_event_log","message")) {        
627
                $query="ALTER TABLE `glpi_event_log` CHANGE `itemtype` `itemtype` VARCHAR( 200 ) NULL ,
628
                        CHANGE `service` `service` VARCHAR( 200 ) NULL ,
629
                        CHANGE `message` `message` TEXT NULL   ";
630
                $DB->query($query) or die("0.65 alter various fields in event_log ".$LANG["update"][90].$DB->error());
631
        }
632

    
633
        if(FieldExists("glpi_kbitems","question")) {        
634
                $query="ALTER TABLE `glpi_kbitems` CHANGE `question` `question` TEXT NULL ,
635
                        CHANGE `answer` `answer` TEXT NULL ";
636
                $DB->query($query) or die("0.65 alter various fields in kbitems ".$LANG["update"][90].$DB->error());
637
        }
638

    
639
        if(FieldExists("glpi_licenses","serial")) {        
640
                $query="ALTER TABLE `glpi_licenses` CHANGE `serial` `serial` VARCHAR( 255 ) NULL";
641
                $DB->query($query) or die("0.65 alter serial in licenses ".$LANG["update"][90].$DB->error());
642
        }
643

    
644
        if(FieldExists("glpi_links","data")) {        
645
                $query="ALTER TABLE `glpi_links` CHANGE `name` `name` VARCHAR( 255 ) NULL ,
646
                        CHANGE `data` `data` TEXT NULL";
647
                $DB->query($query) or die("0.65 alter various fields in links ".$LANG["update"][90].$DB->error());
648
        }
649

    
650

    
651
        if(FieldExists("glpi_networking_ports","ifmac")) {        
652
                $query="ALTER TABLE `glpi_networking_ports` CHANGE `name` `name` CHAR( 200 ) NULL ,
653
                        CHANGE `ifaddr` `ifaddr` CHAR( 200 ) NULL ,
654
                        CHANGE `ifmac` `ifmac` CHAR( 200 ) NULL";
655
                $DB->query($query) or die("0.65 alter various fields in networking_ports ".$LANG["update"][90].$DB->error());
656
        }
657

    
658
        if(FieldExists("glpi_reservation_resa","comment")) {        
659
                $query="ALTER TABLE `glpi_reservation_resa` CHANGE `comment` `comment` TEXT NULL";
660
                $DB->query($query) or die("0.65 alter comment in reservation_resa ".$LANG["update"][90].$DB->error());
661
        } 
662

    
663
        if(FieldExists("glpi_software","version")) {        
664
                $query="ALTER TABLE `glpi_software` CHANGE `name` `name` VARCHAR( 200 ) NULL ,
665
                        CHANGE `version` `version` VARCHAR( 200 ) NULL ";
666
                $DB->query($query) or die("0.65 alter various fields in software ".$LANG["update"][90].$DB->error());
667
        } 
668

    
669
        if(FieldExists("glpi_type_docs","name")) {        
670
                $query="ALTER TABLE `glpi_type_docs` CHANGE `name` `name` VARCHAR( 255 ) NULL ,
671
                        CHANGE `ext` `ext` VARCHAR( 10 ) NULL ,
672
                        CHANGE `icon` `icon` VARCHAR( 255 ) NULL ,
673
                        CHANGE `mime` `mime` VARCHAR( 100 ) NULL ";
674
                $DB->query($query) or die("0.65 alter various fields in type_docs ".$LANG["update"][90].$DB->error());
675
        } 
676

    
677
        if(FieldExists("glpi_users","language")) {        
678
                $query="ALTER TABLE `glpi_users` CHANGE `name` `name` VARCHAR( 80 ) NULL ,
679
                        CHANGE `password` `password` VARCHAR( 80 ) NULL ,
680
                        CHANGE `password_md5` `password_md5` VARCHAR( 80 ) NULL ,
681
                        CHANGE `email` `email` VARCHAR( 200 ) NULL ,
682
                        CHANGE `realname` `realname` VARCHAR( 255 ) NULL ,
683
                        CHANGE `language` `language` VARCHAR( 255 ) NULL  ";
684
                $DB->query($query) or die("0.65 alter various fields in users ".$LANG["update"][90].$DB->error());
685
        } 
686

    
687
        if(FieldExists("glpi_config","cut")) {        
688
                $query="ALTER TABLE `glpi_config` CHANGE `num_of_events` `num_of_events` VARCHAR( 200 ) NULL ,
689
                        CHANGE `jobs_at_login` `jobs_at_login` VARCHAR( 200 ) NULL ,
690
                        CHANGE `sendexpire` `sendexpire` VARCHAR( 200 ) NULL ,
691
                        CHANGE `cut` `cut` VARCHAR( 200 ) NULL ,
692
                        CHANGE `expire_events` `expire_events` VARCHAR( 200 ) NULL ,
693
                        CHANGE `list_limit` `list_limit` VARCHAR( 200 ) NULL ,
694
                        CHANGE `version` `version` VARCHAR( 200 ) NULL ,
695
                        CHANGE `logotxt` `logotxt` VARCHAR( 200 ) NULL ,
696
                        CHANGE `root_doc` `root_doc` VARCHAR( 200 ) NULL ,
697
                        CHANGE `event_loglevel` `event_loglevel` VARCHAR( 200 ) NULL ,
698
                        CHANGE `mailing` `mailing` VARCHAR( 200 ) NULL ,
699
                        CHANGE `imap_auth_server` `imap_auth_server` VARCHAR( 200 ) NULL ,
700
                        CHANGE `imap_host` `imap_host` VARCHAR( 200 ) NULL ,
701
                        CHANGE `ldap_host` `ldap_host` VARCHAR( 200 ) NULL ,
702
                        CHANGE `ldap_basedn` `ldap_basedn` VARCHAR( 200 ) NULL ,
703
                        CHANGE `ldap_rootdn` `ldap_rootdn` VARCHAR( 200 ) NULL ,
704
                        CHANGE `ldap_pass` `ldap_pass` VARCHAR( 200 ) NULL ,
705
                        CHANGE `admin_email` `admin_email` VARCHAR( 200 ) NULL ,
706
                        CHANGE `mailing_signature` `mailing_signature` VARCHAR( 200 ) NOT NULL DEFAULT '--' ,
707
                        CHANGE `mailing_new_admin` `mailing_new_admin` tinyint(4) NOT NULL DEFAULT '1' ,
708
                        CHANGE `mailing_followup_admin` `mailing_followup_admin` tinyint(4) NOT NULL DEFAULT '1' ,
709
                        CHANGE `mailing_finish_admin` `mailing_finish_admin` tinyint(4) NOT NULL DEFAULT '1' ,
710
                        CHANGE `mailing_new_all_admin` `mailing_new_all_admin` tinyint(4) NOT NULL DEFAULT '0' ,
711
                        CHANGE `mailing_followup_all_admin` `mailing_followup_all_admin` tinyint(4) NOT NULL DEFAULT '0' ,
712
                        CHANGE `mailing_finish_all_admin` `mailing_finish_all_admin` tinyint(4) NOT NULL DEFAULT '0' ,
713
                        CHANGE `mailing_new_all_normal` `mailing_new_all_normal` tinyint(4) NOT NULL DEFAULT '0' ,
714
                        CHANGE `mailing_followup_all_normal` `mailing_followup_all_normal` tinyint(4) NOT NULL DEFAULT '0' ,
715
                        CHANGE `mailing_finish_all_normal` `mailing_finish_all_normal` tinyint(4) NOT NULL DEFAULT '0' ,
716
                        CHANGE `mailing_new_attrib` `mailing_new_attrib` tinyint(4) NOT NULL DEFAULT '1' ,
717
                        CHANGE `mailing_followup_attrib` `mailing_followup_attrib` tinyint(4) NOT NULL DEFAULT '1' ,
718
                        CHANGE `mailing_finish_attrib` `mailing_finish_attrib` tinyint(4) NOT NULL DEFAULT '1' ,
719
                        CHANGE `mailing_new_user` `mailing_new_user` tinyint(4) NOT NULL DEFAULT '1' ,
720
                        CHANGE `mailing_followup_user` `mailing_followup_user` tinyint(4) NOT NULL DEFAULT '1' ,
721
                        CHANGE `mailing_finish_user` `mailing_finish_user` tinyint(4) NOT NULL DEFAULT '1' ,
722
                        CHANGE `mailing_resa_all_admin` `mailing_resa_all_admin` tinyint(4) NOT NULL DEFAULT '0' ,
723
                        CHANGE `mailing_resa_user` `mailing_resa_user` tinyint(4) NOT NULL DEFAULT '1' ,
724
                        CHANGE `mailing_resa_admin` `mailing_resa_admin` tinyint(4) NOT NULL DEFAULT '1' ,
725
                        CHANGE `ldap_field_name` `ldap_field_name` VARCHAR( 200 ) NULL ,
726
                        CHANGE `ldap_field_email` `ldap_field_email` VARCHAR( 200 ) NULL ,
727
                        CHANGE `ldap_field_location` `ldap_field_location` VARCHAR( 200 ) NULL ,
728
                        CHANGE `ldap_field_realname` `ldap_field_realname` VARCHAR( 200 ) NULL ,
729
                        CHANGE `ldap_field_phone` `ldap_field_phone` VARCHAR( 200 ) NULL ,
730
                        CHANGE `ldap_condition` `ldap_condition` VARCHAR( 255 ) NULL ,
731
                        CHANGE `permit_helpdesk` `permit_helpdesk` VARCHAR( 200 ) NULL ,
732
                        CHANGE `cas_host` `cas_host` VARCHAR( 255 ) NULL ,
733
                        CHANGE `cas_port` `cas_port` VARCHAR( 255 ) NULL ,
734
                        CHANGE `cas_uri` `cas_uri` VARCHAR( 255 ) NULL ,
735
                        CHANGE `url_base` `url_base` VARCHAR( 255 ) NULL ,
736
                        CHANGE `text_login` `text_login` TEXT NULL ,
737
                        CHANGE `founded_new_version` `founded_new_version` VARCHAR( 10 ) NULL ";
738
                $DB->query($query) or die("0.65 alter various fields in config ".$LANG["update"][90].$DB->error());
739
        } 
740
        ///// END  MySQL Compatibility
741

    
742

    
743
        if(!FieldExists("glpi_config","dropdown_limit")) {        
744
                $query="ALTER TABLE `glpi_config` ADD `dropdown_limit` INT( 11 ) DEFAULT '50' NOT NULL ";
745
                $DB->query($query) or die("0.65 add dropdown_limit in config ".$LANG["update"][90].$DB->error());
746
        }
747

    
748

    
749
        if(FieldExists("glpi_consumables_type","type")) {        
750
                $query="ALTER TABLE `glpi_consumables_type` CHANGE `type` `type` INT( 11 ) NOT NULL DEFAULT '0',
751
                        CHANGE `alarm` `alarm` INT( 11 ) NOT NULL DEFAULT '10'";
752
                $DB->query($query) or die("0.65 alter type and alarm in consumables_type ".$LANG["update"][90].$DB->error());
753
        }
754

    
755

    
756
        if(!FieldExists("glpi_config","post_only_followup")) {        
757
                $query="ALTER TABLE `glpi_config` ADD `post_only_followup` tinyint( 4 ) DEFAULT '1' NOT NULL ";
758
                $DB->query($query) or die("0.65 add dropdown_limit in config ".$LANG["update"][90].$DB->error());
759
        }
760

    
761
        if(!FieldExists("glpi_monitors","flags_dvi")) {        
762
                $query="ALTER TABLE `glpi_monitors` ADD `flags_dvi` tinyint( 4 ) DEFAULT '0' NOT NULL AFTER `flags_bnc`";
763
                $DB->query($query) or die("0.65 add dropdown_limit in config ".$LANG["update"][90].$DB->error());
764
        }
765

    
766
        if(!TableExists("glpi_history")) {
767
                $query="CREATE TABLE `glpi_history` (
768
                        `ID` int(11) NOT NULL auto_increment,
769
                        `FK_glpi_device` int(11) NOT NULL default '0',
770
                        `device_type` tinyint(4) NOT NULL default '0',
771
                        `device_internal_type` int(11) default '0',
772
                        `device_internal_action` tinyint(4) default '0',
773
                        `user_name` varchar(200) default NULL,
774
                        `date_mod` datetime default NULL,
775
                        `id_search_option` int(11) NOT NULL default '0',
776
                        `old_value` varchar(255) default NULL,
777
                        `new_value` varchar(255) default NULL,
778
                        PRIMARY KEY  (`ID`),
779
                        KEY `FK_glpi_device` (`FK_glpi_device`)
780
                                ) TYPE=MyISAM;";
781

    
782
                $DB->query($query) or die("0.65 add glpi_history table".$LANG["update"][90].$DB->error());
783
        }
784

    
785
        if(FieldExists("glpi_tracking","assign_type")) {        
786

    
787
                $query="ALTER TABLE `glpi_tracking` ADD `assign_ent` INT NOT NULL DEFAULT '0' AFTER `assign` ";
788
                $DB->query($query) or die("0.65 add assign_ent in tracking ".$LANG["update"][90].$DB->error());
789

    
790
                $query="UPDATE `glpi_tracking` SET assign_ent=assign WHERE assign_type='".ENTERPRISE_TYPE."'";
791
                $DB->query($query) or die("0.65 update assign_ent in tracking ".$LANG["update"][90].$DB->error());
792

    
793
                $query="UPDATE `glpi_tracking` SET assign=0 WHERE assign_type='".ENTERPRISE_TYPE."'";
794
                $DB->query($query) or die("0.65 update assign_ent in tracking ".$LANG["update"][90].$DB->error());
795

    
796
                $query="ALTER TABLE `glpi_tracking` DROP `assign_type`";
797
                $DB->query($query) or die("0.65 drop assign_type in tracking ".$LANG["update"][90].$DB->error());
798

    
799

    
800

    
801
        }
802

    
803
        if(!FieldExists("glpi_config","mailing_update_admin")) {
804
                $query="ALTER TABLE `glpi_config` ADD `mailing_update_admin` tinyint(4) NOT NULL DEFAULT '1' AFTER `mailing_new_admin` ;";
805
                $DB->query($query) or die("0.65 add mailing_update_admin in config".$LANG["update"][90].$DB->error());
806
        }
807
        if(!FieldExists("glpi_config","mailing_update_all_admin")) {
808
                $query="ALTER TABLE `glpi_config` ADD `mailing_update_all_admin` tinyint(4) NOT NULL DEFAULT '0' AFTER `mailing_new_all_admin` ;";
809
                $DB->query($query) or die("0.65 add mailing_update_all_admin in config".$LANG["update"][90].$DB->error());
810
        }
811
        if(!FieldExists("glpi_config","mailing_update_all_normal")) {
812
                $query="ALTER TABLE `glpi_config` ADD `mailing_update_all_normal` tinyint(4) NOT NULL DEFAULT '0' AFTER `mailing_new_all_normal` ;";
813
                $DB->query($query) or die("0.65 add mailing_update_all_normal in config".$LANG["update"][90].$DB->error());
814
        }
815
        if(!FieldExists("glpi_config","mailing_update_attrib")) {
816
                $query="ALTER TABLE `glpi_config` ADD `mailing_update_attrib` tinyint(4) NOT NULL DEFAULT '1' AFTER `mailing_new_attrib` ;";
817
                $DB->query($query) or die("0.65 add mailing_update_attrib in config".$LANG["update"][90].$DB->error());
818
        }
819
        if(!FieldExists("glpi_config","mailing_update_user")) {
820
                $query="ALTER TABLE `glpi_config` ADD `mailing_update_user` tinyint(4) NOT NULL DEFAULT '1' AFTER `mailing_new_user` ;";
821
                $DB->query($query) or die("0.65 add mailing_update_user in config".$LANG["update"][90].$DB->error());
822
        }
823

    
824
        if(!FieldExists("glpi_config","ldap_use_tls")) {
825
                $query="ALTER TABLE `glpi_config` ADD `ldap_use_tls` VARCHAR( 200 ) NOT NULL DEFAULT '0' AFTER `ldap_login` ";
826
                $DB->query($query) or die("0.65 add ldap_use_tls in config".$LANG["update"][90].$DB->error());
827
        }
828

    
829
        if(FieldExists("glpi_config","cut")) { // juste pour affichage identique sur toutes les versions.
830
                $query="UPDATE `glpi_config` SET `cut` = '255' WHERE `ID` =1";
831
                $DB->query($query) or die("0.65 update Cut in config".$LANG["update"][90].$DB->error());
832
        }
833

    
834
        if(!FieldExists("glpi_licenses","comments")) {
835
                $query="ALTER TABLE `glpi_licenses` ADD `comments` TEXT NULL ";
836
                $DB->query($query) or die("0.65 add comments in licenses".$LANG["update"][90].$DB->error());
837
        }
838

    
839
        ///////////// MODE OCS
840

    
841
        // Delete plugin table
842
        if(TableExists("glpi_ocs_link")&&!FieldExists("glpi_ocs_link","import_device")) {
843
                $query = "DROP TABLE `glpi_ocs_link`";
844
                $DB->query($query) or die("0.65 MODE OCS drop plugin ocs_link ".$LANG["update"][90].$DB->error());
845
        }
846

    
847
        if(TableExists("glpi_ocs_config")&&!FieldExists("glpi_ocs_config","checksum")) {
848
                $query = "DROP TABLE `glpi_ocs_config`";
849
                $DB->query($query) or die("0.65 MODE OCS drop plugin ocs_config ".$LANG["update"][90].$DB->error());
850
        }
851

    
852
        if(!TableExists("glpi_ocs_link")) {
853
                $query = "CREATE TABLE `glpi_ocs_link` (
854
                        `ID` int(11) NOT NULL auto_increment,
855
                        `glpi_id` int(11) NOT NULL default '0',
856
                        `ocs_id` varchar(255) NOT NULL default '',
857
                        `auto_update` int(2) NOT NULL default '1',
858
                        `last_update` datetime NOT NULL default '0000-00-00 00:00:00',
859
                        `computer_update` LONGTEXT NULL,
860
                        `import_device` LONGTEXT NULL,
861
                        `import_software` LONGTEXT NULL,
862
                        `import_monitor` LONGTEXT NULL,
863
                        `import_peripheral` LONGTEXT NULL,
864
                        `import_printers` LONGTEXT NULL,
865
                        PRIMARY KEY  (`ID`),
866
                        UNIQUE KEY `ocs_id_2` (`ocs_id`),
867
                        KEY `ocs_id` (`ocs_id`),
868
                        KEY `glpi_id` (`glpi_id`),
869
                        KEY `auto_update` (`auto_update`),
870
                        KEY `last_update` (`last_update`)
871
                                ) TYPE=MyISAM";
872
                $DB->query($query) or die("0.65 MODE OCS creation ocs_link ".$LANG["update"][90].$DB->error());
873
        }
874

    
875
        if(!TableExists("glpi_ocs_config")) {
876
                $query = "CREATE TABLE `glpi_ocs_config` (
877
                        `ID` int(11) NOT NULL auto_increment,
878
                        `ocs_db_user` varchar(255) NOT NULL default '',
879
                        `ocs_db_passwd` varchar(255) NOT NULL default '',
880
                        `ocs_db_host` varchar(255) NOT NULL default '',
881
                        `ocs_db_name` varchar(255) NOT NULL default '',
882
                        `checksum` int(11) NOT NULL default '0',
883
                        `import_periph` int(2) NOT NULL default '0',
884
                        `import_monitor` int(2) NOT NULL default '0',
885
                        `import_software` int(2) NOT NULL default '0',
886
                        `import_printer` int(2) NOT NULL default '0',
887
                        `import_general_os` int(2) NOT NULL default '0',
888
                        `import_general_serial` int(2) NOT NULL default '0',
889
                        `import_general_model` int(2) NOT NULL default '0',
890
                        `import_general_enterprise` int(2) NOT NULL default '0',
891
                        `import_general_type` int(2) NOT NULL default '0',
892
                        `import_general_domain` int(2) NOT NULL default '0',
893
                        `import_general_contact` int(2) NOT NULL default '0',
894
                        `import_general_comments` int(2) NOT NULL default '0',
895
                        `import_device_processor` int(2) NOT NULL default '0',
896
                        `import_device_memory` int(2) NOT NULL default '0',
897
                        `import_device_hdd` int(2) NOT NULL default '0',
898
                        `import_device_iface` int(2) NOT NULL default '0',
899
                        `import_device_gfxcard` int(2) NOT NULL default '0',
900
                        `import_device_sound` int(2) NOT NULL default '0',
901
                        `import_device_drives` int(2) NOT NULL default '0',
902
                        `import_device_ports` int(2) NOT NULL default '0',
903
                        `import_device_modems` int(2) NOT NULL default '0',
904
                        `import_ip` int(2) NOT NULL default '0',
905
                        `default_state` int(11) NOT NULL default '0',
906
                        `tag_limit` varchar(255) NOT NULL default '',
907
                        PRIMARY KEY  (`ID`)
908
                                ) TYPE=MyISAM";
909

    
910
                $DB->query($query) or die("0.65 MODE OCS creation ocs_config ".$LANG["update"][90].$DB->error());
911
                $query = "INSERT INTO `glpi_ocs_config` VALUES (1, 'ocs', 'ocs', 'localhost', 'ocsweb', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '');";
912
                $DB->query($query) or die("0.65 MODE OCS add default config ".$LANG["update"][90].$DB->error());
913

    
914
        }
915

    
916
        if(!FieldExists("glpi_computers","ocs_import")) {
917
                $query = "ALTER TABLE `glpi_computers` ADD `ocs_import` TINYINT NOT NULL DEFAULT '0'";
918
                $DB->query($query) or die("0.65 MODE OCS add default config ".$LANG["update"][90].$DB->error());
919
        }
920

    
921
        if(!FieldExists("glpi_config","ocs_mode")) {
922
                $query = "ALTER TABLE `glpi_config` ADD `ocs_mode` TINYINT NOT NULL DEFAULT '0' ";
923
                $DB->query($query) or die("0.65 MODE OCS add ocs_mode in config ".$LANG["update"][90].$DB->error());
924
        }
925
        ///////////// FIN MODE OCS
926

    
927

    
928
        if(!TableExists("glpi_dropdown_budget")) {
929
                $query = "CREATE TABLE `glpi_dropdown_budget` (
930
                        `ID` int(11) NOT NULL auto_increment,
931
                        `name` varchar(255) NOT NULL DEFAULT '',
932
                        PRIMARY KEY  (`ID`)
933
                                ) TYPE=MyISAM;";
934
                $DB->query($query) or die("0.65 add dropdown_budget ".$LANG["update"][90].$DB->error());
935
        }
936

    
937
        if(!FieldExists("glpi_infocoms","budget")) {
938
                $query = "ALTER TABLE `glpi_infocoms` ADD `budget` INT NULL DEFAULT '0';";
939
                $DB->query($query) or die("0.65 add budget in infocoms ".$LANG["update"][90].$DB->error());
940
        }
941

    
942
        if(!FieldExists("glpi_tracking","cost_time")) {
943
                $query = "ALTER TABLE `glpi_tracking` ADD `cost_time` FLOAT NOT NULL DEFAULT '0',
944
                        ADD `cost_fixed` FLOAT NOT NULL DEFAULT '0',
945
                        ADD `cost_material` FLOAT NOT NULL DEFAULT '0'";
946
                $DB->query($query) or die("0.65 add cost fields in tracking ".$LANG["update"][90].$DB->error());
947
        }
948

    
949
        // Global Printers
950
        if(!FieldExists("glpi_printers","is_global")) {
951
                $query="ALTER TABLE `glpi_printers` ADD `is_global` ENUM('0', '1') DEFAULT '0' NOT NULL AFTER `FK_glpi_enterprise` ;";
952
                $DB->query($query) or die("0.6 add is_global in printers ".$LANG["update"][90].$DB->error());
953
        }
954

    
955
        if(!FieldExists("glpi_config","debug")) {
956
                $query="ALTER TABLE `glpi_config` ADD `debug` int(2) NOT NULL default '0' ";
957
                $DB->query($query) or die("0.65 add debug in config ".$LANG["update"][90].$DB->error());
958
        }
959

    
960
        if(!TableExists("glpi_dropdown_os_version")) {
961
                $query = "CREATE TABLE `glpi_dropdown_os_version` (
962
                        `ID` int(11) NOT NULL auto_increment,
963
                        `name` varchar(255) NOT NULL default '',
964
                        PRIMARY KEY  (`ID`)
965
                                ) TYPE=MyISAM;";
966
                $DB->query($query) or die("0.65 add dropdown_os_version ".$LANG["update"][90].$DB->error());
967
        }
968

    
969
        if(!TableExists("glpi_dropdown_os_sp")) {
970
                $query = "CREATE TABLE `glpi_dropdown_os_sp` (
971
                        `ID` int(11) NOT NULL auto_increment,
972
                        `name` varchar(255) NOT NULL default '',
973
                        PRIMARY KEY  (`ID`)
974
                                ) TYPE=MyISAM;";
975
                $DB->query($query) or die("0.65 add dropdown_os_sp ".$LANG["update"][90].$DB->error());
976
        }
977

    
978
        if(!FieldExists("glpi_computers","os_version")) {
979
                $query="ALTER TABLE `glpi_computers` ADD `os_version` INT NOT NULL DEFAULT '0' AFTER `os` ,
980
                        ADD `os_sp` INT NOT NULL DEFAULT '0' AFTER `os_version` ";
981
                $DB->query($query) or die("0.65 add os_version os_sp in computers ".$LANG["update"][90].$DB->error());
982
        }
983

    
984
        // ADD INDEX
985
        $tbl=array("cartridges_type","computers","consumables_type","contacts","contracts","docs","enterprises","monitors","networking","peripherals","printers","software","users");
986

    
987
        foreach ($tbl as $t)
988
                if(!isIndex("glpi_$t","name")) {        
989
                        $query="ALTER TABLE `glpi_$t` ADD INDEX ( `name` ) ";
990
                        $DB->query($query) or die("0.65 add index in name field $t ".$LANG["update"][90].$DB->error());
991
                }
992

    
993
        $result=$DB->list_tables();
994
        while ($line = $DB->fetch_array($result))
995
                if (ereg("glpi_dropdown",$line[0])||ereg("glpi_type",$line[0])){
996
                        if(!isIndex($line[0],"name")) {        
997
                                $query="ALTER TABLE `".$line[0]."` ADD INDEX ( `name` ) ";
998
                                $DB->query($query) or die("0.65 add index in name field ".$line[0]." ".$LANG["update"][90].$DB->error());
999
                        }
1000
                }
1001

    
1002
        if(!isIndex("glpi_reservation_item","device_type_2")) {        
1003
                $query="ALTER TABLE `glpi_reservation_item` ADD INDEX  `device_type_2` ( `device_type`,`id_device` ) ";
1004
                $DB->query($query) or die("0.65 add index in reservation_item ".$line[0]." ".$LANG["update"][90].$DB->error());
1005
        }
1006

    
1007

    
1008
        if(!TableExists("glpi_dropdown_model_phones")) {
1009

    
1010
                $query = "CREATE TABLE `glpi_dropdown_model_phones` (
1011
                        `ID` int(11) NOT NULL auto_increment,
1012
                        `name` varchar(255) NOT NULL default '',
1013
                        PRIMARY KEY  (`ID`),
1014
                        KEY `name` (`name`)
1015
                                ) TYPE=MyISAM;";
1016
                $DB->query($query) or die("0.65 add dropdown_model_phones ".$LANG["update"][90].$DB->error());
1017
        }
1018

    
1019
        if(!TableExists("glpi_type_phones")) {
1020

    
1021
                $query = "CREATE TABLE `glpi_type_phones` (
1022
                        `ID` int(11) NOT NULL auto_increment,
1023
                        `name` varchar(255) NOT NULL default '',
1024
                        PRIMARY KEY  (`ID`),
1025
                        KEY `name` (`name`)
1026
                                ) TYPE=MyISAM;";
1027
                $DB->query($query) or die("0.65 add type_phones ".$LANG["update"][90].$DB->error());
1028
        }
1029

    
1030

    
1031
        if(!TableExists("glpi_dropdown_phone_power")) {
1032

    
1033
                $query = "CREATE TABLE `glpi_dropdown_phone_power` (
1034
                        `ID` int(11) NOT NULL auto_increment,
1035
                        `name` varchar(255) NOT NULL default '',
1036
                        PRIMARY KEY  (`ID`),
1037
                        KEY `name` (`name`)
1038
                                ) TYPE=MyISAM;";
1039
                $DB->query($query) or die("0.65 add dropdown_phone_power ".$LANG["update"][90].$DB->error());
1040
        }
1041

    
1042
        if(!TableExists("glpi_phones")) {
1043

    
1044
                $query = "CREATE TABLE `glpi_phones` (
1045
                        `ID` int(11) NOT NULL auto_increment,
1046
                        `name` varchar(255) default NULL,
1047
                        `date_mod` datetime NOT NULL default '0000-00-00 00:00:00',
1048
                        `contact` varchar(255) default NULL,
1049
                        `contact_num` varchar(255) default NULL,
1050
                        `tech_num` int(11) NOT NULL default '0',
1051
                        `comments` text,
1052
                        `serial` varchar(255) default NULL,
1053
                        `otherserial` varchar(255) default NULL,
1054
                        `firmware` varchar(255) default NULL,
1055
                        `location` int(11) NOT NULL default '0',
1056
                        `type` int(11) NOT NULL default '0',
1057
                        `model` int(11) default NULL,
1058
                        `brand` varchar(255) default NULL,
1059
                        `power` tinyint(4) NOT NULL default '0',
1060
                        `number_line` varchar(255) NOT NULL default '',
1061
                        `flags_casque` tinyint(4) NOT NULL default '0',
1062
                        `flags_hp` tinyint(4) NOT NULL default '0',
1063
                        `FK_glpi_enterprise` int(11) NOT NULL default '0',
1064
                        `is_global` enum('0','1') NOT NULL default '0',
1065
                        `deleted` enum('Y','N') NOT NULL default 'N',
1066
                        `is_template` enum('0','1') NOT NULL default '0',
1067
                        `tplname` varchar(255) default NULL,
1068
                        `notes` longtext,
1069
                        PRIMARY KEY  (`ID`),
1070
                        KEY `type` (`type`),
1071
                        KEY `name` (`name`),
1072
                        KEY `location` (`location`),
1073
                        KEY `FK_glpi_enterprise` (`FK_glpi_enterprise`),
1074
                        KEY `deleted` (`deleted`),
1075
                        KEY `is_template` (`is_template`),
1076
                        KEY `tech_num` (`tech_num`)
1077
                                ) TYPE=MyISAM;";
1078
                $DB->query($query) or die("0.65 add phones ".$LANG["update"][90].$DB->error());
1079

    
1080
                $query="INSERT INTO `glpi_phones` VALUES (1, NULL, '0000-00-00 00:00:00', NULL, NULL, 0, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, 0, '', 0, 0, 0, '0', 'N', '1', 'Blank Template', NULL);";
1081
                $DB->query($query) or die("0.65 blank template in phones ".$LANG["update"][90].$DB->error());
1082
        }
1083

    
1084

    
1085

    
1086
        if(!TableExists("glpi_reminder")) {
1087
                $query="CREATE TABLE `glpi_reminder` (
1088
                        `ID` int(11) NOT NULL auto_increment,
1089
                        `date` datetime default NULL,
1090
                        `author` int(11) NOT NULL default '0',
1091
                        `title` text,
1092
                        `text` text,
1093
                        `type` varchar(50) NOT NULL default 'private',
1094
                        `begin` datetime default NULL,
1095
                        `end` datetime default NULL,
1096
                        `rv` enum('0','1') NOT NULL default '0',
1097
                        `date_mod` datetime default NULL,
1098
                        PRIMARY KEY  (`ID`),
1099
                        KEY `date` (`date`),
1100
                        KEY `author` (`author`),
1101
                        KEY `rv` (`rv`),
1102
                        KEY `type` (`type`)
1103
                                ) TYPE=MyISAM ;";
1104

    
1105
                $DB->query($query) or die("0.65 add reminder ".$LANG["update"][90].$DB->error());
1106
        }
1107

    
1108
        $result=$DB->list_tables();
1109
        while ($line = $DB->fetch_array($result))
1110
                if (ereg("glpi_dropdown",$line[0])||ereg("glpi_type",$line[0])){
1111
                        if ($line[0]!="glpi_type_docs"){
1112
                                if(!FieldExists($line[0],"comments")) {
1113
                                        $query="ALTER TABLE `".$line[0]."` ADD `comments` TEXT NULL ";
1114
                                        $DB->query($query) or die("0.65 add comments field in ".$line[0]." ".$LANG["update"][90].$DB->error());
1115
                                }
1116
                        }
1117
                }
1118
        if(!FieldExists("glpi_consumables","id_user")) {
1119
                $query="ALTER TABLE `glpi_consumables` ADD `id_user` INT NOT NULL DEFAULT '0';";
1120
                $DB->query($query) or die("0.65 add id_user field in consumables ".$LANG["update"][90].$DB->error());
1121
        }
1122

    
1123

    
1124

    
1125
} // fin 0.65
1126

    
1127
?>
Redmine Appliance - Powered by TurnKey Linux