#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
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( );
?>
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%;" />';
<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>
Configuration goes here...
</fieldset>
-</form>
+</form>
\ No newline at end of file
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;
/**
* 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;
+
+ }
+
}
+
}
/**