Example #1
0
 /**
  * Genera Img Captcha
  *
  */
 public function captcha()
 {
     Load::lib('captcha/captcha');
     View::select(NULL, NULL);
     $captcha = new Captcha();
     $captcha->run();
 }
 /**
  * Callback que se ejecuta antes de los métodos de todos los controladores
  */
 protected final function initialize()
 {
     if (APP_UPDATE) {
         DwMessage::info('Estamos en labores de mantenimiento y actualización.');
         View::select(NULL, 'update');
     }
 }
Example #3
0
 protected final function initialize()
 {
     $recurso = '';
     if ($this->module_name == 'admin') {
         View::template('admin');
         if ($this->module_name) {
             $recurso = "{$this->module_name}/{$this->controller_name}/{$this->action_name}/";
         } else {
             $recurso = "{$this->controller_name}/{$this->action_name}/";
         }
         if (Auth::get('rol_id') == 5) {
             Flash::warning("No tienes permiso para acceder.");
             View::select(null, '401');
             return FALSE;
         }
         Load::lib('SdAuth');
         if (!SdAuth::isLogged()) {
             $this->error_msj = SdAuth::getError();
             View::template('login');
             return FALSE;
         }
         $ku_acl = new KuAcl();
         $ku_acl->cargarPermisos(Auth::get('id'));
         if (!$ku_acl->check($recurso, Auth::get('id'))) {
             Flash::warning("No tienes permiso para acceder al siguiente recurso: <b>{$recurso}</b>");
             View::select(null, '401');
             return FALSE;
         }
     }
 }
 /**
  * Hacer el router de la petición y envia los parametros correspondientes
  * a la acción, adema captura formatos de entrada y salida
  */
 protected function initREST()
 {
     /* formato de entrada */
     $this->_fInput = isset($_SERVER["CONTENT_TYPE"]) ? $_SERVER["CONTENT_TYPE"] : '';
     /* busco un posible formato de salida */
     $accept = self::accept();
     $keys = array_keys($this->_outputType);
     foreach ($accept as $key => $a) {
         if (in_array($key, $keys)) {
             $this->_fOutput = $this->_outputType[$key];
             break;
         }
     }
     /* por defecto uso json
      * ¿o debería mandar un 415?
      */
     $this->_fOutput = empty($this->_fOutput) ? 'json' : $this->_fOutput;
     View::select(null, $this->_fOutput);
     /**
      * reescribimos la acción a ejecutar, ahora tendra será el metodo de
      * la peticion: get(:id), getAll , put, post, delete, etc.
      */
     $action = $this->action_name;
     $method = strtolower(Router::get('method'));
     $rewrite = "{$method}_{$action}";
     if ($this->actionExist($rewrite)) {
         $this->action_name = $rewrite;
     } elseif ($action == 'index' && $method != 'post') {
         $this->action_name = 'getAll';
     } else {
         $this->action_name = $method;
         $this->parameters = $action == 'index' ? $this->parameters : array($action) + $this->parameters;
     }
 }
 /**
  * Método para agregar un nuevo usuario
  */
 public function agregar()
 {
     //Titulo de la página
     $this->title = 'Nueva usuario';
     //Ckeck de los radios para habilitar comentarios
     // $this->check_si = (HABILITAR_USUARIO) ? false : true;
     // $this->check_no = (disabled) ? true : false;
     $this->check_si = true;
     $this->check_no = false;
     //Array para determinar la visibilidad de los post
     $this->tipo = array(Grupo::ADMINISTRADOR => 'Administrador', Grupo::AUTOR => 'Autor', Grupo::COLABORADOR => 'Colaborador', Grupo::EDITOR => 'Editor');
     //Verifico si ha enviado los datos a través del formulario
     if (Input::hasPost('usuario')) {
         //Verifico que el formulario coincida con la llave almacenada en sesion
         if (SecurityKey::isValid()) {
             Load::models('usuario');
             $usuario = new Usuario(Input::post('usuario'));
             $resultado = $usuario->registrarUsuario();
             if ($resultado) {
                 View::select('usuario');
             }
             /* else {
                    //Hago persitente los datos
                    $this->categoria = Input::post('categorias');
                    $this->etiquetas = Input::post('etiquetas');
                }
                $this->post = $post;*/
         } else {
             Flash::info('La llave de acceso ha caducado. Por favor intente nuevamente.');
         }
     }
 }
