Event::event_download() only if file is found

- Fix if item doesn't exists.
pull/2487/head
jmontoyaa 9 years ago
parent daff21618f
commit 78925cd36f
  1. 15
      main/work/work.lib.php

@ -2802,7 +2802,6 @@ function getStudentSubscribedToWork(
} else { } else {
return $usersInWork; return $usersInWork;
} }
} }
/** /**
@ -4944,16 +4943,16 @@ function getFileContents($id, $course_info, $sessionId = 0, $correction = false)
$sessionId $sessionId
); );
if (empty($item_info)) {
return false;
}
allowOnlySubscribedUser( allowOnlySubscribedUser(
api_get_user_id(), api_get_user_id(),
$row['parent_id'], $row['parent_id'],
$course_info['real_id'] $course_info['real_id']
); );
if (empty($item_info)) {
api_not_allowed();
}
/* /*
field show_score in table course : field show_score in table course :
0 => New documents are visible for all users 0 => New documents are visible for all users
@ -4989,7 +4988,7 @@ function getFileContents($id, $course_info, $sessionId = 0, $correction = false)
$student_is_owner_of_work = user_is_author($row['id'], $row['user_id']); $student_is_owner_of_work = user_is_author($row['id'], $row['user_id']);
if ($is_editor || if ($is_editor ||
($student_is_owner_of_work) || $student_is_owner_of_work ||
($doc_visible_for_all && $work_is_visible) ($doc_visible_for_all && $work_is_visible)
) { ) {
$title = $row['title']; $title = $row['title'];
@ -5011,12 +5010,12 @@ function getFileContents($id, $course_info, $sessionId = 0, $correction = false)
} }
} }
Event::event_download($title);
if (Security::check_abs_path( if (Security::check_abs_path(
$full_file_name, $full_file_name,
api_get_path(SYS_COURSE_PATH).api_get_course_path().'/') api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')
) { ) {
Event::event_download($title);
return array( return array(
'path' => $full_file_name, 'path' => $full_file_name,
'title' => $title, 'title' => $title,

Loading…
Cancel
Save