Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

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

Historique | Voir | Annoter | Télécharger (34,7 ko)

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

    
40
        if(!TableExists("glpi_profiles")) {
41
                $query="CREATE TABLE `glpi_profiles` (
42
                        `ID` int(11) NOT NULL auto_increment,
43
                        `name` varchar(255) default NULL,
44
                        `interface` varchar(50) NOT NULL default 'helpdesk',
45
                        `is_default` enum('0','1') NOT NULL default '0',
46
                        `computer` char(1) default NULL,
47
                        `monitor` char(1) default NULL,
48
                        `software` char(1) default NULL,
49
                        `networking` char(1) default NULL,
50
                        `printer` char(1) default NULL,
51
                        `peripheral` char(1) default NULL,
52
                        `cartridge` char(1) default NULL,
53
                        `consumable` char(1) default NULL,
54
                        `phone` char(1) default NULL,
55
                        `notes` char(1) default NULL,
56
                        `contact_enterprise` char(1) default NULL,
57
                        `document` char(1) default NULL,
58
                        `contract_infocom` char(1) default NULL,
59
                        `knowbase` char(1) default NULL,
60
                        `faq` char(1) default NULL,
61
                        `reservation_helpdesk` char(1) default NULL,
62
                        `reservation_central` char(1) default NULL,
63
                        `reports` char(1) default NULL,
64
                        `ocsng` char(1) default NULL,
65
                        `dropdown` char(1) default NULL,
66
                        `device` char(1) default NULL,
67
                        `typedoc` char(1) default NULL,
68
                        `link` char(1) default NULL,
69
                        `config` char(1) default NULL,
70
                        `search_config` char(1) default NULL,
71
                        `update` char(1) default NULL,
72
                        `profile` char(1) default NULL,
73
                        `user` char(1) default NULL,
74
                        `group` char(1) default NULL,
75
                        `logs` char(1) default NULL,
76
                        `reminder_public` char(1) default NULL,
77
                        `backup` char(1) default NULL,
78
                        `create_ticket` char(1) default NULL,
79
                        `delete_ticket` char(1) default NULL,
80
                        `comment_ticket` char(1) default NULL,
81
                        `comment_all_ticket` char(1) default NULL,
82
                        `update_ticket` char(1) default NULL,
83
                        `own_ticket` char(1) default NULL,
84
                        `steal_ticket` char(1) default NULL,
85
                        `assign_ticket` char(1) default NULL,
86
                        `show_ticket` char(1) default NULL,
87
                        `show_full_ticket` char(1) default NULL,
88
                        `observe_ticket` char(1) default NULL,
89
                        `show_planning` char(1) default NULL,
90
                        `show_all_planning` char(1) default NULL,
91
                        `statistic` char(1) default NULL,
92
                        `password_update` char(1) default NULL,
93
                        `helpdesk_hardware` tinyint(2) NOT NULL  DEFAULT '0',
94
                        `helpdesk_hardware_type` int(11) NOT NULL  DEFAULT '0',
95
                        PRIMARY KEY  (`ID`),
96
                        KEY `interface` (`interface`)
97
                                ) TYPE=MyISAM;";
98

    
99
                $DB->query($query) or die("0.68 add profiles ".$LANG["update"][90].$DB->error());
100

    
101
                $helpdesk_link_type=array(COMPUTER_TYPE,PRINTER_TYPE,MONITOR_TYPE,PERIPHERAL_TYPE,NETWORKING_TYPE,PHONE_TYPE,NETWORKING_TYPE);
102
                $checksum=0;
103
                foreach ($helpdesk_link_type as $val)
104
                        $checksum+=pow(2,$val);
105

    
106
                $query="INSERT INTO `glpi_profiles` VALUES (1, 'post-only', 'helpdesk', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'r', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, '1', '1', '$checksum');";
107
                $DB->query($query) or die("0.68 add post-only profile ".$LANG["update"][90].$DB->error());
108
                $query="INSERT INTO `glpi_profiles` VALUES (2, 'normal', 'central', '0', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', '1', 'r', 'r', NULL, NULL, NULL, 'r', 'r', NULL, NULL, 'r', NULL, 'r', 'r', NULL, NULL, NULL, '1', '1', '1', '0', '0', '1', '0', '0', '1', '0', '1', '1', '0', '1', '1', '1', '$checksum');";
109
                $DB->query($query) or die("0.68 add normal profile ".$LANG["update"][90].$DB->error());
110
                $query="INSERT INTO `glpi_profiles` VALUES (3, 'admin', 'central', '0', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', '1', 'w', 'r', 'w', 'w', 'w', 'w', 'w', NULL, 'w', 'r', 'r', 'w', 'w', NULL, NULL, NULL, '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '3', '$checksum');";
111
                $DB->query($query) or die("0.68 add admin profile ".$LANG["update"][90].$DB->error());
112
                $query="INSERT INTO `glpi_profiles` VALUES (4, 'super-admin', 'central', '0', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', '1', 'w', 'r', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'r', 'w', 'w', 'w', 'r', 'w', 'w', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '3', '$checksum');";
113
                $DB->query($query) or die("0.68 add super-admin profile ".$LANG["update"][90].$DB->error());
114

    
115
        }