Example #6
0
 /**
  * Hacer el router de la petición y envia los parametros correspondientes
  * a la acción, adema captura formatos de entrada y salida
  */
 protected function initREST()
 {
     /* formato de entrada */
     $this->_fInput = self::getInputFormat();
     $this->_fOutput = self::getOutputFormat($this->_outputType);
     View::select(null, $this->_fOutput);
     $this->rewriteActionName();
 }
 public function index()
 {
     View::select(null, null);
     $fecha2 = new DateTime();
     $fecha1 = new DateTime();
     $fecha2->add(new DateInterval('P30D'));
     print_r($fecha2->format('Y-m-d') . "\n");
     print_r($fecha1->format('Y-m-d') . "\n");
 }
 public function checkdac($id)
 {
     View::select(null);
     $usuario = new Usuario();
     $dac = $usuario->getdac($id);
     if ($dac != false) {
     } else {
     }
 }
 public function get_empresas()
 {
     $tags = Load::model("usuarios")->find("columns: empresa", "group: empresa");
     $array_tags = array();
     foreach ($tags as $key => $value) {
         $array_tags[] = $value->empresa;
     }
     View::select(null, "json");
     $this->data = $array_tags;
 }
 public function obtener_profesor_de_asignatura()
 {
     View::select(null, "json");
     $profesorasignatura = new Profesorasignatura();
     $asignatura_id = Input::get("id");
     $semestre_id = Input::get("semestre_id");
     $seccion_id = Input::get("seccion_id");
     $registros = $profesorasignatura->getProfesorByAsignaturaId($asignatura_id, $semestre_id, $seccion_id);
     $this->data = $registros;
 }
Example #11
0
 /**
  * Constructor
  *
  * @param array $args
  */
 public function __construct($args)
 {
     /*modulo al que pertenece el controlador*/
     $this->module_name = $args['module'];
     $this->controller_name = $args['controller'];
     $this->parameters = $args['parameters'];
     $this->action_name = $args['action'];
     View::select($args['action']);
     View::setPath($args['controller_path']);
 }
Example #12
0
 protected final function initialize()
 {
     Session::delete('myDbName');
     $this->my_auth = new MyAuth();
     if (!$this->my_auth->check()) {
         Flash::warning($this->my_auth->getError());
         Input::delete('password');
         View::select(null, 'login');
     }
 }
 public function logout()
 {
     View::select('null');
     $us = new Usuario();
     if ($us->logout() == true) {
         Flash::valid('Se ha cerrado su sesión.');
     } else {
         Flash::error('No ha podido cerrarse la sesión. Inténtelo de nuevo.');
     }
     Redirect::to('index');
 }
 /**
  * Eliminar un menu
  *
  * @param int $id
  */
 public function borrar($id = null)
 {
     if ($id) {
         if (!Load::model($this->model)->delete($id)) {
             Flash::error('Falló Operación');
         }
     }
     //enrutando al index para listar los articulos
     Router::redirect("{$this->controller_path}");
     View::select(NULL, NULL);
 }
 /**
  * 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 #16
0
 function editar($id)
 {
     $tag = (new Tags())->find_first($id);
     if (Input::hasPost('tag')) {
         if ($tag->update(Input::post('tag'))) {
             Flash::valid('Se ha actualizado el tag de forma exitosa');
         }
     }
     View::select('form');
     $this->tag = $tag;
 }
 public function deshabilitar($id_profesorevaluacion)
 {
     View::select(null, 'json');
     $profesorevaluacion = new Profesorevaluacion();
     $data = $profesorevaluacion->find($id_profesorevaluacion);
     $data->habilitado = 0;
     if ($data->save()) {
         $this->data = true;
     } else {
         $this->data = false;
     }
 }
Example #18
0
 /**
  * Redirecciona la ejecución a otro controlador en un
  * tiempo de ejecución determinado
  *
  * @param string $route ruta a la que será redirigida la petición.
  * @param integer $seconds segundos que se esperarán antes de redirigir
  * @param integer $statusCode código http de la respuesta, por defecto 302
  */
 public static function to($route = '', $seconds = 0, $statusCode = 302)
 {
     $route or $route = Router::get('controller_path') . '/';
     $route = PUBLIC_PATH . ltrim($route, '/');
     if ($seconds) {
         header("Refresh: {$seconds}; url={$route}");
     } else {
         header('Location: ' . $route, TRUE, $statusCode);
         $_SESSION['KUMBIA.CONTENT'] = ob_get_clean();
         View::select(null, null);
     }
 }
 public function nueva()
 {
     View::select(null, "json");
     $nueva = new Especie(Input::post("especie"));
     if ($nueva->save()) {
         $buscar = new Especie();
         $options = $buscar->getInOptionsFormat();
         $this->data = array("valid" => true, "mensaje" => "Especie Agregada con éxito", "html" => $options);
     } else {
         $this->data = array("valid" => false, "mensaje" => strip_tags(str_replace("<br>", "\n", ob_get_contents())));
     }
 }
