diff --git a/ktapi/KTAPITrigger.inc.php b/ktapi/KTAPITrigger.inc.php new file mode 100644 index 0000000..6c632c2 --- /dev/null +++ b/ktapi/KTAPITrigger.inc.php @@ -0,0 +1,102 @@ +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + */ + +/** + * API for the handling the KnowledgeTree trigger + * + * @author KnowledgeTree Team + * @package KTAPI + * @version 0.1 + */ +class KTAPI_Trigger +{ + + /** + * This is a reference to the ktapi object. + * + * @access protected + * @var KTAPI + */ + var $ktapi; + + /** + * Creates a new KTAPI_Trigger, sets up the internal variables. + * + * @author KnowledgeTree Team + * @access public + * @param KTAPI $ktapi Instance of the KTAPI object + * @return KTAPI_Trigger + */ + function KTAPI_Trigger(&$ktapi) + { + assert(!is_null($ktapi)); + assert(is_a($ktapi,'KTAPI')); + + $this->ktapi=&$ktapi; + } + + + /** + * Triggers a new KTAPI_Trigger + * + * @author KnowledgeTree Team + * @access public + * @param KTAPIDocument $document Document to trigger on + * @param string $action Action to trigger + * @param string $slot Slot the action falls in + */ + function doTrigger($document, $action, $slot) + { + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); + $aTriggers = $oKTTriggerRegistry->getTriggers($action, $slot); + + foreach ($aTriggers as $aTrigger) { + $sTrigger = $aTrigger[0]; + $oTrigger = new $sTrigger; + $aInfo = array( + 'document' => $document->document, + ); + $oTrigger->setInfo($aInfo); + $ret = $oTrigger->postValidate(); + if (PEAR::isError($ret)) { + return $ret; + } + } + } + +} + +?> \ No newline at end of file diff --git a/ktapi/ktapi.inc.php b/ktapi/ktapi.inc.php index d1a2efc..6619201 100644 --- a/ktapi/ktapi.inc.php +++ b/ktapi/ktapi.inc.php @@ -59,6 +59,7 @@ require_once(KTAPI_DIR .'/KTAPIDocument.inc.php'); require_once(KTAPI_DIR .'/KTAPIAcl.inc.php'); require_once(KTAPI_DIR .'/KTAPICollection.inc.php'); require_once(KTAPI_DIR .'/KTAPIBulkActions.inc.php'); +require_once(KTAPI_DIR .'/KTAPITrigger.inc.php'); /** * This class defines functions that MUST exist in the inheriting class