diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/upload.php | 4 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 10 | ||||
-rw-r--r-- | apps/files/lib/app.php | 6 | ||||
-rw-r--r-- | apps/files/tests/ajax_rename.php | 71 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 119 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 9 | ||||
-rw-r--r-- | apps/user_ldap/lib/access.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/lib/connection.php | 4 |
8 files changed, 216 insertions, 13 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index fcee0166da6..7bf6c40e87c 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -168,7 +168,7 @@ if (strpos($dir, '..') === false) { } else { $data = \OCA\Files\Helper::formatFileInfo($meta); $data['status'] = 'success'; - $data['originalname'] = $files['tmp_name'][$i]; + $data['originalname'] = $files['name'][$i]; $data['uploadMaxFilesize'] = $maxUploadFileSize; $data['maxHumanFilesize'] = $maxHumanFileSize; $data['permissions'] = $meta['permissions'] & $allowedPermissions; @@ -195,7 +195,7 @@ if (strpos($dir, '..') === false) { } else { $data['status'] = 'readonly'; } - $data['originalname'] = $files['tmp_name'][$i]; + $data['originalname'] = $files['name'][$i]; $data['uploadMaxFilesize'] = $maxUploadFileSize; $data['maxHumanFilesize'] = $maxHumanFileSize; $data['permissions'] = $meta['permissions'] & $allowedPermissions; diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index d6d5bcf912e..1d7252220bf 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1674,7 +1674,9 @@ setFilter:function(filter) { this._filter = filter; this.fileSummary.setFilter(filter, this.files); - this.hideIrrelevantUIWhenNoFilesMatch(); + if (!this.$el.find('.mask').exists()) { + this.hideIrrelevantUIWhenNoFilesMatch(); + } var that = this; this.$fileList.find('tr').each(function(i,e) { var $e = $(e); @@ -1690,13 +1692,15 @@ if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) { this.$el.find('#filestable thead th').addClass('hidden'); this.$el.find('#emptycontent').addClass('hidden'); - if ( $('#searchresults').length === 0 || $('#searchresults').hasClass('hidden')) { + if ( $('#searchresults').length === 0 || $('#searchresults').hasClass('hidden') ) { this.$el.find('.nofilterresults').removeClass('hidden'). find('p').text(t('files', "No entries in this folder match '{filter}'", {filter:this._filter}, null, {'escape': false})); } } else { this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty); - this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); + if (!this.$el.find('.mask').exists()) { + this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); + } this.$el.find('.nofilterresults').addClass('hidden'); } }, diff --git a/apps/files/lib/app.php b/apps/files/lib/app.php index c21e44bff4e..47d0ec9be9d 100644 --- a/apps/files/lib/app.php +++ b/apps/files/lib/app.php @@ -104,9 +104,11 @@ class App { ) { // successful rename $meta = $this->view->getFileInfo($normalizedNewPath); - $fileinfo = \OCA\Files\Helper::formatFileInfo($meta); + $meta = \OCA\Files\Helper::populateTags(array($meta)); + $fileInfo = \OCA\Files\Helper::formatFileInfo(current($meta)); + $fileInfo['path'] = dirname($normalizedNewPath); $result['success'] = true; - $result['data'] = $fileinfo; + $result['data'] = $fileInfo; } else { // rename failed $result['data'] = array( diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php index 1cfecf9e58c..488c741d3f6 100644 --- a/apps/files/tests/ajax_rename.php +++ b/apps/files/tests/ajax_rename.php @@ -117,12 +117,83 @@ class Test_OC_Files_App_Rename extends \Test\TestCase { $this->assertEquals(18, $result['data']['size']); $this->assertEquals('httpd/unix-directory', $result['data']['mimetype']); $this->assertEquals('abcdef', $result['data']['etag']); + $this->assertFalse(isset($result['data']['tags'])); + $this->assertEquals('/', $result['data']['path']); $icon = \OC_Helper::mimetypeIcon('dir'); $icon = substr($icon, 0, -3) . 'svg'; $this->assertEquals($icon, $result['data']['icon']); } /** + * test rename of file with tag + */ + function testRenameFileWithTag() { + $taggerMock = $this->getMock('\OCP\ITags'); + $taggerMock->expects($this->any()) + ->method('getTagsForObjects') + ->with(array(123)) + ->will($this->returnValue(array(123 => array('tag1', 'tag2')))); + $tagManagerMock = $this->getMock('\OCP\ITagManager'); + $tagManagerMock->expects($this->any()) + ->method('load') + ->with('files') + ->will($this->returnValue($taggerMock)); + $oldTagManager = \OC::$server->query('TagManager'); + \OC::$server->registerService('TagManager', function ($c) use ($tagManagerMock) { + return $tagManagerMock; + }); + + $dir = '/'; + $oldname = 'oldname.txt'; + $newname = 'newname.txt'; + + $this->viewMock->expects($this->any()) + ->method('file_exists') + ->with($this->anything()) + ->will($this->returnValueMap(array( + array('/', true), + array('/oldname.txt', true) + ))); + + + $this->viewMock->expects($this->any()) + ->method('getFileInfo') + ->will($this->returnValue(new \OC\Files\FileInfo( + '/new_name.txt', + new \OC\Files\Storage\Local(array('datadir' => '/')), + '/', + array( + 'fileid' => 123, + 'type' => 'file', + 'mimetype' => 'text/plain', + 'mtime' => 0, + 'permissions' => 31, + 'size' => 18, + 'etag' => 'abcdef', + 'directory' => '/', + 'name' => 'new_name.txt', + ), null))); + + $result = $this->files->rename($dir, $oldname, $newname); + + $this->assertTrue($result['success']); + $this->assertEquals(123, $result['data']['id']); + $this->assertEquals('new_name.txt', $result['data']['name']); + $this->assertEquals(18, $result['data']['size']); + $this->assertEquals('text/plain', $result['data']['mimetype']); + $this->assertEquals('abcdef', $result['data']['etag']); + $this->assertEquals(array('tag1', 'tag2'), $result['data']['tags']); + $this->assertEquals('/', $result['data']['path']); + $icon = \OC_Helper::mimetypeIcon('text'); + $icon = substr($icon, 0, -3) . 'svg'; + $this->assertEquals($icon, $result['data']['icon']); + + \OC::$server->registerService('TagManager', function ($c) use ($oldTagManager) { + return $oldTagManager; + }); + } + + /** * Test rename inside a folder that doesn't exist any more */ function testRenameInNonExistingFolder() { diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 6dafa262715..c1c8e4ce337 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -61,8 +61,8 @@ describe('OCA.Files.FileList tests', function() { $('#testArea').append( '<div id="app-content-files">' + // init horrible parameters - '<input type="hidden" id="dir" value="/subdir"></input>' + - '<input type="hidden" id="permissions" value="31"></input>' + + '<input type="hidden" id="dir" value="/subdir"/>' + + '<input type="hidden" id="permissions" value="31"/>' + // dummy controls '<div id="controls">' + ' <div class="actions creatable"></div>' + @@ -88,6 +88,7 @@ describe('OCA.Files.FileList tests', function() { '<tfoot></tfoot>' + '</table>' + '<div id="emptycontent">Empty content message</div>' + + '<div class="nofilterresults hidden"></div>' + '</div>' ); @@ -763,7 +764,7 @@ describe('OCA.Files.FileList tests', function() { fakeServer.requests[0].respond(200, {'Content-Type': 'application/json'}, JSON.stringify({ status: 'error', data: { - message: 'Error while moving file', + message: 'Error while moving file' } })); @@ -785,7 +786,7 @@ describe('OCA.Files.FileList tests', function() { fakeServer.requests[0].respond(200, {'Content-Type': 'application/json'}, JSON.stringify({ status: 'error', data: { - message: 'Error while moving file', + message: 'Error while moving file' } })); @@ -901,6 +902,116 @@ describe('OCA.Files.FileList tests', function() { expect($summary.find('.info').text()).toEqual('0 folders and 1 file'); }); }); + describe('Filtered list rendering', function() { + it('filters the list of files using filter()', function() { + expect(fileList.files.length).toEqual(0); + expect(fileList.files).toEqual([]); + fileList.setFiles(testFiles); + var $summary = $('#filestable .summary'); + var $nofilterresults = fileList.$el.find(".nofilterresults"); + expect($nofilterresults.length).toEqual(1); + expect($summary.hasClass('hidden')).toEqual(false); + + expect($('#fileList tr:not(.hidden)').length).toEqual(4); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('e'); + expect($('#fileList tr:not(.hidden)').length).toEqual(3); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("1 folder and 2 files match 'e'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('ee'); + expect($('#fileList tr:not(.hidden)').length).toEqual(1); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("0 folders and 1 file matches 'ee'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('eee'); + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(false); + + fileList.setFilter('ee'); + expect($('#fileList tr:not(.hidden)').length).toEqual(1); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("0 folders and 1 file matches 'ee'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('e'); + expect($('#fileList tr:not(.hidden)').length).toEqual(3); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("1 folder and 2 files match 'e'"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter(''); + expect($('#fileList tr:not(.hidden)').length).toEqual(4); + expect(fileList.files.length).toEqual(4); + expect($summary.hasClass('hidden')).toEqual(false); + expect($summary.find('.info').text()).toEqual("1 folder and 3 files"); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + }); + it('hides the emptyfiles notice when using filter()', function() { + expect(fileList.files.length).toEqual(0); + expect(fileList.files).toEqual([]); + fileList.setFiles([]); + var $summary = $('#filestable .summary'); + var $emptycontent = fileList.$el.find("#emptycontent"); + var $nofilterresults = fileList.$el.find(".nofilterresults"); + expect($emptycontent.length).toEqual(1); + expect($nofilterresults.length).toEqual(1); + + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(0); + expect($summary.hasClass('hidden')).toEqual(true); + expect($emptycontent.hasClass('hidden')).toEqual(false); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + fileList.setFilter('e'); + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(0); + expect($summary.hasClass('hidden')).toEqual(true); + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(false); + + fileList.setFilter(''); + expect($('#fileList tr:not(.hidden)').length).toEqual(0); + expect(fileList.files.length).toEqual(0); + expect($summary.hasClass('hidden')).toEqual(true); + expect($emptycontent.hasClass('hidden')).toEqual(false); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + }); + it('does not show the emptyfiles or nofilterresults notice when the mask is active', function() { + expect(fileList.files.length).toEqual(0); + expect(fileList.files).toEqual([]); + fileList.showMask(); + fileList.setFiles(testFiles); + var $emptycontent = fileList.$el.find("#emptycontent"); + var $nofilterresults = fileList.$el.find(".nofilterresults"); + expect($emptycontent.length).toEqual(1); + expect($nofilterresults.length).toEqual(1); + + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + + /* + fileList.setFilter('e'); + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(false); + */ + + fileList.setFilter(''); + expect($emptycontent.hasClass('hidden')).toEqual(true); + expect($nofilterresults.hasClass('hidden')).toEqual(true); + }); + }); describe('Rendering next page on scroll', function() { beforeEach(function() { fileList.setFiles(generateFiles(0, 64)); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 3ee7d83f04c..4972e1dffd6 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -59,6 +59,15 @@ class Proxy extends \OC_FileProxy { $parts = explode('/', $path); // we only encrypt/decrypt files in the files and files_versions folder + if (sizeof($parts) < 3) { + /** + * Less then 3 parts means, we can't match: + * - /{$uid}/files/* nor + * - /{$uid}/files_versions/* + * So this is not a path we are looking for. + */ + return true; + } if( strpos($path, '/' . $uid . '/files/') !== 0 && !($parts[2] === 'files_versions' && \OCP\User::userExists($parts[1]))) { diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index f3657176f70..0fb968cebe7 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -149,7 +149,11 @@ class Access extends LDAPUtility implements user\IUserTools { $this->abandonPagedSearch(); // openLDAP requires that we init a new Paged Search. Not needed by AD, // but does not hurt either. - $this->initPagedSearch($filter, array($dn), array($attr), 1, 0); + $pagingSize = intval($this->connection->ldapPagingSize); + // 0 won't result in replies, small numbers may leave out groups + // (cf. #12306), 500 is default for paging and should work everywhere. + $maxResults = $pagingSize < 20 ? $pagingSize : 500; + $this->initPagedSearch($filter, array($dn), array($attr), $maxResults, 0); $dn = $this->DNasBaseParameter($dn); $rr = @$this->ldap->read($cr, $dn, $filter, array($attr)); if(!$this->ldap->isResource($rr)) { diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index c9b4fded9f9..a9d21ffc8e7 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -26,11 +26,13 @@ namespace OCA\user_ldap\lib; //magic properties (incomplete) /** * responsible for LDAP connections in context with the provided configuration + * * @property string ldapUserFilter * @property string ldapUserDisplayName * @property boolean hasPagedResultSupport * @property string[] ldapBaseUsers -*/ + * @property int|string ldapPagingSize holds an integer + */ class Connection extends LDAPUtility { private $ldapConnectionRes = null; private $configPrefix; |