Example #20
0
 public function changed()
 {
     View::select('index');
     $usuario_id = Session::get('id');
     $this->eventos = Calendario::getCalendario($usuario_id);
     // $this->eventos = Evento::getListadoEventos($usuario_id);
     $this->eventos = json_encode($this->eventos);
     $reporte = new Reporte();
     $this->progress_report = $reporte->getListadoReportePorTipo($usuario_id, 'progress_report');
     $this->demographics_report = $reporte->getListadoReportePorTipo($usuario_id, 'demographics_report');
     $this->beehive_report = $reporte->getListadoReportePorTipo($usuario_id, 'beehive_report');
     $this->read_only = false;
 }
 public function eliminar_archivo()
 {
     View::select(null, "json");
     if (isset($_POST['archivo'])) {
         $archivo = $_POST['archivo'];
         if (file_exists($this->path_archivo . "/{$archivo}")) {
             unlink($this->path_archivo . "/{$archivo}");
             $this->data = 1;
         } else {
             $this->data = 0;
         }
     }
 }
 public function autocomplete()
 {
     View::template(NULL);
     View::select(NULL);
     if (Input::isAjax()) {
         //solo devolvemos los estados si se accede desde ajax
         $busqueda = Input::post('busqueda');
         $profesiones = Load::model('config/profesion')->obtener_profesiones($busqueda);
         die(json_encode($profesiones));
         // solo devolvemos los datos, sin template ni vista
         //json_encode nos devolverá el array en formato json ["aragua","carabobo","..."]
     }
 }
 public function eliminar($id)
 {
     View::select(null);
     $reporte = new Reporte();
     $rep = $reporte->deleteReporte($id);
     if ($rep == false) {
         Flash::error('No ha podido eliminarse el reporte.');
         Redirect::to('');
     } else {
         Flash::success('El reporte se ha eliminado con éxito');
         Redirect::to('');
     }
 }
 /**
  * Realiza el dispatch de una ruta
  *
  * @return Object
  */
 public static function execute($route)
 {
     extract($route, EXTR_OVERWRITE);
     if (!(include_once APP_PATH . "controllers/{$controller_path}" . '_controller.php')) {
         throw new KumbiaException(NULL, 'no_controller');
     }
     //Asigna el controlador activo
     $app_controller = Util::camelcase($controller) . 'Controller';
     $cont = self::$_controller = new $app_controller($module, $controller, $action, $parameters);
     View::select($action);
     View::setPath($controller_path);
     // Se ejecutan los filtros before
     if ($cont->k_callback('initialize') === FALSE) {
         return $cont;
     }
     if ($cont->k_callback('before_filter') === FALSE) {
         return $cont;
     }
     //Se ejecuta el metodo con el nombre de la accion
     //en la clase de acuerdo al convenio
     if (!method_exists($cont, $action)) {
         throw new KumbiaException(NULL, 'no_action');
     }
     //Obteniendo el metodo
     $reflectionMethod = new ReflectionMethod($cont, $action);
     //k_callback y __constructor metodo reservado
     if ($reflectionMethod->name == 'k_callback' || $reflectionMethod->isConstructor()) {
         throw new KumbiaException('Esta intentando ejecutar un método reservado de KumbiaPHP');
     }
     //se verifica que el metodo sea public
     if (!$reflectionMethod->isPublic()) {
         throw new KumbiaException(NULL, 'no_action');
     }
     //se verifica que los parametros que recibe
     //la action sea la cantidad correcta
     $num_params = count($parameters);
     if ($cont->limit_params && ($num_params < $reflectionMethod->getNumberOfRequiredParameters() || $num_params > $reflectionMethod->getNumberOfParameters())) {
         throw new KumbiaException("Número de parámetros erroneo para ejecutar la acción \"{$action}\" en el controlador \"{$controller}\"");
     }
     $reflectionMethod->invokeArgs($cont, $parameters);
     //Corre los filtros after
     $cont->k_callback('after_filter');
     $cont->k_callback('finalize');
     //Si esta routed volver a ejecutar
     if (Router::getRouted()) {
         Router::setRouted(FALSE);
         return Dispatcher::execute(Router::get());
         // Vuelve a ejecutar el dispatcher
     }
     return $cont;
 }
 /**
  * Metodo para cerrar la sesion del usuario actual
  */
 public function salir()
 {
     if (!Auth::is_valid()) {
         Flash::info("Identifícate nuevamente.");
     } else {
         Auth::destroy_identity();
         Session::delete('ip');
         Session::delete("usuario");
         Session::delete('grupo');
         Session::delete('nivel');
         Flash::valid("La sesión se ha cerrado correctamente.");
     }
     //Cambio la vista
     View::setPath('dc-admin/usuario');
     View::select('entrar', 'login');
 }
