Commit 334a26ca15b6da044ec9d27f0ca9e3167275a590
1 parent
92fb6405
Add updateTransactionText, which takes all the comments from all
transactions into a single full-text indexed string in the database for search purposes. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3927 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
22 additions
and
0 deletions
lib/documentmanagement/documentutil.inc.php
| @@ -440,6 +440,28 @@ class KTDocumentUtil { | @@ -440,6 +440,28 @@ class KTDocumentUtil { | ||
| 440 | return true; | 440 | return true; |
| 441 | } | 441 | } |
| 442 | // }}} | 442 | // }}} |
| 443 | + | ||
| 444 | + // {{{ updateTransactionText | ||
| 445 | + function updateTransactionText($oDocument) { | ||
| 446 | + $iDocumentId = KTUtil::getId($oDocument); | ||
| 447 | + $aTransactions = DocumentTransaction::getByDocument($iDocumentId); | ||
| 448 | + foreach ($aTransactions as $oTransaction) { | ||
| 449 | + $aComments[] = $oTransaction->getComment(); | ||
| 450 | + } | ||
| 451 | + $sAllComments = join("\n\n", $aComments); | ||
| 452 | + $sTable = KTUtil::getTableName('document_transaction_text'); | ||
| 453 | + $aQuery = array("DELETE FROM $sTable WHERE document_id = ?", array($iDocumentId)); | ||
| 454 | + $res = DBUtil::runQuery($aQuery); | ||
| 455 | + if (PEAR::isError($res)) { | ||
| 456 | + return $res; | ||
| 457 | + } | ||
| 458 | + $aInsert = array( | ||
| 459 | + "document_id" => $iDocumentId, | ||
| 460 | + "document_text" => $sAllComments, | ||
| 461 | + ); | ||
| 462 | + return DBUtil::autoInsert($sTable, $aInsert, array('noid' => true)); | ||
| 463 | + } | ||
| 464 | + // }}} | ||
| 443 | } | 465 | } |
| 444 | 466 | ||
| 445 | class KTMetadataValidationError extends PEAR_Error { | 467 | class KTMetadataValidationError extends PEAR_Error { |