[surforce-library commit] r42 - trunk/library/Zsurforce/Generic

1 view
Skip to first unread message

codesite...@google.com

unread,
Feb 8, 2009, 10:07:14 PM2/8/09
to surforce...@googlegroups.com
Author: enriqueplace
Date: Sun Feb 8 17:48:25 2009
New Revision: 42

Added:
trunk/library/Zsurforce/Generic/ControllerUsuarios.php
Modified:
trunk/library/Zsurforce/Generic/Controller.php
trunk/library/Zsurforce/Generic/ControllerAdmin.php

Log:
Se crea un nuebo controller solo para los Usuarios del sistema, separando a
los administradores del mismo
- más detalle de debug

Modified: trunk/library/Zsurforce/Generic/Controller.php
==============================================================================
--- trunk/library/Zsurforce/Generic/Controller.php (original)
+++ trunk/library/Zsurforce/Generic/Controller.php Sun Feb 8 17:48:25 2009
@@ -70,10 +70,13 @@

$this->view->user =
Zend_Auth::getInstance()->getIdentity();

+ /*
+ * FIXME: generar un archivo de log, al imprimir esta linea
+ * rompe la session del sistema
+ */
if(isset($this->_debug) && $this->_debug){
- var_dump($this->_request);
- }
-
+ echo "<!--".var_export($this->_request,true)."-->";
+ }

$this->view->controllerName =
$this->_request->getParam('controller');
$this->view->moduleName = $this->_request->getParam('module');

Modified: trunk/library/Zsurforce/Generic/ControllerAdmin.php
==============================================================================
--- trunk/library/Zsurforce/Generic/ControllerAdmin.php (original)
+++ trunk/library/Zsurforce/Generic/ControllerAdmin.php Sun Feb 8 17:48:25
2009
@@ -34,15 +34,22 @@
$layout->menu = Models_Menu::getMenu(
$this->_registry->config->application->id
);
+
$layout->menuItems = Models_Menu::getMenuItemsFromModule(
$this->view->moduleName
);

}catch(Zend_Db_Statement_Exception $e){
+
$this->view->mensajeError =
'Se ha producido un error al intentar recuperar los
datos <br><br>'
.'['.$e->getMessage().']<br><br>'
.' Por favor envíe un email a
sistemas '.$this->_config->general->email ;
+
+ if($this->_debug){
+ $this->view->mensajeError .= $e;
+ }
+
}catch(Zend_Db_Adapter_Exception $e){
$this->view->mensajeError =
'Se ha producido un error al conectar a la base de
datos.'

Added: trunk/library/Zsurforce/Generic/ControllerUsuarios.php
==============================================================================
--- (empty file)
+++ trunk/library/Zsurforce/Generic/ControllerUsuarios.php Sun Feb 8
17:48:25 2009
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Controller Genérico para definir un comportamiento común a
+ * todos los controllers para Administración de una aplicación.
+ *
+ * @category SURFORCE
+ * @package SURFORCE-LIBRARY
+ * @license GPL v2
+ */
+
+require_once '../application/default/models/Menu.php';
+
+abstract class Zsurforce_Generic_ControllerUsuarios extends
Zsurforce_Generic_Controller
+{
+ /**
+ * Verifica siempre que el usuario esté logueado, de lo contrario
+ * interrumpe la ejecución de un controller.
+ *
+ * Todo controller de un admin debería extender de este controller
+ * genérico
+ */
+ final function preDispatch()
+ {
+ $auth = Zend_Auth::getInstance();
+
+ if ($auth->hasIdentity ()) {
+ $this->view->usuarioLogueado = true;
+
+ /* Genera el menú dinámico para el sistema de admin */
+ try{
+
+ $layout = Zend_Layout::getMvcInstance();
+
+ $layout->menu = Models_Menu::getMenu(
+ $this->_registry->config->application->id
+ );
+
+ $layout->menuItems = Models_Menu::getMenuItemsFromModule(
+ $this->view->moduleName
+ );
+
+ }catch(Zend_Db_Statement_Exception $e){
+
+ $this->view->mensajeError =
+ 'Se ha producido un error al intentar recuperar los
datos <br><br>'
+ .'['.$e->getMessage().']<br><br>'
+ .' Por favor envíe un email a
sistemas '.$this->_config->general->email ;
+
+ if($this->_debug){
+ $this->view->mensajeError .= $e;
+ }
+
+ }catch(Zend_Db_Adapter_Exception $e){
+ $this->view->mensajeError =
+ 'Se ha producido un error al conectar a la base de
datos.'
+ .' Por favor reintente en unos minutos';
+ }catch(Exception $e){
+ $this->view->mensajeError =
+ 'Se ha producido un error inesperado.'
+ .' Por favor reintente en unos minutos';
+ }
+
+ }else {
+ $this->_redirect('/usuarios/login/');
+ return;
+ }
+ }
+}
\ No newline at end of file
Reply all
Reply to author
Forward
0 new messages