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. 20
      main/template/default/javascript/editor/elfinder_standalone.tpl

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

@ -19,9 +19,11 @@
$().ready(function() {
var funcNum = getUrlParam('CKEditorFuncNum');
var sessionId = {{session_id}};
var elf = $('#elfinder').elfinder({
url : '{{ _p.web_lib ~ 'elfinder/connectorAction.php?' }}{{ course_condition }}', // connector URL (REQUIRED)
getFileCallback : function(file) {
if (!file.name.includes("__0") || file.name.includes("__" + sessionId + "__")) {
if (window.opener) {
if (window.opener.CKEDITOR) {
window.opener.CKEDITOR.tools.callFunction(funcNum, file.url);
@ -31,12 +33,26 @@
window.opener.addImageToQuestion(file.url, {{ question_id }});
}
}
window.close();
}
},
startPathHash: 'l2_Lw', // Sets the course driver as default
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');
});
</script>

Loading…
Cancel
Save