116

    
117

    
118
        if (FieldExists("glpi_config","post_only_followup")){
119

    
120
                $query="SELECT post_only_followup FROM glpi_config WHERE ID='1' ";
121
                $result=$DB->query($query);
122
                if ($DB->result($result,0,0)){
123
                        $query="UPDATE glpi_profiles SET comment_ticket='1';";
124
                        $DB->query($query) or die("0.68 update default glpi_profiles ".$LANG["update"][90].$DB->error());
125
                }
126

    
127
                // TO DO : drop post_only_followup field of glpi_config
128
                $query="ALTER TABLE `glpi_config` DROP `post_only_followup`;";
129
                $DB->query($query) or die("0.68 drop post_only_followup in glpi_config ".$LANG["update"][90].$DB->error());
130
        }
131

    
132
        $profiles=array("post-only"=>1,"normal"=>2,"admin"=>3,"super-admin"=>4);
133
        if(!TableExists("glpi_users_profiles")) {        
134
                $query="CREATE TABLE `glpi_users_profiles` (
135
                        `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
136
                        `FK_users` INT NOT NULL DEFAULT '0',
137
                        `FK_profiles` INT NOT NULL DEFAULT '0',
138
                        KEY `FK_users` (`FK_users`),
139
                        KEY `FK_profiles` (`FK_profiles`),
140
                        UNIQUE `FK_users_profiles` (`FK_users`,`FK_profiles`)
141
                                ) TYPE = MYISAM ;";
142
                $DB->query($query) or die("0.68 create users_profiles table ".$LANG["update"][90].$DB->error());
143

    
144

    
145
                $query="SELECT ID, type FROM glpi_users";
146
                $result=$DB->query($query);
147
                if ($DB->numrows($result)){
148
                        while ($data=$DB->fetch_array($result)){
149
                                $query2="INSERT INTO glpi_users_profiles (FK_users,FK_profiles) VALUES ('".$data['ID']."','".$profiles[$data['type']]."')";
150
                                $DB->query($query2) or die("0.68 insert new users_profiles ".$LANG["update"][90].$DB->error());
151
                        }
152
                }
153
                $query="ALTER TABLE `glpi_users` DROP `type`, DROP `can_assign_job`;";
154
                $DB->query($query) or die("0.68 drop type and can_assign_job from users ".$LANG["update"][90].$DB->error());
155
        }
156

    
157
        if(!TableExists("glpi_mailing")) {        
158
                $query="CREATE TABLE `glpi_mailing` (
159
                        `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
160
                        `type`  varchar(255) default NULL,
161
                        `FK_item` INT NOT NULL DEFAULT '0',
162
                        `item_type` INT NOT NULL DEFAULT '0',
163
                        KEY `type` (`type`),
164
                        KEY `FK_item` (`FK_item`),
165
                        KEY `item_type` (`item_type`),
166
                        KEY `items` (`item_type`,`FK_item`),
167
                        UNIQUE `mailings` (`type`,`FK_item`,`item_type`)
168
                                ) TYPE = MYISAM ;";
169
                $DB->query($query) or die("0.68 create mailing table ".$LANG["update"][90].$DB->error());
170

    
171
                // MAILING TYPE
172
                define("USER_MAILING_TYPE","1");
173
                define("PROFILE_MAILING_TYPE","2");
174
                define("GROUP_MAILING_TYPE","3");
175

    
176
                // MAILING USERS TYPE
177
                define("ADMIN_MAILING","1");
178
                define("ASSIGN_MAILING","2");
179
                define("AUTHOR_MAILING","3");
180
                define("OLD_ASSIGN_MAILING","4");
181

    
182

    
183
                $query="SELECT * from glpi_config WHERE ID='1'";
184
                $result=$DB->query($query);
