当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::scheduleExpire方法代码示例

本文整理汇总了PHP中OCA\Files_Versions\Storage::scheduleExpire方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::scheduleExpire方法的具体用法?PHP Storage::scheduleExpire怎么用?PHP Storage::scheduleExpire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCA\Files_Versions\Storage的用法示例。


在下文中一共展示了Storage::scheduleExpire方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rollback

 /**
  * Rollback to an old version of a file.
  *
  * @param string $file file name
  * @param int $revision revision timestamp
  */
 public static function rollback($file, $revision)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         // add expected leading slash
         $file = '/' . ltrim($file, '/');
         list($uid, $filename) = self::getUidAndFilename($file);
         $users_view = new \OC\Files\View('/' . $uid);
         $files_view = new \OC\Files\View('/' . \OCP\User::getUser() . '/files');
         $versionCreated = false;
         //first create a new version
         $version = 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename);
         if (!$users_view->file_exists($version)) {
             $users_view->copy('files' . $filename, 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename));
             $versionCreated = true;
         }
         // rollback
         if (self::copyFileContents($users_view, 'files_versions' . $filename . '.v' . $revision, 'files' . $filename)) {
             $files_view->touch($file, $revision);
             Storage::scheduleExpire($uid, $file);
             \OC_Hook::emit('\\OCP\\Versions', 'rollback', array('path' => $filename));
             return true;
         } else {
             if ($versionCreated) {
                 self::deleteVersion($users_view, $version);
             }
         }
     }
     return false;
 }
开发者ID:DanielTosello,项目名称:owncloud,代码行数:35,代码来源:storage.php

示例2: rollback

 /**
  * Rollback to an old version of a file.
  *
  * @param string $file file name
  * @param int $revision revision timestamp
  */
 public static function rollback($file, $revision)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         // add expected leading slash
         $file = '/' . ltrim($file, '/');
         list($uid, $filename) = self::getUidAndFilename($file);
         $users_view = new View('/' . $uid);
         $files_view = new View('/' . User::getUser() . '/files');
         $versionCreated = false;
         //first create a new version
         $version = 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename);
         if (!$users_view->file_exists($version)) {
             $users_view->copy('files' . $filename, 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename));
             $versionCreated = true;
         }
         $fileToRestore = 'files_versions' . $filename . '.v' . $revision;
         // Restore encrypted version of the old file for the newly restored file
         // This has to happen manually here since the file is manually copied below
         $oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
         $newFileInfo = $files_view->getFileInfo($filename);
         $cache = $newFileInfo->getStorage()->getCache();
         $cache->update($newFileInfo->getId(), ['encrypted' => $oldVersion, 'encryptedVersion' => $oldVersion]);
         // rollback
         if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) {
             $files_view->touch($file, $revision);
             Storage::scheduleExpire($uid, $file);
             \OC_Hook::emit('\\OCP\\Versions', 'rollback', array('path' => $filename, 'revision' => $revision));
             return true;
         } else {
             if ($versionCreated) {
                 self::deleteVersion($users_view, $version);
             }
         }
     }
     return false;
 }
开发者ID:gvde,项目名称:core,代码行数:42,代码来源:storage.php

示例3: rollback

 /**
  * rollback to an old version of a file.
  */
 public static function rollback($file, $revision)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         list($uid, $filename) = self::getUidAndFilename($file);
         $users_view = new \OC\Files\View('/' . $uid);
         $files_view = new \OC\Files\View('/' . \OCP\User::getUser() . '/files');
         $versionCreated = false;
         //first create a new version
         $version = 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename);
         if (!$users_view->file_exists($version)) {
             $users_view->copy('files' . $filename, 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename));
             $versionCreated = true;
         }
         // rollback
         if (@$users_view->rename('files_versions' . $filename . '.v' . $revision, 'files' . $filename)) {
             $files_view->touch($file, $revision);
             Storage::scheduleExpire($file);
             return true;
         } else {
             if ($versionCreated) {
                 self::deleteVersion($users_view, $version);
             }
         }
     }
     return false;
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:29,代码来源:storage.php


注:本文中的OCA\Files_Versions\Storage::scheduleExpire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。