Commit 3af983adc00a36af45d223c449ac26b9140f1f4a
1 parent
734a0e5f
- fix for KTS-1298: folder rename doesn't generate a transaction
- cleanup whitespace in Rename.php. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5963 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
22 additions
and
11 deletions
lib/foldermanagement/folderutil.inc.php
| @@ -209,7 +209,7 @@ class KTFolderUtil { | @@ -209,7 +209,7 @@ class KTFolderUtil { | ||
| 209 | 209 | ||
| 210 | function rename($oFolder, $sNewName, $oUser) { | 210 | function rename($oFolder, $sNewName, $oUser) { |
| 211 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 211 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 212 | - | 212 | + $sOldName = $oFolder->getName(); |
| 213 | // First, deal with SQL, as it, at least, is guaranteed to be atomic | 213 | // First, deal with SQL, as it, at least, is guaranteed to be atomic |
| 214 | $table = "folders"; | 214 | $table = "folders"; |
| 215 | 215 | ||
| @@ -253,6 +253,17 @@ class KTFolderUtil { | @@ -253,6 +253,17 @@ class KTFolderUtil { | ||
| 253 | $oFolder->setName($sNewName); | 253 | $oFolder->setName($sNewName); |
| 254 | $res = $oFolder->update(); | 254 | $res = $oFolder->update(); |
| 255 | 255 | ||
| 256 | + $oTransaction = KTFolderTransaction::createFromArray(array( | ||
| 257 | + 'folderid' => $oFolder->getId(), | ||
| 258 | + 'comment' => sprintf("Renamed from \"%s\" to \"%s\"", $sOldName, $sNewName), | ||
| 259 | + 'transactionNS' => 'ktcore.transactions.rename', | ||
| 260 | + 'userid' => $_SESSION['userID'], | ||
| 261 | + 'ip' => Session::getClientIP(), | ||
| 262 | + )); | ||
| 263 | + if (PEAR::isError($oTransaction)) { | ||
| 264 | + return $oTransaction; | ||
| 265 | + } | ||
| 266 | + | ||
| 256 | KTFolderUtil::updateSearchableText($oFolder); | 267 | KTFolderUtil::updateSearchableText($oFolder); |
| 257 | 268 | ||
| 258 | Document::clearAllCaches(); | 269 | Document::clearAllCaches(); |
plugins/ktcore/folder/Rename.php
| @@ -69,18 +69,18 @@ class KTFolderRenameAction extends KTFolderAction { | @@ -69,18 +69,18 @@ class KTFolderRenameAction extends KTFolderAction { | ||
| 69 | $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername'); | 69 | $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername'); |
| 70 | $aErrorOptions['defaultmessage'] = _kt("No folder name given"); | 70 | $aErrorOptions['defaultmessage'] = _kt("No folder name given"); |
| 71 | $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); | 71 | $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); |
| 72 | - $sOldFolderName = $this->oFolder->getName(); | 72 | + $sOldFolderName = $this->oFolder->getName(); |
| 73 | 73 | ||
| 74 | $oParentFolder =& Folder::get($this->oFolder->getParentID()); | 74 | $oParentFolder =& Folder::get($this->oFolder->getParentID()); |
| 75 | - if(PEAR::isError($oParentFolder)) { | ||
| 76 | - $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); | ||
| 77 | - exit(0); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { | ||
| 81 | - $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); | ||
| 82 | - exit(0); | ||
| 83 | - } | 75 | + if(PEAR::isError($oParentFolder)) { |
| 76 | + $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); | ||
| 77 | + exit(0); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { | ||
| 81 | + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); | ||
| 82 | + exit(0); | ||
| 83 | + } | ||
| 84 | 84 | ||
| 85 | $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser); | 85 | $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser); |
| 86 | 86 |