+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4 foldmethod=marker:
+// +----------------------------------------------------------------------+
+// | PHP Version 4 |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2003 The PHP Group |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license, |
+// | that is bundled with this package in the file LICENSE, and is |
+// | available at through the world-wide-web at |
+// | http://www.php.net/license/2_02.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +----------------------------------------------------------------------+
+// | Created: jue sep 18 14:29:07 ART 2003
+// | Author: Martin Marrese <mmarre@mecon.gov.ar>
+// +----------------------------------------------------------------------+
+//
+// $Id$
+//
+
+//VERIFICO SI SE TIENE ACCESO A LA PAGINA{{{
+$SAMURAI_PERM->chequear(SAMURAI_DEVELOPER);
+//}}}
+//REQUIRE ONCE {{{
+ require_once 'MECON/HTML/QuickForm.php';
+ require_once 'MECON/HTML/Tabla.php';
+ require_once 'SAMURAI/Sistema.php';
+ require_once 'SAMURAI/Permiso.php';
+// }}}
+//GLOBALES {{{
+$start = <<<EOT
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4 foldmethod=marker:
+// +----------------------------------------------------------------------+
+// | Ministerio De Economia |
+// +----------------------------------------------------------------------+
+// | Archivo generado automaticamente por samurai. |
+// | Definicion de constantes para su uso en los sistemas. |
+// +----------------------------------------------------------------------+
+//
+EOT;
+$start.= '$Id$';
+$end = <<<EOT2
+
+
+?>
+EOT2;
+//}}}
+//CREO LOS OBJETOS NECESARIOS {{{
+ $TABLAFORM = new MECON_HTML_Tabla ('width="500"', 'comun');
+ $FORM = new MECON_HTML_QuickForm ('php_constantes','post','php-constantes');
+ $FORM->renderer->setTable($TABLAFORM);
+ $SISTEMAS = SAMURAI_Sistema::getArraySistemas($DB);
+//}}}
+//AGREGO LOS ELEMENTOS DEL FORM {{{
+ $FORM->addElement ('header', 'cabecera', 'Seleccione el sistema.');
+ $FORM->addElement ('select', 'sistemas', 'Sistemas', $SISTEMAS, array('size' => '1'));
+ $group[] = HTML_QuickForm::createElement('submit', 'aceptar' , 'Seleccionar');
+ $FORM->addGroup($group,'botones', '', ', ');
+//}}}
+//VALIDO EL FORMULARIO {{{
+ if ($FORM->validate()) {
+ $f_sistema =& $FORM->getElement ('sistemas');
+ $tmp = $f_sistema->getSelected();
+ $SISTEMA = new SAMURAI_Sistema ($DB, $tmp[0]);
+
+ $nombre_sistema= strtoupper(strtr($SISTEMA->getNombre().'_PERM', array(
+ '$'=>'_', '@'=>'_' , '!'=>'_' , '#'=>'_', '%'=>'_',
+ '^'=>'_', '&'=>'_' , '*'=>'_' , '-'=>'_', '+'=>'_',
+ '='=>'_', '\\'=>'_', '|'=>'_' , '`'=>'_', '~'=>'_',
+ '/'=>'_', '\"'=>'_', '\''=>'_', '<'=>'_', '>'=>'_',
+ '?'=>'_' , ','=>'_' , 'ç'=>'c', 'Ç'=>'C', ' '=>'_')
+ ));
+
+ $permisos = SAMURAI_Permiso::getArrayPermisos($DB, $SISTEMA->getId());
+
+ //Armo el contenido {{{
+ $contenido = $start;
+ $contenido.= "\n\n/** @file\n * Definicion de Constantes del sistema ".
+ $SISTEMA->getNombre()."\n */";
+
+ $contenido.= "\n\n/**\n * Identificador del Sistema\n */\n";
+ $contenido.= 'define(\''.$nombre_sistema.'\', '.$SISTEMA->getId().');';
+
+ foreach ($permisos as $key => $value) {
+ $contenido.= "\n\n/**\n * Identificacion del permiso ". $value ."\n */\n";
+ $value= strtoupper(strtr($value,
+ array(
+ '$'=>'_', '@'=>'_' , '!'=>'_' , '#'=>'_', '%'=>'_',
+ '^'=>'_', '&'=>'_' , '*'=>'_' , '-'=>'_', '+'=>'_',
+ '='=>'_', '\\'=>'_', '|'=>'_' , '`'=>'_', '~'=>'_',
+ '/'=>'_', '\"'=>'_', '\''=>'_', '<'=>'_', '>'=>'_',
+ '?'=>'_' , ','=>'_' , 'ç'=>'c', 'Ç'=>'C', ' '=>'_')
+ ));
+
+ $contenido.= 'define(\''.$nombre_sistema.'_'.$value.'\', '.$key.');';
+ }
+ $contenido.= $end;
+ //}}}
+
+ //Envio el archivo {{{
+ header('Content-type: application/octet-stream');
+ header("Content-Disposition: attachment; filename=permisos.php");
+ print $contenido;
+ exit;
+ //}}}
+ }
+// }}}
+//DIBUJO LA PAGINA {{{
+ $MARCO->addBody($FORM);
+ $MARCO->setTitle('Definicion de constantes');
+ $MARCO->display();
+// }}}
+//FIN
+?>