Commit 21b83452e01a85ba168522910ca2a6ac838e82bd
Merge branch 'master' of git@github.com:ktgit/knowledgetree
Showing
1 changed file
with
18 additions
and
7 deletions
plugins/ktstandard/KTDocumentLinks.php
| ... | ... | @@ -482,19 +482,30 @@ class KTDocumentLinkAction extends KTDocumentAction { |
| 482 | 482 | |
| 483 | 483 | // do deletion |
| 484 | 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 | 495 | $this->commitTransaction(); |
| 494 | 496 | |
| 495 | 497 | $this->successRedirectToMain(_kt('Document link deleted'), sprintf('fDocumentId=%d', $oParentDocument->getId())); |
| 496 | 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 | 511 | class KTDocLinkAdminDispatcher extends KTAdminDispatcher { | ... | ... |