Plugin: OnlyOffice: Add OnlyOffice viewer by default for corresponding extensions in documents tool - refs #5395

pull/5986/head
Yannick Warnier 9 months ago
parent 3439ff1d71
commit ab1f124dfd
  1. 8
      main/inc/lib/document.lib.php
  2. 4
      plugin/onlyoffice/editor.php
  3. 6
      plugin/onlyoffice/lib/onlyofficeTools.php

@ -5479,7 +5479,13 @@ class DocumentManager
} else {
// For a "PDF Download" of the file.
$pdfPreview = null;
if ($ext != 'pdf' && !in_array($ext, $webODFList)) {
if (OnlyofficePlugin::create()->isEnabled() &&
OnlyofficePlugin::isExtensionAllowed($document_data['file_extension']) &&
method_exists('OnlyofficeTools', 'getPathToView')
) {
$url = OnlyofficeTools::getPathToView($document_data['id']);
} elseif ($ext != 'pdf' && !in_array($ext, $webODFList)) {
$url = $basePageUrl.'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
} else {
$pdfPreview = Display::url(

@ -35,8 +35,8 @@ if (empty($documentServerUrl)) {
$config = [];
$docApiUrl = $appSettings->getDocumentServerApiUrl();
$docId = $_GET['docId'];
$groupId = isset($_GET['groupId']) && !empty($_GET['groupId']) ? $_GET['groupId'] : null;
$docId = (int) $_GET['docId'];
$groupId = isset($_GET['groupId']) && !empty($_GET['groupId']) ? (int) $_GET['groupId'] : (!empty($_GET['gidReq']) ? (int) $_GET['gidReq'] : null);
$userId = api_get_user_id();
$userInfo = api_get_user_info($userId);
$sessionId = api_get_session_id();

@ -187,11 +187,10 @@ class OnlyofficeTools
$docInfoGroup = api_get_item_property_info(api_get_course_int_id(), 'document', $documentId, $sessionId);
$isGroupAccess = GroupManager::allowUploadEditDocument($userId, $courseInfo['code'], $groupProperties, $docInfoGroup);
$urlToEdit = $urlToEdit.'?groupId='.$groupId.'&';
$urlToEdit = $urlToEdit.'?'.api_get_cidreq().'&';
} else {
$urlToEdit = $urlToEdit.'?';
$urlToEdit = $urlToEdit.'?'.api_get_cidreq().'&';
}
error_log(__LINE__.' '.$urlToEdit);
$isMyDir = DocumentManager::is_my_shared_folder($userId, $docInfo['absolute_parent_path'], $sessionId);
@ -203,7 +202,6 @@ class OnlyofficeTools
}
if ($canView && !$accessRights) {
error_log(__LINE__.' '.$urlToEdit);
return $urlToEdit;
}

Loading…
Cancel
Save