Commit 43b5fcf88487574fa2cbb84b44ed4a63cb7dd658

Authored by Neil Blakey-Milner
1 parent 4cc2c0a2

When adding a document, the "scan" trigger on the "content" action is

now checked to verify whether this document will be added.  For
example, after doing an anti-virus check and finding a virus in the
document.

When adding a document, the "transform" trigger on the "content" action
is now run to change attributes of the document based on its contents.
For example, automatically adding the title from the contents of the
document as a metadata field.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3917 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/documentutil.inc.php
... ... @@ -362,6 +362,19 @@ class KTDocumentUtil {
362 362 return $oDocument;
363 363 }
364 364  
  365 + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
  366 + $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'scan');
  367 + foreach ($aTriggers as $aTrigger) {
  368 + $sTrigger = $aTrigger[0];
  369 + $oTrigger = new $sTrigger;
  370 + $oTrigger->setDocument($oDocument);
  371 + $ret = $oTrigger->scan();
  372 + if (PEAR::isError($ret)) {
  373 + $oDocument->delete();
  374 + return $ret;
  375 + }
  376 + }
  377 +
365 378 //create the web document link
366 379 $oWebDocument = & new WebDocument($oDocument->getID(), -1, 1, NOT_PUBLISHED, getCurrentDateTime());
367 380 $res = $oWebDocument->create();
... ... @@ -370,6 +383,15 @@ class KTDocumentUtil {
370 383 return $res;
371 384 }
372 385  
  386 + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
  387 + $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform');
  388 + foreach ($aTriggers as $aTrigger) {
  389 + $sTrigger = $aTrigger[0];
  390 + $oTrigger = new $sTrigger;
  391 + $oTrigger->setDocument($oDocument);
  392 + $oTrigger->transform();
  393 + }
  394 +
373 395 $aOptions = array('user' => $oUser);
374 396 //create the document transaction record
375 397 $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), "Document created", CREATE, $aOptions);
... ...