added revert attempt outcome messages, removed contextual ajax revert button for now as it's not functional, improved readaibility of scripts
This commit is contained in:
parent
768041b6cb
commit
80c850d018
|
@ -1,3 +1,16 @@
|
||||||
#history {
|
#history {
|
||||||
margin: 2em 2em 0;
|
margin: 2em 2em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#feedback-messages h3 {
|
||||||
|
font-size: 1.3em;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.failure {
|
||||||
|
color: red;
|
||||||
|
}
|
|
@ -24,20 +24,31 @@ require_once( '../../lib/base.php' );
|
||||||
|
|
||||||
OC_Util::checkLoggedIn( );
|
OC_Util::checkLoggedIn( );
|
||||||
OC_Util::addStyle('files_versions','versions');
|
OC_Util::addStyle('files_versions','versions');
|
||||||
|
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
|
||||||
|
|
||||||
if ( isset( $_GET['path'] ) ) {
|
if ( isset( $_GET['path'] ) ) {
|
||||||
|
|
||||||
$path = $_GET['path'];
|
$path = $_GET['path'];
|
||||||
$path = strip_tags( $path );
|
$path = strip_tags( $path );
|
||||||
|
$tmpl->assign( 'path', $path );
|
||||||
|
|
||||||
// roll back to old version if button clicked
|
// roll back to old version if button clicked
|
||||||
if( isset( $_GET['revert'] ) ) {
|
if( isset( $_GET['revert'] ) ) {
|
||||||
|
|
||||||
if( \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>";
|
$tmpl->assign( 'outcome_stat', 'success' );
|
||||||
|
|
||||||
|
$tmpl->assign( 'outcome_msg', "File {$_GET['path']} was reverted to version ".OC_Util::formatDate( $_GET['revert'] ) );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$tmpl->assign( 'outcome_stat', 'failure' );
|
||||||
|
|
||||||
|
$tmpl->assign( 'outcome_msg', "File {$_GET['path']} could not be reverted to version ".OC_Util::formatDate( $_GET['revert'] ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the history only if there is something to show
|
// show the history only if there is something to show
|
||||||
|
@ -46,21 +57,19 @@ if ( isset( $_GET['path'] ) ) {
|
||||||
$count=999; //show the newest revisions
|
$count=999; //show the newest revisions
|
||||||
$versions=OCA_Versions\Storage::getversions( $path, $count);
|
$versions=OCA_Versions\Storage::getversions( $path, $count);
|
||||||
|
|
||||||
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
|
|
||||||
$tmpl->assign( 'path', $path);
|
|
||||||
$tmpl->assign( 'versions', array_reverse( $versions ) );
|
$tmpl->assign( 'versions', array_reverse( $versions ) );
|
||||||
$tmpl->printPage( );
|
|
||||||
}else{
|
}else{
|
||||||
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
|
|
||||||
$tmpl->assign( 'path', $path);
|
|
||||||
$tmpl->assign( 'message', 'No old versions available' );
|
$tmpl->assign( 'message', 'No old versions available' );
|
||||||
$tmpl->printPage( );
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
|
|
||||||
$tmpl->assign( 'message', 'No path specified' );
|
$tmpl->assign( 'message', 'No path specified' );
|
||||||
$tmpl->printPage( );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tmpl->printPage( );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -31,11 +31,11 @@ function createVersionsDropdown(filename, files) {
|
||||||
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
|
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
|
||||||
html += '<div id="private">';
|
html += '<div id="private">';
|
||||||
html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">';
|
html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">';
|
||||||
html += '<option value="">Select version</option>';
|
html += '<option value="">Saved versions</option>';
|
||||||
html += '</select>';
|
html += '</select>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<input type="button" value="Revert file" onclick="revertFile()" />';
|
//html += '<input type="button" value="Revert file" onclick="revertFile()" />';
|
||||||
html += '<input type="button" value="More..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
|
html += '<input type="button" value="Revert file..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
|
||||||
html += '<br />';
|
html += '<br />';
|
||||||
html += '<input id="link" style="display:none; width:90%;" />';
|
html += '<input id="link" style="display:none; width:90%;" />';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<div id="history">
|
<div id="history">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if( isset( $_['message'] ) ) {
|
if( isset( $_['message'] ) ) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +10,15 @@
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
if( isset( $_['outcome_stat'] ) ) {
|
||||||
|
|
||||||
|
echo( '<div id="feedback-messages" class="'.$_['outcome_stat'].'"><h3>'.$_['outcome_msg'] ).'</h3></div><br>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
echo( '<strong>Versions of '.$_['path'] ).'</strong><br>';
|
echo( '<strong>Versions of '.$_['path'] ).'</strong><br>';
|
||||||
echo('<p><em>You can click on the revert button to revert to the specific verson.</em></p><br />');
|
echo('<p><em>You can click on the revert button to revert to the specific verson.</em></p><br />');
|
||||||
|
|
||||||
foreach ( $_['versions'] as $v ) {
|
foreach ( $_['versions'] as $v ) {
|
||||||
|
|
||||||
echo ' ';
|
echo ' ';
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Storage {
|
||||||
const DEFAULTFOLDER='versions';
|
const DEFAULTFOLDER='versions';
|
||||||
const DEFAULTBLACKLIST='avi mp3 mpg mp4';
|
const DEFAULTBLACKLIST='avi mp3 mpg mp4';
|
||||||
const DEFAULTMAXFILESIZE=1048576; // 10MB
|
const DEFAULTMAXFILESIZE=1048576; // 10MB
|
||||||
const DEFAULTMININTERVAL=1; // 5 min
|
const DEFAULTMININTERVAL=120; // 2 min
|
||||||
const DEFAULTMAXVERSIONS=50;
|
const DEFAULTMAXVERSIONS=50;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,12 +122,26 @@ class Storage {
|
||||||
* rollback to an old version of a file.
|
* rollback to an old version of a file.
|
||||||
*/
|
*/
|
||||||
public static function rollback($filename,$revision) {
|
public static function rollback($filename,$revision) {
|
||||||
|
|
||||||
if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||||
|
|
||||||
$versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OC_User::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
$versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OC_User::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||||
|
|
||||||
$filesfoldername=\OC_Config::getValue('datadirectory').'/'. \OC_User::getUser() .'/files';
|
$filesfoldername=\OC_Config::getValue('datadirectory').'/'. \OC_User::getUser() .'/files';
|
||||||
|
|
||||||
// rollback
|
// rollback
|
||||||
@copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename);
|
if ( @copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename) ) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue