]> source.dussan.org Git - nextcloud-server.git/commitdiff
added revert attempt outcome messages, removed contextual ajax revert button for...
authorSam Tuke <samtuke@jack-laptop.(none)>
Fri, 27 Apr 2012 12:19:16 +0000 (13:19 +0100)
committerSam Tuke <samtuke@jack-laptop.(none)>
Fri, 27 Apr 2012 12:19:16 +0000 (13:19 +0100)
apps/files_versions/css/versions.css
apps/files_versions/history.php
apps/files_versions/js/versions.js
apps/files_versions/templates/history.php
apps/files_versions/templates/settings.php
apps/files_versions/versions.php

index b2279e9b05ac9662e48249ed6345722209fcaaf5..a9b259ce1405ac7da4393a9baee111186f08c710 100644 (file)
@@ -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
index 05a5db55daa245d2be90791b322dd05792e5139a..5e1949bf540cb5053158924989df2311e6c71c20 100644 (file)
@@ -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( );
 
 ?>
index a9e60a0cfa6c0b43bb15b0a0251b147b4c7ac7f0..c2dfcd9f3b60b937630df88ea18e8f6bb72a86bb 100644 (file)
@@ -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%;" />';
        
index 92a3eb9c07e9cf6399cbc6f864ec1fa28ffc4f46..2ef0c89e22954d57641ced73955f2eb22d1928b1 100644 (file)
@@ -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>
index 8c8def94429d1031f68b2128620704d3ea2e32ca..2f918257360f68b9f570798600edbeef6fff3ff9 100644 (file)
@@ -4,4 +4,4 @@
 
                Configuration goes here...
        </fieldset>
-</form>
+</form>
\ No newline at end of file
index 167c64a4345562b811ed9653ae1115fab11b6ff7..ece84da468d0b7e4a7c30c1f20911af6fbd84fa9 100644 (file)
@@ -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;
+                               
+                       }
+                       
                }
+               
        }
 
        /**