From 2e38c8fb9252b91fa0c02d32b7b4c5008592192e Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 29 Jul 2025 21:17:04 +0200 Subject: [PATCH 1/5] add command 'setoriginalname' --- op/op.Ajax.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/op/op.Ajax.php b/op/op.Ajax.php index 604b9a8b3..9e85f33c1 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -684,6 +684,44 @@ switch($command) { } break; /* }}} */ + case 'setoriginalname': /* {{{ */ + if($user && $user->isAdmin()) { + if(checkFormKey('setoriginalname')) { + $content = $dms->getDocumentContent($_REQUEST['contentid']); + if($content) { + $document = $content->getDocument(); + if ($document->getAccessMode($user) >= M_READWRITE) { + $oldname = $content->getOriginalFileName(); + if (!$content->setOriginalFilename($_REQUEST['name'])) { + header('Content-Type: application/json'); + echo json_encode(array('success'=>false, 'message'=>'Error setting original file name', 'data'=>'')); + } else { + if($fulltextservice && ($index = $fulltextservice->Indexer())) { + $lucenesearch = $fulltextservice->Search(); + if($hit = $lucenesearch->getDocument($document->getId())) { + $index->reindexDocument($hit->id); + $index->commit(); + } + } + header('Content-Type: application/json'); + echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_changed'), 'data'=>'')); + add_log_line("set original filename '".$_REQUEST['name']."' of document ".$document->getId().":".$content->getVersion()); + } + } else { + header('Content-Type: application/json'); + echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>'')); + } + } else { + header('Content-Type: application/json'); + echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>'')); + } + } else { + header('Content-Type: application/json'); + echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>'')); + } + } + break; /* }}} */ + case 'setmimetype': /* {{{ */ if($user && $user->isAdmin()) { if(checkFormKey('setmimetype', 'GET')) { From f20f4d2ae2b219b5198d9b810148be867bd02aa8 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 29 Jul 2025 21:17:35 +0200 Subject: [PATCH 2/5] add method printInlineEditOriginalName() --- views/bootstrap/class.Bootstrap.php | 16 ++++++++++++++++ views/bootstrap4/class.Bootstrap4.php | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 8d6c4f271..b9e3c70e3 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -2567,6 +2567,22 @@ $(function() { echo $text; } /* }}} */ + /** + * Wrap text in inline editing tags + * + * @param string text + */ + function printInlineEditOriginalName($text, $object){ /* {{{ */ + if(!empty($this->params['settings']->_inlineEditing)) { + echo "isType('documentcontent')) + echo " data-content=\"".$object->getId()."\" data-formtoken=\"".createFormKey('setoriginalname')."\""; + echo ">".$text; + echo "\n"; + } else + echo $text; + } /* }}} */ + /** * Print button with link for deleting a document * diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php index 3d253d11d..5f36bbd09 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -2593,6 +2593,22 @@ $(function() { echo $text; } /* }}} */ + /** + * Wrap text in inline editing tags + * + * @param string text + */ + function printInlineEditOriginalName($text, $object){ /* {{{ */ + if(!empty($this->params['settings']->_inlineEditing)) { + echo "isType('documentcontent')) + echo " data-content=\"".$object->getId()."\" data-formtoken=\"".createFormKey('setoriginalname')."\""; + echo ">".$text; + echo "\n"; + } else + echo $text; + } /* }}} */ + /** * Print button with link for deleting a document * From 5dfd280ec529321a6bdf900232084090b92faa21 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 29 Jul 2025 21:18:33 +0200 Subject: [PATCH 3/5] add code for setting original filename --- views/bootstrap/styles/application.js | 15 +++++++++++++++ views/bootstrap4/styles/application.js | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/views/bootstrap/styles/application.js b/views/bootstrap/styles/application.js index cc8b8508c..f21d8fb5f 100644 --- a/views/bootstrap/styles/application.js +++ b/views/bootstrap/styles/application.js @@ -736,6 +736,21 @@ $(document).ready( function() { }); }); /* }}} */ + $("body").on("blur", "span.editorigname", function(e) { /* {{{ */ + e.preventDefault(); + $.post(seeddms_webroot+"op/op.Ajax.php", { command: "setoriginalname", contentid: $(this).data('content'), formtoken: $(this).data('formtoken'), name: $(this).text() }) + .done(function( data ) { + noty({ + text: data.message, + type: data.success ? 'success' : 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500 + }); + }); + }); /* }}} */ + $("body").on("keypress", "span.editable", function(e) { /* {{{ */ if(e.which == 13) { $(this).blur(); diff --git a/views/bootstrap4/styles/application.js b/views/bootstrap4/styles/application.js index d39b0ac65..25b47f341 100644 --- a/views/bootstrap4/styles/application.js +++ b/views/bootstrap4/styles/application.js @@ -784,6 +784,21 @@ $(document).ready( function() { }); }); /* }}} */ + $("body").on("blur", "span.editorigname", function(e) { /* {{{ */ + e.preventDefault(); + $.post(seeddms_webroot+"op/op.Ajax.php", { command: "setoriginalname", contentid: $(this).data('content'), formtoken: $(this).data('formtoken'), name: $(this).text() }) + .done(function( data ) { + noty({ + text: data.message, + type: data.success ? 'success' : 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500 + }); + }); + }); /* }}} */ + $("body").on("keypress", "span.editable", function(e) { /* {{{ */ if(e.which == 13) { $(this).blur(); From 46594fa3bceb36f20acaf30ec0d9080ea86c4fab Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 29 Jul 2025 21:21:05 +0200 Subject: [PATCH 4/5] allow to edit original filename --- views/bootstrap/class.ViewDocument.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/views/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index 9663580ad..e15530bfa 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -747,7 +747,16 @@ $(document).ready( function() { $this->columnEnd(); $this->columnStart(5); print "
    \n"; - print "
  • ".htmlspecialchars($latestContent->getOriginalFileName())."
  • \n"; + print "
  • "; + if ($latestContent->getDocument()->getAccessMode($user) >= M_READWRITE) { + $this->printInlineEditOriginalName(htmlspecialchars($latestContent->getOriginalFileName()), $latestContent); + } else { + print htmlspecialchars($latestContent->getOriginalFileName()); + } + if(!$latestContent->checkOriginalFileName()) { + echo " "; + } + print "
  • \n"; print "
  • ".getMLText('version').": ".$latestContent->getVersion()."
  • \n"; if ($file_exists) { From d47b8f8adf0b8ea5bf70c649eaa9ca86994ebfae Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 29 Jul 2025 21:21:44 +0200 Subject: [PATCH 5/5] add changes for 5.1.41 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index a61862b0e..24bcc52f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ already (in menu task list and document list) - break long original file names on viewDocument page - fix potential XSS attack in many fields of settings +- allow to edit original filename -------------------------------------------------------------------------------- Changes in version 5.1.40