From b4ebb04c6474a0f846e88ed90451cc0508f4f1e0 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Thu, 7 Oct 2010 01:23:49 +0300 Subject: [PATCH] Feature #2099 - Additional source files have been added. --- main/admin/course_request_accepted.php | 116 +++++++++++++ main/admin/course_request_rejected.php | 164 +++++++++++++++++++ main/admin/course_request_review.php | 215 +++++++++++++++++++++++++ main/admin/index.php | 9 +- main/create_course/add_course.php | 3 +- 5 files changed, 504 insertions(+), 3 deletions(-) create mode 100644 main/admin/course_request_accepted.php create mode 100644 main/admin/course_request_rejected.php create mode 100644 main/admin/course_request_review.php diff --git a/main/admin/course_request_accepted.php b/main/admin/course_request_accepted.php new file mode 100644 index 0000000000..4b6df1b731 --- /dev/null +++ b/main/admin/course_request_accepted.php @@ -0,0 +1,116 @@ +, 2010 + * @author Bruno Rubio Gayo , 2010 + * Centro de Supercomputacion de Galicia (CESGA) + * + * @author Ivan Tcholakov (technical adaptation for Chamilo 1.8.8), 2010 + */ + +/* INIT SECTION */ + +// Language files that need to be included. +$language_file = array('admin', 'create_course'); + +$cidReset = true; + +require '../inc/global.inc.php'; + +$this_section = SECTION_PLATFORM_ADMIN; + +api_protect_admin_script(); + +require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'; +require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'course_request.lib.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; + +// Including a configuration file. +require api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; + +// Include additional libraries +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; + + +/** + * Get the number of courses which will be displayed + */ +function get_number_of_courses() { + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); + $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_ACCEPTED; + $res = Database :: query($sql); + $obj = Database :: fetch_object($res); + return $obj->total_number_of_items; +} + +/** + * Get course data to display + */ +function get_course_data($from, $number_of_items, $column, $direction) { + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); + $users_table = Database :: get_main_table(TABLE_MAIN_USER); + $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); + + $sql = "SELECT code AS col0, + + title AS col1, + category_code AS col2, + tutor_name AS col3, + request_date AS col4, + id AS col5 + FROM $course_table WHERE status = ".COURSE_REQUEST_ACCEPTED; + + $sql .= " ORDER BY col$column $direction "; + $sql .= " LIMIT $from,$number_of_items"; + $res = Database :: query($sql); + $courses = array(); + + while ($course = Database :: fetch_row($res)) { + $courses[] = $course; + } + + return $courses; +} + +/** + * Actions in the list: edit. + */ +function modify_filter($id) { + return + ''.get_lang('Edit').' '; +} + +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); +$tool_name = get_lang('cesga_AdminCursosValid'); +Display :: display_header($tool_name); + +//api_display_tool_title($tool_name); +if (isset ($_GET['delete_course'])) { + CourseManager :: delete_course($_GET['delete_course']); +} + +// Create a sortable table with the course data +$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2); +$table->set_additional_parameters($parameters); +//$table->set_header(0, '', false); +$table->set_header(0, get_lang('Code')); +$table->set_header(1, get_lang('Title')); +$table->set_header(2, get_lang('Category')); +//$table->set_header(3, get_lang('Teacher'), false); +//$table->set_header(4, get_lang('cesga_AdminFechaSolic'), false); +$table->set_header(3, get_lang('Teacher')); +$table->set_header(4, get_lang('cesga_AdminFechaSolic')); +$table->set_header(5, '', false); +$table->set_column_filter(5, 'modify_filter'); +//$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course'); +$table->display(); + +/* FOOTER */ + +Display :: display_footer(); diff --git a/main/admin/course_request_rejected.php b/main/admin/course_request_rejected.php new file mode 100644 index 0000000000..91ad1dc591 --- /dev/null +++ b/main/admin/course_request_rejected.php @@ -0,0 +1,164 @@ +, 2010 + * @author Bruno Rubio Gayo , 2010 + * Centro de Supercomputacion de Galicia (CESGA) + * + * @author Ivan Tcholakov (technical adaptation for Chamilo 1.8.8), 2010 + */ + +/* INIT SECTION */ + +// Language files that need to be included. +$language_file = array('admin', 'create_course'); + +$cidReset = true; + +require '../inc/global.inc.php'; + +$this_section = SECTION_PLATFORM_ADMIN; + +api_protect_admin_script(); + +require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'; +require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'course_request.lib.php'; +require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; + +// Including a configuration file. +require api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; + +// Including additional libraries. +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; + + +/** + * 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); + } + + + // TODO: Sent the e-mail. + + + + //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']."'"; + + //$sql_temp = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id LIKE '".$_GET['accept_course']."'"; + $result = api_sql_query($sql_temp); + + unset ($_GET['accept_course']); +} + +/** + * Get the number of courses which will be displayed + */ +function get_number_of_courses() { + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); + $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED; + $res = Database :: query($sql); + $obj = Database :: fetch_object($res); + return $obj->total_number_of_items; +} + +/** + * Get course data to display + */ +function get_course_data($from, $number_of_items, $column, $direction) { + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); + $users_table = Database :: get_main_table(TABLE_MAIN_USER); + $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); + + $sql = "SELECT code AS col0, + + title AS col1, + category_code AS col2, + tutor_name AS col3, + request_date AS col4, + id AS col5 + FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED; + + $sql .= " ORDER BY col$column $direction "; + $sql .= " LIMIT $from,$number_of_items"; + $res = Database :: query($sql); + $courses = array(); + + while ($course = Database :: fetch_row($res)) { + $courses[] = $course; + } + + return $courses; +} + +/** + * Actions in the list: edit. + */ + +function modify_filter($id) { + return + ''.get_lang('Edit').' '.' '. + ''.get_lang('cesga_AdminValidar').''; +} + +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); +$tool_name = get_lang('cesga_AdminCursosRexeit'); //nombre que aparece en la barra de navegación +Display :: display_header($tool_name); + +//api_display_tool_title($tool_name); +if (isset($_GET['delete_course'])) { + CourseManager :: delete_course($_GET['delete_course']); +} + +// Create a sortable table with the course data +$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2); +$table->set_additional_parameters($parameters); +//$table->set_header(0, '', false); +$table->set_header(0, get_lang('Code')); +$table->set_header(1, get_lang('Title')); +$table->set_header(2, get_lang('Category')); +//$table->set_header(3, get_lang('Teacher'), false); +//$table->set_header(4, get_lang('cesga_AdminFechaSolic'), false); +$table->set_header(3, get_lang('Teacher')); +$table->set_header(4, get_lang('cesga_AdminFechaSolic')); +$table->set_header(5, '', false); +$table->set_column_filter(5, 'modify_filter'); +//$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course'); +$table->display(); + +/* FOOTER */ + +Display :: display_footer(); diff --git a/main/admin/course_request_review.php b/main/admin/course_request_review.php new file mode 100644 index 0000000000..7c146906e3 --- /dev/null +++ b/main/admin/course_request_review.php @@ -0,0 +1,215 @@ +, 2010 + * Centro de Supercomputacion de Galicia (CESGA) + * + * @author Ivan Tcholakov (technical adaptation for Chamilo 1.8.8), 2010 + */ + +/* INIT SECTION */ + +// Language files that need to be included. +$language_file = array('admin', 'create_course'); + +$cidReset = true; +require '../inc/global.inc.php'; +$this_section = SECTION_PLATFORM_ADMIN; + +api_protect_admin_script(); + +require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'; +require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'course_request.lib.php'; +require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; +require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; +require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; + +// Including a configuration file. +require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; + +// Including additional libraries. +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'); + +/* + * Sending to the teacher a request for additional information about the proposed course. + */ + +if (isset($_GET['request_info']) && $_GET['request_info'] != '') { + + // TODO: Sent the e-mail. + + // 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); + + unset ($_GET['request_info']); +} + +/** + * Course rejection + */ + +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); + + unset ($_GET['reject_course']); +} + +/** + * Coutse acceptance and creation. + */ + +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. + } + + // TODO: Send the e-mail. + + unset ($_GET['accept_course']); +} + +/** + * Funcion feita por nos para saber o numero de cursos na taboa temporal sen validar + */ +function get_number_of_courses() { + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); + $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_PENDING; + $res = Database::query($sql); + $obj = Database::fetch_object($res); + return $obj->total_number_of_items; +} + +/** + * Get course data to display + */ +function get_course_data($from, $number_of_items, $column, $direction) { + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); + $users_table = Database :: get_main_table(TABLE_MAIN_USER); + $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); + + $sql = "SELECT code AS col0, + code AS col1, + title AS col2, + category_code AS col3, + tutor_name AS col4, + request_date AS col5, + id AS col6 + FROM $course_table WHERE status = ".COURSE_REQUEST_PENDING; + + $sql .= " ORDER BY col$column $direction "; + $sql .= " LIMIT $from,$number_of_items"; + $res = Database::query($sql); + $courses = array(); + + while ($course = Database::fetch_row($res)) { + $courses[] = $course; + } + + return $courses; +} + +/** + * Enlace a la ficha del profesor + */ +function email_filter($teacher) { + $sql = "SELECT user_id FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE tutor_name LIKE '".$teacher."'"; + $res = Database::query($sql); + $info = Database::fetch_array($res); + return ''.$teacher.''; +} + +/** + * Actions in the list: edit, accept, reject, request additional information. + */ + +function modify_filter($id) { + /* + return + ''.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); + + 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').' '; + + } else { + + return + ''.get_lang('Edit').' '.' '.''.get_lang('Delete').''.' '.''.get_lang('cesga_AdminValidar').''.' '.''.get_lang('cesga_AdminPedirInfo').'  '; + } +} + +if (isset ($_POST['action'])) { + switch ($_POST['action']) { + // Delete selected courses + case 'delete_courses' : + $course_codes = $_POST['course']; + if (count($course_codes) > 0) { + foreach ($course_codes as $index => $course_code) { + //CourseManager :: delete_course($course_code); + $sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE code LIKE '".$course_code."'"; + //echo $sql; + $result = Database::query($sql); + } + } + break; + } +} + +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); +$tool_name = get_lang('cesga_AdminValidCursos'); //nombre que aparece en la barra de navegación +Display :: display_header($tool_name); + +//api_display_tool_title($tool_name); +if (isset ($_GET['delete_course'])) { + CourseManager :: delete_course($_GET['delete_course']); +} + +// Create a sortable table with the course data +$table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2); +$table->set_additional_parameters($parameters); +$table->set_header(0, '', false); +$table->set_header(1, get_lang('Code')); +$table->set_header(2, get_lang('Title')); +$table->set_header(3, get_lang('Category')); +//$table->set_header(4, get_lang('Teacher'), false); +//$table->set_header(5, get_lang('cesga_AdminFechaSolic'), false); +$table->set_header(4, get_lang('Teacher')); +$table->set_header(5, get_lang('cesga_AdminFechaSolic')); +$table->set_header(6, '', false); +$table->set_column_filter(4,'email_filter'); +$table->set_column_filter(6,'modify_filter'); +$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course'); +$table->display(); + +/* FOOTER */ + +Display :: display_footer(); diff --git a/main/admin/index.php b/main/admin/index.php index a59272028e..78b74d998c 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'); +$language_file = array('admin', 'tracking', 'cesga'); // Resetting the course id. $cidReset = true; @@ -103,13 +103,20 @@ if (api_is_platform_admin()) { ?>
  • +
  • +
  • + +
  • +
  • +
  • +
  • validate()) { $target_audience = Security::remove_XSS($course_values['target_audience']); $status = '0'; + // TODO: Why escaping quotes is needed here? $description = str_replace('"', '', $description); $objetives = str_replace('"', '', $objetives); $target_audience = str_replace('"', '', $target_audience); @@ -250,8 +251,6 @@ if ($form->validate()) { if ($request_id) { - // TODO: Prepare and send notification e-mail messages. - $course_request_info = CourseRequestManager::get_course_request_info($request_id); $visual_code = is_array($course_request_info) ? $course_request_info['visual_code'] : ''; $message = get_lang('CourseRequestCreated');