Browse Source

started implementing ajax file rollback

tags/v4.0.0beta
Sam Tuke 12 years ago
parent
commit
18a024e251

+ 9
- 2
apps/files_versions/ajax/getVersions.php View File

@@ -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);

+ 26
- 0
apps/files_versions/ajax/rollbackVersion.php View File

@@ -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 );
}

?>

+ 7
- 2
apps/files_versions/history.php View 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' );

+ 19
- 13
apps/files_versions/js/versions.js View File

@@ -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>';

Loading…
Cancel
Save