]> source.dussan.org Git - nextcloud-server.git/commitdiff
check if some encrypted files are left after the app was disabled and warn the user
authorBjoern Schiessle <schiessle@owncloud.com>
Mon, 12 Aug 2013 15:25:27 +0000 (17:25 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 12 Aug 2013 15:25:27 +0000 (17:25 +0200)
apps/files/index.php
apps/files/js/files.js
apps/files/templates/index.php
lib/public/util.php
lib/util.php
settings/personal.php

index 2f0053915090d43146e4d49a7d739d36dd013c71..57171ac3b5aff3953c7d7e07132a75cdd09f3f68 100644 (file)
@@ -143,5 +143,6 @@ if ($needUpgrade) {
        $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
        $tmpl->assign('isPublic', false);
        $tmpl->assign('publicUploadEnabled', $publicUploadEnabled);
+       $tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles());
        $tmpl->printPage();
 }
index 98fc53b71a9d91d85726a6782d80f0085c5da5bc..d6886fc17e4fd9c54b55e181b58bfa9d70809659 100644 (file)
@@ -81,9 +81,23 @@ Files={
                if (usedSpacePercent > 90) {
                        OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent}));
                }
+       },
+
+       displayEncryptionWarning: function() {
+
+               if (!OC.Notification.isHidden()) {
+                       return;
+               }
+
+               var encryptedFiles = $('#encryptedFiles').val();
+               if (encryptedFiles === '1') {
+                       OC.Notification.show(t('files_encryption', 'Encryption was disabled but your files are still encrypted. Please go to your personal settings to decrypt your files.', "www.schiessle.org"));
+                       return;
+               }
        }
 };
 $(document).ready(function() {
+       Files.displayEncryptionWarning();
        Files.bindKeyboardShortcuts(document, jQuery);
        $('#fileList tr').each(function(){
                //little hack to set unescape filenames in attribute
index e07316093685a379d3b092b584e4832860c9acc6..72bc1e937cc0e3f86525071a2188e384997cdabf 100644 (file)
 <!-- config hints for javascript -->
 <input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php p($_['allowZipDownload']); ?>" />
 <input type="hidden" name="usedSpacePercent" id="usedSpacePercent" value="<?php p($_['usedSpacePercent']); ?>" />
+<input type="hidden" name="encryptedFiles" id="encryptedFiles" value="<?php $_['encryptedFiles'] ? p('1') : p('0'); ?>" />
index 693805946ea3473d050eb2971a1827b97424a5c1..b33f07b55e64396296d06d6cd41b94bee36fce84 100644 (file)
@@ -122,6 +122,14 @@ class Util {
                return(\OC_Util::formatDate( $timestamp, $dateOnly ));
        }
 
+       /**
+        * @brief check if some encrypted files are stored
+        * @return bool
+        */
+       public static function encryptedFiles() {
+               return \OC_Util::encryptedFiles();
+       }
+       
        /**
         * @brief Creates an absolute url
         * @param string $app app
index 2586ad28320eaefc06174fd41ba8bba3b58d34bc..cc432af62afbd821c42f531f55c6a9a3b8eca7d1 100755 (executable)
@@ -312,6 +312,23 @@ class OC_Util {
                return $errors;
        }
 
+       /**
+        * @brief check if there are still some encrypted files stored
+        * @return boolean
+        */
+       public static function encryptedFiles() {
+               //check if encryption was enabled in the past
+               $encryptedFiles = false;
+               if (OC_App::isEnabled('files_encryption') === false) {
+                       $view = new OC\Files\View('/' . OCP\User::getUser());
+                       if ($view->file_exists('/files_encryption/keyfiles')) {
+                               $encryptedFiles = true;
+                       }
+               }
+               
+               return $encryptedFiles;
+       }
+       
        /**
        * Check for correct file permissions of data directory
        * @return array arrays with error messages and hints
index bad19ba03cee8397c32098b7388834a565a1655a..e69898f6f8fcacde6b1550a881ea070f48fd4d68 100644 (file)
@@ -25,13 +25,7 @@ $userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N:
 $languageCodes=OC_L10N::findAvailableLanguages();
 
 //check if encryption was enabled in the past
-$enableDecryptAll = false;
-if (OC_App::isEnabled('files_encryption') === false) {
-       $view = new OC\Files\View('/'.OCP\User::getUser());
-       if($view->file_exists('/files_encryption/keyfiles')) {
-               $enableDecryptAll = true;
-       }
-}
+$enableDecryptAll = OC_Util::encryptedFiles();
 
 // array of common languages
 $commonlangcodes = array(