[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * phpGroupWare - Setup * |
---|
| 4 | * http://www.phpgroupware.org * |
---|
| 5 | * -------------------------------------------- * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 7 | * under the terms of the GNU General Public License as published by the * |
---|
| 8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 9 | * option) any later version. * |
---|
| 10 | \**************************************************************************/ |
---|
| 11 | $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 | } |
---|
[285] | 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)"); |
---|
[308] | 66 | $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.15'; |
---|
[285] | 67 | return $GLOBALS['setup_info']['contactcenter']['currentver']; |
---|
| 68 | } |
---|
| 69 | $test[] = '1.15'; |
---|
[308] | 70 | function contactcenter_upgrade1_15() { |
---|
| 71 | $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_contact','last_status', array('type' => 'char', 'precision' => 1, 'default' => 'N')); |
---|
[533] | 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 | } |
---|
[285] | 78 | $GLOBALS['setup_info']['contactcenter']['currentver'] = '1.20'; |
---|
| 79 | return $GLOBALS['setup_info']['contactcenter']['currentver']; |
---|
| 80 | } |
---|
[307] | 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 | } |
---|
[533] | 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 | } |
---|
[1323] | 118 | $test[] = '1.21'; |
---|
| 119 | function contactcenter_upgrade1_21() { |
---|
| 120 | $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.0.000'; |
---|
[1359] | 121 | // Bug fixing for type cast problem PGSQL version > 8.1. Replacing trigger function: |
---|
| 122 | $GLOBALS['phpgw_setup']->db->query("CREATE OR REPLACE function share_catalog_delete() returns trigger as '". |
---|
| 123 | "begin if old.acl_appname = ''contactcenter'' and old.acl_location!=''run'' then delete from ". |
---|
| 124 | "phpgw_cc_contact_rels where id_contact=old.acl_location::bigint and id_related=old.acl_account ". |
---|
| 125 | "and id_typeof_contact_relation=1; end if; return new; end;' language 'plpgsql'"); |
---|
[1323] | 126 | return $GLOBALS['setup_info']['contactcenter']['currentver']; |
---|
| 127 | } |
---|
[1728] | 128 | $test[] = '2.0.000'; |
---|
| 129 | function contactcenter_upgrade2_0_000() { |
---|
[1665] | 130 | $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.0.001'; |
---|
| 131 | $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN web_page character varying(100)"); |
---|
| 132 | $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN corporate_name character varying(100)"); |
---|
| 133 | $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN job_title character varying(40)"); |
---|
| 134 | $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ADD COLUMN department character varying(30)"); |
---|
| 135 | return $GLOBALS['setup_info']['contactcenter']['currentver']; |
---|
| 136 | } |
---|
[1728] | 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 | } |
---|
[2154] | 142 | $test[] = '2.1.000'; |
---|
| 143 | function contactcenter_upgrade2_1_000() { |
---|
| 144 | $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cc_city','is_district', array('type' => 'boolean', 'precision' => 1, 'default' => TRUE)); |
---|
| 145 | $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.2.000'; |
---|
| 146 | return $GLOBALS['setup_info']['contactcenter']['currentver']; |
---|
| 147 | } |
---|
[2] | 148 | ?> |
---|