Commit 95d04e68348627e3764b0a75a2b06f1a29fa4470
1 parent
a717d985
Add static function to check if a document already exists
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@351 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
46 additions
and
0 deletions
lib/documentmanagement/Document.inc
| ... | ... | @@ -326,6 +326,52 @@ class Document { |
| 326 | 326 | |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | + /** | |
| 330 | + * Get a document's transaction history | |
| 331 | + * | |
| 332 | + * @return Array array of DocumentTransaction objects | |
| 333 | + * | |
| 334 | + */ | |
| 335 | + function getDocumentHistory() { | |
| 336 | + global $default, $lang_err_database; | |
| 337 | + $aDocumentHistory; | |
| 338 | + settype($aDocumentHistory, "array"); | |
| 339 | + $sql = new Owl_DB(); | |
| 340 | + $result = $sql->query("SELECT * FROM " . $default->owl_document_transactions_table . " WHERE document_id = $this->iId ORDER BY datetime ASC"); | |
| 341 | + if ($result) { | |
| 342 | + $iCount = 0; | |
| 343 | + while($sql->next_record()) { | |
| 344 | + $oDocumentTransaction = DocumentTransaction::get($sql->f("id")); | |
| 345 | + $aDocumentHistory[$iCount] = $oDocumentTransaction; | |
| 346 | + $iCount++; | |
| 347 | + } | |
| 348 | + return $history; | |
| 349 | + } | |
| 350 | + $_SESSION["errorMessage"] = $lang_err_database; | |
| 351 | + return false; | |
| 352 | + | |
| 353 | + } | |
| 354 | + | |
| 355 | + /** | |
| 356 | + * Static function. | |
| 357 | + * Check if a document already exists | |
| 358 | + * | |
| 359 | + * @param $sName Name of document | |
| 360 | + * @param $sFolderID Primary key of folder to which document is assigned | |
| 361 | + * | |
| 362 | + * @return boolean true if document exists, false otherwise and set $_SESSION["errorMessage"] | |
| 363 | + */ | |
| 364 | + function documentExists($sName, $iFolderID) { | |
| 365 | + global $default, $lang_err_doc_not_exist; | |
| 366 | + $sql = new Owl_DB(); | |
| 367 | + $sql->query("SELECT * FROM " . $default->owl_documents_table . " WHERE name = '" . $sName "' AND folder_id = " . $iFolderID); | |
| 368 | + if ($sql->next_record()) { | |
| 369 | + return true; | |
| 370 | + } | |
| 371 | + $_SESSION["errorMessage"] = $lang_err_doc_not_exist . "name = " . $sName . " folder_id = " . $iFolderID; | |
| 372 | + return false; | |
| 373 | + } | |
| 374 | + | |
| 329 | 375 | } |
| 330 | 376 | |
| 331 | 377 | ?> | ... | ... |