public function approve_online_enrollments()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_aprobar_matriculas_online', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('enrollments/academic_year_error', $data);
             }
             $data["search"] = null;
             $data["state"] = 'P';
             $data["level"] = '0';
             $data["enrollments_data"] = Enrollment::where('academic_year_id', '=', $current_ay->id)->where('state', '=', 'P')->orderBy('date')->paginate(20);
             $data["states"] = ['P' => 'Pendientes de aprobación', 'A' => 'Aprobadas', 'D' => 'Desaprobadas'];
             $data["levels"] = Level::lists('name', 'id');
             $data["levels"]["0"] = "Todos los niveles";
             return View::make('enrollments/approve_online_enrollments', $data);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
예제 #2
0
 /**
  * unsave from my course list
  *
  * @param  string  $email
  * @return Response
  */
 public static function removeFromMyCourses($idCourse, $idUser)
 {
     $app = \Slim\Slim::getInstance();
     if (!User::find($idUser)) {
         $app->response->setStatus(400);
         return "User does not exist";
     }
     if (!Course::find($idCourse)) {
         $app->response->setStatus(400);
         return "Course does not exist";
     }
     if (Enrollment::where('user_id', $idUser)->where('course_id', $idCourse)->count()) {
         $app->response->setStatus(400);
         return "You already enrolled this course";
     }
     MyCourses::where('user_id', $idUser)->where('course_id', $idCourse)->delete();
     return "success";
 }
예제 #3
0
 public static function launchCourse($idCourse, $token, $page)
 {
     $app = \Slim\Slim::getInstance();
     if (!Course::find($idCourse)) {
         $app->halt("404");
     }
     $auth = Auth_Token::where('token', '=', $token)->first();
     if (!$auth || Enrollment::where('user_id', '=', $auth->user_id)->where('course_id', '=', $idCourse)->count() == 0) {
         $app->response->headers->set('Content-Type', 'text/html');
         $app->render('course_launch_401.php');
         $app->stop();
     }
     FileController::readCourse($idCourse, $page);
 }
 public static function download($idUser, $idCourse)
 {
     $app = \Slim\Slim::getInstance();
     if (!Course::find($idCourse)) {
         $app->response->setStatus(404);
         return json_encode("Course not found");
     }
     if (!Enrollment::where('user_id', '=', $idUser)->where('course_id', '=', $idCourse)->count()) {
         $app->response->setStatus(401);
         return json_encode("You have to enroll this course first.");
     }
     FileController::downloadCourse($idCourse);
 }