185
                if ($result){
186
                        $data=$DB->fetch_assoc($result);
187
                        if ($data["mailing_resa_all_admin"]){
188
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('resa','".$profiles["admin"]."','".PROFILE_MAILING_TYPE."');";
189
                                $DB->query($query2) or die("0.68 populate mailing resa all admin ".$LANG["update"][90].$DB->error());
190
                        }
191
                        if ($data["mailing_resa_user"]){
192
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('resa','".AUTHOR_MAILING."','".USER_MAILING_TYPE."');";
193
                                $DB->query($query2) or die("0.68 populate mailing resa all admin ".$LANG["update"][90].$DB->error());
194
                        }
195
                        if ($data["mailing_resa_admin"]){
196
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('resa','".ADMIN_MAILING."','".USER_MAILING_TYPE."');";
197
                                $DB->query($query2) or die("0.68 populate mailing resa all admin ".$LANG["update"][90].$DB->error());
198
                        }
199
                        if ($data["mailing_new_all_admin"]){
200
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('new','".$profiles["admin"]."','".PROFILE_MAILING_TYPE."');";
201
                                $DB->query($query2) or die("0.68 populate mailing new all admin ".$LANG["update"][90].$DB->error());
202
                        }
203
                        if ($data["mailing_update_all_admin"]){
204
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('update','".$profiles["admin"]."','".PROFILE_MAILING_TYPE."');";
205
                                $DB->query($query2) or die("0.68 populate mailing update all admin ".$LANG["update"][90].$DB->error());
206
                        }
207
                        if ($data["mailing_followup_all_admin"]){
208
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('followup','".$profiles["admin"]."','".PROFILE_MAILING_TYPE."');";
209
                                $DB->query($query2) or die("0.68 populate mailing followup all admin ".$LANG["update"][90].$DB->error());
210
                        }
211
                        if ($data["mailing_finish_all_admin"]){
212
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('finish','".$profiles["admin"]."','".PROFILE_MAILING_TYPE."');";
213
                                $DB->query($query2) or die("0.68 populate mailing finish all admin ".$LANG["update"][90].$DB->error());
214
                        }
215
                        if ($data["mailing_new_all_normal"]){
216
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('new','".$profiles["normal"]."','".PROFILE_MAILING_TYPE."');";
217
                                $DB->query($query2) or die("0.68 populate mailing new all normal ".$LANG["update"][90].$DB->error());
218
                        }
219
                        if ($data["mailing_update_all_normal"]){
220
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('update','".$profiles["normal"]."','".PROFILE_MAILING_TYPE."');";
221
                                $DB->query($query2) or die("0.68 populate mailing update all normal ".$LANG["update"][90].$DB->error());
222
                        }
223
                        if ($data["mailing_followup_all_normal"]){
224
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('followup','".$profiles["normal"]."','".PROFILE_MAILING_TYPE."');";
225
                                $DB->query($query2) or die("0.68 populate mailing followup all normal ".$LANG["update"][90].$DB->error());
226
                        }
227
                        if ($data["mailing_finish_all_normal"]){
228
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('finish','".$profiles["normal"]."','".PROFILE_MAILING_TYPE."');";
229
                                $DB->query($query2) or die("0.68 populate mailing finish all normal ".$LANG["update"][90].$DB->error());
230
                        }
231
                        if ($data["mailing_new_admin"]){
232
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('new','".ADMIN_MAILING."','".USER_MAILING_TYPE."');";
233
                                $DB->query($query2) or die("0.68 populate mailing new admin ".$LANG["update"][90].$DB->error());
234
                        }
235
                        if ($data["mailing_update_admin"]){
236
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('update','".ADMIN_MAILING."','".USER_MAILING_TYPE."');";
237
                                $DB->query($query2) or die("0.68 populate mailing update admin ".$LANG["update"][90].$DB->error());
238
                        }
239
                        if ($data["mailing_followup_admin"]){
240
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('followup','".ADMIN_MAILING."','".USER_MAILING_TYPE."');";
241
                                $DB->query($query2) or die("0.68 populate mailing followup admin ".$LANG["update"][90].$DB->error());
242
                        }
243
                        if ($data["mailing_finish_admin"]){
244
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('finish','".ADMIN_MAILING."','".USER_MAILING_TYPE."');";
245
                                $DB->query($query2) or die("0.68 populate mailing finish admin ".$LANG["update"][90].$DB->error());
246
                        }
247
                        if ($data["mailing_new_attrib"]){
248
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('new','".ASSIGN_MAILING."','".USER_MAILING_TYPE."');";
249
                                $DB->query($query2) or die("0.68 populate mailing new attrib ".$LANG["update"][90].$DB->error());
250
                        }
251
                        if ($data["mailing_update_attrib"]){
252
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('update','".ASSIGN_MAILING."','".USER_MAILING_TYPE."');";
253
                                $DB->query($query2) or die("0.68 populate mailing update attrib ".$LANG["update"][90].$DB->error());
254
                        }
255
                        if ($data["mailing_followup_attrib"]){
256
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('followup','".ASSIGN_MAILING."','".USER_MAILING_TYPE."');";
257
                                $DB->query($query2) or die("0.68 populate mailing followup attrib ".$LANG["update"][90].$DB->error());
258
                        }
259
                        if ($data["mailing_finish_attrib"]){
260
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('finish','".ASSIGN_MAILING."','".USER_MAILING_TYPE."');";
261
                                $DB->query($query2) or die("0.68 populate mailing finish attrib ".$LANG["update"][90].$DB->error());
262
                        }
263
                        if ($data["mailing_attrib_attrib"]){
264
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('update','".OLD_ASSIGN_MAILING."','".USER_MAILING_TYPE."');";
265
                                $DB->query($query2) or die("0.68 populate mailing finish attrib ".$LANG["update"][90].$DB->error());
266
                        }        
267
                        if ($data["mailing_new_user"]){
268
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('new','".AUTHOR_MAILING."','".USER_MAILING_TYPE."');";
269
                                $DB->query($query2) or die("0.68 populate mailing new user ".$LANG["update"][90].$DB->error());
270
                        }
271
                        if ($data["mailing_update_user"]){
272
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('update','".AUTHOR_MAILING."','".USER_MAILING_TYPE."');";
273
                                $DB->query($query2) or die("0.68 populate mailing update user ".$LANG["update"][90].$DB->error());
274
                        }
275
                        if ($data["mailing_followup_user"]){
276
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('followup','".AUTHOR_MAILING."','".USER_MAILING_TYPE."');";
277
                                $DB->query($query2) or die("0.68 populate mailing followup user ".$LANG["update"][90].$DB->error());
278
                        }
279
                        if ($data["mailing_finish_user"]){
280
                                $query2="INSERT INTO `glpi_mailing` (type,FK_item,item_type) VALUES ('finish','".AUTHOR_MAILING."','".USER_MAILING_TYPE."');";
281
                                $DB->query($query2) or die("0.68 populate mailing finish user ".$LANG["update"][90].$DB->error());
282
                        }
283

    
284
                }
285

    
286
                $query=" ALTER TABLE `glpi_config`
287
                        DROP `mailing_resa_all_admin`,
288
                             DROP `mailing_resa_user`,
289
                             DROP `mailing_resa_admin`,
290
                             DROP `mailing_new_admin`,
291
                             DROP `mailing_update_admin`,
292
                             DROP `mailing_followup_admin`,
293
                             DROP `mailing_finish_admin`,
294
                             DROP `mailing_new_all_admin`,
295
                             DROP `mailing_update_all_admin`,
296
                             DROP `mailing_followup_all_admin`,
297
                             DROP `mailing_finish_all_admin`,
298
                             DROP `mailing_new_all_normal`,
299
                             DROP `mailing_update_all_normal`,
