function processPetition()
 {
     //Se controla que el usuario no tenga acceso.
     $bol_hasaccess = false;
     //Primero comprueba si estamos identificados y si no es asi entonces vamos a ver si es una peticion de autenticacion
     $user_id = $this->getSessionElement('userinfo', 'user_id');
     if (isset($user_id) && $user_id != '') {
         $bol_hasaccess = true;
         $user = $this->getSessionElement('userinfo', 'user_alias');
     } else {
     }
     if ($bol_hasaccess) {
         if ($user == 'guest') {
             //Error, el usuario no puede ser el invitado
         } else {
             //Miramos si se puede hacer la inscripción directa
             $course_id = $this->getViewVariable('course_id');
             $courseAccess = miguel_CourseInfo::getAccess($this->obj_data, $course_id);
             if (!$courseAccess) {
                 //Realiza la inscripciÛn directa en el curso
                 $this->_subscribeCourse($user_id, $course_id);
                 $this->addNavElement(Util::format_URLPath('main/index.php'), agt('miguel_Courses'));
                 $course_name = $this->obj_data->getCourseName($course_id);
                 $this->setViewVariable('course_name', $course_name);
                 $subject = agt('miguel_newCourseSubscriptionSubject') . ' ' . $course_name;
                 $body = $course_name . ',\\n ' . agt('miguel_newCourseSubscriptionBody') . '\\n' . agt('miguel_disclaimer');
             } else {
                 //La inscripción ha de ser validada por el responsable
                 $subject = agt('miguel_newCourseSubscriptionPending') . ' ' . $course_name;
                 $body = $course_name . ',\\n ' . agt('miguel_newCourseSubscriptionBody') . '\\n' . agt('miguel_disclaimer');
             }
             //Realiza la notificacion si esta permitido
             if ($this->getSessionElement('userinfo', 'notify_email')) {
                 include_once Util::base_Path("include/classes/mailer.class.php");
                 $mail = new miguel_mailer();
                 $mail->From = $this->getSessionElement('userinfo', 'email');
                 $mail->FromName = $this->getSessionElement('userinfo', 'name') . ' ' . $this->getSessionElement('userinfo', 'surname');
                 $mail->AddAddress($this->getSessionElement('userinfo', 'email'), $this->getSessionElement('userinfo', 'name'));
                 $mail->AddReplyTo($this->getSessionElement('userinfo', 'email'), $this->getSessionElement('userinfo', 'name'));
                 $mail->Subject = $subject;
                 $mail->Body = $body;
                 if (!$mail->Send()) {
                     echo "Message could not be sent. <p>";
                     echo "Mailer Error: " . $mail->ErrorInfo;
                     //exit;
                 }
             }
             $this->setCacheFile("miguel_VSubscribe_" . $this->getSessionElement("userinfo", "user_id"));
             $this->setMessage(agt("miguel_userSubscribe"));
             $this->setPageTitle("miguel_userSubscribe");
         }
     } else {
         //Bienvenida
     }
     $this->setCacheFlag(true);
     $this->setHelp("EducContent");
 }
 function processPetition()
 {
     /* Falta la comprobación del acceso */
     $user_id = $this->getSessionElement('userinfo', 'user_id');
     $course_id = 0;
     if ($this->issetViewVariable('course')) {
         $course_id = $this->getViewVariable('course');
         if ($this->issetViewVariable('item') && $this->issetViewVariable('act')) {
             $item_id = $this->getViewVariable('item');
             if ($this->getViewVariable('act') == 'on') {
                 $this->obj_data->setBottonVisibility($course_id, $item_id, '1');
             } else {
                 $this->obj_data->setBottonVisibility($course_id, $item_id, '0');
             }
         }
     }
     if (miguel_CourseInfo::isCourseAdmin($this->obj_data, $course_id, $user_id)) {
         $this->setViewVariable('isCourseAdmin', true);
         Session::setValue('isCourseAdmin', true);
         $courseAccess = true;
     } else {
         $this->setViewVariable('isCourseAdmin', false);
         $courseAccess = miguel_CourseInfo::hasAccess($this->obj_data, $course_id, $user_id);
     }
     if ($courseAccess) {
         $infoCourse = miguel_CourseInfo::getInfo($this->obj_data, $course_id);
         //Debug::oneVar($infoCourse, __FILE__,__LINE__);
         $this->setViewVariable('infoCourse', $infoCourse);
         $this->setViewVariable('courseId', $course_id);
         $this->setViewVariable('visual_array', $this->obj_data->getCourseItems($course_id));
         //Debug::oneVar($this->getViewVariable('visual_array'),__FILE__, __LINE__);
         $this->addNavElement(Util::format_URLPath("course/index.php", "course=" . $course_id), $infoCourse['name']);
         $this->setCacheFile('miguel_VCourse_' . $course_id . '_' . $this->getSessionElement("userinfo", "user_id"));
         $this->setPageTitle("miguelOO Curso: " . $infoCourse['name']);
         $this->setMessage('Bienvenido al curso "' . $infoCourse['name'] . '"');
         $this->setHelp("EducContent");
     } else {
         $this->setPageTitle("miguelOO Curso: " . agt('miguel_courseNoAccess'));
         $this->setMessage(agt('miguel_courseNoAccess'));
         $this->setHelp("EducContent");
         $this->setError('miguel_VNoAccess');
     }
 }
 function processPetition()
 {
     $arr_cvw = $this->getSessionData();
     //Debug::oneVar($arr_cvw, __FILE__,__LINE__);
     //Obtención del id de curso
     //Parametro temporal para demo
     $course_id = $this->getViewVariable('id');
     if (!isset($course_id)) {
         if (!isset($arr_cvw['course_id'])) {
             $course_id = 8;
         } else {
             $course_id = $arr_cvw['course_id'];
         }
     } else {
         $arr_cvw = array();
     }
     //En un futuro deberia ser lo siguiente
     //$course_id = Session::getValue('course_id');
     if ($course_id != $arr_cvw['course_id']) {
         unset($arr_cvw);
         $arr_cvw['course_id'] = $course_id;
     }
     //Si el curso se inicializa correctamente...
     if (isset($course_id) && $course_id != '') {
         include_once Util::app_Path('common/control/classes/miguel_courseinfo.class.php');
         $infoCourse = miguel_CourseInfo::getInfo($this->obj_data, $course_id);
         //Debug::oneVar($infoCourse, __FILE__,__LINE__);
         //$this->setViewVariable('infoCourse', $infoCourse);
         //$arr_cvw['module_path'] = $this->obj_data->CourseModules($course_id);
         //Se obtiene el orden de documentos
         $arr_cvw['sec_docs'] = $this->obj_data->CourseModulesOrder($course_id);
         //Hay que ver si se nos redirecciona desde el exterior
         //Si existe la variable mid (id de módulo) reorientamos el índice
         $module_id = $this->getViewVariable('mid');
         if (isset($module_id) && $module_id != '') {
             $this->moveIndex($module_id, $arr_cvw);
         } else {
             //Hay que navegar
             $option = $this->getViewVariable('opt');
             //$this->processNavigation($option, $arr_cvw);
             $index = $arr_cvw['index'];
             $document_id = $arr_cvw['sec_docs'][$index]['document'];
             //Procesar datos de formulario
             if ($arr_cvw['accion']) {
                 //Procesamos el formulario, si existe
                 $this->processForm($document_id, $arr_cvw);
                 //Sólo si no hay que mostrar un resultado se sigue
                 if (!isset($arr_cvw['result'])) {
                     //Procesamos la navegacion
                     $this->processNavigation($option, $arr_cvw);
                 }
             } else {
                 $this->processNavigation($option, $arr_cvw);
             }
         }
         $index = $arr_cvw['index'];
         $document_id = $arr_cvw['sec_docs'][$index]['document'];
         $module_id = $arr_cvw['sec_docs'][$index]['module'];
         $arr_path = $this->getFolderNavInfo($document_id);
         //Debug::oneVar($arrPath, __FILE__,__LINE__);
         if ($arr_path['fl_type']) {
             $this->setViewVariable('view_elem', $this->processNextForm($arr_cvw));
             $this->setViewClass('miguel_VCourseActioner');
             $arr_cvw['accion'] = true;
         } else {
             $this->setViewClass('miguel_VCourseViewer');
             $arr_cvw['accion'] = false;
         }
         $this->setViewVariable('ban_mid', $this->obj_data->getCourseModulesPosition($arr_cvw['course_id'], $module_id));
         $this->setViewVariable('esInicio', $index == 0);
         $this->setViewVariable('hayPrevio', $index != 0);
         $this->setViewVariable('haySiguiente', $index < count($arr_cvw['sec_docs']) - 1);
         $this->setViewVariable('actual', Util::formatPath(MIGUEL_APPDIR . 'var/courses/course_' . $course_id . '/pages/' . $arr_path['fl_actual']));
         //Util::formatPath(MIGUEL_APPDIR.'var/courses/'.$file);
         $this->setViewVariable('path', 'var/courses/course_' . $course_id . '/pages/');
         //Guardamos variables de navegacion
         $this->setSessionElement('cvw', $arr_cvw);
         $this->addNavElement(Util::format_URLPath("courseViewer/index.php", 'url=' . $this->getViewVariable('url') . '&name=' . $this->getViewVariable('name')), $infoCourse['description']);
         $this->setPageTitle("miguel Course Viewer Page ");
         $this->setMessage('');
         //$this->setCacheFile("miguel_vParser");
         $this->setCacheFlag(true);
         $this->setHelp("");
     }
 }
 /**
  * Obtiene toda la informaciÛn de un curso
  * @param base_model $obj_model Instancia de un modelo
  * @param string $course_id Identificador de curso.
  * @return array Toda la informaciÛn: nombre, email, idioma,...
  */
 function getInfo(&$obj_model, $course_id)
 {
     //Obtiene información del curso
     $ret_sql = $obj_model->SelectMultiTable('course, user, person', 'course.course_name, course.course_description, course.course_language, person.person_name, person.person_surname, user.email', 'course_id = ' . $course_id . ' AND course.user_id = user.user_id AND user.person_id = person.person_id');
     if ($obj_model->hasError()) {
         $ret_val = null;
     } else {
         $arr_path = miguel_CourseInfo::_getPath($obj_model, $course_id);
         $ret_val = array('course_id' => $course_id, 'name' => $ret_sql[0]['course.course_name'], 'description' => $ret_sql[0]['course.course_description'], 'user_responsable' => $ret_sql[0]['person.person_name'] . ' ' . $ret_sql[0]['person.person_surname'], 'email' => $ret_sql[0]['user.email'], 'language' => $ret_sql[0]['course.course_language'], 'path' => $arr_path);
     }
     return $ret_val;
 }