2 // vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4 foldmethod=marker:
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Created: mar mar 9 17:40:23 ART 2004
17 // | Author: Martin Marrese <mmarre@mecon.gov.ar>
18 // +----------------------------------------------------------------------+
23 //Verifico si se tiene acceso a la pagina{{{
24 $SAMURAI_PERM->setSistema(SAMURAI_PERM);
25 if (!$SAMURAI_PERM->tiene(SAMURAI_PERM_DEVELOPER)) {
26 $SAMURAI_PERM->chequear(SAMURAI_PERM_DEVELOPER);
28 $MARCO =& new MECON_Marco ('/var/www/sistemas/samurai/sistema/conf/confSecciones.php', $SAMURAI_PERM);
32 require_once 'MECON/HTML/Error.php';
33 require_once 'MECON/HTML/QuickForm.php';
34 require_once 'SAMURAI/Sistema.php';
35 require_once 'SAMURAI/Migrar.php';
38 //Obtengo la info de los sistemas de la base {{{
39 $SISTEMAS = SAMURAI_Sistema::getArraySistemas($DB);
42 //Agrego los elementos del form {{{
43 $TABLA =& new MECON_HTML_Tabla ('width="400"', 'comun');
44 $TABLA->addLink('volver', 'consultas');
45 $FORM =& new MECON_HTML_QuickForm ('migrar','post','migrar');
46 $FORM->renderer->setTable($TABLA);
47 $FORM->addElement ('header', 'cabecera', 'Datos de la migración.');
48 $sistema =& $FORM->addElement ('select', 'sistema', 'Sistema', $SISTEMAS, array('size' => '1'));
49 $db_host =& $FORM->addElement ('text', 'db_host', 'DB Host Dest.', '', array ('size'=>50));
50 $db_user =& $FORM->addElement ('text', 'db_user', 'DB User Dest.', '', array ('size'=>50));
51 $db_pass =& $FORM->addElement ('password', 'db_pass', 'DB Pass Dest.', '', array ('size'=>50));
52 $group[] = HTML_QuickForm::createElement('submit', 'aceptar' , 'Migrar');
53 $FORM->addGroup($group,'botones', '', ', ');
55 //Agrego las reglas de validación
56 $FORM->addRule('sistema', 'Debe seleccionar un sistema.', 'required', '', 'client');
57 $FORM->addRule('db_host', 'Debe indicar el MYSQL Server destino.', 'required', '', 'client');
58 $FORM->addRule('db_user', 'Debe ingresar el usuario MySQL destino.', 'required', '', 'client');
59 $FORM->addRule('db_pass', 'Debe ingresar el password MySQL destino.', 'required', '', 'client');
62 //Valido el formulario {{{
63 if ($FORM->validate()) {
64 //Migro el sistema {{{
65 $migrar =& new SAMURAI_Migrar (
72 $res = $migrar->migrarSistema(array_shift($sistema->getSelected()));
73 if (PEAR::isError($res)) {
74 switch ($res->getUserInfo()) {
76 $ERROR =& new MECON_HTML_Error ('Error: '. $res->getMessage());
79 trigger_error('Error: ' . $res->getMessage() . "\n", E_USER_ERROR);
84 // $header ('Location: consultas');
90 //Dibujo la pagina {{{
91 $MARCO->addBody($FORM);
92 @$MARCO->addBody($ERROR);
93 $MARCO->setTitle('Migrar Sistema');