summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorSam Tuke <samtuke@jack-laptop.(none)>2012-04-27 13:19:16 +0100
committerSam Tuke <samtuke@jack-laptop.(none)>2012-04-27 13:19:16 +0100
commit80c850d018baceca3a6197a7c21651c58d0edc25 (patch)
tree6bf962e30bf88e2e5397f598e0ec18938a38c4a8 /apps/files_versions
parent768041b6cba5e8d4614e17d2ad492c855ec740a0 (diff)
downloadnextcloud-server-80c850d018baceca3a6197a7c21651c58d0edc25.tar.gz
nextcloud-server-80c850d018baceca3a6197a7c21651c58d0edc25.zip
added revert attempt outcome messages, removed contextual ajax revert button for now as it's not functional, improved readaibility of scripts
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/css/versions.css15
-rw-r--r--apps/files_versions/history.php33
-rw-r--r--apps/files_versions/js/versions.js6
-rw-r--r--apps/files_versions/templates/history.php35
-rw-r--r--apps/files_versions/templates/settings.php2
-rw-r--r--apps/files_versions/versions.php18
6 files changed, 77 insertions, 32 deletions
diff --git a/apps/files_versions/css/versions.css b/apps/files_versions/css/versions.css
index b2279e9b05a..a9b259ce140 100644
--- a/apps/files_versions/css/versions.css
+++ b/apps/files_versions/css/versions.css
@@ -1,3 +1,16 @@
#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;
} \ No newline at end of file
diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php
index 05a5db55daa..5e1949bf540 100644
--- a/apps/files_versions/history.php
+++ b/apps/files_versions/history.php
@@ -24,43 +24,52 @@ require_once( '../../lib/base.php' );
OC_Util::checkLoggedIn( );
OC_Util::addStyle('files_versions','versions');
+$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
if ( isset( $_GET['path'] ) ) {
$path = $_GET['path'];
$path = strip_tags( $path );
+ $tmpl->assign( 'path', $path );
// roll back to old version if button clicked
if( isset( $_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
if( OCA_Versions\Storage::isversioned( $path ) ) {
-
+
$count=999; //show the newest revisions
$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->printPage( );
+ $tmpl->assign( 'versions', array_reverse( $versions ) );
+
}else{
- $tmpl = new OC_Template( 'files_versions', 'history', 'user' );
- $tmpl->assign( 'path', $path);
+
$tmpl->assign( 'message', 'No old versions available' );
- $tmpl->printPage( );
+
}
}else{
- $tmpl = new OC_Template( 'files_versions', 'history', 'user' );
+
$tmpl->assign( 'message', 'No path specified' );
- $tmpl->printPage( );
+
}
+$tmpl->printPage( );
?>
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index a9e60a0cfa6..c2dfcd9f3b6 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -31,11 +31,11 @@ function createVersionsDropdown(filename, files) {
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 += '<option value="">Saved versions</option>';
html += '</select>';
html += '</div>';
- 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="revertFile()" />';
+ html += '<input type="button" value="Revert file..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
html += '<br />';
html += '<input id="link" style="display:none; width:90%;" />';
diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php
index 92a3eb9c07e..2ef0c89e229 100644
--- a/apps/files_versions/templates/history.php
+++ b/apps/files_versions/templates/history.php
@@ -1,24 +1,33 @@
<div id="history">
+
<?php
- if(isset($_['message'])){
+
+if( isset( $_['message'] ) ) {
- if(isset($_['path'])) echo('<strong>File: '.$_['path']).'</strong><br>';
- echo('<strong>'.$_['message']).'</strong><br>';
+ if( isset($_['path'] ) ) echo('<strong>File: '.$_['path'] ).'</strong><br>';
+ echo('<strong>'.$_['message'] ).'</strong><br>';
- }else{
+}else{
- 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 />');
- foreach ( $_['versions'] as $v ){
-
- echo ' ';
- echo OC_Util::formatDate( $v );
- echo ' <a href="history.php?path='.urlencode( $_['path'] ).'&revert='. $v .'" class="button">Revert</a><br /><br />';
-
- }
+ 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('<p><em>You can click on the revert button to revert to the specific verson.</em></p><br />');
+
+ foreach ( $_['versions'] as $v ) {
+
+ echo ' ';
+ echo OC_Util::formatDate( $v );
+ echo ' <a href="history.php?path='.urlencode( $_['path'] ).'&revert='. $v .'" class="button">Revert</a><br /><br />';
+
+ }
+
+}
+
?>
</div>
diff --git a/apps/files_versions/templates/settings.php b/apps/files_versions/templates/settings.php
index 8c8def94429..2f918257360 100644
--- a/apps/files_versions/templates/settings.php
+++ b/apps/files_versions/templates/settings.php
@@ -4,4 +4,4 @@
Configuration goes here...
</fieldset>
-</form>
+</form> \ No newline at end of file
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php
index 167c64a4345..ece84da468d 100644
--- a/apps/files_versions/versions.php
+++ b/apps/files_versions/versions.php
@@ -36,7 +36,7 @@ class Storage {
const DEFAULTFOLDER='versions';
const DEFAULTBLACKLIST='avi mp3 mpg mp4';
const DEFAULTMAXFILESIZE=1048576; // 10MB
- const DEFAULTMININTERVAL=1; // 5 min
+ const DEFAULTMININTERVAL=120; // 2 min
const DEFAULTMAXVERSIONS=50;
/**
@@ -122,12 +122,26 @@ class Storage {
* rollback to an old version of a file.
*/
public static function rollback($filename,$revision) {
+
if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') {
+
$versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OC_User::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER);
+
$filesfoldername=\OC_Config::getValue('datadirectory').'/'. \OC_User::getUser() .'/files';
+
// rollback
- @copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename);
+ if ( @copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename) ) {
+
+ return true;
+
+ }else{
+
+ return false;
+
+ }
+
}
+
}
/**