function postValidate() { global $default; $oDocument =& $this->aInfo["document"]; $oOldFolder =& $this->aInfo["old_folder"]; $oNewFolder =& $this->aInfo["new_folder"]; // fire subscription alerts for the checked in document $oSubscriptionEvent = new SubscriptionEvent(); $oSubscriptionEvent->MoveDocument($oDocument, $oNewFolder, $oNewFolder); }
function move($oDocument, $oToFolder, $oUser = null, $sReason = null) { //make sure we move the symlink, and the document it's linking to if ($oDocument->isSymbolicLink()) { $oDocument->switchToRealCore(); } else { $oDocument->switchToLinkedCore(); } $oFolder = $oToFolder; // alias. $oOriginalFolder = Folder::get($oDocument->getFolderId()); $iOriginalFolderPermissionObjectId = $oOriginalFolder->getPermissionObjectId(); $iDocumentPermissionObjectId = $oDocument->getPermissionObjectId(); if ($iDocumentPermissionObjectId === $iOriginalFolderPermissionObjectId) { $oDocument->setPermissionObjectId($oFolder->getPermissionObjectId()); } //put the document in the new folder $oDocument->setFolderID($oFolder->getId()); $sName = $oDocument->getName(); $sFilename = $oDocument->getFileName(); $oDocument->setFileName(KTDocumentUtil::getUniqueFilename($oToFolder, $sFilename)); $oDocument->setName(KTDocumentUtil::getUniqueDocumentName($oToFolder, $sName)); $res = $oDocument->update(); if (PEAR::isError($res)) { return $res; } //move the document on the file system(not if it's a symlink) if (!$oDocument->isSymbolicLink()) { $oStorage =& KTStorageManagerUtil::getSingleton(); $res = $oStorage->moveDocument($oDocument, $oFolder, $oOriginalFolder); if (PEAR::isError($res) || $res === false) { $oDocument->setFolderID($oOriginalFolder->getId()); $res = $oDocument->update(); if (PEAR::isError($res)) { return $res; } return $res; // we failed, bail. } } $sMoveMessage = sprintf(_kt("Moved from %s/%s to %s/%s. %s"), $oOriginalFolder->getFullPath(), $oOriginalFolder->getName(), $oFolder->getFullPath(), $oFolder->getName(), $sReason); // create the document transaction record $oDocumentTransaction = new DocumentTransaction($oDocument, $sMoveMessage, 'ktcore.transactions.move'); $oDocumentTransaction->create(); $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); $aTriggers = $oKTTriggerRegistry->getTriggers('moveDocument', 'postValidate'); foreach ($aTriggers as $aTrigger) { $sTrigger = $aTrigger[0]; $oTrigger = new $sTrigger(); $aInfo = array('document' => $oDocument, 'old_folder' => $oOriginalFolder, 'new_folder' => $oFolder); $oTrigger->setInfo($aInfo); $ret = $oTrigger->postValidate(); if (PEAR::isError($ret)) { return $ret; } } // fire subscription alerts for the moved document $oSubscriptionEvent = new SubscriptionEvent(); $oSubscriptionEvent->MoveDocument($oDocument, $oFolder, $oOriginalFolder); return KTPermissionUtil::updatePermissionLookup($oDocument); }