300
                             DROP `mailing_followup_all_normal`,
301
                             DROP `mailing_finish_all_normal`,
302
                             DROP `mailing_new_attrib`,
303
                             DROP `mailing_update_attrib`,
304
                             DROP `mailing_followup_attrib`,
305
                             DROP `mailing_finish_attrib`,
306
                             DROP `mailing_new_user`,
307
                             DROP `mailing_update_user`,
308
                             DROP `mailing_followup_user`,
309
                             DROP `mailing_finish_user`,
310
                             DROP `mailing_attrib_attrib`;";
311
                $DB->query($query) or die("0.68 delete mailing config from config ".$LANG["update"][90].$DB->error());
312
        }
313

    
314

    
315
        // Convert old content of knowbase in HTML And add new fields
316
        if(TableExists("glpi_kbitems")){
317

    
318
                if(!FieldExists("glpi_kbitems","author")) {
319
                        // convert
320
                        $query="SELECT * FROM glpi_kbitems ";
321
                        $result=$DB->query($query);
322

    
323
                        if ($DB->numrows($result)>0){
324
                                while($line = $DB->fetch_array($result)) {
325
                                        $query="UPDATE glpi_kbitems SET answer='".addslashes(rembo($line["answer"]))."' WHERE ID='".$line["ID"]."'";
326
                                        $DB->query($query)          or die("0.68 convert knowbase to xhtml ".$LANG["update"][90].$DB->error());
327
                                }
328
                                $DB->free_result($result);
329
                        }
330
                        // add new fields
331
                        $query="ALTER TABLE `glpi_kbitems` ADD `author` INT( 11 ) NOT NULL DEFAULT '0' AFTER `faq` ,
332
                                ADD `view` INT( 11 ) NOT NULL DEFAULT '0' AFTER `author` ,
333
                                ADD `date` DATETIME NULL DEFAULT NULL AFTER `view` ,
334
                                ADD `date_mod` DATETIME NULL DEFAULT NULL AFTER `date` ;";
335
                        $DB->query($query) or die("0.68 add  fields in knowbase ".$LANG["update"][90].$DB->error());
336

    
337
                }
338
        } // fin convert
339

    
340
        // Add Level To Dropdown 
341
        $dropdowntree_tables=array("glpi_dropdown_locations","glpi_dropdown_kbcategories");
342
        foreach ($dropdowntree_tables as $t)
343
                if(!FieldExists($t,"level")) {        
344
                        $query="ALTER TABLE `$t` ADD `level` INT(11)";
345
                        $DB->query($query) or die("0.68 add level to $t ".$LANG["update"][90].$DB->error());
346
                        regenerateTreeCompleteName($t);
347
                }
348

    
349
        if(FieldExists("glpi_config","root_doc")) {        
350
                $query="ALTER TABLE `glpi_config` DROP  `root_doc`";
351
                $DB->query($query) or die("0.68 drop root_doc ".$LANG["update"][90].$DB->error());
352
                regenerateTreeCompleteName($t);
353
        }
354
        // add smtp config
355
        if(!FieldExists("glpi_config","smtp_mode")) {        
356
                $query="ALTER TABLE  `glpi_config` ADD  `smtp_mode` tinyint(4) DEFAULT '0' NOT NULL,
357
                        ADD  `smtp_host` varchar(255),
358
                        ADD  `smtp_port` int(11) DEFAULT '25' NOT NULL,
359
                        ADD  `smtp_username` varchar(255),
360
                        ADD  `smtp_password` varchar(255);";
361
                $DB->query($query) or die("0.68 add smtp config ".$LANG["update"][90].$DB->error());
362
        }
363

    
364
        $map_lang=array("french"=>"fr_FR","english"=>"en_GB","deutsch"=>"de_DE","italian"=>"it_IT","castillano"=>"es_ES","portugese"=>"pt_PT","dutch"=>"nl_NL","hungarian"=>"hu_HU","polish"=>"po_PO","rumanian"=>"ro_RO","russian"=>"ru_RU");
365
        foreach ($map_lang as $old => $new){
366
                $query="UPDATE glpi_users SET language='$new' WHERE language='$old';";
367
                $DB->query($query) or die("0.68 update $new lang user setting ".$LANG["update"][90].$DB->error());
368

    
369
        }
370
        $query="SELECT default_language FROM glpi_config WHERE ID='1';";
371
        $result=$DB->query($query);
372
        $def_lang=$DB->result($result,0,0);
373
        if (isset($map_lang[$def_lang])){
374
                $query="UPDATE glpi_config SET default_language='".$map_lang[$def_lang]."' WHERE ID='1';";
375
                $DB->query($query) or die("0.68 update default_language in config ".$LANG["update"][90].$DB->error());
376
        }
377

    
378
        // Improve link management
379
        if(!FieldExists("glpi_links","link")) {        
380
                $query="ALTER TABLE `glpi_links` CHANGE `name` `link` VARCHAR( 255 ) NULL DEFAULT NULL ";
381
                $DB->query($query) or die("0.68 rename name in link ".$LANG["update"][90].$DB->error());
382
                $query="ALTER TABLE `glpi_links` ADD `name` VARCHAR( 255 ) NULL AFTER `ID`";
383
                $DB->query($query) or die("0.68 add name in link ".$LANG["update"][90].$DB->error());
384
                $query="UPDATE glpi_links SET name=link";
385
                $DB->query($query) or die("0.68 init name field in link ".$LANG["update"][90].$DB->error());
386
        }
