Hide documents from other sessions

pull/5657/head
juancpbinario 1 year ago
parent e555b88c9c
commit 3e68693daa
  1. 2
      main/inc/lib/elfinder/filemanager.php
  2. 34
      main/template/default/javascript/editor/elfinder_standalone.tpl

@ -18,8 +18,10 @@ if (file_exists($file)) {
$language = $iso; $language = $iso;
} }
$questionId = isset($_REQUEST['question_id']) ? (int) $_REQUEST['question_id'] : 0; $questionId = isset($_REQUEST['question_id']) ? (int) $_REQUEST['question_id'] : 0;
$sessionId = api_get_session_id();
$template->assign('question_id', $questionId); $template->assign('question_id', $questionId);
$template->assign('session_id', $sessionId);
$template->assign('elfinder_lang', $language); $template->assign('elfinder_lang', $language);
$template->assign('elfinder_translation_file', $includeFile); $template->assign('elfinder_translation_file', $includeFile);
$template->display('default/javascript/editor/ckeditor/elfinder.tpl'); $template->display('default/javascript/editor/ckeditor/elfinder.tpl');

@ -19,24 +19,40 @@
$().ready(function() { $().ready(function() {
var funcNum = getUrlParam('CKEditorFuncNum'); var funcNum = getUrlParam('CKEditorFuncNum');
var sessionId = {{session_id}};
var elf = $('#elfinder').elfinder({ var elf = $('#elfinder').elfinder({
url : '{{ _p.web_lib ~ 'elfinder/connectorAction.php?' }}{{ course_condition }}', // connector URL (REQUIRED) url : '{{ _p.web_lib ~ 'elfinder/connectorAction.php?' }}{{ course_condition }}', // connector URL (REQUIRED)
getFileCallback : function(file) { getFileCallback : function(file) {
if (window.opener) { if (!file.name.includes("__0") || file.name.includes("__" + sessionId + "__")) {
if (window.opener.CKEDITOR) { if (window.opener) {
window.opener.CKEDITOR.tools.callFunction(funcNum, file.url); if (window.opener.CKEDITOR) {
} window.opener.CKEDITOR.tools.callFunction(funcNum, file.url);
}
if (window.opener.addImageToQuestion) { if (window.opener.addImageToQuestion) {
window.opener.addImageToQuestion(file.url, {{ question_id }}); window.opener.addImageToQuestion(file.url, {{ question_id }});
}
} }
window.close();
} }
window.close();
}, },
startPathHash: 'l2_Lw', // Sets the course driver as default startPathHash: 'l2_Lw', // Sets the course driver as default
resizable: false, resizable: false,
lang: '{{ elfinder_lang }}' lang: '{{ elfinder_lang }}',
handlers : {
sync : function (event, elfinderInstance) {
let files = elfinderInstance.files();
for (const key in files) {
for (const subkey in files[key]) {
if (subkey === "name") {
if (files[key][subkey].includes("__0") && !files[key][subkey].includes("__" + sessionId + "__")) {
$('#' + files[key].hash).hide();
}
}
}
}
}
}
}).elfinder('instance'); }).elfinder('instance');
}); });
</script> </script>

Loading…
Cancel
Save