예제 #1
0
 /**
  * Gets url to download version of file.
  * @param Version $version Version of file.
  * @return string
  */
 public function getUrlForDownloadVersion(Version $version)
 {
     return $this->getUrlDownloadController('downloadVersion', array('fileId' => $version->getObjectId(), 'versionId' => $version->getId()));
 }
예제 #2
0
 public function linkVersion(Version $version)
 {
     $update = $this->update(array('OBJECT_ID' => $version->getObjectId(), 'VERSION_ID' => $version->getId()));
     if ($update) {
         $this->setAttributes(array('VERSION' => $version, 'OBJECT' => $version->getObject()));
     }
     return $update;
 }
예제 #3
0
 /**
  * Restores file from the version.
  *
  * The method is similar with (@see Bitrix\Disk\File::addVersion()).
  *
  * @param Version $version Version which need to restore.
  * @param int $createdBy Id of user.
  * @return bool
  */
 public function restoreFromVersion(Version $version, $createdBy)
 {
     $this->errorCollection->clear();
     if ($version->getObjectId() != $this->id) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_RESTORE_FROM_ANOTHER_OBJECT'), self::ERROR_COULD_NOT_RESTORE_FROM_OBJECT)));
         return false;
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     $forkFileId = \CFile::copyFile($version->getFileId(), true);
     if (!$forkFileId) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_COPY_FILE'), self::ERROR_COULD_NOT_COPY_FILE)));
         return false;
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     if ($this->addVersion(\CFile::getFileArray($forkFileId), $createdBy, true) === null) {
         return false;
     }
     return true;
 }