/**
  * @param string $courseCode
  * @param string $fileName
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function getFileAction($courseCode, $fileName)
 {
     $courseInfo = api_get_course_info($courseCode);
     $sessionId = $this->getRequest()->get('id_session');
     $docId = \DocumentManager::get_document_id($courseInfo, "/" . $fileName);
     $filePath = null;
     if ($docId) {
         $isVisible = \DocumentManager::is_visible_by_id($docId, $courseInfo, $sessionId, api_get_user_id());
         $documentData = \DocumentManager::get_document_data_by_id($docId, $courseCode);
         $filePath = $documentData['absolute_path'];
         event_download($filePath);
     }
     if (!api_is_allowed_to_edit() && !$isVisible) {
         $this->abort(500);
     }
     return $this->sendFile($filePath);
 }
Exemplo n.º 2
0
    $actionsRight = $form->returnForm();
}
$table_footer = '';
$total_size = 0;
$sortable_data = array();
if (isset($documentAndFolders) && is_array($documentAndFolders)) {
    if ($groupId == 0 || GroupManager::user_has_access($userId, $groupId, GroupManager::GROUP_TOOL_DOCUMENTS)) {
        $count = 1;
        $countedPaths = array();
        $countedPaths = array();
        foreach ($documentAndFolders as $key => $document_data) {
            $row = array();
            $row['id'] = $document_data['id'];
            $row['type'] = $document_data['filetype'];
            // If the item is invisible, wrap it in a span with class invisible.
            $is_visible = DocumentManager::is_visible_by_id($document_data['id'], $courseInfo, $sessionId, api_get_user_id(), false);
            $invisibility_span_open = $is_visible == 0 ? '<span class="muted">' : '';
            $invisibility_span_close = $is_visible == 0 ? '</span>' : '';
            // Size (or total size of a directory)
            $size = $document_data['filetype'] == 'folder' ? get_total_folder_size($document_data['path'], $is_allowed_to_edit) : $document_data['size'];
            // Get the title or the basename depending on what we're using
            if ($document_data['title'] != '') {
                $document_name = $document_data['title'];
            } else {
                $document_name = basename($document_data['path']);
            }
            $row['name'] = $document_name;
            // Data for checkbox
            if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) {
                $row[] = $document_data['id'];
            }