387

    
388
        if(FieldExists("glpi_config","ldap_field_name")) {
389
                $query="UPDATE `glpi_config` SET  ldap_login = ldap_field_name ";
390
                $DB->query($query);
391
                $query="ALTER TABLE `glpi_config` DROP `ldap_field_name` ";
392
                $DB->query($query) or die("0.68 drop ldap_field_name in config ".$LANG["update"][90].$DB->error());
393
        }
394

    
395
        // Security user Helpdesk
396
        $query="UPDATE glpi_users SET password='', active='0' WHERE name='Helpdesk';";
397
        $DB->query($query) or die("0.68 security update for user Helpdesk ".$LANG["update"][90].$DB->error());
398

    
399
        if(!FieldExists("glpi_ocs_config","import_general_name")) {        
400
                $query = "ALTER TABLE `glpi_ocs_config` ADD `import_general_name` INT( 2 ) NOT NULL DEFAULT '0' AFTER `import_printer`"; 
401
                $DB->query($query) or die("0.68 add import_name in ocs_config ".$LANG["update"][90].$DB->error());
402
        }
403
        // Clean default values for devices
404
        if(FieldExists("glpi_device_drive","speed")) {        
405
                $query = "ALTER TABLE `glpi_device_drive` CHANGE `speed` `speed` VARCHAR( 255 ) NULL "; 
406
                $DB->query($query) or die("0.68 alter speed in device_drive ".$LANG["update"][90].$DB->error());
407
        }
408

    
409
        if(FieldExists("glpi_device_gfxcard","ram")) {        
410
                $query = "ALTER TABLE `glpi_device_gfxcard` CHANGE `ram` `ram` VARCHAR( 255 ) NULL "; 
411
                $DB->query($query) or die("0.68 alter ram in device_gfxcard ".$LANG["update"][90].$DB->error());
412
        }
413

    
414
        if(FieldExists("glpi_device_hdd","rpm")) {        
415
                $query = "ALTER TABLE `glpi_device_hdd` CHANGE `rpm` `rpm` VARCHAR( 255 ) NULL , CHANGE `cache` `cache` VARCHAR( 255 ) NULL "; 
416
                $DB->query($query) or die("0.68 alter rpm and cache in device_hdd ".$LANG["update"][90].$DB->error());
417
        }        
418

    
419
        if(FieldExists("glpi_device_iface","bandwidth")) {        
420
                $query = "ALTER TABLE `glpi_device_iface` CHANGE `bandwidth` `bandwidth` VARCHAR( 255 ) NULL "; 
421
                $DB->query($query) or die("0.68 alter bandwidth in device_iface ".$LANG["update"][90].$DB->error());
422
        }
423

    
424
        if(FieldExists("glpi_device_moboard","chipset")) {        
425
                $query = "ALTER TABLE `glpi_device_moboard` CHANGE `chipset` `chipset` VARCHAR( 255 ) NULL "; 
426
                $DB->query($query) or die("0.68 alter chipset in device_moboard ".$LANG["update"][90].$DB->error());
427
        }
428

    
429
        if(FieldExists("glpi_device_drive","speed")) {        
430
                $query = "ALTER TABLE `glpi_device_drive` CHANGE `speed` `speed` VARCHAR( 255 ) NULL "; 
431
                $DB->query($query) or die("0.68 alter speed in device_drive ".$LANG["update"][90].$DB->error());
432
        }
433

    
434
        if(FieldExists("glpi_device_power","power")) {        
435
                $query = "ALTER TABLE `glpi_device_power` CHANGE `power` `power` VARCHAR( 255 ) NULL "; 
436
                $DB->query($query) or die("0.68 alter power in device_power ".$LANG["update"][90].$DB->error());
437
        }
438

    
439
        if(FieldExists("glpi_device_ram","frequence")) {        
440
                $query = "ALTER TABLE `glpi_device_ram` CHANGE `frequence` `frequence` VARCHAR( 255 ) NULL "; 
441
                $DB->query($query) or die("0.68 alter frequence in device_ram ".$LANG["update"][90].$DB->error());
442
        }
443

    
444
        if(FieldExists("glpi_device_sndcard","type")) {        
445
                $query = "ALTER TABLE `glpi_device_sndcard` CHANGE `type` `type` VARCHAR( 255 ) NULL "; 
446
                $DB->query($query) or die("0.68 alter type in device_sndcard ".$LANG["update"][90].$DB->error());
447
        }        
448

    
449
        if(!FieldExists("glpi_display","FK_users")) {        
450
                $query = "ALTER TABLE `glpi_display` ADD `FK_users` INT NOT NULL DEFAULT '0'"; 
451
                $DB->query($query) or die("0.68 alter display add FK_users".$LANG["update"][90].$DB->error());
452
                $query="ALTER TABLE `glpi_display` DROP INDEX `type_2`, ADD UNIQUE `type_2` ( `type` , `num` , `FK_users` )";
453
                $DB->query($query) or die("0.68 alter display update unique key".$LANG["update"][90].$DB->error());
454
        }        
455

    
456
        // Proxy configuration
457

    
458
        if(!FieldExists("glpi_config","proxy_name")) {        
459
                $query = "ALTER TABLE `glpi_config` ADD `proxy_name` VARCHAR( 255 ) NULL, ADD `proxy_port` VARCHAR( 255 ) DEFAULT '8080' NOT NULL, ADD `proxy_user` VARCHAR( 255 ) NULL, ADD `proxy_password` VARCHAR( 255 ) NULL"; 
460
                $DB->query($query) or die("0.68 add proxy fields to glpi_config".$LANG["update"][90].$DB->error());
461
        }        
462
        // Log update with followups
