public function index($username) { $username = strip_tags(htmlspecialchars($username)); $perfil = Perfil::where('username', '=', $username)->get(); $session = Utilities::getSession(); $links = Utilities::getMenu($session); $logged = false; $maestro = null; if (count($perfil) > 0) { $maestro = Maestro::with('cursos', 'perfil')->where('maestro_id', '=', $perfil[0]->perfil_id)->get(); if (count($maestro) > 0) { $maestro = $maestro[0]; foreach ($maestro->cursos as $key => $value) { $action = '/curso/' . $value->nombre; $value->action = $action; } } else { $maestro = null; } } if (strcmp($username, $session['username'])) { $logged = true; } $this->view = new MaestroView($maestro, $links, $logged); $this->view->display(); //Utilities::printData( $maestro ); }
public function usersList($username) { $session = Utilities::getSession(); $username = strip_tags(htmlspecialchars($username)); $username = filter_var($username, FILTER_SANITIZE_STRING); if ($session['username'] == $username) { $users = User::with('perfil', 'level')->where('level_id', '=', 4)->get(); $links = Utilities::getMenu($session); foreach ($users as $key => $value) { $action = '/' . $value->perfil->username; $value->perfil->action = $action; } $this->view = new UsersListView($users, $links); $this->view->display(); } else { $this->app->redirect($app->urlFor('admin-login')); } }
public function index() { date_default_timezone_set('America/Mexico_City'); $total_alumnos = 12; $fecha_actual = date('Y-m-d'); $fecha_actual = date_create($fecha_actual); $cursos = Curso::where('status', '=', 1)->where('total_alumnos', '<', $total_alumnos)->get(); $lista_cursos = array(); $session = Utilities::getSession(); $links = Utilities::getMenu($session); foreach ($cursos as $key => $value) { $fechaInicio = date_create($value->fechaInicio); $interval = date_diff($fecha_actual, $fechaInicio); if ($interval->invert == 0 && $interval->d >= 0) { $value->action = '/suscribirme/' . $value->curso_id; $lista_cursos[] = $value; } } //Utilities::printData( $lista_cursos ); $this->view = new Index($this->app->urlFor('join'), $lista_cursos, $links); $this->view->display(); }
public function cambiarFotoView($params) { $usuario_id = strip_tags(htmlspecialchars($params['usuario'])); $usuario_id = intval($usuario_id); $usuario_id = filter_var($usuario_id, FILTER_VALIDATE_INT); $error = 0; if (!$usuario_id || $usuario_id == 0) { $error = 1; } $usuario = Perfil::find($usuario_id); if (count($usuario) == 0) { $error = 2; } $action = '/usuario/' . $usuario_id . '/foto/'; $session = Utilities::getSession(); $links = Utilities::getMenu($session); $this->view = new FotoView($action, Utilities::createToken(), $usuario, $links, $error); $this->view->display(); }
public function editView($params) { $curso_id = strip_tags(htmlspecialchars($params['curso'])); $curso_id = intval($curso_id); $curso_id = filter_var($curso_id, FILTER_VALIDATE_INT); $attempt = 0; $session = Utilities::getSession(); $links = Utilities::getMenu($session); if (isset($params['attempt']) && is_int($params['attempt'])) { $attempt = strip_tags(htmlspecialchars($params['attempt'])); $attempt = intval($attempt); $attempt = filter_var($attempt, FILTER_VALIDATE_INT); } if (!$curso_id) { $this->app->redirect($this->app->urlFor('Index')); } $curso = Curso::find($curso_id); if (count($curso) == 0) { $this->app->redirect($this->app->urlFor('Index')); } $action = '/curso/' . $curso->curso_id . '/edit'; $tipo_curso = TipoCurso::all(); $maestros = Maestro::with('perfil')->get(); $this->view = new CursoEditView($links, $curso, $tipo_curso, $maestros, $action, $attempt); $this->view->display(); //Utilities::printData($maestros); }