diff options
Diffstat (limited to 'apps')
58 files changed, 1110 insertions, 562 deletions
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index 1f7e42e0d3e..4b4a7f8948d 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -21,12 +21,6 @@ * */ -// only need filesystem apps -$RUNTIME_APPTYPES=array('filesystem'); - -// Init owncloud - - // Check if we are a user OCP\User::checkLoggedIn(); \OC::$session->close(); diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php index 17415b6933f..dd8af39bada 100644 --- a/apps/files/ajax/getstoragestats.php +++ b/apps/files/ajax/getstoragestats.php @@ -1,8 +1,5 @@ <?php -// only need filesystem apps -$RUNTIME_APPTYPES = array('filesystem'); - $dir = '/'; if (isset($_GET['dir'])) { diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 667209599a0..3bb35579d5f 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -1,11 +1,5 @@ <?php -// only need filesystem apps -$RUNTIME_APPTYPES=array('filesystem'); - -// Init owncloud - - OCP\JSON::checkLoggedIn(); \OC::$session->close(); diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php index 6c2569e2ebb..f18bbffb74a 100644 --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -1,8 +1,5 @@ <?php -// only need filesystem apps -$RUNTIME_APPTYPES = array('filesystem'); - OCP\JSON::checkLoggedIn(); \OC::$session->close(); diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index 826f72fb0e6..a8acfdb6e6e 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -22,12 +22,6 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ -// load needed apps -$RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging'); - -OC_App::loadApps($RUNTIME_APPTYPES); - -OC_Util::obEnd(); // Backends $authBackend = new OC_Connector_Sabre_Auth(); diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index f334f29a939..25ab70af362 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -58,7 +58,6 @@ class Scan extends Command { protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('all')) { - \OC_App::loadApps('authentication'); $users = $this->userManager->search(''); } else { $users = $input->getArgument('user_id'); diff --git a/apps/files/css/files.css b/apps/files/css/files.css index af863aca33e..1bac5d2b7db 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -77,10 +77,10 @@ } /* make sure there's enough room for the file actions */ #body-user #filestable { - min-width: 750px; + min-width: 688px; /* 768 (mobile break) - 80 (nav width) */ } #body-user #controls { - min-width: 600px; + min-width: 688px; /* 768 (mobile break) - 80 (nav width) */ } #filestable tbody tr { background-color:#fff; height:40px; } diff --git a/apps/files/css/mobile.css b/apps/files/css/mobile.css new file mode 100644 index 00000000000..3ad7d634838 --- /dev/null +++ b/apps/files/css/mobile.css @@ -0,0 +1,68 @@ +@media only screen and (max-width: 768px) { + +/* don’t require a minimum width for files table */ +#body-user #filestable { + min-width: initial !important; +} + +/* do not show Deleted Files on mobile, not optimized yet and button too long */ +#controls #trash { + display: none; +} + +/* hide size and date columns */ +table th#headerSize, +table td.filesize, +table th#headerDate, +table td.date { + display: none; +} + +/* remove shift for multiselect bar to account for missing navigation */ +table.multiselect thead { + padding-left: 0; +} + +/* restrict length of displayed filename to prevent overflow */ +table td.filename .nametext { + max-width: 75% !important; +} + +/* always show actions on mobile, not only on hover */ +#fileList a.action { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)" !important; + filter: alpha(opacity=20) !important; + opacity: .2 !important; + display: inline !important; +} +/* do not show Rename or Versions on mobile */ +#fileList .action.action-rename, +#fileList .action.action-versions { + display: none !important; +} +/* some padding for better clickability */ +#fileList a.action img { + padding: 0 6px 0 12px; +} +/* hide text of the actions on mobile */ +#fileList a.action span { + display: none; +} + +/* ellipsis on file names */ +.nametext { + width: 60%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +/* proper notification area for multi line messages */ +#notification-container { + display: -webkit-box; + display: -moz-box; + display: -ms-flexbox; + display: -webkit-flex; + display: flex; +} +} diff --git a/apps/files/index.php b/apps/files/index.php index c66cd40fb56..4d765b69e41 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -27,6 +27,7 @@ OCP\User::checkLoggedIn(); // Load the files we need OCP\Util::addStyle('files', 'files'); OCP\Util::addStyle('files', 'upload'); +OCP\Util::addStyle('files', 'mobile'); OCP\Util::addscript('files', 'file-upload'); OCP\Util::addscript('files', 'jquery.iframe-transport'); OCP\Util::addscript('files', 'jquery.fileupload'); @@ -39,7 +40,7 @@ $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : ''; $dir = \OC\Files\Filesystem::normalizePath($dir); $dirInfo = \OC\Files\Filesystem::getFileInfo($dir); // Redirect if directory does not exist -if (!$dirInfo->getType() === 'dir') { +if (!$dirInfo || !$dirInfo->getType() === 'dir') { header('Location: ' . OCP\Util::getScriptName() . ''); exit(); } diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 9a69d7b3688..a7d1fa9d8a2 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -15,21 +15,33 @@ var FileActions = { defaults: {}, icons: {}, currentFile: null, - register: function (mime, name, permissions, icon, action) { + register: function (mime, name, permissions, icon, action, displayName) { if (!FileActions.actions[mime]) { FileActions.actions[mime] = {}; } if (!FileActions.actions[mime][name]) { FileActions.actions[mime][name] = {}; } + if (!displayName) { + displayName = t('files', name); + } FileActions.actions[mime][name]['action'] = action; FileActions.actions[mime][name]['permissions'] = permissions; + FileActions.actions[mime][name]['displayName'] = displayName; FileActions.icons[name] = icon; }, setDefault: function (mime, name) { FileActions.defaults[mime] = name; }, get: function (mime, type, permissions) { + var actions = this.getActions(mime, type, permissions); + var filteredActions = {}; + $.each(actions, function (name, action) { + filteredActions[name] = action.action; + }); + return filteredActions; + }, + getActions: function (mime, type, permissions) { var actions = {}; if (FileActions.actions.all) { actions = $.extend(actions, FileActions.actions.all); @@ -51,7 +63,7 @@ var FileActions = { var filteredActions = {}; $.each(actions, function (name, action) { if (action.permissions & permissions) { - filteredActions[name] = action.action; + filteredActions[name] = action; } }); return filteredActions; @@ -82,7 +94,7 @@ var FileActions = { */ display: function (parent, triggerEvent) { FileActions.currentFile = parent; - var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions()); + var actions = FileActions.getActions(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions()); var file = FileActions.getCurrentFile(); var nameLinks; if (FileList.findFileEl(file).data('renaming')) { @@ -105,15 +117,16 @@ var FileActions = { event.data.actionFunc(file); }; - var addAction = function (name, action) { + var addAction = function (name, action, displayName) { // NOTE: Temporary fix to prevent rename action in root of Shared directory if (name === 'Rename' && $('#dir').val() === '/Shared') { return true; } if ((name === 'Download' || action !== defaultAction) && name !== 'Delete') { + var img = FileActions.icons[name], - actionText = t('files', name), + actionText = displayName, actionContainer = 'a.name>span.fileactions'; if (name === 'Rename') { @@ -125,7 +138,7 @@ var FileActions = { if (img.call) { img = img(file); } - var html = '<a href="#" class="action" data-action="' + name + '">'; + var html = '<a href="#" class="action action-' + name.toLowerCase() + '" data-action="' + name + '">'; if (img) { html += '<img class ="svg" src="' + img + '" />'; } @@ -133,8 +146,7 @@ var FileActions = { var element = $(html); element.data('action', name); - //alert(element); - element.on('click', {a: null, elem: parent, actionFunc: actions[name]}, actionHandler); + element.on('click', {a: null, elem: parent, actionFunc: actions[name].action}, actionHandler); parent.find(actionContainer).append(element); } @@ -142,12 +154,15 @@ var FileActions = { $.each(actions, function (name, action) { if (name !== 'Share') { - addAction(name, action); + displayName = action.displayName; + ah = action.action; + + addAction(name, ah, displayName); } }); if(actions.Share && !($('#dir').val() === '/' && file === 'Shared')){ - // t('files', 'Share') - addAction('Share', actions.Share); + displayName = t('files', 'Share'); + addAction('Share', actions.Share, displayName); } // remove the existing delete action diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 503bf681139..cda4e823a73 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -71,7 +71,7 @@ window.FileList={ }); // filename td td = $('<td></td>').attr({ - "class": "filename", + "class": "filename svg", "style": 'background-image:url('+iconurl+'); background-size: 32px;' }); var rand = Math.random().toString(16).slice(2); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 1186a72a44f..1137364db4a 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -196,11 +196,14 @@ var Files = { if (width !== Files.lastWidth) { if ((width < Files.lastWidth || firstRun) && width < Files.breadcrumbsWidth) { if (Files.hiddenBreadcrumbs === 0) { - Files.breadcrumbsWidth -= $(Files.breadcrumbs[1]).get(0).offsetWidth; - $(Files.breadcrumbs[1]).find('a').hide(); - $(Files.breadcrumbs[1]).append('<span>...</span>'); - Files.breadcrumbsWidth += $(Files.breadcrumbs[1]).get(0).offsetWidth; - Files.hiddenBreadcrumbs = 2; + bc = $(Files.breadcrumbs[1]).get(0); + if (typeof bc != 'undefined') { + Files.breadcrumbsWidth -= bc.offsetWidth; + $(Files.breadcrumbs[1]).find('a').hide(); + $(Files.breadcrumbs[1]).append('<span>...</span>'); + Files.breadcrumbsWidth += bc.offsetWidth; + Files.hiddenBreadcrumbs = 2; + } } var i = Files.hiddenBreadcrumbs; while (width < Files.breadcrumbsWidth && i > 1 && i < Files.breadcrumbs.length - 1) { diff --git a/apps/files/l10n/el.php b/apps/files/l10n/el.php index 9144cf3ea10..c71aa9a35ab 100644 --- a/apps/files/l10n/el.php +++ b/apps/files/l10n/el.php @@ -5,6 +5,7 @@ $TRANSLATIONS = array( "File name cannot be empty." => "Το όνομα αρχείου δεν μπορεί να είναι κενό.", "\"%s\" is an invalid file name." => "Το \"%s\" είναι ένα μη έγκυρο όνομα αρχείου.", "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed." => "Μη έγκυρο όνομα, '\\', '/', '<', '>', ':', '\"', '|', '?' και '*' δεν επιτρέπονται.", +"The target folder has been moved or deleted." => "Ο φάκελος προορισμού έχει μετακινηθεί ή διαγραφεί.", "The name %s is already used in the folder %s. Please choose a different name." => "Το όνομα %s χρησιμοποιείτε ήδη στον φάκελο %s. Παρακαλώ επιλέξτε ένα άλλο όνομα.", "Not a valid source" => "Μη έγκυρη πηγή", "Server is not allowed to open URLs, please check the server configuration" => "Ο διακομιστής δεν επιτρέπεται να ανοίγει URL, παρακαλώ ελέγξτε τις ρυθμίσεις του διακομιστή", @@ -28,6 +29,8 @@ $TRANSLATIONS = array( "Invalid directory." => "Μη έγκυρος φάκελος.", "Files" => "Αρχεία", "Unable to upload {filename} as it is a directory or has 0 bytes" => "Αδυναμία φόρτωσης {filename} καθώς είναι κατάλογος αρχείων ή έχει 0 bytes", +"Total file size {size1} exceeds upload limit {size2}" => "Το συνολικό μέγεθος αρχείου {size1} υπερβαίνει το όριο μεταφόρτωσης {size2}", +"Not enough free space, you are uploading {size1} but only {size2} is left" => "Δεν υπάρχει αρκετός ελεύθερος χώρος, μεταφορτώνετε μέγεθος {size1} αλλά υπάρχει χώρος μόνο {size2}", "Upload cancelled." => "Η αποστολή ακυρώθηκε.", "Could not get result from server." => "Αδυναμία λήψης αποτελέσματος από το διακομιστή.", "File upload is in progress. Leaving the page now will cancel the upload." => "Η αποστολή του αρχείου βρίσκεται σε εξέλιξη. Το κλείσιμο της σελίδας θα ακυρώσει την αποστολή.", diff --git a/apps/files/l10n/pl_PL.php b/apps/files/l10n/pl_PL.php deleted file mode 100644 index b67f67b972e..00000000000 --- a/apps/files/l10n/pl_PL.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php -$TRANSLATIONS = array( -"Save" => "Zapisz" -); -$PLURAL_FORMS = "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/apps/files/l10n/ru.php b/apps/files/l10n/ru.php index 2c0335f3cc3..ac958e5dfd3 100644 --- a/apps/files/l10n/ru.php +++ b/apps/files/l10n/ru.php @@ -3,7 +3,9 @@ $TRANSLATIONS = array( "Could not move %s - File with this name already exists" => "Невозможно переместить %s - файл с таким именем уже существует", "Could not move %s" => "Невозможно переместить %s", "File name cannot be empty." => "Имя файла не может быть пустым.", +"\"%s\" is an invalid file name." => "\"%s\" это не правильное имя файла.", "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed." => "Неправильное имя: символы '\\', '/', '<', '>', ':', '\"', '|', '?' и '*' недопустимы.", +"The target folder has been moved or deleted." => "Целевой каталог был перемещен или удален.", "The name %s is already used in the folder %s. Please choose a different name." => "Имя %s уже используется для каталога %s. Пожалуйста, выберите другое имя.", "Not a valid source" => "Неправильный источник", "Server is not allowed to open URLs, please check the server configuration" => "Сервер не позволяет открывать URL-адреса, пожалуйста, проверьте настройки сервера", @@ -27,6 +29,8 @@ $TRANSLATIONS = array( "Invalid directory." => "Неверный каталог.", "Files" => "Файлы", "Unable to upload {filename} as it is a directory or has 0 bytes" => "Невозможно загрузить {filename}, так как это либо каталог, либо файл нулевого размера", +"Total file size {size1} exceeds upload limit {size2}" => "Полный размер файла {size1} превышает лимит по загрузке {size2}", +"Not enough free space, you are uploading {size1} but only {size2} is left" => "Не достаточно свободного места, Вы загружаете {size1} но осталось только {size2}", "Upload cancelled." => "Загрузка отменена.", "Could not get result from server." => "Не удалось получить ответ от сервера.", "File upload is in progress. Leaving the page now will cancel the upload." => "Идёт загрузка файла. Покинув страницу, вы прервёте загрузку.", @@ -48,6 +52,7 @@ $TRANSLATIONS = array( "_%n file_::_%n files_" => array("%n файл","%n файла","%n файлов"), "{dirs} and {files}" => "{dirs} и {files}", "_Uploading %n file_::_Uploading %n files_" => array("Закачка %n файла","Закачка %n файлов","Закачка %n файлов"), +"\"{name}\" is an invalid file name." => "\"{name}\" это не правильное имя файла.", "Your storage is full, files can not be updated or synced anymore!" => "Ваше хранилище заполнено, произведите очистку перед загрузкой новых файлов.", "Your storage is almost full ({usedSpacePercent}%)" => "Ваше хранилище почти заполнено ({usedSpacePercent}%)", "Encryption App is enabled but your keys are not initialized, please log-out and log-in again" => "Приложение для шифрования активно, но ваши ключи не инициализированы, пожалуйста, перелогиньтесь", diff --git a/apps/files/templates/admin.php b/apps/files/templates/admin.php index a5afd55fbc3..5f7d3261d6c 100644 --- a/apps/files/templates/admin.php +++ b/apps/files/templates/admin.php @@ -1,28 +1,26 @@ <?php OCP\Util::addscript('files', 'admin'); ?> -<form name="filesForm" action='#' method='post'> - <fieldset class="personalblock"> - <h2><?php p($l->t('File handling')); ?></h2> - <?php if($_['uploadChangable']):?> - <label for="maxUploadSize"><?php p($l->t( 'Maximum upload size' )); ?> </label> - <input type="text" name='maxUploadSize' id="maxUploadSize" value='<?php p($_['uploadMaxFilesize']) ?>'/> - <?php if($_['displayMaxPossibleUploadSize']):?> - (<?php p($l->t('max. possible: ')); p($_['maxPossibleUploadSize']) ?>) - <?php endif;?> - <br/> +<form name="filesForm" class="section" action="#" method="post"> + <h2><?php p($l->t('File handling')); ?></h2> + <?php if($_['uploadChangable']):?> + <label for="maxUploadSize"><?php p($l->t( 'Maximum upload size' )); ?> </label> + <input type="text" name='maxUploadSize' id="maxUploadSize" value='<?php p($_['uploadMaxFilesize']) ?>'/> + <?php if($_['displayMaxPossibleUploadSize']):?> + (<?php p($l->t('max. possible: ')); p($_['maxPossibleUploadSize']) ?>) <?php endif;?> - <input type="checkbox" name="allowZipDownload" id="allowZipDownload" value="1" - title="<?php p($l->t( 'Needed for multi-file and folder downloads.' )); ?>" - <?php if ($_['allowZipDownload']): ?> checked="checked"<?php endif; ?> /> - <label for="allowZipDownload"><?php p($l->t( 'Enable ZIP-download' )); ?></label><br/> + <br/> + <?php endif;?> + <input type="checkbox" name="allowZipDownload" id="allowZipDownload" value="1" + title="<?php p($l->t( 'Needed for multi-file and folder downloads.' )); ?>" + <?php if ($_['allowZipDownload']): ?> checked="checked"<?php endif; ?> /> + <label for="allowZipDownload"><?php p($l->t( 'Enable ZIP-download' )); ?></label><br/> - <input type="text" name="maxZipInputSize" id="maxZipInputSize" style="width:180px;" value='<?php p($_['maxZipInputSize']) ?>' - title="<?php p($l->t( '0 is unlimited' )); ?>" - <?php if (!$_['allowZipDownload']): ?> disabled="disabled"<?php endif; ?> /><br /> - <em><?php p($l->t( 'Maximum input size for ZIP files' )); ?> </em><br /> + <input type="text" name="maxZipInputSize" id="maxZipInputSize" style="width:180px;" value='<?php p($_['maxZipInputSize']) ?>' + title="<?php p($l->t( '0 is unlimited' )); ?>" + <?php if (!$_['allowZipDownload']): ?> disabled="disabled"<?php endif; ?> /><br /> + <em><?php p($l->t( 'Maximum input size for ZIP files' )); ?> </em><br /> - <input type="hidden" value="<?php p($_['requesttoken']); ?>" name="requesttoken" /> - <input type="submit" name="submitFilesAdminSettings" id="submitFilesAdminSettings" - value="<?php p($l->t( 'Save' )); ?>"/> - </fieldset> + <input type="hidden" value="<?php p($_['requesttoken']); ?>" name="requesttoken" /> + <input type="submit" name="submitFilesAdminSettings" id="submitFilesAdminSettings" + value="<?php p($l->t( 'Save' )); ?>"/> </form> diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 5b0bad7f341..34acd9c4f51 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -5,15 +5,15 @@ <div id="new" class="button"> <a><?php p($l->t('New'));?></a> <ul> - <li class="icon-filetype-text" + <li class="icon-filetype-text svg" data-type="file" data-newname="<?php p($l->t('New text file')) ?>.txt"> <p><?php p($l->t('Text file'));?></p> </li> - <li class="icon-filetype-folder" + <li class="icon-filetype-folder svg" data-type="folder" data-newname="<?php p($l->t('New folder')) ?>"> <p><?php p($l->t('Folder'));?></p> </li> - <li class="icon-link" data-type="web"> + <li class="icon-link svg" data-type="web"> <p><?php p($l->t('From link'));?></p> </li> </ul> diff --git a/apps/files/templates/part.breadcrumb.php b/apps/files/templates/part.breadcrumb.php index 2a0df622767..69b4cbca10d 100644 --- a/apps/files/templates/part.breadcrumb.php +++ b/apps/files/templates/part.breadcrumb.php @@ -1,4 +1,4 @@ -<div class="crumb <?php if(!count($_["breadcrumb"])) p('last');?>" data-dir=''> +<div class="crumb svg <?php if(!count($_["breadcrumb"])) p('last');?>" data-dir=''> <a href="<?php print_unescaped($_['baseURL']); ?>"> <?php if(isset($_['rootBreadCrumb'])): echo $_['rootBreadCrumb']; diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index ab47de828b9..15a09a29f51 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -2,7 +2,7 @@ <info> <id>files_encryption</id> <name>Encryption</name> - <description>The ownCloud files encryption system provides server side-encryption. After the app was enabled you need to re-login to initialize your encryption keys. Please note that server side encryption requires that the ownCloud server admin can be trusted. The main purpose of this app is the encryption of files that are stored on externally mounted storages.</description> + <description>The ownCloud files encryption system provides server side-encryption. After the app is enabled you need to re-login to initialize your encryption keys. Please note that server side encryption requires that the ownCloud server admin can be trusted. The main purpose of this app is the encryption of files that are stored on externally mounted storages.</description> <licence>AGPL</licence> <author>Sam Tuke, Bjoern Schiessle, Florin Peter</author> <require>4</require> diff --git a/apps/files_encryption/l10n/el.php b/apps/files_encryption/l10n/el.php index ad8617bc6d2..972d7d7138c 100644 --- a/apps/files_encryption/l10n/el.php +++ b/apps/files_encryption/l10n/el.php @@ -16,6 +16,7 @@ $TRANSLATIONS = array( "Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled." => "Παρακαλώ επιβεβαιώστε ότι η PHP 5.3.3 ή νεότερη είναι εγκατεστημένη και ότι το OpenSSL μαζί με το PHP extension είναι ενεργοποιήμένο και έχει ρυθμιστεί σωστά. Προς το παρόν, η εφαρμογή κρυπτογράφησης είναι απενεργοποιημένη.", "Following users are not set up for encryption:" => "Οι κάτωθι χρήστες δεν έχουν ρυθμιστεί για κρυπογράφηση:", "Initial encryption started... This can take some time. Please wait." => "Η αρχική κρυπτογράφηση άρχισε... Αυτό μπορεί να πάρει κάποια ώρα. Παρακαλώ περιμένετε.", +"Initial encryption running... Please try again later." => "Εκτέλεση αρχικής κρυπτογράφησης... Παρακαλώ προσπαθήστε αργότερα.", "Go directly to your " => "Πηγαίνε απευθείας στο ", "personal settings" => "προσωπικές ρυθμίσεις", "Encryption" => "Κρυπτογράφηση", diff --git a/apps/files_encryption/l10n/ru.php b/apps/files_encryption/l10n/ru.php index bce245ce680..ba984868932 100644 --- a/apps/files_encryption/l10n/ru.php +++ b/apps/files_encryption/l10n/ru.php @@ -16,6 +16,7 @@ $TRANSLATIONS = array( "Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled." => "Пожалуйста, убедитесь, что версия PHP 5.3.3 или новее, а также, что OpenSSL и соответствующее расширение PHP включены и правильно настроены. На данный момент приложение шифрования отключено.", "Following users are not set up for encryption:" => "Для следующих пользователей шифрование не настроено:", "Initial encryption started... This can take some time. Please wait." => "Начато начальное шифрование... Это может занять какое-то время. Пожалуйста, подождите.", +"Initial encryption running... Please try again later." => "Работает первоначальное шифрование... Пожалуйста, повторите попытку позже.", "Go directly to your " => "Перейти прямо в", "personal settings" => "персональные настройки", "Encryption" => "Шифрование", diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index bae1fded53d..8fd51178285 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -3,9 +3,10 @@ /** * ownCloud * - * @author Sam Tuke, Robin Appelman - * @copyright 2012 Sam Tuke samtuke@owncloud.com, Robin Appelman - * icewind1991@gmail.com + * @author Bjoern Schiessle, Sam Tuke, Robin Appelman + * @copyright 2012 Sam Tuke <samtuke@owncloud.com> + * 2012 Robin Appelman <icewind1991@gmail.com> + * 2014 Bjoern Schiessle <schiessle@owncloud.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -36,37 +37,40 @@ namespace OCA\Encryption; */ class Proxy extends \OC_FileProxy { - private static $blackList = null; //mimetypes blacklisted from encryption private static $unencryptedSizes = array(); // remember unencrypted size private static $fopenMode = array(); // remember the fopen mode + private static $enableEncryption = false; // Enable encryption for the given path /** * Check if a file requires encryption * @param string $path + * @param string $mode type of access * @return bool * - * Tests if server side encryption is enabled, and file is allowed by blacklists + * Tests if server side encryption is enabled, and if we should call the + * crypt stream wrapper for the given file */ - private static function shouldEncrypt($path) { + private static function shouldEncrypt($path, $mode = 'w') { $userId = Helper::getUser($path); - if (\OCP\App::isEnabled('files_encryption') === false || Crypt::mode() !== 'server' || - strpos($path, '/' . $userId . '/files') !== 0) { + // don't call the crypt stream wrapper, if... + if ( + \OCP\App::isEnabled('files_encryption') === false // encryption is disabled + || Crypt::mode() !== 'server' // we are not in server-side-encryption mode + || strpos($path, '/' . $userId . '/files') !== 0 // path is not in files/ + || substr($path, 0, 8) === 'crypt://' // we are already in crypt mode + ) { return false; } - if (is_null(self::$blackList)) { - self::$blackList = explode(',', \OCP\Config::getAppValue('files_encryption', 'type_blacklist', '')); - } - - if (Crypt::isCatfileContent($path)) { - return true; - } - - $extension = substr($path, strrpos($path, '.') + 1); + $view = new \OC_FilesystemView(''); + $util = new Util($view, $userId); - if (array_search($extension, self::$blackList) === false) { + // for write operation we always encrypt the files, for read operations + // we check if the existing file is encrypted or not decide if it needs to + // decrypt it. + if (($mode !== 'r' && $mode !== 'rb') || $util->isEncryptedPath($path)) { return true; } @@ -128,6 +132,8 @@ class Proxy extends \OC_FileProxy { // re-enable proxy - our work is done \OC_FileProxy::$enabled = $proxyStatus; + } else { + return false; } } } @@ -220,7 +226,10 @@ class Proxy extends \OC_FileProxy { * @param string $mode type of access */ public function preFopen($path, $mode) { + self::$fopenMode[$path] = $mode; + self::$enableEncryption = self::shouldEncrypt($path, $mode); + } @@ -233,26 +242,14 @@ class Proxy extends \OC_FileProxy { $path = \OC\Files\Filesystem::normalizePath($path); - if (!$result) { + if (!$result || self::$enableEncryption === false) { return $result; } - // split the path parts - $pathParts = explode('/', $path); - - // don't try to encrypt/decrypt cache chunks or files in the trash bin - if (isset($pathParts[2]) && ($pathParts[2] === 'cache' || $pathParts[2] === 'files_trashbin')) { - return $result; - } - - // Disable encryption proxy to prevent recursive calls - $proxyStatus = \OC_FileProxy::$enabled; - \OC_FileProxy::$enabled = false; - // if we remember the mode from the pre proxy we re-use it - // oterwise we fall back to stream_get_meta_data() + // otherwise we fall back to stream_get_meta_data() if (isset(self::$fopenMode[$path])) { $mode = self::$fopenMode[$path]; unset(self::$fopenMode[$path]); @@ -261,35 +258,12 @@ class Proxy extends \OC_FileProxy { $mode = $meta['mode']; } - $view = new \OC_FilesystemView(''); - - $userId = Helper::getUser($path); - $util = new Util($view, $userId); + // Close the original encrypted file + fclose($result); - // If file is already encrypted, decrypt using crypto protocol - if ( - Crypt::mode() === 'server' - && $util->isEncryptedPath($path) - ) { - - // Close the original encrypted file - fclose($result); - - // Open the file using the crypto stream wrapper - // protocol and let it do the decryption work instead - $result = fopen('crypt://' . $path, $mode); - - } elseif ( - self::shouldEncrypt($path) - and $mode !== 'r' - and $mode !== 'rb' - - ) { - $result = fopen('crypt://' . $path, $mode); - } - - // Re-enable the proxy - \OC_FileProxy::$enabled = $proxyStatus; + // Open the file using the crypto stream wrapper + // protocol and let it do the decryption work instead + $result = fopen('crypt://' . $path, $mode); return $result; diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php index 58ac03373a7..1a163db887c 100644 --- a/apps/files_encryption/lib/stream.php +++ b/apps/files_encryption/lib/stream.php @@ -568,21 +568,25 @@ class Stream { // part file. $path = Helper::stripPartialFileExtension($this->rawPath); - // get file info - $fileInfo = $this->rootView->getFileInfo($path); - if ($fileInfo) { - // set encryption data - $fileInfo['encrypted'] = true; - $fileInfo['size'] = $this->size; - $fileInfo['unencrypted_size'] = $this->unencryptedSize; - - // set fileinfo - $this->rootView->putFileInfo($path, $fileInfo); - } + $fileInfo = array( + 'encrypted' => true, + 'size' => $this->size, + 'unencrypted_size' => $this->unencryptedSize, + ); + + // set fileinfo + $this->rootView->putFileInfo($path, $fileInfo); } - return fclose($this->handle); + $result = fclose($this->handle); + + if ($result === false) { + \OCP\Util::writeLog('Encryption library', 'Could not close stream, file could be corrupted', \OCP\Util::FATAL); + } + + return $result; + } } diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 3db5a423478..c3058aefa6f 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -432,25 +432,28 @@ class Util { $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; - // we only need 24 byte from the last chunk $data = ''; - $handle = $this->view->fopen($path, 'r'); - if (is_resource($handle)) { - // suppress fseek warining, we handle the case that fseek doesn't - // work in the else branch - if (@fseek($handle, -24, SEEK_END) === 0) { - $data = fgets($handle); - } else { - // if fseek failed on the storage we create a local copy from the file - // and read this one - fclose($handle); - $localFile = $this->view->getLocalFile($path); - $handle = fopen($localFile, 'r'); - if (is_resource($handle) && fseek($handle, -24, SEEK_END) === 0) { + + // we only need 24 byte from the last chunk + if ($this->view->file_exists($path)) { + $handle = $this->view->fopen($path, 'r'); + if (is_resource($handle)) { + // suppress fseek warining, we handle the case that fseek doesn't + // work in the else branch + if (@fseek($handle, -24, SEEK_END) === 0) { $data = fgets($handle); + } else { + // if fseek failed on the storage we create a local copy from the file + // and read this one + fclose($handle); + $localFile = $this->view->getLocalFile($path); + $handle = fopen($localFile, 'r'); + if (is_resource($handle) && fseek($handle, -24, SEEK_END) === 0) { + $data = fgets($handle); + } } + fclose($handle); } - fclose($handle); } // re-enable proxy diff --git a/apps/files_encryption/templates/settings-admin.php b/apps/files_encryption/templates/settings-admin.php index 231a68b6a58..cf676c445ce 100644 --- a/apps/files_encryption/templates/settings-admin.php +++ b/apps/files_encryption/templates/settings-admin.php @@ -1,63 +1,60 @@ -<form id="encryption"> - <fieldset class="personalblock"> +<form id="encryption" class="section"> + <h2><?php p($l->t('Encryption')); ?></h2> - <h2><?php p($l->t('Encryption')); ?></h2> + <p> + <?php p($l->t("Enable recovery key (allow to recover users files in case of password loss):")); ?> + <br/> + <br/> + <input type="password" name="encryptionRecoveryPassword" id="encryptionRecoveryPassword"/> + <label for="recoveryPassword"><?php p($l->t("Recovery key password")); ?></label> + <br/> + <input type="password" name="encryptionRecoveryPassword" id="repeatEncryptionRecoveryPassword"/> + <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat Recovery key password")); ?></label> + <br/> + <input + type='radio' + name='adminEnableRecovery' + value='1' + <?php echo($_["recoveryEnabled"] === '1' ? 'checked="checked"' : 'disabled'); ?> /> + <?php p($l->t("Enabled")); ?> + <br/> - <p> - <?php p($l->t("Enable recovery key (allow to recover users files in case of password loss):")); ?> - <br/> - <br/> - <input type="password" name="encryptionRecoveryPassword" id="encryptionRecoveryPassword"/> - <label for="recoveryPassword"><?php p($l->t("Recovery key password")); ?></label> - <br/> - <input type="password" name="encryptionRecoveryPassword" id="repeatEncryptionRecoveryPassword"/> - <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat Recovery key password")); ?></label> - <br/> - <input - type='radio' - name='adminEnableRecovery' - value='1' - <?php echo($_["recoveryEnabled"] === '1' ? 'checked="checked"' : 'disabled'); ?> /> - <?php p($l->t("Enabled")); ?> - <br/> + <input + type='radio' + name='adminEnableRecovery' + value='0' + <?php echo($_["recoveryEnabled"] === '0' ? 'checked="checked"' : 'disabled'); ?> /> + <?php p($l->t("Disabled")); ?> + </p> + <br/><br/> - <input - type='radio' - name='adminEnableRecovery' - value='0' - <?php echo($_["recoveryEnabled"] === '0' ? 'checked="checked"' : 'disabled'); ?> /> - <?php p($l->t("Disabled")); ?> - </p> + <p name="changeRecoveryPasswordBlock" <?php if ($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> + <strong><?php p($l->t("Change recovery key password:")); ?></strong> <br/><br/> - - <p name="changeRecoveryPasswordBlock" <?php if ($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> - <strong><?php p($l->t("Change recovery key password:")); ?></strong> - <br/><br/> - <input - type="password" - name="changeRecoveryPassword" - id="oldEncryptionRecoveryPassword" - <label for="oldEncryptionRecoveryPassword"><?php p($l->t("Old Recovery key password")); ?></label> - <br/> - <br/> - <input - type="password" - name="changeRecoveryPassword" - id="newEncryptionRecoveryPassword" - <label for="newEncryptionRecoveryPassword"><?php p($l->t("New Recovery key password")); ?></label> - <br/> - <input - type="password" - name="changeRecoveryPassword" - id="repeatedNewEncryptionRecoveryPassword" - <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat New Recovery key password")); ?></label> - <br/> - <button - type="button" - name="submitChangeRecoveryKey" - disabled><?php p($l->t("Change Password")); ?> - </button> - <span class="msg"></span> - </p> - </fieldset> + <input + type="password" + name="changeRecoveryPassword" + id="oldEncryptionRecoveryPassword" + <label for="oldEncryptionRecoveryPassword"><?php p($l->t("Old Recovery key password")); ?></label> + <br/> + <br/> + <input + type="password" + name="changeRecoveryPassword" + id="newEncryptionRecoveryPassword" + <label for="newEncryptionRecoveryPassword"><?php p($l->t("New Recovery key password")); ?></label> + <br/> + <input + type="password" + name="changeRecoveryPassword" + id="repeatedNewEncryptionRecoveryPassword" + <label for="repeatEncryptionRecoveryPassword"><?php p($l->t("Repeat New Recovery key password")); ?></label> + <br/> + <button + type="button" + name="submitChangeRecoveryKey" + disabled><?php p($l->t("Change Password")); ?> + </button> + <span class="msg"></span> + </p> </form> diff --git a/apps/files_encryption/templates/settings-personal.php b/apps/files_encryption/templates/settings-personal.php index 1b4239d82cd..8139ece1950 100644 --- a/apps/files_encryption/templates/settings-personal.php +++ b/apps/files_encryption/templates/settings-personal.php @@ -1,66 +1,63 @@ -<form id="encryption">
- <fieldset class="personalblock">
- <h2><?php p( $l->t( 'Encryption' ) ); ?></h2>
+<form id="encryption" class="section">
+ <h2><?php p( $l->t( 'Encryption' ) ); ?></h2>
- <?php if ( $_["initialized"] === '1' ): ?>
- <p>
- <a name="changePKPasswd" />
- <label for="changePrivateKeyPasswd">
- <?php p( $l->t( "Your private key password no longer match your log-in password:" ) ); ?>
- </label>
- <br />
- <em><?php p( $l->t( "Set your old private key password to your current log-in password." ) ); ?>
- <?php if ( $_["recoveryEnabledForUser"] ):
- p( $l->t( " If you don't remember your old password you can ask your administrator to recover your files." ) );
- endif; ?>
- </em>
- <br />
- <input
- type="password"
- name="changePrivateKeyPassword"
- id="oldPrivateKeyPassword" />
- <label for="oldPrivateKeyPassword"><?php p($l->t( "Old log-in password" )); ?></label>
- <br />
- <input
- type="password"
- name="changePrivateKeyPassword"
- id="newPrivateKeyPassword" />
- <label for="newRecoveryPassword"><?php p($l->t( "Current log-in password" )); ?></label>
- <br />
- <button
- type="button"
- name="submitChangePrivateKeyPassword"
- disabled><?php p($l->t( "Update Private Key Password" )); ?>
- </button>
- <span class="msg"></span>
- </p>
- <?php endif; ?>
-
- <?php if ( $_["recoveryEnabled"] && $_["privateKeySet"] ): ?>
+ <?php if ( $_["initialized"] === '1' ): ?>
+ <p>
+ <a name="changePKPasswd" />
+ <label for="changePrivateKeyPasswd">
+ <?php p( $l->t( "Your private key password no longer match your log-in password:" ) ); ?>
+ </label>
+ <br />
+ <em><?php p( $l->t( "Set your old private key password to your current log-in password." ) ); ?>
+ <?php if ( $_["recoveryEnabledForUser"] ):
+ p( $l->t( " If you don't remember your old password you can ask your administrator to recover your files." ) );
+ endif; ?>
+ </em>
+ <br />
+ <input
+ type="password"
+ name="changePrivateKeyPassword"
+ id="oldPrivateKeyPassword" />
+ <label for="oldPrivateKeyPassword"><?php p($l->t( "Old log-in password" )); ?></label>
+ <br />
+ <input
+ type="password"
+ name="changePrivateKeyPassword"
+ id="newPrivateKeyPassword" />
+ <label for="newRecoveryPassword"><?php p($l->t( "Current log-in password" )); ?></label>
<br />
- <p>
- <label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label>
- <br />
- <em><?php p( $l->t( "Enabling this option will allow you to reobtain access to your encrypted files in case of password loss" ) ); ?></em>
- <br />
- <input
- type='radio'
- name='userEnableRecovery'
- value='1'
- <?php echo ( $_["recoveryEnabledForUser"] == 1 ? 'checked="checked"' : '' ); ?> />
- <?php p( $l->t( "Enabled" ) ); ?>
- <br />
+ <button
+ type="button"
+ name="submitChangePrivateKeyPassword"
+ disabled><?php p($l->t( "Update Private Key Password" )); ?>
+ </button>
+ <span class="msg"></span>
+ </p>
+ <?php endif; ?>
- <input
- type='radio'
- name='userEnableRecovery'
- value='0'
- <?php echo ( $_["recoveryEnabledForUser"] == 0 ? 'checked="checked"' : '' ); ?> />
- <?php p( $l->t( "Disabled" ) ); ?>
- <div id="recoveryEnabledSuccess"><?php p( $l->t( 'File recovery settings updated' ) ); ?></div>
- <div id="recoveryEnabledError"><?php p( $l->t( 'Could not update file recovery' ) ); ?></div>
- </p>
- <?php endif; ?>
+ <?php if ( $_["recoveryEnabled"] && $_["privateKeySet"] ): ?>
+ <br />
+ <p>
+ <label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label>
+ <br />
+ <em><?php p( $l->t( "Enabling this option will allow you to reobtain access to your encrypted files in case of password loss" ) ); ?></em>
+ <br />
+ <input
+ type='radio'
+ name='userEnableRecovery'
+ value='1'
+ <?php echo ( $_["recoveryEnabledForUser"] == 1 ? 'checked="checked"' : '' ); ?> />
+ <?php p( $l->t( "Enabled" ) ); ?>
+ <br />
- </fieldset>
+ <input
+ type='radio'
+ name='userEnableRecovery'
+ value='0'
+ <?php echo ( $_["recoveryEnabledForUser"] == 0 ? 'checked="checked"' : '' ); ?> />
+ <?php p( $l->t( "Disabled" ) ); ?>
+ <div id="recoveryEnabledSuccess"><?php p( $l->t( 'File recovery settings updated' ) ); ?></div>
+ <div id="recoveryEnabledError"><?php p( $l->t( 'Could not update file recovery' ) ); ?></div>
+ </p>
+ <?php endif; ?>
</form>
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php index be56968ac09..1f57d7cb635 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -100,11 +100,11 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { $this->filename = 'share-tmp.test'; - // we don't want to tests with app files_trashbin enabled - \OC_App::disable('files_trashbin'); - // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); + + // we don't want to tests with app files_trashbin enabled + \OC_App::disable('files_trashbin'); } function tearDown() { diff --git a/apps/files_external/3rdparty/smb4php/smb.php b/apps/files_external/3rdparty/smb4php/smb.php index 656930514f0..e325506fa14 100644 --- a/apps/files_external/3rdparty/smb4php/smb.php +++ b/apps/files_external/3rdparty/smb4php/smb.php @@ -8,6 +8,8 @@ # Homepage: http://www.phpclasses.org/smb4php # # Copyright (c) 2007 Victor M. Varela <vmvarela@gmail.com> +# Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org> +# Copyright (c) 2014 Robin McCorkell <rmccorkell@karoshi.org.uk> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -19,8 +21,6 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -# Addition 17/12/2012 Frank Karlitschek (frank@owncloud.org) -# Addition 17/03/2014 Robin McCorkell (rmccorkell@karoshi.org.uk) # On the official website http://www.phpclasses.org/smb4php the # license is listed as LGPL so we assume that this is # dual-licensed GPL/LGPL @@ -44,6 +44,42 @@ $GLOBALS['__smb_cache'] = array ('stat' => array (), 'dir' => array ()); class smb { + private static $regexp = array ( + '^added interface ip=(.*) bcast=(.*) nmask=(.*)$' => 'skip', + 'Anonymous login successful' => 'skip', + '^Domain=\[(.*)\] OS=\[(.*)\] Server=\[(.*)\]$' => 'skip', + '^\tSharename[ ]+Type[ ]+Comment$' => 'shares', + '^\t---------[ ]+----[ ]+-------$' => 'skip', + '^\tServer [ ]+Comment$' => 'servers', + '^\t---------[ ]+-------$' => 'skip', + '^\tWorkgroup[ ]+Master$' => 'workg', + '^\t(.*)[ ]+(Disk|IPC)[ ]+IPC.*$' => 'skip', + '^\tIPC\\\$(.*)[ ]+IPC' => 'skip', + '^\t(.*)[ ]+(Disk)[ ]+(.*)$' => 'share', + '^\t(.*)[ ]+(Printer)[ ]+(.*)$' => 'skip', + '([0-9]+) blocks of size ([0-9]+)\. ([0-9]+) blocks available' => 'skip', + 'Got a positive name query response from ' => 'skip', + '^(session setup failed): (.*)$' => 'error', + '^(.*): ERRSRV - ERRbadpw' => 'error', + '^Error returning browse list: (.*)$' => 'error', + '^tree connect failed: (.*)$' => 'error', + '^(Connection to .* failed)(.*)$' => 'error-connect', + '^NT_STATUS_(.*) ' => 'error', + '^NT_STATUS_(.*)\$' => 'error', + 'ERRDOS - ERRbadpath \((.*).\)' => 'error', + 'cd (.*): (.*)$' => 'error', + '^cd (.*): NT_STATUS_(.*)' => 'error', + '^\t(.*)$' => 'srvorwg', + '^([0-9]+)[ ]+([0-9]+)[ ]+(.*)$' => 'skip', + '^Job ([0-9]+) cancelled' => 'skip', + '^[ ]+(.*)[ ]+([0-9]+)[ ]+(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[ ](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]+([0-9]+)[ ]+([0-9]{2}:[0-9]{2}:[0-9]{2})[ ]([0-9]{4})$' => 'files', + '^message start: ERRSRV - (ERRmsgoff)' => 'error' + ); + + function getRegexp() { + return self::$regexp; + } + function parse_url ($url) { $pu = parse_url (trim($url)); foreach (array ('domain', 'user', 'pass', 'host', 'port', 'path') as $i) { @@ -75,46 +111,16 @@ class smb { } - function execute ($command, $purl) { + function execute ($command, $purl, $regexp = NULL) { return smb::client ('-d 0 ' . escapeshellarg ('//' . $purl['host'] . '/' . $purl['share']) - . ' -c ' . escapeshellarg ($command), $purl + . ' -c ' . escapeshellarg ($command), $purl, $regexp ); } - function client ($params, $purl) { - - static $regexp = array ( - '^added interface ip=(.*) bcast=(.*) nmask=(.*)$' => 'skip', - 'Anonymous login successful' => 'skip', - '^Domain=\[(.*)\] OS=\[(.*)\] Server=\[(.*)\]$' => 'skip', - '^\tSharename[ ]+Type[ ]+Comment$' => 'shares', - '^\t---------[ ]+----[ ]+-------$' => 'skip', - '^\tServer [ ]+Comment$' => 'servers', - '^\t---------[ ]+-------$' => 'skip', - '^\tWorkgroup[ ]+Master$' => 'workg', - '^\t(.*)[ ]+(Disk|IPC)[ ]+IPC.*$' => 'skip', - '^\tIPC\\\$(.*)[ ]+IPC' => 'skip', - '^\t(.*)[ ]+(Disk)[ ]+(.*)$' => 'share', - '^\t(.*)[ ]+(Printer)[ ]+(.*)$' => 'skip', - '([0-9]+) blocks of size ([0-9]+)\. ([0-9]+) blocks available' => 'skip', - 'Got a positive name query response from ' => 'skip', - '^(session setup failed): (.*)$' => 'error', - '^(.*): ERRSRV - ERRbadpw' => 'error', - '^Error returning browse list: (.*)$' => 'error', - '^tree connect failed: (.*)$' => 'error', - '^(Connection to .* failed)(.*)$' => 'error-connect', - '^NT_STATUS_(.*) ' => 'error', - '^NT_STATUS_(.*)\$' => 'error', - 'ERRDOS - ERRbadpath \((.*).\)' => 'error', - 'cd (.*): (.*)$' => 'error', - '^cd (.*): NT_STATUS_(.*)' => 'error', - '^\t(.*)$' => 'srvorwg', - '^([0-9]+)[ ]+([0-9]+)[ ]+(.*)$' => 'skip', - '^Job ([0-9]+) cancelled' => 'skip', - '^[ ]+(.*)[ ]+([0-9]+)[ ]+(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[ ](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ]+([0-9]+)[ ]+([0-9]{2}:[0-9]{2}:[0-9]{2})[ ]([0-9]{4})$' => 'files', - '^message start: ERRSRV - (ERRmsgoff)' => 'error' - ); + function client ($params, $purl, $regexp = NULL) { + + if ($regexp === NULL) $regexp = smb::$regexp; if (SMB4PHP_AUTHMODE == 'env') { putenv("USER={$purl['user']}%{$purl['pass']}"); diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php index 0e83660f845..aeb7a2cb23a 100644 --- a/apps/files_external/appinfo/app.php +++ b/apps/files_external/appinfo/app.php @@ -1,6 +1,7 @@ <?php /** * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * Copyright (c) 2014 Robin McCorkell <rmccorkell@karoshi.org.uk> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -13,6 +14,7 @@ OC::$CLASSPATH['OC\Files\Storage\OwnCloud'] = 'files_external/lib/owncloud.php'; OC::$CLASSPATH['OC\Files\Storage\Google'] = 'files_external/lib/google.php'; OC::$CLASSPATH['OC\Files\Storage\Swift'] = 'files_external/lib/swift.php'; OC::$CLASSPATH['OC\Files\Storage\SMB'] = 'files_external/lib/smb.php'; +OC::$CLASSPATH['OC\Files\Storage\SMB_OC'] = 'files_external/lib/smb_oc.php'; OC::$CLASSPATH['OC\Files\Storage\AmazonS3'] = 'files_external/lib/amazons3.php'; OC::$CLASSPATH['OC\Files\Storage\Dropbox'] = 'files_external/lib/dropbox.php'; OC::$CLASSPATH['OC\Files\Storage\SFTP'] = 'files_external/lib/sftp.php'; @@ -27,4 +29,5 @@ if (OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes') == ' // connecting hooks OCP\Util::connectHook('OC_Filesystem', 'post_initMountPoints', '\OC_Mount_Config', 'initMountPointsHook'); OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\iRODS', 'login'); +OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\SMB_OC', 'login'); diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index cd2a3103eb7..00793a614c2 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -181,16 +181,21 @@ $(document).ready(function() { $.each(configurations, function(backend, parameters) { if (backend == backendClass) { $.each(parameters['configuration'], function(parameter, placeholder) { - if (placeholder.indexOf('*') != -1) { - td.append('<input type="password" data-parameter="'+parameter+'" placeholder="'+placeholder.substring(1)+'" />'); - } else if (placeholder.indexOf('!') != -1) { + var is_optional = false; + if (placeholder.indexOf('&') === 0) { + is_optional = true; + placeholder = placeholder.substring(1); + } + if (placeholder.indexOf('*') === 0) { + var class_string = is_optional ? ' class="optional"' : ''; + td.append('<input type="password"' + class_string + ' data-parameter="'+parameter+'" placeholder="'+placeholder.substring(1)+'" />'); + } else if (placeholder.indexOf('!') === 0) { td.append('<label><input type="checkbox" data-parameter="'+parameter+'" />'+placeholder.substring(1)+'</label>'); - } else if (placeholder.indexOf('&') != -1) { - td.append('<input type="text" class="optional" data-parameter="'+parameter+'" placeholder="'+placeholder.substring(1)+'" />'); - } else if (placeholder.indexOf('#') != -1) { + } else if (placeholder.indexOf('#') === 0) { td.append('<input type="hidden" data-parameter="'+parameter+'" />'); } else { - td.append('<input type="text" data-parameter="'+parameter+'" placeholder="'+placeholder+'" />'); + var class_string = is_optional ? ' class="optional"' : ''; + td.append('<input type="text"' + class_string + ' data-parameter="'+parameter+'" placeholder="'+placeholder+'" />'); } }); if (parameters['custom'] && $('#externalStorage tbody tr.'+backendClass.replace(/\\/g, '\\\\')).length == 1) { diff --git a/apps/files_external/l10n/el.php b/apps/files_external/l10n/el.php index 4dcd93d7ac8..15f2b3b15ec 100644 --- a/apps/files_external/l10n/el.php +++ b/apps/files_external/l10n/el.php @@ -22,6 +22,7 @@ $TRANSLATIONS = array( "Users" => "Χρήστες", "Delete" => "Διαγραφή", "Enable User External Storage" => "Ενεργοποίηση Εξωτερικού Αποθηκευτικού Χώρου Χρήστη", +"Allow users to mount the following external storage" => "Χορήγηση άδειας στους χρήστες να συνδέσουν τα παρακάτω εξωτερικά μέσα αποθήκευσης", "SSL root certificates" => "Πιστοποιητικά SSL root", "Import Root Certificate" => "Εισαγωγή Πιστοποιητικού Root" ); diff --git a/apps/files_external/l10n/ru.php b/apps/files_external/l10n/ru.php index 66d6f9fa6b8..8ed437839cd 100644 --- a/apps/files_external/l10n/ru.php +++ b/apps/files_external/l10n/ru.php @@ -5,6 +5,7 @@ $TRANSLATIONS = array( "Grant access" => "Предоставление доступа", "Please provide a valid Dropbox app key and secret." => "Пожалуйста, предоставьте действующий ключ Dropbox и пароль.", "Error configuring Google Drive storage" => "Ошибка при настройке хранилища Google Drive", +"Saved" => "Сохранено", "<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Внимание:</b> \"smbclient\" не установлен. Подключение по CIFS/SMB невозможно. Пожалуйста, обратитесь к системному администратору, чтобы установить его.", "<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Внимание:</b> Поддержка FTP не включена в PHP. Подключение по FTP невозможно. Пожалуйста, обратитесь к системному администратору, чтобы включить.", "<b>Warning:</b> The Curl support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV or GoogleDrive is not possible. Please ask your system administrator to install it." => "<b>Внимание:</b> Поддержка Curl в PHP не включена или не установлена. Подключение ownCloud / WebDAV или GoogleDrive невозможно. Попросите вашего системного администратора установить его.", @@ -21,6 +22,7 @@ $TRANSLATIONS = array( "Users" => "Пользователи", "Delete" => "Удалить", "Enable User External Storage" => "Включить пользовательские внешние носители", +"Allow users to mount the following external storage" => "Разрешить пользователям монтировать следующую внешнюю систему хранения данных", "SSL root certificates" => "Корневые сертификаты SSL", "Import Root Certificate" => "Импортировать корневые сертификаты" ); diff --git a/apps/files_external/l10n/sk_SK.php b/apps/files_external/l10n/sk_SK.php index aa288982576..245bcc62aaa 100644 --- a/apps/files_external/l10n/sk_SK.php +++ b/apps/files_external/l10n/sk_SK.php @@ -5,6 +5,7 @@ $TRANSLATIONS = array( "Grant access" => "Povoliť prístup", "Please provide a valid Dropbox app key and secret." => "Zadajte platný kľúč aplikácie a heslo Dropbox", "Error configuring Google Drive storage" => "Chyba pri konfigurácii úložiska Google drive", +"Saved" => "Uložené", "<b>Warning:</b> \"smbclient\" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it." => "<b>Upozornenie:</b> \"smbclient\" nie je nainštalovaný. Nie je možné pripojenie oddielov CIFS/SMB. Požiadajte administrátora systému, nech ho nainštaluje.", "<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it." => "<b>Upozornenie:</b> Podpora FTP v PHP nie je povolená alebo nainštalovaná. Nie je možné pripojenie oddielov FTP. Požiadajte administrátora systému, nech ho nainštaluje.", "<b>Warning:</b> The Curl support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV or GoogleDrive is not possible. Please ask your system administrator to install it." => "<b>Varovanie:</b> nie je nainštalovaná, alebo povolená, podpora Curl v PHP. Nie je možné pripojenie oddielov ownCloud, WebDAV, či GoogleDrive. Prosím požiadajte svojho administrátora systému, nech ju nainštaluje.", diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index ffbab7bca80..472c3963d51 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -5,6 +5,7 @@ * @author Michael Gapczynski * @copyright 2012 Michael Gapczynski mtgap@owncloud.com * @copyright 2014 Vincent Petry <pvince81@owncloud.com> +* @copyright 2014 Robin McCorkell <rmccorkell@karoshi.org.uk> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -122,11 +123,18 @@ class OC_Mount_Config { 'password' => '*Password', 'share' => 'Share', 'root' => '&Root')); + $backends['\OC\Files\Storage\SMB_OC'] = array( + 'backend' => 'SMB / CIFS using OC login', + 'configuration' => array( + 'host' => 'URL', + 'username_as_share' => '!Username as share', + 'share' => '&Share', + 'root' => '&Root')); } } if(OC_Mount_Config::checkcurl()){ - $backends['\OC\Files\Storage\DAV']=array( + $backends['\OC\Files\Storage\DAV']=array( 'backend' => 'WebDAV', 'configuration' => array( 'host' => 'URL', @@ -134,7 +142,7 @@ class OC_Mount_Config { 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure https://')); - $backends['\OC\Files\Storage\OwnCloud']=array( + $backends['\OC\Files\Storage\OwnCloud']=array( 'backend' => 'ownCloud', 'configuration' => array( 'host' => 'URL', @@ -185,7 +193,7 @@ class OC_Mount_Config { * @return array of mount point string as key, mountpoint config as value */ public static function getAbsoluteMountPoints($user) { - $mountPoints = array(); + $mountPoints = array(); $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); $mount_file = \OC_Config::getValue("mount_file", $datadir . "/mount.json"); @@ -304,18 +312,23 @@ class OC_Mount_Config { $mount['options'] = self::decryptPasswords($mount['options']); // Remove '/$user/files/' from mount point $mountPoint = substr($mountPoint, 13); - // Merge the mount point into the current mount points - if (isset($system[$mountPoint]) && $system[$mountPoint]['configuration'] == $mount['options']) { - $system[$mountPoint]['applicable']['groups'] - = array_merge($system[$mountPoint]['applicable']['groups'], array($group)); + + $config = array( + 'class' => $mount['class'], + 'mountpoint' => $mountPoint, + 'backend' => $backends[$mount['class']]['backend'], + 'options' => $mount['options'], + 'applicable' => array('groups' => array($group), 'users' => array()), + 'status' => self::getBackendStatus($mount['class'], $mount['options'], false) + ); + $hash = self::makeConfigHash($config); + // If an existing config exists (with same class, mountpoint and options) + if (isset($system[$hash])) { + // add the groups into that config + $system[$hash]['applicable']['groups'] + = array_merge($system[$hash]['applicable']['groups'], array($group)); } else { - $system[$mountPoint] = array( - 'class' => $mount['class'], - 'backend' => $backends[$mount['class']]['backend'], - 'configuration' => $mount['options'], - 'applicable' => array('groups' => array($group), 'users' => array()), - 'status' => self::getBackendStatus($mount['class'], $mount['options']) - ); + $system[$hash] = $config; } } } @@ -330,23 +343,27 @@ class OC_Mount_Config { $mount['options'] = self::decryptPasswords($mount['options']); // Remove '/$user/files/' from mount point $mountPoint = substr($mountPoint, 13); - // Merge the mount point into the current mount points - if (isset($system[$mountPoint]) && $system[$mountPoint]['configuration'] == $mount['options']) { - $system[$mountPoint]['applicable']['users'] - = array_merge($system[$mountPoint]['applicable']['users'], array($user)); + $config = array( + 'class' => $mount['class'], + 'mountpoint' => $mountPoint, + 'backend' => $backends[$mount['class']]['backend'], + 'options' => $mount['options'], + 'applicable' => array('groups' => array(), 'users' => array($user)), + 'status' => self::getBackendStatus($mount['class'], $mount['options'], false) + ); + $hash = self::makeConfigHash($config); + // If an existing config exists (with same class, mountpoint and options) + if (isset($system[$hash])) { + // add the users into that config + $system[$hash]['applicable']['users'] + = array_merge($system[$hash]['applicable']['users'], array($user)); } else { - $system[$mountPoint] = array( - 'class' => $mount['class'], - 'backend' => $backends[$mount['class']]['backend'], - 'configuration' => $mount['options'], - 'applicable' => array('groups' => array(), 'users' => array($user)), - 'status' => self::getBackendStatus($mount['class'], $mount['options']) - ); + $system[$hash] = $config; } } } } - return $system; + return array_values($system); } /** @@ -366,12 +383,13 @@ class OC_Mount_Config { $mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15); } $mount['options'] = self::decryptPasswords($mount['options']); - // Remove '/uid/files/' from mount point - $personal[substr($mountPoint, strlen($uid) + 8)] = array( + $personal[] = array( 'class' => $mount['class'], + // Remove '/uid/files/' from mount point + 'mountpoint' => substr($mountPoint, strlen($uid) + 8), 'backend' => $backends[$mount['class']]['backend'], - 'configuration' => $mount['options'], - 'status' => self::getBackendStatus($mount['class'], $mount['options']) + 'options' => $mount['options'], + 'status' => self::getBackendStatus($mount['class'], $mount['options'], true) ); } } @@ -384,7 +402,7 @@ class OC_Mount_Config { * @param array $options backend configuration options * @return bool true if the connection succeeded, false otherwise */ - private static function getBackendStatus($class, $options) { + private static function getBackendStatus($class, $options, $isPersonal) { if (self::$skipTest) { return true; } @@ -394,7 +412,7 @@ class OC_Mount_Config { if (class_exists($class)) { try { $storage = new $class($options); - return $storage->test(); + return $storage->test($isPersonal); } catch (Exception $exception) { \OCP\Util::logException('files_external', $exception); return false; @@ -461,7 +479,7 @@ class OC_Mount_Config { $mountPoints[$mountType] = $mount; } self::writeData($isPersonal, $mountPoints); - return self::getBackendStatus($class, $classOptions); + return self::getBackendStatus($class, $classOptions, $isPersonal); } /** @@ -538,7 +556,12 @@ class OC_Mount_Config { $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/'); $file = \OC_Config::getValue('mount_file', $datadir . '/mount.json'); } - $content = json_encode($data); + $options = 0; + if (defined('JSON_PRETTY_PRINT')) { + // only for PHP >= 5.4 + $options = JSON_PRETTY_PRINT; + } + $content = json_encode($data, $options); @file_put_contents($file, $content); @chmod($file, 0640); } @@ -707,4 +730,20 @@ class OC_Mount_Config { $cipher->setKey(\OCP\Config::getSystemValue('passwordsalt')); return $cipher; } + + /** + * Computes a hash based on the given configuration. + * This is mostly used to find out whether configurations + * are the same. + */ + private static function makeConfigHash($config) { + $data = json_encode( + array( + 'c' => $config['class'], + 'm' => $config['mountpoint'], + 'o' => $config['options'] + ) + ); + return hash('md5', $data); + } } diff --git a/apps/files_external/lib/smb_oc.php b/apps/files_external/lib/smb_oc.php new file mode 100644 index 00000000000..0c79c06c5df --- /dev/null +++ b/apps/files_external/lib/smb_oc.php @@ -0,0 +1,93 @@ +<?php +/** + * Copyright (c) 2014 Robin McCorkell <rmccorkell@karoshi.org.uk> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Storage; + +require_once __DIR__ . '/../3rdparty/smb4php/smb.php'; + +class SMB_OC extends \OC\Files\Storage\SMB { + private $username_as_share; + + public function __construct($params) { + if (isset($params['host']) && \OC::$session->exists('smb-credentials')) { + $host=$params['host']; + $this->username_as_share = ($params['username_as_share'] === 'true'); + + $params_auth = \OC::$session->get('smb-credentials'); + $user = \OC::$session->get('loginname'); + $password = $params_auth['password']; + + $root=isset($params['root'])?$params['root']:'/'; + $share = ''; + + if ($this->username_as_share) { + $share = '/'.$user; + } elseif (isset($params['share'])) { + $share = $params['share']; + } else { + throw new \Exception(); + } + parent::__construct(array( + "user" => $user, + "password" => $password, + "host" => $host, + "share" => $share, + "root" => $root + )); + } else { + throw new \Exception(); + } + } + + public static function login( $params ) { + \OC::$session->set('smb-credentials', $params); + } + + public function isSharable($path) { + return false; + } + + public function test($isPersonal = true) { + if ($isPersonal) { + if ($this->stat('')) { + return true; + } + return false; + } else { + $smb = new \smb(); + $pu = $smb->parse_url($this->constructUrl('')); + + // Attempt to connect anonymously + $pu['user'] = ''; + $pu['pass'] = ''; + + // Share cannot be checked if dynamic + if ($this->username_as_share) { + if ($smb->look($pu)) { + return true; + } else { + return false; + } + } + if (!$pu['share']) { + return false; + } + + // The following error messages are expected due to anonymous login + $regexp = array( + '(NT_STATUS_ACCESS_DENIED)' => 'skip' + ) + $smb->getRegexp(); + + if ($smb->client("-d 0 " . escapeshellarg('//' . $pu['host'] . '/' . $pu['share']) . " -c exit", $pu, $regexp)) { + return true; + } else { + return false; + } + } + } +} diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 7a56fcfc8b7..1337d9f581d 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -251,6 +251,10 @@ class Swift extends \OC\Files\Storage\Common { $mtime = $object->extra_headers['X-Object-Meta-Timestamp']; } + if (!empty($mtime)) { + $mtime = floor($mtime); + } + $stat = array(); $stat['size'] = $object->content_length; $stat['mtime'] = $mtime; @@ -370,7 +374,7 @@ class Swift extends \OC\Files\Storage\Common { 'X-Object-Meta-Timestamp' => $mtime ) ); - return $object->Update($settings); + return $object->UpdateMetadata($settings); } else { $object = $this->container->DataObject(); if (is_null($mtime)) { diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index de44d3c8644..e8815acaf16 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -1,149 +1,152 @@ -<form id="files_external"> - <fieldset class="personalblock"> +<form id="files_external" class="section"> <h2><?php p($l->t('External Storage')); ?></h2> - <?php if (isset($_['dependencies']) and ($_['dependencies']<>'')) print_unescaped(''.$_['dependencies'].''); ?> - <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['isAdminPage'])); ?>'> - <thead> - <tr> - <th></th> - <th><?php p($l->t('Folder name')); ?></th> - <th><?php p($l->t('External storage')); ?></th> - <th><?php p($l->t('Configuration')); ?></th> - <!--<th><?php p($l->t('Options')); ?></th> --> - <?php if ($_['isAdminPage']) print_unescaped('<th>'.$l->t('Applicable').'</th>'); ?> - <th> </th> - </tr> - </thead> - <tbody width="100%"> - <?php $_['mounts'] = array_merge($_['mounts'], array('' => array())); ?> - <?php foreach ($_['mounts'] as $mountPoint => $mount): ?> - <tr <?php print_unescaped(($mountPoint != '') ? 'class="'.OC_Util::sanitizeHTML($mount['class']).'"' : 'id="addMountPoint"'); ?>> - <td class="status"> - <?php if (isset($mount['status'])): ?> - <span class="<?php p(($mount['status']) ? 'success' : 'error'); ?>"></span> - <?php endif; ?> + <?php if (isset($_['dependencies']) and ($_['dependencies']<>'')) print_unescaped(''.$_['dependencies'].''); ?> + <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['isAdminPage'])); ?>'> + <thead> + <tr> + <th></th> + <th><?php p($l->t('Folder name')); ?></th> + <th><?php p($l->t('External storage')); ?></th> + <th><?php p($l->t('Configuration')); ?></th> + <!--<th><?php p($l->t('Options')); ?></th> --> + <?php if ($_['isAdminPage']) print_unescaped('<th>'.$l->t('Available for').'</th>'); ?> + <th> </th> + </tr> + </thead> + <tbody width="100%"> + <?php $_['mounts'] = array_merge($_['mounts'], array('' => array())); ?> + <?php foreach ($_['mounts'] as $mount): ?> + <tr <?php print_unescaped(($mount['mountpoint'] !== '') ? 'class="'.OC_Util::sanitizeHTML($mount['class']).'"' : 'id="addMountPoint"'); ?>> + <td class="status"> + <?php if (isset($mount['status'])): ?> + <span class="<?php p(($mount['status']) ? 'success' : 'error'); ?>"></span> + <?php endif; ?> + </td> + <td class="mountPoint"><input type="text" name="mountPoint" + value="<?php p($mount['mountpoint']); ?>" + placeholder="<?php p($l->t('Folder name')); ?>" /></td> + <?php if ($mount['mountpoint'] == ''): ?> + <td class="backend"> + <select id="selectBackend" data-configurations='<?php print_unescaped(json_encode($_['backends'])); ?>'> + <option value="" disabled selected + style="display:none;"><?php p($l->t('Add storage')); ?></option> + <?php foreach ($_['backends'] as $class => $backend): ?> + <option value="<?php p($class); ?>"><?php p($backend['backend']); ?></option> + <?php endforeach; ?> + </select> </td> - <td class="mountPoint"><input type="text" name="mountPoint" - value="<?php p($mountPoint); ?>" - placeholder="<?php p($l->t('Folder name')); ?>" /></td> - <?php if ($mountPoint == ''): ?> - <td class="backend"> - <select id="selectBackend" data-configurations='<?php print_unescaped(json_encode($_['backends'])); ?>'> - <option value="" disabled selected - style="display:none;"><?php p($l->t('Add storage')); ?></option> - <?php foreach ($_['backends'] as $class => $backend): ?> - <option value="<?php p($class); ?>"><?php p($backend['backend']); ?></option> - <?php endforeach; ?> - </select> - </td> - <?php else: ?> - <td class="backend" - data-class="<?php p($mount['class']); ?>"><?php p($mount['backend']); ?></td> - <?php endif; ?> - <td class ="configuration" width="100%"> - <?php if (isset($mount['configuration'])): ?> - <?php foreach ($mount['configuration'] as $parameter => $value): ?> - <?php if (isset($_['backends'][$mount['class']]['configuration'][$parameter])): ?> - <?php $placeholder = $_['backends'][$mount['class']]['configuration'][$parameter]; ?> - <?php if (strpos($placeholder, '*') !== false): ?> - <input type="password" - data-parameter="<?php p($parameter); ?>" - value="<?php p($value); ?>" - placeholder="<?php p(substr($placeholder, 1)); ?>" /> - <?php elseif (strpos($placeholder, '!') !== false): ?> - <label><input type="checkbox" - data-parameter="<?php p($parameter); ?>" - <?php if ($value == 'true'): ?> checked="checked"<?php endif; ?> - /><?php p(substr($placeholder, 1)); ?></label> - <?php elseif (strpos($placeholder, '&') !== false): ?> - <input type="text" - class="optional" - data-parameter="<?php p($parameter); ?>" - value="<?php p($value); ?>" - placeholder="<?php p(substr($placeholder, 1)); ?>" /> - <?php elseif (strpos($placeholder, '#') !== false): ?> - <input type="hidden" - data-parameter="<?php p($parameter); ?>" - value="<?php p($value); ?>" /> - <?php else: ?> - <input type="text" - data-parameter="<?php p($parameter); ?>" - value="<?php p($value); ?>" - placeholder="<?php p($placeholder); ?>" /> - <?php endif; ?> + <?php else: ?> + <td class="backend" + data-class="<?php p($mount['class']); ?>"><?php p($mount['backend']); ?></td> + <?php endif; ?> + <td class ="configuration" width="100%"> + <?php if (isset($mount['options'])): ?> + <?php foreach ($mount['options'] as $parameter => $value): ?> + <?php if (isset($_['backends'][$mount['class']]['configuration'][$parameter])): ?> + <?php + $placeholder = $_['backends'][$mount['class']]['configuration'][$parameter]; + $is_optional = FALSE; + if (strpos($placeholder, '&') === 0) { + $is_optional = TRUE; + $placeholder = substr($placeholder, 1); + } + ?> + <?php if (strpos($placeholder, '*') === 0): ?> + <input type="password" + <?php if ($is_optional): ?> class="optional"<?php endif; ?> + data-parameter="<?php p($parameter); ?>" + value="<?php p($value); ?>" + placeholder="<?php p(substr($placeholder, 1)); ?>" /> + <?php elseif (strpos($placeholder, '!') === 0): ?> + <label><input type="checkbox" + data-parameter="<?php p($parameter); ?>" + <?php if ($value == 'true'): ?> checked="checked"<?php endif; ?> + /><?php p(substr($placeholder, 1)); ?></label> + <?php elseif (strpos($placeholder, '#') === 0): ?> + <input type="hidden" + data-parameter="<?php p($parameter); ?>" + value="<?php p($value); ?>" /> + <?php else: ?> + <input type="text" + <?php if ($is_optional): ?> class="optional"<?php endif; ?> + data-parameter="<?php p($parameter); ?>" + value="<?php p($value); ?>" + placeholder="<?php p($placeholder); ?>" /> <?php endif; ?> - <?php endforeach; ?> - <?php if (isset($_['backends'][$mount['class']]['custom']) && !in_array('files_external/js/'.$_['backends'][$mount['class']]['custom'], \OC_Util::$scripts)): ?> - <?php OCP\Util::addScript('files_external', $_['backends'][$mount['class']]['custom']); ?> <?php endif; ?> + <?php endforeach; ?> + <?php if (isset($_['backends'][$mount['class']]['custom']) && !in_array('files_external/js/'.$_['backends'][$mount['class']]['custom'], \OC_Util::$scripts)): ?> + <?php OCP\Util::addScript('files_external', $_['backends'][$mount['class']]['custom']); ?> <?php endif; ?> - </td> - <?php if ($_['isAdminPage']): ?> - <td class="applicable" - align="right" - data-applicable-groups='<?php if (isset($mount['applicable']['groups'])) - print_unescaped(json_encode($mount['applicable']['groups'])); ?>' - data-applicable-users='<?php if (isset($mount['applicable']['users'])) - print_unescaped(json_encode($mount['applicable']['users'])); ?>'> - <select class="chzn-select" - multiple style="width:20em;" - data-placeholder="<?php p($l->t('None set')); ?>"> - <option value="all" <?php if (isset($mount['applicable']['users']) && in_array('all', $mount['applicable']['users'])) print_unescaped('selected="selected"');?> ><?php p($l->t('All Users')); ?></option> - <optgroup label="<?php p($l->t('Groups')); ?>"> - <?php foreach ($_['groups'] as $group): ?> - <option value="<?php p($group); ?>(group)" - <?php if (isset($mount['applicable']['groups']) && in_array($group, $mount['applicable']['groups'])): ?> - selected="selected" - <?php endif; ?>><?php p($group); ?></option> - <?php endforeach; ?> - </optgroup> - <optgroup label="<?php p($l->t('Users')); ?>"> - <?php foreach ($_['users'] as $user): ?> - <option value="<?php p($user); ?>" - <?php if (isset($mount['applicable']['users']) && in_array($user, $mount['applicable']['users'])): ?> - selected="selected" - <?php endif; ?>><?php p($_['userDisplayNames'][$user]); ?></option> - <?php endforeach; ?> - </optgroup> - </select> - </td> <?php endif; ?> - <td <?php if ($mountPoint != ''): ?>class="remove" - <?php else: ?>style="visibility:hidden;" - <?php endif ?>><img alt="<?php p($l->t('Delete')); ?>" - title="<?php p($l->t('Delete')); ?>" - class="svg action" - src="<?php print_unescaped(image_path('core', 'actions/delete.svg')); ?>" /></td> - </tr> - <?php endforeach; ?> - </tbody> - </table> - <br /> + </td> + <?php if ($_['isAdminPage']): ?> + <td class="applicable" + align="right" + data-applicable-groups='<?php if (isset($mount['applicable']['groups'])) + print_unescaped(json_encode($mount['applicable']['groups'])); ?>' + data-applicable-users='<?php if (isset($mount['applicable']['users'])) + print_unescaped(json_encode($mount['applicable']['users'])); ?>'> + <select class="chzn-select" + multiple style="width:20em;" + data-placeholder="<?php p($l->t('No user or group')); ?>"> + <option value="all" + <?php if (empty($mount['class']) || (isset($mount['applicable']['users']) && in_array('all', $mount['applicable']['users']))) print_unescaped('selected="selected"');?> > + <?php p($l->t('All Users')); ?> + </option> + <optgroup label="<?php p($l->t('Groups')); ?>"> + <?php foreach ($_['groups'] as $group): ?> + <option value="<?php p($group); ?>(group)" + <?php if (isset($mount['applicable']['groups']) && in_array($group, $mount['applicable']['groups'])): ?> + selected="selected" + <?php endif; ?>><?php p($group); ?></option> + <?php endforeach; ?> + </optgroup> + <optgroup label="<?php p($l->t('Users')); ?>"> + <?php foreach ($_['users'] as $user): ?> + <option value="<?php p($user); ?>" + <?php if (isset($mount['applicable']['users']) && in_array($user, $mount['applicable']['users'])): ?> + selected="selected" + <?php endif; ?>><?php p($_['userDisplayNames'][$user]); ?></option> + <?php endforeach; ?> + </optgroup> + </select> + </td> + <?php endif; ?> + <td <?php if ($mount['mountpoint'] != ''): ?>class="remove" + <?php else: ?>style="visibility:hidden;" + <?php endif ?>><img alt="<?php p($l->t('Delete')); ?>" + title="<?php p($l->t('Delete')); ?>" + class="svg action" + src="<?php print_unescaped(image_path('core', 'actions/delete.svg')); ?>" /></td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + <br /> - <?php if ($_['isAdminPage']): ?> - <br /> - <input type="checkbox" name="allowUserMounting" id="allowUserMounting" - value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> /> - <label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label> <span id="userMountingMsg" class="msg"></span> + <?php if ($_['isAdminPage']): ?> + <br /> + <input type="checkbox" name="allowUserMounting" id="allowUserMounting" + value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> /> + <label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label> <span id="userMountingMsg" class="msg"></span> - <p id="userMountingBackups"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> - <?php p($l->t('Allow users to mount the following external storage')); ?><br /> - <?php $i = 0; foreach ($_['personal_backends'] as $class => $backend): ?> - <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($class); ?>" <?php if ($backend['enabled']) print_unescaped(' checked="checked"'); ?> /> - <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend['backend']); ?></label> <br /> - <?php $i++; ?> - <?php endforeach; ?> - </p> - <?php endif; ?> - </fieldset> + <p id="userMountingBackups"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> + <?php p($l->t('Allow users to mount the following external storage')); ?><br /> + <?php $i = 0; foreach ($_['personal_backends'] as $class => $backend): ?> + <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($class); ?>" <?php if ($backend['enabled']) print_unescaped(' checked="checked"'); ?> /> + <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend['backend']); ?></label> <br /> + <?php $i++; ?> + <?php endforeach; ?> + </p> + <?php endif; ?> </form> <?php if ( ! $_['isAdminPage']): ?> -<form id="files_external" +<form id="files_external" class="section" method="post" enctype="multipart/form-data" action="<?php p(OCP\Util::linkTo('files_external', 'ajax/addRootCertificate.php')); ?>"> -<fieldset class="personalblock"> <h2><?php p($l->t('SSL root certificates'));?></h2> <table id="sslCertificate" data-admin='<?php print_unescaped(json_encode($_['isAdminPage'])); ?>'> <tbody width="100%"> @@ -163,6 +166,5 @@ <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>"> <input type="file" id="rootcert_import" name="rootcert_import"> <input type="submit" name="cert_import" value="<?php p($l->t('Import Root Certificate')); ?>" /> -</fieldset> </form> <?php endif; ?> diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php index bf43bb31c38..c89874c94d5 100644 --- a/apps/files_external/tests/mountconfig.php +++ b/apps/files_external/tests/mountconfig.php @@ -212,13 +212,51 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { } /** + * Provider for testing configurations with different + * "applicable" values (all, user, groups) + */ + public function applicableConfigProvider() { + return array( + // applicable to "all" + array( + OC_Mount_Config::MOUNT_TYPE_USER, + 'all', + array( + 'users' => array('all'), + 'groups' => array() + ) + ), + // applicable to single user + array( + OC_Mount_Config::MOUNT_TYPE_USER, + self::TEST_USER1, + array( + 'users' => array(self::TEST_USER1), + 'groups' => array() + ) + ), + // applicable to single group + array( + OC_Mount_Config::MOUNT_TYPE_GROUP, + self::TEST_GROUP1, + array( + 'users' => array(), + 'groups' => array(self::TEST_GROUP1) + ) + ), + ); + } + + /** * Test reading and writing global config + * + * @dataProvider applicableConfigProvider */ - public function testReadWriteGlobalConfig() { - $mountType = OC_Mount_Config::MOUNT_TYPE_USER; - $applicable = 'all'; + public function testReadWriteGlobalConfig($mountType, $applicable, $expectApplicableArray) { + $mountType = $mountType; + $applicable = $applicable; $isPersonal = false; - $mountConfig = array( + $options = array( 'host' => 'smbhost', 'user' => 'smbuser', 'password' => 'smbpassword', @@ -231,7 +269,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { OC_Mount_Config::addMountPoint( '/ext', '\OC\Files\Storage\SMB', - $mountConfig, + $options, $mountType, $applicable, $isPersonal @@ -241,12 +279,13 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { // re-read config $config = OC_Mount_Config::getSystemMountPoints(); $this->assertEquals(1, count($config)); - $this->assertTrue(isset($config['ext'])); - $this->assertEquals('\OC\Files\Storage\SMB', $config['ext']['class']); - $savedMountConfig = $config['ext']['configuration']; - $this->assertEquals($mountConfig, $savedMountConfig); + $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']); + $this->assertEquals('ext', $config[0]['mountpoint']); + $this->assertEquals($expectApplicableArray, $config[0]['applicable']); + $savedOptions = $config[0]['options']; + $this->assertEquals($options, $savedOptions); // key order needs to be preserved for the UI... - $this->assertEquals(array_keys($mountConfig), array_keys($savedMountConfig)); + $this->assertEquals(array_keys($options), array_keys($savedOptions)); } /** @@ -256,7 +295,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { $mountType = OC_Mount_Config::MOUNT_TYPE_USER; $applicable = self::TEST_USER1; $isPersonal = true; - $mountConfig = array( + $options = array( 'host' => 'smbhost', 'user' => 'smbuser', 'password' => 'smbpassword', @@ -269,7 +308,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { OC_Mount_Config::addMountPoint( '/ext', '\OC\Files\Storage\SMB', - $mountConfig, + $options, $mountType, $applicable, $isPersonal @@ -279,12 +318,12 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { // re-read config $config = OC_Mount_Config::getPersonalMountPoints(); $this->assertEquals(1, count($config)); - $this->assertTrue(isset($config['ext'])); - $this->assertEquals('\OC\Files\Storage\SMB', $config['ext']['class']); - $savedMountConfig = $config['ext']['configuration']; - $this->assertEquals($mountConfig, $savedMountConfig); + $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']); + $this->assertEquals('ext', $config[0]['mountpoint']); + $savedOptions = $config[0]['options']; + $this->assertEquals($options, $savedOptions); // key order needs to be preserved for the UI... - $this->assertEquals(array_keys($mountConfig), array_keys($savedMountConfig)); + $this->assertEquals(array_keys($options), array_keys($savedOptions)); } /** @@ -362,7 +401,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { // re-read config, password was read correctly $config = OC_Mount_Config::getPersonalMountPoints(); - $savedMountConfig = $config['ext']['configuration']; + $savedMountConfig = $config[0]['options']; $this->assertEquals($mountConfig, $savedMountConfig); } @@ -475,4 +514,130 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase { $this->assertEquals(0, count($mountPoints)); } } + + /** + * Test the same config for multiple users. + * The config will be merged by getSystemMountPoints(). + */ + public function testConfigMerging() { + $mountType = OC_Mount_Config::MOUNT_TYPE_USER; + $isPersonal = false; + $options = array( + 'host' => 'smbhost', + 'user' => 'smbuser', + 'password' => 'smbpassword', + 'share' => 'smbshare', + 'root' => 'smbroot' + ); + + // write config + $this->assertTrue( + OC_Mount_Config::addMountPoint( + '/ext', + '\OC\Files\Storage\SMB', + $options, + OC_Mount_Config::MOUNT_TYPE_USER, + self::TEST_USER1, + $isPersonal + ) + ); + + $this->assertTrue( + OC_Mount_Config::addMountPoint( + '/ext', + '\OC\Files\Storage\SMB', + $options, + OC_Mount_Config::MOUNT_TYPE_USER, + self::TEST_USER2, + $isPersonal + ) + ); + + $this->assertTrue( + OC_Mount_Config::addMountPoint( + '/ext', + '\OC\Files\Storage\SMB', + $options, + OC_Mount_Config::MOUNT_TYPE_GROUP, + self::TEST_GROUP2, + $isPersonal + ) + ); + + $this->assertTrue( + OC_Mount_Config::addMountPoint( + '/ext', + '\OC\Files\Storage\SMB', + $options, + OC_Mount_Config::MOUNT_TYPE_GROUP, + self::TEST_GROUP1, + $isPersonal + ) + ); + + // re-read config + $config = OC_Mount_Config::getSystemMountPoints(); + $this->assertEquals(1, count($config)); + $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']); + $this->assertEquals('ext', $config[0]['mountpoint']); + $this->assertEquals($options, $config[0]['options']); + $this->assertEquals(array(self::TEST_USER1, self::TEST_USER2), $config[0]['applicable']['users']); + $this->assertEquals(array(self::TEST_GROUP2, self::TEST_GROUP1), $config[0]['applicable']['groups']); + } + + /** + * Create then re-read mount points configs where the mount points + * have the same path, the config must NOT be merged. + */ + public function testRereadMountpointWithSamePath() { + $mountType = OC_Mount_Config::MOUNT_TYPE_USER; + $isPersonal = false; + $options1 = array( + 'host' => 'smbhost', + 'user' => 'smbuser', + 'password' => 'smbpassword', + 'share' => 'smbshare', + 'root' => 'smbroot' + ); + + // write config + $this->assertTrue( + OC_Mount_Config::addMountPoint( + '/ext', + '\OC\Files\Storage\SMB', + $options1, + $mountType, + self::TEST_USER1, + $isPersonal + ) + ); + + $options2 = array( + 'host' => 'anothersmbhost', + 'user' => 'anothersmbuser', + 'password' => 'anothersmbpassword', + 'share' => 'anothersmbshare', + 'root' => 'anothersmbroot' + ); + $this->assertTrue( + OC_Mount_Config::addMountPoint( + '/ext', + '\OC\Files\Storage\SMB', + $options2, + $mountType, + self::TEST_USER2, + $isPersonal + ) + ); + + // re-read config + $config = OC_Mount_Config::getSystemMountPoints(); + $this->assertEquals(2, count($config)); + $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']); + $this->assertEquals('ext', $config[0]['mountpoint']); + $this->assertEquals($options1, $config[0]['options']); + $this->assertEquals('\OC\Files\Storage\SMB', $config[1]['class']); + $this->assertEquals('ext', $config[1]['mountpoint']); + $this->assertEquals($options2, $config[1]['options']); + } } diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php index 4b716e764f4..ab32108ea25 100644 --- a/apps/files_sharing/appinfo/update.php +++ b/apps/files_sharing/appinfo/update.php @@ -71,19 +71,6 @@ if (version_compare($installedVersion, '0.3', '<')) { } // clean up oc_share table from files which are no longer exists -if (version_compare($installedVersion, '0.3.5', '<')) { - - // get all shares where the original file no longer exists - $findShares = \OC_DB::prepare('SELECT `file_source` FROM `*PREFIX*share` LEFT JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` WHERE `*PREFIX*filecache`.`fileid` IS NULL AND `*PREFIX*share`.`item_type` IN (\'file\', \'folder\')'); - $sharesFound = $findShares->execute(array())->fetchAll(); - - // delete those shares from the oc_share table - if (is_array($sharesFound) && !empty($sharesFound)) { - $delArray = array(); - foreach ($sharesFound as $share) { - $delArray[] = $share['file_source']; - } - $removeShares = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source` IN (?)'); - $result = $removeShares->execute(array(implode(',', $delArray))); - } +if (version_compare($installedVersion, '0.3.5.6', '<')) { + \OC\Files\Cache\Shared_Updater::fixBrokenSharesOnAppUpdate(); } diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version index 09e9157034c..8f91d33378e 100644 --- a/apps/files_sharing/appinfo/version +++ b/apps/files_sharing/appinfo/version @@ -1 +1 @@ -0.3.5
\ No newline at end of file +0.3.5.6 diff --git a/apps/files_sharing/css/mobile.css b/apps/files_sharing/css/mobile.css index 7d2116d190d..333c4c77fc9 100644 --- a/apps/files_sharing/css/mobile.css +++ b/apps/files_sharing/css/mobile.css @@ -1,4 +1,4 @@ -@media only screen and (max-width: 600px) { +@media only screen and (max-width: 768px) { /* make header scroll up for single shares, more view of content on small screens */ #header.share-file { @@ -45,5 +45,13 @@ table td.filename .nametext { display: none; } +/* ellipsis on file names */ +.nametext { + width: 60%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + } diff --git a/apps/files_sharing/l10n/sk_SK.php b/apps/files_sharing/l10n/sk_SK.php index 4e9856da4a7..6856c0591f4 100644 --- a/apps/files_sharing/l10n/sk_SK.php +++ b/apps/files_sharing/l10n/sk_SK.php @@ -11,6 +11,7 @@ $TRANSLATIONS = array( "sharing is disabled" => "zdieľanie je zakázané", "For more info, please ask the person who sent this link." => "Pre viac informácií kontaktujte osobu, ktorá vám poslala tento odkaz.", "shared by %s" => "Zdieľa %s", +"Download %s" => "Stiahnuť %s", "Direct link" => "Priama linka" ); $PLURAL_FORMS = "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"; diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 01db29d72e2..eeb62c3cce2 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -20,6 +20,7 @@ */ namespace OC\Files\Cache; + use OCP\Share_Backend_Collection; /** @@ -50,7 +51,7 @@ class Shared_Cache extends Cache { \OC\Files\Filesystem::initMountPoints($source['fileOwner']); $mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']); if (is_array($mount)) { - $fullPath = $mount[key($mount)]->getMountPoint().$source['path']; + $fullPath = $mount[key($mount)]->getMountPoint() . $source['path']; list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath); if ($storage) { $this->files[$target] = $internalPath; @@ -75,7 +76,7 @@ class Shared_Cache extends Cache { /** * get the stored metadata of a file or folder * - * @param string/int $file + * @param string /int $file * @return array */ public function get($file) { @@ -95,8 +96,8 @@ class Shared_Cache extends Cache { } else { $query = \OC_DB::prepare( 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`,' - .' `size`, `mtime`, `encrypted`, `unencrypted_size`' - .' FROM `*PREFIX*filecache` WHERE `fileid` = ?'); + . ' `size`, `mtime`, `encrypted`, `unencrypted_size`' + . ' FROM `*PREFIX*filecache` WHERE `fileid` = ?'); $result = $query->execute(array($file)); $data = $result->fetchRow(); $data['fileid'] = (int)$data['fileid']; @@ -288,8 +289,7 @@ class Shared_Cache extends Cache { foreach ($files as $file) { if ($file['mimetype'] === 'httpd/unix-directory') { $exploreDirs[] = ltrim($dir . '/' . $file['name'], '/'); - } - else if (($mimepart && $file['mimepart'] === $mimepart) || ($mimetype && $file['mimetype'] === $mimetype)) { + } else if (($mimepart && $file['mimepart'] === $mimepart) || ($mimetype && $file['mimetype'] === $mimetype)) { // usersPath not reliable //$file['path'] = $file['usersPath']; $file['path'] = ltrim($dir . '/' . $file['name'], '/'); @@ -344,8 +344,6 @@ class Shared_Cache extends Cache { if ($row['encrypted'] or ($row['unencrypted_size'] > 0 and $row['mimetype'] === 'httpd/unix-directory')) { $row['encrypted_size'] = $row['size']; $row['size'] = $row['unencrypted_size']; - } else { - $row['size'] = $row['size']; } $files[] = $row; } @@ -402,4 +400,48 @@ class Shared_Cache extends Cache { return false; } + /** + * get the path of a file on this storage by it's id + * + * @param int $id + * @param string $pathEnd (optional) used internally for recursive calls + * @return string | null + */ + public function getPathById($id, $pathEnd = '') { + // direct shares are easy + if ($path = $this->getShareById($id)) { + return $path . $pathEnd; + } else { + // if the item is a direct share we try and get the path of the parent and append the name of the item to it + list($parent, $name) = $this->getParentInfo($id); + if ($parent > 0) { + return $this->getPathById($parent, '/' . $name . $pathEnd); + } else { + return null; + } + } + } + + private function getShareById($id) { + $item = \OCP\Share::getItemSharedWithBySource('file', $id); + if ($item) { + return trim($item['file_target'], '/'); + } + $item = \OCP\Share::getItemSharedWithBySource('folder', $id); + if ($item) { + return trim($item['file_target'], '/'); + } + return null; + } + + private function getParentInfo($id) { + $sql = 'SELECT `parent`, `name` FROM `*PREFIX*filecache` WHERE `fileid` = ?'; + $query = \OC_DB::prepare($sql); + $result = $query->execute(array($id)); + if ($row = $result->fetchRow()) { + return array($row['parent'], $row['name']); + } else { + return array(-1, ''); + } + } } diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index 23ebc9fb811..e3a7679292d 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -135,4 +135,19 @@ class Shared_Updater { } } + /** + * clean up oc_share table from files which are no longer exists + * + * This fixes issues from updates from files_sharing < 0.3.5.6 (ownCloud 4.5) + * It will just be called during the update of the app + */ + static public function fixBrokenSharesOnAppUpdate() { + // delete all shares where the original file no longer exists + $findAndRemoveShares = \OC_DB::prepare('DELETE FROM `*PREFIX*share` ' . + 'WHERE `file_source` NOT IN ( ' . + 'SELECT `fileid` FROM `*PREFIX*filecache` WHERE `item_type` IN (\'file\', \'folder\'))' + ); + $findAndRemoveShares->execute(array()); + } + } diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index e2bbb548182..e3c5b6e4315 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -886,5 +886,5 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base { class TestShareApi extends \OCA\Files\Share\Api { public function correctPathTest($path, $folder) { return self::correctPath($path, $folder); -} + } } diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php index a75e1860527..47969833ab5 100644 --- a/apps/files_sharing/tests/cache.php +++ b/apps/files_sharing/tests/cache.php @@ -246,4 +246,43 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base { } } + public function testGetPathByIdDirectShare() { + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); + \OC\Files\Filesystem::file_put_contents('test.txt', 'foo'); + $info = \OC\Files\Filesystem::getFileInfo('test.txt'); + \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \OC_Util::tearDownFS(); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); + $this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/test.txt')); + list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/Shared/test.txt'); + /** + * @var \OC\Files\Storage\Shared $sharedStorage + */ + + $sharedCache = $sharedStorage->getCache(); + $this->assertEquals('test.txt', $sharedCache->getPathById($info->getId())); + } + + public function testGetPathByIdShareSubFolder() { + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); + \OC\Files\Filesystem::mkdir('foo'); + \OC\Files\Filesystem::mkdir('foo/bar'); + \OC\Files\Filesystem::touch('foo/bar/test.txt', 'bar'); + $folderInfo = \OC\Files\Filesystem::getFileInfo('foo'); + $fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt'); + \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \OC_Util::tearDownFS(); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); + $this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/foo')); + list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/Shared/foo'); + /** + * @var \OC\Files\Storage\Shared $sharedStorage + */ + + $sharedCache = $sharedStorage->getCache(); + $this->assertEquals('foo', $sharedCache->getPathById($folderInfo->getId())); + $this->assertEquals('foo/bar/test.txt', $sharedCache->getPathById($fileInfo->getId())); + } } diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php new file mode 100644 index 00000000000..79ae4879b64 --- /dev/null +++ b/apps/files_sharing/tests/updater.php @@ -0,0 +1,91 @@ +<?php +/** + * ownCloud + * + * @author Morris Jobke + * @copyright 2014 Morris Jobke <morris.jobke@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * Class Test_Files_Sharing_Updater + */ +class Test_Files_Sharing_Updater extends \PHPUnit_Framework_TestCase { + + function setUp() { + // some previous tests didn't clean up and therefore this has to be done here + // FIXME: DIRTY HACK - TODO: find tests, that don't clean up and fix it there + $this->tearDown(); + + // add items except one - because this is the test case for the broken share table + $addItems = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache` (`storage`, `path_hash`, ' . + '`parent`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`) ' . + 'VALUES (1, ?, 1, 1, 1, 1, 1, 1)'); + $items = array(1, 3); + $fileIds = array(); + foreach($items as $item) { + // the number is used as path_hash + $addItems->execute(array($item)); + $fileIds[] = \OC_DB::insertId('*PREFIX*filecache'); + } + + $addShares = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`file_source`, `item_type`, `uid_owner`) VALUES (?, \'file\', 1)'); + // the number is used as item_source + $addShares->execute(array($fileIds[0])); + $addShares->execute(array(200)); // id of "deleted" file + $addShares->execute(array($fileIds[1])); + } + + function tearDown() { + $removeShares = \OC_DB::prepare('DELETE FROM `*PREFIX*share`'); + $removeShares->execute(); + $removeItems = \OC_DB::prepare('DELETE FROM `*PREFIX*filecache`'); + $removeItems->execute(); + } + + /** + * @medium + */ + function testRemoveBrokenShares() { + // check if there are just 3 shares (see setUp - precondition: empty table) + $countShares = \OC_DB::prepare('SELECT COUNT(`id`) FROM `*PREFIX*share`'); + $result = $countShares->execute()->fetchOne(); + $this->assertEquals(3, $result); + + // check if there are just 2 items (see setUp - precondition: empty table) + $countItems = \OC_DB::prepare('SELECT COUNT(`fileid`) FROM `*PREFIX*filecache`'); + $result = $countItems->execute()->fetchOne(); + $this->assertEquals(2, $result); + + // execute actual code which should be tested + \OC\Files\Cache\Shared_Updater::fixBrokenSharesOnAppUpdate(); + + // check if there are just 2 shares (one gets killed by the code as there is no filecache entry for this) + $countShares = \OC_DB::prepare('SELECT COUNT(`id`) FROM `*PREFIX*share`'); + $result = $countShares->execute()->fetchOne(); + $this->assertEquals(2, $result); + + // check if the share of file '200' is removed as there is no entry for this in filecache table + $countShares = \OC_DB::prepare('SELECT COUNT(`id`) FROM `*PREFIX*share` WHERE `file_source` = 200'); + $result = $countShares->execute()->fetchOne(); + $this->assertEquals(0, $result); + + // check if there are just 2 items + $countItems = \OC_DB::prepare('SELECT COUNT(`fileid`) FROM `*PREFIX*filecache`'); + $result = $countItems->execute()->fetchOne(); + $this->assertEquals(2, $result); + } +} diff --git a/apps/files_trashbin/ajax/list.php b/apps/files_trashbin/ajax/list.php index 124a236bcbd..cec18c46525 100644 --- a/apps/files_trashbin/ajax/list.php +++ b/apps/files_trashbin/ajax/list.php @@ -1,11 +1,5 @@ <?php -// only need filesystem apps -$RUNTIME_APPTYPES=array('filesystem'); - -// Init owncloud - - OCP\JSON::checkLoggedIn(); // Load the files diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index 6aade210505..efe1e89f0bf 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -25,6 +25,11 @@ $(document).ready(function() { enableActions(); } + Files.updateStorageStatistics = function() { + // no op because the trashbin doesn't have + // storage info like free space / used space + }; + if (typeof FileActions !== 'undefined') { FileActions.register('all', 'Restore', OC.PERMISSION_READ, OC.imagePath('core', 'actions/history'), function(filename) { var tr = FileList.findFileEl(filename); diff --git a/apps/files_trashbin/l10n/ar.php b/apps/files_trashbin/l10n/ar.php index 68c51d1cc7d..4084daa127a 100644 --- a/apps/files_trashbin/l10n/ar.php +++ b/apps/files_trashbin/l10n/ar.php @@ -4,6 +4,7 @@ $TRANSLATIONS = array( "Couldn't restore %s" => "تعذّر استرجاع %s ", "Deleted files" => "حذف الملفات", "Error" => "خطأ", +"restored" => "تمت الاستعادة", "Nothing in here. Your trash bin is empty!" => "لا يوجد شيء هنا. سلة المهملات خاليه.", "Name" => "اسم", "Restore" => "استعيد", diff --git a/apps/files_versions/appinfo/info.xml b/apps/files_versions/appinfo/info.xml index 661d64aa979..a735caee945 100644 --- a/apps/files_versions/appinfo/info.xml +++ b/apps/files_versions/appinfo/info.xml @@ -9,7 +9,7 @@ <description> ownCloud supports simple version control for files. The versioning app expires old versions automatically to make sure that - the user doesn't run out of space. Following pattern is used to delete + the user doesn't run out of space. The following pattern is used to delete old versions: For the first 10 seconds ownCloud keeps one version every 2 seconds; For the first hour ownCloud keeps one version every minute; diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 4adf14745de..b452bc25b13 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -11,7 +11,7 @@ $(document).ready(function(){ // Add versions button to 'files/index.php' FileActions.register( 'file' - , t('files_versions', 'Versions') + , 'Versions' , OC.PERMISSION_UPDATE , function() { // Specify icon for hitory button @@ -36,6 +36,7 @@ $(document).ready(function(){ createVersionsDropdown(filename, file); } } + , t('files_versions', 'Versions') ); } diff --git a/apps/user_ldap/appinfo/info.xml b/apps/user_ldap/appinfo/info.xml index 9cc908e8522..e4a4375a737 100644 --- a/apps/user_ldap/appinfo/info.xml +++ b/apps/user_ldap/appinfo/info.xml @@ -2,8 +2,8 @@ <info> <id>user_ldap</id> <name>LDAP user and group backend</name> - <description>Authenticate users and groups by LDAP respectively Active - Directory. + <description>Authenticate users and groups through LDAP, such as OpenLDAP + or Active Directory. This app is not compatible with the WebDAV user backend. </description> diff --git a/apps/user_ldap/l10n/el.php b/apps/user_ldap/l10n/el.php index 1e975911953..926419d86b2 100644 --- a/apps/user_ldap/l10n/el.php +++ b/apps/user_ldap/l10n/el.php @@ -33,12 +33,14 @@ $TRANSLATIONS = array( "Save" => "Αποθήκευση", "Test Configuration" => "Δοκιμαστικες ρυθμισεις", "Help" => "Βοήθεια", +"Groups meeting these criteria are available in %s:" => "Οι ομάδες που πληρούν τα κριτήρια είναι διαθέσιμες σε %s:", "only those object classes:" => "μόνο αυτές οι κλάσεις αντικειμένων:", "only from those groups:" => "μόνο από αυτές τις ομάδες:", "Edit raw filter instead" => "Επεξεργασία πρωτογενούς φίλτρου αντί αυτού", "Raw LDAP filter" => "Πρωτογενές φίλτρο ", "The filter specifies which LDAP groups shall have access to the %s instance." => "Το φίλτρο καθορίζει ποιες ομάδες LDAP θα έχουν πρόσβαση στην εγκατάσταση %s.", "groups found" => "ομάδες βρέθηκαν", +"Users login with this attribute:" => "Οι χρήστες εισέρχονται με αυτό το χαρακτηριστικό:", "LDAP Username:" => "Όνομα χρήστη LDAP:", "LDAP Email Address:" => "Διεύθυνση ηλ. ταχυδρομείου LDAP:", "Other Attributes:" => "Άλλες Ιδιότητες:", @@ -53,6 +55,7 @@ $TRANSLATIONS = array( "For anonymous access, leave DN and Password empty." => "Για ανώνυμη πρόσβαση, αφήστε κενά τα πεδία DN και Pasword.", "One Base DN per line" => "Ένα DN Βάσης ανά γραμμή ", "You can specify Base DN for users and groups in the Advanced tab" => "Μπορείτε να καθορίσετε το Base DN για χρήστες και ομάδες από την καρτέλα Προηγμένες ρυθμίσεις", +"Limit %s access to users meeting these criteria:" => "Περιορισμός της πρόσβασης %s σε χρήστες που πληρούν τα κριτήρια:", "The filter specifies which LDAP users shall have access to the %s instance." => "Το φίλτρο καθορίζει ποιοι χρήστες LDAP θα έχουν πρόσβαση στην εγκατάσταση %s.", "users found" => "χρήστες βρέθηκαν", "Back" => "Επιστροφή", @@ -85,6 +88,7 @@ $TRANSLATIONS = array( "One Group Base DN per line" => "Μια ομαδικη Βάση DN ανά γραμμή", "Group Search Attributes" => "Ομάδα Χαρακτηριστικων Αναζήτηση", "Group-Member association" => "Group-Member association", +"Nested Groups" => "Φωλιασμένες ομάδες", "Special Attributes" => "Ειδικά Χαρακτηριστικά ", "Quota Field" => "Ποσοσταση πεδιου", "Quota Default" => "Προκαθισμενο πεδιο", diff --git a/apps/user_ldap/l10n/sl.php b/apps/user_ldap/l10n/sl.php index b2a21b6e029..b6df62ffb79 100644 --- a/apps/user_ldap/l10n/sl.php +++ b/apps/user_ldap/l10n/sl.php @@ -85,6 +85,7 @@ $TRANSLATIONS = array( "One Group Base DN per line" => "Eno osnovno ime skupine na vrstico", "Group Search Attributes" => "Skupinski atributi iskanja", "Group-Member association" => "Povezava član-skupina", +"Nested Groups" => "Gnezdene skupine", "Special Attributes" => "Posebni atributi", "Quota Field" => "Polje količinske omejitve", "Quota Default" => "Privzeta količinska omejitev", diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 79c4ae224c3..ee4a7df3cb8 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -1,5 +1,5 @@ <form id="ldap" action="#" method="post"> - <div id="ldapSettings" class="personalblock"> + <div id="ldapSettings" class="section"> <ul> <?php foreach($_['toc'] as $id => $title) { ?> <li id="<?php p($id); ?>"><a href="<?php p($id); ?>"><?php p($title); ?></a></li> diff --git a/apps/user_webdavauth/appinfo/info.xml b/apps/user_webdavauth/appinfo/info.xml index 76b314e48aa..20c5909cc12 100755 --- a/apps/user_webdavauth/appinfo/info.xml +++ b/apps/user_webdavauth/appinfo/info.xml @@ -4,7 +4,7 @@ <name>WebDAV user backend</name> <description>Authenticate users by a WebDAV call. You can use any WebDAV server, ownCloud server or other webserver to authenticate. It should return http 200 for right credentials and http 401 for wrong ones. - This app is not compatible to the LDAP user and group backend.</description> + This app is not compatible with the LDAP user and group backend.</description> <licence>AGPL</licence> <author>Frank Karlitschek</author> <require>4.93</require> diff --git a/apps/user_webdavauth/templates/settings.php b/apps/user_webdavauth/templates/settings.php index ad1701add8c..4596fdf3c78 100755 --- a/apps/user_webdavauth/templates/settings.php +++ b/apps/user_webdavauth/templates/settings.php @@ -1,9 +1,7 @@ -<form id="webdavauth" action="#" method="post"> - <fieldset class="personalblock"> - <h2><?php p($l->t('WebDAV Authentication'));?></h2> - <p><label for="webdav_url"><?php p($l->t('Address: '));?><input type="url" placeholder="https://example.com/webdav" id="webdav_url" name="webdav_url" value="<?php p($_['webdav_url']); ?>"></label> - <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken"> - <input type="submit" value="Save" /> - <br /><?php p($l->t('The user credentials will be sent to this address. This plugin checks the response and will interpret the HTTP statuscodes 401 and 403 as invalid credentials, and all other responses as valid credentials.')); ?> - </fieldset> +<form id="webdavauth" class="section" action="#" method="post"> + <h2><?php p($l->t('WebDAV Authentication'));?></h2> + <p><label for="webdav_url"><?php p($l->t('Address: '));?><input type="url" placeholder="https://example.com/webdav" id="webdav_url" name="webdav_url" value="<?php p($_['webdav_url']); ?>"></label> + <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken"> + <input type="submit" value="Save" /> + <br /><?php p($l->t('The user credentials will be sent to this address. This plugin checks the response and will interpret the HTTP statuscodes 401 and 403 as invalid credentials, and all other responses as valid credentials.')); ?> </form> |