Commit 49fb7fb60f305a18be96022a345814d6c82e3a21
1 parent
f697dac5
Fixed merge errors that brought unneeded 3.5.x stuff in.
Committed By: Kevin Fourie Reviewed By: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.4.5-Release-Branch@7767 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
43 additions
and
311 deletions
lib/documentmanagement/documentutil.inc.php
| @@ -106,7 +106,7 @@ class KTDocumentUtil { | @@ -106,7 +106,7 @@ class KTDocumentUtil { | ||
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | // create the document transaction record | 108 | // create the document transaction record |
| 109 | - $oDocumentTransaction = new DocumentTransaction($oDocument, $sCheckInComment, 'ktcore.transactions.check_in'); | 109 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, $sCheckInComment, 'ktcore.transactions.check_in'); |
| 110 | $oDocumentTransaction->create(); | 110 | $oDocumentTransaction->create(); |
| 111 | 111 | ||
| 112 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | 112 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); |
| @@ -122,11 +122,6 @@ class KTDocumentUtil { | @@ -122,11 +122,6 @@ class KTDocumentUtil { | ||
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | - // NEW SEARCH | ||
| 126 | - | ||
| 127 | - Indexer::index($oDocument); | ||
| 128 | - | ||
| 129 | - /* | ||
| 130 | $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); | 125 | $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); |
| 131 | foreach ($aTriggers as $aTrigger) { | 126 | foreach ($aTriggers as $aTrigger) { |
| 132 | $sTrigger = $aTrigger[0]; | 127 | $sTrigger = $aTrigger[0]; |
| @@ -137,7 +132,6 @@ class KTDocumentUtil { | @@ -137,7 +132,6 @@ class KTDocumentUtil { | ||
| 137 | $oTrigger->setDocument($oDocument); | 132 | $oTrigger->setDocument($oDocument); |
| 138 | $oTrigger->transform(); | 133 | $oTrigger->transform(); |
| 139 | } | 134 | } |
| 140 | - */ | ||
| 141 | 135 | ||
| 142 | // fire subscription alerts for the checked in document | 136 | // fire subscription alerts for the checked in document |
| 143 | $oSubscriptionEvent = new SubscriptionEvent(); | 137 | $oSubscriptionEvent = new SubscriptionEvent(); |
| @@ -175,10 +169,10 @@ class KTDocumentUtil { | @@ -175,10 +169,10 @@ class KTDocumentUtil { | ||
| 175 | } | 169 | } |
| 176 | } | 170 | } |
| 177 | 171 | ||
| 178 | - $oDocumentTransaction = new DocumentTransaction($oDocument, $sCheckoutComment, 'ktcore.transactions.check_out'); | 172 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, $sCheckoutComment, 'ktcore.transactions.check_out'); |
| 179 | $oDocumentTransaction->create(); | 173 | $oDocumentTransaction->create(); |
| 180 | 174 | ||
| 181 | - // fire subscription alerts for the downloaded document | 175 | + // fire subscription alerts for the checked in document |
| 182 | $oSubscriptionEvent = new SubscriptionEvent(); | 176 | $oSubscriptionEvent = new SubscriptionEvent(); |
| 183 | $oFolder = Folder::get($oDocument->getFolderID()); | 177 | $oFolder = Folder::get($oDocument->getFolderID()); |
| 184 | $oSubscriptionEvent->CheckOutDocument($oDocument, $oFolder); | 178 | $oSubscriptionEvent->CheckOutDocument($oDocument, $oFolder); |
| @@ -186,45 +180,6 @@ class KTDocumentUtil { | @@ -186,45 +180,6 @@ class KTDocumentUtil { | ||
| 186 | return true; | 180 | return true; |
| 187 | } | 181 | } |
| 188 | 182 | ||
| 189 | - function archive($oDocument, $sReason) { | ||
| 190 | - | ||
| 191 | - $this->startTransaction(); | ||
| 192 | - $oDocument->setStatusID(ARCHIVED); | ||
| 193 | - $res = $oDocument->update(); | ||
| 194 | - | ||
| 195 | - if (PEAR::isError($res) || ($res === false)) { | ||
| 196 | - return PEAR::raiseError(_kt('There was a database error while trying to archive this file')); | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt('Document archived: %s'), $sReason), 'ktcore.transactions.update'); | ||
| 200 | - $oDocumentTransaction->create(); | ||
| 201 | - | ||
| 202 | - $this->commitTransaction(); | ||
| 203 | - | ||
| 204 | - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | ||
| 205 | - $aTriggers = $oKTTriggerRegistry->getTriggers('archive', 'postValidate'); | ||
| 206 | - foreach ($aTriggers as $aTrigger) { | ||
| 207 | - $sTrigger = $aTrigger[0]; | ||
| 208 | - $oTrigger = new $sTrigger; | ||
| 209 | - $aInfo = array( | ||
| 210 | - 'document' => $oDocument, | ||
| 211 | - ); | ||
| 212 | - $oTrigger->setInfo($aInfo); | ||
| 213 | - $ret = $oTrigger->postValidate(); | ||
| 214 | - if (PEAR::isError($ret)) { | ||
| 215 | - $oDocument->delete(); | ||
| 216 | - return $ret; | ||
| 217 | - } | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - // fire subscription alerts for the archived document | ||
| 221 | - $oSubscriptionEvent = new SubscriptionEvent(); | ||
| 222 | - $oFolder = Folder::get($oDocument->getFolderID()); | ||
| 223 | - $oSubscriptionEvent->ArchivedDocument($oDocument, $oFolder); | ||
| 224 | - | ||
| 225 | - return true; | ||
| 226 | - } | ||
| 227 | - | ||
| 228 | function &_add($oFolder, $sFilename, $oUser, $aOptions) { | 183 | function &_add($oFolder, $sFilename, $oUser, $aOptions) { |
| 229 | global $default; | 184 | global $default; |
| 230 | 185 | ||
| @@ -249,6 +204,9 @@ class KTDocumentUtil { | @@ -249,6 +204,9 @@ class KTDocumentUtil { | ||
| 249 | 'creatorid' => $oUser->getID(), | 204 | 'creatorid' => $oUser->getID(), |
| 250 | 'documenttypeid' => $iDocumentTypeId, | 205 | 'documenttypeid' => $iDocumentTypeId, |
| 251 | )); | 206 | )); |
| 207 | + if (PEAR::isError($oDocument)) { | ||
| 208 | + return $oDocument; | ||
| 209 | + } | ||
| 252 | 210 | ||
| 253 | // if (is_null($oContents)) { | 211 | // if (is_null($oContents)) { |
| 254 | // $res = KTDocumentUtil::setIncomplete($oDocument, 'contents'); | 212 | // $res = KTDocumentUtil::setIncomplete($oDocument, 'contents'); |
| @@ -286,81 +244,6 @@ class KTDocumentUtil { | @@ -286,81 +244,6 @@ class KTDocumentUtil { | ||
| 286 | return $oDocument; | 244 | return $oDocument; |
| 287 | } | 245 | } |
| 288 | 246 | ||
| 289 | - // Overwrite the document | ||
| 290 | - function overwrite($oDocument, $sFilename, $sTempFileName, $oUser, $aOptions) { | ||
| 291 | - //$oDocument, $sFilename, $sCheckInComment, $oUser, $aOptions = false | ||
| 292 | - $oStorage =& KTStorageManagerUtil::getSingleton(); | ||
| 293 | - $iFileSize = filesize($sTempFileName); | ||
| 294 | - | ||
| 295 | - // Check that document is not checked out | ||
| 296 | - if($oDocument->getIsCheckedOut()) { | ||
| 297 | - return PEAR::raiseError(_kt('Document is checkout and cannot be overwritten')); | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - if (!$oStorage->upload($oDocument, $sTempFileName)) { | ||
| 301 | - return PEAR::raiseError(_kt('An error occurred while storing the new file')); | ||
| 302 | - } | ||
| 303 | - | ||
| 304 | - $oDocument->setLastModifiedDate(getCurrentDateTime()); | ||
| 305 | - $oDocument->setModifiedUserId($oUser->getId()); | ||
| 306 | - | ||
| 307 | - $oDocument->setFileSize($iFileSize); | ||
| 308 | - | ||
| 309 | - $sOriginalFilename = $oDocument->getFileName(); | ||
| 310 | - | ||
| 311 | - if($sOriginalFilename != $sFilename){ | ||
| 312 | - if(strlen($sFilename)) { | ||
| 313 | - global $default; | ||
| 314 | - $oDocument->setFileName($sFilename); | ||
| 315 | - $default->log->info('renamed document ' . $oDocument->getId() . ' to ' . $sFilename); | ||
| 316 | - } | ||
| 317 | - $oDocument->setMinorVersionNumber($oDocument->getMinorVersionNumber()+1); | ||
| 318 | - } | ||
| 319 | - | ||
| 320 | - $sType = KTMime::getMimeTypeFromFile($sFilename); | ||
| 321 | - $iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName()); | ||
| 322 | - $oDocument->setMimeTypeId($iMimeTypeId); | ||
| 323 | - | ||
| 324 | - $bSuccess = $oDocument->update(); | ||
| 325 | - if ($bSuccess !== true) { | ||
| 326 | - if (PEAR::isError($bSuccess)) { | ||
| 327 | - return $bSuccess; | ||
| 328 | - } | ||
| 329 | - return PEAR::raiseError(_kt('An error occurred while storing this document in the database')); | ||
| 330 | - } | ||
| 331 | -/* | ||
| 332 | - // create the document transaction record | ||
| 333 | - $oDocumentTransaction = new DocumentTransaction($oDocument, $sCheckInComment, 'ktcore.transactions.check_in'); | ||
| 334 | - $oDocumentTransaction->create(); | ||
| 335 | - | ||
| 336 | - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | ||
| 337 | - $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'scan'); | ||
| 338 | - foreach ($aTriggers as $aTrigger) { | ||
| 339 | - $sTrigger = $aTrigger[0]; | ||
| 340 | - $oTrigger = new $sTrigger; | ||
| 341 | - $oTrigger->setDocument($oDocument); | ||
| 342 | - $ret = $oTrigger->scan(); | ||
| 343 | - if (PEAR::isError($ret)) { | ||
| 344 | - $oDocument->delete(); | ||
| 345 | - return $ret; | ||
| 346 | - } | ||
| 347 | - } | ||
| 348 | - | ||
| 349 | - // NEW SEARCH | ||
| 350 | - | ||
| 351 | - Indexer::index($oDocument); | ||
| 352 | - | ||
| 353 | - | ||
| 354 | - // fire subscription alerts for the checked in document | ||
| 355 | - $oSubscriptionEvent = new SubscriptionEvent(); | ||
| 356 | - $oFolder = Folder::get($oDocument->getFolderID()); | ||
| 357 | - $oSubscriptionEvent->CheckinDocument($oDocument, $oFolder); | ||
| 358 | - | ||
| 359 | - KTDocumentUtil::updateSearchableText($oDocument); | ||
| 360 | -*/ | ||
| 361 | - return true; | ||
| 362 | - } | ||
| 363 | - | ||
| 364 | // {{{ validateMetadata | 247 | // {{{ validateMetadata |
| 365 | function validateMetadata(&$oDocument, $aMetadata) { | 248 | function validateMetadata(&$oDocument, $aMetadata) { |
| 366 | $aFieldsets =& KTFieldset::getGenericFieldsets(); | 249 | $aFieldsets =& KTFieldset::getGenericFieldsets(); |
| @@ -542,15 +425,34 @@ class KTDocumentUtil { | @@ -542,15 +425,34 @@ class KTDocumentUtil { | ||
| 542 | // {{{ _in_add | 425 | // {{{ _in_add |
| 543 | function &_in_add($oFolder, $sFilename, $oUser, $aOptions) { | 426 | function &_in_add($oFolder, $sFilename, $oUser, $aOptions) { |
| 544 | $aOrigOptions = $aOptions; | 427 | $aOrigOptions = $aOptions; |
| 545 | - while(KTDocumentUtil::fileExists($oFolder, $sFilename)) { | ||
| 546 | - $oDoc = Document::getByFilenameAndFolder($sFilename, $oFolder->getId()); | ||
| 547 | - $sFilename = KTDocumentUtil::generateNewDocumentFilename($oDoc->getFileName()); | 428 | + if (KTDocumentUtil::fileExists($oFolder, $sFilename)) { |
| 429 | + $oDoc = Document::getByFilenameAndFolder($sFilename, $oFolder->getId()); | ||
| 430 | + if (PEAR::isError($oDoc)) { | ||
| 431 | + return PEAR::raiseError(_kt('Document with that filename already exists in this folder, and appears to be invalid. Please contact the system administrator.')); | ||
| 432 | + } else { | ||
| 433 | + if ($oDoc->getStatusID() != LIVE) { | ||
| 434 | + $sError = _kt('Document with that filename already exists in this folder, but it has been archived or deleted and is still available for restoration. To prevent it being overwritten, you are not allowed to add a document with the same title or filename.'); | ||
| 435 | + } else { | ||
| 436 | + $sError = _kt('Document with that filename already exists in this folder.'); | ||
| 437 | + } | ||
| 438 | + | ||
| 439 | + $sError .= _kt(' Document') . ': ' . $oDoc->getName() . ' (ID:' . $oDoc->getId() . ')'; | ||
| 440 | + return PEAR::raiseError($sError); | ||
| 441 | + } | ||
| 548 | } | 442 | } |
| 549 | $sName = KTUtil::arrayGet($aOptions, 'description', $sFilename); | 443 | $sName = KTUtil::arrayGet($aOptions, 'description', $sFilename); |
| 550 | - while(KTDocumentUtil::nameExists($oFolder, $sName)) { | ||
| 551 | - $oDoc = Document::getByNameAndFolder($sName, $oFolder->getId()); | ||
| 552 | - $aOptions['description'] = KTDocumentUtil::generateNewDocumentName($oDoc->getName()); | ||
| 553 | - $sName = KTDocumentUtil::generateNewDocumentName($oDoc->getName()); | 444 | + if (KTDocumentUtil::nameExists($oFolder, $sName)) { |
| 445 | + $oDoc = Document::getByNameAndFolder($sName, $oFolder->getId()); | ||
| 446 | + if (PEAR::isError($oDoc)) { | ||
| 447 | + return PEAR::raiseError(_kt('Document with that title already exists in this folder, and appears to be invalid. Please contact the system administrator.')); | ||
| 448 | + } else { | ||
| 449 | + if ($oDoc->getStatusID != LIVE) { | ||
| 450 | + return PEAR::raiseError(_kt('Document with that title already exists in this folder, but it has been archived or deleted and is still available for restoration. To prevent it being overwritten, you are not allowed to add a document with the same title or filename.')); | ||
| 451 | + } else { | ||
| 452 | + return PEAR::raiseError(_kt('Document with that title already exists in this folder.')); | ||
| 453 | + } | ||
| 454 | + } | ||
| 455 | + | ||
| 554 | } | 456 | } |
| 555 | 457 | ||
| 556 | $oUploadChannel =& KTUploadChannel::getSingleton(); | 458 | $oUploadChannel =& KTUploadChannel::getSingleton(); |
| @@ -577,10 +479,6 @@ class KTDocumentUtil { | @@ -577,10 +479,6 @@ class KTDocumentUtil { | ||
| 577 | } | 479 | } |
| 578 | } | 480 | } |
| 579 | 481 | ||
| 580 | - // NEW SEARCH | ||
| 581 | - | ||
| 582 | - Indexer::index($oDocument); | ||
| 583 | - /* | ||
| 584 | $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Transforming file'))); | 482 | $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Transforming file'))); |
| 585 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | 483 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); |
| 586 | $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); | 484 | $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); |
| @@ -593,12 +491,12 @@ class KTDocumentUtil { | @@ -593,12 +491,12 @@ class KTDocumentUtil { | ||
| 593 | $oTrigger->setDocument($oDocument); | 491 | $oTrigger->setDocument($oDocument); |
| 594 | // $oUploadChannel->sendMessage(new KTUploadGenericMessage(sprintf(_kt(" (trigger %s)"), $sTrigger))); | 492 | // $oUploadChannel->sendMessage(new KTUploadGenericMessage(sprintf(_kt(" (trigger %s)"), $sTrigger))); |
| 595 | $oTrigger->transform(); | 493 | $oTrigger->transform(); |
| 596 | - }*/ | 494 | + } |
| 597 | 495 | ||
| 598 | // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating transaction'))); | 496 | // $oUploadChannel->sendMessage(new KTUploadGenericMessage(_kt('Creating transaction'))); |
| 599 | $aOptions = array('user' => $oUser); | 497 | $aOptions = array('user' => $oUser); |
| 600 | //create the document transaction record | 498 | //create the document transaction record |
| 601 | - $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document created'), 'ktcore.transactions.create', $aOptions); | 499 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document created'), 'ktcore.transactions.create', $aOptions); |
| 602 | $res = $oDocumentTransaction->create(); | 500 | $res = $oDocumentTransaction->create(); |
| 603 | if (PEAR::isError($res)) { | 501 | if (PEAR::isError($res)) { |
| 604 | $oDocument->delete(); | 502 | $oDocument->delete(); |
| @@ -633,45 +531,6 @@ class KTDocumentUtil { | @@ -633,45 +531,6 @@ class KTDocumentUtil { | ||
| 633 | } | 531 | } |
| 634 | // }}} | 532 | // }}} |
| 635 | 533 | ||
| 636 | - function generateNewDocumentFilename($sDocFilename){ | ||
| 637 | - if(preg_match("/\([0-9]+\)(\.[^\.]+){1,}$/", $sDocFilename)){ | ||
| 638 | - preg_match("/\([0-9]+\)\./", $sDocFilename, $matches); | ||
| 639 | - $new_one = substr($matches[0], 1); | ||
| 640 | - $new_two = explode(')', $new_one); | ||
| 641 | - $new = $new_two[0]+1; | ||
| 642 | - | ||
| 643 | - $pattern[0] = '/\([0-9]+\)\./'; | ||
| 644 | - $replacement[0] = ' ('.$new.').'; | ||
| 645 | - $sFilename = preg_replace($pattern, $replacement, $sDocFilename); | ||
| 646 | - }else{ | ||
| 647 | - $matches = explode('.', $sDocFilename); | ||
| 648 | - $prefix = $matches[0].' (2)'; | ||
| 649 | - for($i = 1; $i < count($matches); $i++ ){ | ||
| 650 | - $suffix .= '.'.$matches[$i]; | ||
| 651 | - } | ||
| 652 | - $sFilename = $prefix.$suffix; | ||
| 653 | - } | ||
| 654 | - | ||
| 655 | - return $sFilename; | ||
| 656 | - } | ||
| 657 | - | ||
| 658 | - function generateNewDocumentName($sDocName){ | ||
| 659 | - if(preg_match("/\([0-9]+\)$/", $sDocName)){ | ||
| 660 | - preg_match("/\([0-9]+\)$/", $sDocName, $matches); | ||
| 661 | - $new_one = substr($matches[0], 1); | ||
| 662 | - $new_two = explode(')', $new_one); | ||
| 663 | - $new = $new_two[0]+1; | ||
| 664 | - | ||
| 665 | - $pattern[0] = '/\([0-9]+\)$/'; | ||
| 666 | - $replacement[0] = '('.$new.')'; | ||
| 667 | - $sName = preg_replace($pattern, $replacement, $sDocName); | ||
| 668 | - }else{ | ||
| 669 | - $sName = $sDocName.' (2)'; | ||
| 670 | - } | ||
| 671 | - | ||
| 672 | - return $sName; | ||
| 673 | - } | ||
| 674 | - | ||
| 675 | // {{{ fileExists | 534 | // {{{ fileExists |
| 676 | function fileExists($oFolder, $sFilename) { | 535 | function fileExists($oFolder, $sFilename) { |
| 677 | return Document::fileExists($sFilename, $oFolder->getID()); | 536 | return Document::fileExists($sFilename, $oFolder->getID()); |
| @@ -731,11 +590,6 @@ class KTDocumentUtil { | @@ -731,11 +590,6 @@ class KTDocumentUtil { | ||
| 731 | 590 | ||
| 732 | // {{{ updateTransactionText | 591 | // {{{ updateTransactionText |
| 733 | function updateTransactionText($oDocument) { | 592 | function updateTransactionText($oDocument) { |
| 734 | - | ||
| 735 | - // NEW SEARCH | ||
| 736 | - | ||
| 737 | - return; | ||
| 738 | - | ||
| 739 | $iDocumentId = KTUtil::getId($oDocument); | 593 | $iDocumentId = KTUtil::getId($oDocument); |
| 740 | $aTransactions = DocumentTransaction::getByDocument($iDocumentId); | 594 | $aTransactions = DocumentTransaction::getByDocument($iDocumentId); |
| 741 | foreach ($aTransactions as $oTransaction) { | 595 | foreach ($aTransactions as $oTransaction) { |
| @@ -758,10 +612,6 @@ class KTDocumentUtil { | @@ -758,10 +612,6 @@ class KTDocumentUtil { | ||
| 758 | 612 | ||
| 759 | // {{{ updateSearchableText | 613 | // {{{ updateSearchableText |
| 760 | function updateSearchableText($oDocument, $bOverride = false) { | 614 | function updateSearchableText($oDocument, $bOverride = false) { |
| 761 | - | ||
| 762 | - // NEW SEARCH | ||
| 763 | - return; | ||
| 764 | - | ||
| 765 | if (isset($GLOBALS['_IN_ADD']) && empty($bOverride)) { | 615 | if (isset($GLOBALS['_IN_ADD']) && empty($bOverride)) { |
| 766 | return; | 616 | return; |
| 767 | } | 617 | } |
| @@ -866,7 +716,7 @@ class KTDocumentUtil { | @@ -866,7 +716,7 @@ class KTDocumentUtil { | ||
| 866 | return PEAR::raiseError(_kt('There was a problem deleting the document from storage.')); | 716 | return PEAR::raiseError(_kt('There was a problem deleting the document from storage.')); |
| 867 | } | 717 | } |
| 868 | 718 | ||
| 869 | - $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document deleted: ') . $sReason, 'ktcore.transactions.delete'); | 719 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document deleted: ') . $sReason, 'ktcore.transactions.delete'); |
| 870 | $oDocumentTransaction->create(); | 720 | $oDocumentTransaction->create(); |
| 871 | 721 | ||
| 872 | $oDocument->setFolderID(1); | 722 | $oDocument->setFolderID(1); |
| @@ -902,14 +752,6 @@ class KTDocumentUtil { | @@ -902,14 +752,6 @@ class KTDocumentUtil { | ||
| 902 | // }}} | 752 | // }}} |
| 903 | 753 | ||
| 904 | function reindexDocument($oDocument) { | 754 | function reindexDocument($oDocument) { |
| 905 | - | ||
| 906 | - // NEW SEARCH | ||
| 907 | - | ||
| 908 | - Indexer::index($oDocument); | ||
| 909 | - | ||
| 910 | - return; | ||
| 911 | - | ||
| 912 | - /* | ||
| 913 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | 755 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); |
| 914 | $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); | 756 | $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform'); |
| 915 | foreach ($aTriggers as $aTrigger) { | 757 | foreach ($aTriggers as $aTrigger) { |
| @@ -921,7 +763,7 @@ class KTDocumentUtil { | @@ -921,7 +763,7 @@ class KTDocumentUtil { | ||
| 921 | $oTrigger->setDocument($oDocument); | 763 | $oTrigger->setDocument($oDocument); |
| 922 | $oTrigger->transform(); | 764 | $oTrigger->transform(); |
| 923 | } | 765 | } |
| 924 | - KTDocumentUtil::updateSearchableText($oDocument);*/ | 766 | + KTDocumentUtil::updateSearchableText($oDocument); |
| 925 | } | 767 | } |
| 926 | 768 | ||
| 927 | 769 | ||
| @@ -936,7 +778,7 @@ class KTDocumentUtil { | @@ -936,7 +778,7 @@ class KTDocumentUtil { | ||
| 936 | } | 778 | } |
| 937 | 779 | ||
| 938 | 780 | ||
| 939 | - function copy($oDocument, $oDestinationFolder, $sReason = null, $sDestinationDocName = null) { | 781 | + function copy($oDocument, $oDestinationFolder, $sReason = null) { |
| 940 | // 1. generate a new triad of content, metadata and core objects. | 782 | // 1. generate a new triad of content, metadata and core objects. |
| 941 | // 2. update the storage path. | 783 | // 2. update the storage path. |
| 942 | //print '--------------------------------- BEFORE'; | 784 | //print '--------------------------------- BEFORE'; |
| @@ -955,36 +797,23 @@ class KTDocumentUtil { | @@ -955,36 +797,23 @@ class KTDocumentUtil { | ||
| 955 | // we still have a bogus md_version, but integrity holds, so fix it now. | 797 | // we still have a bogus md_version, but integrity holds, so fix it now. |
| 956 | $oCore = KTDocumentCore::get($id); | 798 | $oCore = KTDocumentCore::get($id); |
| 957 | 799 | ||
| 958 | - // Get the metadata version for the source document | ||
| 959 | $sTable = KTUtil::getTableName('document_metadata_version'); | 800 | $sTable = KTUtil::getTableName('document_metadata_version'); |
| 960 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; | 801 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; |
| 961 | $aParams = array($oDocument->getMetadataVersionId()); | 802 | $aParams = array($oDocument->getMetadataVersionId()); |
| 962 | $aMDRow = DBUtil::getOneResult(array($sQuery, $aParams)); | 803 | $aMDRow = DBUtil::getOneResult(array($sQuery, $aParams)); |
| 963 | unset($aMDRow['id']); | 804 | unset($aMDRow['id']); |
| 964 | - | ||
| 965 | - // Copy the source metadata into the destination document | ||
| 966 | $aMDRow['document_id'] = $oCore->getId(); | 805 | $aMDRow['document_id'] = $oCore->getId(); |
| 967 | - if(!empty($sDestinationDocName)){ | ||
| 968 | - $aMDRow['name'] = $sDestinationDocName; | ||
| 969 | - $aMDRow['description'] = $sDestinationDocName; | ||
| 970 | - } | ||
| 971 | $id = DBUtil::autoInsert($sTable, $aMDRow); | 806 | $id = DBUtil::autoInsert($sTable, $aMDRow); |
| 972 | if (PEAR::isError($id)) { return $id; } | 807 | if (PEAR::isError($id)) { return $id; } |
| 973 | $oCore->setMetadataVersionId($id); | 808 | $oCore->setMetadataVersionId($id); |
| 974 | $oMDV = KTDocumentMetadataVersion::get($id); | 809 | $oMDV = KTDocumentMetadataVersion::get($id); |
| 975 | 810 | ||
| 976 | - // Get the content version for the source document | ||
| 977 | $sTable = KTUtil::getTableName('document_content_version'); | 811 | $sTable = KTUtil::getTableName('document_content_version'); |
| 978 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; | 812 | $sQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ?'; |
| 979 | $aParams = array($oDocument->_oDocumentContentVersion->getId()); | 813 | $aParams = array($oDocument->_oDocumentContentVersion->getId()); |
| 980 | $aContentRow = DBUtil::getOneResult(array($sQuery, $aParams)); | 814 | $aContentRow = DBUtil::getOneResult(array($sQuery, $aParams)); |
| 981 | unset($aContentRow['id']); | 815 | unset($aContentRow['id']); |
| 982 | - | ||
| 983 | - // Copy the source content into the destination document | ||
| 984 | $aContentRow['document_id'] = $oCore->getId(); | 816 | $aContentRow['document_id'] = $oCore->getId(); |
| 985 | - if(!empty($sDestinationDocName)){ | ||
| 986 | - $aContentRow['filename'] = $sDestinationDocName; | ||
| 987 | - } | ||
| 988 | $id = DBUtil::autoInsert($sTable, $aContentRow); | 817 | $id = DBUtil::autoInsert($sTable, $aContentRow); |
| 989 | if (PEAR::isError($id)) { return $id; } | 818 | if (PEAR::isError($id)) { return $id; } |
| 990 | $oMDV->setContentVersionId($id); | 819 | $oMDV->setContentVersionId($id); |
| @@ -1006,10 +835,6 @@ class KTDocumentUtil { | @@ -1006,10 +835,6 @@ class KTDocumentUtil { | ||
| 1006 | $res = KTDocumentUtil::copyMetadata($oNewDocument, $oDocument->getMetadataVersionId()); | 835 | $res = KTDocumentUtil::copyMetadata($oNewDocument, $oDocument->getMetadataVersionId()); |
| 1007 | if (PEAR::isError($res)) { return $res; } | 836 | if (PEAR::isError($res)) { return $res; } |
| 1008 | 837 | ||
| 1009 | - // Ensure the copied document is not checked out | ||
| 1010 | - $oNewDocument->setIsCheckedOut(false); | ||
| 1011 | - $oNewDocument->setCheckedOutUserID(-1); | ||
| 1012 | - | ||
| 1013 | // finally, copy the actual file. | 838 | // finally, copy the actual file. |
| 1014 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 839 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 1015 | $res = $oStorage->copy($oDocument, $oNewDocument); | 840 | $res = $oStorage->copy($oDocument, $oNewDocument); |
| @@ -1026,11 +851,6 @@ class KTDocumentUtil { | @@ -1026,11 +851,6 @@ class KTDocumentUtil { | ||
| 1026 | $res = $oNewDocument->update(); | 851 | $res = $oNewDocument->update(); |
| 1027 | if (PEAR::isError($res)) { return $res; } | 852 | if (PEAR::isError($res)) { return $res; } |
| 1028 | 853 | ||
| 1029 | - // NEW SEARCH | ||
| 1030 | - | ||
| 1031 | - | ||
| 1032 | - /* | ||
| 1033 | - | ||
| 1034 | $sTable = KTUtil::getTableName('document_text'); | 854 | $sTable = KTUtil::getTableName('document_text'); |
| 1035 | $aQuery = array("SELECT document_text FROM $sTable WHERE document_id = ?", array($oDocument->getId())); | 855 | $aQuery = array("SELECT document_text FROM $sTable WHERE document_id = ?", array($oDocument->getId())); |
| 1036 | $sData = DBUtil::getOneResultKey($aQuery, 'document_text'); | 856 | $sData = DBUtil::getOneResultKey($aQuery, 'document_text'); |
| @@ -1040,8 +860,6 @@ class KTDocumentUtil { | @@ -1040,8 +860,6 @@ class KTDocumentUtil { | ||
| 1040 | 'document_text' => $contents, | 860 | 'document_text' => $contents, |
| 1041 | ); | 861 | ); |
| 1042 | DBUtil::autoInsert($sTable, $aInsertValues, array('noid' => true)); | 862 | DBUtil::autoInsert($sTable, $aInsertValues, array('noid' => true)); |
| 1043 | - | ||
| 1044 | - */ | ||
| 1045 | KTDocumentUtil::updateSearchableText($oNewDocument); | 863 | KTDocumentUtil::updateSearchableText($oNewDocument); |
| 1046 | KTPermissionUtil::updatePermissionLookup($oNewDocument); | 864 | KTPermissionUtil::updatePermissionLookup($oNewDocument); |
| 1047 | 865 | ||
| @@ -1049,36 +867,14 @@ class KTDocumentUtil { | @@ -1049,36 +867,14 @@ class KTDocumentUtil { | ||
| 1049 | $sReason = ''; | 867 | $sReason = ''; |
| 1050 | } | 868 | } |
| 1051 | 869 | ||
| 1052 | - $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Copied to folder \"%s\". %s"), $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy'); | 870 | + |
| 871 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt("Copied to folder \"%s\". %s"), $oDestinationFolder->getName(), $sReason), 'ktcore.transactions.copy'); | ||
| 1053 | $oDocumentTransaction->create(); | 872 | $oDocumentTransaction->create(); |
| 1054 | 873 | ||
| 1055 | $oSrcFolder = Folder::get($oDocument->getFolderID()); | 874 | $oSrcFolder = Folder::get($oDocument->getFolderID()); |
| 1056 | - $oDocumentTransaction = new DocumentTransaction($oNewDocument, sprintf(_kt("Copied from original in folder \"%s\". %s"), $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy'); | 875 | + $oDocumentTransaction = & new DocumentTransaction($oNewDocument, sprintf(_kt("Copied from original in folder \"%s\". %s"), $oSrcFolder->getName(), $sReason), 'ktcore.transactions.copy'); |
| 1057 | $oDocumentTransaction->create(); | 876 | $oDocumentTransaction->create(); |
| 1058 | 877 | ||
| 1059 | - | ||
| 1060 | - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | ||
| 1061 | - $aTriggers = $oKTTriggerRegistry->getTriggers('copyDocument', 'postValidate'); | ||
| 1062 | - foreach ($aTriggers as $aTrigger) { | ||
| 1063 | - $sTrigger = $aTrigger[0]; | ||
| 1064 | - $oTrigger = new $sTrigger; | ||
| 1065 | - $aInfo = array( | ||
| 1066 | - 'document' => $oNewDocument, | ||
| 1067 | - 'old_folder' => $oSrcFolder, | ||
| 1068 | - 'new_folder' => $oDestinationFolder, | ||
| 1069 | - ); | ||
| 1070 | - $oTrigger->setInfo($aInfo); | ||
| 1071 | - $ret = $oTrigger->postValidate(); | ||
| 1072 | - if (PEAR::isError($ret)) { | ||
| 1073 | - return $ret; | ||
| 1074 | - } | ||
| 1075 | - } | ||
| 1076 | - | ||
| 1077 | - // fire subscription alerts for the copied document | ||
| 1078 | - $oSubscriptionEvent = new SubscriptionEvent(); | ||
| 1079 | - $oFolder = Folder::get($oDocument->getFolderID()); | ||
| 1080 | - $oSubscriptionEvent->MoveDocument($oDocument, $oDestinationFolder, $oSrcFolder, 'CopiedDocument'); | ||
| 1081 | - | ||
| 1082 | return $oNewDocument; | 878 | return $oNewDocument; |
| 1083 | } | 879 | } |
| 1084 | 880 | ||
| @@ -1111,7 +907,7 @@ class KTDocumentUtil { | @@ -1111,7 +907,7 @@ class KTDocumentUtil { | ||
| 1111 | } | 907 | } |
| 1112 | 908 | ||
| 1113 | // create the document transaction record | 909 | // create the document transaction record |
| 1114 | - $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document renamed'), 'ktcore.transactions.update'); | 910 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, _kt('Document renamed'), 'ktcore.transactions.update'); |
| 1115 | $oDocumentTransaction->create(); | 911 | $oDocumentTransaction->create(); |
| 1116 | 912 | ||
| 1117 | // fire subscription alerts for the checked in document | 913 | // fire subscription alerts for the checked in document |
| @@ -1163,7 +959,7 @@ class KTDocumentUtil { | @@ -1163,7 +959,7 @@ class KTDocumentUtil { | ||
| 1163 | 959 | ||
| 1164 | // create the document transaction record | 960 | // create the document transaction record |
| 1165 | 961 | ||
| 1166 | - $oDocumentTransaction = new DocumentTransaction($oDocument, $sMoveMessage, 'ktcore.transactions.move'); | 962 | + $oDocumentTransaction = & new DocumentTransaction($oDocument, $sMoveMessage, 'ktcore.transactions.move'); |
| 1167 | $oDocumentTransaction->create(); | 963 | $oDocumentTransaction->create(); |
| 1168 | 964 | ||
| 1169 | 965 | ||
| @@ -1184,79 +980,15 @@ class KTDocumentUtil { | @@ -1184,79 +980,15 @@ class KTDocumentUtil { | ||
| 1184 | } | 980 | } |
| 1185 | } | 981 | } |
| 1186 | 982 | ||
| 1187 | - // fire subscription alerts for the moved document | ||
| 1188 | - $oSubscriptionEvent = new SubscriptionEvent(); | ||
| 1189 | - $oSubscriptionEvent->MoveDocument($oDocument, $oFolder, $oOriginalFolder); | ||
| 1190 | - | ||
| 1191 | return KTPermissionUtil::updatePermissionLookup($oDocument); | 983 | return KTPermissionUtil::updatePermissionLookup($oDocument); |
| 1192 | } | 984 | } |
| 1193 | 985 | ||
| 1194 | - /** | ||
| 1195 | - * Delete a selected version of the document. | ||
| 1196 | - */ | ||
| 1197 | - function deleteVersion($oDocument, $iVersionID, $sReason){ | ||
| 1198 | - | ||
| 1199 | - $oDocument =& KTUtil::getObject('Document', $oDocument); | ||
| 1200 | - $oVersion =& KTDocumentMetadataVersion::get($iVersionID); | ||
| 1201 | - | ||
| 1202 | - $oStorageManager =& KTStorageManagerUtil::getSingleton(); | ||
| 1203 | - | ||
| 1204 | - global $default; | ||
| 1205 | - | ||
| 1206 | - if (empty($sReason)) { | ||
| 1207 | - return PEAR::raiseError(_kt('Deletion requires a reason')); | ||
| 1208 | - } | ||
| 1209 | - | ||
| 1210 | - if (PEAR::isError($oDocument) || ($oDocument == false)) { | ||
| 1211 | - return PEAR::raiseError(_kt('Invalid document object.')); | ||
| 1212 | - } | ||
| 1213 | - | ||
| 1214 | - if (PEAR::isError($oVersion) || ($oVersion == false)) { | ||
| 1215 | - return PEAR::raiseError(_kt('Invalid document version object.')); | ||
| 1216 | - } | ||
| 1217 | - | ||
| 1218 | - $iContentId = $oVersion->getContentVersionId(); | ||
| 1219 | - $oContentVersion = KTDocumentContentVersion::get($iContentId); | ||
| 1220 | - | ||
| 1221 | - if (PEAR::isError($oContentVersion) || ($oContentVersion == false)) { | ||
| 1222 | - DBUtil::rollback(); | ||
| 1223 | - return PEAR::raiseError(_kt('Invalid document content version object.')); | ||
| 1224 | - } | ||
| 1225 | - | ||
| 1226 | - DBUtil::startTransaction(); | ||
| 1227 | - | ||
| 1228 | - // now delete the document version | ||
| 1229 | - $res = $oStorageManager->deleteVersion($oVersion); | ||
| 1230 | - if (PEAR::isError($res) || ($res == false)) { | ||
| 1231 | - //could not delete the document version from the file system | ||
| 1232 | - $default->log->error('Deletion: Filesystem error deleting the metadata version ' . | ||
| 1233 | - $oVersion->getMetadataVersion() . ' of the document ' . | ||
| 1234 | - $oDocument->getFileName() . ' from folder ' . | ||
| 1235 | - Folder::getFolderPath($oDocument->getFolderID()) . | ||
| 1236 | - ' id=' . $oDocument->getFolderID()); | ||
| 1237 | - | ||
| 1238 | - // we use a _real_ transaction here ... | ||
| 1239 | - | ||
| 1240 | - DBUtil::rollback(); | ||
| 1241 | - | ||
| 1242 | - return PEAR::raiseError(_kt('There was a problem deleting the document from storage.')); | ||
| 1243 | - } | ||
| 1244 | - | ||
| 1245 | - // change status for the metadata version | ||
| 1246 | - $oVersion->setStatusId(VERSION_DELETED); | ||
| 1247 | - $oVersion->update(); | ||
| 1248 | - | ||
| 1249 | - // set the storage path to empty | ||
| 1250 | -// $oContentVersion->setStoragePath(''); | ||
| 1251 | - | ||
| 1252 | - DBUtil::commit(); | ||
| 1253 | - } | ||
| 1254 | } | 986 | } |
| 1255 | 987 | ||
| 1256 | class KTMetadataValidationError extends PEAR_Error { | 988 | class KTMetadataValidationError extends PEAR_Error { |
| 1257 | function KTMetadataValidationError ($aFailed) { | 989 | function KTMetadataValidationError ($aFailed) { |
| 1258 | $this->aFailed = $aFailed; | 990 | $this->aFailed = $aFailed; |
| 1259 | - $message = _kt('Please be sure to enter information for all the Required fields below'); | 991 | + $message = _kt('Validation Failed'); |
| 1260 | parent::PEAR_Error($message); | 992 | parent::PEAR_Error($message); |
| 1261 | } | 993 | } |
| 1262 | } | 994 | } |