source: companies/serpro/expressoMail1_2/setup/tables_update.inc.php @ 903

Revision 903, 7.4 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1<?php
2        /**************************************************************************\
3        * phpGroupWare - Setup                                                     *
4        * http://www.phpgroupware.org                                              *
5        * --------------------------------------------                             *
6        * This program is free software; you can redistribute it and/or modify it  *
7        * under the terms of the GNU General Public License as published by the    *
8        * Free Software Foundation; either version 2 of the License, or (at your   *
9        * option) any later version.                                               *
10        \**************************************************************************/
11        if ($GLOBALS['setup_info']['expressoMail1_2']['currentver'] == '1.333'){
12                $test[] = '1.333';
13                function expressoMail1_2_upgrade1_333() {
14                        global $phpgw_setup, $setup_info;
15                        $db2 = $GLOBALS['phpgw_setup']->db;
16
17                        $phpgw_setup->oProc->RenameTable('phpgw_certificados','phpgw_certificados_old');
18                        $phpgw_setup->oProc->CreateTable('phpgw_certificados',array(
19                                'fd' => array(
20                                        'email' => array( 'type' => 'varchar', 'precision' => 60, 'nullable' => false),
21                                        'chave_publica' => array( 'type' => 'text'),
22                                        'expirado' => array('type' => 'bool', 'default' => 'false'),
23                                        'revogado' => array('type' => 'bool', 'default' => 'false'),
24                                        'serialnumber' => array('type' => 'int', 'precision' => 8, 'nullable' => false),
25                                        'authoritykeyidentifier' => array( 'type' => 'text', 'nullable' => false),
26                                ),
27                                'pk' => array('email','serialnumber','authoritykeyidentifier'),
28                                'fk' => array(),
29                                'ix' => array(),
30                                'uc' => array()
31                                )
32                        );
33
34                        $sql = "SELECT * FROM phpgw_certificados_old";
35                        $phpgw_setup->oProc->query($sql,__LINE__,__FILE__);
36                        if($phpgw_setup->oProc->num_rows())
37                        {
38                                echo    "<br /> Verificando certificados para inserir na nova tabela... <br />";
39                                include_once(PHPGW_INCLUDE_ROOT."/seguranca/classes/CertificadoB.php");
40                                while($phpgw_setup->oProc->next_record())
41                                {
42                                        $email = $phpgw_setup->oProc->f('email');
43                                        $chave_publica = $phpgw_setup->oProc->f('chave_publica');
44
45                                        $c1 = new certificadoB();
46                                        $c1->certificado($chave_publica);
47
48                                        if ($c1->apresentado)
49                                        {
50                                                $c2 = new Verifica_Certificado($c1->dados,$chave_publica);
51                                                if (!$c1->dados['EXPIRADO'] && !$c2->revogado && $c2->status)
52                                                {
53                                                        $insert[] = array(
54                                                                                'sql' => 'INSERT INTO phpgw_certificados(email,chave_publica,expirado,revogado,serialnumber,authoritykeyidentifier)'.
55                                                                                'VALUES (\''.$email.'\',\''.$chave_publica.'\',\'0\',\'0\',\''.$c1->dados['SERIALNUMBER'].'\',\''.$c1->dados['AUTHORITYKEYIDENTIFIER'].'\')',
56
57                                                                                'email' => $email);
58                                                        // o codigo abaixo nao funciona, por isso teve q ser feito fora do if...while...
59                                                        //$db2->query($insert,__LINE__,__FILE__);
60                                                        //echo "<br />email: " . $email . " -> ok <br />";
61
62                                                }
63                                                else
64                                                {
65                                                        echo    "<br /> erro no email: " . $email .
66                                                                        "<br /> <pre>" . print_r($c1->dados) . "</pre> <br />";
67                                                }
68                                        }
69                                }
70                        }
71
72                        foreach($insert as $item)
73                        {
74                                $db2->query($item['sql'],__LINE__,__FILE__);
75                                echo "<br />email: " . $item['email'] . " -> ok <br />";
76                        }
77
78                        $GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_certificados_old');
79
80                        $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.334';
81                        return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];
82                }
83        }
84
85        if ($GLOBALS['setup_info']['expressoMail1_2']['currentver'] == '1.223'){
86                $test[] = '1.223';
87                function expressoMail1_2_upgrade1_223() {
88                        $oProc = $GLOBALS['phpgw_setup']->oProc;
89                        $oProc->CreateTable('phpgw_expressomail_contacts',array(
90                                'fd' => array(
91                                        'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
92                                        'data' => array( 'type' => 'text')
93                                ),
94                                'pk' => array('id_owner'),
95                                'fk' => array(),
96                                'ix' => array(),
97                                'uc' => array()
98                                )
99                        );
100                        $oProc->CreateTable('phpgw_certificados',array(
101                                'fd' => array(
102                                        'email' => array( 'type' => 'varchar', 'precision' => 60, 'nullable' => false),
103                                        'chave_publica' => array( 'type' => 'text'),
104                                        'expirado' => array('type' => 'bool', 'default' => 'false')
105                                ),
106                                'pk' => array('email'),
107                                'fk' => array(),
108                                'ix' => array(),
109                                'uc' => array()
110                                )
111                        );
112                        $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.333';
113                        return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];
114                }
115        }       
116       
117        if ($GLOBALS['setup_info']['expressoMail1_2']['currentver'] == '1.2031'){
118                $test[] = '1.2031';
119                function expressoMail1_2_upgrade1_2031() {
120                        $oProc = $GLOBALS['phpgw_setup']->oProc;
121                        $oProc->CreateTable('phpgw_expressomail_contacts',array(
122                                'fd' => array(
123                                        'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
124                                        'data' => array( 'type' => 'text')
125                                ),
126                                'pk' => array('id_owner'),
127                                'fk' => array(),
128                                'ix' => array(),
129                                'uc' => array()
130                                )
131                        );
132                        $oProc->CreateTable('phpgw_certificados',array(
133                                'fd' => array(
134                                        'email' => array( 'type' => 'varchar', 'precision' => 60, 'nullable' => false),
135                                        'chave_publica' => array( 'type' => 'text'),
136                                        'expirado' => array('type' => 'bool', 'default' => 'false')
137                                ),
138                                'pk' => array('email'),
139                                'fk' => array(),
140                                'ix' => array(),
141                                'uc' => array()
142                                )
143                        );
144                        $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.223';
145                        return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];
146                }
147        }
148
149        if ($GLOBALS['setup_info']['expressoMail1_2']['currentver'] == '1.2211'){
150                $test[] = '1.2211';
151                function expressoMail1_2_upgrade1_2211() {
152                        $oProc = $GLOBALS['phpgw_setup']->oProc;
153                        $oProc->CreateTable('phpgw_expressomail_contacts',array(
154                                'fd' => array(
155                                        'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
156                                        'data' => array( 'type' => 'text')
157                                ),
158                                'pk' => array('id_owner'),
159                                'fk' => array(),
160                                'ix' => array(),
161                                'uc' => array()
162                                )
163                        );
164                        $oProc->CreateTable('phpgw_certificados',array(
165                                'fd' => array(
166                                        'email' => array( 'type' => 'varchar', 'precision' => 60, 'nullable' => false),
167                                        'chave_publica' => array( 'type' => 'text'),
168                                        'expirado' => array('type' => 'bool', 'default' => 'false')
169                                ),
170                                'pk' => array('email'),
171                                'fk' => array(),
172                                'ix' => array(),
173                                'uc' => array()
174                                )
175                        );
176                        $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.223';
177                        return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];
178                }
179        }
180
181        if ($GLOBALS['setup_info']['expressoMail1_2']['currentver'] == '1.222'){
182                $test[] = '1.222';
183                function expressoMail1_2_upgrade1_222() {
184                        $oProc = $GLOBALS['phpgw_setup']->oProc;
185                        $oProc->CreateTable('phpgw_expressomail_contacts',array(
186                                'fd' => array(
187                                        'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
188                                        'data' => array( 'type' => 'text')
189                                ),
190                                'pk' => array('id_owner'),
191                                'fk' => array(),
192                                'ix' => array(),
193                                'uc' => array()
194                                )
195                        );
196                        $oProc->CreateTable('phpgw_certificados',array(
197                                'fd' => array(
198                                        'email' => array( 'type' => 'varchar', 'precision' => 60, 'nullable' => false),
199                                        'chave_publica' => array( 'type' => 'text'),
200                                        'expirado' => array('type' => 'bool', 'default' => 'false')
201                                ),
202                                'pk' => array('email'),
203                                'fk' => array(),
204                                'ix' => array(),
205                                'uc' => array()
206                                )
207                        );
208                        $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '1.223';
209                        return $GLOBALS['setup_info']['expressoMail1_2']['currentver'];
210                }
211        }
212?>
Note: See TracBrowser for help on using the repository browser.