Changeset 3031


Ignore:
Timestamp:
07/12/10 10:39:22 (14 years ago)
Author:
niltonneto
Message:

Ticket #1135 - Ajuste da atualização do header.inc.php, setup dos módulos e API.

Location:
branches/2.2
Files:
5 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/admin/setup/setup.inc.php

    r1728 r3031  
    1212 
    1313        $setup_info['admin']['name']      = 'admin'; 
    14         $setup_info['admin']['version']   = '2.1.000'; 
     14        $setup_info['admin']['version']   = '2.2.000'; 
    1515        $setup_info['admin']['app_order'] = 1; 
    1616        $setup_info['admin']['tables']    = ''; 
     
    4747        $setup_info['admin']['depends'][] = array( 
    4848                'appname' => 'phpgwapi', 
    49                 'versions' => Array('2.1') 
     49                'versions' => Array('2.2') 
    5050        ); 
    5151?> 
  • branches/2.2/calendar/setup/setup.inc.php

    r1728 r3031  
    1212 
    1313        $setup_info['calendar']['name']    = 'calendar'; 
    14         $setup_info['calendar']['version'] = '2.1.000'; 
     14        $setup_info['calendar']['version'] = '2.2.000'; 
    1515        $setup_info['calendar']['app_order'] = 3; 
    1616        $setup_info['calendar']['enable']  = 1; 
     
    5252        $setup_info['calendar']['depends'][] = array( 
    5353                 'appname' => 'phpgwapi', 
    54                  'versions' => Array('2.1') 
     54                 'versions' => Array('2.2') 
    5555        ); 
  • branches/2.2/calendar/setup/tables_update.inc.php

    r1835 r3031  
    1919                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE ".$table." ADD COLUMN ".$column." ".$attrs); 
    2020        }   
    21         $test[] = '0.9.2'; 
    22         function calendar_upgrade0_9_2() 
    23         { 
    24                 $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.17'; 
    25                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    26         } 
    27         $test[] = '0.9.17'; 
    28         function calendar_upgrade0_9_17() 
    29         { 
    30                 $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.21'; 
    31                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    32         } 
    33         $test[] = '0.9.20'; 
    34         function calendar_upgrade0_9_20() 
    35         { 
    36                 $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.21'; 
    37                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    38         }        
    39         $test[] = '0.9.21'; 
    40         function calendar_upgrade0_9_21() 
    41         { 
    42                 addSpecialColumn("phpgw_cal","last_status","char(1) DEFAULT 'N'::bpchar"); 
    43                 addSpecialColumn("phpgw_cal","last_update","int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision)"); 
    44                 $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.22'; 
    45                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    46         }        
    47         $test[] = '0.9.22'; 
    48         function calendar_upgrade0_9_22() 
    49         { 
    50                 $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.23'; 
    51                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    52         } 
    53         $test[] = '0.9.23'; 
    54         function calendar_upgrade0_9_23() 
    55         { 
    56                 $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.3'; 
    57                 return $GLOBALS['setup_info']['calendar']['currentver']; 
    58         }        
     21/// Since Expresso 1.2 using Calendar 0.9.3  
    5922        $test[] = '0.9.3'; 
    6023        function calendar_upgrade0_9_3() 
     
    7841        function calendar_upgrade2_0_002() 
    7942        { 
     43                $GLOBALS['setup_info']['calendar']['currentver'] = '2.0.003'; 
     44                return $GLOBALS['setup_info']['calendar']['currentver']; 
     45        } 
     46        $test[] = '2.0.003'; 
     47        function calendar_upgrade2_0_003() 
     48        { 
     49                $GLOBALS['setup_info']['calendar']['currentver'] = '2.0.004'; 
     50                return $GLOBALS['setup_info']['calendar']['currentver']; 
     51        }        
     52        $test[] = '2.0.004'; 
     53        function calendar_upgrade2_0_004() 
     54        { 
     55                $GLOBALS['setup_info']['calendar']['currentver'] = '2.0.005'; 
     56                return $GLOBALS['setup_info']['calendar']['currentver']; 
     57        }        
     58        $test[] = '2.0.005'; 
     59        function calendar_upgrade2_0_005() 
     60        { 
    8061                $GLOBALS['setup_info']['calendar']['currentver'] = '2.1.000'; 
    8162                return $GLOBALS['setup_info']['calendar']['currentver']; 
    8263        } 
     64        $test[] = '2.1.000'; 
     65        function calendar_upgrade2_1_000() 
     66        { 
     67                $GLOBALS['setup_info']['calendar']['currentver'] = '2.2.000'; 
     68                return $GLOBALS['setup_info']['calendar']['currentver']; 
     69        } 
    8370?> 
  • branches/2.2/contactcenter/setup/setup.inc.php

    r1728 r3031  
    1717        $setup_info['contactcenter']['name']      = 'contactcenter'; 
    1818        $setup_info['contactcenter']['title']     = 'ContactCenter'; 
    19         $setup_info['contactcenter']['version']   = '2.1.000'; 
     19        $setup_info['contactcenter']['version']   = '2.2.000'; 
    2020        $setup_info['contactcenter']['app_order'] = 4; 
    2121        $setup_info['contactcenter']['enable']    = 1; 
     
    7676        $setup_info['contactcenter']['depends'][] = array( 
    7777                'appname' => 'phpgwapi', 
    78                 'versions' => Array('2.1') 
     78                'versions' => Array('2.2') 
    7979        ); 
    8080?> 
  • branches/2.2/contactcenter/setup/tables_update.inc.php

    r1728 r3031  
    99        * option) any later version.                                               * 
    1010        \**************************************************************************/     
    11         $test[] = '0.4.1'; 
    12         function contactcenter_upgrade0_4_1() { 
    13                  
    14                 $oProc = $GLOBALS['phpgw_setup']->oProc; 
    15                 $oProc->DropTable('phpgw_cc_city'); 
    16                 $oProc->DropTable('phpgw_cc_state'); 
    17                 $oProc->CreateTable( 
    18                         'phpgw_cc_state',array( 
    19                                 'fd' => array( 
    20                                         'id_state' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false), 
    21                                         'id_country' => array( 'type' => 'char', 'nullable' => false, 'precision' => 2), 
    22                                         'state_name' => array( 'type' => 'varchar', 'precision' => 30), 
    23                                         'state_symbol' => array( 'type' => 'varchar', 'precision' => 10) 
    24                                 ), 
    25                                 'pk' => array('id_state'), 
    26                                 'fk' => array('id_country' => array('phpgw_common_country_list' => 'id_country')), 
    27                                 'ix' => array(), 
    28                                 'uc' => array() 
    29                         ) 
    30                 ); 
    31                 $oProc->CreateTable( 
    32                         'phpgw_cc_city', array( 
    33                                 'fd' => array( 
    34                                         'id_city' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false ), 
    35                                         'id_state' => array( 'type' => 'int', 'precision' => 8 ), 
    36                                         'id_country' => array( 'type' => 'char', 'nullable' => false, 'precision' => 2), 
    37                                         'city_timezone' => array( 'type' => 'int', 'precision' => 2 ), 
    38                                         'city_geo_location' => array(  'type'  => 'varchar', 'precision' => 40 ), 
    39                                         'city_name' => array( 'type'  => 'varchar', 'precision' => 60, 'nullable' => 'false' ),                          
    40                                 ), 
    41                                 'pk' => array('id_city'), 
    42                                 'fk' => array('id_state'   => array('phpgw_cc_state' => 'id_state')     ), 
    43                                 'ix' => array(), 
    44                                 'uc' => array() 
    45                         )                
    46                 );               
    47                  
    48                 include("states_pt-br.inc.php");  
    49                 include("cities_pt-br.inc.php"); 
    50                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.0.0'; 
    51                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    52         } 
    53         $test[] = '1.0.0'; 
    54         function contactcenter_upgrade1_0_0() { 
    55                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.0.005'; 
    56                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    57         } 
    58         $test[] = '1.0.005'; 
    59         function contactcenter_upgrade1_0_005() { 
    60                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.14'; 
    61                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    62         } 
    63         $test[] = '1.14'; 
    64         function contactcenter_upgrade1_14() {                           
    65                 $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_connections ALTER COLUMN connection_value TYPE varchar(100)"); 
    66                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.15'; 
    67                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    68         } 
    69         $test[] = '1.15'; 
    70         function contactcenter_upgrade1_15() {           
    71                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_contact','last_status', array('type' => 'char', 'precision' => 1, 'default' => 'N')); 
    72                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_contact','category', array('type' => 'varchar', 'precision' => 20));                                 
    73                 // Verify if last_update column exists..... 
    74                 $GLOBALS['phpgw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['phpgw_setup']->oProc,'phpgw_cc_contact', &$sColumns); 
    75                 if(array_search("last_update",explode(",",$sColumns)) === FALSE) { 
    76                         $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN last_update int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision)"); 
    77                 } 
    78                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.20'; 
    79                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    80         } 
    81         $test[] = '1.20'; 
    82         function contactcenter_upgrade1_20() { 
    83                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.20.001'; 
    84                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    85         } 
    86         $test[] = '1.20.001'; 
    87         function contactcenter_upgrade1_20_001() { 
    88                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.21'; 
    89                 // Verify if plpgsql language is installed. 
    90                 $res = $GLOBALS['phpgw_setup']->db->query("select lanname from pg_language where lanname = 'plpgsql'"); 
    91                 if(!strstr($res,'plpgsql')){ 
    92                         $GLOBALS['phpgw_setup']->db->query("create language 'plpgsql'"); 
    93                 }                
    94                 // Verify if trigger Insert() for Shared Contacts exists, else create it..... 
    95                 $res = $GLOBALS['phpgw_setup']->db->query("select tgname from pg_trigger where tgname = 'trig_share_catalog_insert'"); 
    96                 if(!strstr($res,'trig_share_catalog_insert')){ 
    97                         $GLOBALS['phpgw_setup']->db->query("create function share_catalog_insert() returns trigger as ' begin if ". 
    98                                 "new.acl_appname = ''contactcenter'' and  new.acl_location <> ''run'' then ". 
    99                                 "insert into phpgw_cc_contact_rels (id_contact,id_related,id_typeof_contact_relation) ". 
    100                                 "values (new.acl_location::integer,new.acl_account,1); end if; return new; end;' language 'plpgsql';");          
    101  
    102                         $GLOBALS['phpgw_setup']->db->query("create trigger trig_share_catalog_insert after insert on phpgw_acl for " . 
    103                                 "each row execute procedure share_catalog_insert()");  
    104                 } 
    105                 // Verify if trigger Delete() for Shared Contacts exists, else create it..... 
    106                 $res = $GLOBALS['phpgw_setup']->db->query("select tgname from pg_trigger where tgname = 'trig_share_catalog_delete'");           
    107                 if(!strstr($res,'trig_share_catalog_delete')){ 
    108                         $GLOBALS['phpgw_setup']->db->query("create function share_catalog_delete() returns trigger as ' begin if " . 
    109                                                                 "old.acl_appname = ''contactcenter'' then delete from phpgw_cc_contact_rels where " . 
    110                                                                 "id_contact=old.acl_location and id_related=old.acl_account and " . 
    111                                                                 "id_typeof_contact_relation=1; end if; return new; end;' language 'plpgsql'"); 
    112          
    113                         $GLOBALS['phpgw_setup']->db->query("create trigger trig_share_catalog_delete after delete on phpgw_acl for " . 
    114                                 "each row execute procedure share_catalog_delete()"); 
    115                 } 
    116                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    117         } 
     11        // Since Expresso 1.2 using ContactCenter 1.21 
    11812        $test[] = '1.21'; 
    11913        function contactcenter_upgrade1_21() { 
     
    12923        function contactcenter_upgrade2_0_000() { 
    13024                $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.0.001'; 
     25                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
     26        } 
     27        $test[] = '2.0.001'; 
     28        function contactcenter_upgrade2_0_001() { 
     29                $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.0.002'; 
     30                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
     31        }                
     32        $test[] = '2.0.002'; 
     33        function contactcenter_upgrade2_0_002() { 
     34                $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.1.000'; 
     35                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
     36        }        
     37        $test[] = '2.1.000'; 
     38        function contactcenter_upgrade2_1_000() {                
    13139                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN web_page character varying(100)"); 
    13240                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN corporate_name character varying(100)"); 
    13341                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN job_title character varying(40)"); 
    13442                $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN department character varying(30)"); 
     43                $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.2.000'; 
    13544                return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    136         } 
    137         $test[] = '2.0.001'; 
    138         function contactcenter_upgrade2_0_001() { 
    139                 $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.1.000'; 
    140                 return $GLOBALS['setup_info']['contactcenter']['currentver']; 
    141         } 
     45        }        
    14246?> 
  • branches/2.2/emailadmin/setup/setup.inc.php

    r1728 r3031  
    1414        $setup_info['emailadmin']['name']      = 'emailadmin'; 
    1515        $setup_info['emailadmin']['title']     = 'EMailAdmin'; 
    16         $setup_info['emailadmin']['version']   = '2.1.000'; 
     16        $setup_info['emailadmin']['version']   = '2.2.000'; 
    1717        $setup_info['emailadmin']['app_order'] = 10; 
    1818        $setup_info['emailadmin']['enable']    = 2; 
     
    4040        $setup_info['emailadmin']['depends'][] = array( 
    4141                'appname'  => 'phpgwapi', 
    42                 'versions' => Array('2.1') 
     42                'versions' => Array('2.2') 
    4343        ); 
    4444 
  • branches/2.2/emailadmin/setup/tables_update.inc.php

    r1728 r3031  
    9292   $test[] = '2.0.000'; 
    9393   function emailadmin_upgrade2_0_000() 
    94         { 
    95       $GLOBALS['setup_info']['emailadmin']['currentver'] = '2.0.001'; 
     94        {       
    9695      $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_emailadmin','imapcreatespamfolder', array('type' => 'varchar', 'precision' => 3)); 
    9796      $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_emailadmin','imapcyrususerpostspam', array('type' => 'varchar', 'precision' => 30)); 
     97          $GLOBALS['setup_info']['emailadmin']['currentver'] = '2.1.000';       
    9898      return $GLOBALS['setup_info']['emailadmin']['currentver']; 
    9999   } 
    100    $test[] = '2.0.001'; 
    101    function emailadmin_upgrade2_0_001() 
     100   $test[] = '2.1.000'; 
     101   function emailadmin_upgrade2_1_000() 
    102102        { 
    103       $GLOBALS['setup_info']['emailadmin']['currentver'] = '2.1.000'; 
     103      $GLOBALS['setup_info']['emailadmin']['currentver'] = '2.2.000'; 
    104104      return $GLOBALS['setup_info']['emailadmin']['currentver']; 
    105105   } 
  • branches/2.2/expressoAdmin1_2/setup/setup.inc.php

    r1728 r3031  
    1313        $setup_info['expressoAdmin1_2']['title']        = 'Expresso Admin'; 
    1414        /* Ao incrementar versão, não esquecer de declarar função do tables_update.inc.php*/ 
    15         $setup_info['expressoAdmin1_2']['version']      = '2.1.000'; 
     15        $setup_info['expressoAdmin1_2']['version']      = '2.2.000'; 
    1616        $setup_info['expressoAdmin1_2']['app_order']    = 1; 
    1717        $setup_info['expressoAdmin1_2']['tables'][]             = 'phpgw_expressoadmin'; 
     
    3535        $setup_info['expressoAdmin1_2']['depends'][] = array( 
    3636                'appname' => 'phpgwapi', 
    37                 'versions' => Array('2.1') 
     37                'versions' => Array('2.2') 
    3838        ); 
    3939?> 
  • branches/2.2/expressoAdmin1_2/setup/tables_update.inc.php

    r1836 r3031  
    99        * option) any later version.                                               * 
    1010        \**************************************************************************/     
    11         $test[] = '1.2'; 
    12         function expressoAdmin1_2_upgrade1_2() 
    13         { 
    14                 $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '1.21'; 
    15                 return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
    16         } 
    17          
    18         $test[] = '1.21'; 
    19         function expressoAdmin1_2_upgrade1_21() 
    20         { 
    21                 $oProc = $GLOBALS['phpgw_setup']->oProc; 
    22  
    23                 $oProc->CreateTable( 
    24                         'phpgw_expressoadmin_samba', array( 
    25                                 'fd' => array( 
    26                                         'samba_domain_name' => array( 'type' => 'varchar', 'precision' => 50), 
    27                                         'samba_domain_sid' => array( 'type' => 'varchar', 'precision' => 100) 
    28                                 ), 
    29                                 'pk' => array('samba_domain_name'), 
    30                                 'fk' => array(), 
    31                                 'ix' => array(), 
    32                                 'uc' => array() 
    33                         ) 
    34                 ); 
    35                  
    36                 $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '1.240'; 
    37                 return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
    38         } 
    39  
    40         $test[] = '1.240'; 
    41         function expressoAdmin1_2_upgrade1_240() 
    42         { 
    43                 $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '1.250'; 
    44                 return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
    45         } 
    46          
    47         $test[] = '1.250'; 
    48         function expressoAdmin1_2_upgrade1_250() 
    49         { 
    50                 $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_expressoadmin_log','','appinfo'); 
    51                 $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_expressoadmin_log','','groupinfo'); 
    52                 $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_expressoadmin_log','','msg'); 
    53                 $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '1.261'; 
    54                 return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
    55         } 
    56          
     11        // Since Expresso 1.2 using ExpressoAdmin 1.261 
    5712        $test[] = '1.261'; 
    5813        function expressoAdmin1_2_upgrade1_261() 
     
    7025        function expressoAdmin1_2_upgrade2_0_001() 
    7126        { 
     27                $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '2.0.002'; 
     28                return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
     29        }        
     30        $test[] = '2.0.002'; 
     31        function expressoAdmin1_2_upgrade2_0_002() 
     32        { 
     33                $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '2.0.003'; 
     34                return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
     35        }        
     36        $test[] = '2.0.003'; 
     37        function expressoAdmin1_2_upgrade2_0_003() 
     38        { 
     39                $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '2.0.004'; 
     40                return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
     41        }                
     42        $test[] = '2.0.004'; 
     43        function expressoAdmin1_2_upgrade2_0_004() 
     44        { 
    7245                $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '2.1.000'; 
    7346                return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
    7447        } 
    75  
     48        $test[] = '2.1.000'; 
     49        function expressoAdmin1_2_upgrade2_1_000() 
     50        { 
     51                $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '2.2.000'; 
     52                return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver']; 
     53        } 
    7654?> 
  • branches/2.2/expressoMail1_2/setup/setup.inc.php

    r1728 r3031  
    1212        $setup_info['expressoMail1_2']['name']          = 'expressoMail1_2'; 
    1313        $setup_info['expressoMail1_2']['title']         = 'Expresso Mail'; 
    14         $setup_info['expressoMail1_2']['version']       = '2.1.000'; 
     14        $setup_info['expressoMail1_2']['version']       = '2.2.000'; 
    1515        $setup_info['expressoMail1_2']['app_order']     = 2; 
    1616        $setup_info['expressoMail1_2']['tables'][]              = 'phpgw_expressomail_contacts'; 
     
    3737        $setup_info['expressoMail1_2']['depends'][] = array( 
    3838                'appname' => 'phpgwapi', 
    39                 'versions' => Array('2.1') 
     39                'versions' => Array('2.2') 
    4040        ); 
    4141?> 
  • branches/2.2/expressoMail1_2/setup/tables_update.inc.php

    r1835 r3031  
    99        * option) any later version.                                               * 
    1010        \**************************************************************************/ 
    11         $test[] = '1.2031'; 
    12         function expressoMail1_2_upgrade1_2031() { 
    13                 $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.2201'; 
    14                 return $GLOBALS['setup_info']['expressoMail1_2']['currentver']; 
    15         } 
    16          
    17         $test[] = '1.2201'; 
    18         function expressoMail1_2_upgrade1_2201() { 
    19                 $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.2211'; 
    20                 return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];          
    21         } 
    22          
    23         $test[] = '1.2211'; 
    24         function expressoMail1_2_upgrade1_2211() { 
    25                 $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.222'; 
    26                 return $GLOBALS['setup_info']['expressoMail1_2']['currentver']; 
    27         } 
    28  
    29         $test[] = '1.222'; 
    30         function expressoMail1_2_upgrade1_222() { 
    31                 $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.230'; 
    32                 return $GLOBALS['setup_info']['expressoMail1_2']['currentver']; 
    33         } 
    34          
    35         $test[] = '1.230'; 
    36         function expressoMail1_2_upgrade1_230() { 
    37                 $oProc = $GLOBALS['phpgw_setup']->oProc; 
    38                 $oProc->CreateTable('phpgw_expressomail_contacts',array( 
    39                         'fd' => array( 
    40                                 'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false), 
    41                                 'data' => array( 'type' => 'text') 
    42                         ), 
    43                         'pk' => array('id_owner'), 
    44                         'fk' => array(), 
    45                         'ix' => array(), 
    46                         'uc' => array() ) 
    47                 ); 
    48                 $setup_info['expressoMail1_2']['currentver'] = '1.231'; 
    49                 return $setup_info['expressoMail1_2']['currentver']; 
    50         }                
    51         $test[] = '1.231';                                                                                                       
    52         function expressoMail1_2_upgrade1_231() { 
    53                 $setup_info['expressoMail1_2']['currentver'] = '1.232'; 
    54                 return $setup_info['expressoMail1_2']['currentver']; 
    55         } 
    56          
    57         $test[] = '1.232'; 
    58         function expressoMail1_2_upgrade1_232() { 
    59                 $setup_info['expressoMail1_2']['currentver'] = '1.233'; 
    60                 return $setup_info['expressoMail1_2']['currentver']; 
    61         } 
    62          
     11        //      Since Expresso 1.2 using ExpressoMail 1.233              
    6312        $test[] = '1.233'; 
    6413        function expressoMail1_2_upgrade1_233() { 
     
    6615                return $setup_info['expressoMail1_2']['currentver']; 
    6716        } 
    68          
    6917        $test[] = '1.234'; 
    7018        function expressoMail1_2_upgrade1_234() { 
     
    10553        $test[] = '2.0.002'; 
    10654        function expressoMail1_2_upgrade2_0_002() { 
     55                $setup_info['expressoMail1_2']['currentver'] = '2.0.003'; 
     56                return $setup_info['expressoMail1_2']['currentver']; 
     57        } 
     58        $test[] = '2.0.003'; 
     59        function expressoMail1_2_upgrade2_0_003() { 
     60                $setup_info['expressoMail1_2']['currentver'] = '2.0.004'; 
     61                return $setup_info['expressoMail1_2']['currentver']; 
     62        } 
     63        $test[] = '2.0.004'; 
     64        function expressoMail1_2_upgrade2_0_004() { 
     65                $setup_info['expressoMail1_2']['currentver'] = '2.0.005'; 
     66                return $setup_info['expressoMail1_2']['currentver']; 
     67        }        
     68        $test[] = '2.0.005'; 
     69        function expressoMail1_2_upgrade2_0_005() { 
     70                $setup_info['expressoMail1_2']['currentver'] = '2.0.006'; 
     71                return $setup_info['expressoMail1_2']['currentver']; 
     72        }        
     73        $test[] = '2.0.006'; 
     74        function expressoMail1_2_upgrade2_0_006() { 
     75                $setup_info['expressoMail1_2']['currentver'] = '2.0.007'; 
     76                return $setup_info['expressoMail1_2']['currentver']; 
     77        }                
     78        $test[] = '2.0.007'; 
     79        function expressoMail1_2_upgrade2_0_007() { 
    10780                $setup_info['expressoMail1_2']['currentver'] = '2.1.000'; 
    10881                return $setup_info['expressoMail1_2']['currentver']; 
    10982        } 
     83        $test[] = '2.1.000'; 
     84        function expressoMail1_2_upgrade2_1_000() { 
     85                $setup_info['expressoMail1_2']['currentver'] = '2.2.000'; 
     86                return $setup_info['expressoMail1_2']['currentver']; 
     87        }        
    11088?> 
  • branches/2.2/filemanager/setup/setup.inc.php

    r3019 r3031  
    4747        ( 
    4848                 'appname' => 'phpgwapi', 
    49                  'versions' => array('2.0.004') 
     49                 'versions' => array('2.2') 
    5050        ); 
    5151?> 
  • branches/2.2/help/setup/setup.inc.php

    r1728 r3031  
    1313        $setup_info['help']['name']      = 'help'; 
    1414        $setup_info['help']['title']     = 'User Manual and Help Page'; 
    15         $setup_info['help']['version']   = '2.1.000'; 
     15        $setup_info['help']['version']   = '2.2.000'; 
    1616        $setup_info['help']['app_order'] = 5; 
    1717        $setup_info['help']['enable']    = 2;   // Invisible on top (navigation bar) 
     
    2626        $setup_info['help']['depends'][] = array( 
    2727                 'appname' => 'phpgwapi', 
    28                  'versions' => Array('2.1') 
     28                 'versions' => Array('2.2') 
    2929        ); 
    3030?> 
  • branches/2.2/jabberit_messenger/setup/setup.inc.php

    r3030 r3031  
    88        $setup_info['jabberit_messenger']['name']       = 'jabberit_messenger'; 
    99        $setup_info['jabberit_messenger']['title']      = 'Jeti Applet'; 
    10         $setup_info['jabberit_messenger']['version']    = '2.1.000'; 
     10        $setup_info['jabberit_messenger']['version']    = '2.2.000'; 
    1111        $setup_info['jabberit_messenger']['app_order']  = 9; 
    1212        $setup_info['jabberit_messenger']['enable']     = 1; 
  • branches/2.2/mobile/setup/setup.inc.php

    r1728 r3031  
    1414        $setup_info['mobile']['name']      = 'mobile'; 
    1515        $setup_info['mobile']['title']     = 'ExpressoMini'; 
    16         $setup_info['mobile']['version']   = '2.1.000'; 
     16        $setup_info['mobile']['version']   = '2.2.000'; 
    1717        $setup_info['mobile']['app_order'] = 4; 
    1818        $setup_info['mobile']['enable']    = 2; 
     
    3939        $setup_info['mobile']['depends'][] = array( 
    4040                'appname' => 'phpgwapi', 
    41                 'versions' => Array('2.1') 
     41                'versions' => Array('2.2') 
    4242        ); 
    4343?> 
  • branches/2.2/news_admin/setup/setup.inc.php

    r1728 r3031  
    1414        $setup_info['news_admin']['name']      = 'news_admin'; 
    1515        //$setup_info['news_admin']['title']     = 'News Admin'; 
    16         $setup_info['news_admin']['version']   = '2.1.000'; 
     16        $setup_info['news_admin']['version']   = '2.2.000'; 
    1717        $setup_info['news_admin']['app_order'] = 16; 
    1818        $setup_info['news_admin']['enable']    = 1; 
     
    3131        $setup_info['news_admin']['depends'][] = array( 
    3232                 'appname' => 'phpgwapi', 
    33                  'versions' => Array('2.1') 
     33                 'versions' => Array('2.2') 
    3434        ); 
    3535 
  • branches/2.2/news_admin/setup/tables_update.inc.php

    r1835 r3031  
    1212        * http://www.goldenglair.com                                               * 
    1313        \**************************************************************************/ 
    14  
    15  
    16         $test[] = '0.0.1'; 
    17         function news_admin_upgrade0_0_1() 
    18         { 
    19                 global $setup_info; 
    20  
    21                 $setup_info['news_admin']['currentver'] = '0.8.1'; 
    22                 return $setup_info['news_admin']['currentver']; 
    23         } 
    24  
    25         $test[] = '0.8.1'; 
    26         function news_admin_upgrade0_8_1() 
    27         { 
    28                 global $setup_info, $phpgw_setup; 
    29  
    30                 $phpgw_setup->oProc->RenameTable('webpage_news','phpgw_news'); 
    31  
    32                 $setup_info['news_admin']['currentver'] = '0.8.1.001'; 
    33                 return $setup_info['news_admin']['currentver']; 
    34         } 
    35  
    36         $test[] = '0.8.1.001'; 
    37         function news_admin_upgrade0_8_1_001() 
    38         { 
    39                 global $setup_info, $phpgw_setup; 
    40  
    41                 $phpgw_setup->oProc->AddColumn('phpgw_news','news_cat',array('type' => 'int','precision' => 4,'nullable' => True)); 
    42                 $phpgw_setup->oProc->query("update phpgw_news set news_cat='0'",__LINE__,__FILE__); 
    43  
    44                 $setup_info['news_admin']['currentver'] = '0.8.1.002'; 
    45                 return $setup_info['news_admin']['currentver']; 
    46         } 
    47  
    48         $test[] = '0.8.1.002'; 
    49         function news_admin_upgrade0_8_1_002() 
    50         { 
    51                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_news','news_teaser',array( 
    52                         'type' => 'varchar', 
    53                         'precision' => '255', 
    54                         'nullable' => True 
    55                 )); 
    56  
    57  
    58                 $GLOBALS['setup_info']['news_admin']['currentver'] = '0.9.14.500'; 
    59                 return $GLOBALS['setup_info']['news_admin']['currentver']; 
    60         } 
    61  
    62         $test[] = '0.9.14.500'; 
    63         function news_admin_upgrade0_9_14_500() 
    64         { 
    65                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_news_export',array( 
    66                         'fd' => array( 
    67                                 'cat_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    68                                 'export_type' => array('type' => 'int','precision' => '2','nullable' => True), 
    69                                 'export_itemsyntax' => array('type' => 'int','precision' => '2','nullable' => True), 
    70                                 'export_title' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    71                                 'export_link' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    72                                 'export_description' => array('type' => 'text', 'nullable' => True), 
    73                                 'export_img_title' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    74                                 'export_img_url' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    75                                 'export_img_link' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    76                         ), 
    77                         'pk' => array('cat_id'), 
    78                         'fk' => array(), 
    79                         'ix' => array(), 
    80                         'uc' => array() 
    81                 )); 
    82  
    83                 $GLOBALS['setup_info']['news_admin']['currentver'] = '0.9.14.501'; 
    84                 return $GLOBALS['setup_info']['news_admin']['currentver']; 
    85         } 
    86  
    87         $test[] = '0.9.14.501'; 
    88         function news_admin_upgrade0_9_14_501() 
    89         { 
    90                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_news','news_begin',array( 
    91                         'type' => 'int','precision' => '4','nullable' => True 
    92                 )); 
    93                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_news','news_end',array( 
    94                         'type' => 'int','precision' => '4','nullable' => True 
    95                 )); 
    96                 $db2 = $GLOBALS['phpgw_setup']->db; 
    97                 $GLOBALS['phpgw_setup']->oProc->query('SELECT news_id,news_status FROM phpgw_news'); 
    98                 while($GLOBALS['phpgw_setup']->oProc->next_record()) 
    99                 { 
    100                         $unixtimestampmax = 2147483647; 
    101                         $db2->query('UPDATE phpgw_news SET news_begin=news_date,news_end=' .  
    102                                 (($GLOBALS['phpgw_setup']->oProc->f('news_status') == 'Active') ? $unixtimestampmax : 'news_date') . 
    103                                 ' WHERE news_id=' . $GLOBALS['phpgw_setup']->oProc->f('news_id')); 
    104                 } 
    105                 $newtbldef = array( 
    106                         'fd' => array( 
    107                                 'news_id' => array('type' => 'auto','nullable' => False), 
    108                                 'news_date' => array('type' => 'int','precision' => '4','nullable' => True), 
    109                                 'news_subject' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    110                                 'news_submittedby' => array('type' => 'varchar','precision' => '255','nullable' => True), 
    111                                 'news_content' => array('type' => 'blob','nullable' => True), 
    112                                 'news_begin' => array('type' => 'int','precision' => '4','nullable' => True), 
    113                                 'news_end' => array('type' => 'int','precision' => '4','nullable' => True), 
    114                                 'news_cat' => array('type' => 'int','precision' => '4','nullable' => True), 
    115                                 'news_teaser' => array('type' => 'varchar','precision' => '255','nullable' => True) 
    116                         ), 
    117                         'pk' => array('news_id'), 
    118                         'fk' => array(), 
    119                         'ix' => array('news_date','news_subject'), 
    120                         'uc' => array() 
    121                 ); 
    122                 $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_news',$newtbldef,'news_status'); 
    123  
    124                 $GLOBALS['setup_info']['news_admin']['currentver'] = '0.9.14.502'; 
    125                 return $GLOBALS['setup_info']['news_admin']['currentver']; 
    126         } 
    127  
    128  
    129         $test[] = '0.9.14.502'; 
    130         function news_admin_upgrade0_9_14_502() 
    131         { 
    132                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_news','is_html',array( 
    133                         'type' => 'int', 
    134                         'precision' => '2', 
    135                         'nullable' => False, 
    136                         'default' => '0' 
    137                 )); 
    138  
    139  
    140                 $GLOBALS['setup_info']['news_admin']['currentver'] = '0.9.14.503'; 
    141                 return $GLOBALS['setup_info']['news_admin']['currentver']; 
    142         } 
    143  
    144  
    145         $test[] = '0.9.14.503'; 
    146         function news_admin_upgrade0_9_14_503() 
    147         { 
    148                 $GLOBALS['setup_info']['news_admin']['currentver'] = '1.0.0'; 
    149                 return $GLOBALS['setup_info']['news_admin']['currentver']; 
    150         } 
     14        // Since Expresso 1.2 using news_admin 1.0.0  
    15115        $test[] = '1.0.0'; 
    15216        function news_admin_upgrade1_0_0() 
     
    16731                return $GLOBALS['setup_info']['news_admin']['currentver']; 
    16832        } 
     33        $test[] = '2.1.000'; 
     34        function news_admin_upgrade2_1_000() 
     35        { 
     36                $GLOBALS['setup_info']['news_admin']['currentver'] = '2.2.000'; 
     37                return $GLOBALS['setup_info']['news_admin']['currentver']; 
     38        }        
    16939?> 
  • branches/2.2/phpgwapi/setup/setup.inc.php

    r1728 r3031  
    1414        $setup_info['phpgwapi']['name']      = 'phpgwapi'; 
    1515        $setup_info['phpgwapi']['title']     = 'phpgwapi'; 
    16         $setup_info['phpgwapi']['version']   = '2.1.000'; 
    17         $setup_info['phpgwapi']['versions']['current_header'] = '2.0'; 
     16        $setup_info['phpgwapi']['version']   = '2.2.000'; 
     17        $setup_info['phpgwapi']['versions']['current_header'] = '2.2'; 
    1818        $setup_info['phpgwapi']['enable']    = 3; 
    1919        $setup_info['phpgwapi']['app_order'] = 1; 
     
    3333        $setup_info['phpgwapi']['tables'][]  = 'phpgw_nextid'; 
    3434        $setup_info['phpgwapi']['tables'][]  = 'phpgw_categories'; 
    35         /* 
    36         $setup_info['phpgwapi']['tables'][]  = 'phpgw_addressbook'; 
    37         $setup_info['phpgwapi']['tables'][]  = 'phpgw_addressbook_extra'; 
    38         */ 
    3935        $setup_info['phpgwapi']['tables'][]  = 'phpgw_log'; 
    4036        $setup_info['phpgwapi']['tables'][]  = 'phpgw_log_msg'; 
    41         /*$setup_info['phpgwapi']['tables'][]  = 'phpgw_interserv';*/ 
    4237        $setup_info['phpgwapi']['tables'][]  = 'phpgw_vfs'; 
    4338        $setup_info['phpgwapi']['tables'][]  = 'phpgw_history_log'; 
    4439        $setup_info['phpgwapi']['tables'][]  = 'phpgw_async'; 
    4540 
    46         /* Basic information about this app */ 
    47         /* 
    48         $setup_info['notifywindow']['name']      = 'notifywindow'; 
    49         $setup_info['notifywindow']['title']     = 'Notify Window'; 
    50         $setup_info['notifywindow']['version']   = '1.0.0'; 
    51         $setup_info['notifywindow']['enable']    = 2; 
    52         $setup_info['notifywindow']['app_order'] = 1; 
    53         $setup_info['notifywindow']['tables']    = ''; 
    54         $setup_info['notifywindow']['hooks'][]   = 'home'; 
    55         */ 
    5641 
    5742 
    5843 
    59  
    60  
  • branches/2.2/phpgwapi/setup/tables_update.inc.php

    r1835 r3031  
    1010        \**************************************************************************/ 
    1111 
    12  
    13         /* Include older phpGroupWare update support */ 
    14         include('tables_update_0_9_9.inc.php'); 
    15         include('tables_update_0_9_10.inc.php'); 
    16         include('tables_update_0_9_12.inc.php'); 
    17  
    18         /* This is since the last release */ 
    19         $test[] = '0.9.12'; 
    20         function phpgwapi_upgrade0_9_12() 
    21         { 
    22                 global $setup_info,$phpgw_setup; 
    23                 $setup_info['phpgwapi']['currentver'] = '0.9.13.001'; 
    24                 return $setup_info['phpgwapi']['currentver']; 
    25         } 
    26  
    27         $test[] = '0.9.13.001'; 
    28         function phpgwapi_upgrade0_9_13_001() 
    29         { 
    30                 global $setup_info,$phpgw_setup; 
    31  
    32                 $phpgw_setup->oProc->AlterColumn('phpgw_categories','cat_access', array('type' => 'varchar', 'precision' => 7)); 
    33  
    34                 $setup_info['phpgwapi']['currentver'] = '0.9.13.002'; 
    35                 return $setup_info['phpgwapi']['currentver']; 
    36         } 
    37  
    38         $test[] = '0.9.13.002'; 
    39         function phpgwapi_upgrade0_9_13_002() 
    40         { 
    41                 global $setup_info,$phpgw_setup; 
    42  
    43                 $phpgw_setup->oProc->AddColumn('phpgw_accounts','account_file_space', array ('type' => 'varchar', 'precision' => 25)); 
    44  
    45                 $setup_info['phpgwapi']['currentver'] = '0.9.13.003'; 
    46                 return $setup_info['phpgwapi']['currentver']; 
    47         } 
    48  
    49         $test[] = '0.9.13.003'; 
    50         function phpgwapi_upgrade0_9_13_003() 
    51         { 
    52                 global $setup_info,$phpgw_setup; 
    53  
    54                 $phpgw_setup->oProc->AlterColumn('phpgw_access_log','sessionid',array('type' => 'char', 'precision' => 32)); 
    55  
    56                 $setup_info['phpgwapi']['currentver'] = '0.9.13.004'; 
    57                 return $setup_info['phpgwapi']['currentver']; 
    58         } 
    59  
    60         $test[] = '0.9.13.004'; 
    61         function phpgwapi_upgrade0_9_13_004() 
    62         { 
    63                 global $setup_info, $phpgw_setup; 
    64  
    65                 $phpgw_setup->oProc->AddColumn('phpgw_access_log','account_id',array('type' => 'int', 'precision' => 4, 'default' => 0, 'nullable' => False)); 
    66  
    67                 $phpgw_setup->setup_account_object(); 
    68  
    69                 $phpgw_setup->oProc->query("select * from phpgw_access_log"); 
    70                 while($phpgw_setup->oProc->next_record()) 
    71                 { 
    72                         $lid         = explode('@',$phpgw_setup->oProc->f('loginid')); 
    73                         $account_lid = $lid[0]; 
    74                         $account_id = $accounts->name2id($account_lid); 
    75  
    76                         $phpgw_setup->db->query("update phpgw_access_log set account_id='" . $account_id 
    77                                 . "' where sessionid='" . $phpgw_setup->oProc->f('sessionid') . "'"); 
    78                 } 
    79  
    80                 $setup_info['phpgwapi']['currentver'] = '0.9.13.005'; 
    81                 return $setup_info['phpgwapi']['currentver']; 
    82         } 
    83  
    84         $test[] = '0.9.13.005'; 
    85         function phpgwapi_upgrade0_9_13_005() 
    86         { 
    87                 global $setup_info, $phpgw_setup; 
    88  
    89                 $newtbldef = array( 
    90                         'fd' => array( 
    91                                 'account_id' => array('type' => 'auto', 'nullable' => false), 
    92                                 'account_lid' => array('type' => 'varchar', 'precision' => 25, 'nullable' => false), 
    93                                 'account_pwd' => array('type' => 'varchar', 'precision' => 32, 'nullable' => false), 
    94                                 'account_firstname' => array('type' => 'varchar', 'precision' => 50), 
    95                                 'account_lastname' => array('type' => 'varchar', 'precision' => 50), 
    96                                 'account_permissions' => array('type' => 'text'), 
    97                                 'account_groups' => array('type' => 'varchar', 'precision' => 30), 
    98                                 'account_lastlogin' => array('type' => 'int', 'precision' => 4), 
    99                                 'account_lastloginfrom' => array('type' => 'varchar', 'precision' => 255), 
    100                                 'account_lastpwd_change' => array('type' => 'int', 'precision' => 4), 
    101                                 'account_status' => array('type' => 'char', 'precision' => 1, 'nullable' => false, 'default' => 'A'), 
    102                                 'account_expires' => array('type' => 'int', 'precision' => 4), 
    103                                 'account_type' => array('type' => 'char', 'precision' => 1, 'nullable' => true) 
    104                         ), 
    105                         'pk' => array('account_id'), 
    106                         'fk' => array(), 
    107                         'ix' => array(), 
    108                         'uc' => array('account_lid') 
    109                 ); 
    110  
    111                 $phpgw_setup->oProc->DropColumn('phpgw_accounts',$newtbldef,'account_file_space'); 
    112  
    113                 $setup_info['phpgwapi']['currentver'] = '0.9.13.006'; 
    114                 return $setup_info['phpgwapi']['currentver']; 
    115         } 
    116  
    117         $test[] = '0.9.13.006'; 
    118         function phpgwapi_upgrade0_9_13_006() 
    119         { 
    120                 global $setup_info, $phpgw_setup; 
    121  
    122                 $phpgw_setup->oProc->CreateTable( 
    123                         'phpgw_log', array( 
    124                                 'fd' => array( 
    125                                         'log_id'        => array('type' => 'auto',      'precision' => 4,  'nullable' => False), 
    126                                         'log_date'      => array('type' => 'timestamp', 'nullable' => False), 
    127                                         'log_user'      => array('type' => 'int',       'precision' => 4,  'nullable' => False), 
    128                                         'log_app'       => array('type' => 'varchar',   'precision' => 50, 'nullable' => False), 
    129                                         'log_severity'  => array('type' => 'char',  'precision' => 1,  'nullable' => False) 
    130                                 ), 
    131                                 'pk' => array('log_id'), 
    132                                 'fk' => array(), 
    133                                 'ix' => array(), 
    134                                 'uc' => array() 
    135                         ) 
    136                 ); 
    137  
    138                 $phpgw_setup->oProc->CreateTable( 
    139                         'phpgw_log_msg', array( 
    140                                 'fd' => array( 
    141                                         'log_msg_log_id'        => array('type' => 'auto',      'precision' => 4,  'nullable' => False), 
    142                                         'log_msg_seq_no'        => array('type' => 'int',       'precision' => 4,  'nullable' => False), 
    143                                         'log_msg_date'          => array('type' => 'timestamp', 'nullable' => False), 
    144                                         'log_msg_tx_fid'        => array('type' => 'varchar',   'precision' => 4,  'nullable' => True), 
    145                                         'log_msg_tx_id'         => array('type' => 'varchar',   'precision' => 4,  'nullable' => True), 
    146                                         'log_msg_severity'      => array('type' => 'char',      'precision' => 1,  'nullable' => False), 
    147                                         'log_msg_code'          => array('type' => 'varchar',   'precision' => 30, 'nullable' => False), 
    148                                         'log_msg_msg'           => array('type' => 'text', 'nullable' => False), 
    149                                         'log_msg_parms'         => array('type' => 'text', 'nullable' => False) 
    150                                 ), 
    151                                 'pk' => array('log_msg_log_id', 'log_msg_seq_no'), 
    152                                 'fk' => array(), 
    153                                 'ix' => array(), 
    154                                 'uc' => array() 
    155                         ) 
    156                 ); 
    157  
    158                 $setup_info['phpgwapi']['currentver'] = '0.9.13.007'; 
    159                 return $setup_info['phpgwapi']['currentver']; 
    160         } 
    161  
    162         $test[] = '0.9.13.007'; 
    163         function phpgwapi_upgrade0_9_13_007() 
    164         { 
    165                 global $setup_info, $phpgw_setup; 
    166  
    167                 $phpgw_setup->oProc->AlterColumn('phpgw_log_msg','log_msg_log_id',array('type' => 'int', 'precision' => 4, 'nullable'=> False)); 
    168  
    169                 $setup_info['phpgwapi']['currentver'] = '0.9.13.008'; 
    170                 return $setup_info['phpgwapi']['currentver']; 
    171         } 
    172  
    173         $test[] = '0.9.13.008'; 
    174         function phpgwapi_upgrade0_9_13_008() 
    175         { 
    176                 global $setup_info, $phpgw_setup; 
    177  
    178                 $phpgw_setup->oProc->AddColumn('phpgw_log_msg','log_msg_file',array('type' => 'varchar', 'precision' => 255, 'nullable'=> False)); 
    179                 $phpgw_setup->oProc->AddColumn('phpgw_log_msg','log_msg_line',array('type' => 'int', 'precision' => 4, 'nullable'=> False)); 
    180  
    181                 $setup_info['phpgwapi']['currentver'] = '0.9.13.009'; 
    182                 return $setup_info['phpgwapi']['currentver']; 
    183         } 
    184  
    185         $test[] = '0.9.13.009'; 
    186         function phpgwapi_upgrade0_9_13_009() 
    187         { 
    188                 global $setup_info, $phpgw_setup; 
    189  
    190                 $phpgw_setup->oProc->CreateTable( 
    191                         'phpgw_interserv', array( 
    192                                 'fd' => array( 
    193                                         'server_id'   => array('type' => 'auto', 'nullable' => False), 
    194                                         'server_name' => array('type' => 'varchar', 'precision' => 64,  'nullable' => True), 
    195                                         'server_host' => array('type' => 'varchar', 'precision' => 255, 'nullable' => True), 
    196                                         'server_url'  => array('type' => 'varchar', 'precision' => 255, 'nullable' => True), 
    197                                         'trust_level' => array('type' => 'int',     'precision' => 4), 
    198                                         'trust_rel'   => array('type' => 'int',     'precision' => 4), 
    199                                         'username'    => array('type' => 'varchar', 'precision' => 64,  'nullable' => True), 
    200                                         'password'    => array('type' => 'varchar', 'precision' => 255, 'nullable' => True), 
    201                                         'admin_name'  => array('type' => 'varchar', 'precision' => 255, 'nullable' => True), 
    202                                         'admin_email' => array('type' => 'varchar', 'precision' => 255, 'nullable' => True), 
    203                                         'server_mode' => array('type' => 'varchar', 'precision' => 16,  'nullable' => False, 'default' => 'xmlrpc'), 
    204                                         'server_security' => array('type' => 'varchar', 'precision' => 16,'nullable' => True) 
    205                                 ), 
    206                                 'pk' => array('server_id'), 
    207                                 'fk' => array(), 
    208                                 'ix' => array(), 
    209                                 'uc' => array() 
    210                         ) 
    211                 ); 
    212  
    213                 $setup_info['phpgwapi']['currentver'] = '0.9.13.010'; 
    214                 return $setup_info['phpgwapi']['currentver']; 
    215         } 
    216  
    217         $test[] = '0.9.13.010'; 
    218         function phpgwapi_upgrade0_9_13_010() 
    219         { 
    220                 global $setup_info, $phpgw_setup; 
    221  
    222                 $phpgw_setup->oProc->AlterColumn('phpgw_sessions','session_lid',array('type' => 'varchar', 'precision' => 255, 'nullable'=> False)); 
    223  
    224                 $setup_info['phpgwapi']['currentver'] = '0.9.13.011'; 
    225                 return $setup_info['phpgwapi']['currentver']; 
    226         } 
    227  
    228         $test[] = '0.9.13.011'; 
    229         function phpgwapi_upgrade0_9_13_011() 
    230         { 
    231                 global $setup_info, $phpgw_setup; 
    232  
    233                 $phpgw_setup->oProc->CreateTable( 
    234                         'phpgw_vfs', array( 
    235                                 'fd' => array( 
    236                                         'file_id' => array('type' => 'auto','nullable' => False), 
    237                                         'owner_id' => array('type' => 'int', 'precision' => 4,'nullable' => False), 
    238                                         'createdby_id' => array('type' => 'int', 'precision' => 4,'nullable' => True), 
    239                                         'modifiedby_id' => array('type' => 'int', 'precision' => 4,'nullable' => True), 
    240                                         'created' => array('type' => 'date','nullable' => False,'default' => '1970-01-01'), 
    241                                         'modified' => array('type' => 'date','nullable' => True), 
    242                                         'size' => array('type' => 'int', 'precision' => 4,'nullable' => True), 
    243                                         'mime_type' => array('type' => 'varchar', 'precision' => 150,'nullable' => True), 
    244                                         'deleteable' => array('type' => 'char', 'precision' => 1,'nullable' => True,'default' => 'Y'), 
    245                                         'comment' => array('type' => 'text','nullable' => True), 
    246                                         'app' => array('type' => 'varchar', 'precision' => 25,'nullable' => True), 
    247                                         'directory' => array('type' => 'text','nullable' => True), 
    248                                         'name' => array('type' => 'text','nullable' => False), 
    249                                         'link_directory' => array('type' => 'text','nullable' => True), 
    250                                         'link_name' => array('type' => 'text','nullable' => True), 
    251                                         'version' => array('type' => 'varchar', 'precision' => 30,'nullable' => False,'default' => '0.0.0.0') 
    252                                 ), 
    253                                 'pk' => array('file_id'), 
    254                                 'fk' => array(), 
    255                                 'ix' => array(), 
    256                                 'uc' => array() 
    257                         ) 
    258                 ); 
    259                 $setup_info['phpgwapi']['currentver'] = '0.9.13.012'; 
    260                 return $setup_info['phpgwapi']['currentver']; 
    261         } 
    262  
    263         $test[] = '0.9.13.012'; 
    264         function phpgwapi_upgrade0_9_13_012() 
    265         { 
    266                 global $setup_info, $phpgw_setup; 
    267  
    268                 $phpgw_setup->oProc->AlterColumn('phpgw_applications', 'app_tables', array('type' => 'text')); 
    269  
    270                 $setup_info['phpgwapi']['currentver'] = '0.9.13.013'; 
    271                 return $setup_info['phpgwapi']['currentver']; 
    272         } 
    273  
    274         $test[] = '0.9.13.013'; 
    275         function phpgwapi_upgrade0_9_13_013() 
    276         { 
    277                 $GLOBALS['phpgw_setup']->oProc->CreateTable( 
    278                         'phpgw_history_log', array( 
    279                                 'fd' => array( 
    280                                         'history_id'        => array('type' => 'auto',      'precision' => 4,  'nullable' => False), 
    281                                         'history_record_id' => array('type' => 'int',       'precision' => 4,  'nullable' => False), 
    282                                         'history_appname'   => array('type' => 'varchar',   'precision' => 64, 'nullable' => False), 
    283                                         'history_owner'     => array('type' => 'int',       'precision' => 4,  'nullable' => False), 
    284                                         'history_status'    => array('type' => 'char',      'precision' => 2,  'nullable' => False), 
    285                                         'history_new_value' => array('type' => 'text',      'nullable' => False), 
    286                                         'history_timestamp' => array('type' => 'timestamp', 'nullable' => False, 'default' => 'current_timestamp') 
    287  
    288                                 ), 
    289                                 'pk' => array('history_id'), 
    290                                 'fk' => array(), 
    291                                 'ix' => array(), 
    292                                 'uc' => array() 
    293                         ) 
    294                 ); 
    295  
    296                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.13.014'; 
    297                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    298         } 
    299  
    300         $test[] = '0.9.13.014'; 
    301         function phpgwapi_upgrade0_9_13_014() 
    302         { 
    303                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_applications SET app_order=100 WHERE app_order IS NULL"); 
    304                 $GLOBALS['phpgw_setup']->oProc->query("SELECT * FROM phpgw_applications"); 
    305                 while ($GLOBALS['phpgw_setup']->oProc->next_record()) 
    306                 { 
    307                         $app_name[]     = $GLOBALS['phpgw_setup']->oProc->f('app_name'); 
    308                         $app_title[]    = $GLOBALS['phpgw_setup']->oProc->f('app_title'); 
    309                         $app_enabled[]  = $GLOBALS['phpgw_setup']->oProc->f('app_enabled'); 
    310                         $app_order[]    = $GLOBALS['phpgw_setup']->oProc->f('app_order'); 
    311                         $app_tables[]   = $GLOBALS['phpgw_setup']->oProc->f('app_tables'); 
    312                         $app_version[]  = $GLOBALS['phpgw_setup']->oProc->f('app_version'); 
    313                 } 
    314  
    315                 $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_applications'); 
    316  
    317                 $GLOBALS['phpgw_setup']->oProc->CreateTable( 
    318                         'phpgw_applications', array( 
    319                                 'fd' => array( 
    320                                         'app_id' => array('type' => 'auto', 'precision' => 4, 'nullable' => false), 
    321                                         'app_name' => array('type' => 'varchar', 'precision' => 25, 'nullable' => false), 
    322                                         'app_title' => array('type' => 'varchar', 'precision' => 50), 
    323                                         'app_enabled' => array('type' => 'int', 'precision' => 4), 
    324                                         'app_order' => array('type' => 'int', 'precision' => 4), 
    325                                         'app_tables' => array('type' => 'varchar', 'precision' => 255), 
    326                                         'app_version' => array('type' => 'varchar', 'precision' => 20, 'nullable' => false, 'default' => '0.0') 
    327                                 ), 
    328                                 'pk' => array('app_id'), 
    329                                 'fk' => array(), 
    330                                 'ix' => array(), 
    331                                 'uc' => array('app_name') 
    332                         ) 
    333                 ); 
    334  
    335                 $rec_count = count($app_name); 
    336                 for($rec_loop=0;$rec_loop<$rec_count;$rec_loop++) 
    337                 { 
    338                         $GLOBALS['phpgw_setup']->oProc->query('INSERT INTO phpgw_applications(app_id,app_name,app_title,app_enabled,app_order,app_tables,app_version) ' 
    339                                 . 'VALUES('.($rec_loop + 1).",'".$app_name[$rec_loop]."','".$app_title[$rec_loop]."',".$app_enabled[$rec_loop].','.$app_order[$rec_loop].",'".$app_tables[$rec_loop]."','".$app_version[$rec_loop]."')"); 
    340                 } 
    341  
    342                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.13.015'; 
    343                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    344         } 
    345  
    346         $test[] = '0.9.13.015'; 
    347         function phpgwapi_upgrade0_9_13_015() 
    348         { 
    349                 /* Skip this for mysql 3.22.X in php4 at least */ 
    350                 if(phpversion() >= '4.0.5' && @$GLOBALS['phpgw_setup']->db->Type == 'mysql') 
    351                 { 
    352                         $_ver_str = @mysql_get_server_info(); 
    353                         $_ver_arr = explode(".",$_ver_str); 
    354                         $_ver = $_ver_arr[1]; 
    355                         if((int)$_ver < 23) 
    356                         { 
    357                                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.13.016'; 
    358                                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    359                         } 
    360                 } 
    361  
    362                 $GLOBALS['phpgw_setup']->oProc->AlterColumn( 
    363                         'lang', 
    364                         'message_id', 
    365                         array( 
    366                                 'type' => 'varchar', 
    367                                 'precision' => 255, 
    368                                 'nullable' => false, 
    369                                 'default' => '' 
    370                         ) 
    371                 ); 
    372  
    373                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.13.016'; 
    374                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    375         } 
    376  
    377         $test[] = '0.9.13.016'; 
    378         function phpgwapi_upgrade0_9_13_016() 
    379         { 
    380                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','acl_manager','hook_acl_manager.inc.php')"); 
    381                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','add_def_pref','hook_add_def_pref.inc.php')"); 
    382                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','after_navbar','hook_after_navbar.inc.php')"); 
    383                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','deleteaccount','hook_deleteaccount.inc.php')"); 
    384                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','config','hook_config.inc.php')"); 
    385                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','manual','hook_manual.inc.php')"); 
    386                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('admin','view_user','hook_view_user.inc.php')"); 
    387  
    388                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('preferences','admin_deleteaccount','hook_admin_deleteaccount.inc.php')"); 
    389                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('preferences','config','hook_config.inc.php')"); 
    390                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('preferences','manual','hook_manual.inc.php')"); 
    391                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('preferences','preferences','hook_preferences.inc.php')"); 
    392                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('preferences','settings','hook_settings.inc.php')"); 
    393  
    394                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','about','hook_about.inc.php')"); 
    395                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','add_def_pref','hook_add_def_pref.inc.php')"); 
    396                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','config_validate','hook_config_validate.inc.php')"); 
    397                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','deleteaccount','hook_deleteaccount.inc.php')"); 
    398                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','home','hook_home.inc.php')"); 
    399                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','manual','hook_manual.inc.php')"); 
    400                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname,hook_location,hook_filename) VALUES ('addressbook','notifywindow','hook_notifywindow.inc.php')"); 
    401  
    402                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.13.017'; 
    403                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    404         } 
    405  
    406         $test[] = '0.9.13.017'; 
    407         function phpgwapi_upgrade0_9_13_017() 
    408         { 
    409                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_history_log','history_old_value',array('type' => 'text','nullable' => False)); 
    410  
    411                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.13.018'; 
    412                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    413         } 
    414  
    415         $test[] = '0.9.13.018'; 
    416         function phpgwapi_upgrade0_9_13_018() 
    417         { 
    418                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.000'; 
    419                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    420         } 
    421  
    422         $test[] = '0.9.14.000'; 
    423         function phpgwapi_upgrade0_9_14_000() 
    424         { 
    425                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.001'; 
    426                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    427         } 
    428  
    429         $test[] = '0.9.14.001'; 
    430         function phpgwapi_upgrade0_9_14_001() 
    431         { 
    432                 // Fix bug from update script in 0.9.11.004/5: 
    433                 // column config_app was added to table phpgw_config (which places it as last column), 
    434                 // but in the tables_current.inc.php it was added as first column. 
    435                 // When setup / schemaproc wants to do the AlterColum it recreates the table for pgSql, 
    436                 // as pgSql could not change the column-type. This recreation is can not be based on  
    437                 // tables_current, but on running tables_baseline throught all update-scripts. 
    438                 // Which gives at the end two different versions of the table on new or updated installs. 
    439                 // I fix it now in the (wrong) order of the tables_current, as some apps might depend on! 
    440  
    441                 $confs = array(); 
    442                 $GLOBALS['phpgw_setup']->oProc->query("SELECT * FROM phpgw_config"); 
    443                 while ($GLOBALS['phpgw_setup']->oProc->next_record()) 
    444                 { 
    445                         $confs[] = array( 
    446                                 'config_app' => $GLOBALS['phpgw_setup']->oProc->f('config_app'), 
    447                                 'config_name' => $GLOBALS['phpgw_setup']->oProc->f('config_name'), 
    448                                 'config_value' => $GLOBALS['phpgw_setup']->oProc->f('config_value') 
    449                         ); 
    450                 } 
    451                 $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_config'); 
    452  
    453                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_config',array( 
    454                         'fd' => array( 
    455                                 'config_app' => array('type' => 'varchar', 'precision' => 50), 
    456                                 'config_name' => array('type' => 'varchar', 'precision' => 255, 'nullable' => false), 
    457                                 'config_value' => array('type' => 'text') 
    458                         ), 
    459                         'pk' => array(), 
    460                         'fk' => array(), 
    461                         'ix' => array(), 
    462                         'uc' => array('config_name') 
    463                 )); 
    464  
    465                 foreach($confs as $conf) 
    466                 { 
    467                         $GLOBALS['phpgw_setup']->oProc->query( 
    468                                 "INSERT INTO phpgw_config (config_app,config_name,config_value) VALUES ('". 
    469                                 $conf['config_app']."','".$conf['config_name']."','".$conf['config_value']."')"); 
    470                 } 
    471  
    472                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE languages SET available='Yes' WHERE lang_id='cs'"); 
    473  
    474                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.002'; 
    475                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    476         } 
    477  
    478         $test[] = '0.9.14.002'; 
    479         function phpgwapi_upgrade0_9_14_002() 
    480         { 
    481                 // 0.9.14.5xx are the development-versions of the 0.9.16 release (based on the 0.9.14 api) 
    482                 // as 0.9.15.xxx are already used in HEAD 
    483                  
    484                 // this is the 0.9.15.003 update, needed for the new filemanager and vfs-classes in the api 
    485                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_vfs','content', array ('type' => 'text', 'nullable' => True)); 
    486  
    487                 // this is the 0.9.15.004 update, needed for the polish translations 
    488                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE languages set available='Yes' WHERE lang_id='pl'"); 
    489  
    490                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.500'; 
    491                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    492         } 
    493  
    494         $test[] = '0.9.14.003'; 
    495         function phpgwapi_upgrade0_9_14_003() 
    496         { 
    497                 // goes direct to 0.9.14.500 
    498                 return phpgwapi_upgrade0_9_14_002(); 
    499         } 
    500  
    501         $test[] = '0.9.14.004'; 
    502         function phpgwapi_upgrade0_9_14_004() 
    503         { 
    504                 // goes direct to 0.9.14.500 
    505                 return phpgwapi_upgrade0_9_14_002(); 
    506         } 
    507  
    508         $test[] = '0.9.14.005'; 
    509         function phpgwapi_upgrade0_9_14_005() 
    510         { 
    511                 // goes direct to 0.9.14.500 
    512                 return phpgwapi_upgrade0_9_14_002(); 
    513         } 
    514  
    515         $test[] = '0.9.14.006'; 
    516         function phpgwapi_upgrade0_9_14_006() 
    517         { 
    518                 // goes direct to 0.9.14.500 
    519                 return phpgwapi_upgrade0_9_14_002(); 
    520         } 
    521  
    522         $test[] = '0.9.14.007'; 
    523         function phpgwapi_upgrade0_9_14_007() 
    524         { 
    525                 // goes direct to 0.9.14.500 
    526                 return phpgwapi_upgrade0_9_14_002(); 
    527         } 
    528  
    529         $test[] = '0.9.14.500'; 
    530         function phpgwapi_upgrade0_9_14_500() 
    531         { 
    532                 // this is the 0.9.15.001 update 
    533                 $GLOBALS['phpgw_setup']->oProc->RenameTable('lang','phpgw_lang'); 
    534                 $GLOBALS['phpgw_setup']->oProc->RenameTable('languages','phpgw_languages'); 
    535  
    536                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.501'; 
    537                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    538         } 
    539  
    540         $test[] = '0.9.14.501'; 
    541         function phpgwapi_upgrade0_9_14_501() 
    542         { 
    543                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_async',array( 
    544                         'fd' => array( 
    545                                 'id' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    546                                 'next' => array('type' => 'int','precision' => '4','nullable' => False), 
    547                                 'times' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    548                                 'method' => array('type' => 'varchar','precision' => '80','nullable' => False), 
    549                                 'data' => array('type' => 'text','nullable' => False) 
    550                         ), 
    551                         'pk' => array('id'), 
    552                         'fk' => array(), 
    553                         'ix' => array(), 
    554                         'uc' => array() 
    555                 )); 
    556  
    557                 $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_applications',array( 
    558                         'fd' => array( 
    559                                 'app_id' => array('type' => 'auto','precision' => '4','nullable' => False), 
    560                                 'app_name' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    561                                 'app_enabled' => array('type' => 'int','precision' => '4'), 
    562                                 'app_order' => array('type' => 'int','precision' => '4'), 
    563                                 'app_tables' => array('type' => 'text'), 
    564                                 'app_version' => array('type' => 'varchar','precision' => '20','nullable' => False,'default' => '0.0') 
    565                         ), 
    566                         'pk' => array('app_id'), 
    567                         'fk' => array(), 
    568                         'ix' => array(), 
    569                         'uc' => array('app_name') 
    570                 ),'app_title'); 
    571  
    572                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.502'; 
    573                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    574         } 
    575  
    576         $test[] = '0.9.14.502'; 
    577         function phpgwapi_upgrade0_9_14_502() 
    578         { 
    579                 $GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_preferences','old_preferences'); 
    580  
    581                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_preferences',array( 
    582                         'fd' => array( 
    583                                 'preference_owner' => array('type' => 'int','precision' => '4','nullable' => False), 
    584                                 'preference_app' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    585                                 'preference_value' => array('type' => 'text','nullable' => False) 
    586                         ), 
    587                         'pk' => array('preference_owner','preference_app'), 
    588                         'fk' => array(), 
    589                         'ix' => array(), 
    590                         'uc' => array() 
    591                 )); 
    592                 $db2 = $GLOBALS['phpgw_setup']->db;     // we need a 2. result-set 
    593                 $GLOBALS['phpgw_setup']->oProc->query("SELECT * FROM old_preferences"); 
    594                 while ($GLOBALS['phpgw_setup']->oProc->next_record()) 
    595                 { 
    596                         $owner = (int)$GLOBALS['phpgw_setup']->oProc->f('preference_owner'); 
    597                         $prefs = unserialize($GLOBALS['phpgw_setup']->oProc->f('preference_value')); 
    598  
    599                         if (is_array($prefs)) 
    600                         { 
    601                                 foreach ($prefs as $app => $pref) 
    602                                 { 
    603                                         if (!empty($app) && count($pref)) 
    604                                         { 
    605                                                 $app = addslashes($app); 
    606                                                 $pref = serialize($pref); 
    607                                                 $db2->query("INSERT INTO phpgw_preferences". 
    608                                                         " (preference_owner,preference_app,preference_value)". 
    609                                                         " VALUES ($owner,'$app','$pref')"); 
    610                                         } 
    611                                 } 
    612                         } 
    613                 } 
    614                 $GLOBALS['phpgw_setup']->oProc->DropTable('old_preferences'); 
    615  
    616                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.503'; 
    617                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    618         } 
    619  
    620         $test[] = '0.9.14.503'; 
    621         function phpgwapi_upgrade0_9_14_503() 
    622         { 
    623                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_addressbook','last_mod',array( 
    624                         'type' => 'int', 
    625                         'precision' => '4', 
    626                         'nullable' => False 
    627                 )); 
    628  
    629                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.504'; 
    630                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    631         } 
    632  
    633         $test[] = '0.9.14.504'; 
    634         function phpgwapi_upgrade0_9_14_504() 
    635         { 
    636                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_categories','last_mod',array( 
    637                         'type' => 'int', 
    638                         'precision' => '4', 
    639                         'nullable' => False 
    640                 )); 
    641  
    642                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.505'; 
    643                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    644         } 
    645  
    646         $test[] = '0.9.14.505'; 
    647         function phpgwapi_upgrade0_9_14_505() 
    648         { 
    649                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_access_log','lo',array( 
    650                         'type' => 'int', 
    651                         'precision' => '4', 
    652                         'nullable' => True, 
    653                         'default' => '0' 
    654                 )); 
    655  
    656                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.506'; 
    657                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    658         } 
    659  
    660         $test[] = '0.9.14.506'; 
    661         function phpgwapi_upgrade0_9_14_506() 
    662         { 
    663                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_vfs','content',array( 
    664                         'type' => 'text', 
    665                         'nullable' => True 
    666                 )); 
    667  
    668                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.507'; 
    669                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    670         } 
    671  
    672         $test[] = '0.9.14.507'; 
    673         function phpgwapi_upgrade0_9_14_507() 
    674         { 
    675                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_async','account_id',array( 
    676                         'type' => 'int', 
    677                         'precision' => '4', 
    678                         'nullable' => False, 
    679                         'default' => '0' 
    680                 )); 
    681  
    682                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508'; 
    683                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    684         } 
    685  
    686         $test[] = '0.9.14.508'; 
    687         function phpgwapi_upgrade0_9_14_508() 
    688         { 
    689                 // the following if detects if we come from a phpGW version after the fork 
    690                 // (0.9.14.508 < currentversion < 0.9.99) and running only baseline-deltas 
    691                 if ($GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    692                 { 
    693                         $currentver = explode('.',$GLOBALS['phpgw_setup']->process->currentversion); 
    694                         if ($currentver[0] == 0 && $currentver[1] == 9 &&  
    695                                 ($currentver[2] == 14 && $currentver[3] > 508 ||  
    696                                 ($currentver[2] > 14 && $currentver[2] < 99))) 
    697                         { 
    698                                 // this is a phpGW update from a version after the fork 
    699                                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.509'; 
    700                                 //echo "currentver=".print_r($currentver,true)." ==> following the phpGW update path ==> ".$GLOBALS['setup_info']['phpgwapi']['currentver']."<br>\n"; 
    701                                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    702                         } 
    703                 }                                        
    704                 // update to 0.9.10pre3 droped the columns account_permissions and account_groups 
    705                 // unfortunally they are still in the tables_current of 0.9.14.508 
    706                 // so it depends on having a new or an updated install, if one have them or not 
    707                 // we now check if they are there and drop them if thats the case 
    708  
    709                 $GLOBALS['phpgw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['phpgw_setup']->oProc,'phpgw_accounts',$columns); 
    710                 $columns = explode(',',$columns); 
    711                 if (in_array('account_permissions',$columns)) 
    712                 { 
    713                         $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_accounts',array( 
    714                                 'fd' => array( 
    715                                         'account_id' => array('type' => 'auto','nullable' => False), 
    716                                         'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    717                                         'account_pwd' => array('type' => 'varchar','precision' => '32','nullable' => False), 
    718                                         'account_firstname' => array('type' => 'varchar','precision' => '50'), 
    719                                         'account_lastname' => array('type' => 'varchar','precision' => '50'), 
    720                                         'account_groups' => array('type' => 'varchar','precision' => '30'), 
    721                                         'account_lastlogin' => array('type' => 'int','precision' => '4'), 
    722                                         'account_lastloginfrom' => array('type' => 'varchar','precision' => '255'), 
    723                                         'account_lastpwd_change' => array('type' => 'int','precision' => '4'), 
    724                                         'account_status' => array('type' => 'char','precision' => '1','nullable' => False,'default' => 'A'), 
    725                                         'account_expires' => array('type' => 'int','precision' => '4'), 
    726                                         'account_type' => array('type' => 'char','precision' => '1','nullable' => True) 
    727                                 ), 
    728                                 'pk' => array('account_id'), 
    729                                 'fk' => array(), 
    730                                 'ix' => array(), 
    731                                 'uc' => array('account_lid') 
    732                         ),'account_permissions'); 
    733                 } 
    734                 if (in_array('account_groups',$columns)) 
    735                 { 
    736                         $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_accounts',array( 
    737                                 'fd' => array( 
    738                                         'account_id' => array('type' => 'auto','nullable' => False), 
    739                                         'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    740                                         'account_pwd' => array('type' => 'varchar','precision' => '32','nullable' => False), 
    741                                         'account_firstname' => array('type' => 'varchar','precision' => '50'), 
    742                                         'account_lastname' => array('type' => 'varchar','precision' => '50'), 
    743                                         'account_lastlogin' => array('type' => 'int','precision' => '4'), 
    744                                         'account_lastloginfrom' => array('type' => 'varchar','precision' => '255'), 
    745                                         'account_lastpwd_change' => array('type' => 'int','precision' => '4'), 
    746                                         'account_status' => array('type' => 'char','precision' => '1','nullable' => False,'default' => 'A'), 
    747                                         'account_expires' => array('type' => 'int','precision' => '4'), 
    748                                         'account_type' => array('type' => 'char','precision' => '1','nullable' => True) 
    749                                 ), 
    750                                 'pk' => array('account_id'), 
    751                                 'fk' => array(), 
    752                                 'ix' => array(), 
    753                                 'uc' => array('account_lid') 
    754                         ),'account_groups'); 
    755                 } 
    756  
    757                 // we add the person_id from the .16RC1, if its not already there 
    758                 if (!in_array('person_id',$columns)) 
    759                 { 
    760                         $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','person_id',array( 
    761                                 'type' => 'int', 
    762                                 'precision' => '4', 
    763                                 'nullable' => True 
    764                         )); 
    765                 } 
    766                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','account_primary_group',array( 
    767                         'type' => 'int', 
    768                         'precision' => '4', 
    769                         'nullable' => False, 
    770                         'default' => '0' 
    771                 )); 
    772  
    773                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.002'; 
    774                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    775         } 
    776  
    777         $test[] = '0.9.99.002'; 
    778         function phpgwapi_upgrade0_9_99_002() 
    779         { 
    780                 // needed for the chinese(simplified) translations 
    781                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET lang_name='Chinese(simplified)',available='Yes' WHERE lang_id='zh'"); 
    782  
    783                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.003'; 
    784                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    785         } 
    786  
    787         /* 
    788          * Updates from phpGroupWare after the fork 
    789          */ 
    790  
    791         $test[] = '0.9.14.509'; 
    792         function phpgwapi_upgrade0_9_14_509() 
    793         { 
    794                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.510'; 
    795         } 
    796                  
    797         $test[] = '0.9.14.510'; 
    798         function phpgwapi_upgrade0_9_14_510() 
    799         { 
    800                 $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_log_msg'); 
    801                 $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_log'); 
    802                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_log',array( 
    803                         'fd' => array( 
    804                                 'log_id' => array('type' => 'auto','precision' => '4','nullable' => False), 
    805                                 'log_date' => array('type' => 'timestamp','nullable' => False), 
    806                                 'log_account_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    807                                 'log_account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    808                                 'log_app' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    809                                 'log_severity' => array('type' => 'char','precision' => '1','nullable' => False), 
    810                                 'log_file' => array('type' => 'varchar','precision' => '255','nullable' => False, 'default' => ''), 
    811                                 'log_line' => array('type' => 'int','precision' => '4','nullable' => False, 'default' => '0'), 
    812                                 'log_msg' => array('type' => 'text','nullable' => False) 
    813                         ), 
    814                         'pk' => array('log_id'), 
    815                         'fk' => array(), 
    816                         'ix' => array(), 
    817                         'uc' => array() 
    818                 )); 
    819                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.511'; 
    820         } 
    821                  
    822         $test[] = '0.9.14.511'; 
    823         function phpgwapi_upgrade0_9_14_511() 
    824         { 
    825                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.512'; 
    826         } 
    827                  
    828         $test[] = '0.9.14.512'; 
    829         function phpgwapi_upgrade0_9_14_512() 
    830         { 
    831                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.513'; 
    832         } 
    833                  
    834         $test[] = '0.9.14.513'; 
    835         function phpgwapi_upgrade0_9_14_513() 
    836         { 
    837                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','account_quota',array('type' => 'int','precision' => '4','default' => -1,'nullable' => True)); 
    838                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.514'; 
    839         } 
    840          
    841         $test[] = '0.9.14.514'; 
    842         function phpgwapi_upgrade0_9_14_514() 
    843         { 
    844                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.16.000'; 
    845         } 
    846                  
    847         $test[] = '0.9.16.000'; 
    848         function phpgwapi_upgrade0_9_16_000() 
    849         { 
    850                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.16.001'; 
    851         } 
    852  
    853         $test[] = '0.9.16.001'; 
    854         function phpgwapi_upgrade0_9_16_001() 
    855         { 
    856                 foreach($GLOBALS['phpgw_setup']->db->table_names() as $tableinfo) 
    857                 { 
    858                         $tablenames[] = $tableinfo['table_name']; 
    859                 } 
    860                 // we need to redo the 0.9.14.510 update with the new phpgw_log table 
    861                 // we just drop and recreate the table, as it contains no important data 
    862                 $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_log'); 
    863                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_log',array( 
    864                         'fd' => array( 
    865                                 'log_id' => array('type' => 'auto','precision' => '4','nullable' => False), 
    866                                 'log_date' => array('type' => 'timestamp','nullable' => False), 
    867                                 'log_user' => array('type' => 'int','precision' => '4','nullable' => False), 
    868                                 'log_app' => array('type' => 'varchar','precision' => '50','nullable' => False), 
    869                                 'log_severity' => array('type' => 'char','precision' => '1','nullable' => False) 
    870                         ), 
    871                         'pk' => array('log_id'), 
    872                         'fk' => array(), 
    873                         'ix' => array(), 
    874                         'uc' => array() 
    875                 )); 
    876                 if (in_array('phpgw_log_msg',$tablenames))  
    877                 { 
    878                         $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_log_msg'); 
    879                 } 
    880                 $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_log_msg',array( 
    881                         'fd' => array( 
    882                                 'log_msg_log_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    883                                 'log_msg_seq_no' => array('type' => 'int','precision' => '4','nullable' => False), 
    884                                 'log_msg_date' => array('type' => 'timestamp','nullable' => False), 
    885                                 'log_msg_tx_fid' => array('type' => 'varchar','precision' => '4','nullable' => True), 
    886                                 'log_msg_tx_id' => array('type' => 'varchar','precision' => '4','nullable' => True), 
    887                                 'log_msg_severity' => array('type' => 'char','precision' => '1','nullable' => False), 
    888                                 'log_msg_code' => array('type' => 'varchar','precision' => '30','nullable' => False), 
    889                                 'log_msg_msg' => array('type' => 'text','nullable' => False), 
    890                                 'log_msg_parms' => array('type' => 'text','nullable' => False), 
    891                                 'log_msg_file' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    892                                 'log_msg_line' => array('type' => 'int','precision' => '4','nullable' => False) 
    893                         ), 
    894                         'pk' => array('log_msg_log_id','log_msg_seq_no'), 
    895                         'fk' => array(), 
    896                         'ix' => array(), 
    897                         'uc' => array() 
    898                 )); 
    899                  
    900                 // now we need to drop phpgw_accounts.accounts_quota from the 0.9.14.513 update 
    901                 $GLOBALS['phpgw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['phpgw_setup']->oProc,'phpgw_accounts',$columns); 
    902                 $columns = explode(',',$columns); 
    903                 if (in_array('account_quota',$columns)) 
    904                 { 
    905                         $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_accounts',array( 
    906                                 'fd' => array( 
    907                                         'account_id' => array('type' => 'auto','nullable' => False), 
    908                                         'account_lid' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    909                                         'account_pwd' => array('type' => 'varchar','precision' => '32','nullable' => False), 
    910                                         'account_firstname' => array('type' => 'varchar','precision' => '50'), 
    911                                         'account_lastname' => array('type' => 'varchar','precision' => '50'), 
    912                                         'account_lastlogin' => array('type' => 'int','precision' => '4'), 
    913                                         'account_lastloginfrom' => array('type' => 'varchar','precision' => '255'), 
    914                                         'account_lastpwd_change' => array('type' => 'int','precision' => '4'), 
    915                                         'account_status' => array('type' => 'char','precision' => '1','nullable' => False,'default' => 'A'), 
    916                                         'account_expires' => array('type' => 'int','precision' => '4'), 
    917                                         'account_type' => array('type' => 'char','precision' => '1','nullable' => True) 
    918                                 ), 
    919                                 'pk' => array('account_id'), 
    920                                 'fk' => array(), 
    921                                 'ix' => array(), 
    922                                 'uc' => array('account_lid') 
    923                         ),'account_quota'); 
    924                 } 
    925                 /* we dont drop phpGW's new contacts tables for now ;-) 
    926                 foreach(array( 
    927                         'phpgw_contact', 
    928                         'phpgw_contact_person', 
    929                         'phpgw_contact_org', 
    930                         'phpgw_contact_org_person', 
    931                         'phpgw_contact_addr', 
    932                         'phpgw_contact_note', 
    933                         'phpgw_contact_others', 
    934                         'phpgw_contact_comm', 
    935                         'phpgw_contact_comm_descr', 
    936                         'phpgw_contact_comm_type', 
    937                         'phpgw_contact_types', 
    938                         'phpgw_contact_addr_type', 
    939                         'phpgw_contact_note_type' 
    940                 ) as $table) 
    941                 { 
    942                         $GLOBALS['phpgw_setup']->oProc->DropTable($table); 
    943                 }*/ 
    944                  
    945                 // we need to check if we stil have the original addressbook-tables and create them again if not 
    946                 if (!in_array('phpgw_addressbook',$tablenames)) 
    947                 { 
    948                         $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_addressbook',array( 
    949                                 'fd' => array( 
    950                                         'id' => array('type' => 'auto','nullable' => False), 
    951                                         'lid' => array('type' => 'varchar','precision' => '32'), 
    952                                         'tid' => array('type' => 'char','precision' => '1'), 
    953                                         'owner' => array('type' => 'int','precision' => '8'), 
    954                                         'access' => array('type' => 'varchar','precision' => '7'), 
    955                                         'cat_id' => array('type' => 'varchar','precision' => '32'), 
    956                                         'fn' => array('type' => 'varchar','precision' => '64'), 
    957                                         'n_family' => array('type' => 'varchar','precision' => '64'), 
    958                                         'n_given' => array('type' => 'varchar','precision' => '64'), 
    959                                         'n_middle' => array('type' => 'varchar','precision' => '64'), 
    960                                         'n_prefix' => array('type' => 'varchar','precision' => '64'), 
    961                                         'n_suffix' => array('type' => 'varchar','precision' => '64'), 
    962                                         'sound' => array('type' => 'varchar','precision' => '64'), 
    963                                         'bday' => array('type' => 'varchar','precision' => '32'), 
    964                                         'note' => array('type' => 'text'), 
    965                                         'tz' => array('type' => 'varchar','precision' => '8'), 
    966                                         'geo' => array('type' => 'varchar','precision' => '32'), 
    967                                         'url' => array('type' => 'varchar','precision' => '128'), 
    968                                         'pubkey' => array('type' => 'text'), 
    969                                         'org_name' => array('type' => 'varchar','precision' => '64'), 
    970                                         'org_unit' => array('type' => 'varchar','precision' => '64'), 
    971                                         'title' => array('type' => 'varchar','precision' => '64'), 
    972                                         'adr_one_street' => array('type' => 'varchar','precision' => '64'), 
    973                                         'adr_one_locality' => array('type' => 'varchar','precision' => '64'), 
    974                                         'adr_one_region' => array('type' => 'varchar','precision' => '64'), 
    975                                         'adr_one_postalcode' => array('type' => 'varchar','precision' => '64'), 
    976                                         'adr_one_countryname' => array('type' => 'varchar','precision' => '64'), 
    977                                         'adr_one_type' => array('type' => 'varchar','precision' => '32'), 
    978                                         'label' => array('type' => 'text'), 
    979                                         'adr_two_street' => array('type' => 'varchar','precision' => '64'), 
    980                                         'adr_two_locality' => array('type' => 'varchar','precision' => '64'), 
    981                                         'adr_two_region' => array('type' => 'varchar','precision' => '64'), 
    982                                         'adr_two_postalcode' => array('type' => 'varchar','precision' => '64'), 
    983                                         'adr_two_countryname' => array('type' => 'varchar','precision' => '64'), 
    984                                         'adr_two_type' => array('type' => 'varchar','precision' => '32'), 
    985                                         'tel_work' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    986                                         'tel_home' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    987                                         'tel_voice' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    988                                         'tel_fax' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    989                                         'tel_msg' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    990                                         'tel_cell' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    991                                         'tel_pager' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    992                                         'tel_bbs' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    993                                         'tel_modem' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    994                                         'tel_car' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    995                                         'tel_isdn' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    996                                         'tel_video' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    997                                         'tel_prefer' => array('type' => 'varchar','precision' => '32'), 
    998                                         'email' => array('type' => 'varchar','precision' => '64'), 
    999                                         'email_type' => array('type' => 'varchar','precision' => '32','default' => 'INTERNET'), 
    1000                                         'email_home' => array('type' => 'varchar','precision' => '64'), 
    1001                                         'email_home_type' => array('type' => 'varchar','precision' => '32','default' => 'INTERNET'), 
    1002                                         'last_mod' => array('type' => 'int','precision' => '8','nullable' => False) 
    1003                                 ), 
    1004                                 'pk' => array('id'), 
    1005                                 'fk' => array(), 
    1006                                 'ix' => array(array('tid','owner','access','n_family','n_given','email'),array('tid','cat_id','owner','access','n_family','n_given','email')), 
    1007                                 'uc' => array() 
    1008                         )); 
    1009                         $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_addressbook_extra',array( 
    1010                                 'fd' => array( 
    1011                                         'contact_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    1012                                         'contact_owner' => array('type' => 'int','precision' => '8'), 
    1013                                         'contact_name' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    1014                                         'contact_value' => array('type' => 'text') 
    1015                                 ), 
    1016                                 'pk' => array('contact_id','contact_name'), 
    1017                                 'fk' => array(), 
    1018                                 'ix' => array(), 
    1019                                 'uc' => array() 
    1020                         )); 
    1021                 } 
    1022                 // now we return to the version of the fork 
    1023                 return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508'; 
    1024         } 
    1025          
    1026         /* 
    1027          * Updates / downgrades from phpGroupWare HEAD branch 
    1028          */ 
    1029  
    1030         $test[] = '0.9.15.013'; 
    1031         function phpgwapi_upgrade0_9_15_013() 
    1032         { 
    1033                 // is db-compatible to 0.9.14.507 
    1034                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.507'; 
    1035                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1036         } 
    1037  
    1038         $test[] = '0.9.15.014'; 
    1039         function phpgwapi_upgrade0_9_15_014() 
    1040         { 
    1041                 // is db-compatible to 0.9.14.508 
    1042                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508'; 
    1043                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1044         } 
    1045  
    1046         /* 
    1047          * More eGroupWare 0.9.99 updates 
    1048          */ 
    1049  
    1050         $test[] = '0.9.99.003'; 
    1051         function phpgwapi_upgrade0_9_99_003() 
    1052         { 
    1053                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_id',array( 
    1054                         'type' => 'auto' 
    1055                 )); 
    1056                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_lid',array( 
    1057                         'type' => 'varchar', 
    1058                         'precision' => '25' 
    1059                 )); 
    1060                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_firstname',array( 
    1061                         'type' => 'varchar', 
    1062                         'precision' => '50' 
    1063                 )); 
    1064                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_lastname',array( 
    1065                         'type' => 'varchar', 
    1066                         'precision' => '50' 
    1067                 )); 
    1068                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_lastlogin',array( 
    1069                         'type' => 'int', 
    1070                         'precision' => '4' 
    1071                 )); 
    1072                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_lastloginfrom',array( 
    1073                         'type' => 'varchar', 
    1074                         'precision' => '255' 
    1075                 )); 
    1076                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_lastpwd_change',array( 
    1077                         'type' => 'int', 
    1078                         'precision' => '4' 
    1079                 )); 
    1080                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_accounts','account_expires',array( 
    1081                         'type' => 'int', 
    1082                         'precision' => '4' 
    1083                 )); 
    1084  
    1085                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.004'; 
    1086                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1087         } 
    1088  
    1089         $test[] = '0.9.99.004'; 
    1090         function phpgwapi_upgrade0_9_99_004() 
    1091         { 
    1092                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_app_sessions','content',array( 
    1093                         'type' => 'longtext' 
    1094                 )); 
    1095  
    1096                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.005'; 
    1097                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1098         } 
    1099  
    1100         $test[] = '0.9.99.005'; 
    1101         function phpgwapi_upgrade0_9_99_005() 
    1102         { 
    1103                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET available='Yes' WHERE lang_id='sl'"); 
    1104  
    1105                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.006'; 
    1106                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1107         } 
    1108  
    1109         $test[] = '0.9.99.006'; 
    1110         function phpgwapi_upgrade0_9_99_006() 
    1111         { 
    1112                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET available='Yes' WHERE lang_id='pt'"); 
    1113  
    1114                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.007'; 
    1115                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1116         } 
    1117  
    1118         $test[] = '0.9.99.007'; 
    1119         function phpgwapi_upgrade0_9_99_007() 
    1120         { 
    1121                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_languages', 'lang_id', array('type' => 'varchar','precision' => '5','nullable' => False)); 
    1122                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name, available) VALUES ('pt-br','Brazil','Yes')"); 
    1123                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.008'; 
    1124                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1125         } 
    1126  
    1127         $test[] = '0.9.99.008'; 
    1128         function phpgwapi_upgrade0_9_99_008() 
    1129         { 
    1130                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name, available) VALUES ('es-es','Spanish / Spain','Yes')"); 
    1131                 $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name, available) VALUES ('es-mx','Spanish / Mexico','Yes')"); 
    1132                 $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_languages where lang_id='es'"); 
    1133                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.009'; 
    1134                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1135         } 
    1136  
    1137         $test[] = '0.9.99.009'; 
    1138         function phpgwapi_upgrade0_9_99_009() 
    1139         { 
    1140                 $GLOBALS['phpgw_setup']->oProc->AlterColumn( 
    1141                         'phpgw_accounts', 
    1142                         'account_pwd', 
    1143                         array('type' => 'varchar','precision' => '100','nullable' => False) 
    1144                 ); 
    1145  
    1146                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.010'; 
    1147                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1148         } 
    1149  
    1150         $test[] = '0.9.99.010'; 
    1151         function phpgwapi_upgrade0_9_99_010() 
    1152         { 
    1153                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET available='Yes' WHERE lang_id='uk'"); 
    1154  
    1155                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.011'; 
    1156                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1157         } 
    1158  
    1159         $test[] = '0.9.99.011'; 
    1160         function phpgwapi_upgrade0_9_99_011() 
    1161         { 
    1162                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_categories','last_mod',array( 
    1163                         'type' => 'int', 
    1164                         'precision' => '8', 
    1165                         'nullable' => False 
    1166                 )); 
    1167                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_addressbook','last_mod',array( 
    1168                         'type' => 'int', 
    1169                         'precision' => '8', 
    1170                         'nullable' => False 
    1171                 )); 
    1172  
    1173                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.012'; 
    1174                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1175         } 
    1176  
    1177         $test[] = '0.9.99.012'; 
    1178         function phpgwapi_upgrade0_9_99_012() 
    1179         { 
    1180                 $GLOBALS['phpgw_setup']->oProc->AlterColumn( 
    1181                         'phpgw_accounts', 
    1182                         'account_lid', 
    1183                         array('type' => 'varchar','precision' => '25','nullable' => False) 
    1184                 ); 
    1185  
    1186                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.013'; 
    1187                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1188         } 
    1189  
    1190         $test[] = '0.9.99.013'; 
    1191         function phpgwapi_upgrade0_9_99_013() 
    1192         { 
    1193                 // this update fixes the problem that some users cant change their password 
    1194                 // it was caused be 0 acl_rights values in groups (inserted by setup::add_acl which is fixed too) 
    1195                 $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_acl WHERE acl_appname='preferences' AND acl_location='changepassword' AND acl_rights=0"); 
    1196  
    1197                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.014'; 
    1198                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1199         } 
    1200  
    1201         $test[] = '0.9.99.014'; 
    1202         function phpgwapi_upgrade0_9_99_014() 
    1203         { 
    1204                 // enabeling russian language 
    1205                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET available='Yes' WHERE lang_id='ru'"); 
    1206  
    1207                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.015'; 
    1208                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1209         } 
    1210  
    1211  
    1212         // the following series of upgrades create indices for the api tables, RalfBecker 2004/04/03 
    1213  
    1214         $test[] = '0.9.99.015'; 
    1215         function phpgwapi_upgrade0_9_99_015() 
    1216         { 
    1217                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_acl',array( 
    1218                         'fd' => array( 
    1219                                 'acl_appname' => array('type' => 'varchar','precision' => '50','nullable' => False), 
    1220                                 'acl_location' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    1221                                 'acl_account' => array('type' => 'int','precision' => '4','nullable' => False), 
    1222                                 'acl_rights' => array('type' => 'int','precision' => '4') 
    1223                         ), 
    1224                         'pk' => array('acl_appname','acl_location','acl_account'), 
    1225                         'fk' => array(), 
    1226                         'ix' => array('acl_account',array('acl_location','acl_account'),array('acl_appname','acl_account')), 
    1227                         'uc' => array() 
    1228                 )); 
    1229  
    1230                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.016'; 
    1231                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1232         } 
    1233  
    1234  
    1235         $test[] = '0.9.99.016'; 
    1236         function phpgwapi_upgrade0_9_99_016() 
    1237         { 
    1238                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_categories',array( 
    1239                         'fd' => array( 
    1240                                 'cat_id' => array('type' => 'auto','precision' => '4','nullable' => False), 
    1241                                 'cat_main' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), 
    1242                                 'cat_parent' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), 
    1243                                 'cat_level' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '0'), 
    1244                                 'cat_owner' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), 
    1245                                 'cat_access' => array('type' => 'varchar','precision' => '7'), 
    1246                                 'cat_appname' => array('type' => 'varchar','precision' => '50','nullable' => False), 
    1247                                 'cat_name' => array('type' => 'varchar','precision' => '150','nullable' => False), 
    1248                                 'cat_description' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    1249                                 'cat_data' => array('type' => 'text'), 
    1250                                 'last_mod' => array('type' => 'int','precision' => '8','nullable' => False) 
    1251                         ), 
    1252                         'pk' => array('cat_id'), 
    1253                         'fk' => array(), 
    1254                         'ix' => array(array('cat_appname','cat_owner','cat_parent','cat_level')), 
    1255                         'uc' => array() 
    1256                 )); 
    1257  
    1258                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.017'; 
    1259                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1260         } 
    1261  
    1262  
    1263         $test[] = '0.9.99.017'; 
    1264         function phpgwapi_upgrade0_9_99_017() 
    1265         { 
    1266                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_lang',array( 
    1267                         'fd' => array( 
    1268                                 'lang' => array('type' => 'varchar','precision' => '5','nullable' => False,'default' => ''), 
    1269                                 'app_name' => array('type' => 'varchar','precision' => '100','nullable' => False,'default' => 'common'), 
    1270                                 'message_id' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => ''), 
    1271                                 'content' => array('type' => 'text') 
    1272                         ), 
    1273                         'pk' => array('lang','app_name','message_id'), 
    1274                         'fk' => array(), 
    1275                         'ix' => array(), 
    1276                         'uc' => array() 
    1277                 )); 
    1278  
    1279                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.018'; 
    1280                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1281         } 
    1282  
    1283  
    1284         $test[] = '0.9.99.018'; 
    1285         function phpgwapi_upgrade0_9_99_018() 
    1286         { 
    1287                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_config',array( 
    1288                         'fd' => array( 
    1289                                 'config_app' => array('type' => 'varchar','precision' => '50','nullable' => False), 
    1290                                 'config_name' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    1291                                 'config_value' => array('type' => 'text') 
    1292                         ), 
    1293                         'pk' => array('config_app','config_name'), 
    1294                         'fk' => array(), 
    1295                         'ix' => array(), 
    1296                         'uc' => array() 
    1297                 )); 
    1298  
    1299                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.019'; 
    1300                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1301         } 
    1302  
    1303  
    1304         $test[] = '0.9.99.019'; 
    1305         function phpgwapi_upgrade0_9_99_019() 
    1306         { 
    1307                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_applications',array( 
    1308                         'fd' => array( 
    1309                                 'app_id' => array('type' => 'auto','precision' => '4','nullable' => False), 
    1310                                 'app_name' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    1311                                 'app_enabled' => array('type' => 'int','precision' => '4','nullable' => False), 
    1312                                 'app_order' => array('type' => 'int','precision' => '4','nullable' => False), 
    1313                                 'app_tables' => array('type' => 'text','nullable' => False), 
    1314                                 'app_version' => array('type' => 'varchar','precision' => '20','nullable' => False,'default' => '0.0') 
    1315                         ), 
    1316                         'pk' => array('app_id'), 
    1317                         'fk' => array(), 
    1318                         'ix' => array(array('app_enabled','app_order')), 
    1319                         'uc' => array('app_name') 
    1320                 )); 
    1321  
    1322                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.020'; 
    1323                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1324         } 
    1325  
    1326  
    1327         $test[] = '0.9.99.020'; 
    1328         function phpgwapi_upgrade0_9_99_020() 
    1329         { 
    1330                 // at least for postgres we need to change the colum-type, else we get an error in RefreshTable 
    1331                 $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_app_sessions','loginid',array( 
    1332                         'type' => 'int','precision' => '4','nullable' => False 
    1333                 )); 
    1334                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_app_sessions',array( 
    1335                         'fd' => array( 
    1336                                 'sessionid' => array('type' => 'varchar','precision' => '128','nullable' => False), 
    1337                                 'loginid' => array('type' => 'int','precision' => '4','nullable' => False), 
    1338                                 'app' => array('type' => 'varchar','precision' => '25','nullable' => False), 
    1339                                 'location' => array('type' => 'varchar','precision' => '128','nullable' => False), 
    1340                                 'content' => array('type' => 'longtext'), 
    1341                                 'session_dla' => array('type' => 'int','precision' => '4') 
    1342                         ), 
    1343                         'pk' => array('sessionid','loginid','location','app'), 
    1344                         'fk' => array(), 
    1345                         'ix' => array(), 
    1346                         'uc' => array() 
    1347                 )); 
    1348  
    1349                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.021'; 
    1350                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1351         } 
    1352  
    1353  
    1354         $test[] = '0.9.99.021'; 
    1355         function phpgwapi_upgrade0_9_99_021() 
    1356         { 
    1357                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_sessions',array( 
    1358                         'fd' => array( 
    1359                                 'session_id' => array('type' => 'varchar','precision' => '128','nullable' => False), 
    1360                                 'session_lid' => array('type' => 'varchar','precision' => '128'), 
    1361                                 'session_ip' => array('type' => 'varchar','precision' => '32'), 
    1362                                 'session_logintime' => array('type' => 'int','precision' => '4'), 
    1363                                 'session_dla' => array('type' => 'int','precision' => '4'), 
    1364                                 'session_action' => array('type' => 'varchar','precision' => '255'), 
    1365                                 'session_flags' => array('type' => 'char','precision' => '2') 
    1366                         ), 
    1367                         'pk' => array(), 
    1368                         'fk' => array(), 
    1369                         'ix' => array(array('session_flags','session_dla')), 
    1370                         'uc' => array('session_id') 
    1371                 )); 
    1372  
    1373                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.022'; 
    1374                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1375         } 
    1376  
    1377  
    1378         $test[] = '0.9.99.022'; 
    1379         function phpgwapi_upgrade0_9_99_022() 
    1380         { 
    1381                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_history_log',array( 
    1382                         'fd' => array( 
    1383                                 'history_id' => array('type' => 'auto','precision' => '4','nullable' => False), 
    1384                                 'history_record_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    1385                                 'history_appname' => array('type' => 'varchar','precision' => '64','nullable' => False), 
    1386                                 'history_owner' => array('type' => 'int','precision' => '4','nullable' => False), 
    1387                                 'history_status' => array('type' => 'char','precision' => '2','nullable' => False), 
    1388                                 'history_new_value' => array('type' => 'text','nullable' => False), 
    1389                                 'history_timestamp' => array('type' => 'timestamp','nullable' => False,'default' => 'current_timestamp'), 
    1390                                 'history_old_value' => array('type' => 'text','nullable' => False) 
    1391                         ), 
    1392                         'pk' => array('history_id'), 
    1393                         'fk' => array(), 
    1394                         'ix' => array(array('history_appname','history_record_id','history_status','history_timestamp')), 
    1395                         'uc' => array() 
    1396                 )); 
    1397  
    1398                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.023'; 
    1399                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1400         } 
    1401  
    1402  
    1403         $test[] = '0.9.99.023'; 
    1404         function phpgwapi_upgrade0_9_99_023() 
    1405         { 
    1406                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_vfs',array( 
    1407                         'fd' => array( 
    1408                                 'file_id' => array('type' => 'auto','nullable' => False), 
    1409                                 'owner_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    1410                                 'createdby_id' => array('type' => 'int','precision' => '4'), 
    1411                                 'modifiedby_id' => array('type' => 'int','precision' => '4'), 
    1412                                 'created' => array('type' => 'date','nullable' => False,'default' => '1970-01-01'), 
    1413                                 'modified' => array('type' => 'date'), 
    1414                                 'size' => array('type' => 'int','precision' => '4'), 
    1415                                 'mime_type' => array('type' => 'varchar','precision' => '64'), 
    1416                                 'deleteable' => array('type' => 'char','precision' => '1','default' => 'Y'), 
    1417                                 'comment' => array('type' => 'varchar','precision' => '255'), 
    1418                                 'app' => array('type' => 'varchar','precision' => '25'), 
    1419                                 'directory' => array('type' => 'varchar','precision' => '255'), 
    1420                                 'name' => array('type' => 'varchar','precision' => '128','nullable' => False), 
    1421                                 'link_directory' => array('type' => 'varchar','precision' => '255'), 
    1422                                 'link_name' => array('type' => 'varchar','precision' => '128'), 
    1423                                 'version' => array('type' => 'varchar','precision' => '30','nullable' => False,'default' => '0.0.0.0'), 
    1424                                 'content' => array('type' => 'text') 
    1425                         ), 
    1426                         'pk' => array('file_id'), 
    1427                         'fk' => array(), 
    1428                         'ix' => array(array('directory','name','mime_type')), 
    1429                         'uc' => array() 
    1430                 )); 
    1431  
    1432                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.024'; 
    1433                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1434         } 
    1435  
    1436  
    1437         $test[] = '0.9.99.024'; 
    1438         function phpgwapi_upgrade0_9_99_024() 
    1439         { 
    1440                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_addressbook_extra',array( 
    1441                         'fd' => array( 
    1442                                 'contact_id' => array('type' => 'int','precision' => '4','nullable' => False), 
    1443                                 'contact_owner' => array('type' => 'int','precision' => '8'), 
    1444                                 'contact_name' => array('type' => 'varchar','precision' => '255','nullable' => False), 
    1445                                 'contact_value' => array('type' => 'text') 
    1446                         ), 
    1447                         'pk' => array('contact_id','contact_name'), 
    1448                         'fk' => array(), 
    1449                         'ix' => array(), 
    1450                         'uc' => array() 
    1451                 )); 
    1452  
    1453                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.99.025'; 
    1454                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1455         } 
    1456  
    1457  
    1458         $test[] = '0.9.99.025'; 
    1459         function phpgwapi_upgrade0_9_99_025() 
    1460         { 
    1461                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_addressbook',array( 
    1462                         'fd' => array( 
    1463                                 'id' => array('type' => 'auto','nullable' => False), 
    1464                                 'lid' => array('type' => 'varchar','precision' => '32'), 
    1465                                 'tid' => array('type' => 'char','precision' => '1'), 
    1466                                 'owner' => array('type' => 'int','precision' => '8'), 
    1467                                 'access' => array('type' => 'varchar','precision' => '7'), 
    1468                                 'cat_id' => array('type' => 'varchar','precision' => '32'), 
    1469                                 'fn' => array('type' => 'varchar','precision' => '64'), 
    1470                                 'n_family' => array('type' => 'varchar','precision' => '64'), 
    1471                                 'n_given' => array('type' => 'varchar','precision' => '64'), 
    1472                                 'n_middle' => array('type' => 'varchar','precision' => '64'), 
    1473                                 'n_prefix' => array('type' => 'varchar','precision' => '64'), 
    1474                                 'n_suffix' => array('type' => 'varchar','precision' => '64'), 
    1475                                 'sound' => array('type' => 'varchar','precision' => '64'), 
    1476                                 'bday' => array('type' => 'varchar','precision' => '32'), 
    1477                                 'note' => array('type' => 'text'), 
    1478                                 'tz' => array('type' => 'varchar','precision' => '8'), 
    1479                                 'geo' => array('type' => 'varchar','precision' => '32'), 
    1480                                 'url' => array('type' => 'varchar','precision' => '128'), 
    1481                                 'pubkey' => array('type' => 'text'), 
    1482                                 'org_name' => array('type' => 'varchar','precision' => '64'), 
    1483                                 'org_unit' => array('type' => 'varchar','precision' => '64'), 
    1484                                 'title' => array('type' => 'varchar','precision' => '64'), 
    1485                                 'adr_one_street' => array('type' => 'varchar','precision' => '64'), 
    1486                                 'adr_one_locality' => array('type' => 'varchar','precision' => '64'), 
    1487                                 'adr_one_region' => array('type' => 'varchar','precision' => '64'), 
    1488                                 'adr_one_postalcode' => array('type' => 'varchar','precision' => '64'), 
    1489                                 'adr_one_countryname' => array('type' => 'varchar','precision' => '64'), 
    1490                                 'adr_one_type' => array('type' => 'varchar','precision' => '32'), 
    1491                                 'label' => array('type' => 'text'), 
    1492                                 'adr_two_street' => array('type' => 'varchar','precision' => '64'), 
    1493                                 'adr_two_locality' => array('type' => 'varchar','precision' => '64'), 
    1494                                 'adr_two_region' => array('type' => 'varchar','precision' => '64'), 
    1495                                 'adr_two_postalcode' => array('type' => 'varchar','precision' => '64'), 
    1496                                 'adr_two_countryname' => array('type' => 'varchar','precision' => '64'), 
    1497                                 'adr_two_type' => array('type' => 'varchar','precision' => '32'), 
    1498                                 'tel_work' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1499                                 'tel_home' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1500                                 'tel_voice' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1501                                 'tel_fax' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1502                                 'tel_msg' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1503                                 'tel_cell' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1504                                 'tel_pager' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1505                                 'tel_bbs' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1506                                 'tel_modem' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1507                                 'tel_car' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1508                                 'tel_isdn' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1509                                 'tel_video' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => '+1 (000) 000-0000'), 
    1510                                 'tel_prefer' => array('type' => 'varchar','precision' => '32'), 
    1511                                 'email' => array('type' => 'varchar','precision' => '64'), 
    1512                                 'email_type' => array('type' => 'varchar','precision' => '32','default' => 'INTERNET'), 
    1513                                 'email_home' => array('type' => 'varchar','precision' => '64'), 
    1514                                 'email_home_type' => array('type' => 'varchar','precision' => '32','default' => 'INTERNET'), 
    1515                                 'last_mod' => array('type' => 'int','precision' => '8','nullable' => False) 
    1516                         ), 
    1517                         'pk' => array('id'), 
    1518                         'fk' => array(), 
    1519                         'ix' => array(array('tid','owner','access','n_family','n_given','email'),array('tid','cat_id','owner','access','n_family','n_given','email')), 
    1520                         'uc' => array() 
    1521                 )); 
    1522  
    1523                 // we dont need to do update 0.9.99.026, as UpdateSequenze is called now by RefreshTable 
    1524                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0'; 
    1525                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1526         } 
    1527          
    1528          
    1529         $test[] = '0.9.99.026'; 
    1530         function phpgwapi_upgrade0_9_99_026() 
    1531         { 
    1532                 // update the sequenzes for refreshed tables (postgres only) 
    1533                 $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_categories','cat_id'); 
    1534                 $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_applications','app_id'); 
    1535                 $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_history_log','history_id'); 
    1536                 $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_vfs','file_id'); 
    1537                 $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_addressbook','id'); 
    1538                  
    1539                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0'; 
    1540                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1541         } 
    1542  
    1543  
    1544         $test[] = '1.0.0'; 
    1545         function phpgwapi_upgrade1_0_0() 
    1546         { 
    1547                 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','account_email',array( 
    1548                         'type' => 'varchar', 
    1549                         'precision' => '100' 
    1550                 )); 
    1551                  
    1552                 $GLOBALS['phpgw_setup']->oProc->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='mail_suffix'",__LINE__,__FILE__); 
    1553                 $mail_domain = $GLOBALS['phpgw_setup']->oProc->next_record() ? $GLOBALS['phpgw_setup']->oProc->f(0) : ''; 
    1554  
    1555                 // copy the email-addresses from the preferences of the mail-app (if set) to the new field 
    1556                 $db2 = $GLOBALS['phpgw_setup']->oProc->m_odb; 
    1557                 $sql = "SELECT account_id,account_lid,preference_value FROM phpgw_accounts LEFT JOIN phpgw_preferences ON account_id=preference_owner AND preference_app='email' WHERE account_type = 'u'"; 
    1558                 $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__); 
    1559                 while ($GLOBALS['phpgw_setup']->oProc->next_record()) 
    1560                 { 
    1561                         $email_prefs = unserialize($GLOBALS['phpgw_setup']->oProc->f('preference_value')); 
    1562                         $account_lid = $GLOBALS['phpgw_setup']->oProc->f('account_lid'); 
    1563                         $db2->update('phpgw_accounts',array( 
    1564                                 'account_email' => $email_prefs['address'] ? $email_prefs['address'] : $account_lid.(strstr($account_lid,'@')===False?'@'.$mail_domain:''), 
    1565                         ),array( 
    1566                                 'account_id' => $GLOBALS['phpgw_setup']->oProc->f('account_id') 
    1567                         ),__LINE__,__FILE__); 
    1568                 } 
    1569                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.000'; 
    1570                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1571         } 
    1572  
    1573  
    1574         $test[] = '1.0.0.000'; 
    1575         function phpgwapi_upgrade1_0_0_000() 
    1576         { 
    1577                 // removing the not longer needed 'availible' column, that information is in the file setup/lang/languages 
    1578                 $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_languages',array( 
    1579                         'fd' => array( 
    1580                                 'lang_id' => array('type' => 'varchar','precision' => '5','nullable' => False), 
    1581                                 'lang_name' => array('type' => 'varchar','precision' => '50','nullable' => False) 
    1582                         ), 
    1583                         'pk' => array('lang_id'), 
    1584                         'ix' => array(), 
    1585                         'fk' => array(), 
    1586                         'uc' => array() 
    1587                 ),'available'); 
    1588  
    1589                 // correcting the id for Catalan 
    1590                 $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET lang_id='es-ca' WHERE lang_id='ca'"); 
    1591  
    1592                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.001'; 
    1593                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1594         } 
    1595  
    1596  
    1597         $test[] = '1.0.0.001'; 
    1598         function phpgwapi_upgrade1_0_0_001() 
    1599         { 
    1600                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.002'; 
    1601                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1602         } 
    1603  
    1604  
    1605         $test[] = '1.0.0.002'; 
    1606         function phpgwapi_upgrade1_0_0_002() 
    1607         { 
    1608                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.003'; 
    1609                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1610         } 
    1611  
    1612  
    1613         $test[] = '1.0.0.003'; 
    1614         function phpgwapi_upgrade1_0_0_003() 
    1615         { 
    1616                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.004'; 
    1617                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1618         } 
    1619  
    1620  
    1621         $test[] = '1.0.0.004'; 
    1622         function phpgwapi_upgrade1_0_0_004() 
    1623         { 
    1624                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.005'; 
    1625                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1626         } 
    1627  
    1628  
    1629         $test[] = '1.0.0.005'; 
    1630         function phpgwapi_upgrade1_0_0_005() 
    1631         { 
    1632                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.006'; 
    1633                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1634         } 
    1635  
    1636         $test[] = '1.0.0.006'; 
    1637         function phpgwapi_upgrade1_0_0_006() 
    1638         { 
    1639                 $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.007'; 
    1640                 return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1641         } 
    1642  
     12        // Since Expresso 1.2 using API EgroupWare 1.0.0.007  
    164313        $test[] = '1.0.0.007'; 
    164414        function phpgwapi_upgrade1_0_0_007() 
     
    167848                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.0.002'; 
    167949                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    1680         } 
     50        }                
    168151        $test[] = '2.0.002'; 
    168252        function phpgwapi_upgrade2_0_002() 
    168353        { 
     54                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.0.003'; 
     55                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
     56        } 
     57        $test[] = '2.0.003'; 
     58        function phpgwapi_upgrade2_0_003() 
     59        { 
     60                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.0.004'; 
     61                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
     62        } 
     63        $test[] = '2.0.004'; 
     64        function phpgwapi_upgrade2_0_004() 
     65        { 
     66                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.0.005'; 
     67                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
     68        } 
     69        $test[] = '2.0.005'; 
     70        function phpgwapi_upgrade2_0_005() 
     71        { 
     72                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.0.006'; 
     73                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
     74        }                        
     75        $test[] = '2.0.006'; 
     76        function phpgwapi_upgrade2_0_006() 
     77        { 
     78                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.0.007'; 
     79                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
     80        }        
     81        $test[] = '2.0.007'; 
     82        function phpgwapi_upgrade2_0_007() 
     83        { 
    168484                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.1.000'; 
     85                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
     86        }        
     87        $test[] = '2.1.000'; 
     88        function phpgwapi_upgrade2_1_000() 
     89        { 
     90                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '2.2.000'; 
    168591                return $GLOBALS['setup_info']['phpgwapi']['currentver']; 
    168692        } 
  • branches/2.2/preferences/setup/setup.inc.php

    r1728 r3031  
    1313        $setup_info['preferences']['name']      = 'preferences'; 
    1414        $setup_info['preferences']['title']     = 'Preferences'; 
    15         $setup_info['preferences']['version']   = '2.1.000'; 
     15        $setup_info['preferences']['version']   = '2.2.000'; 
    1616        $setup_info['preferences']['app_order'] = 1; 
    1717        $setup_info['preferences']['tables']    = ''; 
     
    2828        $setup_info['preferences']['depends'][] = array( 
    2929                'appname' => 'phpgwapi', 
    30                 'versions' => Array('2.1') 
     30                'versions' => Array('2.2') 
    3131        ); 
    3232?> 
  • branches/2.2/workflow/setup/setup.inc.php

    r1974 r3031  
    1313        $setup_info['workflow']['name']                 = 'workflow'; 
    1414        $setup_info['workflow']['title']                = 'Workflow management'; 
    15         $setup_info['workflow']['version']              = '2.1.000'; 
     15        $setup_info['workflow']['version']              = '2.2.000'; 
    1616        $setup_info['workflow']['app_order']    = 10; 
    1717        $setup_info['workflow']['enable']               = 1; 
     
    5959        $setup_info['workflow']['depends'][] = array( 
    6060                'appname' => 'phpgwapi', 
    61                 'versions' => Array('1.0.0','1.0.1','1.2', '2.0', '2.1') 
     61                'versions' => Array('1.2', '2.0', '2.2') 
    6262        ); 
    6363        $setup_info['workflow']['depends'][] = array( 
    6464                'appname' => 'preferences', 
    65                 'versions' => Array('1.0.0', '0.9.13.002', '2.0', '2.1') 
     65                'versions' => Array('0.9.13.002', '2.0', '2.2') 
    6666        ); 
    6767?> 
  • branches/2.2/workflow/setup/tables_update.inc.php

    r1981 r3031  
    3939                return $workflowHostInfo; 
    4040        } 
    41  
    42         $test[] = '1.0.1'; 
    43         function workflow_upgrade1_0_1() 
    44         { 
    45                 # add an instance_supplements table 
    46                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_instance_supplements', 
    47                         array( 
    48                                 'fd' => array( 
    49                                         'wf_supplement_id'      => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    50                                         'wf_supplement_type'    => array('type' => 'varchar', 'precision' => '50', 'nullable' => True), 
    51                                         'wf_supplement_name'    => array('type' => 'varchar', 'precision' => '100', 'nullable' => True), 
    52                                         'wf_supplement_value'   => array('type' => 'text', 'nullable' => True), 
    53                                         'wf_workitem_id'        => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    54                                         'wf_supplement_blob'    => array('type' => 'blob', 'nullable' => True) 
    55                                 ), 
    56                                 'pk' => array('wf_supplement_id'), 
    57                                 'fk' => array(), 
    58                                 'ix' => array(), 
    59                                 'uc' => array() 
    60                         ) 
    61                 ); 
    62  
    63                 #Add in activities table is_reassign_box, is_report, default_user and default group 
    64                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_is_reassign_box',array('type' => 'char', 'precision' => 1, 'nullable' => True)); 
    65                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_is_report',array('type' => 'char', 'precision' => 1, 'nullable' => True)); 
    66                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_default_user', array('type' => 'varchar', 'precision' => '200', 'nullable' => True, 'default' => '*')); 
    67                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_default_group', array('type' => 'varchar', 'precision' => '200', 'nullable' => True, 'default' => '*')); 
    68  
    69                 #Add in instance_activities table the group field 
    70                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instance_activities' ,'wf_group',array('type' => 'varchar', 'precision' => 200, 'nullable' => True, 'default' => '*')); 
    71  
    72                 #Add in instance table the name, and the priority, we keep the properties for the moment 
    73                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_priority',array('type' => 'int', 'precision' => 4, 'nullable' => True)); 
    74                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_name',array('type' => 'varchar', 'precision' => 120, 'nullable' => True)); 
    75  
    76                 #Add in workitems table note and action 
    77                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_workitems' ,'wf_note',array('type' => 'text', 'precision' => 50, 'nullable' => True)); 
    78                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_workitems' ,'wf_action',array('type' => 'text', 'precision' => 50, 'nullable' => True)); 
    79  
    80                 #Add in user_roles table the account type 
    81                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_user_roles' ,'wf_account_type',array('type' => 'char', 'precision' => 1, 'nullable' => True, 'default' => 'u')); 
    82                         #modifying the sequence as well 
    83                         #we need a RefreshTable 
    84                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_user_roles' ,array( 
    85                         'fd' => array( 
    86                                 'wf_role_id'            => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    87                                 'wf_p_id'               => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    88                                 'wf_user'               => array('type' => 'varchar', 'precision' => '200', 'nullable' => False), 
    89                                 'wf_account_type'       => array('type' => 'char', 'precision' => '1', 'nullable' => True, 'default' => 'u'), 
    90                          ), 
    91                          'pk' => array('wf_role_id', 'wf_user', 'wf_account_type'), 
    92                          'fk' => array(), 
    93                          'ix' => array(), 
    94                          'uc' => array() 
    95                 )); 
    96  
    97                 #updating the current version 
    98                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.00.000'; 
    99                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    100         } 
    101  
    102         $test[] = '1.1.00.000'; 
    103         function workflow_upgrade1_1_00_000() 
    104         { 
    105                 # add a process_config table 
    106                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_process_config', 
    107                         array( 
    108                                 'fd' => array( 
    109                                         'wf_p_id'               => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    110                                         'wf_config_name'        => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), 
    111                                         'wf_config_value'       => array('type' => 'text', 'nullable' => True), 
    112                                         'wf_config_value_int'   => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    113                                 ), 
    114                                 'pk' => array('wf_p_id','wf_config_name'), 
    115                                 'fk' => array(), 
    116                                 'ix' => array(), 
    117                                 'uc' => array() 
    118                         ) 
    119                 ); 
    120  
    121                 //change de default value for priority 
    122  
    123  
    124                 #updating the current version 
    125                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.01.000'; 
    126                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    127         } 
    128  
    129         $test[] = '1.1.01.000'; 
    130         function workflow_upgrade1_1_01_000() 
    131         { 
    132                 #remove unused 'new' fields in activity and add a agent key 
    133                 $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities', '', 'wf_is_reassign_box'); 
    134                 $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities', '', 'wf_is_report'); 
    135                 $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities', '', 'wf_default_group'); 
    136                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_agent', array('type' => 'int', 'precision' => '4', 'nullable' => True)); 
    137  
    138                 #add a readonly attribute to role/activty mapping 
    139                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activity_roles' ,'wf_readonly', array('type' => 'int', 'precision' => '1', 'nullable' => False, 'default'=> 0)); 
    140  
    141                 #add a instance category attribute 
    142                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_category', array('type' => 'int', 'precision'=>'4', 'nullable' => True)); 
    143  
    144                 #updating the current version 
    145                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.02.000'; 
    146                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    147         } 
    148  
    149  
    150         $test[] = '1.1.02.000'; 
    151         function workflow_upgrade1_1_02_000() 
    152         { 
    153                 //drop the agent key in activity, we need something more complex in fact 
    154                 $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities','','wf_agent'); 
    155  
    156                 //add the agent table, link between activities and agents 
    157                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_activity_agents', 
    158                         array( 
    159                                 'fd' => array( 
    160                                         'wf_activity_id'        => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    161                                         'wf_agent_id'           => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    162                                         'wf_agent_type'         => array('type' => 'varchar', 'precision' => '15', 'nullable' => False), 
    163                                 ), 
    164                                 'pk' => array('wf_activity_id', 'wf_agent_id'), 
    165                                 'fk' => array(), 
    166                                 'ix' => array(), 
    167                                 'uc' => array() 
    168                         ) 
    169                 ); 
    170  
    171                 // add the mail_smtp agent table 
    172                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_agent_mail_smtp', 
    173                         array( 
    174                                 'fd' => array( 
    175                                         'wf_agent_id'           => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    176                                         'wf_to'                 => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '%roles%'), 
    177                                         'wf_cc'                 => array('type' => 'varchar', 'precision' => '255', 'nullable' => True), 
    178                                         'wf_bcc'                => array('type' => 'varchar', 'precision' => '255', 'nullable' => True), 
    179                                         'wf_from'               => array('type' => 'varchar', 'precision' => '255', 'nullable' => True, 'default' => '%user%'), 
    180                                         'wf_replyTo'            => array('type' => 'varchar', 'precision' => '255', 'nullable' => True, 'default' => '%user%'), 
    181                                         'wf_subject'            => array('type' => 'varchar', 'precision' => '255', 'nullable' => True), 
    182                                         'wf_message'            => array('type' => 'text', 'nullable' => True), 
    183                                         'wf_send_mode'          => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default' => 0), 
    184                                 ), 
    185                                 'pk' => array('wf_agent_id'), 
    186                                 'fk' => array(), 
    187                                 'ix' => array(), 
    188                                 'uc' => array() 
    189                         ) 
    190                 ); 
    191  
    192                 #updating the current version 
    193                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.03.000'; 
    194                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    195         } 
    196  
    197         $test[] = '1.1.03.000'; 
    198         function workflow_upgrade1_1_03_000() 
    199         { 
    200                 //change type of wf_next_user to handle serialization -> multiple states if instance has multiple activities running 
    201                 //we will loose current wf_next_activity but the update should'nt be made when instances are running and this is 
    202                 //a field needed only at runtime, normally. 
    203                 $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_instances','','wf_next_activity'); 
    204                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_next_activity', array('type' => 'blob', 'nullable' => True)); 
    205  
    206                 #updating the current version 
    207                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.04.000'; 
    208                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    209         } 
    210  
    211         $test[] = '1.1.04.000'; 
    212         function workflow_upgrade1_1_04_000() 
    213         { 
    214                 //unused column. Notice I had to do this manually with MAIN versions of phpgwapi/class.schema_proc.inc.php 
    215                 $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_instance_activities','','wf_group'); 
    216  
    217                 //Adding some indexes on some tables: 
    218  
    219                 //we need a RefreshTable for that 
    220                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_instance_activities' ,array( 
    221                         'fd' => array( 
    222                                 'wf_instance_id'        => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    223                                 'wf_activity_id'        => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    224                                 'wf_started'            => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    225                                 'wf_ended'              => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    226                                 'wf_user'               => array('type' => 'varchar', 'precision' => '200', 'nullable' => True), 
    227                                 'wf_status'             => array('type' => 'varchar', 'precision' => '25', 'nullable' => True), 
    228                         ), 
    229                         'pk' => array('wf_instance_id', 'wf_activity_id'), 
    230                         'fk' => array(), 
    231                         'ix' => array(array('wf_activity_id'),array('wf_instance_id'), array('wf_user')), 
    232                         'uc' => array() 
    233                 )); 
    234                 // we change some indexes 
    235                 // we need a RefreshTable 
    236                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_instances' ,array( 
    237                         'fd' => array( 
    238                                 'wf_instance_id'        => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    239                                 'wf_p_id'               => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    240                                 'wf_started'            => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    241                                 'wf_owner'              => array('type' => 'varchar', 'precision' => '200', 'nullable' => True), 
    242                                 'wf_next_activity'      => array('type' => 'blob', 'nullable' => True), 
    243                                 'wf_next_user'          => array('type' => 'varchar', 'precision' => '200', 'nullable' => True), 
    244                                 'wf_ended'              => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    245                                 'wf_status'             => array('type' => 'varchar', 'precision' => '25', 'nullable' => True), 
    246                                 'wf_priority'           => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default'=> 0), 
    247                                 'wf_properties'         => array('type' => 'blob', 'nullable' => True), 
    248                                 'wf_name'               => array('type' => 'varchar', 'precision'=>'120', 'nullable' => True), 
    249                                 'wf_category'           => array('type' => 'int', 'precision'=>'4', 'nullable' => True), 
    250                         ), 
    251                         'pk' => array('wf_instance_id'), 
    252                         'fk' => array(), 
    253                         'ix' => array(array('wf_owner'), array('wf_status')), 
    254                         'uc' => array() 
    255                 )); 
    256                 // we change some indexes 
    257                 // we need a RefreshTable 
    258                 $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_processes' ,array( 
    259                         'fd' => array( 
    260                                 'wf_p_id'               => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    261                                 'wf_name'               => array('type' => 'varchar', 'precision' => '80', 'nullable' => True), 
    262                                 'wf_is_valid'           => array('type' => 'char', 'precision' => '1', 'nullable' => True), 
    263                                 'wf_is_active'          => array('type' => 'char', 'precision' => '1', 'nullable' => True), 
    264                                 'wf_version'            => array('type' => 'varchar', 'precision' => '12', 'nullable' => True), 
    265                                 'wf_description'        => array('type' => 'text', 'nullable' => True), 
    266                                 'wf_last_modif'         => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    267                                 'wf_normalized_name'    => array('type' => 'varchar', 'precision' => '80', 'nullable' => True), 
    268                         ), 
    269                         'pk' => array('wf_p_id'), 
    270                         'fk' => array(), 
    271                         'ix' => array(array('wf_p_id','wf_is_active')), 
    272                         'uc' => array() 
    273                 )); 
    274  
    275                 #updating the current version 
    276                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.05.000'; 
    277                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    278         } 
    279  
    280         $test[] = '1.1.05.000'; 
    281         function workflow_upgrade1_1_05_000() 
    282         { 
    283                 #serialized data is now stored with a Base64 encoding to ensure it work in all case (even with \' for example) 
    284                 //We gonna make our updates manually here: 
    285                 //they were an error (quotes) in the first version of this upgrade, if your database is MySQL you should 
    286                 //set the version to 1.1.05.000 in egw_applications and rerun this upgrade for old properties 
    287                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    288                 { 
    289                         $GLOBALS['phpgw']->ADOdb->SetFetchMode(ADODB_FETCH_ASSOC); 
    290                         $result = $GLOBALS['phpgw']->ADOdb->query('select * from egw_wf_instances'); 
    291                         if (!(empty($result))) 
    292                         { 
    293                                 while ($res = $result->fetchRow()) 
    294                                 { 
    295                                         $new_props = base64_encode($res['wf_properties']); 
    296                                         $new_next = base64_encode($res['wf_next_activity']); 
    297                                         $ok =  $GLOBALS['phpgw']->ADOdb->query( 
    298                                                 'update egw_wf_instances set wf_properties = ?, wf_next_activity=? where wf_instance_id = ?', 
    299                                                 array($new_props,$new_next, (int)$res['wf_instance_id']) 
    300                                         ); 
    301                                 } 
    302                         } 
    303                         $result = $GLOBALS['phpgw']->ADOdb->query('select * from egw_wf_workitems'); 
    304                         if (!(empty($result))) 
    305                         { 
    306                                 while ($res = $result->fetchRow()) 
    307                                 { 
    308                                         $new_props = base64_encode($res['wf_properties']); 
    309                                         $ok =  $GLOBALS['phpgw']->ADOdb->query( 
    310                                                 'update egw_wf_workitems set wf_properties = ?  where wf_item_id = ?', 
    311                                                 array($new_props, (int)$res['wf_item_id']) 
    312                                         ); 
    313                                 } 
    314                         } 
    315                 } 
    316  
    317                 #updating the current version 
    318                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.00.000'; 
    319                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    320         } 
    321  
    322         $test[] = '1.2.00.000'; 
    323         function workflow_upgrade1_2_00_000() 
    324         { 
    325                 #updating the current version 
    326                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.00.001'; 
    327                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    328         } 
    329         $test[] = '1.2.00.001'; 
    330         function workflow_upgrade1_2_00_001() 
    331         { 
    332                 #updating the current version 
    333                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.00.002'; 
    334                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    335         } 
    336         $test[] = '1.2.00.002'; 
    337         function workflow_upgrade1_2_00_002() 
    338         { 
    339                 #groups Ids are now negative in egroupware, we need to negative all user id which is positive and of type 'g' 
    340                 #code inspired by phpgwapi/setup/table_update.inc.php 
    341                 // convert all positive group id's to negative ones 
    342                 // this allows duplicate id for users and groups in ldap 
    343  
    344                 /* Celepar: não realizar esta atualização 
    345                 $where = false; 
    346                 list($table,$col,$where) = $data; 
    347                 $table = 'egw_wf_user_roles'; 
    348                 $col = 'wf_user'; 
    349                 $where = "wf_account_type='g' and (SUBSTR($col,1,1) <> '-')"; 
    350                 $set = $col.'='.$GLOBALS['egw_setup']->db->concat("'-'",$col); 
    351                 $query = "UPDATE $table SET $set WHERE $where"; 
    352                 //echo "<p>debug query: $query</p>\n"; 
    353                 $GLOBALS['egw_setup']->db->query($query,__LINE__,__FILE__); 
    354  
    355                 */ 
    356  
    357                 #updating the current version 
    358                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.000'; 
    359                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    360         } 
    361  
    362         $test[] = '1.2.01.000'; 
    363         function workflow_upgrade1_2_01_000() 
    364         { 
    365                 #updating the current version 
    366                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.001'; 
    367                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    368         } 
    369  
    370         $test[] = '1.2.01.001'; 
    371         function workflow_upgrade1_2_01_001() 
    372         { 
    373                 #updating the current version 
    374                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.002'; 
    375                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    376         } 
    377  
    378         $test[] = '1.2.01.002'; 
    379         function workflow_upgrade1_2_01_002() 
    380         { 
    381                 #updating the current version 
    382                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.003'; 
    383                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    384         } 
    385  
    386         $test[] = '1.2.01.003'; 
    387         function workflow_upgrade1_2_01_003() 
    388         { 
    389                 #updating the current version 
    390                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.004'; 
    391                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    392         } 
    393  
    394         $test[] = '1.2.01.004'; 
    395         function workflow_upgrade1_2_01_004() 
    396         { 
    397                 #updating the current version 
    398                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.005'; 
    399                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    400         } 
    401  
    402         $test[] = '1.2.01.005'; 
    403         function workflow_upgrade1_2_01_005() 
    404         { 
    405                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    406                 { 
    407                         $workflowHostInfo = extractDatabaseParameters(); 
    408  
    409                         /* create the workflow database */ 
    410                         $GLOBALS['phpgw']->ADOdb->query("CREATE DATABASE workflow WITH OWNER = postgres TEMPLATE = template0 ENCODING = 'LATIN1'"); 
    411                         $GLOBALS['phpgw']->ADOdb->query("CREATE USER admin_workflow WITH PASSWORD 'admin_workflow' NOCREATEDB NOCREATEUSER VALID UNTIL 'infinity'"); 
    412                         $GLOBALS['phpgw']->ADOdb->query("CREATE GROUP workflow"); 
    413                         $GLOBALS['phpgw']->ADOdb->query("ALTER GROUP workflow ADD USER admin_workflow"); 
    414                         $GLOBALS['phpgw']->ADOdb->query("GRANT workflow TO admin_workflow"); 
    415  
    416                         /* connect to the new database */ 
    417                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    418                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    419                         { 
    420                                 /* create a sample application (Music CD Loan) */ 
    421                                 $workflowDB->query("CREATE USER admin_cds WITH PASSWORD 'admin_cds' NOCREATEDB NOCREATEUSER VALID UNTIL 'infinity'"); 
    422                                 $workflowDB->query("ALTER GROUP workflow ADD USER admin_cds"); 
    423                                 $workflowDB->query("CREATE SCHEMA cds AUTHORIZATION admin_cds"); 
    424                                 $workflowDB->query("GRANT ALL ON SCHEMA cds TO admin_cds"); 
    425                                 $workflowDB->query("GRANT ALL ON SCHEMA cds TO postgres"); 
    426                                 $workflowDB->query("CREATE TABLE cds.cdcollection(cdid int4 NOT NULL, title varchar(200), status varchar(40), usuario varchar(200), CONSTRAINT cdcollection_pkey PRIMARY KEY (cdid))"); 
    427                                 $workflowDB->query("ALTER TABLE cds.cdcollection OWNER TO admin_cds"); 
    428                                 $workflowDB->query("GRANT ALL ON TABLE cds.cdcollection TO postgres WITH GRANT OPTION"); 
    429                                 $workflowDB->query("GRANT ALL ON TABLE cds.cdcollection TO admin_cds"); 
    430                                 $workflowDB->query("COMMENT ON TABLE cds.cdcollection IS 'Exemplo de Empréstimo de CDs'"); 
    431                                 $workflowDB->query("INSERT INTO cdcollection VALUES (1, 'Iron Maiden - Powerslave', 'disponivel', '')"); 
    432                                 $workflowDB->query("INSERT INTO cdcollection VALUES (2, 'Pink Floyd - The Wall', 'disponivel', '')"); 
    433                                 $workflowDB->query("INSERT INTO cdcollection VALUES (3, 'Deep Purple - Fireball', 'disponivel', '')"); 
    434  
    435                                 /* create the new tables */ 
    436                                 $workflowDB->query('CREATE TABLE organizacao (organizacao_id serial NOT NULL, nome character varying(20) NOT NULL, descricao character varying(100) NOT NULL)'); 
    437                                 $workflowDB->query('CREATE TABLE area_status (area_status_id serial NOT NULL, organizacao_id integer NOT NULL, descricao character varying(50) NOT NULL, nivel integer NOT NULL)'); 
    438                                 $workflowDB->query('CREATE TABLE centro_custo (organizacao_id integer NOT NULL, centro_custo_id serial NOT NULL, nm_centro_custo integer NOT NULL, grupo character varying(30), descricao character varying(100) NOT NULL)'); 
    439                                 $workflowDB->query('CREATE TABLE localidade (organizacao_id integer NOT NULL, localidade_id serial NOT NULL, centro_custo_id integer, descricao character varying(50) NOT NULL)'); 
    440                                 $workflowDB->query('CREATE TABLE funcionario (funcionario_id character varying NOT NULL, area_id integer NOT NULL, localidade_id integer NOT NULL, centro_custo_id integer NOT NULL, organizacao_id integer NOT NULL, funcionario_status_id integer NOT NULL)'); 
    441                                 $workflowDB->query('CREATE TABLE area (organizacao_id integer NOT NULL, area_id serial NOT NULL, area_status_id integer NOT NULL, areasup_organizacao_id integer, superior_area_id integer, centro_custo_id integer, titular_funcionario_id character varying, substituto_funcionario_id character varying, sigla character varying(20) NOT NULL, descricao character varying(100) NOT NULL, ativa character varying(1) NOT NULL)'); 
    442                                 $workflowDB->query('CREATE TABLE funcionario_status (funcionario_status_id serial NOT NULL, descricao character varying(50) NOT NULL)'); 
    443                                 $workflowDB->query('CREATE TABLE admin_access (admin_access_id integer NOT NULL, tipo character(3) NOT NULL, numvalue smallint NOT NULL, nivel integer DEFAULT 0)'); 
    444                                 $workflowDB->query('CREATE TABLE aplicacao_externa (apl_in_id serial NOT NULL, apl_st_nome character varying(50) NOT NULL, apl_st_descricao text, apl_st_imagem character varying(100), apl_st_endereco character varying(120) NOT NULL, apl_bt_autentica bit(1), apl_st_post text, apl_in_responsavel integer NOT NULL, apl_in_area integer NOT NULL)'); 
    445                                 $workflowDB->query('CREATE TABLE aplicacao_externa_acl (apl_in_id integer NOT NULL, apl_in_uid integer NOT NULL)'); 
    446  
    447                                 /* add the constraints */ 
    448                                 $workflowDB->query('ALTER TABLE ONLY organizacao ADD CONSTRAINT organizacao_pkey PRIMARY KEY (organizacao_id)'); 
    449                                 $workflowDB->query('ALTER TABLE ONLY area_status ADD CONSTRAINT areastatus_pkey PRIMARY KEY (area_status_id, organizacao_id)'); 
    450                                 $workflowDB->query('ALTER TABLE ONLY centro_custo ADD CONSTRAINT centrocusto_pkey PRIMARY KEY (organizacao_id, centro_custo_id)'); 
    451                                 $workflowDB->query('ALTER TABLE ONLY localidade ADD CONSTRAINT localidade_pkey PRIMARY KEY (organizacao_id, localidade_id)'); 
    452                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT funcionario_pkey PRIMARY KEY (funcionario_id)'); 
    453                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT area_pkey PRIMARY KEY (organizacao_id, area_id)'); 
    454                                 $workflowDB->query('ALTER TABLE ONLY funcionario_status ADD CONSTRAINT funcionario_status_pkey PRIMARY KEY (funcionario_status_id)'); 
    455                                 $workflowDB->query('ALTER TABLE ONLY area_status ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
    456                                 $workflowDB->query('ALTER TABLE ONLY centro_custo ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
    457                                 $workflowDB->query('ALTER TABLE ONLY localidade ADD CONSTRAINT "$1" FOREIGN KEY (centro_custo_id, organizacao_id) REFERENCES centro_custo(centro_custo_id, organizacao_id)'); 
    458                                 $workflowDB->query('ALTER TABLE ONLY localidade ADD CONSTRAINT "$2" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
    459                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id, centro_custo_id) REFERENCES centro_custo(organizacao_id, centro_custo_id)'); 
    460                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$2" FOREIGN KEY (organizacao_id, localidade_id) REFERENCES localidade(organizacao_id, localidade_id)'); 
    461                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$1" FOREIGN KEY (superior_area_id, areasup_organizacao_id) REFERENCES area(area_id, organizacao_id)'); 
    462                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$2" FOREIGN KEY (centro_custo_id, organizacao_id) REFERENCES centro_custo(centro_custo_id, organizacao_id)'); 
    463                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$5" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
    464                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$6" FOREIGN KEY (area_status_id, organizacao_id) REFERENCES area_status(area_status_id, organizacao_id)'); 
    465                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$3" FOREIGN KEY (organizacao_id, area_id) REFERENCES area(organizacao_id, area_id)'); 
    466                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$4" FOREIGN KEY (funcionario_status_id) REFERENCES funcionario_status(funcionario_status_id)'); 
    467                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$3" FOREIGN KEY (titular_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
    468                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$4" FOREIGN KEY (substituto_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
    469                                 $workflowDB->query('ALTER TABLE ONLY admin_access ADD CONSTRAINT admin_access_pkey PRIMARY KEY (admin_access_id, tipo, numvalue)'); 
    470                                 $workflowDB->query('ALTER TABLE ONLY aplicacao_externa ADD CONSTRAINT seq_aplicacao_externa PRIMARY KEY (apl_in_id)'); 
    471                                 $workflowDB->query('ALTER TABLE ONLY aplicacao_externa_acl ADD CONSTRAINT pk_aplicacao_externa_acl PRIMARY KEY (apl_in_id, apl_in_uid)'); 
    472                                 $workflowDB->query('ALTER TABLE ONLY aplicacao_externa_acl ADD CONSTRAINT fk01_aplicacao_externa_acl FOREIGN KEY (apl_in_id) REFERENCES aplicacao_externa(apl_in_id) ON UPDATE CASCADE ON DELETE CASCADE'); 
    473  
    474                                 /* set the permissions to the database objects */ 
    475                                 $dbObjects = array('organizacao', 'area_status', 'centro_custo', 'localidade', 'funcionario', 'area', 'funcionario_status', 'organizacao_organizacao_id_seq', 'area_status_area_status_id_seq', 'centro_custo_centro_custo_id_seq', 'localidade_localidade_id_seq', 'area_area_id_seq', 'funcionario_status_funcionario_status_id_seq', 'admin_access', 'aplicacao_externa', 'aplicacao_externa_apl_in_id_seq', 'aplicacao_externa_acl'); 
    476                                 foreach ($dbObjects as $dbObject) 
    477                                 { 
    478                                         $workflowDB->query("GRANT ALL ON TABLE $dbObject TO admin_workflow"); 
    479                                         $workflowDB->query("GRANT ALL ON TABLE $dbObject TO postgres"); 
    480                                         $workflowDB->query("GRANT SELECT ON TABLE $dbObject TO public"); 
    481                                 } 
    482                         } 
    483  
    484                         /* reconnect to the previous database */ 
    485                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    486                 } 
    487  
    488                 #updating the current version 
    489                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.3.00.000'; 
    490                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    491         } 
    492  
    493         $test[] = '1.3.00.000'; 
    494         function workflow_upgrade1_3_00_000() 
    495         { 
    496                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_interinstance_relations', 
    497                         array( 
    498                                 'fd' => array( 
    499                                         'wf_parent_instance_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    500                                         'wf_parent_activity_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    501                                         'wf_child_instance_id'  => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    502                                         'wf_parent_lock'                => array('type' => 'int', 'precision' => '2', 'nullable' => True) 
    503                                 ), 
    504                                 'pk' => array('wf_parent_instance_id', 'wf_parent_activity_id', 'wf_child_instance_id'), 
    505                                 'fk' => array(), 
    506                                 'ix' => array(), 
    507                                 'uc' => array() 
    508                         ) 
    509                 ); 
    510  
    511                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    512                 { 
    513                         $workflowHostInfo = extractDatabaseParameters(); 
    514  
    515                         /* connect to the workflow database */ 
    516                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    517                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    518                         { 
    519                                 /* change the type of the employee ID (funcionario_id field) */ 
    520                                 $workflowDB->query('ALTER TABLE funcionario ALTER COLUMN centro_custo_id DROP NOT NULL'); 
    521                                 $workflowDB->query('ALTER TABLE area DROP CONSTRAINT "$3"'); 
    522                                 $workflowDB->query('ALTER TABLE area DROP CONSTRAINT "$4"'); 
    523                                 $workflowDB->query('ALTER TABLE funcionario ADD COLUMN funcionario_id2 int4'); 
    524                                 $workflowDB->query('UPDATE funcionario SET funcionario_id2 = int4(funcionario_id)'); 
    525                                 $workflowDB->query('ALTER TABLE funcionario DROP COLUMN funcionario_id'); 
    526                                 $workflowDB->query('ALTER TABLE funcionario RENAME COLUMN funcionario_id2 TO funcionario_id'); 
    527                                 $workflowDB->query('ALTER TABLE funcionario ALTER funcionario_id SET NOT NULL'); 
    528                                 $workflowDB->query('ALTER TABLE funcionario ADD CONSTRAINT funcionario_pkey PRIMARY KEY (funcionario_id)'); 
    529                                 $workflowDB->query('ALTER TABLE area ADD titular_funcionario_id2 int4'); 
    530                                 $workflowDB->query('ALTER TABLE area ADD substituto_funcionario_id2 int4'); 
    531                                 $workflowDB->query('UPDATE area SET titular_funcionario_id2 = int4(titular_funcionario_id), substituto_funcionario_id2 = int4(substituto_funcionario_id)'); 
    532                                 $workflowDB->query('ALTER TABLE area DROP COLUMN titular_funcionario_id'); 
    533                                 $workflowDB->query('ALTER TABLE area DROP COLUMN substituto_funcionario_id'); 
    534                                 $workflowDB->query('ALTER TABLE area RENAME COLUMN titular_funcionario_id2 TO titular_funcionario_id'); 
    535                                 $workflowDB->query('ALTER TABLE area RENAME COLUMN substituto_funcionario_id2 TO substituto_funcionario_id'); 
    536                                 $workflowDB->query('ALTER TABLE area ADD CONSTRAINT "$3" FOREIGN KEY (titular_funcionario_id) REFERENCES funcionario (funcionario_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION'); 
    537                                 $workflowDB->query('ALTER TABLE AREA ADD CONSTRAINT "$4" FOREIGN KEY (substituto_funcionario_id) REFERENCES funcionario (funcionario_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION'); 
    538                         } 
    539  
    540                         /* reconnect to the previous database */ 
    541                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    542                 } 
    543  
    544                 #updating the current version 
    545                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.00.000'; 
    546                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    547         } 
    548  
    549         $test[] = '1.4.00.000'; 
    550         function workflow_upgrade1_4_00_000() 
    551         { 
    552                 #updating the current version 
    553                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.00.001'; 
    554                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    555         } 
    556  
    557         $test[] = '1.4.00.001'; 
    558         function workflow_upgrade1_4_00_001() 
    559         { 
    560                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_menu_path', array('type' => 'varchar', 'precision' => 200, 'nullable' => True)); 
    561  
    562                 #updating the current version 
    563                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.01.000'; 
    564                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    565         } 
    566  
    567         $test[] = '1.4.01.000'; 
    568         function workflow_upgrade1_4_01_000() 
    569         { 
    570                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    571                 { 
    572                         $workflowHostInfo = extractDatabaseParameters(); 
    573  
    574                         /* connect to the new database */ 
    575                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    576                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    577                         { 
    578                                 /* add a new column to the area table (orgchart) */ 
    579                                 $workflowDB->query('ALTER TABLE area ADD COLUMN auxiliar_funcionario_id int4'); 
    580                                 $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$7" FOREIGN KEY (auxiliar_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
    581                         } 
    582  
    583                         /* reconnect to the previous database */ 
    584                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    585                 } 
    586  
    587  
    588  
    589                 #updating the current version 
    590                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.02.000'; 
    591                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    592         } 
    593  
    594         $test[] = '1.4.02.000'; 
    595         function workflow_upgrade1_4_02_000() 
    596         { 
    597                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_admin_access', 
    598                         array( 
    599                                 'fd' => array( 
    600                                         'admin_access_id'               => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    601                                         'tipo'  => array('type' => 'char', 'precision' => '3', 'nullable' => False), 
    602                                         'numvalue'      => array('type' => 'int', 'precision' => '2', 'nullable' => False), 
    603                                         'nivel' => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default' => 0) 
    604                                 ), 
    605                                 'pk' => array('admin_access_id', 'tipo', 'numvalue'), 
    606                                 'fk' => array(), 
    607                                 'ix' => array(), 
    608                                 'uc' => array() 
    609                         ) 
    610                 ); 
    611  
    612                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_external_application', 
    613                         array( 
    614                                 'fd' => array( 
    615                                         'external_application_id' => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    616                                         'name' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False), 
    617                                         'description' => array('type' => 'text', 'nullable' => True), 
    618                                         'image' => array('type' => 'varchar', 'precision' => '100', 'nullable' => True), 
    619                                         'address' => array('type' => 'varchar', 'precision' => '120', 'nullable' => False), 
    620                                         'authentication' => array('type' => 'bit', 'precision' => '1', 'nullable' => True), 
    621                                         'post' => array('type' => 'text', 'nullable' => True) 
    622                                 ), 
    623                                 'pk' => array('external_application_id'), 
    624                                 'fk' => array(), 
    625                                 'ix' => array(), 
    626                                 'uc' => array() 
    627                         ) 
    628                 ); 
    629  
    630                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    631                 { 
    632                         $adminAccessData = array(); 
    633                         $externalApplicationData = array(); 
    634                         $externalApplicationSequence = 1; 
    635                         $externalApplicationACLData = array(); 
    636                         $workflowHostInfo = extractDatabaseParameters(); 
    637                         $GLOBALS['phpgw']->ADOdb->SetFetchMode(ADODB_FETCH_ASSOC); 
    638  
    639                         /* connect to the Workflow database */ 
    640                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    641                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    642                         { 
    643                                 $result = $GLOBALS['phpgw']->ADOdb->query('SELECT admin_access_id, tipo, numvalue, nivel FROM admin_access'); 
    644                                 if ($result) 
    645                                         while ($row = $result->fetchRow()) 
    646                                                 $adminAccessData[] = array($row['admin_access_id'], $row['tipo'], $row['numvalue'], $row['nivel']); 
    647  
    648                                 $result = $GLOBALS['phpgw']->ADOdb->query('SELECT apl_in_id, apl_st_nome, apl_st_descricao, apl_st_imagem, apl_st_endereco, apl_bt_autentica, apl_st_post FROM aplicacao_externa'); 
    649                                 if ($result) 
    650                                         while ($row = $result->fetchRow()) 
    651                                                 $externalApplicationData[] = array($row['apl_in_id'], $row['apl_st_nome'], $row['apl_st_descricao'], $row['apl_st_imagem'], $row['apl_st_endereco'], $row['apl_bt_autentica'], $row['apl_st_post']); 
    652                                 $result = $GLOBALS['phpgw']->ADOdb->query('SELECT last_value FROM aplicacao_externa_apl_in_id_seq'); 
    653                                 if ($result) 
    654                                         if ($row = $result->fetchRow()) 
    655                                                 $externalApplicationSequence = $row['last_value']; 
    656  
    657                                 $result = $GLOBALS['phpgw']->ADOdb->query('SELECT apl_in_uid, apl_in_id FROM aplicacao_externa_acl'); 
    658                                 if ($result) 
    659                                         while ($row = $result->fetchRow()) 
    660                                                 $externalApplicationACLData[] = array($row['apl_in_uid'], $row['apl_in_id']); 
    661  
    662                                 /* remove the unused tables */ 
    663                                 $GLOBALS['phpgw']->ADOdb->query('DROP TABLE admin_access'); 
    664                                 $GLOBALS['phpgw']->ADOdb->query('DROP SEQUENCE aplicacao_externa_apl_in_id_seq'); 
    665                                 $GLOBALS['phpgw']->ADOdb->query('DROP CONSTRAINT fk01_aplicacao_externa_acl'); 
    666                                 $GLOBALS['phpgw']->ADOdb->query('DROP TABLE aplicacao_externa_acl'); 
    667                                 $GLOBALS['phpgw']->ADOdb->query('DROP TABLE aplicacao_externa'); 
    668                         } 
    669  
    670                         /* reconnect to the previous database */ 
    671                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    672                         foreach ($adminAccessData as $newRow) 
    673                                 $result = $GLOBALS['phpgw']->ADOdb->query("INSERT INTO egw_wf_admin_access(admin_access_id, tipo, numvalue, nivel) VALUES (?, ?, ?, ?)", $newRow); 
    674  
    675                         foreach ($externalApplicationData as $newRow) 
    676                                 $result = $GLOBALS['phpgw']->ADOdb->query("INSERT INTO egw_wf_external_application(external_application_id, name, description, image, address, authentication, post) VALUES(?, ?, ?, ?, ?, ?, ?)", $newRow); 
    677                         $GLOBALS['phpgw']->ADOdb->query("SELECT pg_catalog.setval('seq_egw_wf_external_application', ?, true)", array($externalApplicationSequence)); 
    678  
    679                         foreach ($externalApplicationACLData as $newRow) 
    680                                 $result = $GLOBALS['phpgw']->ADOdb->query("INSERT INTO egw_wf_admin_access(admin_access_id, tipo, numvalue, nivel) VALUES (?, 'APX', ?, 0)", $newRow); 
    681                 } 
    682  
    683                 #updating the current version 
    684                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.03.000'; 
    685                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    686         } 
    687  
    688         $test[] = '1.4.03.000'; 
    689         function workflow_upgrade1_4_03_000() 
    690         { 
    691                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    692                 { 
    693                         $workflowHostInfo = extractDatabaseParameters(); 
    694  
    695                         /* connect to the new database */ 
    696                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    697                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    698                         { 
    699                                 /* add a new column to the funcionario_status table (orgchart) */ 
    700                                 $workflowDB->query('ALTER TABLE funcionario_status ADD COLUMN exibir character varying(1)'); 
    701                                 $workflowDB->query('UPDATE funcionario_status SET exibir = ?', array('S')); 
    702                                 $workflowDB->query('ALTER TABLE funcionario_status ALTER COLUMN exibir SET NOT NULL'); 
    703                         } 
    704  
    705                         /* reconnect to the previous database */ 
    706                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    707                 } 
    708  
    709                 #updating the current version 
    710                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.04.000'; 
    711                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    712         } 
    713  
    714         $test[] = '1.4.04.000'; 
    715         function workflow_upgrade1_4_04_000() 
    716         { 
    717                 /* remove unused table */ 
    718                 $GLOBALS['phpgw_setup']->oProc->DropTable('egw_wf_instance_supplements'); 
    719  
    720                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    721                 { 
    722                         $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_instances ALTER COLUMN wf_next_user TYPE text'); 
    723                         $GLOBALS['phpgw']->ADOdb->SetFetchMode(ADODB_FETCH_ASSOC); 
    724                         $result = $GLOBALS['phpgw']->ADOdb->query('SELECT i.wf_instance_id, ia.wf_activity_id, i.wf_next_user FROM egw_wf_instances i, egw_wf_instance_activities ia WHERE (i.wf_instance_id = ia.wf_instance_id) AND (i.wf_next_user IS NOT NULL)'); 
    725                         if (!empty($result)) 
    726                         { 
    727                                 while ($res = $result->fetchRow()) 
    728                                 { 
    729                                         $newNextUser = base64_encode(serialize(array('*' . $res['wf_activity_id'] => $res['wf_next_user']))); 
    730                                         $ok = $GLOBALS['phpgw']->ADOdb->query( 
    731                                                 'UPDATE egw_wf_instances SET wf_next_user = ? WHERE (wf_instance_id = ?)', 
    732                                                 array($newNextUser, (int)$res['wf_instance_id']) 
    733                                         ); 
    734                                 } 
    735                         } 
    736  
    737                         $workflowHostInfo = extractDatabaseParameters(); 
    738  
    739                         /* connect to the new database */ 
    740                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    741                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    742                         { 
    743                                 /* add a new column to the organizacao table (orgchart) */ 
    744                                 $workflowDB->query('ALTER TABLE organizacao ADD COLUMN url_imagem character varying(200)'); 
    745                         } 
    746  
    747                         /* reconnect to the previous database */ 
    748                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    749                 } 
    750  
    751                 #updating the current version 
    752                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.05.000'; 
    753                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    754         } 
    755  
    756         $test[] = '1.4.05.000'; 
    757         function workflow_upgrade1_4_05_000() 
    758         { 
    759                 $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_external_application' ,'intranet_only', array('type' => 'bit', 'precision' => '1', 'nullable' => True)); 
    760  
    761                 #updating the current version 
    762                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.4.06.000'; 
    763                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    764         } 
    765  
    766         $test[] = '1.4.06.000'; 
    767         function workflow_upgrade1_4_06_000() 
    768         { 
    769                 #updating the current version 
    770                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.6.00.000'; 
    771                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    772         } 
    773  
    774         $test[] = '1.6.00.000'; 
    775         function workflow_upgrade1_6_00_000() 
    776         { 
    777                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    778                 { 
    779                         $workflowHostInfo = extractDatabaseParameters(); 
    780  
    781                         /* connect to the new database */ 
    782                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    783                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    784                         { 
    785                                 /* create the new tables and add the referencial constraints */ 
    786                                 $workflowDB->query('CREATE TABLE cargo (cargo_id serial NOT NULL, descricao character varying(150), organizacao_id int4)'); 
    787                                 $workflowDB->query('ALTER TABLE ONLY cargo ADD CONSTRAINT cargo_pkey PRIMARY KEY (cargo_id)'); 
    788                                 $workflowDB->query('ALTER TABLE ONLY cargo ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao (organizacao_id)'); 
    789                                 $workflowDB->query('CREATE TABLE funcionario_categoria (funcionario_categoria_id serial NOT NULL, descricao character varying(150), organizacao_id int4)'); 
    790                                 $workflowDB->query('ALTER TABLE ONLY funcionario_categoria ADD CONSTRAINT funcionario_categoria_pkey PRIMARY KEY (funcionario_categoria_id)'); 
    791                                 $workflowDB->query('ALTER TABLE ONLY funcionario_categoria ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao (organizacao_id)'); 
    792  
    793                                 /* add a new column to the organizacao table (orgchart) */ 
    794                                 $workflowDB->query('ALTER TABLE funcionario ADD COLUMN cargo_id int4'); 
    795                                 $workflowDB->query('ALTER TABLE funcionario ADD COLUMN nivel int2'); 
    796                                 $workflowDB->query('ALTER TABLE funcionario ADD COLUMN funcionario_categoria_id int4'); 
    797                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$5" FOREIGN KEY (cargo_id) REFERENCES cargo (cargo_id)'); 
    798                                 $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$6" FOREIGN KEY (funcionario_categoria_id) REFERENCES funcionario_categoria (funcionario_categoria_id)'); 
    799  
    800                                 /* set the permissions to the database objects */ 
    801                                 $dbObjects = array('cargo', 'cargo_cargo_id_seq', 'funcionario_categoria', 'funcionario_categoria_funcionario_categoria_id_seq'); 
    802                                 foreach ($dbObjects as $dbObject) 
    803                                 { 
    804                                         $workflowDB->query("GRANT ALL ON TABLE $dbObject TO admin_workflow"); 
    805                                         $workflowDB->query("GRANT ALL ON TABLE $dbObject TO postgres"); 
    806                                         $workflowDB->query("GRANT SELECT ON TABLE $dbObject TO public"); 
    807                                 } 
    808                         } 
    809  
    810                         /* reconnect to the previous database */ 
    811                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    812                 } 
    813  
    814                 #updating the current version 
    815                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.6.01.000'; 
    816                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    817         } 
    818  
    819         $test[] = '1.6.01.000'; 
    820         function workflow_upgrade1_6_01_000() 
    821         { 
    822                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    823                 { 
    824                         /* tries to load the 'files_dir' value (usually '/home/expressolivre') */ 
    825                         $GLOBALS['phpgw']->ADOdb->SetFetchMode(ADODB_FETCH_ASSOC); 
    826                         $result = $GLOBALS['phpgw']->ADOdb->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir')); 
    827                         if (!(empty($result))) 
    828                         { 
    829                                 $res = $result->fetchRow(); 
    830  
    831                                 /* initialize some variables */ 
    832                                 $resourcesBase = $res['config_value']; 
    833                                 $oldResourcesDir = PHPGW_SERVER_ROOT . '/workflow/resources'; 
    834                                 $success = true; 
    835  
    836                                 /* if the resources dir exists, move it's subdirectories */ 
    837                                 if (is_dir($oldResourcesDir)) 
    838                                 { 
    839                                         $success = false; 
    840                                         $handle = opendir($oldResourcesDir); 
    841                                         if ($handle) 
    842                                         { 
    843                                                 $success = true; 
    844                                                 $OKToDeleteDir = true; 
    845  
    846                                                 /* move all subdirectories (except the '.' and '..' for oubvious reasons) to their new place */ 
    847                                                 while (false !== ($processDir = readdir($handle))) 
    848                                                 { 
    849                                                         if (($processDir == '.') || ($processDir == '..')) 
    850                                                                 continue; 
    851  
    852                                                         /* check if we are dealing with a directory */ 
    853                                                         if (!is_dir($oldResourcesDir . '/' . $processDir)) 
    854                                                         { 
    855                                                                 $OKToDeleteDir = false; 
    856                                                                 continue; 
    857                                                         } 
    858  
    859                                                         /* special treatment for the workflow directory */ 
    860                                                         if ($processDir == 'workflow') 
    861                                                         { 
    862                                                                 $success = $success && @rename($oldResourcesDir . '/' . $processDir, $resourcesBase . '/workflow/workflow'); 
    863                                                                 continue; 
    864                                                         } 
    865  
    866                                                         /* if the destination directory exists, move it */ 
    867                                                         $newProcessDir = $resourcesBase . '/workflow/' . $processDir; 
    868                                                         if (is_dir($newProcessDir)) 
    869                                                                 $success = $success && @rename($oldResourcesDir . '/' . $processDir, $newProcessDir . '/resources'); 
    870                                                         else 
    871                                                                 $OKToDeleteDir = false; 
    872                                                 } 
    873  
    874                                                 /* close the handler */ 
    875                                                 closedir($handle); 
    876  
    877                                                 /* if the directory is empty, remove it */ 
    878                                                 if ($OKToDeleteDir && $success) 
    879                                                         if (!@rmdir($oldResourcesDir)) 
    880                                                                 echo '<font color="red">Não foi possível remover o diretório: ' . $oldResourcesDir . '<br/> Tente removê-lo manualmente.</font>'; 
    881                                         } 
    882                                 } 
    883  
    884                                 /* in case of an unsuccessful attemp to move a directory, warn the system admin */ 
    885                                 if (!$success) 
    886                                         echo '<font color="red">Pelo menos um diretório não pode ser movido. Você precisa mover, manualmente, os diretórios de resources dos processos. Exemplo: <br/><strong>' . $oldResourcesDir . '/PROCESSO_XX</strong> para <strong>' . $resourcesBase . '/workflow/PROCESSO_XX/resources</strong></font>'; 
    887                         } 
    888  
    889                 } 
    890  
    891                 /* updates the current version */ 
    892                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.6.02.000'; 
    893                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    894         } 
    895  
    896         $test[] = '1.6.02.000'; 
    897         function workflow_upgrade1_6_02_000() 
    898         { 
    899                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_user_cache', 
    900                         array( 
    901                                 'fd' => array( 
    902                                         'uidnumber'                     => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    903                                         'uid'                           => array('type' => 'varchar', 'precision' => '30', 'nullable' => True), 
    904                                         'cn'                            => array('type' => 'varchar', 'precision' => '100', 'nullable' => True), 
    905                                         'givenname'                     => array('type' => 'varchar', 'precision' => '30', 'nullable' => True), 
    906                                         'sn'                            => array('type' => 'varchar', 'precision' => '70', 'nullable' => True), 
    907                                         'mail'                          => array('type' => 'varchar', 'precision' => '80', 'nullable' => True), 
    908                                         'accountstatus'         => array('type' => 'varchar', 'precision' => '80', 'nullable' => True), 
    909                                         'dn'                            => array('type' => 'varchar', 'precision' => '150', 'nullable' => True), 
    910                                         'employeenumber'        => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    911                                         'cpf'                           => array('type' => 'varchar', 'precision' => '15', 'nullable' => True), 
    912                                         'telephonenumber'       => array('type' => 'varchar', 'precision' => '50', 'nullable' => True), 
    913                                         'last_update'           => array('type' => 'timestamp without time zone default now()', 'nullable' => True) 
    914                                 ), 
    915                                 'pk' => array('uidnumber'), 
    916                                 'fk' => array(), 
    917                                 'ix' => array('mail', 'employeenumber', 'cpf'), 
    918                                 'uc' => array() 
    919                         ) 
    920                 ); 
    921  
    922                 #updating the current version 
    923                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.6.03.000'; 
    924                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    925         } 
    926  
    927         $test[] = '1.6.03.000'; 
    928         function workflow_upgrade1_6_03_000() 
    929         { 
    930                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    931                 { 
    932                         $workflowHostInfo = extractDatabaseParameters(); 
    933  
    934                         /* connect to the new database */ 
    935                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    936                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    937                         { 
    938                                 $result = $workflowDB->query("SELECT 1 FROM pg_tables WHERE (schemaname = 'public') AND (tablename = 'funcionario_status')"); 
    939                                 $row = array(); 
    940                                 if (!empty($result)) 
    941                                         $row = $result->fetchRow(); 
    942  
    943                                 /* only some instalations are missing this table */ 
    944                                 if ($row === false) 
    945                                 { 
    946                                         $workflowDB->query('CREATE TABLE funcionario_status (funcionario_status_id serial NOT NULL, descricao character varying(50) NOT NULL, exibir character varying(1) NOT NULL)'); 
    947                                         $workflowDB->query('ALTER TABLE ONLY funcionario_status ADD CONSTRAINT funcionario_status_pkey PRIMARY KEY (funcionario_status_id)'); 
    948                                         $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT "$4" FOREIGN KEY (funcionario_status_id) REFERENCES funcionario_status(funcionario_status_id)'); 
    949  
    950                                         $dbObjects = array('funcionario_status', 'funcionario_status_funcionario_status_id_seq'); 
    951                                         foreach ($dbObjects as $dbObject) 
    952                                         { 
    953                                                 $workflowDB->query("GRANT ALL ON TABLE $dbObject TO admin_workflow"); 
    954                                                 $workflowDB->query("GRANT ALL ON TABLE $dbObject TO postgres"); 
    955                                                 $workflowDB->query("GRANT SELECT ON TABLE $dbObject TO public"); 
    956                                         } 
    957                                 } 
    958                         } 
    959                         /* reconnect to the previous database */ 
    960                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    961                 } 
    962  
    963                 #updating the current version 
    964                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.6.03.001'; 
    965                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    966         } 
    967  
    968         $test[] = '1.6.03.001'; 
    969         function workflow_upgrade1_6_03_001() 
    970         { 
    971                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_jobs', 
    972                         array( 
    973                                 'fd' => array( 
    974                                         'job_id'                        => array('type' => 'auto', 'precision' => '4', 'nullable' => False), 
    975                                         'wf_process_id'         => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    976                                         'name'                          => array('type' => 'varchar', 'precision' => '100', 'nullable' => False), 
    977                                         'description'           => array('type' => 'text', 'nullable' => True), 
    978                                         'time_start'            => array('type' => 'timestamp without time zone', 'nullable' => False), 
    979                                         'interval_value'        => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    980                                         'interval_unity'        => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    981                                         'date_type'                     => array('type' => 'int', 'precision' => '4', 'nullable' => True), 
    982                                         'week_days'                     => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default' => 0), 
    983                                         'month_offset'          => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default' => 0), 
    984                                         'active'                        => array('type' => 'bool', 'nullable' => True) 
    985                                 ), 
    986                                 'pk' => array('job_id'), 
    987                                 'fk' => array(), 
    988                                 'ix' => array(), 
    989                                 'uc' => array() 
    990                         ) 
    991                 ); 
    992  
    993                 $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_job_logs', 
    994                         array( 
    995                                 'fd' => array( 
    996                                         'job_id'                => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    997                                         'date_time'             => array('type' => 'timestamp without time zone', 'nullable' => False), 
    998                                         'result'                => array('type' => 'blob', 'nullable' => True), 
    999                                         'status'                => array('type' => 'int', 'precision' => '4', 'nullable' => True) 
    1000                                 ), 
    1001                                 'pk' => array('job_id', 'date_time'), 
    1002                                 'fk' => array(), 
    1003                                 'ix' => array(), 
    1004                                 'uc' => array() 
    1005                         ) 
    1006                 ); 
    1007  
    1008                 #updating the current version 
    1009                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.7.00.000'; 
    1010                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    1011         } 
    1012  
    1013         $test[] = '1.7.00.000'; 
    1014         function workflow_upgrade1_7_00_000() 
    1015         { 
    1016                 #updating the current version 
    1017                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.00.000'; 
    1018                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    1019         } 
    1020  
    1021         $test[] = '1.8.00.000'; 
    1022         function workflow_upgrade1_8_00_000() 
    1023         { 
    1024                 #updating the current version 
    1025                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.01.000'; 
    1026                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    1027         } 
    1028  
    1029         $test[] = '1.8.01.000'; 
    1030         function workflow_upgrade1_8_01_000() 
    1031         { 
    1032                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    1033                 { 
    1034                         $GLOBALS['phpgw']->ADOdb->query('CREATE INDEX egw_wf_instances_wf_name_idx ON egw_wf_instances(UPPER(wf_name))'); 
    1035                         $GLOBALS['phpgw']->ADOdb->query('CREATE INDEX egw_wf_instances_wf_p_id_idx ON egw_wf_instances(wf_p_id)'); 
    1036                         $GLOBALS['phpgw']->ADOdb->query('DELETE FROM phpgw_config where config_app = \'workflow\' and config_name in (\'database_user\', \'database_password\')'); 
    1037  
    1038                         $workflowHostInfo = extractDatabaseParameters(); 
    1039  
    1040                         /* connect to the new database */ 
    1041                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    1042                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    1043                         { 
    1044                                 /* add a new column to the area organization (orgchart) */ 
    1045                                 $workflowDB->query('ALTER TABLE organizacao ADD COLUMN ativa character varying(1)'); 
    1046                                 $workflowDB->query('UPDATE organizacao SET ativa = \'S\''); 
    1047                                 $workflowDB->query('ALTER TABLE organizacao ALTER ativa SET NOT NULL'); 
    1048                         } 
    1049  
    1050                         /* reconnect to the previous database */ 
    1051                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    1052                 } 
    1053  
    1054                 #updating the current version 
    1055                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.02.000'; 
    1056                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    1057         } 
    1058  
    1059         $test[] = '1.8.02.000'; 
    1060         function workflow_upgrade1_8_02_000() 
    1061         { 
    1062                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    1063                 { 
    1064                         $workflowHostInfo = extractDatabaseParameters(); 
    1065  
    1066                         /* connect to the new database */ 
    1067                         $workflowDB = $GLOBALS['phpgw']->ADOdb; 
    1068                         if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
    1069                         { 
    1070                                 /* gather some information */ 
    1071                                 $workflowDB->setFetchMode(ADODB_FETCH_ASSOC); 
    1072                                 $organizations = $workflowDB->GetAll('SELECT organizacao_id FROM organizacao'); 
    1073                                 $employeeStatus = $workflowDB->GetAll('SELECT funcionario_status_id, descricao, exibir FROM funcionario_status'); 
    1074  
    1075                                 /* add the new column */ 
    1076                                 $workflowDB->query('ALTER TABLE funcionario_status ADD COLUMN organizacao_id INTEGER'); 
    1077                                 if (count($organizations) > 0) 
    1078                                 { 
    1079                                         /* run update for the first organization */ 
    1080                                         $workflowDB->query('UPDATE funcionario_status SET organizacao_id = ?', array($organizations[0]['organizacao_id'])); 
    1081  
    1082                                         /* replicate the 'funcionario_status' table information for other organizations */ 
    1083                                         for ($i = 1; $i < count($organizations); $i++) 
    1084                                         { 
    1085                                                 $organizationID = $organizations[$i]['organizacao_id']; 
    1086                                                 foreach ($employeeStatus as $es) 
    1087                                                 { 
    1088                                                         $values = array( 
    1089                                                                 $es['descricao'], 
    1090                                                                 $es['exibir'], 
    1091                                                                 $organizationID 
    1092                                                         ); 
    1093  
    1094                                                         /* insert the new status */ 
    1095                                                         $workflowDB->query('INSERT INTO funcionario_status (descricao, exibir, organizacao_id) VALUES (?, ?, ?)', $values); 
    1096  
    1097                                                         $values = array( 
    1098                                                                 $organizationID, 
    1099                                                                 $es['funcionario_status_id'] 
    1100                                                         ); 
    1101  
    1102                                                         /* update the existing employees */ 
    1103                                                         $workflowDB->query('UPDATE funcionario SET funcionario_status_id = (SELECT MAX(funcionario_status_id) FROM funcionario_status) WHERE (organizacao_id = ?) AND (funcionario_status_id = ?)', $values); 
    1104                                                 } 
    1105                                         } 
    1106                                 } 
    1107                                 /* add the new constraint */ 
    1108                                 $workflowDB->query('ALTER TABLE ONLY funcionario_status ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
    1109                         } 
    1110  
    1111                         /* reconnect to the previous database */ 
    1112                         $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
    1113                 } 
    1114  
    1115                 #updating the current version 
    1116                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.03.000'; 
    1117                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    1118         } 
    1119  
    1120         $test[] = '1.8.03.000'; 
    1121         function workflow_upgrade1_8_03_000() 
    1122         { 
    1123                 /* setting new default attributes for workflow Logger  */ 
    1124                 if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
    1125                 { 
    1126                         $GLOBALS['phpgw']->ADOdb->query('INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES (\'workflow\', \'log_type_file\', \'True\')'); 
    1127                         $GLOBALS['phpgw']->ADOdb->query('INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES (\'workflow\', \'log_type_firebug\', \'True\')'); 
    1128                         $GLOBALS['phpgw']->ADOdb->query('INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES (\'workflow\', \'log_level\', \'7\')'); 
    1129                 } 
    1130  
    1131                 #updating the current version 
    1132                 $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.04.000'; 
    1133                 return $GLOBALS['setup_info']['workflow']['currentver']; 
    1134         } 
    1135  
     41        // Since Expresso 1.2 using Workflow 1.8.04.000 
    113642        $test[] = '1.8.04.000'; 
    113743        function workflow_upgrade1_8_04_000() 
     
    1216122        { 
    1217123                #updating the current version 
     124                $GLOBALS['setup_info']['workflow']['currentver'] = '2.0.003'; 
     125                return $GLOBALS['setup_info']['workflow']['currentver']; 
     126        } 
     127        $test[] = '2.0.003'; 
     128        function workflow_upgrade2_0_003() 
     129        { 
     130                #updating the current version 
     131                $GLOBALS['setup_info']['workflow']['currentver'] = '2.0.004'; 
     132                return $GLOBALS['setup_info']['workflow']['currentver']; 
     133        }        
     134        $test[] = '2.0.004'; 
     135        function workflow_upgrade2_0_004() 
     136        { 
     137                #updating the current version 
    1218138                $GLOBALS['setup_info']['workflow']['currentver'] = '2.1.000'; 
    1219139                return $GLOBALS['setup_info']['workflow']['currentver']; 
    1220140        } 
     141        $test[] = '2.1.000'; 
     142        function workflow_upgrade2_1_000() 
     143        { 
     144                $GLOBALS['setup_info']['workflow']['currentver'] = '2.2.000'; 
     145                return $GLOBALS['setup_info']['workflow']['currentver']; 
     146        }        
    1221147?> 
Note: See TracChangeset for help on using the changeset viewer.