本文整理汇总了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;
}
示例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;
}
示例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;
}