Browse Source

Event::event_download() only if file is found

- Fix if item doesn't exists.
jmontoyaa 8 years ago
parent
commit
78925cd36f
1 changed files with 7 additions and 8 deletions
  1. 7 8
      main/work/work.lib.php

+ 7 - 8
main/work/work.lib.php

@@ -2802,7 +2802,6 @@ function getStudentSubscribedToWork(
     } else {
         return $usersInWork;
     }
-
 }
 
 /**
@@ -4944,16 +4943,16 @@ function getFileContents($id, $course_info, $sessionId = 0, $correction = false)
                 $sessionId
             );
 
+            if (empty($item_info)) {
+                return false;
+            }
+
             allowOnlySubscribedUser(
                 api_get_user_id(),
                 $row['parent_id'],
                 $course_info['real_id']
             );
 
-            if (empty($item_info)) {
-                api_not_allowed();
-            }
-
             /*
             field show_score in table course :
                 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']);
 
             if ($is_editor ||
-                ($student_is_owner_of_work) ||
+                $student_is_owner_of_work ||
                 ($doc_visible_for_all && $work_is_visible)
             ) {
                 $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(
                     $full_file_name,
                     api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')
                 ) {
+                    Event::event_download($title);
+
                     return array(
                         'path' => $full_file_name,
                         'title' => $title,