Commit 21b83452e01a85ba168522910ca2a6ac838e82bd

Authored by Megan Watson
2 parents f5881012 339c6455

Merge branch 'master' of git@github.com:ktgit/knowledgetree

plugins/ktstandard/KTDocumentLinks.php
@@ -482,19 +482,30 @@ class KTDocumentLinkAction extends KTDocumentAction { @@ -482,19 +482,30 @@ class KTDocumentLinkAction extends KTDocumentAction {
482 482
483 // do deletion 483 // do deletion
484 $this->startTransaction(); 484 $this->startTransaction();
485 -  
486 - $res = $oDocumentLink->delete();  
487 -  
488 - if (PEAR::isError($res)) {  
489 - $this->errorRedirectToMain(_kt('Could not delete document link'), sprintf('fDocumentId=%d', $oParentDocument->getId()));  
490 - exit(0); 485 + // Cannot call delete directly if no link exists.
  486 + if($oDocumentLink) {
  487 + $res = $oDocumentLink->delete();
  488 + if (PEAR::isError($res)) {
  489 + $this->errorRedirectToMain(_kt('Could not delete document link'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
  490 + exit(0);
  491 + }
  492 + } else {
  493 + $this->successRedirectToMain(_kt('Document link not deleted. Document link does not exists, or previously deleted.'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
491 } 494 }
492 -  
493 $this->commitTransaction(); 495 $this->commitTransaction();
494 496
495 $this->successRedirectToMain(_kt('Document link deleted'), sprintf('fDocumentId=%d', $oParentDocument->getId())); 497 $this->successRedirectToMain(_kt('Document link deleted'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
496 exit(0); 498 exit(0);
497 } 499 }
  500 +
  501 + function check() {
  502 + $res = parent::check();
  503 + if ($res !== true) {
  504 + return $res;
  505 + }
  506 +
  507 + return true;
  508 + }
498 } 509 }
499 510
500 class KTDocLinkAdminDispatcher extends KTAdminDispatcher { 511 class KTDocLinkAdminDispatcher extends KTAdminDispatcher {