diff --git a/CHANGELOG b/CHANGELOG index e1774a229..93cf081a3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/op/op.Ajax.php b/op/op.Ajax.php index f45b57036..5db4814b2 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -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')) { diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index a542d4e23..536f4b9b0 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -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 "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/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index 2f708bcb0..c032d6550 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -777,7 +777,16 @@ $(document).ready( function() { $this->columnEnd(); $this->columnStart(5); print "