From 61efca60a410b99e8e5e20e7893658763e963ac2 Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Tue, 8 Nov 2005 15:06:35 +0000 Subject: [PATCH] Document actions are now dispatchers - they can be accessed at /action.php/actionname. (Single) document actions expect the document id in fDocumentId, and validate the document exists before continuing. --- lib/actions/documentaction.inc.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/actions/documentaction.inc.php b/lib/actions/documentaction.inc.php index b858642..680404f 100644 --- a/lib/actions/documentaction.inc.php +++ b/lib/actions/documentaction.inc.php @@ -2,8 +2,9 @@ require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php'); require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php'); +require_once(KT_LIB_DIR . '/dispatcher.inc.php'); -class KTDocumentAction { +class KTDocumentAction extends KTStandardDispatcher { var $sName; var $sDescription; var $sDisplayName; @@ -14,9 +15,18 @@ class KTDocumentAction { var $_bDisabled; var $_sDisabledText = null; - function KTDocumentAction($oDocument, $oUser) { - $this->oDocument = $oDocument; - $this->oUser = $oUser; + function KTDocumentAction($oDocument = null, $oUser = null) { + $this->oDocument =& $oDocument; + $this->oUser =& $oUser; + parent::KTStandardDispatcher(); + } + + function setDocument(&$oDocument) { + $this->oDocument =& $oDocument; + } + + function setUser(&$oUser) { + $this->oUser =& $oUser; } function _show() { @@ -53,7 +63,7 @@ class KTDocumentAction { } function getURL() { - return sprintf("/plugin.php/%s?fDocumentID=%d", $this->sName, $this->oDocument->getID()); + return sprintf("/action.php/%s?fDocumentId=%d", $this->sName, $this->oDocument->getID()); } function getInfo() { @@ -86,6 +96,15 @@ class KTDocumentAction { function customiseInfo($aInfo) { return $aInfo; } + + function check() { + $this->oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']); + return true; + } + + function do_main() { + return "Dispatcher component of action not implemented."; + } } class KTDocumentActionUtil { -- libgit2 0.21.4