summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Tuke <sam@donttravelempty.com>2012-04-26 18:45:17 +0100
committerSam Tuke <sam@donttravelempty.com>2012-04-26 18:45:17 +0100
commit18a024e251cbcdaafb0ef2893cd5cf8544b03f4d (patch)
tree9633209305aec012458c1a60e372b39f5e1230d8
parentc693ee2adb1b8b251d7905791eeca0946c31c68b (diff)
downloadnextcloud-server-18a024e251cbcdaafb0ef2893cd5cf8544b03f4d.tar.gz
nextcloud-server-18a024e251cbcdaafb0ef2893cd5cf8544b03f4d.zip
started implementing ajax file rollback
-rw-r--r--apps/files_versions/ajax/getVersions.php11
-rw-r--r--apps/files_versions/ajax/rollbackVersion.php26
-rw-r--r--apps/files_versions/history.php9
-rw-r--r--apps/files_versions/js/versions.js32
4 files changed, 61 insertions, 17 deletions
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index fbe65146acc..32aac10b718 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -11,9 +11,16 @@ $source = strip_tags( $source );
if( OCA_Versions\Storage::isversioned( $source ) ) {
$count=5; //show the newest revisions
- $versions=OCA_Versions\Storage::getversions( $source, $count);
+ $versions = OCA_Versions\Storage::getversions( $source, $count);
+ $versionsFormatted = array();
+
+ foreach ( $versions AS $version ) {
+
+ $versionsFormatted[] = OC_Util::formatDate( $version );
+
+ }
- $versionsSorted = array_reverse( $versions );
+ $versionsSorted = array_reverse( $versionsFormatted );
if ( !empty( $versionsSorted ) ) {
OC_JSON::encodedPrint($versionsSorted);
diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php
new file mode 100644
index 00000000000..660411973a2
--- /dev/null
+++ b/apps/files_versions/ajax/rollbackVersion.php
@@ -0,0 +1,26 @@
+<?php
+
+require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_versions');
+require_once('../versions.php');
+
+$userDirectory = "/".OC_User::getUser()."/files";
+
+$source = $_GET['source'];
+
+$source = strip_tags( $source );
+
+echo "\n\n$source\n\n";
+
+$revision = strtotime( $source );
+
+echo "\n\n$revision\n\n";
+
+if( OCA_Versions\Storage::isversioned( $source ) ) {
+
+
+ #\OCA_Versions\Storage::rollback( $source, $revision );
+
+}
+
+?> \ No newline at end of file
diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php
index 434feaf3576..05a5db55daa 100644
--- a/apps/files_versions/history.php
+++ b/apps/files_versions/history.php
@@ -32,13 +32,18 @@ if ( isset( $_GET['path'] ) ) {
// roll back to old version if button clicked
if( isset( $_GET['revert'] ) ) {
- \OCA_Versions\Storage::rollback( $path, $_GET['revert'] );
+
+ if( \OCA_Versions\Storage::rollback( $path, $_GET['revert'] ) ) {
+
+ echo "<script>OC.dialogs.alert(response.data.message, t('contacts', 'Error'))</script>";
+
+ }
}
// show the history only if there is something to show
if( OCA_Versions\Storage::isversioned( $path ) ) {
- $count=5; //show the newest revisions
+ $count=999; //show the newest revisions
$versions=OCA_Versions\Storage::getversions( $path, $count);
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index 5018b75f154..a9e60a0cfa6 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -17,17 +17,7 @@ $(document).ready(function(){
async: false,
success: function(versions) {
if (versions) {
-
- // icon = OC.imagePath('core', 'actions/shared');
- // $.each(users, function(index, row) {
- // if (row.uid_shared_with == 'public') {
- // icon = OC.imagePath('core', 'actions/public');
- // }
- // });
- // } else {
- // icon = OC.imagePath('core', 'actions/share');
}
- shared_status[file]= { timestamp: new Date().getTime(), icon: icon };
}
});
@@ -37,15 +27,15 @@ $(document).ready(function(){
function createVersionsDropdown(filename, files) {
var historyUrl = '../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
- //alert( historyUrl );
+
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
html += '<div id="private">';
html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">';
html += '<option value="">Select version</option>';
html += '</select>';
html += '</div>';
- html += '<input type="button" name="makelink" id="makelink" value="Revert file" />';
- html += '<input type="button" onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" value="More..." />';
+ html += '<input type="button" value="Revert file" onclick="revertFile()" />';
+ html += '<input type="button" value="More..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
html += '<br />';
html += '<input id="link" style="display:none; width:90%;" />';
@@ -76,6 +66,22 @@ function createVersionsDropdown(filename, files) {
});
+ function revertFile() {
+
+ $.ajax({
+ type: 'GET',
+ url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'),
+ dataType: 'json',
+ data: {path: file, revision: 'revision'},
+ async: false,
+ success: function(versions) {
+ if (versions) {
+ }
+ }
+ });
+
+ }
+
function addVersion( name ) {
var version = '<option>'+name+'</option>';