diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-01-23 00:39:11 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-01-23 00:39:11 +0100 |
commit | f950ce82ae137977eeca5babe69d732ca55cbeaa (patch) | |
tree | 4c1b949c81b45ce081503343780eea91afd6b659 /apps | |
parent | 4ec6debe2b145b0df106c7e5a3f4ed0cf2885957 (diff) | |
parent | 4474421ada2a4b5642f1a081d6491d7858b3b9b0 (diff) | |
download | nextcloud-server-f950ce82ae137977eeca5babe69d732ca55cbeaa.tar.gz nextcloud-server-f950ce82ae137977eeca5babe69d732ca55cbeaa.zip |
Merge branch 'master' into mobile-style
Conflicts:
apps/files/js/files.js
apps/files_sharing/css/public.css
apps/files_sharing/js/public.js
apps/files_sharing/templates/public.php
Diffstat (limited to 'apps')
48 files changed, 534 insertions, 317 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 0e905f993ac..bdaf6a77d14 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -34,6 +34,7 @@ if (empty($_POST['dirToken'])) { // resolve reshares $rootLinkItem = OCP\Share::resolveReShare($linkItem); + OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); // Setup FS with owner OC_Util::tearDownFS(); OC_Util::setupFS($rootLinkItem['uid_owner']); diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 196817432d5..225c3319107 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -222,6 +222,14 @@ $(document).ready(function() { //examine file var file = data.files[0]; + try { + // FIXME: not so elegant... need to refactor that method to return a value + Files.isFileNameValid(file.name); + } + catch (errorMessage) { + data.textStatus = 'invalidcharacters'; + data.errorThrown = errorMessage; + } if (file.type === '' && file.size === 4096) { data.textStatus = 'dirorzero'; @@ -605,7 +613,7 @@ $(document).ready(function() { if (result.status === 'success') { var date=new Date(); FileList.addDir(name, 0, date, hidden); - var tr=$('tr[data-file="'+name+'"]'); + var tr = FileList.findFileEl(name); tr.attr('data-id', result.data.id); } else { OC.dialogs.alert(result.data.message, t('core', 'Could not create folder')); @@ -647,7 +655,7 @@ $(document).ready(function() { $('#uploadprogressbar').fadeOut(); var date = new Date(); FileList.addFile(localName, size, date, false, hidden); - var tr = $('tr[data-file="'+localName+'"]'); + var tr = FileList.findFileEl(localName); tr.data('mime', mime).data('id', id); tr.attr('data-id', id); var path = $('#dir').val()+'/'+localName; diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 03e23189a97..74bb711ef3d 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -71,7 +71,7 @@ var FileActions = { FileActions.currentFile = parent; var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions()); var file = FileActions.getCurrentFile(); - if ($('tr[data-file="'+file+'"]').data('renaming')) { + if (FileList.findFileEl(file).data('renaming')) { return; } diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 473bcf25f2d..66968ab54c7 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -6,6 +6,13 @@ var FileList={ $(this).attr('data-file',decodeURIComponent($(this).attr('data-file'))); }); }, + /** + * Returns the tr element for a given file name + */ + findFileEl: function(fileName){ + // use filterAttr to avoid escaping issues + return $('#fileList tr').filterAttr('data-file', fileName); + }, update:function(fileListHtml) { var $fileList = $('#fileList'); $fileList.empty().html(fileListHtml); @@ -20,6 +27,8 @@ var FileList={ Files.setupDragAndDrop(); } FileList.updateFileSummary(); + procesSelection(); + $fileList.trigger(jQuery.Event("updated")); }, createRow:function(type, name, iconurl, linktarget, size, lastModified, permissions) { @@ -292,8 +301,12 @@ var FileList={ $('#filestable').toggleClass('hidden', show); }, remove:function(name){ - $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy'); - $('tr').filterAttr('data-file',name).remove(); + var fileEl = FileList.findFileEl(name); + if (fileEl.data('permissions') & OC.PERMISSION_DELETE) { + // file is only draggable when delete permissions are set + fileEl.find('td.filename').draggable('destroy'); + } + fileEl.remove(); FileList.updateFileSummary(); if ( ! $('tr[data-file]').exists() ) { $('#emptycontent').removeClass('hidden'); @@ -334,7 +347,7 @@ var FileList={ FileList.updateFileSummary(); }, loadingDone:function(name, id) { - var mime, tr = $('tr[data-file="'+name+'"]'); + var mime, tr = FileList.findFileEl(name); tr.data('loading', false); mime = tr.data('mime'); tr.attr('data-mime', mime); @@ -347,12 +360,12 @@ var FileList={ }, null, null, tr.attr('data-etag')); tr.find('td.filename').draggable(dragOptions); }, - isLoading:function(name) { - return $('tr[data-file="'+name+'"]').data('loading'); + isLoading:function(file) { + return FileList.findFileEl(file).data('loading'); }, rename:function(oldname) { var tr, td, input, form; - tr = $('tr[data-file="'+oldname+'"]'); + tr = FileList.findFileEl(oldname); tr.data('renaming',true); td = tr.children('td.filename'); input = $('<input type="text" class="filename"/>').val(oldname); @@ -500,14 +513,16 @@ var FileList={ form.trigger('submit'); }); }, - inList:function(filename) { - return $('#fileList tr[data-file="'+filename+'"]').length; + inList:function(file) { + return FileList.findFileEl(file).length; }, replace:function(oldName, newName, isNewFile) { // Finish any existing actions - $('tr[data-file="'+oldName+'"]').hide(); - $('tr[data-file="'+newName+'"]').hide(); - var tr = $('tr[data-file="'+oldName+'"]').clone(); + var oldFileEl = FileList.findFileEl(oldName); + var newFileEl = FileList.findFileEl(newName); + oldFileEl.hide(); + newFileEl.hide(); + var tr = oldFileEl.clone(); tr.attr('data-replace', 'true'); tr.attr('data-file', newName); var td = tr.children('td.filename'); @@ -559,7 +574,7 @@ var FileList={ files=[files]; } for (var i=0; i<files.length; i++) { - var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete"); + var deleteAction = FileList.findFileEl(files[i]).children("td.date").children(".action.delete"); deleteAction.removeClass('delete-icon').addClass('progress-icon'); } // Finish any existing actions @@ -573,7 +588,7 @@ var FileList={ function(result) { if (result.status === 'success') { $.each(files,function(index,file) { - var files = $('tr[data-file="'+file+'"]'); + var files = FileList.findFileEl(file); files.remove(); files.find('input[type="checkbox"]').removeAttr('checked'); files.removeClass('selected'); @@ -595,7 +610,7 @@ var FileList={ OC.Notification.hide(); }, 10000); $.each(files,function(index,file) { - var deleteAction = $('tr[data-file="' + file + '"] .action.delete'); + var deleteAction = FileList.findFileEl(file).find('.action.delete'); deleteAction.removeClass('progress-icon').addClass('delete-icon'); }); } @@ -737,7 +752,7 @@ var FileList={ }, scrollTo:function(file) { //scroll to and highlight preselected file - var $scrolltorow = $('tr[data-file="'+file+'"]'); + var $scrolltorow = FileList.findFileEl(file); if ($scrolltorow.exists()) { $scrolltorow.addClass('searchresult'); $(window).scrollTop($scrolltorow.position().top); @@ -949,7 +964,7 @@ $(document).ready(function() { $('#notification').on('click', '.undo', function() { if (FileList.deleteFiles) { $.each(FileList.deleteFiles,function(index,file) { - $('tr[data-file="'+file+'"]').show(); + FileList.findFileEl(file).show(); }); FileList.deleteCanceled=true; FileList.deleteFiles=null; @@ -959,10 +974,10 @@ $(document).ready(function() { FileList.deleteCanceled = false; FileList.deleteFiles = [FileList.replaceOldName]; } else { - $('tr[data-file="'+FileList.replaceOldName+'"]').show(); + FileList.findFileEl(FileList.replaceOldName).show(); } $('tr[data-replace="true"').remove(); - $('tr[data-file="'+FileList.replaceNewName+'"]').show(); + FileList.findFileEl(FileList.replaceNewName).show(); FileList.replaceCanceled = true; FileList.replaceOldName = null; FileList.replaceNewName = null; @@ -977,7 +992,8 @@ $(document).ready(function() { }); }); $('#notification:first-child').on('click', '.suggest', function() { - $('tr[data-file="'+$('#notification > span').attr('data-oldName')+'"]').show(); + var file = $('#notification > span').attr('data-oldName'); + FileList.findFileEl(file).show(); OC.Notification.hide(); }); $('#notification:first-child').on('click', '.cancel', function() { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index d5e8450f41f..b5633ae01aa 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -282,7 +282,7 @@ $(document).ready(function() { procesSelection(); } else { var filename=$(this).parent().parent().attr('data-file'); - var tr=$('tr[data-file="'+filename+'"]'); + var tr = FileList.findFileEl(filename); var renaming=tr.data('renaming'); if (!renaming && !FileList.isLoading(filename)) { FileActions.currentFile = $(this).parent(); @@ -541,10 +541,12 @@ var folderDropOptions={ if (result) { if (result.status === 'success') { //recalculate folder size - var oldSize = $('#fileList tr[data-file="'+target+'"]').data('size'); - var newSize = oldSize + $('#fileList tr[data-file="'+file+'"]').data('size'); - $('#fileList tr[data-file="'+target+'"]').data('size', newSize); - $('#fileList tr[data-file="'+target+'"]').find('td.filesize').text(humanFileSize(newSize)); + var oldFile = FileList.findFileEl(target); + var newFile = FileList.findFileEl(file); + var oldSize = oldFile.data('size'); + var newSize = oldSize + newFile.data('size'); + oldFile.data('size', newSize); + oldFile.find('td.filesize').text(humanFileSize(newSize)); FileList.remove(file); procesSelection(); @@ -610,11 +612,12 @@ function procesSelection() { return el.type==='dir'; }); if (selectedFiles.length === 0 && selectedFolders.length === 0) { - $('#headerName>span.name').text(t('files','Name')); + $('#headerName span.name').text(t('files','Name')); $('#headerSize').text(t('files','Size')); $('#modified').text(t('files','Modified')); $('table').removeClass('multiselect'); $('.selectedActions').hide(); + $('#select_all').removeAttr('checked'); } else { $('.selectedActions').show(); @@ -738,7 +741,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { } function getUniqueName(name) { - if ($('tr[data-file="'+name+'"]').exists()) { + if (FileList.findFileEl(name).exists()) { var parts=name.split('.'); var extension = ""; if (parts.length > 1) { diff --git a/apps/files/l10n/ru_RU.php b/apps/files/l10n/ru_RU.php deleted file mode 100644 index 2a6ceeb99b9..00000000000 --- a/apps/files/l10n/ru_RU.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -$TRANSLATIONS = array( -"File name cannot be empty." => "Имя файла не может быть пустым.", -"Files" => "Файлы", -"Share" => "Сделать общим", -"Rename" => "Переименовать", -"_%n folder_::_%n folders_" => array("","",""), -"_%n file_::_%n files_" => array("","",""), -"_Uploading %n file_::_Uploading %n files_" => array("","",""), -"'.' is an invalid file name." => "'.' является неверным именем файла.", -"Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed." => "Некорректное имя, '\\', '/', '<', '>', ':', '\"', '|', '?' и '*' не допустимы.", -"Error" => "Ошибка", -"Size" => "Размер", -"Upload" => "Загрузка", -"0 is unlimited" => "0 без ограничений", -"Save" => "Сохранить", -"Cancel upload" => "Отмена загрузки", -"Download" => "Загрузка", -"Delete" => "Удалить" -); -$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/apps/files/templates/part.breadcrumb.php b/apps/files/templates/part.breadcrumb.php index 90d07d4336c..2a0df622767 100644 --- a/apps/files/templates/part.breadcrumb.php +++ b/apps/files/templates/part.breadcrumb.php @@ -1,6 +1,10 @@ <div class="crumb <?php if(!count($_["breadcrumb"])) p('last');?>" data-dir=''> <a href="<?php print_unescaped($_['baseURL']); ?>"> - <img src="<?php print_unescaped(OCP\image_path('core', 'places/home.svg'));?>" class="svg" /> + <?php if(isset($_['rootBreadCrumb'])): + echo $_['rootBreadCrumb']; + else:?> + <img src="<?php print_unescaped(OCP\image_path('core', 'places/home.svg'));?>" class="svg" /> + <?php endif;?> </a> </div> <?php for($i=0; $i<count($_["breadcrumb"]); $i++): diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 2f630e1f014..f4fb96a7a7c 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -18,7 +18,7 @@ $totalsize = 0; ?> data-size="<?php p($file['size']);?>" data-etag="<?php p($file['etag']);?>" data-permissions="<?php p($file['permissions']); ?>"> - <?php if($file['isPreviewAvailable']): ?> + <?php if(isset($file['isPreviewAvailable']) and $file['isPreviewAvailable']): ?> <td class="filename svg preview-icon" <?php else: ?> <td class="filename svg" diff --git a/apps/files/triggerupdate.php b/apps/files/triggerupdate.php index 0e29edbba35..a37b9823add 100644 --- a/apps/files/triggerupdate.php +++ b/apps/files/triggerupdate.php @@ -6,6 +6,7 @@ if (OC::$CLI) { if (count($argv) === 2) { $file = $argv[1]; list(, $user) = explode('/', $file); + OCP\JSON::checkUserExists($owner); OC_Util::setupFS($user); $view = new \OC\Files\View(''); /** diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index 9d495916d26..b6d9d6bb0a3 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -2,11 +2,15 @@ <info> <id>files_encryption</id> <name>Encryption</name> - <description>The new ownCloud 5 files encryption system. After the app was enabled you need to re-login to initialize your encryption keys.</description> + <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.</description> <licence>AGPL</licence> <author>Sam Tuke, Bjoern Schiessle, Florin Peter</author> <require>4</require> <shipped>true</shipped> + <documentation> + <user>http://doc.owncloud.org/server/6.0/user_manual/files/encryption.html</user> + <admin>http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_encryption.html</admin> + </documentation> <rememberlogin>false</rememberlogin> <types> <filesystem/> diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 41f352d853a..4fe76b97711 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -255,8 +255,8 @@ class Proxy extends \OC_FileProxy { // split the path parts $pathParts = explode('/', $path); - // FIXME: handling for /userId/cache used by webdav for chunking. The cache chunks are NOT encrypted - if (isset($pathParts[2]) && $pathParts[2] === 'cache') { + // 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; } diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index ca14e3e2ccb..388980ad4fd 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -155,7 +155,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { */ function testSymmetricStreamEncryptShortFileContent() { - $filename = 'tmp-' . time() . '.test'; + $filename = 'tmp-' . uniqid() . '.test'; $util = new Encryption\Util(new \OC_FilesystemView(), $this->userId); @@ -214,7 +214,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { function testSymmetricStreamEncryptLongFileContent() { // Generate a a random filename - $filename = 'tmp-' . time() . '.test'; + $filename = 'tmp-' . uniqid() . '.test'; $util = new Encryption\Util(new \OC_FilesystemView(), $this->userId); @@ -297,7 +297,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { */ function testSymmetricStreamDecryptShortFileContent() { - $filename = 'tmp-' . time(); + $filename = 'tmp-' . uniqid(); // Save long data as encrypted file using stream wrapper $cryptedFile = file_put_contents('crypt:///'. $this->userId . '/files/' . $filename, $this->dataShort); @@ -327,7 +327,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { */ function testSymmetricStreamDecryptLongFileContent() { - $filename = 'tmp-' . time(); + $filename = 'tmp-' . uniqid(); // Save long data as encrypted file using stream wrapper $cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong); @@ -418,7 +418,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { */ function testRenameFile() { - $filename = 'tmp-' . time(); + $filename = 'tmp-' . uniqid(); // Save long data as encrypted file using stream wrapper $cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong); @@ -431,7 +431,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $this->assertEquals($this->dataLong, $decrypt); - $newFilename = 'tmp-new-' . time(); + $newFilename = 'tmp-new-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); $view->rename($filename, $newFilename); @@ -449,7 +449,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { */ function testMoveFileIntoFolder() { - $filename = 'tmp-' . time(); + $filename = 'tmp-' . uniqid(); // Save long data as encrypted file using stream wrapper $cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong); @@ -462,8 +462,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $this->assertEquals($this->dataLong, $decrypt); - $newFolder = '/newfolder' . time(); - $newFilename = 'tmp-new-' . time(); + $newFolder = '/newfolder' . uniqid(); + $newFilename = 'tmp-new-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); $view->mkdir($newFolder); $view->rename($filename, $newFolder . '/' . $newFilename); @@ -484,8 +484,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $view = new \OC\Files\View('/' . $this->userId . '/files'); - $filename = '/tmp-' . time(); - $folder = '/folder' . time(); + $filename = '/tmp-' . uniqid(); + $folder = '/folder' . uniqid(); $view->mkdir($folder); @@ -500,7 +500,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $this->assertEquals($this->dataLong, $decrypt); - $newFolder = '/newfolder/subfolder' . time(); + $newFolder = '/newfolder/subfolder' . uniqid(); $view->mkdir('/newfolder'); $view->rename($folder, $newFolder); @@ -519,7 +519,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { * @medium */ function testChangePassphrase() { - $filename = 'tmp-' . time(); + $filename = 'tmp-' . uniqid(); // Save long data as encrypted file using stream wrapper $cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong); @@ -557,7 +557,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { */ function testViewFilePutAndGetContents() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -590,7 +590,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { * @large */ function testTouchExistingFile() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -614,7 +614,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { * @medium */ function testTouchFile() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); $view->touch($filename); @@ -638,7 +638,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { * @medium */ function testFopenFile() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php index 1467979f005..58a57ee5af4 100644 --- a/apps/files_encryption/tests/keymanager.php +++ b/apps/files_encryption/tests/keymanager.php @@ -143,7 +143,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase { $key = $this->randomKey; - $file = 'unittest-' . time() . '.txt'; + $file = 'unittest-' . uniqid() . '.txt'; $util = new Encryption\Util($this->view, $this->userId); @@ -196,7 +196,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase { function testRecursiveDelShareKeys() { // generate filename - $filename = '/tmp-' . time() . '.txt'; + $filename = '/tmp-' . uniqid() . '.txt'; // create folder structure $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1'); diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index 419f95e1a38..c3006274d6d 100644 --- a/apps/files_encryption/tests/proxy.php +++ b/apps/files_encryption/tests/proxy.php @@ -80,7 +80,7 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase { // init short data $this->data = 'hats'; - $this->filename = 'enc_proxy_tests-' . time() . '.txt'; + $this->filename = 'enc_proxy_tests-' . uniqid() . '.txt'; } diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index 2767bbe512b..fed2e7d89d1 100644 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -99,7 +99,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { } function testStreamOptions() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -122,7 +122,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { } function testStreamSetBlocking() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -144,7 +144,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { * @medium */ function testStreamSetTimeout() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -163,7 +163,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { } function testStreamSetWriteBuffer() { - $filename = '/tmp-' . time(); + $filename = '/tmp-' . uniqid(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -187,9 +187,9 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { */ function testStreamFromLocalFile() { - $filename = '/' . $this->userId . '/files/' . 'tmp-' . time().'.txt'; + $filename = '/' . $this->userId . '/files/' . 'tmp-' . uniqid().'.txt'; - $tmpFilename = "/tmp/" . time() . ".txt"; + $tmpFilename = "/tmp/" . uniqid() . ".txt"; // write an encrypted file $cryptedFile = $this->view->file_put_contents($filename, $this->dataShort); diff --git a/apps/files_encryption/tests/trashbin.php b/apps/files_encryption/tests/trashbin.php index 2a41ace4015..2f9ecfd9d5d 100755 --- a/apps/files_encryption/tests/trashbin.php +++ b/apps/files_encryption/tests/trashbin.php @@ -119,7 +119,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase { function testDeleteFile() { // generate filename - $filename = 'tmp-' . time() . '.txt'; + $filename = 'tmp-' . uniqid() . '.txt'; // save file with content $cryptedFile = file_put_contents('crypt:///' .\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename, $this->dataShort); @@ -223,7 +223,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase { function testPermanentDeleteFile() { // generate filename - $filename = 'tmp-' . time() . '.txt'; + $filename = 'tmp-' . uniqid() . '.txt'; // save file with content $cryptedFile = file_put_contents('crypt:///' .$this->userId. '/files/' . $filename, $this->dataShort); diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index b1904cbadc7..97e3c518dac 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -142,8 +142,8 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { self::loginHelper($this->userId); - $unencryptedFile = '/tmpUnencrypted-' . time() . '.txt'; - $encryptedFile = '/tmpEncrypted-' . time() . '.txt'; + $unencryptedFile = '/tmpUnencrypted-' . uniqid() . '.txt'; + $encryptedFile = '/tmpEncrypted-' . uniqid() . '.txt'; // Disable encryption proxy to write a unencrypted file $proxyStatus = \OC_FileProxy::$enabled; @@ -254,7 +254,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { \OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); - $filename = '/tmp-' . time() . '.test'; + $filename = '/tmp-' . uniqid() . '.test'; // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -282,7 +282,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { function testGetFileSize() { \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); - $filename = 'tmp-' . time(); + $filename = 'tmp-' . uniqid(); $externalFilename = '/' . $this->userId . '/files/' . $filename; // Test for 0 byte files @@ -318,7 +318,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { function testEncryptAll() { - $filename = "/encryptAll" . time() . ".txt"; + $filename = "/encryptAll" . uniqid() . ".txt"; $util = new Encryption\Util($this->view, $this->userId); // disable encryption to upload a unencrypted file @@ -350,7 +350,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { function testDecryptAll() { - $filename = "/decryptAll" . time() . ".txt"; + $filename = "/decryptAll" . uniqid() . ".txt"; $util = new Encryption\Util($this->view, $this->userId); $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort); diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php index a2a8ce6e34f..8e8b9c53cee 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -113,7 +113,7 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { function testWebdavPUT() { // generate filename - $filename = '/tmp-' . time() . '.txt'; + $filename = '/tmp-' . uniqid() . '.txt'; // set server vars $_SERVER['REQUEST_METHOD'] = 'OPTIONS'; diff --git a/apps/files_external/3rdparty/smb4php/smb.php b/apps/files_external/3rdparty/smb4php/smb.php index e454ddecb81..622942b052a 100644 --- a/apps/files_external/3rdparty/smb4php/smb.php +++ b/apps/files_external/3rdparty/smb4php/smb.php @@ -130,7 +130,7 @@ class smb { // this put env is necessary to read the output of smbclient correctly $old_locale = getenv('LC_ALL'); putenv('LC_ALL=en_US.UTF-8'); - $output = popen (SMB4PHP_SMBCLIENT." -N {$auth} {$options} {$port} {$options} {$params} 2>/dev/null", 'r'); + $output = popen ('TZ=UTC '.SMB4PHP_SMBCLIENT." -N {$auth} {$options} {$port} {$options} {$params} 2>/dev/null", 'r'); $gotInfo = false; $info = array (); $info['info']= array (); diff --git a/apps/files_external/js/dropbox.js b/apps/files_external/js/dropbox.js index 957daeb4d1f..6baaabe11b6 100644 --- a/apps/files_external/js/dropbox.js +++ b/apps/files_external/js/dropbox.js @@ -23,9 +23,12 @@ $(document).ready(function() { $(token).val(result.access_token); $(token_secret).val(result.access_token_secret); $(configured).val('true'); - OC.MountConfig.saveStorage(tr); - $(tr).find('.configuration input').attr('disabled', 'disabled'); - $(tr).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); + OC.MountConfig.saveStorage(tr, function(status) { + if (status) { + $(tr).find('.configuration input').attr('disabled', 'disabled'); + $(tr).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); + } + }); } else { OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Dropbox storage')); } @@ -77,7 +80,6 @@ $(document).ready(function() { var tr = $(this).parent().parent(); var app_key = $(this).parent().find('[data-parameter="app_key"]').val(); var app_secret = $(this).parent().find('[data-parameter="app_secret"]').val(); - var statusSpan = $(tr).find('.status span'); if (app_key != '' && app_secret != '') { var tr = $(this).parent().parent(); var configured = $(this).parent().find('[data-parameter="configured"]'); @@ -88,10 +90,9 @@ $(document).ready(function() { $(configured).val('false'); $(token).val(result.data.request_token); $(token_secret).val(result.data.request_token_secret); - OC.MountConfig.saveStorage(tr); - statusSpan.removeClass(); - statusSpan.addClass('waiting'); - window.location = result.data.url; + OC.MountConfig.saveStorage(tr, function() { + window.location = result.data.url; + }); } else { OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Dropbox storage')); } diff --git a/apps/files_external/js/google.js b/apps/files_external/js/google.js index b4be1c1dc41..068c2c13c66 100644 --- a/apps/files_external/js/google.js +++ b/apps/files_external/js/google.js @@ -32,11 +32,14 @@ $(document).ready(function() { if (result && result.status == 'success') { $(token).val(result.data.token); $(configured).val('true'); - OC.MountConfig.saveStorage(tr); - $(tr).find('.configuration input').attr('disabled', 'disabled'); - $(tr).find('.configuration').append($('<span/>') - .attr('id', 'access') - .text(t('files_external', 'Access granted'))); + OC.MountConfig.saveStorage(tr, function(status) { + if (status) { + $(tr).find('.configuration input').attr('disabled', 'disabled'); + $(tr).find('.configuration').append($('<span/>') + .attr('id', 'access') + .text(t('files_external', 'Access granted'))); + } + }); } else { OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Google Drive storage') @@ -99,7 +102,6 @@ $(document).ready(function() { var configured = $(this).parent().find('[data-parameter="configured"]'); var client_id = $(this).parent().find('[data-parameter="client_id"]').val(); var client_secret = $(this).parent().find('[data-parameter="client_secret"]').val(); - var statusSpan = $(tr).find('.status span'); if (client_id != '' && client_secret != '') { var token = $(this).parent().find('[data-parameter="token"]'); $.post(OC.filePath('files_external', 'ajax', 'google.php'), @@ -112,10 +114,9 @@ $(document).ready(function() { if (result && result.status == 'success') { $(configured).val('false'); $(token).val('false'); - OC.MountConfig.saveStorage(tr); - statusSpan.removeClass(); - statusSpan.addClass('waiting'); - window.location = result.data.url; + OC.MountConfig.saveStorage(tr, function(status) { + window.location = result.data.url; + }); } else { OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Google Drive storage') diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 886c324e338..895f97bd2c3 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -12,7 +12,7 @@ function updateStatus(statusEl, result){ } OC.MountConfig={ - saveStorage:function(tr) { + saveStorage:function(tr, callback) { var mountPoint = $(tr).find('.mountPoint input').val(); if (mountPoint == '') { return false; @@ -84,9 +84,15 @@ OC.MountConfig={ }, success: function(result) { status = updateStatus(statusSpan, result); + if (callback) { + callback(status); + } }, error: function(result){ status = updateStatus(statusSpan, result); + if (callback) { + callback(status); + } } }); }); @@ -137,9 +143,15 @@ OC.MountConfig={ }, success: function(result) { status = updateStatus(statusSpan, result); + if (callback) { + callback(status); + } }, error: function(result){ status = updateStatus(statusSpan, result); + if (callback) { + callback(status); + } } }); } diff --git a/apps/files_external/l10n/ru_RU.php b/apps/files_external/l10n/ru_RU.php deleted file mode 100644 index d517597f59c..00000000000 --- a/apps/files_external/l10n/ru_RU.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -$TRANSLATIONS = array( -"Options" => "Опции", -"Delete" => "Удалить" -); -$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 2abf7acb91e..01d588b3721 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -392,8 +392,7 @@ class OC_Mount_Config { * @return array */ public static function getCertificates() { - $view = \OCP\Files::getStorage('files_external'); - $path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/'; + $path=OC_User::getHome(OC_User::getUser()) . '/files_external/uploads/'; \OCP\Util::writeLog('files_external', 'checking path '.$path, \OCP\Util::INFO); if ( ! is_dir($path)) { //path might not exist (e.g. non-standard OC_User::getHome() value) @@ -415,8 +414,7 @@ class OC_Mount_Config { * creates certificate bundle */ public static function createCertificateBundle() { - $view = \OCP\Files::getStorage("files_external"); - $path = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath(""); + $path=OC_User::getHome(OC_User::getUser()) . '/files_external'; $certs = OC_Mount_Config::getCertificates(); $fh_certs = fopen($path."/rootcerts.crt", 'w'); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index cc7f3a5c9e2..f6f4cb16e87 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -14,6 +14,7 @@ class DAV extends \OC\Files\Storage\Common{ private $host; private $secure; private $root; + private $certPath; private $ready; /** * @var \Sabre_DAV_Client @@ -40,6 +41,12 @@ class DAV extends \OC\Files\Storage\Common{ } else { $this->secure = false; } + if ($this->secure === true) { + $certPath=\OC_User::getHome(\OC_User::getUser()) . '/files_external/rootcerts.crt'; + if (file_exists($certPath)) { + $this->certPath=$certPath; + } + } $this->root=isset($params['root'])?$params['root']:'/'; if ( ! $this->root || $this->root[0]!='/') { $this->root='/'.$this->root; @@ -58,20 +65,16 @@ class DAV extends \OC\Files\Storage\Common{ } $this->ready = true; - $settings = array( - 'baseUri' => $this->createBaseUri(), - 'userName' => $this->user, - 'password' => $this->password, - ); + $settings = array( + 'baseUri' => $this->createBaseUri(), + 'userName' => $this->user, + 'password' => $this->password, + ); $this->client = new \Sabre_DAV_Client($settings); - $caview = \OCP\Files::getStorage('files_external'); - if ($caview) { - $certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt'; - if (file_exists($certPath)) { - $this->client->addTrustedCertificates($certPath); - } + if ($this->secure === true && $this->certPath) { + $this->client->addTrustedCertificates($this->certPath); } } @@ -166,7 +169,14 @@ class DAV extends \OC\Files\Storage\Common{ curl_setopt($curl, CURLOPT_URL, $this->createBaseUri().str_replace(' ', '%20', $path)); curl_setopt($curl, CURLOPT_FILE, $fp); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); - + if ($this->secure === true) { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); + if($this->certPath){ + curl_setopt($curl, CURLOPT_CAINFO, $this->certPath); + } + } + curl_exec ($curl); curl_close ($curl); rewind($fp); @@ -214,7 +224,7 @@ class DAV extends \OC\Files\Storage\Common{ if (isset($response['{DAV:}quota-available-bytes'])) { return (int)$response['{DAV:}quota-available-bytes']; } else { - return 0; + return \OC\Files\SPACE_UNKNOWN; } } catch(\Exception $e) { return \OC\Files\SPACE_UNKNOWN; @@ -254,6 +264,13 @@ class DAV extends \OC\Files\Storage\Common{ curl_setopt($curl, CURLOPT_INFILE, $source); // file pointer curl_setopt($curl, CURLOPT_INFILESIZE, filesize($path)); curl_setopt($curl, CURLOPT_PUT, true); + if ($this->secure === true) { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); + if($this->certPath){ + curl_setopt($curl, CURLOPT_CAINFO, $this->certPath); + } + } curl_exec ($curl); curl_close ($curl); } @@ -331,3 +348,4 @@ class DAV extends \OC\Files\Storage\Common{ } } } + diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php index 54a9806e8bf..a52f522afac 100644 --- a/apps/files_sharing/ajax/publicpreview.php +++ b/apps/files_sharing/ajax/publicpreview.php @@ -39,6 +39,7 @@ if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) { $rootLinkItem = OCP\Share::resolveReShare($linkedItem); $userId = $rootLinkItem['uid_owner']; +OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); \OC_Util::setupFS($userId); \OC\Files\Filesystem::initMountPoints($userId); $view = new \OC\Files\View('/' . $userId . '/files'); @@ -88,4 +89,4 @@ try{ } catch (\Exception $e) { \OC_Response::setStatus(500); \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG); -}
\ No newline at end of file +} diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php index 0d827da28ea..4b716e764f4 100644 --- a/apps/files_sharing/appinfo/update.php +++ b/apps/files_sharing/appinfo/update.php @@ -44,6 +44,7 @@ if (version_compare($installedVersion, '0.3', '<')) { $shareType = OCP\Share::SHARE_TYPE_USER; $shareWith = $row['uid_shared_with']; } + OCP\JSON::checkUserExists($row['uid_owner']); OC_User::setUserId($row['uid_owner']); //we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break OC_Util::setupFS($row['uid_owner']); diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index d593d353dd7..7bcafd542ca 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -92,16 +92,24 @@ thead{ .directLink { margin-bottom: 20px; } - .directDownload .button img { - vertical-align: text-bottom; - } - .directLink label { - font-weight: normal; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; - filter: alpha(opacity=50); - opacity: .5; - } - .directLink input { - margin-left: 5px; - width: 300px; - } +.directDownload .button img { + vertical-align: text-bottom; +} +.directLink label { + font-weight: normal; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + filter: alpha(opacity=50); + opacity: .5; +} +.directLink input { + margin-left: 5px; + width: 300px; +} + +/*.directLink label {*/ + /*font-weight: normal;*/ +/*}*/ +/*.directLink input {*/ + /*margin-left: 10px;*/ + /*width: 300px;*/ +/*}*/ diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 63e1ccaadfa..31572f5ccf5 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -27,19 +27,19 @@ $(document).ready(function() { } } FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function(filename) { - var tr = $('tr').filterAttr('data-file', filename); + var tr = FileList.findFileEl(filename); if (tr.length > 0) { window.location = $(tr).find('a.name').attr('href'); } }); FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) { - var tr = $('tr').filterAttr('data-file', filename); + var tr = FileList.findFileEl(filename); if (tr.length > 0) { window.location = $(tr).find('a.name').attr('href'); } }); FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) { - var tr = $('tr').filterAttr('data-file', filename); + var tr = FileList.findFileEl(filename); if (tr.length > 0) { window.location = $(tr).find('a.name').attr('href')+'&download'; } diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 340e0939445..36de452a55e 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -22,7 +22,7 @@ $(document).ready(function() { } else { var item = $('#dir').val() + '/' + filename; } - var tr = $('tr').filterAttr('data-file', filename); + var tr = FileList.findFileEl(filename); if ($(tr).data('type') == 'dir') { var itemType = 'folder'; } else { diff --git a/apps/files_sharing/l10n/ru_RU.php b/apps/files_sharing/l10n/ru_RU.php deleted file mode 100644 index 2686b1e852d..00000000000 --- a/apps/files_sharing/l10n/ru_RU.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -$TRANSLATIONS = array( -"Password" => "Пароль", -"Download" => "Загрузка", -"Upload" => "Загрузка", -"Cancel upload" => "Отмена загрузки" -); -$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php index 07e7a4ca0c5..c956c55a1df 100644 --- a/apps/files_sharing/lib/share/file.php +++ b/apps/files_sharing/lib/share/file.php @@ -172,7 +172,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent { $source['fileOwner'] = $fileOwner; return $source; } - \OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, \OCP\Util::ERROR); + \OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, \OCP\Util::DEBUG); return false; } diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 6b4db9763f5..afe5dffdebd 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -279,14 +279,6 @@ class Shared extends \OC\Files\Storage\Common { if ($this->isDeletable($path)) { list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source); return $storage->unlink($internalPath); - } else if (dirname($path) == '/' || dirname($path) == '.') { - // Unshare the file from the user if in the root of the Shared folder - if ($this->is_dir($path)) { - $itemType = 'folder'; - } else { - $itemType = 'file'; - } - return \OCP\Share::unshareFromSelf($itemType, $path); } } return false; diff --git a/apps/files_sharing/lib/watcher.php b/apps/files_sharing/lib/watcher.php index c40cf6911b8..285b1a58c6e 100644 --- a/apps/files_sharing/lib/watcher.php +++ b/apps/files_sharing/lib/watcher.php @@ -32,7 +32,7 @@ class Shared_Watcher extends Watcher { * @param string $path */ public function checkUpdate($path) { - if ($path != '' && parent::checkUpdate($path)) { + if ($path != '' && parent::checkUpdate($path) === true) { // since checkUpdate() has already updated the size of the subdirs, // only apply the update to the owner's parent dirs diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 490cea570bc..0ca923fff08 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -35,7 +35,7 @@ function determineIcon($file, $sharingRoot, $sharingToken) { if (isset($_GET['t'])) { $token = $_GET['t']; - $linkItem = OCP\Share::getShareByToken($token); + $linkItem = OCP\Share::getShareByToken($token, false); if (is_array($linkItem) && isset($linkItem['uid_owner'])) { // seems to be a valid share $type = $linkItem['item_type']; @@ -43,10 +43,10 @@ if (isset($_GET['t'])) { $shareOwner = $linkItem['uid_owner']; $path = null; $rootLinkItem = OCP\Share::resolveReShare($linkItem); - $fileOwner = $rootLinkItem['uid_owner']; - if (isset($fileOwner)) { + if (isset($rootLinkItem['uid_owner'])) { + OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); OC_Util::tearDownFS(); - OC_Util::setupFS($fileOwner); + OC_Util::setupFS($rootLinkItem['uid_owner']); $path = \OC\Files\Filesystem::getPath($linkItem['file_source']); } } @@ -111,6 +111,7 @@ if (isset($path)) { } } $basePath = $path; + $rootName = basename($path); if (isset($_GET['path']) && \OC\Files\Filesystem::isReadable($basePath . $_GET['path'])) { $getPath = \OC\Files\Filesystem::normalizePath($_GET['path']); $path .= $getPath; @@ -188,8 +189,8 @@ if (isset($path)) { } else { $i['extension'] = ''; } - $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']); } + $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']); $i['directory'] = $getPath; $i['permissions'] = OCP\PERMISSION_READ; $i['icon'] = determineIcon($i, $basePath, $token); @@ -216,6 +217,7 @@ if (isset($path)) { $list->assign('sharingroot', $basePath); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); + $breadcrumbNav->assign('rootBreadCrumb', $rootName); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); $maxUploadFilesize=OCP\Util::maxUploadFilesize($path); $fileHeader = (!isset($files) or count($files) > 0); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index fb45401458f..fd0e0ad6412 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -16,7 +16,7 @@ <div class="header-right"> <span id="details"><?php p($l->t('shared by %s', array($_['displayName']))) ?></span> </div> - </div></header> +</header> <div id="content"> <div id="preview"> <?php if (isset($_['folder'])): ?> diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index 1ff5bac6130..46d8b56308c 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -3,8 +3,8 @@ $(document).ready(function() { if (typeof FileActions !== 'undefined') { FileActions.register('all', 'Restore', OC.PERMISSION_READ, OC.imagePath('core', 'actions/history'), function(filename) { - var tr = $('tr').filterAttr('data-file', filename); - var deleteAction = $('tr').filterAttr('data-file', filename).children("td.date").children(".action.delete"); + var tr = FileList.findFileEl(filename); + var deleteAction = tr.children("td.date").children(".action.delete"); deleteAction.removeClass('delete-icon').addClass('progress-icon'); disableActions(); $.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'), @@ -30,8 +30,8 @@ $(document).ready(function() { return OC.imagePath('core', 'actions/delete'); }, function(filename) { $('.tipsy').remove(); - var tr = $('tr').filterAttr('data-file', filename); - var deleteAction = $('tr').filterAttr('data-file', filename).children("td.date").children(".action.delete"); + var tr = FileList.findFileEl(filename); + var deleteAction = tr.children("td.date").children(".action.delete"); deleteAction.removeClass('delete-icon').addClass('progress-icon'); disableActions(); $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'), @@ -73,7 +73,7 @@ $(document).ready(function() { var dirlisting = getSelectedFiles('dirlisting')[0]; disableActions(); for (var i = 0; i < files.length; i++) { - var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete"); + var deleteAction = FileList.findFileEl(files[i]).children("td.date").children(".action.delete"); deleteAction.removeClass('delete-icon').addClass('progress-icon'); } @@ -119,7 +119,7 @@ $(document).ready(function() { } else { for (var i = 0; i < files.length; i++) { - var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete"); + var deleteAction = FileList.findFileEl(files[i]).children("td.date").children(".action.delete"); deleteAction.removeClass('delete-icon').addClass('progress-icon'); } } @@ -169,7 +169,7 @@ $(document).ready(function() { event.preventDefault(); } var filename = $(this).parent().parent().attr('data-file'); - var tr = $('tr').filterAttr('data-file',filename); + var tr = FileList.findFileEl(filename); var renaming = tr.data('renaming'); if(!renaming && !FileList.isLoading(filename)){ if(mime.substr(0, 5) === 'text/'){ //no texteditor for now diff --git a/apps/files_trashbin/l10n/ru_RU.php b/apps/files_trashbin/l10n/ru_RU.php deleted file mode 100644 index dfc99f594fd..00000000000 --- a/apps/files_trashbin/l10n/ru_RU.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -$TRANSLATIONS = array( -"Error" => "Ошибка", -"Delete" => "Удалить" -); -$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 567f88b91b1..7544980e071 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -189,7 +189,7 @@ class Trashbin { if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { $size += self::calculateSize(new \OC\Files\View('/' . $owner . '/files_versions/' . $ownerPath)); if ($owner !== $user) { - $rootView->copy($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp); + self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView); } $rootView->rename($owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp); } else if ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) { @@ -247,7 +247,7 @@ class Trashbin { if ($rootView->is_dir($keyfile)) { $size += self::calculateSize(new \OC\Files\View($keyfile)); if ($owner !== $user) { - $rootView->copy($keyfile, $owner . '/files_trashbin/keyfiles/' . basename($ownerPath) . '.d' . $timestamp); + self::copy_recursive($keyfile, $owner . '/files_trashbin/keyfiles/' . basename($ownerPath) . '.d' . $timestamp, $rootView); } $rootView->rename($keyfile, $user . '/files_trashbin/keyfiles/' . $filename . '.d' . $timestamp); } else { @@ -265,7 +265,7 @@ class Trashbin { if ($rootView->is_dir($sharekeys)) { $size += self::calculateSize(new \OC\Files\View($sharekeys)); if ($owner !== $user) { - $rootView->copy($sharekeys, $owner . '/files_trashbin/share-keys/' . basename($ownerPath) . '.d' . $timestamp); + self::copy_recursive($sharekeys, $owner . '/files_trashbin/share-keys/' . basename($ownerPath) . '.d' . $timestamp, $rootView); } $rootView->rename($sharekeys, $user . '/files_trashbin/share-keys/' . $filename . '.d' . $timestamp); } else { @@ -734,7 +734,7 @@ class Trashbin { // calculate available space for trash bin // subtract size of files and current trash bin size from quota if ($softQuota) { - $rootInfo = $view->getFileInfo('/files/'); + $rootInfo = $view->getFileInfo('/files/', false); $free = $quota - $rootInfo['size']; // remaining free space for user if ($free > 0) { $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 4f48f71d8ca..4cc1c428898 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -5,7 +5,8 @@ $source = $_GET['source']; $start = $_GET['start']; list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source); $count = 5; //show the newest revisions -if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename)) ) { +$versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source); +if( $versions ) { $endReached = false; if (count($versions) <= $start+$count) { diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php index 31525028ef3..bd9b7366ab0 100644 --- a/apps/files_versions/ajax/preview.php +++ b/apps/files_versions/ajax/preview.php @@ -12,18 +12,11 @@ if(!\OC_App::isEnabled('files_versions')){ } $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; -$user = array_key_exists('user', $_GET) ? $_GET['user'] : ''; $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : 44; $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : 44; $version = array_key_exists('version', $_GET) ? $_GET['version'] : ''; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; -if($user === '') { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('versions-preview', 'No user parameter was passed', \OC_Log::DEBUG); - exit; -} - if($file === '' && $version === '') { \OC_Response::setStatus(400); //400 Bad Request \OC_Log::write('versions-preview', 'No file parameter was passed', \OC_Log::DEBUG); @@ -36,7 +29,8 @@ if($maxX === 0 || $maxY === 0) { exit; } -try{ +try { + list($user, $file) = \OCA\Files_Versions\Storage::getUidAndFilename($file); $preview = new \OC\Preview($user, 'files_versions', $file.'.v'.$version); $mimetype = \OC_Helper::getFileNameMimeType($file); $preview->setMimetype($mimetype); diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 738a7ece6f2..4adf14745de 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -77,6 +77,7 @@ function goToVersionPage(url){ function createVersionsDropdown(filename, files) { var start = 0; + var fileEl; var html = '<div id="dropdown" class="drop drop-versions" data-file="'+escapeHTML(files)+'">'; html += '<div id="private">'; @@ -86,8 +87,9 @@ function createVersionsDropdown(filename, files) { html += '<input type="button" value="'+ t('files_versions', 'More versions...') + '" name="show-more-versions" id="show-more-versions" style="display: none;" />'; if (filename) { - $('tr').filterAttr('data-file',filename).addClass('mouseOver'); - $(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename')); + fileEl = FileList.findFileEl(filename); + fileEl.addClass('mouseOver'); + $(html).appendTo(fileEl.find('td.filename')); } else { $(html).appendTo($('thead .share')); } @@ -138,7 +140,7 @@ function createVersionsDropdown(filename, files) { var preview = '<img class="preview" src="'+revision.preview+'"/>'; - var download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">'; + var download ='<a href="' + path + "?file=" + encodeURIComponent(files) + '&revision=' + revision.version + '">'; download+='<img'; download+=' src="' + OC.imagePath('core', 'actions/download') + '"'; download+=' name="downloadVersion" />'; @@ -146,8 +148,7 @@ function createVersionsDropdown(filename, files) { download+='</a>'; var revert='<span class="revertVersion"'; - revert+=' id="' + revision.version + '"'; - revert+=' value="' + files + '">'; + revert+=' id="' + revision.version + '">'; revert+='<img'; revert+=' src="' + OC.imagePath('core', 'actions/history') + '"'; revert+=' name="revertVersion"'; @@ -156,14 +157,13 @@ function createVersionsDropdown(filename, files) { var version=$('<li/>'); version.attr('value', revision.version); version.html(preview + download + revert); + // add file here for proper name escaping + version.find('span.revertVersion').attr('value', files); version.appendTo('#found_versions'); } - $('tr').filterAttr('data-file',filename).addClass('mouseOver'); $('#dropdown').show('blind'); - - } $(this).click( diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 42a15612d67..328ed4305f4 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -98,7 +98,6 @@ class Storage { $files_view = new \OC\Files\View('/'.$uid .'/files'); $users_view = new \OC\Files\View('/'.$uid); - $versions_view = new \OC\Files\View('/'.$uid.'/files_versions'); // check if filename is a directory if($files_view->is_dir($filename)) { @@ -132,7 +131,10 @@ class Storage { \OC_FileProxy::$enabled = false; // store a new version of a file - $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename)); + $mtime = $users_view->filemtime('files'.$filename); + $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'. $mtime); + // call getFileInfo to enforce a file cache entry for the new version + $users_view->getFileInfo('files_versions'.$filename.'.v'.$mtime); // reset proxy state \OC_FileProxy::$enabled = $proxyStatus; @@ -259,11 +261,12 @@ class Storage { /** * @brief get a list of all available versions of a file in descending chronological order - * @param $uid user id from the owner of the file - * @param $filename file to find versions of, relative to the user files dir - * @returns array + * @param string $uid user id from the owner of the file + * @param string $filename file to find versions of, relative to the user files dir + * @param string $userFullPath + * @returns array versions newest version first */ - public static function getVersions($uid, $filename) { + public static function getVersions($uid, $filename, $userFullPath = '') { $versions = array(); // fetch for old versions $view = new \OC\Files\View('/' . $uid . '/' . self::VERSIONS_ROOT); @@ -284,7 +287,11 @@ class Storage { $versions[$key]['cur'] = 0; $versions[$key]['version'] = $version; $versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version); - $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version, 'user' => $uid)); + if (empty($userFullPath)) { + $versions[$key]['preview'] = ''; + } else { + $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $userFullPath, 'version' => $version)); + } $versions[$key]['path'] = $filename; $versions[$key]['name'] = $versionedFile; $versions[$key]['size'] = $file['size']; @@ -390,12 +397,13 @@ class Storage { } } - ksort($versions); + // newest version first + krsort($versions); $result = array(); foreach ($versions as $key => $value) { - $size = $view->filesize($value['path']); + $size = $view->filesize(self::VERSIONS_ROOT.'/'.$value['path'].'.v'.$value['timestamp']); $filename = $value['path']; $result['all'][$key]['version'] = $value['timestamp']; @@ -411,6 +419,63 @@ class Storage { } /** + * @brief get list of files we want to expire + * @param int $currentTime timestamp of current time + * @param array $versions list of versions + * @return array containing the list of to deleted versions and the size of them + */ + protected static function getExpireList($time, $versions) { + + $size = 0; + $toDelete = array(); // versions we want to delete + + $interval = 1; + $step = Storage::$max_versions_per_interval[$interval]['step']; + if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { + $nextInterval = -1; + } else { + $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; + } + + $firstVersion = reset($versions); + $firstKey = key($versions); + $prevTimestamp = $firstVersion['version']; + $nextVersion = $firstVersion['version'] - $step; + unset($versions[$firstKey]); + + foreach ($versions as $key => $version) { + $newInterval = true; + while ($newInterval) { + if ($nextInterval == -1 || $prevTimestamp > $nextInterval) { + if ($version['version'] > $nextVersion) { + //distance between two version too small, mark to delete + $toDelete[$key] = $version['path'] . '.v' . $version['version']; + $size += $version['size']; + \OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::DEBUG); + } else { + $nextVersion = $version['version'] - $step; + $prevTimestamp = $version['version']; + } + $newInterval = false; // version checked so we can move to the next one + } else { // time to move on to the next interval + $interval++; + $step = Storage::$max_versions_per_interval[$interval]['step']; + $nextVersion = $prevTimestamp - $step; + if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { + $nextInterval = -1; + } else { + $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; + } + $newInterval = true; // we changed the interval -> check same version with new interval + } + } + } + + return array($toDelete, $size); + + } + + /** * @brief Erase a file's versions which exceed the set quota */ private static function expire($filename, $versionsSize = null, $offset = 0) { @@ -443,7 +508,7 @@ class Storage { // subtract size of files and current versions size from quota if ($softQuota) { $files_view = new \OC\Files\View('/'.$uid.'/files'); - $rootInfo = $files_view->getFileInfo('/'); + $rootInfo = $files_view->getFileInfo('/', false); $free = $quota-$rootInfo['size']; // remaining free space for user if ( $free > 0 ) { $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - ($versionsSize + $offset); // how much space can be used for versions @@ -454,33 +519,35 @@ class Storage { $availableSpace = $quota - $offset; } - - // with the probability of 0.1% we reduce the number of all versions not only for the current file - $random = rand(0, 1000); - if ($random == 0) { - $allFiles = true; - } else { - $allFiles = false; - } - $allVersions = Storage::getVersions($uid, $filename); - $versionsByFile[$filename] = $allVersions; - $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview); + $time = time(); + list($toDelete, $sizeOfDeletedVersions) = self::getExpireList($time, $allVersions); + $availableSpace = $availableSpace + $sizeOfDeletedVersions; $versionsSize = $versionsSize - $sizeOfDeletedVersions; // if still not enough free space we rearrange the versions from all files - if ($availableSpace <= 0 || $allFiles) { + if ($availableSpace <= 0) { $result = Storage::getAllVersions($uid); - $versionsByFile = $result['by_file']; $allVersions = $result['all']; - $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview); + foreach ($result['by_file'] as $versions) { + list($toDeleteNew, $size) = self::getExpireList($time, $versions); + $toDelete = array_merge($toDelete, $toDeleteNew); + $sizeOfDeletedVersions += $size; + } $availableSpace = $availableSpace + $sizeOfDeletedVersions; $versionsSize = $versionsSize - $sizeOfDeletedVersions; } + foreach($toDelete as $key => $path) { + \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path)); + $versionsFileview->unlink($path); + unset($allVersions[$key]); // update array with the versions we keep + \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG); + } + // Check if enough space is available after versions are rearranged. // If not we delete the oldest versions until we meet the size limit for versions, // but always keep the two latest versions @@ -490,6 +557,7 @@ class Storage { $version = current($allVersions); $versionsFileview->unlink($version['path'].'.v'.$version['version']); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'])); + \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::DEBUG); $versionsSize -= $version['size']; $availableSpace += $version['size']; next($allVersions); @@ -503,69 +571,6 @@ class Storage { } /** - * @brief delete old version from a given list of versions - * - * @param array $versionsByFile list of versions ordered by files - * @param array $allVversions all versions accross multiple files - * @param $versionsFileview OC\Files\View on data/user/files_versions - * @return size of releted versions - */ - private static function delOldVersions($versionsByFile, &$allVersions, $versionsFileview) { - - $time = time(); - $size = 0; - - // delete old versions for every given file - foreach ($versionsByFile as $versions) { - $versions = array_reverse($versions); // newest version first - - $interval = 1; - $step = Storage::$max_versions_per_interval[$interval]['step']; - if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { - $nextInterval = -1; - } else { - $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; - } - - $firstVersion = reset($versions); - $firstKey = key($versions); - $prevTimestamp = $firstVersion['version']; - $nextVersion = $firstVersion['version'] - $step; - unset($versions[$firstKey]); - - foreach ($versions as $key => $version) { - $newInterval = true; - while ($newInterval) { - if ($nextInterval == -1 || $version['version'] >= $nextInterval) { - if ($version['version'] > $nextVersion) { - //distance between two version too small, delete version - $versionsFileview->unlink($version['path'] . '.v' . $version['version']); - \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'] . '.v' . $version['version'])); - $size += $version['size']; - unset($allVersions[$key]); // update array with all versions - } else { - $nextVersion = $version['version'] - $step; - } - $newInterval = false; // version checked so we can move to the next one - } else { // time to move on to the next interval - $interval++; - $step = Storage::$max_versions_per_interval[$interval]['step']; - $nextVersion = $prevTimestamp - $step; - if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { - $nextInterval = -1; - } else { - $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; - } - $newInterval = true; // we changed the interval -> check same version with new interval - } - } - $prevTimestamp = $version['version']; - } - } - return $size; - } - - /** * @brief create recursively missing directories * @param string $filename $path to a file * @param \OC\Files\View $view view on data/user/ diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php new file mode 100644 index 00000000000..25490aa1a04 --- /dev/null +++ b/apps/files_versions/tests/versions.php @@ -0,0 +1,188 @@ +<?php +/** + * ownCloud + * + * @author Bjoern Schiessle + * @copyright 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 + * 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/>. + * + */ + +require_once __DIR__ . '/../lib/versions.php'; + +/** + * Class Test_Files_versions + * @brief this class provide basic files versions test + */ +class Test_Files_Versioning extends \PHPUnit_Framework_TestCase { + + + /** + * @medium + * @brief test expire logic + * @dataProvider versionsProvider + */ + function testGetExpireList($versions, $sizeOfAllDeletedFiles) { + + // last interval enda at 2592000 + $startTime = 5000000; + + $testClass = new VersionStorageToTest(); + list($deleted, $size) = $testClass->callProtectedGetExpireList($startTime, $versions); + + // we should have deleted 16 files each of the size 1 + $this->assertEquals($sizeOfAllDeletedFiles, $size); + + // the deleted array should only contain versions which should be deleted + foreach($deleted as $key => $path) { + unset($versions[$key]); + $this->assertEquals("delete", substr($path, 0, strlen("delete"))); + } + + // the versions array should only contain versions which should be kept + foreach ($versions as $version) { + $this->assertEquals("keep", $version['path']); + } + + } + + public function versionsProvider() { + return array( + // first set of versions uniformly distributed versions + array( + array( + // first slice (10sec) keep one version every 2 seconds + array("version" => 4999999, "path" => "keep", "size" => 1), + array("version" => 4999998, "path" => "delete", "size" => 1), + array("version" => 4999997, "path" => "keep", "size" => 1), + array("version" => 4999995, "path" => "keep", "size" => 1), + array("version" => 4999994, "path" => "delete", "size" => 1), + //next slice (60sec) starts at 4999990 keep one version every 10 secons + array("version" => 4999988, "path" => "keep", "size" => 1), + array("version" => 4999978, "path" => "keep", "size" => 1), + array("version" => 4999975, "path" => "delete", "size" => 1), + array("version" => 4999972, "path" => "delete", "size" => 1), + array("version" => 4999967, "path" => "keep", "size" => 1), + array("version" => 4999958, "path" => "delete", "size" => 1), + array("version" => 4999957, "path" => "keep", "size" => 1), + //next slice (3600sec) start at 4999940 keep one version every 60 seconds + array("version" => 4999900, "path" => "keep", "size" => 1), + array("version" => 4999841, "path" => "delete", "size" => 1), + array("version" => 4999840, "path" => "keep", "size" => 1), + array("version" => 4999780, "path" => "keep", "size" => 1), + array("version" => 4996401, "path" => "keep", "size" => 1), + // next slice (86400sec) start at 4996400 keep one version every 3600 seconds + array("version" => 4996350, "path" => "delete", "size" => 1), + array("version" => 4992800, "path" => "keep", "size" => 1), + array("version" => 4989800, "path" => "delete", "size" => 1), + array("version" => 4989700, "path" => "delete", "size" => 1), + array("version" => 4989200, "path" => "keep", "size" => 1), + // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds + array("version" => 4913600, "path" => "keep", "size" => 1), + array("version" => 4852800, "path" => "delete", "size" => 1), + array("version" => 4827201, "path" => "delete", "size" => 1), + array("version" => 4827200, "path" => "keep", "size" => 1), + array("version" => 4777201, "path" => "delete", "size" => 1), + array("version" => 4777501, "path" => "delete", "size" => 1), + array("version" => 4740000, "path" => "keep", "size" => 1), + // final slice starts at 2408000 keep one version every 604800 secons + array("version" => 2408000, "path" => "keep", "size" => 1), + array("version" => 1803201, "path" => "delete", "size" => 1), + array("version" => 1803200, "path" => "keep", "size" => 1), + array("version" => 1800199, "path" => "delete", "size" => 1), + array("version" => 1800100, "path" => "delete", "size" => 1), + array("version" => 1198300, "path" => "keep", "size" => 1), + ), + 16 // size of all deleted files (every file has the size 1) + ), + // second set of versions, here we have only really old versions + array( + array( + // first slice (10sec) keep one version every 2 seconds + // next slice (60sec) starts at 4999990 keep one version every 10 secons + // next slice (3600sec) start at 4999940 keep one version every 60 seconds + // next slice (86400sec) start at 4996400 keep one version every 3600 seconds + array("version" => 4996400, "path" => "keep", "size" => 1), + array("version" => 4996350, "path" => "delete", "size" => 1), + array("version" => 4996350, "path" => "delete", "size" => 1), + array("version" => 4992800, "path" => "keep", "size" => 1), + array("version" => 4989800, "path" => "delete", "size" => 1), + array("version" => 4989700, "path" => "delete", "size" => 1), + array("version" => 4989200, "path" => "keep", "size" => 1), + // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds + array("version" => 4913600, "path" => "keep", "size" => 1), + array("version" => 4852800, "path" => "delete", "size" => 1), + array("version" => 4827201, "path" => "delete", "size" => 1), + array("version" => 4827200, "path" => "keep", "size" => 1), + array("version" => 4777201, "path" => "delete", "size" => 1), + array("version" => 4777501, "path" => "delete", "size" => 1), + array("version" => 4740000, "path" => "keep", "size" => 1), + // final slice starts at 2408000 keep one version every 604800 secons + array("version" => 2408000, "path" => "keep", "size" => 1), + array("version" => 1803201, "path" => "delete", "size" => 1), + array("version" => 1803200, "path" => "keep", "size" => 1), + array("version" => 1800199, "path" => "delete", "size" => 1), + array("version" => 1800100, "path" => "delete", "size" => 1), + array("version" => 1198300, "path" => "keep", "size" => 1), + ), + 11 // size of all deleted files (every file has the size 1) + ), + // third set of versions, with some gaps inbetween + array( + array( + // first slice (10sec) keep one version every 2 seconds + array("version" => 4999999, "path" => "keep", "size" => 1), + array("version" => 4999998, "path" => "delete", "size" => 1), + array("version" => 4999997, "path" => "keep", "size" => 1), + array("version" => 4999995, "path" => "keep", "size" => 1), + array("version" => 4999994, "path" => "delete", "size" => 1), + //next slice (60sec) starts at 4999990 keep one version every 10 secons + array("version" => 4999988, "path" => "keep", "size" => 1), + array("version" => 4999978, "path" => "keep", "size" => 1), + //next slice (3600sec) start at 4999940 keep one version every 60 seconds + // next slice (86400sec) start at 4996400 keep one version every 3600 seconds + array("version" => 4989200, "path" => "keep", "size" => 1), + // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds + array("version" => 4913600, "path" => "keep", "size" => 1), + array("version" => 4852800, "path" => "delete", "size" => 1), + array("version" => 4827201, "path" => "delete", "size" => 1), + array("version" => 4827200, "path" => "keep", "size" => 1), + array("version" => 4777201, "path" => "delete", "size" => 1), + array("version" => 4777501, "path" => "delete", "size" => 1), + array("version" => 4740000, "path" => "keep", "size" => 1), + // final slice starts at 2408000 keep one version every 604800 secons + array("version" => 2408000, "path" => "keep", "size" => 1), + array("version" => 1803201, "path" => "delete", "size" => 1), + array("version" => 1803200, "path" => "keep", "size" => 1), + array("version" => 1800199, "path" => "delete", "size" => 1), + array("version" => 1800100, "path" => "delete", "size" => 1), + array("version" => 1198300, "path" => "keep", "size" => 1), + ), + 9 // size of all deleted files (every file has the size 1) + ), + + ); + } + +} + +// extend the original class to make it possible to test protected methods +class VersionStorageToTest extends \OCA\Files_Versions\Storage { + + public function callProtectedGetExpireList($time, $versions) { + return self::getExpireList($time, $versions); + + } +} diff --git a/apps/user_ldap/l10n/ru_RU.php b/apps/user_ldap/l10n/ru_RU.php deleted file mode 100644 index 696e44a5bb5..00000000000 --- a/apps/user_ldap/l10n/ru_RU.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -$TRANSLATIONS = array( -"Error" => "Ошибка", -"Select groups" => "Выбрать группы", -"_%s group found_::_%s groups found_" => array("","",""), -"_%s user found_::_%s users found_" => array("","",""), -"Save" => "Сохранить", -"Help" => "Помощь", -"Password" => "Пароль", -"Back" => "Назад" -); -$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"; diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 14dfaa1174d..c4e4efd0483 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -50,7 +50,8 @@ class Connection extends LDAPUtility { parent::__construct($ldap); $this->configPrefix = $configPrefix; $this->configID = $configID; - $this->configuration = new Configuration($configPrefix); + $this->configuration = new Configuration($configPrefix, + !is_null($configID)); $memcache = new \OC\Memcache\Factory(); if($memcache->isAvailable()) { $this->cache = $memcache->create(); diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php index 09f646921e3..9727d847d27 100644 --- a/apps/user_ldap/lib/helper.php +++ b/apps/user_ldap/lib/helper.php @@ -48,18 +48,25 @@ class Helper { static public function getServerConfigurationPrefixes($activeConfigurations = false) { $referenceConfigkey = 'ldap_configuration_active'; - $query = ' + $sql = ' SELECT DISTINCT `configkey` FROM `*PREFIX*appconfig` WHERE `appid` = \'user_ldap\' AND `configkey` LIKE ? '; + if($activeConfigurations) { - $query .= ' AND `configvalue` = \'1\''; + if (\OC_Config::getValue( 'dbtype', 'sqlite' ) === 'oci') { + //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison + $sql .= ' AND to_char(`configvalue`)=\'1\''; + } else { + $sql .= ' AND `configvalue` = \'1\''; + } } - $query = \OCP\DB::prepare($query); - $serverConfigs = $query->execute(array('%'.$referenceConfigkey))->fetchAll(); + $stmt = \OCP\DB::prepare($sql); + + $serverConfigs = $stmt->execute(array('%'.$referenceConfigkey))->fetchAll(); $prefixes = array(); foreach($serverConfigs as $serverConfig) { diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 348a871e2b3..b70ede8599c 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -792,10 +792,13 @@ class Wizard extends LDAPUtility { \OCP\Util::writeLog('user_ldap', 'Wiz: Setting LDAP Options ', \OCP\Util::DEBUG); //set LDAP options - $a = $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); - $c = $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); + $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); + $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); if($tls) { - $this->ldap->startTls($cr); + $isTlsWorking = @$this->ldap->startTls($cr); + if(!$isTlsWorking) { + return false; + } } \OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', \OCP\Util::DEBUG); @@ -809,7 +812,7 @@ class Wizard extends LDAPUtility { if($ncc) { throw new \Exception('Certificate cannot be validated.'); } - \OCP\Util::writeLog('user_ldap', 'Wiz: Bind succesfull with Port '. $port, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successfull to Port '. $port . ' TLS ' . intval($tls), \OCP\Util::DEBUG); return true; } |