Commit 61efca60a410b99e8e5e20e7893658763e963ac2

Authored by Neil Blakey-Milner
1 parent f7b48118

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.

In future, they will perform all the usual show/disable checks before
continuing on their business.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3936 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/actions/documentaction.inc.php
@@ -2,8 +2,9 @@ @@ -2,8 +2,9 @@
2 2
3 require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php'); 3 require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php');
4 require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php'); 4 require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php');
  5 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
5 6
6 -class KTDocumentAction { 7 +class KTDocumentAction extends KTStandardDispatcher {
7 var $sName; 8 var $sName;
8 var $sDescription; 9 var $sDescription;
9 var $sDisplayName; 10 var $sDisplayName;
@@ -14,9 +15,18 @@ class KTDocumentAction { @@ -14,9 +15,18 @@ class KTDocumentAction {
14 var $_bDisabled; 15 var $_bDisabled;
15 var $_sDisabledText = null; 16 var $_sDisabledText = null;
16 17
17 - function KTDocumentAction($oDocument, $oUser) {  
18 - $this->oDocument = $oDocument;  
19 - $this->oUser = $oUser; 18 + function KTDocumentAction($oDocument = null, $oUser = null) {
  19 + $this->oDocument =& $oDocument;
  20 + $this->oUser =& $oUser;
  21 + parent::KTStandardDispatcher();
  22 + }
  23 +
  24 + function setDocument(&$oDocument) {
  25 + $this->oDocument =& $oDocument;
  26 + }
  27 +
  28 + function setUser(&$oUser) {
  29 + $this->oUser =& $oUser;
20 } 30 }
21 31
22 function _show() { 32 function _show() {
@@ -53,7 +63,7 @@ class KTDocumentAction { @@ -53,7 +63,7 @@ class KTDocumentAction {
53 } 63 }
54 64
55 function getURL() { 65 function getURL() {
56 - return sprintf("/plugin.php/%s?fDocumentID=%d", $this->sName, $this->oDocument->getID()); 66 + return sprintf("/action.php/%s?fDocumentId=%d", $this->sName, $this->oDocument->getID());
57 } 67 }
58 68
59 function getInfo() { 69 function getInfo() {
@@ -86,6 +96,15 @@ class KTDocumentAction { @@ -86,6 +96,15 @@ class KTDocumentAction {
86 function customiseInfo($aInfo) { 96 function customiseInfo($aInfo) {
87 return $aInfo; 97 return $aInfo;
88 } 98 }
  99 +
  100 + function check() {
  101 + $this->oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
  102 + return true;
  103 + }
  104 +
  105 + function do_main() {
  106 + return "Dispatcher component of action not implemented.";
  107 + }
89 } 108 }
90 109
91 class KTDocumentActionUtil { 110 class KTDocumentActionUtil {