Commit 33003f68592f6c0fc3f4fd88d502f39ad496ae1e
1 parent
5295a763
Brad Shuttleworth 2006-02-16 copy unit-tests
Brad Shuttleworth 2006-02-15 documentutil::checkout was broken by me.
Brad Shuttleworth 2006-02-15 fix for KTS-XXX: IE blows up on manage cond...
Brad Shuttleworth 2006-02-15 folder and document copy.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4928 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
53 additions
and
14 deletions
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -125,9 +125,9 @@ class KTDocumentUtil { |
| 125 | 125 | |
| 126 | 126 | // FIXME at the moment errors this _does not_ rollback. |
| 127 | 127 | |
| 128 | - $this->oDocument->setIsCheckedOut(true); | |
| 129 | - $this->oDocument->setCheckedOutUserID($oUser->getId()); | |
| 130 | - if (!$this->oDocument->update()) { return PEAR::raiseError(_("There was a problem checking out the document.")); } | |
| 128 | + $oDocument->setIsCheckedOut(true); | |
| 129 | + $oDocument->setCheckedOutUserID($oUser->getId()); | |
| 130 | + if (!$oDocument->update()) { return PEAR::raiseError(_("There was a problem checking out the document.")); } | |
| 131 | 131 | |
| 132 | 132 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); |
| 133 | 133 | $aTriggers = $oKTTriggerRegistry->getTriggers('checkout', 'postValidate'); |
| ... | ... | @@ -646,7 +646,8 @@ class KTDocumentUtil { |
| 646 | 646 | function copy($oDocument, $oDestinationFolder) { |
| 647 | 647 | // 1. generate a new triad of content, metadata and core objects. |
| 648 | 648 | // 2. update the storage path. |
| 649 | - | |
| 649 | + //print '--------------------------------- BEFORE'; | |
| 650 | + //print_r($oDocument); | |
| 650 | 651 | |
| 651 | 652 | // grab the "source "data |
| 652 | 653 | $sTable = KTUtil::getTableName('documents'); |
| ... | ... | @@ -690,6 +691,11 @@ class KTDocumentUtil { |
| 690 | 691 | // now, we have a semi-sane document object. get it. |
| 691 | 692 | $oNewDocument = Document::get($oCore->getId()); |
| 692 | 693 | |
| 694 | + //print '--------------------------------- AFTER'; | |
| 695 | + //print_r($oDocument); | |
| 696 | + //print '======'; | |
| 697 | + //print_r($oNewDocument); | |
| 698 | + | |
| 693 | 699 | // copy the metadata from old to new. |
| 694 | 700 | $res = KTDocumentUtil::copyMetadata($oNewDocument, $oDocument->getMetadataVersionId()); |
| 695 | 701 | if (PEAR::isError($res)) { return $res; } | ... | ... |
lib/foldermanagement/folderutil.inc.php
| ... | ... | @@ -260,7 +260,10 @@ class KTFolderUtil { |
| 260 | 260 | return true; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - function copy($oFolder, $oDestFolder, $oUser, $sReason) { | |
| 263 | + function copy($oSrcFolder, $oDestFolder, $oUser, $sReason) { | |
| 264 | + if (KTFolderUtil::exists($oDestFolder, $oSrcFolder->getName())) { | |
| 265 | + return PEAR::raiseError("Folder with the same name already exists in the new parent folder"); | |
| 266 | + } | |
| 264 | 267 | // |
| 265 | 268 | // FIXME the failure cleanup code here needs some serious work. |
| 266 | 269 | // |
| ... | ... | @@ -276,7 +279,7 @@ class KTFolderUtil { |
| 276 | 279 | $aFailedDocuments = array(); // of String |
| 277 | 280 | $aFailedFolders = array(); // of String |
| 278 | 281 | |
| 279 | - $aRemainingFolders = array($oFolder->getId()); | |
| 282 | + $aRemainingFolders = array($oSrcFolder->getId()); | |
| 280 | 283 | |
| 281 | 284 | DBUtil::startTransaction(); |
| 282 | 285 | |
| ... | ... | @@ -332,7 +335,7 @@ class KTFolderUtil { |
| 332 | 335 | |
| 333 | 336 | $sTable = KTUtil::getTableName('folders'); |
| 334 | 337 | $sGetQuery = 'SELECT * FROM ' . $sTable . ' WHERE id = ? '; |
| 335 | - $aParams = array($oFolder->getId()); | |
| 338 | + $aParams = array($oSrcFolder->getId()); | |
| 336 | 339 | $aRow = DBUtil::getOneResult(array($sGetQuery, $aParams)); |
| 337 | 340 | unset($aRow['id']); |
| 338 | 341 | $aRow['parent_id'] = $oDestFolder->getId(); |
| ... | ... | @@ -341,7 +344,7 @@ class KTFolderUtil { |
| 341 | 344 | DBUtil::rollback(); |
| 342 | 345 | return $id; |
| 343 | 346 | } |
| 344 | - $aFolderMap[$oFolder->getId()] = $id; | |
| 347 | + $aFolderMap[$oSrcFolder->getId()] = $id; | |
| 345 | 348 | $oNewBaseFolder = Folder::get($id); |
| 346 | 349 | $res = $oStorage->createFolder($oNewBaseFolder); |
| 347 | 350 | if (PEAR::isError($res)) { |
| ... | ... | @@ -349,7 +352,7 @@ class KTFolderUtil { |
| 349 | 352 | DBUtil::rollback(); |
| 350 | 353 | return $res; |
| 351 | 354 | } |
| 352 | - $aRemainingFolders = Folder::getList(array('parent_id = ?', array($oFolder->getId())), array('ids' => true)); | |
| 355 | + $aRemainingFolders = Folder::getList(array('parent_id = ?', array($oSrcFolder->getId())), array('ids' => true)); | |
| 353 | 356 | |
| 354 | 357 | |
| 355 | 358 | while (!empty($aRemainingFolders)) { |
| ... | ... | @@ -364,10 +367,12 @@ class KTFolderUtil { |
| 364 | 367 | |
| 365 | 368 | $id = DBUtil::autoInsert($sTable, $aRow); |
| 366 | 369 | if (PEAR::isError($id)) { |
| 370 | + $oStorage->removeFolder($oNewBaseFolder); | |
| 367 | 371 | DBUtil::rollback(); |
| 368 | 372 | return $id; |
| 369 | 373 | } |
| 370 | 374 | $aFolderMap[$iFolderId] = $id; |
| 375 | + | |
| 371 | 376 | $oNewFolder = Folder::get($id); |
| 372 | 377 | $res = $oStorage->createFolder($oNewFolder); |
| 373 | 378 | if (PEAR::isError($res)) { |
| ... | ... | @@ -382,12 +387,15 @@ class KTFolderUtil { |
| 382 | 387 | } |
| 383 | 388 | |
| 384 | 389 | |
| 390 | + var_dump($aFolderMap); | |
| 385 | 391 | |
| 386 | 392 | // now we can go ahead. |
| 387 | 393 | foreach ($aDocuments as $oDocument) { |
| 388 | 394 | $oChildDestinationFolder = Folder::get($aFolderMap[$oDocument->getFolderID()]); |
| 395 | + var_dump($oDocument->getFolderID()); | |
| 389 | 396 | $res = KTDocumentUtil::copy($oDocument, $oChildDestinationFolder); |
| 390 | 397 | if (PEAR::isError($res) || ($res === false)) { |
| 398 | + $oStorage->removeFolder($oNewBaseFolder); | |
| 391 | 399 | DBUtil::rollback(); |
| 392 | 400 | return PEAR::raiseError(_('Delete Aborted. Unexpected failure to copydocument: ') . $oDocument->getName() . $res->getMessage()); |
| 393 | 401 | } | ... | ... |
lib/storage/ondiskpathstoragemanager.inc.php
| ... | ... | @@ -283,9 +283,8 @@ class KTOnDiskPathStorageManager extends KTStorageManager { |
| 283 | 283 | $oConfig =& KTConfig::getSingleton(); |
| 284 | 284 | $sDocumentRoot = $oConfig->get('urls/documentRoot'); |
| 285 | 285 | |
| 286 | - $sOldPath = sprintf("%s/%s-%s", KTDocumentCore::_generateFolderPath($oSrcDocument->getFolderID()), $oSrcDocument->_oDocumentContentVersion->getId(), $oSrcDocument->_oDocumentContentVersion->getFileName()); | |
| 287 | - $sNewPath = sprintf("%s/%s-%s", KTDocumentCore::_generateFolderPath($oNewDocument->getFolderID()), $oNewDocument->_oDocumentContentVersion->getId(), $oNewDocument->_oDocumentContentVersion->getFileName()); | |
| 288 | - $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $sOldPath); | |
| 286 | + $sNewPath = $this->generateStoragePath($oNewDocument); | |
| 287 | + $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $this->generateStoragePath($oSrcDocument)); | |
| 289 | 288 | $sFullNewPath = sprintf("%s/%s", $sDocumentRoot, $sNewPath); |
| 290 | 289 | |
| 291 | 290 | $res = KTUtil::copyFile($sFullOldPath, $sFullNewPath); | ... | ... |
templates/ktcore/metadata/conditional/editsimple.smarty
| 1 | 1 | {capture assign=sCSS} |
| 2 | 2 | {literal} |
| 3 | 3 | /* inactivity */ |
| 4 | + | |
| 4 | 5 | .active .inactivity_message { display: none; } |
| 5 | 6 | |
| 6 | 7 | select { width: 100%; } |
| ... | ... | @@ -14,11 +15,11 @@ select { width: 100%; } |
| 14 | 15 | |
| 15 | 16 | .active.editing .edit_button { display: none; } |
| 16 | 17 | |
| 17 | -.active { position: relative; } | |
| 18 | + | |
| 18 | 19 | td { vertical-align: top; } |
| 19 | 20 | .buttonset.inactive { background: transparent; } |
| 20 | 21 | |
| 21 | -.inactive { background: #ccc; position: relative; } | |
| 22 | +.inactive { background: #ccc; } | |
| 22 | 23 | .inactive .fixed_message, |
| 23 | 24 | .inactive .unassigned_items, |
| 24 | 25 | .inactive .available_behaviours, |
| ... | ... | @@ -79,11 +80,14 @@ refresh the page.</p> |
| 79 | 80 | <input type="hidden" name="fieldset_id" id="global-fieldset-id" value="{$fieldset_id}" /> |
| 80 | 81 | |
| 81 | 82 | <table id="simple_conditional_edit"> |
| 83 | +<thead> | |
| 82 | 84 | <tr> |
| 83 | 85 | {foreach from=$aFields item=oField} |
| 84 | 86 | <th id="header_{$oField->getId()}">{$oField->getName()}</th> |
| 85 | 87 | {/foreach} |
| 86 | 88 | </tr> |
| 89 | +</thead> | |
| 90 | +<tbody> | |
| 87 | 91 | <tr valign="top"> |
| 88 | 92 | |
| 89 | 93 | {foreach from=$aFields item=oField} |
| ... | ... | @@ -101,6 +105,8 @@ refresh the page.</p> |
| 101 | 105 | {/foreach} |
| 102 | 106 | |
| 103 | 107 | </tr> |
| 108 | +</tbody> | |
| 109 | +<tfoot> | |
| 104 | 110 | <tr> |
| 105 | 111 | {foreach from=$aFields item=oField} |
| 106 | 112 | <td class="buttonset" id="buttons_{$oField->getId()}"> |
| ... | ... | @@ -112,7 +118,11 @@ refresh the page.</p> |
| 112 | 118 | </td> |
| 113 | 119 | {/foreach} |
| 114 | 120 | </tr> |
| 121 | +</tfoot> | |
| 115 | 122 | </table> |
| 123 | + | |
| 124 | + | |
| 125 | +</form> | |
| 116 | 126 | <!-- |
| 117 | 127 | <table id="brad-log"> |
| 118 | 128 | <tr> | ... | ... |
tests/storage/copyFolder.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../config/dmsDefaults.php"); | |
| 4 | +require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); | |
| 5 | +require_once(KT_LIB_DIR . '/users/User.inc'); | |
| 6 | +require_once(KT_LIB_DIR . '/database/dbutil.inc'); | |
| 7 | + | |
| 8 | +//error_reporting(E_ALL); | |
| 9 | + | |
| 10 | +$oSrc = Folder::get(3); | |
| 11 | +$oDest = Folder::get(2); | |
| 12 | +$oUser = User::get(1); | |
| 13 | + | |
| 14 | +var_dump(KTFolderUtil::copy($oSrc, $oDest, $oUser, 'copy test')); | |
| 15 | + | |
| 16 | +?> | |
| 0 | 17 | \ No newline at end of file | ... | ... |