diff --git a/lib/workflow/workflowtrigger.inc.php b/lib/workflow/workflowtrigger.inc.php new file mode 100644 index 0000000..3cd2d10 --- /dev/null +++ b/lib/workflow/workflowtrigger.inc.php @@ -0,0 +1,98 @@ +_oTriggerState = null; // initialise to initial state + $this->sFriendlyName = _kt('Base class for workflow triggers'); + $this->sDescription = _kt('This is an abstract base class for the overall workflow trigger. It should never actually be available for installation.'); + } + + function loadConfig($oTriggerInstance) { + $this->oTriggerInstance = $oTriggerInstance; + } + + function isLoaded() { return (!is_null($this->oTriggerInstance)); } + + // simple function to inform the UI/registration what kind of event this is + function getCapabilities() { + return array( + 'guard' => $this->bIsGuard, + 'action' => $this->bIsAction, + 'name' => $this->sFriendlyName, + 'description' => $this->sDescription, + ); + } + + // return true for transition allowed on doc, false for transition not allowed on doc. + function allowTransition($oDocument, $oUser) { + return true; // abstract base class + } + + /* + Multiple triggers can occur on a given transition. If this trigger fails, + return a PEAR::error (the overall system -will- roll the db back - + no need to do it yourself) with a -useful- human error message. + + IF YOU SUCCEED, return a $aRollbackInfo array. This will be passed + to $this->rollbackTransition IF NEEDED (e.g. a later trigger failed.) + This is to do your best to roll back any external changes (e.g. emails + sent.) + */ + function performTransition($oDocument, $oUser) { + $rollbackinfo = null; + return $rollbackinfo; + } + + // roll back the transition. $aRollbackInfo was returned by you earlier + // after ->performTransition. + // + // throw a PEAR::error to -inform- users of a critical problem, NOT to + // cause the system to rollback (that's already happened.) + function rollbackTransition($oDocument, $oUser, $aRollbackInfo = null) { + return true; + // return PEAR::raiseError(_kt('A follow-up email has been sent, informing the previous recipient that the step was cancelled.')); + } +} + +?>