diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-05-17 02:16:33 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-05-17 02:16:33 +0200 |
commit | bfdb374a2c8287b4dea80696928d27aef96fa343 (patch) | |
tree | 492824ad438bba1e5677efea4a74b60e486655e0 /apps/files_versions/ajax | |
parent | 4ccfd27fa233ca737dbd10f65d680ed853e7efcf (diff) | |
download | nextcloud-server-bfdb374a2c8287b4dea80696928d27aef96fa343.tar.gz nextcloud-server-bfdb374a2c8287b4dea80696928d27aef96fa343.zip |
allow reverting file from history dropdown
Diffstat (limited to 'apps/files_versions/ajax')
-rw-r--r-- | apps/files_versions/ajax/getVersions.php | 12 | ||||
-rw-r--r-- | apps/files_versions/ajax/rollbackVersion.php | 28 |
2 files changed, 11 insertions, 29 deletions
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 8ef17d5a25c..1d107c1bda0 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -1,7 +1,4 @@ <?php - -require_once('lib/base.php'); - OCP\JSON::checkAppEnabled('files_versions'); require_once('apps/files_versions/versions.php'); @@ -14,15 +11,8 @@ if( OCA_Versions\Storage::isversioned( $source ) ) { $count=5; //show the newest revisions $versions = OCA_Versions\Storage::getversions( $source, $count); - $versionsFormatted = array(); - - foreach ( $versions AS $version ) { - - $versionsFormatted[] = OCP\Util::formatDate( $version ); - - } - $versionsSorted = array_reverse( $versionsFormatted ); + $versionsSorted = array_reverse( $versions ); if ( !empty( $versionsSorted ) ) { OCP\JSON::encodedPrint($versionsSorted); diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php index 3faaafe935d..127592f3b58 100644 --- a/apps/files_versions/ajax/rollbackVersion.php +++ b/apps/files_versions/ajax/rollbackVersion.php @@ -1,26 +1,18 @@ <?php -require_once('../../../lib/base.php'); OCP\JSON::checkAppEnabled('files_versions'); -require_once('../versions.php'); -$userDirectory = "/".OCP\USER::getUser()."/files"; - -$source = $_GET['source']; - -$source = strip_tags( $source ); - -echo "\n\n$source\n\n"; +require_once('apps/files_versions/versions.php'); -$revision = strtotime( $source ); - -echo "\n\n$revision\n\n"; - -if( OCA_Versions\Storage::isversioned( $source ) ) { +$userDirectory = "/".OCP\USER::getUser()."/files"; +$file = $_GET['file']; +$revision=(int)$_GET['revision']; - #\OCA_Versions\Storage::rollback( $source, $revision ); - +if( OCA_Versions\Storage::isversioned( $file ) ) { + if(OCA_Versions\Storage::rollback( $file, $revision )){ + OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); + }else{ + OCP\JSON::error(array("data" => array( "message" => "Could not revert:" . $file ))); + } } - -?>
\ No newline at end of file |