diff --git a/main/admin/course_request_rejected.php b/main/admin/course_request_rejected.php index 91ad1dc591..15849647ee 100644 --- a/main/admin/course_request_rejected.php +++ b/main/admin/course_request_rejected.php @@ -38,50 +38,36 @@ require api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; // Including additional libraries. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; +// Filltering passed to this page parameters. +$accept_course_request = intval($_GET['accept_course_request']); +$request_info = intval($_GET['request_info']); + /** * Acceptance and creation of the requested course. */ -if (isset($_GET['accept_course']) && $_GET['accept_course'] != '') { // TODO: Secure $_GET['accept_course']. - //Constulta de los datos del curso - $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id LIKE '".$_GET['accept_course']."'"; // TODO: Why "SELECT ... id LIKE x"? Why not "SELECT ... id = x"? - $result = Database :: query($sql); - $curso_alta = Database :: fetch_array($result); - - //Creación del curso - - $wanted_code = $curso_alta['code']; - $tutor_name = $curso_alta['tutor_name']; - $category_code = $curso_alta['category_code']; - $title = $curso_alta['title']; - $course_language = $curso_alta['course_language']; - $keys = define_course_keys($wanted_code, '', $_configuration['db_prefix']); - - if (sizeof($keys)) { - $visual_code = $keys['currentCourseCode']; - $code = $keys['currentCourseId']; - $db_name = $keys['currentCourseDbName']; - $directory = $keys['currentCourseRepository']; - $expiration_date = time() + $firstExpirationDelay; - prepare_course_repository($directory, $code); - update_Db_course($db_name); - $pictures_array = fill_course_repository($directory); - fill_Db_course($db_name, $directory, $course_language,$pictures_array); - register_course($code, $visual_code, $directory, $db_name, $tutor_name, $category_code, $title, $course_language, $curso_alta['user_id'], $expiration_date); - } +if (!empty($accept_course_request)) { + $course_id = CourseRequestManager::accept_course_request($accept_course_request); - // TODO: Sent the e-mail. - + if ($course_id) { + // TODO: Prepare a confirmation message. + } else { + // Prepare an error message. + } +} - //Una vez creado el curso, cambiamos su estado en la tabla temporal - $sql_temp = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET status = 1 WHERE id LIKE '".$_GET['accept_course']."'"; +/** + * Sending to the teacher a request for additional information about the proposed course. + */ +if (!empty($request_info)) { - //$sql_temp = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id LIKE '".$_GET['accept_course']."'"; - $result = api_sql_query($sql_temp); + // Marking the fact, that additional information has been requested. + $sql_info = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id = ".$request_info; + $result_info = Database::query($sql_info); - unset ($_GET['accept_course']); + // TODO: Send the e-mail. } /** @@ -131,7 +117,7 @@ function get_course_data($from, $number_of_items, $column, $direction) { function modify_filter($id) { return ''.get_lang('Edit').' '.' '. - ''.get_lang('cesga_AdminValidar').''; + ''.get_lang('cesga_AdminValidar').''; } $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); diff --git a/main/admin/course_request_review.php b/main/admin/course_request_review.php index 7c146906e3..cb25e1955c 100644 --- a/main/admin/course_request_review.php +++ b/main/admin/course_request_review.php @@ -35,64 +35,56 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; // Including additional libraries. -require_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php'); +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; -// Information about the helpdesk. -$emailto_rt = "helpdesk_elearning@cesga.es"; -$emailbody_rt = "Owner: e-learning\nStatus: resolved\n\n"; -$email_send_rt = get_setting('administratorName').' '.get_setting('administratorSurname'); -$email_send2_rt = get_setting('emailAdministrator'); +// Filltering passed to this page parameters. +$accept_course_request = intval($_GET['accept_course_request']); +$reject_course_request = intval($_GET['reject_course_request']); +$request_info = intval($_GET['request_info']); -/* - * Sending to the teacher a request for additional information about the proposed course. +/** + * Coutse acceptance and creation. */ +if (!empty($accept_course_request)) { -if (isset($_GET['request_info']) && $_GET['request_info'] != '') { - - // TODO: Sent the e-mail. + $course_id = CourseRequestManager::accept_course_request($accept_course_request); - // Marking the fact, that additional information has been requested. - $sql_info = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id LIKE '".$_GET['request_info']."'"; - $result_info = Database::query($sql_info); + if ($course_id) { + // TODO: Prepare a confirmation message. + } else { + // Prepare an error message. + } - unset ($_GET['request_info']); } /** * Course rejection */ +if (isset($_GET['reject_course_request']) && $_GET['reject_course_request'] != '') { -if (isset($_GET['reject_course']) && $_GET['reject_course'] != '') { - - // TODO: Send the e-mail. - - //Una vez notificado al profesor, cambiamos el estado del curso en la tabla temporal - $sql_borrar = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET status = ".COURSE_REQUEST_REJECTED." WHERE id LIKE '".$_GET['reject_course']."'"; - $result_borrar = Database::query($sql_borrar); + $result = CourseRequestManager::reject_course_request($reject_course_request); - unset ($_GET['reject_course']); + if ($result) { + // TODO: Prepare a confirmation message. + } else { + // Prepare an error message. + } } /** - * Coutse acceptance and creation. + * Sending to the teacher a request for additional information about the proposed course. */ +if (!empty($request_info)) { -if (isset($_GET['accept_course']) && $_GET['accept_course'] != '') { - - // TODO: Filter $_GET['accept_course'] - $course_id = CourseRequestManager::accept_course_request($_GET['accept_course']); - - if ($course_id) { - // TODO: Prepare a confirmation message. - } else { - // Prepare an error message. - } + // Marking the fact, that additional information has been requested. + $sql_info = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id = ".$request_info; + $result_info = Database::query($sql_info); // TODO: Send the e-mail. - - unset ($_GET['accept_course']); } + + /** * Funcion feita por nos para saber o numero de cursos na taboa temporal sen validar */ @@ -150,7 +142,7 @@ function email_filter($teacher) { function modify_filter($id) { /* return - ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminPedirInfo').' '.' '.''.get_lang('cesga_AdminValidar').' '; + ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminPedirInfo').' '.' '.''.get_lang('cesga_AdminValidar').' '; */ $sql_request_info = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE (id = ".$id." AND info = 1 )"; $res_request_info = Database::query($sql_request_info); @@ -158,12 +150,12 @@ function modify_filter($id) { if (Database::num_rows($res_request_info) > 0) { //Si ya se le ha pedido información, no se muestra esa opción return - ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminValidar').' '; + ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminValidar').' '; } else { return - ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminValidar').''.' '.''.get_lang('cesga_AdminPedirInfo').'  '; + ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminValidar').''.' '.''.get_lang('cesga_AdminPedirInfo').'  '; } } diff --git a/main/admin/index.php b/main/admin/index.php index 78b74d998c..1ff4fb7135 100755 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -7,7 +7,7 @@ */ // Language files that need to be included. -$language_file = array('admin', 'tracking', 'cesga'); +$language_file = array('admin', 'tracking'); // Resetting the course id. $cidReset = true; diff --git a/main/inc/lib/course_request.lib.php b/main/inc/lib/course_request.lib.php index afc2b7647d..783b8e77aa 100644 --- a/main/inc/lib/course_request.lib.php +++ b/main/inc/lib/course_request.lib.php @@ -112,7 +112,7 @@ class CourseRequestManager { /** * Gets all the information about a course request using its database id as access key. * @param int/string $id The id (an integer number) of the corresponding database record. - * @return array/bool Returns the requested data as an array of FALSE on failure. + * @return array/bool Returns the requested data as an array or FALSE on failure. */ public static function get_course_request_info($id) { $id = (int)$id; @@ -127,7 +127,7 @@ class CourseRequestManager { /** * Accepts a given by its id course request. The requested course gets created immediately after the request acceptance. * @param int/string $id The id (an integer number) of the corresponding database record. - * @return array/bool Returns the requested data as an array of FALSE on failure. + * @return array/bool Returns the code of the newly created course or FALSE on failure. */ public static function accept_course_request($id) { @@ -187,4 +187,20 @@ class CourseRequestManager { } + /** + * Rejects a given course request. + * @param int/string $id The id (an integer number) of the corresponding database record. + * @return array/bool Returns TRUE on success or FALSE on failure. + */ + public static function reject_course_request($id) { + + $id = (int)$id; + $sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET status = ".COURSE_REQUEST_REJECTED." WHERE id = ".$id; + $result = Database::query($sql) !== false; + + // TODO: Prepare and send notification e-mail messages. + + return $result; + } + }