source: trunk/phpgwapi/setup/tables_update_0_9_10.inc.php @ 2

Revision 2, 42.3 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * phpGroupWare - Setup                                                     *
4  * http://www.phpgroupware.org                                              *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11
12
13        $test[] = '0.9.9';
14        function phpgwapi_upgrade0_9_9()
15        {
16                global $setup_info, $phpgw_setup;
17
18                $db2 = $phpgw_setup->db;
19                //convert user settings
20                $phpgw_setup->oProc->query("select account_id, account_permissions from accounts",__LINE__,__FILE__);
21                if($phpgw_setup->oProc->num_rows())
22                {
23                        while($phpgw_setup->oProc->next_record())
24                        {
25                                $apps_perms = explode(":",$phpgw_setup->oProc->f('account_permissions'));
26                                for($i=1;$i<count($apps_perms)-1;$i++)
27                                {
28                                        if ($apps_perms[$i] != "")
29                                        {
30                                                $sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
31                                                $sql .= " values('".$apps_perms[$i]."', 'run', ".$phpgw_setup->oProc->f("account_id").", 'u', 1)";
32                                                $db2->query($sql ,__LINE__,__FILE__);
33                                        }
34                                }
35                        }
36                }
37                $phpgw_setup->oProc->query("update accounts set account_permissions = ''",__LINE__,__FILE__);
38                //convert group settings
39                $phpgw_setup->oProc->query("select group_id, group_apps from groups",__LINE__,__FILE__);
40                if($phpgw_setup->oProc->num_rows())
41                {
42                        while($phpgw_setup->oProc->next_record())
43                        {
44                                $apps_perms = explode(":",$phpgw_setup->oProc->f('group_apps'));
45                                for($i=1;$i<count($apps_perms)-1;$i++)
46                                {
47                                        if ($apps_perms[$i] != '')
48                                        {
49                                                $sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
50                                                $sql .= " values('".$apps_perms[$i]."', 'run', ".$phpgw_setup->oProc->f("group_id").", 'g', 1)";
51                                                $db2->query($sql ,__LINE__,__FILE__);
52                                        }
53                                }
54                        }
55                }
56                $phpgw_setup->oProc->query("update groups set group_apps = ''",__LINE__,__FILE__);
57
58                $setup_info['phpgwapi']['currentver'] = '0.9.10pre1';
59                return $setup_info['phpgwapi']['currentver'];
60                //return True;
61        }
62
63        $test[] = '0.9.10pre1';
64        function phpgwapi_upgrade0_9_10pre1()
65        {
66                global $setup_info, $phpgw_setup;
67
68                $phpgw_setup->oProc->AddColumn('phpgw_categories','cat_access',array('type' => 'varchar', 'precision' => 25));
69
70                $setup_info['phpgwapi']['currentver'] = '0.9.10pre2';
71                return $setup_info['phpgwapi']['currentver'];
72                //return True;
73        }
74
75        $test[] = '0.9.10pre2';
76        function phpgwapi_upgrade0_9_10pre2()
77        {
78                global $setup_info, $phpgw_setup;
79
80                $db2 = $phpgw_setup->oProc;
81
82                $phpgw_setup->oProc->query("SELECT account_groups,account_id FROM accounts",__LINE__,__FILE__);
83                if($phpgw_setup->oProc->num_rows())
84                {
85                        while($phpgw_setup->oProc->next_record())
86                        {
87                                $gl = explode(',',$phpgw_setup->oProc->f('account_groups'));
88                                for ($i=1; $i<(count($gl)-1); $i++)
89                                {
90                                        $ga = explode(':',$gl[$i]);
91                                        $sql = "INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
92                                        $sql .= " VALUES('phpgw_group', '".$ga[0]."', ".$phpgw_setup->oProc->f("account_id").", 'u', 1)";
93                                        $db2->query($sql ,__LINE__,__FILE__);
94                                }
95                        }
96                }
97                $phpgw_setup->oProc->query("UPDATE accounts SET account_groups= ''",__LINE__,__FILE__);
98
99                $setup_info['phpgwapi']['currentver'] = '0.9.10pre3';
100                return $setup_info['phpgwapi']['currentver'];
101                //return True;
102        }
103
104        $test[] = '0.9.10pre3';
105        function phpgwapi_upgrade0_9_10pre3()
106        {
107                global $setup_info, $phpgw_setup;
108
109                $phpgw_setup->oProc->RenameTable('accounts','phpgw_accounts');
110
111                $newtbldef = array(
112                        'fd' => array(
113                                'account_id' => array('type' => 'auto', 'nullable' => false),
114                                'account_lid' => array('type' => 'varchar', 'precision' => 25, 'nullable' => false),
115                                'account_pwd' => array('type' => 'varchar', 'precision' => 32, 'nullable' => false),
116                                'account_firstname' => array('type' => 'varchar', 'precision' => 50),
117                                'account_lastname' => array('type' => 'varchar', 'precision' => 50),
118                                'account_groups' => array('type' => 'varchar', 'precision' => 30),
119                                'account_lastlogin' => array('type' => 'int', 'precision' => 4),
120                                'account_lastloginfrom' => array('type' => 'varchar', 'precision' => 255),
121                                'account_lastpwd_change' => array('type' => 'int', 'precision' => 4),
122                                'account_status' => array('type' => 'char', 'precision' => 1, 'nullable' => false, 'default' => 'A')
123                        ),
124                        'pk' => array('account_id'),
125                        'fk' => array(),
126                        'ix' => array(),
127                        'uc' => array('account_lid')
128                );
129                $phpgw_setup->oProc->DropColumn('phpgw_accounts',$newtbldef,'account_permissions');
130
131                $newtbldef = array(
132                        'fd' => array(
133                                'account_id' => array('type' => 'auto', 'nullable' => false),
134                                'account_lid' => array('type' => 'varchar', 'precision' => 25, 'nullable' => false),
135                                'account_pwd' => array('type' => 'varchar', 'precision' => 32, 'nullable' => false),
136                                'account_firstname' => array('type' => 'varchar', 'precision' => 50),
137                                'account_lastname' => array('type' => 'varchar', 'precision' => 50),
138                                'account_lastlogin' => array('type' => 'int', 'precision' => 4),
139                                'account_lastloginfrom' => array('type' => 'varchar', 'precision' => 255),
140                                'account_lastpwd_change' => array('type' => 'int', 'precision' => 4),
141                                'account_status' => array('type' => 'char', 'precision' => 1, 'nullable' => false, 'default' => 'A')
142                        ),
143                        'pk' => array('account_id'),
144                        'fk' => array(),
145                        'ix' => array(),
146                        'uc' => array('account_lid')
147                );
148                $phpgw_setup->oProc->DropColumn('phpgw_accounts',$newtbldef,'account_groups');
149
150                $phpgw_setup->oProc->AddColumn('phpgw_accounts','account_type', array('type' => 'char', 'precision' => 1));
151                $phpgw_setup->oProc->query("update phpgw_accounts set account_type='u'",__LINE__,__FILE__);
152
153                $setup_info['phpgwapi']['currentver'] = '0.9.10pre4';
154                return $setup_info['phpgwapi']['currentver'];
155                //return True;
156        }
157
158        // TODO see next function
159/*
160                $tables = Array('addressbook','calendar_entry','f_forums','todo');
161                $fields["addressbook"] = Array('ab_access','ab_id');
162                $fields["calendar_entry"] = Array('cal_group','cal_id');
163                $fields["f_forums"] = Array('groups','id');
164                $fields["phpgw_categories"] = Array('cat_access','cat_id');
165                $fields["todo"] = Array('todo_access','todo_id');
166*/
167        function change_groups($table,$field,$old_id,$new_id,$db2,$db3)
168        {
169                $sql = $field[0];
170                for($i=1;$i<count($field);$i++)
171                {
172                        $sql .= ", ".$field[$i];
173                }
174                $db2->query("SELECT $sql FROM $table WHERE $field[0] like '%,".$old_id.",%'",__LINE__,__FILE__);
175                if($db2->num_rows())
176                {
177                        while($db2->next_record())
178                        {
179                                $access = $db2->f($field[0]);
180                                $id = $db2->f($field[1]);
181                                $access = str_replace(','.$old_id.',' , ','.$new_id.',' , $access);
182                                $db3->query("UPDATE $table SET ".$field[0]."='".$access."' WHERE ".$field[1]."=".$id,__LINE__,__FILE__);
183                        }
184                }
185        }
186
187        $test[] = '0.9.10pre4';
188        function phpgwapi_upgrade0_9_10pre4()
189        {
190                global $setup_info, $phpgw_setup;
191
192                $db2 = $phpgw_setup->oProc;
193                $db3 = $phpgw_setup->oProc;
194
195                $phpgw_setup->oProc->query("SELECT MAX(group_id) FROM groups",__LINE__,__FILE__);
196                $phpgw_setup->oProc->next_record();
197                $max_group_id = $phpgw_setup->oProc->f(0);
198
199                // This is for use by former CORE apps to use in this version number's upgrade locally
200                $phpgw_setup->oProc->CreateTable(
201                        'phpgw_temp_groupmap', array(
202                                'fd' => array(
203                                        'oldid'  => array('type' => 'int', 'precision' => 4, 'nullable' => False),
204                                        'oldlid' => array('type' => 'varchar', 'precision' => 255, 'nullable' => True),
205                                        'newid'  => array('type' => 'int', 'precision' => 4, 'nullable' => True),
206                                        'newlid' => array('type' => 'varchar', 'precision' => 255, 'nullable' => True)
207                                ),
208                                'pk' => array('oldid'),
209                                'fk' => array(),
210                                'ix' => array(),
211                                'uc' => array()
212                        )
213                );
214
215                $phpgw_setup->oProc->query("SELECT group_id, group_name FROM groups",__LINE__,__FILE__);
216                while($phpgw_setup->oProc->next_record())
217                {
218                        $old_group_id = $phpgw_setup->oProc->f('group_id');
219                        $old_group_name = $phpgw_setup->oProc->f('group_name');
220                        $group_name = $phpgw_setup->oProc->f('group_name');
221                        while(1)
222                        {
223                                $new_group_id = mt_rand ($max_group_id, 60000);
224                                $db2->query("SELECT account_id FROM phpgw_accounts WHERE account_id=$new_group_id",__LINE__,__FILE__);
225                                if(!$db2->num_rows()) { break; }
226                        }
227                        $db2->query("SELECT account_lid FROM phpgw_accounts WHERE account_lid='$group_name'",__LINE__,__FILE__);
228                        if($db2->num_rows())
229                        {
230                                $group_name .= '_group';
231                        }
232                        $db2->query("INSERT INTO phpgw_accounts(account_id, account_lid, account_pwd, "
233                                ."account_firstname, account_lastname, account_lastlogin, "
234                                ."account_lastloginfrom, account_lastpwd_change, "
235                                ."account_status, account_type) "
236                                ."VALUES ($new_group_id,'$group_name','x','','',$old_group_id,NULL,NULL,'A','g')");
237
238                        // insert oldid/newid into temp table (for use by other apps in this version upgrade
239                        $db2->query("INSERT INTO phpgw_temp_groupmap (oldid,oldlid,newid,newlid) VALUES ($old_group_id,'$old_group_name',$new_group_id,'$group_name')",__LINE__,__FILE__);
240
241                        $db2->query("UPDATE phpgw_acl SET acl_location='$new_group_id' "
242                                ."WHERE acl_appname='phpgw_group' AND acl_account_type='u' "
243                                ."AND acl_location='$old_group_id'");
244                        $db2->query("UPDATE phpgw_acl SET acl_account=$new_group_id "
245                                ."WHERE acl_location='run' AND acl_account_type='g' "
246                                ."AND acl_account=$old_group_id");
247
248                        $db2->query("SELECT cat_access,cat_id FROM phpgw_categories WHERE cat_access LIKE '%,".$old_group_id.",%'",__LINE__,__FILE__);
249                        if($db2->num_rows())
250                        {
251                                while($db2->next_record())
252                                {
253                                        $access = $db2->f('cat_access');
254                                        $id     = $db2->f('cat_id');
255                                        $access = str_replace(','.$old_group_id.',' , ','.$new_group_id.',' , $access);
256                                        $db3->query("UPDATE phpgw_categories SET cat_access='".$access."' WHERE cat_id=".$id,__LINE__,__FILE__);
257                                }
258                        }
259                }
260
261                $phpgw_setup->oProc->DropTable('groups');
262
263                /* Moved back from addressbook */
264                $phpgw_setup->oProc->query('SELECT oldid,newid FROM phpgw_temp_groupmap',__LINE__,__FILE__);
265                if($phpgw_setup->oProc->num_rows())
266                {
267                        while($phpgw_setup->oProc->next_record())
268                        {
269                                $old_group_id = $phpgw_setup->oProc->f(0);
270                                $new_group_id = $phpgw_setup->oProc->f(1);
271                                $db2->query("SELECT ab_access,ab_id FROM addressbook WHERE ab_access LIKE '%,".$old_group_id.",%'",__LINE__,__FILE__);
272                                if($db2->num_rows())
273                                {
274                                        while($db2->next_record())
275                                        {
276                                                $access = $db2->f('cat_access');
277                                                $id     = $db2->f('cat_id');
278                                                $access = str_replace(','.$old_group_id.',' , ','.$new_group_id.',' , $access);
279                                                $db3->query("UPDATE phpgw_categories SET cat_access='".$access."' WHERE cat_id=".$id,__LINE__,__FILE__);
280                                        }
281                                }
282                        }
283                }
284
285                $setup_info['phpgwapi']['currentver'] = '0.9.10pre5';
286                return $setup_info['phpgwapi']['currentver'];
287                //return True;
288        }
289 
290        $test[] = '0.9.10pre5';
291        function phpgwapi_upgrade0_9_10pre5()
292        {
293                global $setup_info, $phpgw_setup;
294
295                /* This is only temp data, so we can kill it. */
296                $phpgw_setup->oProc->DropTable('phpgw_app_sessions');
297                $phpgw_setup->oProc->CreateTable(
298                        'phpgw_app_sessions', array(
299                                'fd' => array(
300                                        'sessionid' => array('type' => 'varchar', 'precision' => 255, 'nullable' => False),
301                                        'loginid' => array('type' => 'varchar', 'precision' => 20),
302                                        'location' => array('type' => 'varchar', 'precision' => 255),
303                                        'app' => array('type' => 'varchar', 'precision' => 20),
304                                        'content' => array('type' => 'text')
305                                ),
306                                'pk' => array(),
307                                'fk' => array(),
308                                'ix' => array(),
309                                'uc' => array()
310                        )
311                );
312
313                $setup_info['phpgwapi']['currentver'] = '0.9.10pre6';
314                return $setup_info['phpgwapi']['currentver'];
315                //return True;
316        }
317
318        $test[] = '0.9.10pre6';
319        function phpgwapi_upgrade0_9_10pre6()
320        {
321                global $setup_info, $phpgw_setup;
322
323                $phpgw_setup->oProc->RenameTable('config','phpgw_config');
324
325                $setup_info['phpgwapi']['currentver'] = '0.9.10pre7';
326                return $setup_info['phpgwapi']['currentver'];
327                //return True;
328        }
329
330        $test[] = '0.9.10pre7';
331        function phpgwapi_upgrade0_9_10pre7()
332        {
333                global $setup_info, $phpgw_setup;
334
335                $phpgw_setup->oProc->RenameTable('applications','phpgw_applications');
336
337                $setup_info['phpgwapi']['currentver'] = '0.9.10pre8';
338                return $setup_info['phpgwapi']['currentver'];
339                //return True;
340        }
341
342        $test[] = '0.9.10pre8';
343        function phpgwapi_upgrade0_9_10pre8()
344        {
345                global $setup_info, $phpgw_setup;
346
347                $phpgw_setup->oProc->RenameColumn('phpgw_sessions', 'session_info', 'session_action');
348                $phpgw_setup->oProc->AlterColumn('phpgw_sessions', 'session_action', array('type' => 'varchar', 'precision' => '255'));
349
350                $setup_info['phpgwapi']['currentver'] = '0.9.10pre9';
351                return $setup_info['phpgwapi']['currentver'];
352                //return True;
353        }
354
355        $test[] = '0.9.10pre9';
356        function phpgwapi_upgrade0_9_10pre9()
357        {
358                global $setup_info, $phpgw_setup;
359
360                $phpgw_setup->oProc->RenameTable('preferences','phpgw_preferences');
361
362                $setup_info['phpgwapi']['currentver'] = '0.9.10pre10';
363                return $setup_info['phpgwapi']['currentver'];
364                //return True;
365        }
366
367        $test[] = '0.9.10pre10';
368        function phpgwapi_upgrade0_9_10pre10()
369        {
370                global $setup_info, $phpgw_setup;
371
372                $newtbldef = array(
373                        "fd" => array(
374                                'acl_appname' => array('type' => 'varchar', 'precision' => 50),
375                                'acl_location' => array('type' => 'varchar', 'precision' => 255),
376                                'acl_account' => array('type' => 'int', 'precision' => 4),
377                                'acl_rights' => array('type' => 'int', 'precision' => 4)
378                        ),
379                        'pk' => array(),
380                        'ix' => array(),
381                        'fk' => array(),
382                        'uc' => array()
383                );
384
385                $phpgw_setup->oProc->DropColumn('phpgw_acl',$newtbldef,'acl_account_type');
386
387                $setup_info['phpgwapi']['currentver'] = '0.9.10pre11';
388                return $setup_info['phpgwapi']['currentver'];
389                //return True;
390        }
391
392        $test[] = '0.9.10pre11';
393        function phpgwapi_upgrade0_9_10pre11()
394        {
395                global $setup_info;
396                $setup_info['phpgwapi']['currentver'] = '0.9.10pre12';
397                return $setup_info['phpgwapi']['currentver'];
398                //return True;
399        }
400
401        $test[] = '0.9.10pre12';
402        function phpgwapi_upgrade0_9_10pre12()
403        {
404                global $setup_info, $phpgw_setup;
405
406                $db1 = $phpgw_setup->db;
407
408                $phpgw_setup->oProc->CreateTable(
409                        'phpgw_addressbook', array(
410                                'fd' => array(
411                                        'id'           => array('type' => 'auto', 'nullable' => False),
412                                        'lid'          => array('type' => 'varchar', 'precision' => 32),
413                                        'tid'          => array('type' => 'char', 'precision' => 1),
414                                        'owner'        => array('type' => 'int', 'precision' => 4),
415                                        'fn'           => array('type' => 'varchar', 'precision' => 64),
416                                        'sound'        => array('type' => 'varchar', 'precision' => 64),
417                                        'org_name'     => array('type' => 'varchar', 'precision' => 64),
418                                        'org_unit'     => array('type' => 'varchar', 'precision' => 64),
419                                        'title'        => array('type' => 'varchar', 'precision' => 64),
420                                        'n_family'     => array('type' => 'varchar', 'precision' => 64),
421                                        'n_given'      => array('type' => 'varchar', 'precision' => 64),
422                                        'n_middle'     => array('type' => 'varchar', 'precision' => 64),
423                                        'n_prefix'     => array('type' => 'varchar', 'precision' => 64),
424                                        'n_suffix'     => array('type' => 'varchar', 'precision' => 64),
425                                        'label'        => array('type' => 'text'),
426                                        'adr_poaddr'   => array('type' => 'varchar', 'precision' => 64),
427                                        'adr_extaddr'  => array('type' => 'varchar', 'precision' => 64),
428                                        'adr_street'   => array('type' => 'varchar', 'precision' => 64),
429                                        'adr_locality' => array('type' => 'varchar', 'precision' => 32),
430                                        'adr_region'   => array('type' => 'varchar', 'precision' => 32),
431                                        'adr_postalcode'  => array('type' => 'varchar', 'precision' => 32),
432                                        'adr_countryname' => array('type' => 'varchar', 'precision' => 32),
433                                        'adr_work'     => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
434                                        'adr_home'     => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
435                                        'adr_parcel'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
436                                        'adr_postal'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
437                                        'tz'           => array('type' => 'varchar', 'precision' => 8),
438                                        'geo'          => array('type' => 'varchar', 'precision' => 32),
439                                        'a_tel'        => array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
440                                        'a_tel_work'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
441                                        'a_tel_home'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
442                                        'a_tel_voice'  => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
443                                        'a_tel_msg'    => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
444                                        'a_tel_fax'    => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
445                                        'a_tel_prefer' => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
446                                        'b_tel'        => array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
447                                        'b_tel_work'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
448                                        'b_tel_home'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
449                                        'b_tel_voice'  => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
450                                        'b_tel_msg'    => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
451                                        'b_tel_fax'    => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
452                                        'b_tel_prefer' => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
453                                        'c_tel'        => array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
454                                        'c_tel_work'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
455                                        'c_tel_home'   => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
456                                        'c_tel_voice'  => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
457                                        'c_tel_msg'    => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
458                                        'c_tel_fax'    => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
459                                        'c_tel_prefer' => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
460                                        'd_emailtype'  => array('type' => 'varchar', 'precision' => 32),
461                                        'd_email'      => array('type' => 'varchar', 'precision' => 64),
462                                        'd_email_work' => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False),
463                                        'd_email_home' => array('type' => 'char', 'precision' => '1', 'default' => 'n', 'nullable' => False)
464                                ),
465                                'pk' => array('id'),
466                                'fk' => array(),
467                                'ix' => array(),
468                                'uc' => array('id')
469                        )
470                );
471
472                $phpgw_setup->oProc->CreateTable(
473                        'phpgw_addressbook_extra', array(
474                                'fd' => array(
475                                        'contact_id'    => array('type' => 'int',     'precision' => 4),
476                                        'contact_owner' => array('type' => 'int',     'precision' => 4),
477                                        'contact_name'  => array('type' => 'varchar', 'precision' => 255),
478                                        'contact_value' => array('type' => 'varchar', 'precision' => 255)
479                                ),
480                                'pk' => array(),
481                                'fk' => array(),
482                                'ix' => array(),
483                                'uc' => array()
484                        )
485                );
486
487                $phpgw_setup->oProc->query("SELECT * FROM addressbook");
488                /* echo '<br>numrows: ' . $phpgw_setup->oProc->num_rows; */
489
490                while ($phpgw_setup->oProc->next_record())
491                {
492                        $fields = $extra = array();
493
494                        $fields['id']         = $phpgw_setup->oProc->f('ab_id');
495                        $fields['owner']      = addslashes($phpgw_setup->oProc->f('ab_owner'));
496                        $fields['n_given']    = addslashes($phpgw_setup->oProc->f('ab_firstname'));
497                        $fields['n_family']   = addslashes($phpgw_setup->oProc->f('ab_lastname'));
498                        $fields['d_email']    = addslashes($phpgw_setup->oProc->f('ab_email'));
499                        $fields['b_tel']      = addslashes($phpgw_setup->oProc->f('ab_hphone'));
500                        $fields['a_tel']      = addslashes($phpgw_setup->oProc->f('ab_wphone'));
501                        $fields['c_tel']      = addslashes($phpgw_setup->oProc->f('ab_fax'));
502                        $fields['fn']         = addslashes($phpgw_setup->oProc->f('ab_firstname').' '.$phpgw_setup->oProc->f('ab_lastname'));
503                        $fields['a_tel_work'] = 'y';
504                        $fields['b_tel_home'] = 'y';
505                        $fields['c_tel_fax']  = 'y';
506                        $fields['org_name']   = addslashes($phpgw_setup->oProc->f('ab_company'));
507                        $fields['title']      = addslashes($phpgw_setup->oProc->f('ab_title'));
508                        $fields['adr_street'] = addslashes($phpgw_setup->oProc->f('ab_street'));
509                        $fields['adr_locality']   = addslashes($phpgw_setup->oProc->f('ab_city'));
510                        $fields['adr_region']     = addslashes($phpgw_setup->oProc->f('ab_state'));
511                        $fields['adr_postalcode'] = addslashes($phpgw_setup->oProc->f('ab_zip'));
512
513                        $extra['pager']       = $phpgw_setup->oProc->f('ab_pager');
514                        $extra['mphone']      = $phpgw_setup->oProc->f('ab_mphone');
515                        $extra['ophone']      = $phpgw_setup->oProc->f('ab_ophone');
516                        $extra['bday']        = $phpgw_setup->oProc->f('ab_bday');
517                        $extra['notes']       = $phpgw_setup->oProc->f('ab_notes');
518                        $extra['address2']    = $phpgw_setup->oProc->f('ab_address2');
519                        $extra['url']         = $phpgw_setup->oProc->f('ab_url');
520
521                        $sql = "INSERT INTO phpgw_addressbook (org_name,n_given,n_family,fn,d_email,title,a_tel,a_tel_work,"
522                                . "b_tel,b_tel_home,c_tel,c_tel_fax,adr_street,adr_locality,adr_region,adr_postalcode,owner)"
523                                . " VALUES ('".$fields['org_name']."','".$fields['n_given']."','".$fields['n_family']."','"
524                                . $fields['fn']."','".$fields['d_email']."','".$fields['title']."','".$fields['a_tel']."','"
525                                . $fields['a_tel_work']."','".$fields['b_tel']."','".$fields['b_tel_home']."','"
526                                . $fields['c_tel']."','".$fields['c_tel_fax']."','".$fields['adr_street']."','"
527                                . $fields['adr_locality']."','".$fields['adr_region']."','".$fields['adr_postalcode']."','"
528                                . $fields['owner'] ."')";
529
530                        $db1->query($sql);
531
532                        while (list($name,$value) = each($extra))
533                        {
534                                $sql = "INSERT INTO phpgw_addressbook_extra VALUES ('".$fields['id']."','" . $fields['owner'] . "','"
535                                        . addslashes($name) . "','" . addslashes($value) . "')";
536                                $db1->query($sql);
537                        }
538                }
539                $setup_info['phpgwapi']['currentver'] = '0.9.10pre13';
540                return $setup_info['phpgwapi']['currentver'];
541                //return True;
542                // Note we are still leaving the old addressbook table alone here... for third party apps if they need it
543        }
544
545        $test[] = '0.9.10pre13';
546        function phpgwapi_upgrade0_9_10pre13()
547        {
548                global $setup_info, $phpgw_setup;
549
550                $db1 = $phpgw_setup->db;
551
552                $phpgw_setup->oProc->AddColumn('phpgw_addressbook', 'url',  array('type' => 'varchar', 'precision' => 128));
553                $phpgw_setup->oProc->AddColumn('phpgw_addressbook', 'bday', array('type' => 'varchar', 'precision' => 32));
554                $phpgw_setup->oProc->AddColumn('phpgw_addressbook', 'note', array('type' => 'text'));
555                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook_extra', 'contact_value', array('type' => 'text'));
556
557                $sql = "SELECT * FROM phpgw_addressbook_extra WHERE contact_name='url'";
558                $phpgw_setup->oProc->query($sql,__LINE__,__FILE__);
559
560                while($phpgw_setup->oProc->next_record())
561                {
562                        $cid   = $phpgw_setup->oProc->f('contact_id');
563                        $cvalu = $phpgw_setup->oProc->f('contact_value');
564                        if ($cid && $cvalu)
565                        {
566                                $update = "UPDATE phpgw_addressbook SET url='" . $cvalu . "' WHERE id=" . $cid;
567                                $db1->query($update);
568                                $delete = "DELETE FROM phpgw_addressbook_extra WHERE contact_id=" . $cid . " AND contact_name='url'";
569                                $db1->query($delete);
570                        }
571                }
572
573                $sql = "SELECT * FROM phpgw_addressbook_extra WHERE contact_name='bday'";
574                $phpgw_setup->oProc->query($sql,__LINE__,__FILE__);
575
576                while($phpgw_setup->oProc->next_record())
577                {
578                        $cid   = $phpgw_setup->oProc->f('contact_id');
579                        $cvalu = $phpgw_setup->oProc->f('contact_value');
580                        if ($cid && $cvalu)
581                        {
582                                $update = "UPDATE phpgw_addressbook set bday='" . $cvalu . "' WHERE id=" . $cid;
583                                $db1->query($update);
584                                $delete = "DELETE FROM phpgw_addressbook_extra WHERE contact_id=" . $cid . " AND contact_name='bday'";
585                                $db1->query($delete);
586                        }
587                }
588
589                $sql = "SELECT * FROM phpgw_addressbook_extra WHERE contact_name='notes'";
590                $phpgw_setup->oProc->query($sql,__LINE__,__FILE__);
591
592                while($phpgw_setup->oProc->next_record())
593                {
594                        $cid   = $phpgw_setup->oProc->f('contact_id');
595                        $cvalu = $phpgw_setup->oProc->f('contact_value');
596                        if ($cvalu)
597                        {
598                                $update = "UPDATE phpgw_addressbook set note='" . $cvalu . "' WHERE id=" . $cid;
599                                $db1->query($update);
600                                $delete = "DELETE FROM phpgw_addressbook_extra WHERE contact_id=" . $cid . " AND contact_name='notes'";
601                                $db1->query($delete);
602                        }
603                }
604                $setup_info['phpgwapi']['currentver'] = '0.9.10pre14';
605                return $setup_info['phpgwapi']['currentver'];
606                //return True;
607        }
608
609        $test[] = '0.9.10pre14';
610        function phpgwapi_upgrade0_9_10pre14()
611        {
612                global $setup_info, $phpgw_setup;
613
614                $phpgw_setup->oProc->AddColumn('phpgw_sessions','session_flags', array('type' => 'char', 'precision' => 2));
615
616                $setup_info['phpgwapi']['currentver'] = '0.9.10pre15';
617                return $setup_info['phpgwapi']['currentver'];
618                //return True;
619        }
620
621        $test[] = '0.9.10pre15';
622        function phpgwapi_upgrade0_9_10pre15()
623        {
624                global $setup_info, $phpgw_setup;
625
626                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'adr_work',      array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
627                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'adr_home',      array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
628                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'adr_parcel',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
629                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'adr_postal',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
630                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'a_tel_work',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
631                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'a_tel_home',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
632                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'a_tel_voice',   array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
633                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'a_tel_msg',     array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
634                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'a_tel_fax',     array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
635                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'a_tel_prefer',  array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
636                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'b_tel_work',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
637                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'b_tel_home',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
638                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'b_tel_voice',   array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
639                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'b_tel_msg',     array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
640                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'b_tel_fax',     array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
641                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'b_tel_prefer',  array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
642                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'c_tel_work',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
643                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'c_tel_home',    array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
644                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'c_tel_voice',   array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
645                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'c_tel_msg',     array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
646                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'c_tel_fax',     array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
647                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'c_tel_prefer',  array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
648                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'd_email_work',  array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
649                $phpgw_setup->oProc->AlterColumn('phpgw_addressbook', 'd_email_home',  array('type' => 'char', 'precision' => 1, 'default' => 'n', 'nullable' => False));
650
651                $setup_info['addressbook']['currentver'] = '0.9.10pre16';
652                return $setup_info['addressbook']['currentver'];
653                //return True;
654        }
655
656        $test[] = '0.9.10pre16';
657        function phpgwapi_upgrade0_9_10pre16()
658        {
659                global $setup_info, $phpgw_setup;
660
661                $db1 = $phpgw_setup->db;
662
663                $phpgw_setup->oProc->RenameTable('phpgw_addressbook', 'phpgw_addressbook_old');
664                $phpgw_setup->oProc->CreateTable(
665                        'phpgw_addressbook', array(
666                                'fd' => array(
667                                        'id' =>                  array('type' => 'auto', 'nullable' => False),
668                                        'lid' =>                 array('type' => 'varchar', 'precision' => 32),
669                                        'tid' =>                 array('type' => 'char', 'precision' => 1),
670                                        'owner' =>               array('type' => 'int', 'precision' => 4),
671                                        'fn' =>                  array('type' => 'varchar', 'precision' => 64),
672                                        'n_family' =>            array('type' => 'varchar', 'precision' => 64),
673                                        'n_given' =>             array('type' => 'varchar', 'precision' => 64),
674                                        'n_middle' =>            array('type' => 'varchar', 'precision' => 64),
675                                        'n_prefix' =>            array('type' => 'varchar', 'precision' => 64),
676                                        'n_suffix' =>            array('type' => 'varchar', 'precision' => 64),
677                                        'sound' =>               array('type' => 'varchar', 'precision' => 64),
678                                        'bday' =>                array('type' => 'varchar', 'precision' => 32),
679                                        'note' =>                array('type' => 'text'),
680                                        'tz' =>                  array('type' => 'varchar', 'precision' => 8),
681                                        'geo' =>                 array('type' => 'varchar', 'precision' => 32),
682                                        'url' =>                 array('type' => 'varchar', 'precision' => 128),
683                                        'org_name' =>            array('type' => 'varchar', 'precision' => 64),
684                                        'org_unit' =>            array('type' => 'varchar', 'precision' => 64),
685                                        'title' =>               array('type' => 'varchar', 'precision' => 64),
686                                        'adr_one_street' =>      array('type' => 'varchar', 'precision' => 64),
687                                        'adr_one_locality' =>    array('type' => 'varchar', 'precision' => 32),
688                                        'adr_one_region' =>      array('type' => 'varchar', 'precision' => 32),
689                                        'adr_one_postalcode' =>  array('type' => 'varchar', 'precision' => 32),
690                                        'adr_one_countryname' => array('type' => 'varchar', 'precision' => 32),
691                                        'adr_one_type' =>        array('type' => 'varchar', 'precision' => 64),
692                                        'label' =>               array('type' => 'text'),
693                                        'adr_two_street' =>      array('type' => 'varchar', 'precision' => 64),
694                                        'adr_two_locality' =>    array('type' => 'varchar', 'precision' => 32),
695                                        'adr_two_region' =>      array('type' => 'varchar', 'precision' => 32),
696                                        'adr_two_postalcode' =>  array('type' => 'varchar', 'precision' => 32),
697                                        'adr_two_type' =>        array('type' => 'varchar', 'precision' => 64),
698                                        'tel_work' =>            array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
699                                        'tel_home' =>            array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
700                                        'tel_voice' =>           array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
701                                        'tel_fax' =>             array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
702                                        'tel_msg' =>             array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
703                                        'tel_cell' =>            array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
704                                        'tel_pager' =>           array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
705                                        'tel_bbs' =>             array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
706                                        'tel_modem' =>           array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
707                                        'tel_car' =>             array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
708                                        'tel_isdn' =>            array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
709                                        'tel_video' =>           array('type' => 'varchar', 'precision' => 40, 'default' => '+1 (000) 000-0000', 'nullable' => False),
710                                        'tel_prefer' =>          array('type' => 'varchar', 'precision' => 32),
711                                        'email' =>               array('type' => 'varchar', 'precision' => 64),
712                                        'email_type' =>          array('type' => 'varchar', 'precision' => 32, 'default' => 'INTERNET'),
713                                        'email_home' =>          array('type' => 'varchar', 'precision' => 64),
714                                        'email_home_type' =>     array('type' => 'varchar', 'precision' => 32, 'default' => 'INTERNET')
715                                ),
716                                'pk' => array('id'),
717                                'fk' => array(),
718                                'ix' => array(),
719                                'uc' => array()
720                        )
721                );
722
723                $phpgw_setup->oProc->query("SELECT * FROM phpgw_addressbook_old");
724                while ($phpgw_setup->oProc->next_record())
725                {
726                        $fields['id']                  = $phpgw_setup->oProc->f("id");
727                        $fields['owner']               = $phpgw_setup->oProc->f("owner");
728                        $fields['n_given']             = $phpgw_setup->oProc->f("firstname");
729                        $fields['n_family']            = $phpgw_setup->oProc->f("lastname");
730                        $fields['email']               = $phpgw_setup->oProc->f("d_email");
731                        $fields['email_type']          = $phpgw_setup->oProc->f("d_emailtype");
732                        $fields['tel_home']            = $phpgw_setup->oProc->f("b_tel");
733                        $fields['tel_work']            = $phpgw_setup->oProc->f("a_tel");
734                        $fields['tel_fax']             = $phpgw_setup->oProc->f("c_tel");
735                        $fields['fn']                  = $phpgw_setup->oProc->f("fn");
736                        $fields['org_name']            = $phpgw_setup->oProc->f("org_name");
737                        $fields['title']               = $phpgw_setup->oProc->f("title");
738                        $fields['adr_one_street']      = $phpgw_setup->oProc->f("adr_street");
739                        $fields['adr_one_locality']    = $phpgw_setup->oProc->f("adr_locality");
740                        $fields['adr_one_region']      = $phpgw_setup->oProc->f("adr_region");
741                        $fields['adr_one_postalcode']  = $phpgw_setup->oProc->f("adr_postalcode");
742                        $fields['adr_one_countryname'] = $phpgw_setup->oProc->f("adr_countryname");
743                        $fields['bday']                = $phpgw_setup->oProc->f("bday");
744                        $fields['note']                = $phpgw_setup->oProc->f("note");
745                        $fields['url']                 = $phpgw_setup->oProc->f("url");
746
747                        $sql="INSERT INTO phpgw_addressbook (org_name,n_given,n_family,fn,email,email_type,title,tel_work,"
748                                . "tel_home,tel_fax,adr_one_street,adr_one_locality,adr_one_region,adr_one_postalcode,adr_one_countryname,"
749                                . "owner,bday,url,note)"
750                                . " VALUES ('".$fields["org_name"]."','".$fields["n_given"]."','".$fields["n_family"]."','"
751                                . $fields["fn"]."','".$fields["email"]."','".$fields["email_type"]."','".$fields["title"]."','".$fields["tel_work"]."','"
752                                . $fields["tel_home"]."','".$fields["tel_fax"] ."','".$fields["adr_one_street"]."','"
753                                . $fields["adr_one_locality"]."','".$fields["adr_one_region"]."','".$fields["adr_one_postalcode"]."','"
754                                . $fields["adr_one_countryname"]."','".$fields["owner"] ."','".$fields["bday"]."','".$fields["url"]."','".$fields["note"]."')";
755
756                        $db1->query($sql,__LINE__,__FILE__);
757                }
758 
759                $phpgw_setup->oProc->query("DROP TABLE phpgw_addressbook_old");
760 
761                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_home=''   WHERE tel_home='n'   OR tel_home='y'");
762                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_work=''   WHERE tel_work='n'   OR tel_work='y'");
763                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_cell=''   WHERE tel_cell='n'   OR tel_cell='y'");
764                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_voice=''  WHERE tel_voice='n'  OR tel_voice='y'");
765                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_fax=''    WHERE tel_fax='n'    OR tel_fax='y'");
766                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_car=''    WHERE tel_car='n'    OR tel_car='y'");
767                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_pager=''  WHERE tel_pager='n'  OR tel_pager='y'");
768                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_msg=''    WHERE tel_msg='n'    OR tel_msg='y'");
769                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_bbs=''    WHERE tel_bbs='n'    OR tel_bbs='y'");
770                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_modem=''  WHERE tel_modem='n'  OR tel_modem='y'");
771                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_prefer='' WHERE tel_prefer='n' OR tel_prefer='y'");
772                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_video=''  WHERE tel_video='n'  OR tel_video='y'");
773                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tel_isdn=''   WHERE tel_isdn='n'   OR tel_isdn='y'");
774
775                $sql = "SELECT * FROM phpgw_addressbook_extra WHERE contact_name='mphone'";
776                $phpgw_setup->oProc->query($sql,__LINE__,__FILE__);
777
778                while($phpgw_setup->oProc->next_record())
779                {
780                        $cid   = $phpgw_setup->oProc->f('contact_id');
781                        $cvalu = $phpgw_setup->oProc->f('contact_value');
782                        if ($cvalu)
783                        {
784                                $update = "UPDATE phpgw_addressbook SET tel_cell='" . $cvalu . "' WHERE id=" . $cid;
785                                $db1->query($update);
786                                $delete = "DELETE FROM phpgw_addressbook_extra WHERE contact_id=" . $cid . " AND contact_name='mphone'";
787                                $db1->query($delete);
788                        }
789                }
790                $setup_info['phpgwapi']['currentver'] = '0.9.10pre17';
791                return $setup_info['phpgwapi']['currentver'];
792                //return True;
793        }
794
795        $test[] = '0.9.10pre17';
796        function phpgwapi_upgrade0_9_10pre17()
797        {
798                global $phpgw_info, $phpgw_setup;
799
800                $phpgw_setup->oProc->AddColumn('phpgw_addressbook','pubkey', array('type' => 'text'));
801                $phpgw_setup->oProc->AddColumn('phpgw_addressbook','adr_two_countryname', array('type' => 'varchar', 'precision' => 32));
802
803                $setup_info['phpgwapi']['currentver'] = '0.9.10pre18';
804                return $setup_info['phpgwapi']['currentver'];
805                //return True;
806        }
807
808        $test[] = '0.9.10pre18';
809        function phpgwapi_upgrade0_9_10pre18()
810        {
811                global $setup_info, $phpgw_setup;
812
813                $phpgw_setup->oProc->CreateTable(
814                        'phpgw_nextid', array(
815                                'fd' => array(
816                                        'appname' => array('type' => 'varchar', 'precision' => 25),
817                                        'id' => array('type' => 'int', 'precision' => 4)
818                                ),
819                                'pk' => array(),
820                                'fk' => array(),
821                                'ix' => array(),
822                                'uc' => array('appname')
823                        )
824                );
825
826                $setup_info['phpgwapi']['currentver'] = '0.9.10pre19';
827                return $setup_info['phpgwapi']['currentver'];
828                //return True;
829        }
830
831        $test[] = '0.9.10pre19';
832        function phpgwapi_upgrade0_9_10pre19()
833        {
834                global $setup_info, $phpgw_setup;
835
836                $phpgw_setup->oProc->DropTable('phpgw_nextid');
837
838                $phpgw_setup->oProc->CreateTable(
839                        'phpgw_nextid', array(
840                                'fd' => array(
841                                        'appname' => array('type' => 'varchar', 'precision' => 25, 'nullable' => False),
842                                        'id' => array('type' => 'int', 'precision' => 4)
843                                ),
844                                'pk' => array(),
845                                'fk' => array(),
846                                'ix' => array(),
847                                'uc' => array('appname')
848                        )
849                );
850
851                $setup_info['phpgwapi']['currentver'] = '0.9.10pre20';
852                return $setup_info['phpgwapi']['currentver'];
853                //return True;
854        }
855        $test[] = '0.9.10pre20';
856        function phpgwapi_upgrade0_9_10pre20()
857        {
858                global $setup_info, $phpgw_setup;
859
860                $phpgw_setup->oProc->AddColumn('phpgw_addressbook', 'access', array('type' => 'char', 'precision' => 7));
861
862                $setup_info['phpgwapi']['currentver'] = '0.9.10pre21';
863                return $setup_info['phpgwapi']['currentver'];
864                //return True;
865        }
866
867        $test[] = '0.9.10pre21';
868        function phpgwapi_upgrade0_9_10pre21()
869        {
870                global $setup_info, $phpgw_setup;
871
872                $phpgw_setup->oProc->AddColumn('phpgw_addressbook', 'cat_id', array('type' => 'varchar', 'precision' => 32));
873
874                $setup_info['phpgwapi']['currentver'] = '0.9.10pre22';
875                return $setup_info['phpgwapi']['currentver'];
876                //return True;
877        }
878
879        $test[] = '0.9.10pre22';
880        function phpgwapi_upgrade0_9_10pre22()
881        {
882                global $setup_info;
883                $setup_info['phpgwapi']['currentver'] = '0.9.10pre23';
884                return $setup_info['phpgwapi']['currentver'];
885                //return True;
886        }
887
888        $test[] = '0.9.10pre23';
889        function phpgwapi_upgrade0_9_10pre23()
890        {
891                global $setup_info, $phpgw_setup;
892
893                $phpgw_setup->oProc->query("UPDATE phpgw_addressbook SET tid='n' WHERE tid is null");
894
895                $setup_info['phpgwapi']['currentver'] = '0.9.10pre24';
896                return $setup_info['phpgwapi']['currentver'];
897                //return True;
898        }
899
900        $test[] = '0.9.10pre24';
901        function phpgwapi_upgrade0_9_10pre24()
902        {
903                global $setup_info, $phpgw_setup;
904
905                $phpgw_setup->oProc->AlterColumn('phpgw_categories','cat_access', array('type' => 'char', 'precision' => 7));
906
907                $setup_info['phpgwapi']['currentver'] = '0.9.10pre25';
908                return $setup_info['phpgwapi']['currentver'];
909                //return True;
910        }
911
912        $test[] = '0.9.10pre25';
913        function phpgwapi_upgrade0_9_10pre25()
914        {
915                global $setup_info, $phpgw_setup;
916
917                $phpgw_setup->oProc->AddColumn('phpgw_app_sessions','session_dla', array('type' => 'int', 'precision' => 4));
918
919                $setup_info['phpgwapi']['currentver'] = '0.9.10pre26';
920                return $setup_info['phpgwapi']['currentver'];
921                //return True;
922        }
923
924        $test[] = '0.9.10pre26';
925        function phpgwapi_upgrade0_9_10pre26()
926        {
927                global $setup_info;
928                $setup_info['phpgwapi']['currentver'] = '0.9.10pre27';
929                return $setup_info['phpgwapi']['currentver'];
930                //return True;
931        }
932
933        $test[] = '0.9.10pre27';
934        function phpgwapi_upgrade0_9_10pre27()
935        {
936                global $setup_info, $phpgw_setup;
937
938                $phpgw_setup->oProc->AlterColumn('phpgw_app_sessions', 'content', array('type' => 'longtext'));
939
940                $setup_info['phpgwapi']['currentver'] = '0.9.10pre28';
941                return $setup_info['phpgwapi']['currentver'];
942                //return True;
943        }
944
945        $test[] = '0.9.10pre28';
946        function phpgwapi_upgrade0_9_10pre28()
947        {
948                global $setup_info;
949                $setup_info['phpgwapi']['currentver'] = '0.9.10';
950                return $setup_info['phpgwapi']['currentver'];
951                //return True;
952        }
953?>
Note: See TracBrowser for help on using the repository browser.