diff --git a/main/document/document.php b/main/document/document.php
index 6c56b3090f..5865062e03 100755
--- a/main/document/document.php
+++ b/main/document/document.php
@@ -1748,17 +1748,9 @@ $userIsSubscribed = CourseManager::is_user_subscribed_in_course(
);
if (isset($documentAndFolders) && is_array($documentAndFolders)) {
- if ($groupId == 0 ||
- GroupManager::user_has_access(
- $userId,
- $groupIid,
- GroupManager::GROUP_TOOL_DOCUMENTS
- )
- ) {
+ if ($groupId == 0 || $userAccess) {
$count = 1;
$countedPaths = array();
- $countedPaths = array();
-
foreach ($documentAndFolders as $key => $document_data) {
$row = array();
$row['id'] = $document_data['id'];
@@ -1820,7 +1812,9 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$courseInfo,
true,
$count,
- $is_visible
+ $is_visible,
+ $size,
+ $isAllowedToEdit
);
$path_info = pathinfo($document_data['path']);
@@ -1839,7 +1833,9 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$courseInfo,
false,
null,
- $is_visible
+ $is_visible,
+ $size,
+ $isAllowedToEdit
);
// Document title with link
diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php
index d59d4b1861..48993699a8 100644
--- a/main/inc/lib/api.lib.php
+++ b/main/inc/lib/api.lib.php
@@ -6020,6 +6020,12 @@ function api_browser_support($format = '')
$a_versiontemp = explode('.', $browser->getVersion());
$current_majorver = $a_versiontemp[0];
+ static $result;
+
+ if (isset($result[$format])) {
+ return $result[$format];
+ }
+
// Native svg support
if ($format == 'svg') {
if (($current_browser == 'Internet Explorer' && $current_majorver >= 9) ||
@@ -6028,22 +6034,28 @@ function api_browser_support($format = '')
($current_browser == 'Chrome' && $current_majorver >= 1) ||
($current_browser == 'Opera' && $current_majorver >= 9)
) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'pdf') {
//native pdf support
if ($current_browser == 'Chrome' && $current_majorver >= 6) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'tif' || $format == 'tiff') {
//native tif support
if ($current_browser == 'Safari' && $current_majorver >= 5) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'ogg' || $format == 'ogx' || $format == 'ogv' || $format == 'oga') {
@@ -6051,43 +6063,55 @@ function api_browser_support($format = '')
if (($current_browser == 'Firefox' && $current_majorver >= 3) ||
($current_browser == 'Chrome' && $current_majorver >= 3) ||
($current_browser == 'Opera' && $current_majorver >= 9)) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'mpg' || $format == 'mpeg') {
//native mpg support
if (($current_browser == 'Safari' && $current_majorver >= 5)) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'mp4') {
//native mp4 support (TODO: Android, iPhone)
if ($current_browser == 'Android' || $current_browser == 'iPhone') {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'mov') {
//native mov support( TODO:check iPhone)
if ($current_browser == 'Safari' && $current_majorver >= 5 || $current_browser == 'iPhone') {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'avi') {
//native avi support
if ($current_browser == 'Safari' && $current_majorver >= 5) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'wmv') {
//native wmv support
if ($current_browser == 'Firefox' && $current_majorver >= 4) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'webm') {
@@ -6098,8 +6122,10 @@ function api_browser_support($format = '')
($current_browser == 'Chrome' && $current_majorver >= 9) ||
$current_browser == 'Android'
) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'wav') {
@@ -6112,29 +6138,37 @@ function api_browser_support($format = '')
$current_browser == 'Android' ||
$current_browser == 'iPhone'
) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'mid' || $format == 'kar') {
//native midi support (TODO:check Android)
if ($current_browser == 'Opera' && $current_majorver >= 9 || $current_browser == 'Android') {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'wma') {
//native wma support
if ($current_browser == 'Firefox' && $current_majorver >= 4) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'au') {
//native au support
if ($current_browser == 'Safari' && $current_majorver >= 5) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == 'mp3') {
@@ -6146,14 +6180,17 @@ function api_browser_support($format = '')
$current_browser == 'iPhone' ||
$current_browser == 'Firefox'
) {
+ $result[$format] = true;
return true;
} else {
+ $result[$format] = false;
return false;
}
} elseif ($format == "check_browser") {
$array_check_browser = array($current_browser, $current_majorver);
return $array_check_browser;
} else {
+ $result[$format] = false;
return false;
}
}
diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php
index 12dc37ed3c..bdb19b5fe2 100755
--- a/main/inc/lib/document.lib.php
+++ b/main/inc/lib/document.lib.php
@@ -3240,7 +3240,6 @@ class DocumentManager
public static function generate_media_preview($i, $type = 'simple')
{
$i = intval($i);
-
$extra_controls = $progress = '';
if ($type == 'advanced') {
$extra_controls = '
stop
@@ -5209,6 +5208,8 @@ class DocumentManager
* @param int $show_as_icon - if it is true, only a clickable icon will be shown
* @param int $visibility (1/0)
* @param int $counter
+ * @param int $size
+ * @param bool $isAllowedToEdit
*
* @return string url
*/
@@ -5217,14 +5218,16 @@ class DocumentManager
$course_info,
$show_as_icon = false,
$counter = null,
- $visibility
+ $visibility,
+ $size = 0,
+ $isAllowedToEdit = false
) {
global $dbl_click_id;
$current_session_id = api_get_session_id();
+ $courseParams = api_get_cidreq();
$www = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/document';
$webODFList = DocumentManager::get_web_odf_extension_list();
- $isAllowedToEdit = api_is_allowed_to_edit(null, true);
// Get the title or the basename depending on what we're using
if ($document_data['title'] != '') {
@@ -5234,9 +5237,7 @@ class DocumentManager
}
$filetype = $document_data['filetype'];
- $size = $filetype == 'folder' ? get_total_folder_size($document_data['path'], $isAllowedToEdit) : $document_data['size'];
$path = $document_data['path'];
-
$url_path = urlencode($document_data['path']);
// Add class="invisible" on invisible files
@@ -5247,7 +5248,7 @@ class DocumentManager
if (!$show_as_icon) {
// Build download link (icon)
- $forcedownload_link = ($filetype == 'folder') ? api_get_self() . '?' . api_get_cidreq() . '&action=downloadfolder&id=' . $document_data['id'] : api_get_self() . '?' . api_get_cidreq() . '&action=download&id=' . $document_data['id'];
+ $forcedownload_link = ($filetype == 'folder') ? api_get_self() . '?' . $courseParams . '&action=downloadfolder&id=' . $document_data['id'] : api_get_self() . '?' . $courseParams . '&action=download&id=' . $document_data['id'];
// Folder download or file download?
$forcedownload_icon = ($filetype == 'folder') ? 'save_pack.png' : 'save.png';
// Prevent multiple clicks on zipped folder download
@@ -5267,17 +5268,17 @@ class DocumentManager
if ($is_browser_viewable_file) {
if ($ext == 'pdf' || in_array($ext, $webODFList)) {
- $url = api_get_self() . '?' . api_get_cidreq() . '&action=download&id=' . $document_data['id'];
+ $url = api_get_self() . '?' . $courseParams . '&action=download&id=' . $document_data['id'];
} else {
- $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'];
+ $url = 'showinframes.php?' . $courseParams . '&id=' . $document_data['id'];
}
} else {
// url-encode for problematic characters (we may not call them dangerous characters...)
- $path = str_replace('%2F', '/', $url_path) . '?' . api_get_cidreq();
+ $path = str_replace('%2F', '/', $url_path) . '?' . $courseParams;
$url = $www . $path;
}
} else {
- $url = api_get_self() . '?' . api_get_cidreq() . '&id=' . $document_data['id'];
+ $url = api_get_self() . '?' . $courseParams . '&id=' . $document_data['id'];
}
// The little download icon
@@ -5344,7 +5345,7 @@ class DocumentManager
if (api_get_setting('allow_my_files') === 'true' &&
api_get_setting('users_copy_files') === 'true'
) {
- $copy_myfiles_link = ($filetype == 'file') ? api_get_self() . '?' . api_get_cidreq() . '&action=copytomyfiles&id=' . $document_data['id'] : api_get_self() . '?' . api_get_cidreq();
+ $copy_myfiles_link = ($filetype == 'file') ? api_get_self() . '?' . $courseParams . '&action=copytomyfiles&id=' . $document_data['id'] : api_get_self() . '?' . $courseParams;
if ($filetype == 'file') {
$copy_to_myfiles = '' .
Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), array(), ICON_SIZE_SMALL) . ' ';
@@ -5355,7 +5356,7 @@ class DocumentManager
}
if ($filetype == 'file') {
- $send_to = Portfolio::share('document', $document_data['id'], array('style' => 'float:right;'));
+ //$send_to = Portfolio::share('document', $document_data['id'], array('style' => 'float:right;'));
}
}
@@ -5366,12 +5367,12 @@ class DocumentManager
$filetype == 'file' &&
in_array($extension, array('html', 'htm'))
) {
- $pdf_icon = ' ' .
+ $pdf_icon = ' ' .
Display::return_icon('pdf.png', get_lang('Export2PDF'), array(), ICON_SIZE_SMALL) . ' ';
}
if ($is_browser_viewable_file) {
- $open_in_new_window_link = '' .
+ $open_in_new_window_link = '' .
Display::return_icon('open_in_new_window.png', get_lang('OpenInANewWindow'), array(), ICON_SIZE_SMALL) . ' ';
}
@@ -5396,7 +5397,7 @@ class DocumentManager
preg_match('/svg$/i', urldecode($checkExtension))
) {
// Simpler version of showinframesmin.php with no headers
- $url = 'show_content.php?' . api_get_cidreq() . '&id=' . $document_data['id'];
+ $url = 'show_content.php?' . $courseParams . '&id=' . $document_data['id'];
$class = 'ajax';
if ($visibility == false) {
$class = "ajax text-muted";
@@ -5417,11 +5418,11 @@ class DocumentManager
// For a "PDF Download" of the file.
$pdfPreview = null;
if ($ext != 'pdf' && !in_array($ext, $webODFList)) {
- $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'];
+ $url = 'showinframes.php?' . $courseParams . '&id=' . $document_data['id'];
} else {
$pdfPreview = Display::url(
Display::return_icon('preview.gif', get_lang('Preview')),
- api_get_path(WEB_CODE_PATH).'document/showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'],
+ api_get_path(WEB_CODE_PATH).'document/showinframes.php?' . $courseParams . '&id=' . $document_data['id'],
array('style' => 'float:right')
);
}
@@ -5458,7 +5459,7 @@ class DocumentManager
preg_match('/bmp$/i', urldecode($checkExtension)) ||
preg_match('/svg$/i', urldecode($checkExtension))
) {
- $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'];
+ $url = 'showinframes.php?' . $courseParams . '&id=' . $document_data['id'];
return '' .
DocumentManager::build_document_icon_tag($filetype, $path, $isAllowedToEdit) .
Display::return_icon('shared.png', get_lang('ResourceShared'), array()) . '';
@@ -5493,7 +5494,7 @@ class DocumentManager
preg_match('/bmp$/i', urldecode($checkExtension)) ||
preg_match('/svg$/i', urldecode($checkExtension))
) {
- $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id']; //without preview
+ $url = 'showinframes.php?' . $courseParams . '&id=' . $document_data['id']; //without preview
return '' .
DocumentManager::build_document_icon_tag($filetype, $path, $isAllowedToEdit) . '';
} else {
@@ -6115,8 +6116,8 @@ class DocumentManager
if (!($result = in_array($file_extension, $allowed_extensions))) { // Assignment + a logical check.
return false;
}
- //check native support (Explorer, Opera, Firefox, Chrome, Safari)
+ //check native support (Explorer, Opera, Firefox, Chrome, Safari)
if ($file_extension == "pdf") {
return api_browser_support('pdf');
} elseif ($file_extension == "mp3") {