Skip to content
Snippets Groups Projects
Commit 18a024e2 authored by Sam Tuke's avatar Sam Tuke
Browse files

started implementing ajax file rollback

parent c693ee2a
Branches
No related tags found
No related merge requests found
......@@ -12,8 +12,15 @@ if( OCA_Versions\Storage::isversioned( $source ) ) {
$count=5; //show the newest revisions
$versions = OCA_Versions\Storage::getversions( $source, $count);
$versionsFormatted = array();
$versionsSorted = array_reverse( $versions );
foreach ( $versions AS $version ) {
$versionsFormatted[] = OC_Util::formatDate( $version );
}
$versionsSorted = array_reverse( $versionsFormatted );
if ( !empty( $versionsSorted ) ) {
OC_JSON::encodedPrint($versionsSorted);
......
<?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
......@@ -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' );
......
......@@ -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>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment