Commit c62b5a85cadcd3f2126d9d9082490708784649b7

Authored by unknown
1 parent 8377ce62

KOA-559

"Checkout new document with Document GUID Inserter On does not show guid in Addin"
Added KTAPITrigger class to allow triggers being invoked from KTAPI

Committed by: Martin Kirsten
Reviewed by: Megan Watson
ktapi/KTAPITrigger.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008, 2009 KnowledgeTree Inc.
  8 + *
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + */
  36 +
  37 +/**
  38 + * API for the handling the KnowledgeTree trigger
  39 + *
  40 + * @author KnowledgeTree Team
  41 + * @package KTAPI
  42 + * @version 0.1
  43 + */
  44 +class KTAPI_Trigger
  45 +{
  46 +
  47 + /**
  48 + * This is a reference to the ktapi object.
  49 + *
  50 + * @access protected
  51 + * @var KTAPI
  52 + */
  53 + var $ktapi;
  54 +
  55 + /**
  56 + * Creates a new KTAPI_Trigger, sets up the internal variables.
  57 + *
  58 + * @author KnowledgeTree Team
  59 + * @access public
  60 + * @param KTAPI $ktapi Instance of the KTAPI object
  61 + * @return KTAPI_Trigger
  62 + */
  63 + function KTAPI_Trigger(&$ktapi)
  64 + {
  65 + assert(!is_null($ktapi));
  66 + assert(is_a($ktapi,'KTAPI'));
  67 +
  68 + $this->ktapi=&$ktapi;
  69 + }
  70 +
  71 +
  72 + /**
  73 + * Triggers a new KTAPI_Trigger
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access public
  77 + * @param KTAPIDocument $document Document to trigger on
  78 + * @param string $action Action to trigger
  79 + * @param string $slot Slot the action falls in
  80 + */
  81 + function doTrigger($document, $action, $slot)
  82 + {
  83 + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
  84 + $aTriggers = $oKTTriggerRegistry->getTriggers($action, $slot);
  85 +
  86 + foreach ($aTriggers as $aTrigger) {
  87 + $sTrigger = $aTrigger[0];
  88 + $oTrigger = new $sTrigger;
  89 + $aInfo = array(
  90 + 'document' => $document->document,
  91 + );
  92 + $oTrigger->setInfo($aInfo);
  93 + $ret = $oTrigger->postValidate();
  94 + if (PEAR::isError($ret)) {
  95 + return $ret;
  96 + }
  97 + }
  98 + }
  99 +
  100 +}
  101 +
  102 +?>
0 \ No newline at end of file 103 \ No newline at end of file
ktapi/ktapi.inc.php
@@ -59,6 +59,7 @@ require_once(KTAPI_DIR .&#39;/KTAPIDocument.inc.php&#39;); @@ -59,6 +59,7 @@ require_once(KTAPI_DIR .&#39;/KTAPIDocument.inc.php&#39;);
59 require_once(KTAPI_DIR .'/KTAPIAcl.inc.php'); 59 require_once(KTAPI_DIR .'/KTAPIAcl.inc.php');
60 require_once(KTAPI_DIR .'/KTAPICollection.inc.php'); 60 require_once(KTAPI_DIR .'/KTAPICollection.inc.php');
61 require_once(KTAPI_DIR .'/KTAPIBulkActions.inc.php'); 61 require_once(KTAPI_DIR .'/KTAPIBulkActions.inc.php');
  62 +require_once(KTAPI_DIR .'/KTAPITrigger.inc.php');
62 63
63 /** 64 /**
64 * This class defines functions that MUST exist in the inheriting class 65 * This class defines functions that MUST exist in the inheriting class