463
        if(!FieldExists("glpi_config","followup_on_update_ticket")) {        
464
                $query = "ALTER TABLE `glpi_config` ADD `followup_on_update_ticket` tinyint(4) DEFAULT '1' NOT NULL;"; 
465
                $DB->query($query) or die("0.68 add followup_on_update_ticket to glpi_config".$LANG["update"][90].$DB->error());
466
        }        
467

    
468

    
469
        // Ticket Category -> Tree mode
470
        if(!FieldExists("glpi_dropdown_tracking_category","completename")) {        
471
                $query = "ALTER TABLE glpi_dropdown_tracking_category ADD `parentID` INT NOT NULL DEFAULT '0' AFTER `ID`,
472
                        ADD `completename` TEXT NULL AFTER `name`,
473
                        ADD `level` INT NULL AFTER `comments` "; 
474
                                $DB->query($query) or die("0.68 glpi_dropdown_tracking_category to dropdown tree".$LANG["update"][90].$DB->error());
475
                regenerateTreeCompleteName("glpi_dropdown_tracking_category");
476
        }
477
        // User to Document
478
        if(!FieldExists("glpi_docs","FK_users")) {        
479
                $query = "ALTER TABLE `glpi_docs` ADD `FK_users` int DEFAULT '0' NOT NULL, ADD `FK_tracking` int DEFAULT '0' NOT NULL;"; 
480
                $DB->query($query) or die("0.68 add FK_users to docs".$LANG["update"][90].$DB->error());
481
        }        
482
        // Import Ocs TAG
483
        if(!FieldExists("glpi_ocs_config","import_tag_field")) {        
484
                $query = "ALTER TABLE `glpi_ocs_config` ADD `import_tag_field` varchar( 255 ) NULL;"; 
485
                $DB->query($query) or die("0.68 add import_tag_field to ocs_config".$LANG["update"][90].$DB->error());
486
        }
487
        // Use ocs soft dict
488
        if(!FieldExists("glpi_ocs_config","use_soft_dict")) {        
489
                $query = "ALTER TABLE `glpi_ocs_config` ADD `use_soft_dict` char( 1 ) DEFAULT '1';"; 
490
                $DB->query($query) or die("0.68 add use_soft_dict to ocs_config".$LANG["update"][90].$DB->error());
491
        }
492

    
493
        // Link user and group to hardware
494
        $new_link=array("computers","software","monitors","networking","peripherals","printers","phones");
495

    
496
        foreach ($new_link as $table)
497
                if(!FieldExists("glpi_$table","FK_users")) {        
498
                        $query="ALTER TABLE `glpi_$table` ADD `FK_users` INT(11) DEFAULT '0', ADD `FK_groups` INT(11) DEFAULT '0';";
499
                        $DB->query($query) or die("0.65 add link user group field in $table ".$LANG["update"][90].$DB->error());
500

    
501
                        if ($table != "software"){
502
                                // Update using name field of users
503
                                $query2="SELECT glpi_users.ID AS USER, glpi_$table.ID AS ID FROM glpi_$table LEFT JOIN glpi_users ON (glpi_$table.contact = glpi_users.name AND glpi_$table.contact <> '') WHERE glpi_users.ID IS NOT NULL";
504
                                $result2=$DB->query($query2);
505
                                if ($DB->numrows($result2)>0){
506
                                        while ($data=$DB->fetch_assoc($result2)){
507
                                                $query3="UPDATE glpi_$table SET FK_users='".$data["USER"]."' WHERE ID='".$data["ID"]."'";
508
                                                $DB->query($query3);
509
                                        }
510
                                }
511
                                // Update using realname field of users
512
                                $query2="SELECT glpi_users.ID AS USER, glpi_$table.ID AS ID FROM glpi_$table LEFT JOIN glpi_users ON (glpi_$table.contact = glpi_users.realname AND glpi_$table.contact <> '') WHERE glpi_users.ID IS NOT NULL AND glpi_$table.FK_users ='0' ";
513
                                $result2=$DB->query($query2);
514
                                if ($DB->numrows($result2)>0){
515
                                        while ($data=$DB->fetch_assoc($result2)){
516
                                                $query3="UPDATE glpi_$table SET FK_users='".$data["USER"]."' WHERE ID='".$data["ID"]."'";
517
                                                $DB->query($query3);
518
                                        }
519
                                }
520
                        }
521

    
522
                }
523

    
524

    
525

    
526

    
527
        //// Group management
528
        // Manage old plugin table
529
        if(FieldExists("glpi_groups","extend")){
530
                $query= "ALTER TABLE `glpi_groups` RENAME `glpi_plugin_droits_groups`;";
531
                $DB->query($query) or die("0.68 rename plugin groups table ".$LANG["update"][90].$DB->error());
532
        }
533

    
534
        if(!TableExists("glpi_groups")) {
535
                $query="CREATE TABLE `glpi_groups` (
536
                        `ID` int(11) NOT NULL auto_increment,
537
                        `name` varchar(255) default NULL,
538
                        `comments` text,
539
                        `ldap_field` varchar(255) default NULL,
540
                        `ldap_value` varchar(255) default NULL,
541
                        PRIMARY KEY  (`ID`),
542
                        KEY `name` (`name`),
543
                        KEY `ldap_field` (`ldap_field`)
544
                                ) TYPE=MyISAM;";
545
                $DB->query($query) or die("0.68 add groups ".$LANG["update"][90].$DB->error());
546

    
547
                $query="INSERT INTO `glpi_display` (`type`, `num`, `rank`, `FK_users`) VALUES ('".GROUP_TYPE."', '16', '1', '0')";
