From 049bc9da4cf494773fb108e647486a8fbb7f11a3 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 24 Jan 2024 12:00:20 +0100 Subject: [PATCH] allow to set link type of related document --- op/op.AddDocumentLink.php | 11 ++++++++++- views/bootstrap/class.ViewDocument.php | 23 +++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/op/op.AddDocumentLink.php b/op/op.AddDocumentLink.php index 6b6efe7a7..c85177d97 100644 --- a/op/op.AddDocumentLink.php +++ b/op/op.AddDocumentLink.php @@ -68,7 +68,16 @@ if (!is_object($doc)) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_doc_id")); } -if (!$document->addDocumentLink($docid, $user->getID(), $public)){ +if(!empty($_GET['linktype'])) { + $linktype = $dms->getLinkType($_GET['linktype']); + if (!is_object($linktype)) { + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_link_type")); + } +} else { + $linktype = null; +} + +if (!$document->addDocumentLink($docid, $user->getID(), $public, $linktype)){ UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")); } diff --git a/views/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index 3d1c48df6..ce010b704 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -1996,6 +1996,9 @@ $(document).ready( function() { print getMLText("document_link_by")." ".htmlspecialchars($responsibleUser->getFullName()); if (($user->getID() == $responsibleUser->getID()) || ($document->getAccessMode($user) == M_ALL )) { print "
".getMLText("document_link_public").": ".(($link->isPublic()) ? getMLText("yes") : getMLText("no")); + if($linktype = $link->getLinkType()) { + print "
".$linktype->getName(); + } print "
params['settings']->_httpRoot."op/op.RemoveDocumentLink.php\" method=\"post\">".createHiddenFieldWithKey('removedocumentlink')."getID()."\" />
"; } print ""; @@ -2012,8 +2015,24 @@ $(document).ready( function() { contentContainerStart(); ?> - formField(getMLText("add_document_link"), $this->getDocumentChooserHtml("form1")); ?> - formField(getMLText("linked_document"), $this->getDocumentChooserHtml("form1")); ?> +getLinkTypes() as $linktype) { + $options[] = array($linktype->getID(), htmlspecialchars($linktype->getName()), $sellinktype && $linktype->getID()==$sellinktype->getID(), array(/*array('data-subtitle', $linktype->countDocumentLinksByType().' '.getMLText('documents'))*/)); + } + $this->formField( + getMLText("global_link_types"), + array( + 'element'=>'select', + 'id'=>'linktype', + 'name'=>'linktype', + 'class'=>'chzn-select', + 'options'=>$options, + 'placeholder'=>getMLText('choose_link_type'), + 'allow_empty'=>true, + ) + ); if ($document->getAccessMode($user) >= M_READWRITE) { $this->formField( getMLText("document_link_public"),