123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- session_cache_limiter('public');
- require_once 'work.lib.php';
- $current_course_tool = TOOL_STUDENTPUBLICATION;
- $this_section = SECTION_COURSES;
- header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
- header('Cache-Control: public');
- header('Pragma: no-cache');
- api_protect_course_script(true);
- $id = intval($_GET['id']);
- $course_info = api_get_course_info();
- if (empty($course_info)) {
- api_not_allowed(true);
- }
- $tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
- if (!empty($course_info['real_id'])) {
- $sql = 'SELECT * FROM '.$tbl_student_publication.' WHERE c_id = '.$course_info['real_id'].' AND id = "'.$id.'"';
- $result = Database::query($sql);
- if ($result && Database::num_rows($result)) {
- $row = Database::fetch_array($result, 'ASSOC');
- $full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
- $item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
- allowOnlySubscribedUser(api_get_user_id(), $row['parent_id'], $course_info['real_id']);
- if (empty($item_info)) {
- exit;
- }
-
- $work_is_visible = ($item_info['visibility'] == 1 && $row['accepted'] == 1);
- $doc_visible_for_all = ($course_info['show_score'] == 1);
- $is_editor = api_is_allowed_to_edit(true, true, true);
- $student_is_owner_of_work = user_is_author($row['id'], $row['user_id']);
- if ($is_editor
-
- || ($student_is_owner_of_work)
- || ($doc_visible_for_all && $work_is_visible)) {
- $title = str_replace(' ', '_', $row['title']);
- event_download($title);
- if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')) {
- DocumentManager::file_send_for_download($full_file_name, true, $title);
- }
- } else {
- api_not_allowed();
- }
- }
- } else {
- api_not_allowed();
- }
- exit;
|