548
                $DB->query($query) or die("0.68 add groups search config".$LANG["update"][90].$DB->error());
549
        }
550

    
551
        if(!TableExists("glpi_users_groups")) {
552

    
553
                $query="CREATE TABLE `glpi_users_groups` (
554
                        `ID` int(11) NOT NULL auto_increment,
555
                        `FK_users` int(11) default '0',
556
                        `FK_groups` int(11) default '0',
557
                        PRIMARY KEY  (`ID`),
558
                        UNIQUE KEY `FK_users` (`FK_users`,`FK_groups`),
559
                        KEY `FK_users_2` (`FK_users`),
560
                        KEY `FK_groups` (`FK_groups`)
561
                                ) TYPE=MyISAM;";
562
                $DB->query($query) or die("0.68 add users_groups ".$LANG["update"][90].$DB->error());
563
        }
564

    
565
        if(!FieldExists("glpi_config","ldap_field_group")) {        
566
                $query="ALTER TABLE  `glpi_config` ADD  `ldap_field_group` varchar(255) NULL;";
567
                $DB->query($query) or die("0.68 add ldap_field_group in config ".$LANG["update"][90].$DB->error());
568
        }
569

    
570
        if(!FieldExists("glpi_tracking","request_type")) {        
571
                $query="ALTER TABLE  `glpi_tracking` ADD  `request_type` tinyint(2) DEFAULT '0' AFTER `author`;";
572
                $DB->query($query) or die("0.68 add request_type in tracking ".$LANG["update"][90].$DB->error());
573
        }
574

    
575
        // History update for software
576
        if(FieldExists("glpi_history","device_internal_action")) {        
577
                $query="ALTER TABLE `glpi_history` CHANGE `device_internal_action` `linked_action` TINYINT( 4 ) NULL DEFAULT '0'";
578
                $DB->query($query) or die("0.68 alater glpi_history ".$LANG["update"][90].$DB->error());
579
        }
580

    
581
        if(!TableExists("glpi_alerts")) {
582

    
583
                $query="CREATE TABLE `glpi_alerts` (
584
                        `ID` int(11) NOT NULL auto_increment,
585
                        `device_type` int(11) default '0',
586
                        `FK_device` int(11) default '0',
587
                        `type` int(11) default '0',
588
                        `date` timestamp NULL default CURRENT_TIMESTAMP,
589
                        PRIMARY KEY  (`ID`),
590
                        UNIQUE KEY `alert` (`device_type`,`FK_device`,`type`),
591
                        KEY `item` (`device_type`,`FK_device`),
592
                        KEY `device_type` (`device_type`),
593
                        KEY `FK_device` (`FK_device`),
594
                        KEY `type` (`type`),
595
                        KEY `date` (`date`)
596
                                ) TYPE=MyISAM;";
597
                $DB->query($query) or die("0.68 add alerts ".$LANG["update"][90].$DB->error());
598
        }
599

    
600
        if(!FieldExists("glpi_contracts","alert")) {        
601
                $query="ALTER TABLE  `glpi_contracts` ADD  `alert` tinyint(2) NOT NULL DEFAULT '0';";
602
                $DB->query($query) or die("0.68 add alert in contracts ".$LANG["update"][90].$DB->error());
603
        }
604

    
605
        if(!FieldExists("glpi_infocoms","alert")) {        
606
                $query="ALTER TABLE  `glpi_infocoms` ADD  `alert` tinyint(2) NOT NULL DEFAULT '0';";
607
                $DB->query($query) or die("0.68 add alert in infocoms ".$LANG["update"][90].$DB->error());
608
        }
609

    
610
        if(!FieldExists("glpi_config","contract_alerts")) {        
611
                $query="ALTER TABLE  `glpi_config` ADD  `contract_alerts` tinyint(2) NOT NULL  DEFAULT '0';";
612
                $DB->query($query) or die("0.68 add contract_alerts in config ".$LANG["update"][90].$DB->error());
613
        }
614

    
615
        if(!FieldExists("glpi_config","infocom_alerts")) {        
616
                $query="ALTER TABLE  `glpi_config` ADD  `infocom_alerts` tinyint(2) NOT NULL DEFAULT '0';";
617
                $DB->query($query) or die("0.68 add infocom_alerts in config ".$LANG["update"][90].$DB->error());
618
        }
619

    
620
        if(!FieldExists("glpi_tracking","FK_group")) {        
621
                $query="ALTER TABLE  `glpi_tracking` ADD  `FK_group` int(11) NOT NULL  DEFAULT '0' AFTER `author`;";
622
                $DB->query($query) or die("0.68 add FK_group in tracking ".$LANG["update"][90].$DB->error());
623
        }
624

    
625
        if(!FieldExists("glpi_config","cartridges_alert")) {        
626
                $query="ALTER TABLE  `glpi_config` ADD  `cartridges_alert` int(11) NOT NULL  DEFAULT '0';";
627
                $DB->query($query) or die("0.68 add cartridges_alert in config ".$LANG["update"][90].$DB->error());
628
        }
629

    
630
        if(!FieldExists("glpi_config","consumables_alert")) {        
631
                $query="ALTER TABLE  `glpi_config` ADD  `consumables_alert` int(11) NOT NULL  DEFAULT '0';";
632
                $DB->query($query) or die("0.68 add consumables_alert in config ".$LANG["update"][90].$DB->error());
633
        }
634

    
635
        if(!FieldExists("glpi_contacts","firstname")) {        
636
                $query="ALTER TABLE  `glpi_contacts` ADD  `firstname` varchar(255)  DEFAULT '' AFTER `name`;";
637
                $DB->query($query) or die("0.68 add firstname in contacts ".$LANG["update"][90].$DB->error());
638
        }
