diff --git a/plugins/ktstandard/KTDocumentLinks.php b/plugins/ktstandard/KTDocumentLinks.php index b92f7c6..6486475 100644 --- a/plugins/ktstandard/KTDocumentLinks.php +++ b/plugins/ktstandard/KTDocumentLinks.php @@ -288,6 +288,18 @@ class KTDocumentLinkAction extends KTDocumentAction { // select a type for the link function do_type_select() { + + //Checking to see if the document is being linked to itself and returning an error if it is. + $iTempParentDocId = $_REQUEST['fDocumentId']; + $aTempDocuments = $_REQUEST['linkselection']; + foreach ($aTempDocuments as $iTempDocId) + { + if($iTempParentDocId == $iTempDocId) + { + $this->errorRedirectToMain(_kt('A document cannot be linked to itself.')); + } + } + $this->oPage->setBreadcrumbDetails(_kt("link")); $sType = (isset($_REQUEST['linktype'])) ? $_REQUEST['linktype'] : 'internal';