示例#1
0
//inicio instancias render y creacion de comboboxes
$usuario = new Usuario($db);
$usuario = $usuario->findBy('user_name', $_SESSION['name']);
$usuario = $usuario[0];
$materias = new Materia($db);
$titulaciones = new Titulacion($db);
$materias = $materias->all();
$titulaciones = $titulaciones->all();
//Instancias TemplateEngine, renderizan elementos
$renderMain = new TemplateEngine();
$renderPlantilla = new TemplateEngine();
$apuntes = $usuario->apuntes();
$tieneapuntes = $usuario->tieneApuntes();
$renderPlantilla->titulos = null;
$renderPlantilla->materias = $materias;
$renderPlantilla->anho = anhoRenderComboBox();
//fin Instancias
//FUNCIONES DEL CONTROLADOR
if (isset($_POST['materia']) || isset($_POST['anho'])) {
    if ($_POST['materia'] != "nil") {
        $materiafiltro = new Materia($db);
        $materiafiltro = $materiafiltro->findBy('mat_name', $_POST['materia']);
        if ($materiafiltro) {
            $materiafiltro = $materiafiltro[0];
            foreach ($apuntes as $key => $apunte) {
                if ($apunte->getMat_id() != $materiafiltro->getMat_id()) {
                    unset($apuntes[$key]);
                }
            }
            foreach ($tieneapuntes as $key => $apunte) {
                if ($apunte->getMat_id() != $materiafiltro->getMat_id()) {
示例#2
0
                $array = $matuser->findBy('mat_id', $apunte->getMat_id());
                foreach ($array as $arrays) {
                    $notificacion->setFecha($buffer);
                    $notificacion->setContenido("Nuevos apuntes en " . $mat);
                    $notificacion->setUser_id($arrays->getUser_id());
                    $notificacion->create();
                }
            } else {
                $titulo = "Error subiendo el apunte.";
                $contenido = "Ha ocurrido un error inesperado. Compruebe los datos de entrada, pruebe otra vez y si el error sigue ocurriendo contacte con un administrador";
            }
        }
    } else {
        $titulo = "fichero invalido";
        $contenido = "compruebe que su fichero es .pdf";
    }
    //fin operacion subir archivo
    $apunte->setRuta($hashedName);
    $apunte->create();
    //se crea en la BD el nuevo apunte
    $renderSubirApunte->modal = renderModal($titulo, $contenido);
}
//RENDERIZADO FINAL
$renderSubirApunte->comboboxAnho = anhoRenderComboBox();
// se renderiza el combobox de año
$renderMain->navbar = renderNavBar();
//Inserción de navBar en la pagina. Omitible si no la necesita
$renderMain->content = $renderSubirApunte->render('subirApunte_v.php');
//Inserción del contenido de la página
echo $renderMain->renderMain();
// Dibujado de la página al completo