639

    
640
        if(!FieldExists("glpi_contacts","mobile")) {        
641
                $query="ALTER TABLE  `glpi_contacts` ADD  `mobile` varchar(255)  DEFAULT '' AFTER `phone2`;";
642
                $DB->query($query) or die("0.68 add mobile in contacts ".$LANG["update"][90].$DB->error());
643
        }
644

    
645
        if(!FieldExists("glpi_enterprises","country")) {        
646
                $query="ALTER TABLE  `glpi_enterprises` ADD  `country` varchar(255)  DEFAULT '' AFTER `address`;";
647
                $DB->query($query) or die("0.68 add country in enterprises ".$LANG["update"][90].$DB->error());
648
        }
649

    
650
        if(!FieldExists("glpi_enterprises","state")) {        
651
                $query="ALTER TABLE  `glpi_enterprises` ADD  `state` varchar(255)  DEFAULT '' AFTER `address`;";
652
                $DB->query($query) or die("0.68 add state in enterprises ".$LANG["update"][90].$DB->error());
653
        }
654

    
655
        if(!FieldExists("glpi_enterprises","town")) {        
656
                $query="ALTER TABLE  `glpi_enterprises` ADD  `town` varchar(255)  DEFAULT '' AFTER `address`;";
657
                $DB->query($query) or die("0.68 add town in enterprises ".$LANG["update"][90].$DB->error());
658
        }
659

    
660
        if(!FieldExists("glpi_enterprises","postcode")) {        
661
                $query="ALTER TABLE  `glpi_enterprises` ADD  `postcode` varchar(255)  DEFAULT '' AFTER `address`;";
662
                $DB->query($query) or die("0.68 add postcode in enterprises ".$LANG["update"][90].$DB->error());
663
        }
664

    
665
        if(!FieldExists("glpi_contracts","renewal")) {        
666
                $query="ALTER TABLE  `glpi_contracts` ADD  `renewal` tinyint(2) NOT NULL DEFAULT '0';";
667
                $DB->query($query) or die("0.68 add renewal in contracts ".$LANG["update"][90].$DB->error());
668
        }
669

    
670

    
671
        // Update contract periodicity and facturation
672
        $values=array("4"=>"6","5"=>"12","6"=>"24");
673

    
674
        foreach ($values as $key => $val){
675
                $query="UPDATE glpi_contracts SET periodicity='$val' WHERE periodicity='$key';";
676
                $DB->query($query) or die("0.68 update contract periodicity value ".$LANG["update"][90].$DB->error());
677
                $query="UPDATE glpi_contracts SET facturation='$val' WHERE facturation='$key';";
678
                $DB->query($query) or die("0.68 update contract facturation value ".$LANG["update"][90].$DB->error());
679
        }
680

    
681
        // Add user fields
682
        if(!FieldExists("glpi_users","mobile")) {        
683
                $query="ALTER TABLE  `glpi_users` ADD  `mobile` varchar(255)  DEFAULT '' AFTER `phone`;";
684
                $DB->query($query) or die("0.68 add mobile in users ".$LANG["update"][90].$DB->error());
685
        }
686
        if(!FieldExists("glpi_users","phone2")) {        
687
                $query="ALTER TABLE  `glpi_users` ADD  `phone2` varchar(255)  DEFAULT '' AFTER `phone`;";
688
                $DB->query($query) or die("0.68 add phone2 in users ".$LANG["update"][90].$DB->error());
689
        }
690
        if(!FieldExists("glpi_users","firstname")) {        
691
                $query="ALTER TABLE  `glpi_users` ADD  `firstname` varchar(255)  DEFAULT '' AFTER `realname`;";
692
                $DB->query($query) or die("0.68 add firstname in users ".$LANG["update"][90].$DB->error());
693
        }
694

    
695
        if(!FieldExists("glpi_users","comments")) {        
696
                $query="ALTER TABLE  `glpi_users` ADD  `comments` TEXT ;";
697
                $DB->query($query) or die("0.68 add comments in users ".$LANG["update"][90].$DB->error());
698
        }
699

    
700
        if(!FieldExists("glpi_config","ldap_field_firstname")) {        
701
                $query="ALTER TABLE  `glpi_config` ADD  `ldap_field_firstname` varchar(200)  DEFAULT 'givenname' AFTER `ldap_field_realname`;";
702
                $DB->query($query) or die("0.68 add ldap_field_firstname in config ".$LANG["update"][90].$DB->error());
703
        }
704

    
705
        if(!FieldExists("glpi_config","ldap_field_mobile")) {        
706
                $query="ALTER TABLE  `glpi_config` ADD  `ldap_field_mobile` varchar(200)  DEFAULT 'mobile' AFTER `ldap_field_phone`;";
707
                $DB->query($query) or die("0.68 add ldap_mobile in config ".$LANG["update"][90].$DB->error());
708
        }
709

    
710
        if(!FieldExists("glpi_config","ldap_field_phone2")) {        
711
                $query="ALTER TABLE  `glpi_config` ADD  `ldap_field_phone2` varchar(200)  DEFAULT 'homephone' AFTER `ldap_field_phone`;";
712
                $DB->query($query) or die("0.68 add ldap_field_phone2 in config ".$LANG["update"][90].$DB->error());
713
        }
714

    
715

    
716

    
717
} // fin 0.68 #####################################################################################
718

    
719
?>
Redmine Appliance - Powered by TurnKey Linux