You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
7.7 KiB
200 lines
7.7 KiB
14 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
|
|
||
|
/**
|
||
7 years ago
|
* A list containig the accepted course requests.
|
||
|
*
|
||
14 years ago
|
* @package chamilo.admin
|
||
7 years ago
|
*
|
||
14 years ago
|
* @author José Manuel Abuin Mosquera <chema@cesga.es>, 2010
|
||
|
* @author Bruno Rubio Gayo <brubio@cesga.es>, 2010
|
||
|
* Centro de Supercomputacion de Galicia (CESGA)
|
||
|
* @author Ivan Tcholakov <ivantcholakov@gmail.com> (technical adaptation for Chamilo 1.8.8), 2010
|
||
|
*/
|
||
|
$cidReset = true;
|
||
|
|
||
8 years ago
|
require_once __DIR__.'/../inc/global.inc.php';
|
||
14 years ago
|
$this_section = SECTION_PLATFORM_ADMIN;
|
||
|
api_protect_admin_script();
|
||
|
|
||
14 years ago
|
// A check whether the course validation feature is enabled.
|
||
|
$course_validation_feature = api_get_setting('course_validation') == 'true';
|
||
|
|
||
14 years ago
|
// Filltering passed to this page parameters.
|
||
10 years ago
|
$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : '';
|
||
|
$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : '';
|
||
14 years ago
|
$is_error_message = !empty($_GET['is_error_message']);
|
||
14 years ago
|
|
||
14 years ago
|
if ($course_validation_feature) {
|
||
|
/**
|
||
|
* Deletion of a course request.
|
||
|
*/
|
||
|
if (!empty($delete_course_request)) {
|
||
|
$course_request_code = CourseRequestManager::get_course_request_code($delete_course_request);
|
||
|
$result = CourseRequestManager::delete_course_request($delete_course_request);
|
||
|
if ($result) {
|
||
5 years ago
|
$message = sprintf(get_lang('The course request %s has been deleted.'), $course_request_code);
|
||
14 years ago
|
$is_error_message = false;
|
||
|
} else {
|
||
5 years ago
|
$message = sprintf(get_lang('The course request %s has not been deleted due to internal error.'), $course_request_code);
|
||
14 years ago
|
$is_error_message = true;
|
||
|
}
|
||
8 years ago
|
} elseif (isset($_POST['action'])) {
|
||
|
/**
|
||
|
* Form actions: delete.
|
||
|
*/
|
||
14 years ago
|
switch ($_POST['action']) {
|
||
|
// Delete selected courses
|
||
8 years ago
|
case 'delete_course_requests':
|
||
14 years ago
|
$course_requests = $_POST['course_request'];
|
||
|
if (is_array($_POST['course_request']) && !empty($_POST['course_request'])) {
|
||
|
$success = true;
|
||
|
foreach ($_POST['course_request'] as $index => $course_request_id) {
|
||
|
$success &= CourseRequestManager::delete_course_request($course_request_id);
|
||
|
}
|
||
5 years ago
|
$message = $success ? get_lang('The selected course requests have been deleted.') : get_lang('Some of the selected course requests have not been deleted due to internal error.');
|
||
14 years ago
|
$is_error_message = !$success;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
10 years ago
|
$link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
|
||
7 years ago
|
$message = sprintf(
|
||
5 years ago
|
get_lang('The "Course validation" feature is not enabled at the moment. In order to use this feature, please, enable it by using the %s setting.'),
|
||
|
sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('Courses validation'))
|
||
7 years ago
|
);
|
||
10 years ago
|
$is_error_message = true;
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
|
/**
|
||
14 years ago
|
* Get the number of courses which will be displayed.
|
||
14 years ago
|
*/
|
||
8 years ago
|
function get_number_of_requests()
|
||
|
{
|
||
14 years ago
|
return CourseRequestManager::count_course_requests(COURSE_REQUEST_ACCEPTED);
|
||
14 years ago
|
}
|
||
|
|
||
|
/**
|
||
7 years ago
|
* Get course data to display.
|
||
14 years ago
|
*/
|
||
10 years ago
|
function get_request_data($from, $number_of_items, $column, $direction)
|
||
|
{
|
||
|
$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : null;
|
||
8 years ago
|
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
|
||
5 years ago
|
$tblCourseCategory = Database::get_main_table(TABLE_MAIN_CATEGORY);
|
||
10 years ago
|
|
||
10 years ago
|
$from = intval($from);
|
||
|
$number_of_items = intval($number_of_items);
|
||
|
$column = intval($column);
|
||
8 years ago
|
$direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction;
|
||
10 years ago
|
|
||
|
$sql = "SELECT
|
||
|
id AS col0,
|
||
|
code AS col1,
|
||
|
title AS col2,
|
||
5 years ago
|
course_category.code AS col3,
|
||
10 years ago
|
tutor_name AS col4,
|
||
|
request_date AS col5,
|
||
|
id AS col6
|
||
|
FROM $course_request_table
|
||
5 years ago
|
LEFT JOIN $tblCourseCategory on course.category_id = course_category.id
|
||
10 years ago
|
WHERE status = ".COURSE_REQUEST_ACCEPTED;
|
||
14 years ago
|
|
||
14 years ago
|
if ($keyword != '') {
|
||
10 years ago
|
$sql .= " AND (
|
||
|
title LIKE '%".$keyword."%' OR
|
||
|
code LIKE '%".$keyword."%' OR
|
||
|
visual_code LIKE '%".$keyword."%'
|
||
|
)";
|
||
14 years ago
|
}
|
||
14 years ago
|
$sql .= " ORDER BY col$column $direction ";
|
||
|
$sql .= " LIMIT $from,$number_of_items";
|
||
|
$res = Database :: query($sql);
|
||
|
|
||
7 years ago
|
$course_requests = [];
|
||
14 years ago
|
while ($course_request = Database :: fetch_row($res)) {
|
||
14 years ago
|
$course_request[5] = api_get_local_time($course_request[5]);
|
||
14 years ago
|
$course_requests[] = $course_request;
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
return $course_requests;
|
||
14 years ago
|
}
|
||
|
|
||
|
/**
|
||
14 years ago
|
* Actions in the list: edit, accept, delete.
|
||
14 years ago
|
*/
|
||
10 years ago
|
function modify_filter($id)
|
||
|
{
|
||
14 years ago
|
$code = CourseRequestManager::get_course_request_code($id);
|
||
10 years ago
|
$result = '<a href="course_request_edit.php?id='.$id.'&caller=1">'.
|
||
7 years ago
|
Display::return_icon('edit.png', get_lang('Edit'), ['style' => 'vertical-align: middle;']).'</a>'.
|
||
10 years ago
|
' <a href="?delete_course_request='.$id.'">'.
|
||
7 years ago
|
Display::return_icon(
|
||
|
'delete.png',
|
||
5 years ago
|
get_lang('Delete this course request'),
|
||
7 years ago
|
[
|
||
7 years ago
|
'style' => 'vertical-align: middle;',
|
||
5 years ago
|
'onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('The course request %s is going to be deleted. Is it OK to proceed?'), $code), ENT_QUOTES)).'\')) return false;',
|
||
7 years ago
|
]
|
||
7 years ago
|
).
|
||
|
'</a>';
|
||
10 years ago
|
|
||
14 years ago
|
return $result;
|
||
14 years ago
|
}
|
||
|
|
||
5 years ago
|
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
|
||
|
$interbreadcrumb[] = ['url' => 'course_list.php', 'name' => get_lang('Course list')];
|
||
|
$tool_name = get_lang('Accepted course requests');
|
||
14 years ago
|
|
||
14 years ago
|
// Display confirmation or error message.
|
||
|
if (!empty($message)) {
|
||
|
if ($is_error_message) {
|
||
8 years ago
|
Display::addFlash(Display::return_message($message, 'error', false));
|
||
14 years ago
|
} else {
|
||
8 years ago
|
Display::addFlash(Display::return_message($message, 'normal', false));
|
||
14 years ago
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
Display :: display_header($tool_name);
|
||
|
|
||
14 years ago
|
if (!$course_validation_feature) {
|
||
|
Display :: display_footer();
|
||
|
exit;
|
||
|
}
|
||
|
|
||
14 years ago
|
// Create a simple search-box.
|
||
|
$form = new FormValidator('search_simple', 'get', '', '', 'width=200px', false);
|
||
|
$renderer = $form->defaultRenderer();
|
||
10 years ago
|
$renderer->setCustomElementTemplate('<span>{element}</span> ');
|
||
10 years ago
|
$form->addElement('text', 'keyword', get_lang('Keyword'));
|
||
10 years ago
|
$form->addButtonSearch(get_lang('Search'));
|
||
14 years ago
|
|
||
14 years ago
|
// The action bar.
|
||
14 years ago
|
echo '<div style="float: right; margin-top: 5px; margin-right: 5px;">';
|
||
7 years ago
|
echo ' <a href="course_request_review.php">'.
|
||
5 years ago
|
Display::return_icon('course_request_pending.png', get_lang('Review incoming course requests')).get_lang('Review incoming course requests').'</a>';
|
||
7 years ago
|
echo ' <a href="course_request_rejected.php">'.
|
||
5 years ago
|
Display::return_icon('course_request_rejected.gif', get_lang('Rejected course requests')).get_lang('Rejected course requests').'</a>';
|
||
14 years ago
|
echo '</div>';
|
||
|
echo '<div class="actions">';
|
||
|
$form->display();
|
||
14 years ago
|
echo '</div>';
|
||
|
|
||
14 years ago
|
// Create a sortable table with the course data.
|
||
14 years ago
|
$table = new SortableTable('course_requests_accepted', 'get_number_of_requests', 'get_request_data', 5, 20, 'DESC');
|
||
14 years ago
|
$table->set_header(0, '', false);
|
||
5 years ago
|
$table->set_header(1, get_lang('Course code'));
|
||
14 years ago
|
$table->set_header(2, get_lang('Title'));
|
||
|
$table->set_header(3, get_lang('Category'));
|
||
5 years ago
|
$table->set_header(4, get_lang('Trainer'));
|
||
|
$table->set_header(5, get_lang('Request date'));
|
||
14 years ago
|
$table->set_header(6, '', false);
|
||
|
$table->set_column_filter(6, 'modify_filter');
|
||
5 years ago
|
$table->set_form_actions(['delete_course_requests' => get_lang('Delete selected course request(s)')], 'course_request');
|
||
14 years ago
|
$table->display();
|
||
|
|
||
|
/* FOOTER */
|
||
|
|
||
|
Display :: display_footer();
|