/**
  * Restore a document from the Deleted/ folder to the specified folder
  *
  * return boolean true on successful move, false otherwhise
  */
 function restore($oDocument)
 {
     $oConfig =& KTConfig::getSingleton();
     $sCurrentPath = $this->getPath($oDocument);
     // check if the deleted folder exists and create it if not
     $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot'));
     $sDocumentRoot = $oConfig->get('urls/documentRoot');
     $oNewFolder = Folder::get($oDocument->getFolderID());
     $aVersions = KTDocumentContentVersion::getByDocument($oDocument);
     foreach ($aVersions as $oVersion) {
         $sNewPath = sprintf("%s/%s-%s", KTDocumentCore::_generateFolderPath($oNewFolder->getID()), $oVersion->getId(), $oVersion->getFileName());
         $oVersion->setStoragePath($sNewPath);
         $sOldPath = sprintf("Deleted/%s-%s", $oVersion->getId(), $oVersion->getFileName());
         $sFullNewPath = sprintf("%s/%s", $sDocumentRoot, $sNewPath);
         $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $sOldPath);
         KTUtil::moveFile($sFullOldPath, $sFullNewPath);
         $oVersion->update();
     }
     return true;
 }
Exemplo n.º 2
0
 function checkRepoDocument($oDocument)
 {
     global $aRepoDocumentProblems;
     $aDCVs = KTDocumentContentVersion::getByDocument($oDocument);
     foreach ($aDCVs as $oDCV) {
         $sDocumentPath = $oDCV->getStoragePath();
         $sFullPath = sprintf("%s/%s", $this->fsPath, $sDocumentPath);
         if (!is_file($sFullPath)) {
             $this->aRepoDocumentProblems[] = array('document' => $oDocument, 'content' => $oDCV, 'path' => $sDocumentPath, 'doclink' => KTBrowseUtil::getUrlForDocument($oDocument));
         }
     }
 }
 /**
  * Completely remove a document from the Deleted/ folder
  *
  * return boolean true on successful expunge
  */
 function expunge($oDocument)
 {
     parent::expunge($oDocument);
     $oConfig =& KTConfig::getSingleton();
     $sCurrentPath = $this->getPath($oDocument);
     $sDocumentRoot = $oConfig->get('urls/documentRoot');
     $aVersions = KTDocumentContentVersion::getByDocument($oDocument);
     foreach ($aVersions as $oVersion) {
         $sPath = sprintf('%s/%s', $sDocumentRoot, $oVersion->getStoragePath());
         @unlink($sPath);
     }
     return true;
 }