/**
  * Callback que se ejecuta antes de los métodos de todos los controladores
  */
 protected final function initialize()
 {
     /**
      * Si el método de entrada es ajax, el tipo de respuesta es sólo la vista
      */
     if (Input::isAjax()) {
         View::template(null);
     }
     /**
      * Verifico que haya iniciado sesión
      */
     if (!MkcAuth::isLogged()) {
         //Verifico que no genere una redirección infinita
         if ($this->controller_name != 'login' && ($this->action_name != 'entrar' && $this->action_name != 'salir')) {
             MkcMessage::warning('No has iniciado sesión o ha caducado.');
             //Verifico que no sea una ventana emergente
             if ($this->module_name == 'reporte') {
                 View::error();
                 //TODO: crear el método error()
             } else {
                 MkcRedirect::toLogin('sistema/login/entrar/');
             }
             return false;
         }
     } else {
         if (MkcAuth::isLogged() && $this->controller_name != 'login') {
             $acl = new MkcAcl();
             //Cargo los permisos y templates
             if (APP_UPDATE && Session::get('perfil_id') != Perfil::SUPER_USUARIO) {
                 //Solo el super usuario puede hacer todo
                 if ($this->module_name != 'dashboard' && $this->controller_name != 'index') {
                     $msj = 'Estamos en labores de actualización y mantenimiento.';
                     $msj .= '<br />';
                     $msj .= 'El servicio se reanudará dentro de ' . APP_UPDATE_TIME;
                     if (Input::isAjax()) {
                         View::update();
                     } else {
                         MkcMessage::info($msj);
                         MkcRedirect::to("dashboard");
                     }
                     return FALSE;
                 }
             }
             if (!$acl->check(Session::get('perfil_id'))) {
                 MkcMessage::error('Tu no posees privilegios para acceder a <b>' . Router::get('route') . '</b>');
                 Input::isAjax() ? View::ajax() : View::select(NULL);
                 return false;
             }
             if (!defined('SKIN')) {
                 define('SKIN', Session::get('tema'));
             }
         }
     }
 }
Example #2
0
/**
 * Calls the static view class in use, passing a uri to identify which part of the
 * view is to be updated (as per the MVC paradigm), the updates as per the interaction
 * with the controller, and the optional message
 *
 * @param string $uri 
 * @param mixed $data 
 * @param string $message 
 * @return void
 * @author Craig Ulliott
 */
function v($uri, $data = NULL, $message = NULL)
{
    // ensure a view class has been included at this point
    if (class_exists('View')) {
        // update the view
        View::update($uri, $data, $message);
    } else {
        throw new exception('A view handler is not avaliable');
    }
}