source: branches/2.2/workflow/setup/tables_update.inc.php @ 3031

Revision 3031, 6.4 KB checked in by niltonneto, 11 years ago (diff)

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

  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare - Setup                                                       *
4        * http://www.egroupware.org                                                *
5        * --------------------------------------------                             *
6        *  This program is free software; you can redistribute it and/or modify it *
7        *  under the terms of the GNU General Public License as published by the   *
8        *  Free Software Foundation; either version 2 of the License, or (at your  *
9        *  option) any later version.                                              *
10        \**************************************************************************/
11
12        function extractDatabaseParameters()
13        {
14                /* extract the database connection parameters */
15
16                $workflowHostInfo = array();
17                if (!empty($GLOBALS['phpgw']->ADOdb->database))
18                {
19                        $workflowHostInfo = array(
20                                'dbname' => $GLOBALS['phpgw']->ADOdb->database,
21                                'host' => $GLOBALS['phpgw']->ADOdb->host,
22                                'port' => $GLOBALS['phpgw']->ADOdb->port,
23                                'user' => $GLOBALS['phpgw']->ADOdb->user,
24                                'password' => $GLOBALS['phpgw']->ADOdb->password);
25                }
26                else
27                {
28                        $hostInfo = "dbname= host= password= port= user= " . $GLOBALS['phpgw']->ADOdb->host;
29                        $hostInfo = explode(' ', $hostInfo);
30                        foreach ($hostInfo as $parameter)
31                        {
32                                $currentParameter = explode('=', $parameter);
33                                $workflowHostInfo[$currentParameter[0]] = isset($currentParameter[1]) ? $currentParameter[1] : "";
34                        }
35                }
36                if (($workflowHostInfo['password']{0} == "'") && ($workflowHostInfo['password']{strlen($workflowHostInfo['password'])-1} == "'"))
37                        $workflowHostInfo['password'] = substr($workflowHostInfo['password'], 1, strlen($workflowHostInfo['password']) - 2);
38
39                return $workflowHostInfo;
40        }
41        // Since Expresso 1.2 using Workflow 1.8.04.000
42        $test[] = '1.8.04.000';
43        function workflow_upgrade1_8_04_000()
44        {
45                /* Create index for table egw_wf_workitems  */
46                if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly)
47                {
48                        $GLOBALS['phpgw']->ADOdb->query('CREATE INDEX egw_wf_workitems_wf_instance_id_idx ON egw_wf_workitems(wf_instance_id)');
49                }
50
51                #updating the current version
52                $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.05.000';
53                return $GLOBALS['setup_info']['workflow']['currentver'];
54        }
55
56        $test[] = '1.8.05.000';
57        function workflow_upgrade1_8_05_000()
58        {
59                /* Alter tables of orgchart */
60                if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly)
61                {
62                        $workflowHostInfo = extractDatabaseParameters();
63
64                        /* connect to workflow database */
65                        $workflowDB = $GLOBALS['phpgw']->ADOdb;
66                        if ($workflowDB->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow'))
67                        {
68                                /* add the new columns */
69                                $workflowDB->query('ALTER TABLE public.funcionario ADD COLUMN titulo CHARACTER VARYING(30)');
70                                $workflowDB->query('ALTER TABLE public.organizacao ADD COLUMN sitio CHARACTER VARYING(100)');
71                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN empresa CHARACTER VARYING(100)');
72                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN endereco CHARACTER VARYING(100)');
73                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN complemento CHARACTER VARYING(50)');
74                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN cep CHARACTER VARYING(9)');
75                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN bairro CHARACTER VARYING(30)');
76                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN cidade CHARACTER VARYING(50)');
77                                $workflowDB->query('ALTER TABLE public.localidade ADD COLUMN uf CHARACTER(2)');
78
79                                /* create table telefone */
80                                $workflowDB->query('CREATE TABLE public.telefone (telefone_id serial NOT NULL, descricao character varying(50) NOT NULL, numero character varying(50) NOT NULL, organizacao_id integer NOT NULL)');
81                                $workflowDB->query('ALTER TABLE ONLY public.telefone ADD CONSTRAINT telefone_pkey PRIMARY KEY (telefone_id)');
82                                $workflowDB->query('ALTER TABLE ONLY public.telefone ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)');
83                                $workflowDB->query("GRANT ALL ON TABLE public.telefone TO admin_workflow");
84                                $workflowDB->query("GRANT ALL ON TABLE public.telefone TO postgres");
85                                $workflowDB->query("GRANT SELECT ON TABLE public.telefone TO public");
86                                $workflowDB->query("GRANT ALL ON TABLE public.telefone_telefone_id_seq TO admin_workflow");
87                                $workflowDB->query("GRANT ALL ON TABLE public.telefone_telefone_id_seq TO postgres");
88                                $workflowDB->query("GRANT SELECT ON TABLE public.telefone_telefone_id_seq TO public");
89                        }
90
91                        /* reconnect to the previous database */
92                        $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'].":".$workflowHostInfo['port'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']);
93                }
94                #updating the current version
95                $GLOBALS['setup_info']['workflow']['currentver'] = '1.8.06.000';
96                return $GLOBALS['setup_info']['workflow']['currentver'];
97        }
98
99        $test[] = '1.8.06.000';
100        function workflow_upgrade1_8_06_000()
101        {
102                #updating the current version
103                $GLOBALS['setup_info']['workflow']['currentver'] = '2.0.000';
104                return $GLOBALS['setup_info']['workflow']['currentver'];
105        }
106        $test[] = '2.0.000';
107        function workflow_upgrade2_0_000()
108        {
109                #updating the current version
110                $GLOBALS['setup_info']['workflow']['currentver'] = '2.0.001';
111                return $GLOBALS['setup_info']['workflow']['currentver'];
112        }
113        $test[] = '2.0.001';
114        function workflow_upgrade2_0_001()
115        {
116                #updating the current version
117                $GLOBALS['setup_info']['workflow']['currentver'] = '2.0.002';
118                return $GLOBALS['setup_info']['workflow']['currentver'];
119        }
120        $test[] = '2.0.002';
121        function workflow_upgrade2_0_002()
122        {
123                #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
138                $GLOBALS['setup_info']['workflow']['currentver'] = '2.1.000';
139                return $GLOBALS['setup_info']['workflow']['currentver'];
140        }
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        }       
147?>
Note: See TracBrowser for help on using the repository browser.