|
|
|
|
@ -13,7 +13,7 @@ |
|
|
|
|
$language_file = array('admin', 'create_course'); |
|
|
|
|
|
|
|
|
|
$cidReset = true; |
|
|
|
|
require '../inc/global.inc.php'; |
|
|
|
|
require_once '../inc/global.inc.php'; |
|
|
|
|
$this_section = SECTION_PLATFORM_ADMIN; |
|
|
|
|
$tool_name = get_lang('CourseRequestEdit'); |
|
|
|
|
|
|
|
|
|
@ -23,6 +23,7 @@ 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_request.lib.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'course_category.lib.php'; |
|
|
|
|
|
|
|
|
|
// Including a configuration file. |
|
|
|
|
require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; |
|
|
|
|
@ -56,7 +57,7 @@ if ($course_validation_feature) { |
|
|
|
|
$form = new FormValidator('add_course', 'post', 'course_request_edit.php?id='.$id.'&caller='.$caller); |
|
|
|
|
|
|
|
|
|
// Form title. |
|
|
|
|
$form->addElement('header', '', $tool_name); |
|
|
|
|
$form->addElement('header', $tool_name); |
|
|
|
|
|
|
|
|
|
// Title. |
|
|
|
|
$form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title')); |
|
|
|
|
@ -64,9 +65,25 @@ if ($course_validation_feature) { |
|
|
|
|
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
|
|
|
|
|
|
// Course category. |
|
|
|
|
$categories_select = $form->addElement('select', 'category_code', get_lang('Fac'), array()); |
|
|
|
|
$form->applyFilter('category_code', 'html_filter'); |
|
|
|
|
CourseManager::select_and_sort_categories($categories_select); |
|
|
|
|
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category'; |
|
|
|
|
|
|
|
|
|
$categoryList = array(); |
|
|
|
|
|
|
|
|
|
if (!empty($course_request_info['category_code'])) { |
|
|
|
|
$data = getCategory($course_request_info['category_code']); |
|
|
|
|
$categoryList[] = array('id' => $data['code'], 'text' => $data['name']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form->addElement( |
|
|
|
|
'select_ajax', |
|
|
|
|
'category_code', |
|
|
|
|
get_lang('CourseFaculty'), |
|
|
|
|
null, |
|
|
|
|
array( |
|
|
|
|
'url' => $url, |
|
|
|
|
'defaults' => $categoryList |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Course code. |
|
|
|
|
$form->add_textfield('wanted_code', get_lang('Code'), false, array('size' => '$maxlength', 'maxlength' => $maxlength)); |
|
|
|
|
@ -76,7 +93,6 @@ if ($course_validation_feature) { |
|
|
|
|
|
|
|
|
|
// The teacher. |
|
|
|
|
$titular = $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled')); |
|
|
|
|
//$form->applyFilter('tutor_name', 'html_filter'); |
|
|
|
|
|
|
|
|
|
// Description of the requested course. |
|
|
|
|
$form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); |
|
|
|
|
@ -98,15 +114,15 @@ if ($course_validation_feature) { |
|
|
|
|
$form->addElement('checkbox', 'exemplary_content', get_lang('FillWithExemplaryContent')); |
|
|
|
|
|
|
|
|
|
// Submit buttons. |
|
|
|
|
$submit_buttons[] = FormValidator::createElement('style_submit_button', 'save_button', get_lang('Save'), array('class' => 'save')); |
|
|
|
|
$submit_buttons[] = $form->createElement('style_submit_button', 'save_button', get_lang('Save'), array('class' => 'save')); |
|
|
|
|
if ($course_request_info['status'] != COURSE_REQUEST_ACCEPTED) { |
|
|
|
|
$submit_buttons[] = FormValidator::createElement('style_submit_button', 'accept_button', get_lang('Accept'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'icons/16/accept.png);')); |
|
|
|
|
$submit_buttons[] = $form->createElement('style_submit_button', 'accept_button', get_lang('Accept'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'icons/16/accept.png);')); |
|
|
|
|
} |
|
|
|
|
if ($course_request_info['status'] != COURSE_REQUEST_ACCEPTED && $course_request_info['status'] != COURSE_REQUEST_REJECTED) { |
|
|
|
|
$submit_buttons[] = FormValidator::createElement('style_submit_button', 'reject_button', get_lang('Reject'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'icons/16/error.png);')); |
|
|
|
|
$submit_buttons[] = $form->createElement('style_submit_button', 'reject_button', get_lang('Reject'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'icons/16/error.png);')); |
|
|
|
|
} |
|
|
|
|
if ($course_request_info['status'] != COURSE_REQUEST_ACCEPTED && intval($course_request_info['info']) <= 0) { |
|
|
|
|
$submit_buttons[] = FormValidator::createElement('style_submit_button', 'ask_info_button', get_lang('AskAdditionalInfo'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'request_info.gif);')); |
|
|
|
|
$submit_buttons[] = $form->createElement('style_submit_button', 'ask_info_button', get_lang('AskAdditionalInfo'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'request_info.gif);')); |
|
|
|
|
} |
|
|
|
|
$form->addGroup($submit_buttons); |
|
|
|
|
|
|
|
|
|
@ -127,7 +143,7 @@ if ($course_validation_feature) { |
|
|
|
|
$values['course_language'] = $course_request_info['course_language']; |
|
|
|
|
$values['title'] = $course_request_info['title']; |
|
|
|
|
$values['description'] = $course_request_info['description']; |
|
|
|
|
$values['category_code'] = $course_request_info['category_code']; |
|
|
|
|
//$values['category_code'] = $course_request_info['category_code']; |
|
|
|
|
$values['tutor_name'] = $course_request_info['tutor_name']; |
|
|
|
|
$values['visual_code'] = $course_request_info['visual_code']; |
|
|
|
|
$values['request_date'] = $course_request_info['request_date']; |
|
|
|
|
@ -140,12 +156,7 @@ if ($course_validation_feature) { |
|
|
|
|
|
|
|
|
|
// Validate the form and perform the ordered actions. |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$course_request_values = $form->exportValues(); |
|
|
|
|
|
|
|
|
|
// Filter incoming data. |
|
|
|
|
foreach ($course_request_values as &$value) { |
|
|
|
|
$value = trim(Security::remove_XSS(stripslashes($value))); |
|
|
|
|
} |
|
|
|
|
$course_request_values = $form->getSubmitValues(); |
|
|
|
|
|
|
|
|
|
// Detection which submit button has been pressed. |
|
|
|
|
$submit_button = isset($_POST['save_button']) ? 'save_button' |
|
|
|
|
@ -164,7 +175,8 @@ if ($course_validation_feature) { |
|
|
|
|
$is_error_message = false; |
|
|
|
|
|
|
|
|
|
// Update the course request. |
|
|
|
|
$update_ok = CourseRequestManager::update_course_request($id, |
|
|
|
|
$update_ok = CourseRequestManager::update_course_request( |
|
|
|
|
$id, |
|
|
|
|
$course_request_values['wanted_code'], |
|
|
|
|
$course_request_values['title'], |
|
|
|
|
$course_request_values['description'], |
|
|
|
|
@ -177,7 +189,7 @@ if ($course_validation_feature) { |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($update_ok) { |
|
|
|
|
$message[] = sprintf(get_lang(CourseRequestUpdated), $course_request_values['wanted_code']); |
|
|
|
|
$message[] = sprintf(get_lang('CourseRequestUpdated'), $course_request_values['wanted_code']); |
|
|
|
|
|
|
|
|
|
switch ($submit_button) { |
|
|
|
|
case 'accept_button': |
|
|
|
|
@ -209,7 +221,7 @@ if ($course_validation_feature) { |
|
|
|
|
//$message = 'The button "'.$submit_button.'" has been pressed.'; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$message[] = sprintf(get_lang(CourseRequestUpdateFailed), $course_request_values['wanted_code']); |
|
|
|
|
$message[] = sprintf(get_lang('CourseRequestUpdateFailed'), $course_request_values['wanted_code']); |
|
|
|
|
$is_error_message = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -223,22 +235,18 @@ if ($course_validation_feature) { |
|
|
|
|
$back_url = api_add_url_param($back_url, 'is_error_message=1', false); |
|
|
|
|
} |
|
|
|
|
header('location:'.$back_url); |
|
|
|
|
|
|
|
|
|
exit; |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
$message = $course_request_values['wanted_code'].' - '.get_lang('CourseCodeAlreadyExists'); |
|
|
|
|
$is_error_message = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
// Prepare an error message notifying that the course validation feature has not been enabled. |
|
|
|
|
$link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation'; |
|
|
|
|
$link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?search_field=course_validation&submit_button=&category=search_setting'; |
|
|
|
|
$message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation'))); |
|
|
|
|
$is_error_message = true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Functions. |
|
|
|
|
|