Skip to content

Commit ab1f124

Browse files
committed
Plugin: OnlyOffice: Add OnlyOffice viewer by default for corresponding extensions in documents tool - refs #5395
1 parent 3439ff1 commit ab1f124

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

main/inc/lib/document.lib.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5479,7 +5479,13 @@ public static function create_document_link(
54795479
} else {
54805480
// For a "PDF Download" of the file.
54815481
$pdfPreview = null;
5482-
if ($ext != 'pdf' && !in_array($ext, $webODFList)) {
5482+
5483+
if (OnlyofficePlugin::create()->isEnabled() &&
5484+
OnlyofficePlugin::isExtensionAllowed($document_data['file_extension']) &&
5485+
method_exists('OnlyofficeTools', 'getPathToView')
5486+
) {
5487+
$url = OnlyofficeTools::getPathToView($document_data['id']);
5488+
} elseif ($ext != 'pdf' && !in_array($ext, $webODFList)) {
54835489
$url = $basePageUrl.'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
54845490
} else {
54855491
$pdfPreview = Display::url(

plugin/onlyoffice/editor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
$config = [];
3737
$docApiUrl = $appSettings->getDocumentServerApiUrl();
38-
$docId = $_GET['docId'];
39-
$groupId = isset($_GET['groupId']) && !empty($_GET['groupId']) ? $_GET['groupId'] : null;
38+
$docId = (int) $_GET['docId'];
39+
$groupId = isset($_GET['groupId']) && !empty($_GET['groupId']) ? (int) $_GET['groupId'] : (!empty($_GET['gidReq']) ? (int) $_GET['gidReq'] : null);
4040
$userId = api_get_user_id();
4141
$userInfo = api_get_user_info($userId);
4242
$sessionId = api_get_session_id();

plugin/onlyoffice/lib/onlyofficeTools.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,10 @@ public static function getPathToView(int $documentId, bool $showHeaders = true):
187187
$docInfoGroup = api_get_item_property_info(api_get_course_int_id(), 'document', $documentId, $sessionId);
188188
$isGroupAccess = GroupManager::allowUploadEditDocument($userId, $courseInfo['code'], $groupProperties, $docInfoGroup);
189189

190-
$urlToEdit = $urlToEdit.'?groupId='.$groupId.'&';
190+
$urlToEdit = $urlToEdit.'?'.api_get_cidreq().'&';
191191
} else {
192-
$urlToEdit = $urlToEdit.'?';
192+
$urlToEdit = $urlToEdit.'?'.api_get_cidreq().'&';
193193
}
194-
error_log(__LINE__.' '.$urlToEdit);
195194

196195
$isMyDir = DocumentManager::is_my_shared_folder($userId, $docInfo['absolute_parent_path'], $sessionId);
197196

@@ -203,7 +202,6 @@ public static function getPathToView(int $documentId, bool $showHeaders = true):
203202
}
204203

205204
if ($canView && !$accessRights) {
206-
error_log(__LINE__.' '.$urlToEdit);
207205

208206
return $urlToEdit;
209207
}

0 commit comments

Comments
 (0)