Example #26
0
 /**
  * Muestra un articulo dado su Slug
  *
  * @param string $slug
  */
 public function ver($slug = NULL)
 {
     if (Input::is('GET') && $slug) {
         $articulo = new Articulo();
         $this->articulo = $articulo->getEntryBySlug($slug);
         $this->pageTitle = $articulo->titulo . ' - simacel.com';
         //Verificando q existan entradas
         if ($this->articulo == NULL) {
             $this->pageTitle = 'Ops! no se Encontraron Noticias - simacel.com';
             View::select('no_entry');
         }
         $this->comentarios = Load::model('comentario')->getCommentByPost($this->articulo->id);
         $this->countComment = count($this->comentarios);
     } else {
         Router::route_to('action: index');
     }
 }
 public function exportar()
 {
     View::select(null, null);
     $desde = Input::get("desde");
     $hasta = Input::get("hasta");
     if (!$desde) {
         $desde = Date("Y-m-d");
     }
     if (!$hasta) {
         $hasta = Date("Y-m-d");
     }
     $escaner = Load::model("escaner");
     $result = $escaner->buscarEntre($desde, $hasta, 1);
     $escaner->download_send_headers("data_export_" . date("Y-m-d") . ".csv");
     echo $escaner->array2csv($result);
     die;
 }
Example #28
0
 /**
  * Edita un Registro
  */
 public function editar($id)
 {
     View::select('crear');
     //se verifica si se ha enviado via POST los datos
     if (Input::hasPost($this->model)) {
         $obj = Load::model($this->model);
         if (!$obj->update(Input::post($this->model))) {
             Flash::error('Falló Operación');
             //se hacen persistente los datos en el formulario
             $this->{$this->model} = Input::post($this->model);
         } else {
             return Redirect::to();
         }
     }
     //Aplicando la autocarga de objeto, para comenzar la edición
     $this->{$this->model} = Load::model($this->model)->find((int) $id);
 }
 public function crear_carpeta()
 {
     View::select(null, "json");
     $nueva_carpeta = new Carpeta();
     $carpeta_data = new CarpetaData();
     $carpeta = json_decode(Input::post("carpeta"));
     /*aqui crea la carpeta*/
     if ($nueva_carpeta->nueva_carpeta($carpeta[0]->nombre_carpeta)) {
         $id = $nueva_carpeta->ultimo_id();
         $result = $carpeta_data->ingresar_a_carpeta($id, $carpeta);
         if (is_array($result)) {
             $this->data = array("error" => $result);
         } else {
             $this->data = array("correcto" => $nueva_carpeta->get_carpetas_by_user_id(Auth::get("id")));
         }
     } else {
         $this->data = false;
     }
 }
 /**
  * Muestra un articulo dado su Slug
  *
  * @param string $slug
  */
 public function ver($slug = NULL)
 {
     if ($slug) {
         $articulo = new Articulo();
         $recaptcha = new Recaptcha();
         $this->articulo = $articulo->getEntryBySlug($slug);
         $this->pageTitle = $articulo->titulo . ' - ' . $this->pageTitle;
         //Verificando que existan entradas
         if ($this->articulo == NULL) {
             $this->pageTitle = 'Ops! no se Encontraron Noticias - ' . $this->pageTitle;
             View::select('no_entry');
         }
         $this->comentarios = Load::model('comentario')->getCommentByPost($this->articulo->id);
         $this->countComment = count($this->comentarios);
         $this->captcha = $recaptcha->generar();
     } else {
         Router::route_to('action: index');
     }
 }