Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2025-07-30 08:20:24 +02:00
commit 5d8f63a33c
7 changed files with 111 additions and 1 deletions

View File

@ -349,6 +349,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

View File

@ -691,6 +691,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')) {

View File

@ -2706,6 +2706,22 @@ $(function() {
echo $text;
} /* }}} */
/**
* Wrap text in inline editing tags
*
* @param string text
*/
function printInlineEditOriginalName($text, $object){ /* {{{ */
if(!empty($this->params['settings']->_inlineEditing)) {
echo "<span class=\"editorigname editable\" contenteditable=\"true\"";
if($object->isType('documentcontent'))
echo " data-content=\"".$object->getId()."\" data-formtoken=\"".createFormKey('setoriginalname')."\"";
echo ">".$text;
echo "</span>\n";
} else
echo $text;
} /* }}} */
/**
* Print button with link for deleting a document
*

View File

@ -777,7 +777,16 @@ $(document).ready( function() {
$this->columnEnd();
$this->columnStart(5);
print "<ul class=\"actions unstyled\">\n";
print "<li style=\"overflow-wrap: break-word;\">".htmlspecialchars($latestContent->getOriginalFileName())."</li>\n";
print "<li style=\"overflow-wrap: break-word;\">";
if ($latestContent->getDocument()->getAccessMode($user) >= M_READWRITE) {
$this->printInlineEditOriginalName(htmlspecialchars($latestContent->getOriginalFileName()), $latestContent);
} else {
print htmlspecialchars($latestContent->getOriginalFileName());
}
if(!$latestContent->checkOriginalFileName()) {
echo " <i class=\"fa fa-exclamation-triangle\" title=\"".getMLText('problematic_filename')."\"></i> ";
}
print "</li>\n";
print "<li>".getMLText('version').": ".$latestContent->getVersion()."</li>\n";
if ($file_exists) {

View File

@ -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();

View File

@ -2656,6 +2656,22 @@ $(function() {
echo $text;
} /* }}} */
/**
* Wrap text in inline editing tags
*
* @param string text
*/
function printInlineEditOriginalName($text, $object){ /* {{{ */
if(!empty($this->params['settings']->_inlineEditing)) {
echo "<span class=\"editorigname editable\" contenteditable=\"true\"";
if($object->isType('documentcontent'))
echo " data-content=\"".$object->getId()."\" data-formtoken=\"".createFormKey('setoriginalname')."\"";
echo ">".$text;
echo "</span>\n";
} else
echo $text;
} /* }}} */
/**
* Print button with link for deleting a document
*

View File

@ -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();