diff --git a/lib/foldermanagement/folderutil.inc.php b/lib/foldermanagement/folderutil.inc.php index 0ffc005..0a8b7ea 100644 --- a/lib/foldermanagement/folderutil.inc.php +++ b/lib/foldermanagement/folderutil.inc.php @@ -209,7 +209,7 @@ class KTFolderUtil { function rename($oFolder, $sNewName, $oUser) { $oStorage =& KTStorageManagerUtil::getSingleton(); - + $sOldName = $oFolder->getName(); // First, deal with SQL, as it, at least, is guaranteed to be atomic $table = "folders"; @@ -253,6 +253,17 @@ class KTFolderUtil { $oFolder->setName($sNewName); $res = $oFolder->update(); + $oTransaction = KTFolderTransaction::createFromArray(array( + 'folderid' => $oFolder->getId(), + 'comment' => sprintf("Renamed from \"%s\" to \"%s\"", $sOldName, $sNewName), + 'transactionNS' => 'ktcore.transactions.rename', + 'userid' => $_SESSION['userID'], + 'ip' => Session::getClientIP(), + )); + if (PEAR::isError($oTransaction)) { + return $oTransaction; + } + KTFolderUtil::updateSearchableText($oFolder); Document::clearAllCaches(); diff --git a/plugins/ktcore/folder/Rename.php b/plugins/ktcore/folder/Rename.php index f22713c..24f4e1d 100644 --- a/plugins/ktcore/folder/Rename.php +++ b/plugins/ktcore/folder/Rename.php @@ -69,18 +69,18 @@ class KTFolderRenameAction extends KTFolderAction { $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername'); $aErrorOptions['defaultmessage'] = _kt("No folder name given"); $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); - $sOldFolderName = $this->oFolder->getName(); + $sOldFolderName = $this->oFolder->getName(); $oParentFolder =& Folder::get($this->oFolder->getParentID()); - if(PEAR::isError($oParentFolder)) { - $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); - exit(0); - } - - if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { - $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); - exit(0); - } + if(PEAR::isError($oParentFolder)) { + $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } + + if(KTFolderUtil::exists($oParentFolder, $sFolderName)) { + $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); + exit(0); + } $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser);