diff options
24 files changed, 336 insertions, 1063 deletions
diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index a9b72252e88..7f64f1cf7db 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -8,43 +8,59 @@ * */ +#commentsTabView .emptycontent { + margin-top: 0; +} + #commentsTabView .newCommentForm { + position: relative; margin-bottom: 20px; } #commentsTabView .newCommentForm .message { - width: 90%; - resize: vertical; + width: calc(100% - 81px); /* 36 (left margin) + 30 (right padding) + 15 (right padding of surrounding box) */ + margin-left: 36px; + padding-right: 30px; +} + +#commentsTabView .newCommentForm .submit { + position: absolute; + top: 1px; + right: 8px; + width: 30px; + margin: 0; + padding: 9px; + background-color: transparent; + border: none; + opacity: .3; +} +#commentsTabView .newCommentForm .submit:hover, +#commentsTabView .newCommentForm .submit:focus { + opacity: 1; } #commentsTabView .newCommentForm .submitLoading { background-position: left; } -#commentsTabView .comment { - margin-bottom: 30px; -} - -#commentsTabView .comment .avatar { - width: 28px; - height: 28px; - line-height: 28px; +#commentsTabView .newCommentForm .cancel { + margin-right: 6px; } #commentsTabView .comment { position: relative; z-index: 1; + margin-bottom: 30px; +} + +#commentsTabView .comment .avatar { + width: 32px; + height: 32px; + line-height: 32px; } #commentsTabView .comment.collapsed .message { - white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ - white-space: -webkit-pre-wrap; /*Chrome & Safari */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - white-space: pre-wrap; /* css-3 */ - word-wrap: break-word; /* Internet Explorer 5.5+ */ - word-break: break-all; - white-space: normal; + white-space: pre-wrap; } #commentsTabView .comment.collapsed .message { @@ -80,17 +96,24 @@ } #commentsTabView .comment .authorRow { - margin-bottom: 5px; position: relative; } +#commentsTabView .comment .author, +#commentsTabView .comment .date { + opacity: .5; +} #commentsTabView .comment .author { - font-weight: bold; + margin-left: 5px; } - #commentsTabView .comment .date { position: absolute; right: 0; + top: 5px; +} + +#commentsTabView .comments li .message { + padding-left: 40px; } #commentsTabView .comment .action { diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index f71567f04d1..9451e828f91 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -14,7 +14,8 @@ var TEMPLATE = '<ul class="comments">' + '</ul>' + - '<div class="empty hidden">{{emptyResultLabel}}</div>' + + '<div class="emptycontent hidden"><div class="icon-comment"></div>' + + '<p>{{emptyResultLabel}}</p></div>' + '<input type="button" class="showMore hidden" value="{{moreLabel}}"' + ' name="show-more" id="show-more" />' + '<div class="loading hidden" style="height: 50px"></div>'; @@ -31,10 +32,10 @@ '{{/if}}' + ' </div>' + ' <form class="newCommentForm">' + - ' <textarea class="message" placeholder="{{newMessagePlaceholder}}">{{{message}}}</textarea>' + - ' <input class="submit" type="submit" value="{{submitText}}" />' + + ' <input type="text" class="message" placeholder="{{newMessagePlaceholder}}" value="{{{message}}}" />' + + ' <input class="submit icon-confirm" type="submit" value="" />' + '{{#if isEditMode}}' + - ' <input class="cancel" type="button" value="{{cancelText}}" />' + + ' <input class="cancel pull-right" type="button" value="{{cancelText}}" />' + '{{/if}}' + ' <div class="submitLoading icon-loading-small hidden"></div>'+ ' </form>' + @@ -113,7 +114,7 @@ avatarEnabled: this._avatarsEnabled, actorId: currentUser.uid, actorDisplayName: currentUser.displayName, - newMessagePlaceholder: t('comments', 'Type in a new comment...'), + newMessagePlaceholder: t('comments', 'New comment …'), deleteTooltip: t('comments', 'Delete comment'), submitText: t('comments', 'Post'), cancelText: t('comments', 'Cancel') @@ -162,17 +163,17 @@ render: function() { this.$el.html(this.template({ - emptyResultLabel: t('comments', 'No other comments available'), - moreLabel: t('comments', 'More comments...') + emptyResultLabel: t('comments', 'No comments yet, start the conversation!'), + moreLabel: t('comments', 'More comments …') })); this.$el.find('.comments').before(this.editCommentTemplate({})); this.$el.find('.has-tooltip').tooltip(); this.$container = this.$el.find('ul.comments'); if (this._avatarsEnabled) { - this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 28); + this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 32); } this.delegateEvents(); - this.$el.find('textarea').on('keydown input change', this._onTypeComment); + this.$el.find('.message').on('keydown input change', this._onTypeComment); }, _formatItem: function(commentModel) { @@ -200,7 +201,7 @@ _onEndRequest: function(type) { var fileInfoModel = this.model; this._toggleLoading(false); - this.$el.find('.empty').toggleClass('hidden', !!this.collection.length); + this.$el.find('.emptycontent').toggleClass('hidden', !!this.collection.length); this.$el.find('.showMore').toggleClass('hidden', !this.collection.hasMoreResults()); if (type !== 'REPORT') { @@ -238,7 +239,7 @@ if(this._avatarsEnabled) { $el.find('.avatar').each(function() { var $this = $(this); - $this.avatar($this.attr('data-username'), 28); + $this.avatar($this.attr('data-username'), 32); }); } }, @@ -360,7 +361,7 @@ var currentUser = OC.getCurrentUser(); var $submit = $form.find('.submit'); var $loading = $form.find('.submitLoading'); - var $textArea = $form.find('textarea'); + var $textArea = $form.find('.message'); var message = $textArea.val().trim(); e.preventDefault(); @@ -437,4 +438,3 @@ OCA.Comments.CommentsTabView = CommentsTabView; })(OC, OCA); - diff --git a/apps/comments/lib/Activity/Extension.php b/apps/comments/lib/Activity/Extension.php index 6e5ac894c0f..0a7503c1915 100644 --- a/apps/comments/lib/Activity/Extension.php +++ b/apps/comments/lib/Activity/Extension.php @@ -82,8 +82,8 @@ class Extension implements IExtension { return array( self::APP_NAME => [ - 'desc' => (string) $l->t('<strong>Comments</strong> for files <em>(always listed in stream)</em>'), - 'methods' => [self::METHOD_MAIL], // self::METHOD_STREAM is forced true by the default value + 'desc' => (string) $l->t('<strong>Comments</strong> for files'), + 'methods' => [self::METHOD_MAIL, self::METHOD_STREAM], ], ); } @@ -278,11 +278,7 @@ class Extension implements IExtension { */ public function filterNotificationTypes($types, $filter) { if ($filter === self::APP_NAME) { - return [self::APP_NAME]; - } - if (in_array($filter, ['all', 'by', 'self', 'filter'])) { - $types[] = self::APP_NAME; - return $types; + return array_intersect($types, [self::APP_NAME]); } return false; } diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js index 70930da7520..33c959e430f 100644 --- a/apps/comments/tests/js/commentstabviewSpec.js +++ b/apps/comments/tests/js/commentstabviewSpec.js @@ -328,12 +328,12 @@ describe('OCA.Comments.CommentsTabView tests', function() { var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]'); expect($formRow.length).toEqual(1); - $formRow.find('textarea').val('modified\nmessage'); + $formRow.find('input').val('modified message'); $formRow.find('form').submit(); expect(saveStub.calledOnce).toEqual(true); expect(saveStub.lastCall.args[0]).toEqual({ - message: 'modified\nmessage' + message: 'modified message' }); var model = view.collection.get(1); diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 004a0b9ff50..b1759abfb1d 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -87,26 +87,26 @@ /* icons for sidebar */ .nav-icon-files { - background-image: url('../img/folder.svg'); + background-image: url('../img/folder.svg?v=1'); } .nav-icon-recent { - background-image: url('../img/recent.svg'); + background-image: url('../img/recent.svg?v=1'); } .nav-icon-favorites { - background-image: url('../img/star.svg'); + background-image: url('../img/star.svg?v=1'); } .nav-icon-sharingin, .nav-icon-sharingout { - background-image: url('../img/share.svg'); + background-image: url('../img/share.svg?v=1'); } .nav-icon-sharinglinks { - background-image: url('../img/public.svg'); + background-image: url('../img/public.svg?v=1'); } .nav-icon-extstoragemounts { - background-image: url('../img/external.svg'); + background-image: url('../img/external.svg?v=1'); } .nav-icon-trashbin { - background-image: url('../img/delete.svg'); + background-image: url('../img/delete.svg?v=1'); } #app-navigation .nav-files a.nav-icon-files { diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 06c163419f0..fcf10adb375 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -68,7 +68,18 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide * Register settings templates */ public function registerSettings() { - \OCP\App::registerPersonal('files_external', 'personal'); + $container = $this->getContainer(); + $userSession = $container->getServer()->getUserSession(); + if (!$userSession->isLoggedIn()) { + return; + } + $backendService = $container->query('OCA\\Files_External\\Service\\BackendService'); + + /** @var \OCA\Files_External\Service\UserGlobalStoragesService $userGlobalStoragesService */ + $userGlobalStoragesService = $container->query('OCA\Files_External\Service\UserGlobalStoragesService'); + if (count($userGlobalStoragesService->getStorages()) > 0 || $backendService->isUserMountingAllowed()) { + \OCP\App::registerPersonal('files_external', 'personal'); + } } /** diff --git a/apps/files_external/lib/Lib/Backend/OwnCloud.php b/apps/files_external/lib/Lib/Backend/OwnCloud.php index 59d1b2cec52..1304b09c87c 100644 --- a/apps/files_external/lib/Lib/Backend/OwnCloud.php +++ b/apps/files_external/lib/Lib/Backend/OwnCloud.php @@ -37,7 +37,7 @@ class OwnCloud extends Backend { ->setIdentifier('owncloud') ->addIdentifierAlias('\OC\Files\Storage\OwnCloud') // legacy compat ->setStorageClass('\OCA\Files_External\Lib\Storage\OwnCloud') - ->setText($l->t('ownCloud')) + ->setText($l->t('Nextcloud')) ->addParameters([ (new DefinitionParameter('host', $l->t('URL'))), (new DefinitionParameter('root', $l->t('Remote subfolder'))) diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index 2c0ed03f880..3e91da37a7d 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -246,17 +246,32 @@ class Share20OCS extends OCSController { /** * @NoAdminRequired * + * @param string $path + * @param int $permissions + * @param int $shareType + * @param string $shareWith + * @param string $publicUpload + * @param string $password + * @param string $expireDate + * * @return DataResponse * @throws OCSNotFoundException * @throws OCSForbiddenException * @throws OCSBadRequestException * @throws OCSException */ - public function createShare() { + public function createShare( + $path = null, + $permissions = \OCP\Constants::PERMISSION_ALL, + $shareType = -1, + $shareWith = null, + $publicUpload = 'false', + $password = '', + $expireDate = '' + ) { $share = $this->shareManager->newShare(); // Verify path - $path = $this->request->getParam('path', null); if ($path === null) { throw new OCSNotFoundException($this->l->t('Please specify a file or folder path')); } @@ -276,14 +291,6 @@ class Share20OCS extends OCSController { throw new OCSNotFoundException($this->l->t('Could not create share')); } - // Parse permissions (if available) - $permissions = $this->request->getParam('permissions', null); - if ($permissions === null) { - $permissions = \OCP\Constants::PERMISSION_ALL; - } else { - $permissions = (int)$permissions; - } - if ($permissions < 0 || $permissions > \OCP\Constants::PERMISSION_ALL) { throw new OCSNotFoundException($this->l->t('invalid permissions')); } @@ -306,9 +313,6 @@ class Share20OCS extends OCSController { $permissions &= ~($permissions & ~$path->getPermissions()); } - $shareWith = $this->request->getParam('shareWith', null); - $shareType = (int)$this->request->getParam('shareType', '-1'); - if ($shareType === \OCP\Share::SHARE_TYPE_USER) { // Valid user is required to share if ($shareWith === null || !$this->userManager->userExists($shareWith)) { @@ -342,7 +346,6 @@ class Share20OCS extends OCSController { return new DataResponse($this->formatShare($existingShares[0])); } - $publicUpload = $this->request->getParam('publicUpload', null); if ($publicUpload === 'true') { // Check if public upload is allowed if (!$this->shareManager->shareApiLinkAllowPublicUpload()) { @@ -365,15 +368,11 @@ class Share20OCS extends OCSController { } // Set password - $password = $this->request->getParam('password', ''); - if ($password !== '') { $share->setPassword($password); } //Expire date - $expireDate = $this->request->getParam('expireDate', ''); - if ($expireDate !== '') { try { $expireDate = $this->parseDate($expireDate); @@ -474,6 +473,11 @@ class Share20OCS extends OCSController { * * @NoAdminRequired * + * @param string $shared_with_me + * @param string $reshares + * @param string $subfiles + * @param string $path + * * - Get shares by the current user * - Get shares by the current user and reshares (?reshares=true) * - Get shares with the current user (?shared_with_me=true) @@ -483,11 +487,12 @@ class Share20OCS extends OCSController { * @return DataResponse * @throws OCSNotFoundException */ - public function getShares() { - $sharedWithMe = $this->request->getParam('shared_with_me', null); - $reshares = $this->request->getParam('reshares', null); - $subfiles = $this->request->getParam('subfiles'); - $path = $this->request->getParam('path', null); + public function getShares( + $shared_with_me = 'false', + $reshares = 'false', + $subfiles = 'false', + $path = null + ) { if ($path !== null) { $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); @@ -501,7 +506,7 @@ class Share20OCS extends OCSController { } } - if ($sharedWithMe === 'true') { + if ($shared_with_me === 'true') { $result = $this->getSharedWithMe($path); return $result; } @@ -544,12 +549,22 @@ class Share20OCS extends OCSController { * @NoAdminRequired * * @param int $id + * @param int $permissions + * @param string $password + * @param string $publicUpload + * @param string $expireDate * @return DataResponse * @throws OCSNotFoundException * @throws OCSBadRequestException * @throws OCSForbiddenException */ - public function updateShare($id) { + public function updateShare( + $id, + $permissions = null, + $password = null, + $publicUpload = null, + $expireDate = null + ) { try { $share = $this->getShareById($id); } catch (ShareNotFound $e) { @@ -562,11 +577,6 @@ class Share20OCS extends OCSController { throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist')); } - $permissions = $this->request->getParam('permissions', null); - $password = $this->request->getParam('password', null); - $publicUpload = $this->request->getParam('publicUpload', null); - $expireDate = $this->request->getParam('expireDate', null); - /* * expirationdate, password and publicUpload only make sense for link shares */ diff --git a/apps/files_sharing/tests/API/Share20OCSTest.php b/apps/files_sharing/tests/API/Share20OCSTest.php index a89bdb065c4..1f0b4855a0d 100644 --- a/apps/files_sharing/tests/API/Share20OCSTest.php +++ b/apps/files_sharing/tests/API/Share20OCSTest.php @@ -46,31 +46,31 @@ class Share20OCSTest extends \Test\TestCase { /** @var string */ private $appName = 'files_sharing'; - /** @var \OC\Share20\Manager | \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OC\Share20\Manager|\PHPUnit_Framework_MockObject_MockObject */ private $shareManager; - /** @var IGroupManager | \PHPUnit_Framework_MockObject_MockObject */ + /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */ private $groupManager; - /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManager; - /** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */ + /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $request; - /** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */ + /** @var IRootFolder|\PHPUnit_Framework_MockObject_MockObject */ private $rootFolder; - /** @var IURLGenerator */ + /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */ private $urlGenerator; - /** @var IUser */ + /** @var IUser|\PHPUnit_Framework_MockObject_MockObject */ private $currentUser; /** @var Share20OCS */ private $ocs; - /** @var IL10N */ + /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l; protected function setUp() { @@ -89,8 +89,6 @@ class Share20OCSTest extends \Test\TestCase { $this->currentUser = $this->getMockBuilder('OCP\IUser')->getMock(); $this->currentUser->method('getUID')->willReturn('currentUser'); - $this->userManager->expects($this->any())->method('userExists')->willReturn(true); - $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock(); $this->l->method('t') ->will($this->returnCallback(function($text, $parameters = []) { @@ -565,12 +563,6 @@ class Share20OCSTest extends \Test\TestCase { * @expectedExceptionMessage Wrong path, file/folder doesn't exist */ public function testCreateShareInvalidPath() { - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'invalid-path'], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -582,7 +574,7 @@ class Share20OCSTest extends \Test\TestCase { ->with('invalid-path') ->will($this->throwException(new \OCP\Files\NotFoundException())); - $this->ocs->createShare(); + $this->ocs->createShare('invalid-path'); } /** @@ -593,13 +585,6 @@ class Share20OCSTest extends \Test\TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, 32], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -616,7 +601,7 @@ class Share20OCSTest extends \Test\TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', 32); } /** @@ -627,14 +612,6 @@ class Share20OCSTest extends \Test\TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -656,7 +633,7 @@ class Share20OCSTest extends \Test\TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER); } /** @@ -667,15 +644,6 @@ class Share20OCSTest extends \Test\TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER], - ['shareWith', $this->any(), 'invalidUser'], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -692,12 +660,14 @@ class Share20OCSTest extends \Test\TestCase { ->method('get') ->with('valid-path') ->willReturn($path); - $path->expects($this->once()) ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); + $this->userManager->method('userExists') + ->with('invalidUser') + ->willReturn(false); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'invalidUser'); } public function testCreateShareUser() { @@ -719,15 +689,6 @@ class Share20OCSTest extends \Test\TestCase { ])->setMethods(['formatShare']) ->getMock(); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER], - ['shareWith', null, 'validUser'], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -766,7 +727,7 @@ class Share20OCSTest extends \Test\TestCase { ->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->createShare(); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -774,21 +735,13 @@ class Share20OCSTest extends \Test\TestCase { /** * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Please specify a valid user + * @expectedExceptionMessage Please specify a valid group */ public function testCreateShareGroupNoValidShareWith() { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('createShare')->will($this->returnArgument(0)); - - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_GROUP], - ['shareWith', $this->any(), 'invalidGroup'], - ])); + $this->shareManager->method('allowGroupSharing')->willReturn(true); $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) @@ -811,7 +764,7 @@ class Share20OCSTest extends \Test\TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); } public function testCreateShareGroup() { @@ -879,7 +832,7 @@ class Share20OCSTest extends \Test\TestCase { ->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->createShare(); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'validGroup'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -893,15 +846,6 @@ class Share20OCSTest extends \Test\TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP], - ['shareWith', null, 'validGroup'], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -925,7 +869,7 @@ class Share20OCSTest extends \Test\TestCase { ->method('allowGroupSharing') ->willReturn(false); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); } /** @@ -951,7 +895,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); } /** @@ -959,14 +903,6 @@ class Share20OCSTest extends \Test\TestCase { * @expectedExceptionMessage Public upload disabled by the administrator */ public function testCreateShareLinkNoPublicUpload() { - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], - ['publicUpload', null, 'true'], - ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') @@ -979,7 +915,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); } /** @@ -987,14 +923,6 @@ class Share20OCSTest extends \Test\TestCase { * @expectedExceptionMessage Public upload is only possible for publicly shared folders */ public function testCreateShareLinkPublicUploadFile() { - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], - ['publicUpload', null, 'true'], - ])); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') @@ -1008,22 +936,12 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $this->ocs->createShare(); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); } public function testCreateShareLinkPublicUploadFolder() { $ocs = $this->mockFormatShare(); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], - ['publicUpload', null, 'true'], - ['expireDate', '', ''], - ['password', '', ''], - ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') @@ -1049,7 +967,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->createShare(); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true', '', ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1058,16 +976,6 @@ class Share20OCSTest extends \Test\TestCase { public function testCreateShareLinkPassword() { $ocs = $this->mockFormatShare(); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], - ['publicUpload', null, 'false'], - ['expireDate', '', ''], - ['password', '', 'password'], - ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') @@ -1093,7 +1001,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->createShare(); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1140,7 +1048,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->createShare(); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', '2000-01-01'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1153,16 +1061,6 @@ class Share20OCSTest extends \Test\TestCase { public function testCreateShareInvalidExpireDate() { $ocs = $this->mockFormatShare(); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], - ['publicUpload', null, 'false'], - ['expireDate', '', 'a1b2d3'], - ['password', '', ''], - ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') @@ -1176,7 +1074,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->createShare(); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', 'a1b2d3'); } /** @@ -1201,15 +1099,6 @@ class Share20OCSTest extends \Test\TestCase { ])->setMethods(['formatShare']) ->getMock(); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['path', null, 'valid-path'], - ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER], - ['shareWith', null, 'validUser'], - ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -1238,7 +1127,7 @@ class Share20OCSTest extends \Test\TestCase { })) ->will($this->returnArgument(0)); - $ocs->createShare(); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); } /** @@ -1318,14 +1207,6 @@ class Share20OCSTest extends \Test\TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['publicUpload', null, 'false'], - ['expireDate', null, ''], - ['password', null, ''], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->expects($this->once())->method('updateShare')->with( @@ -1337,7 +1218,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, null, '', 'false', ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1354,14 +1235,6 @@ class Share20OCSTest extends \Test\TestCase { ->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['publicUpload', null, 'true'], - ['expireDate', null, '2000-01-01'], - ['password', null, 'password'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -1377,7 +1250,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, null, 'password', 'true', '2000-01-01'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1386,7 +1259,7 @@ class Share20OCSTest extends \Test\TestCase { /** * @dataProvider publicUploadParamsProvider */ - public function testUpdateLinkShareEnablePublicUpload($params) { + public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUpload, $expireDate, $password) { $ocs = $this->mockFormatShare(); $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); @@ -1398,10 +1271,6 @@ class Share20OCSTest extends \Test\TestCase { ->setPassword('password') ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap($params)); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); $this->shareManager->method('getSharedWith')->willReturn([]); @@ -1415,7 +1284,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, $permissions, $password, $publicUpload, $expireDate); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1436,37 +1305,25 @@ class Share20OCSTest extends \Test\TestCase { ->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['publicUpload', null, 'true'], - ['expireDate', null, '2000-01-a'], - ['password', null, 'password'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->updateShare(42); + $ocs->updateShare(42, null, 'password', 'true', '2000-01-a'); } public function publicUploadParamsProvider() { return [ - [[ - ['publicUpload', null, 'true'], - ['expireDate', '', null], - ['password', '', 'password'], - ]], [[ - // legacy had no delete - ['permissions', null, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE], - ['expireDate', '', null], - ['password', '', 'password'], - ]], [[ - // correct - ['permissions', null, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE], - ['expireDate', '', null], - ['password', '', 'password'], - ]], + [null, 'true', null, 'password'], + // legacy had no delete + [ + \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE, + null, null, 'password' + ], + // correct + [ + \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE, + null, null, 'password' + ], ]; } @@ -1475,7 +1332,7 @@ class Share20OCSTest extends \Test\TestCase { * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException * @expectedExceptionMessage Public upload disabled by the administrator */ - public function testUpdateLinkSharePublicUploadNotAllowed($params) { + public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password) { $ocs = $this->mockFormatShare(); $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); @@ -1486,14 +1343,10 @@ class Share20OCSTest extends \Test\TestCase { ->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap($params)); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(false); - $ocs->updateShare(42); + $ocs->updateShare(42, $permissions, $password, $publicUpload, $expireDate); } /** @@ -1511,18 +1364,10 @@ class Share20OCSTest extends \Test\TestCase { ->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setNode($file); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['publicUpload', null, 'true'], - ['expireDate', '', ''], - ['password', '', 'password'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->updateShare(42); + $ocs->updateShare(42, null, 'password', 'true', ''); } public function testUpdateLinkSharePasswordDoesNotChangeOther() { @@ -1545,12 +1390,6 @@ class Share20OCSTest extends \Test\TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['password', null, 'newpassword'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->expects($this->once())->method('updateShare')->with( @@ -1562,7 +1401,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, null, 'newpassword', null, null); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1581,12 +1420,6 @@ class Share20OCSTest extends \Test\TestCase { ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setNode($node); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['expireDate', null, '2010-12-23'], - ])); - $node->expects($this->once()) ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); @@ -1605,7 +1438,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, null, null, null, '2010-12-23'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1627,12 +1460,6 @@ class Share20OCSTest extends \Test\TestCase { ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['publicUpload', null, 'true'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -1645,7 +1472,7 @@ class Share20OCSTest extends \Test\TestCase { )->will($this->returnArgument(0)); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, null, null, 'true', null); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1667,12 +1494,6 @@ class Share20OCSTest extends \Test\TestCase { ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['permissions', null, '7'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -1687,7 +1508,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('getSharedWith')->willReturn([]); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, 7, null, null, null); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1713,16 +1534,10 @@ class Share20OCSTest extends \Test\TestCase { ->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setNode($folder); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['permissions', null, '31'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->updateShare(42); + $ocs->updateShare(42, 31); } public function testUpdateOtherPermissions() { @@ -1736,12 +1551,6 @@ class Share20OCSTest extends \Test\TestCase { ->setShareType(\OCP\Share::SHARE_TYPE_USER) ->setNode($file); - $this->request - ->method('getParam') - ->will($this->returnValueMap([ - ['permissions', null, '31'], - ])); - $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); @@ -1754,7 +1563,7 @@ class Share20OCSTest extends \Test\TestCase { $this->shareManager->method('getSharedWith')->willReturn([]); $expected = new DataResponse(null); - $result = $ocs->updateShare(42); + $result = $ocs->updateShare(42, 31, null, null, null); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index f39ddeb5485..a62c29c5cad 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -28,6 +28,7 @@ */ namespace OCA\Files_Sharing\Tests; + use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; @@ -49,6 +50,9 @@ class ApiTest extends TestCase { /** @var \OCP\Files\Folder */ private $userFolder; + /** @var string */ + private $subsubfolder; + protected function setUp() { parent::setUp(); @@ -84,27 +88,10 @@ class ApiTest extends TestCase { } /** - * @param array $data - * @return \OCP\IRequest - */ - private function createRequest(array $data) { - $request = $this->getMockBuilder('\OCP\IRequest')->getMock(); - $request->method('getParam') - ->will($this->returnCallback(function($param, $default = null) use ($data) { - if (isset($data[$param])) { - return $data[$param]; - } - return $default; - })); - return $request; - } - - /** - * @param \OCP\IRequest $request * @param string $userId The userId of the caller * @return \OCA\Files_Sharing\API\Share20OCS */ - private function createOCS($request, $userId) { + private function createOCS($userId) { $currentUser = \OC::$server->getUserManager()->get($userId); $l = $this->getMockBuilder('\OCP\IL10N')->getMock(); @@ -115,7 +102,7 @@ class ApiTest extends TestCase { return new \OCA\Files_Sharing\API\Share20OCS( self::APP_NAME, - $request, + $this->getMockBuilder('OCP\IRequest')->getMock(), $this->shareManager, \OC::$server->getGroupManager(), \OC::$server->getUserManager(), @@ -130,14 +117,8 @@ class ApiTest extends TestCase { * @medium */ function testCreateShareUserFile() { - // simulate a post request - $data['path'] = $this->filename; - $data['shareWith'] = self::TEST_FILES_SHARING_API_USER2; - $data['shareType'] = \OCP\Share::SHARE_TYPE_USER; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -146,22 +127,15 @@ class ApiTest extends TestCase { $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); } function testCreateShareUserFolder() { - // simulate a post request - $data['path'] = $this->folder; - $data['shareWith'] = self::TEST_FILES_SHARING_API_USER2; - $data['shareType'] = \OCP\Share::SHARE_TYPE_USER; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -170,8 +144,7 @@ class ApiTest extends TestCase { $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); @@ -179,14 +152,8 @@ class ApiTest extends TestCase { function testCreateShareGroupFile() { - // simulate a post request - $data['path'] = $this->filename; - $data['shareWith'] = self::TEST_FILES_SHARING_API_GROUP1; - $data['shareType'] = \OCP\Share::SHARE_TYPE_GROUP; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -195,21 +162,14 @@ class ApiTest extends TestCase { $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); } function testCreateShareGroupFolder() { - // simulate a post request - $data['path'] = $this->folder; - $data['shareWith'] = self::TEST_FILES_SHARING_API_GROUP1; - $data['shareType'] = \OCP\Share::SHARE_TYPE_GROUP; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -218,21 +178,15 @@ class ApiTest extends TestCase { $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); } public function testCreateShareLink() { - // simulate a post request - $data['path'] = $this->folder; - $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); $ocs->cleanup(); $data = $result->getData(); @@ -246,21 +200,14 @@ class ApiTest extends TestCase { $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); } public function testCreateShareLinkPublicUpload() { - // simulate a post request - $data['path'] = $this->folder; - $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK; - $data['publicUpload'] = 'true'; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); $ocs->cleanup(); $data = $result->getData(); @@ -280,8 +227,7 @@ class ApiTest extends TestCase { $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); } @@ -291,30 +237,18 @@ class ApiTest extends TestCase { $appConfig = \OC::$server->getAppConfig(); $appConfig->setValue('core', 'shareapi_enforce_links_password', 'yes'); - // don't allow to share link without a password - $data['path'] = $this->folder; - $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare(); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); $this->fail(); } catch (OCSForbiddenException $e) { } $ocs->cleanup(); - // don't allow to share link without a empty password - $data = []; - $data['path'] = $this->folder; - $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK; - $data['password'] = ''; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare(); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', ''); $this->fail(); } catch (OCSForbiddenException $e) { @@ -322,33 +256,19 @@ class ApiTest extends TestCase { $ocs->cleanup(); // share with password should succeed - $data = []; - $data['path'] = $this->folder; - $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK; - $data['password'] = 'foo'; - - $request = $this->createRequest($data); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'bar'); $ocs->cleanup(); $data = $result->getData(); // setting new password should succeed - $data2 = [ - 'password' => 'bar', - ]; - $request = $this->createRequest($data2); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->updateShare($data['id']); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->updateShare($data['id'], null, 'bar'); $ocs->cleanup(); // removing password should fail - $data2 = [ - 'password' => '', - ]; - $request = $this->createRequest($data2); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { $ocs->updateShare($data['id']); $this->fail(); @@ -358,8 +278,7 @@ class ApiTest extends TestCase { $ocs->cleanup(); // cleanup - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($data['id']); $ocs->cleanup(); @@ -373,58 +292,40 @@ class ApiTest extends TestCase { // sharing file to a user should work if shareapi_exclude_groups is set // to no \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'no'); - $post['path'] = $this->filename; - $post['shareWith'] = self::TEST_FILES_SHARING_API_USER2; - $post['shareType'] = \OCP\Share::SHARE_TYPE_USER; - $request = $this->createRequest($post); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); $this->shareManager->getShareById('ocinternal:'.$data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->deleteShare($data['id']); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->deleteShare($data['id']); $ocs->cleanup(); // exclude groups, but not the group the user belongs to. Sharing should still work \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'yes'); \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2'); - $post = []; - $post['path'] = $this->filename; - $post['shareWith'] = self::TEST_FILES_SHARING_API_USER2; - $post['shareType'] = \OCP\Share::SHARE_TYPE_USER; - - $request = $this->createRequest($post); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); $this->shareManager->getShareById('ocinternal:' . $data['id']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->deleteShare($data['id']); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->deleteShare($data['id']); $ocs->cleanup(); // now we exclude the group the user belongs to ('group'), sharing should fail now \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', 'admin,group'); - $post = []; - $post['path'] = $this->filename; - $post['shareWith'] = self::TEST_FILES_SHARING_API_USER2; - $post['shareType'] = \OCP\Share::SHARE_TYPE_USER; - - $request = $this->createRequest($post); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); // cleanup @@ -448,8 +349,7 @@ class ApiTest extends TestCase { $share = $this->shareManager->createShare($share); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -477,12 +377,11 @@ class ApiTest extends TestCase { ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); - $request = $this->createRequest(['shared_with_me' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); - $result = $ocs->getShares(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->getShares('true'); $ocs->cleanup(); - $this->assertTrue(count($result->getData()) === 2); + $this->assertCount(2, $result->getData()); $this->shareManager->deleteShare($share1); $this->shareManager->deleteShare($share2); @@ -492,13 +391,8 @@ class ApiTest extends TestCase { * @medium */ function testPublicLinkUrl() { - // simulate a post request - $post['path'] = $this->folder; - $post['shareType'] = \OCP\Share::SHARE_TYPE_LINK; - - $request = $this->createRequest($post); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); $ocs->cleanup(); $data = $result->getData(); @@ -512,8 +406,7 @@ class ApiTest extends TestCase { $this->assertEquals($url, $data['url']); // check for link in getall shares - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -521,8 +414,7 @@ class ApiTest extends TestCase { $this->assertEquals($url, current($data)['url']); // check for path - $request = $this->createRequest(['path' => $this->folder]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -530,16 +422,14 @@ class ApiTest extends TestCase { $this->assertEquals($url, current($data)['url']); // check in share id - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShare($id); $ocs->cleanup(); $data = $result->getData(); $this->assertEquals($url, current($data)['url']); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs->deleteShare($id); $ocs->cleanup(); } @@ -566,8 +456,7 @@ class ApiTest extends TestCase { ->setPermissions(1); $share2 = $this->shareManager->createShare($share); - $request = $this->createRequest(['path' => $this->filename]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -601,8 +490,7 @@ class ApiTest extends TestCase { ->setPermissions(19); $share2 = $this->shareManager->createShare($share2); - $request = $this->createRequest(['path' => $this->filename]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -610,9 +498,8 @@ class ApiTest extends TestCase { $this->assertTrue(count($result->getData()) === 1); // now also ask for the reshares - $request = $this->createRequest(['path' => $this->filename, 'reshares' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->getShares(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->getShares('false', 'true', 'false', $this->filename); $ocs->cleanup(); // now we should get two shares, the initial share and the reshare @@ -637,8 +524,7 @@ class ApiTest extends TestCase { $share1 = $this->shareManager->createShare($share1); // call getShare() with share ID - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShare($share1->getId()); $ocs->cleanup(); @@ -670,9 +556,8 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->createShare($share2); - $request = $this->createRequest(['path' => $this->folder, 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->getShares(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->getShares('false', 'false', 'true', $this->folder); $ocs->cleanup(); // test should return one share within $this->folder @@ -692,10 +577,9 @@ class ApiTest extends TestCase { ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); - $request = $this->createRequest(['path' => $this->filename, 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->getShares(); + $ocs->getShares('false', 'false', 'true', $this->filename); $this->fail(); } catch (OCSBadRequestException $e) { $this->assertEquals('Not a directory', $e->getMessage()); @@ -743,9 +627,8 @@ class ApiTest extends TestCase { ); foreach ($testValues as $value) { - $request = $this->createRequest(['path' => $value['query'], 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); - $result = $ocs->getShares(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->getShares('false', 'false', 'true', $value['query']); $ocs->cleanup(); // test should return one share within $this->folder @@ -782,8 +665,7 @@ class ApiTest extends TestCase { ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); - $request = $this->createRequest(['path' => '/', 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); $result = $ocs->getShares(); $ocs->cleanup(); @@ -833,7 +715,7 @@ class ApiTest extends TestCase { * Test as recipient */ $request = $this->createRequest(['path' => '/', 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER3); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER3); $result = $ocs->getShares(); $ocs->cleanup(); @@ -847,8 +729,7 @@ class ApiTest extends TestCase { /* * Test for first owner/initiator */ - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -862,8 +743,7 @@ class ApiTest extends TestCase { /* * Test for second initiator */ - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); $result = $ocs->getShares(); $ocs->cleanup(); @@ -909,8 +789,7 @@ class ApiTest extends TestCase { ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); - $request = $this->createRequest(['path' => $this->subfolder]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); $result1 = $ocs->getShares(); $ocs->cleanup(); @@ -919,8 +798,7 @@ class ApiTest extends TestCase { $this->assertCount(1, $data1); $s1 = reset($data1); - $request = $this->createRequest(['path' => $this->folder.$this->subfolder]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); $result2 = $ocs->getShares(); $ocs->cleanup(); @@ -970,8 +848,7 @@ class ApiTest extends TestCase { ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); - $request = $this->createRequest(['path' => '/', 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER3); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER3); $result = $ocs->getShares(); $ocs->cleanup(); @@ -992,8 +869,7 @@ class ApiTest extends TestCase { * @medium */ function testGetShareFromUnknownId() { - $request = $this->createRequest(['path' => '/', 'subfiles' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER3); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER3); try { $ocs->getShare(0); $this->fail(); @@ -1026,12 +902,8 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->createShare($share2); // update permissions - $params = array(); - $params['permissions'] = 1; - - $request = $this->createRequest(['permissions' => 1]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->updateShare($share1->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->updateShare($share1->getId(), 1); $ocs->cleanup(); $share1 = $this->shareManager->getShareById('ocinternal:' . $share1->getId()); @@ -1040,17 +912,15 @@ class ApiTest extends TestCase { // update password for link share $this->assertNull($share2->getPassword()); - $request = $this->createRequest(['password' => 'foo']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $ocs->updateShare($share2->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->updateShare($share2->getId(), null, 'foo'); $ocs->cleanup(); $share2 = $this->shareManager->getShareById('ocinternal:' . $share2->getId()); $this->assertNotNull($share2->getPassword()); - $request = $this->createRequest(['password' => '']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $ocs->updateShare($share2->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->updateShare($share2->getId(), null, ''); $ocs->cleanup(); $share2 = $this->shareManager->getShareById('ocinternal:' . $share2->getId()); @@ -1074,8 +944,7 @@ class ApiTest extends TestCase { ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); - $request = $this->createRequest(['permissions' => \OCP\Constants::PERMISSION_ALL]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { $ocs->updateShare($share1->getId()); $this->fail(); @@ -1104,9 +973,8 @@ class ApiTest extends TestCase { $share1 = $this->shareManager->createShare($share1); // update public upload - $request = $this->createRequest(['publicUpload' => 'true']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->updateShare($share1->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->updateShare($share1->getId(), null, null, 'true'); $ocs->cleanup(); $share1 = $this->shareManager->getShareById($share1->getFullId()); @@ -1148,9 +1016,8 @@ class ApiTest extends TestCase { $dateOutOfRange->add(new \DateInterval('P8D')); // update expire date to a valid value - $request = $this->createRequest(['expireDate' => $dateWithinRange->format('Y-m-d')]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->updateShare($share1->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->updateShare($share1->getId(), null, null, null, $dateWithinRange->format('Y-m-d')); $ocs->cleanup(); $share1 = $this->shareManager->getShareById($share1->getFullId()); @@ -1159,8 +1026,7 @@ class ApiTest extends TestCase { $this->assertEquals($dateWithinRange, $share1->getExpirationDate()); // update expire date to a value out of range - $request = $this->createRequest(['expireDate' => $dateOutOfRange->format('Y-m-d')]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { $ocs->updateShare($share1->getId()); $this->fail(); @@ -1175,8 +1041,7 @@ class ApiTest extends TestCase { $this->assertEquals($dateWithinRange, $share1->getExpirationDate()); // Try to remove expire date - $request = $this->createRequest(['expireDate' => '']); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { $ocs->updateShare($share1->getId()); $this->fail(); @@ -1217,14 +1082,12 @@ class ApiTest extends TestCase { ->setPermissions(1); $share2 = $this->shareManager->createShare($share1); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->deleteShare($share1->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->deleteShare($share1->getId()); $ocs->cleanup(); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->deleteShare($share2->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->deleteShare($share2->getId()); $ocs->cleanup(); $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER)); @@ -1254,9 +1117,8 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->createShare($share2); // test if we can unshare the link again - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); - $result = $ocs->deleteShare($share2->getId()); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); + $ocs->deleteShare($share2->getId()); $ocs->cleanup(); $this->shareManager->deleteShare($share1); @@ -1269,8 +1131,6 @@ class ApiTest extends TestCase { // user 1 shares a folder with user2 self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $fileInfo = $this->view->getFileInfo($this->folder); - $share = $this->share( \OCP\Share::SHARE_TYPE_USER, $this->folder, @@ -1345,8 +1205,6 @@ class ApiTest extends TestCase { // logging in will auto-mount the temp storage for user1 as well self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $fileInfo = $this->view->getFileInfo($this->folder); - // user 1 shares the mount point folder with user2 $share = $this->share( \OCP\Share::SHARE_TYPE_USER, @@ -1368,7 +1226,8 @@ class ApiTest extends TestCase { $this->shareManager->deleteShare($share); - \OC_Hook::clear('OC_Filesystem', 'post_initMountPoints', '\OCA\Files_Sharing\Tests\ApiTest', 'initTestMountPointsHook'); + \OC_Hook::clear('OC_Filesystem', 'post_initMountPoints'); + \OC_Hook::clear('\OCA\Files_Sharing\Tests\ApiTest', 'initTestMountPointsHook'); } /** * @expectedException \Exception @@ -1473,15 +1332,10 @@ class ApiTest extends TestCase { * @dataProvider datesProvider */ public function testPublicLinkExpireDate($date, $valid) { - $request = $this->createRequest([ - 'path' => $this->folder, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, - 'expireDate' => $date, - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $result = $ocs->createShare(); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date); $this->assertTrue($valid); } catch (OCSNotFoundException $e) { $this->assertFalse($valid); @@ -1516,13 +1370,8 @@ class ApiTest extends TestCase { $date = new \DateTime(); $date->add(new \DateInterval('P5D')); - $request = $this->createRequest([ - 'path' => $this->folder, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, - 'expireDate' => $date->format('Y-m-d'), - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date->format('Y-m-d')); $ocs->cleanup(); $data = $result->getData(); @@ -1553,15 +1402,10 @@ class ApiTest extends TestCase { $date = new \DateTime(); $date->add(new \DateInterval('P8D')); - $request = $this->createRequest([ - 'path' => $this->folder, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, - 'expireDate' => $date->format('Y-m-d'), - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare(); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date->format('Y-m-d')); $this->fail(); } catch (OCSException $e) { $this->assertEquals(404, $e->getCode()); @@ -1579,15 +1423,10 @@ class ApiTest extends TestCase { $date = new \DateTime(); $date->sub(new \DateInterval('P8D')); - $request = $this->createRequest([ - 'path' => $this->folder, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, - 'expireDate' => $date->format('Y-m-d'), - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $result = $ocs->createShare(); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date->format('Y-m-d')); $this->fail(); } catch(OCSException $e) { $this->assertEquals(404, $e->getCode()); @@ -1605,35 +1444,22 @@ class ApiTest extends TestCase { */ public function testInvisibleSharesUser() { // simulate a post request - $request = $this->createRequest([ - 'path' => $this->folder, - 'shareWith' => self::TEST_FILES_SHARING_API_USER2, - 'shareType' => \OCP\Share::SHARE_TYPE_USER - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); $topId = $data['id']; - $request = $this->createRequest([ - 'path' => $this->folder . $this->subfolder, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); $ocs->cleanup(); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->deleteShare($topId); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->deleteShare($topId); $ocs->cleanup(); - $request = $this->createRequest([ - 'reshares' => 'true', - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); @@ -1646,35 +1472,22 @@ class ApiTest extends TestCase { */ public function testInvisibleSharesGroup() { // simulate a post request - $request = $this->createRequest([ - 'path' => $this->folder, - 'shareWith' => self::TEST_FILES_SHARING_API_GROUP1, - 'shareType' => \OCP\Share::SHARE_TYPE_GROUP - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); $topId = $data['id']; - $request = $this->createRequest([ - 'path' => $this->folder . $this->subfolder, - 'shareType' => \OCP\Share::SHARE_TYPE_LINK, - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); - $result = $ocs->createShare(); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); $ocs->cleanup(); - $request = $this->createRequest([]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->deleteShare($topId); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); + $ocs->deleteShare($topId); $ocs->cleanup(); - $request = $this->createRequest([ - 'reshares' => 'true', - ]); - $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $result = $ocs->getShares(); $ocs->cleanup(); diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php index b5e769d01d7..e968b40612f 100644 --- a/apps/workflowengine/lib/AppInfo/Application.php +++ b/apps/workflowengine/lib/AppInfo/Application.php @@ -21,9 +21,6 @@ namespace OCA\WorkflowEngine\AppInfo; -use OCP\Util; -use OCP\WorkflowEngine\RegisterCheckEvent; - class Application extends \OCP\AppFramework\App { public function __construct() { @@ -41,6 +38,11 @@ class Application extends \OCP\AppFramework\App { $dispatcher->addListener( 'OCP\WorkflowEngine::loadAdditionalSettingScripts', function() { + if (!function_exists('style')) { + // This is hacky, but we need to load the template class + class_exists('OCP\Template', true); + } + style('workflowengine', [ 'admin', ]); diff --git a/build/license.php b/build/license.php index 5ada91a0f33..3f1fe41764a 100644 --- a/build/license.php +++ b/build/license.php @@ -189,7 +189,7 @@ With help from many libraries and frameworks including: while(!empty($lines)) { $line = $lines[0]; array_shift($lines); - if (strpos($line, 'ownCloud, Inc') !== false) { + if (strpos($line, 'ownCloud, Inc') !== false || strpos($line, 'ownCloud GmbH') !== false) { return true; } } diff --git a/core/ajax/share.php b/core/ajax/share.php deleted file mode 100644 index adcf31a0dfa..00000000000 --- a/core/ajax/share.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Bart Visscher <bartv@thisnet.nl> - * @author Björn Schießle <bjoern@schiessle.org> - * @author Craig Morrissey <craig@owncloud.com> - * @author dampfklon <me@dampfklon.de> - * @author Felix Böhm <felixboehm@gmx.de> - * @author Joas Schilling <coding@schilljs.com> - * @author Leonardo Diez <leio10@users.noreply.github.com> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Michael Gapczynski <GapczynskiM@gmail.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Ramiro Aparicio <rapariciog@gmail.com> - * @author Robin Appelman <robin@icewind.nl> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Thomas Tanghus <thomas@tanghus.net> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -use OCP\IUser; - -OC_JSON::checkLoggedIn(); -OCP\JSON::callCheck(); - -$defaults = new \OCP\Defaults(); - -if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSource'])) { - switch ($_POST['action']) { - case 'informRecipients': - $l = \OC::$server->getL10N('core'); - $shareType = (int) $_POST['shareType']; - $itemType = (string)$_POST['itemType']; - $itemSource = (string)$_POST['itemSource']; - $recipient = (string)$_POST['recipient']; - - $userManager = \OC::$server->getUserManager(); - $recipientList = []; - if($shareType === \OCP\Share::SHARE_TYPE_USER) { - $recipientList[] = $userManager->get($recipient); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { - $recipientList = \OC_Group::usersInGroup($recipient); - $group = \OC::$server->getGroupManager()->get($recipient); - $recipientList = $group->searchUsers(''); - } - // don't send a mail to the user who shared the file - $recipientList = array_filter($recipientList, function($user) { - /** @var IUser $user */ - return $user->getUID() !== \OCP\User::getUser(); - }); - - $mailNotification = new \OC\Share\MailNotifications( - \OC::$server->getUserSession()->getUser(), - \OC::$server->getL10N('lib'), - \OC::$server->getMailer(), - \OC::$server->getLogger(), - $defaults, - \OC::$server->getURLGenerator() - ); - $result = $mailNotification->sendInternalShareMail($recipientList, $itemSource, $itemType); - - \OCP\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, true); - - if (empty($result)) { - OCP\JSON::success(); - } else { - OCP\JSON::error(array( - 'data' => array( - 'message' => $l->t("Couldn't send mail to following users: %s ", - implode(', ', $result) - ) - ) - )); - } - break; - case 'informRecipientsDisabled': - $itemSource = (string)$_POST['itemSource']; - $shareType = (int)$_POST['shareType']; - $itemType = (string)$_POST['itemType']; - $recipient = (string)$_POST['recipient']; - \OCP\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, false); - OCP\JSON::success(); - break; - - case 'email': - // read post variables - $link = (string)$_POST['link']; - $file = (string)$_POST['file']; - $to_address = (string)$_POST['toaddress']; - - $mailNotification = new \OC\Share\MailNotifications( - \OC::$server->getUserSession()->getUser(), - \OC::$server->getL10N('lib'), - \OC::$server->getMailer(), - \OC::$server->getLogger(), - $defaults, - \OC::$server->getURLGenerator() - ); - - $expiration = null; - if (isset($_POST['expiration']) && $_POST['expiration'] !== '') { - try { - $date = new DateTime((string)$_POST['expiration']); - $expiration = $date->getTimestamp(); - } catch (Exception $e) { - \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR); - } - } - - $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration); - if(empty($result)) { - // Get the token from the link - $linkParts = explode('/', $link); - $token = array_pop($linkParts); - - // Get the share for the token - $share = \OCP\Share::getShareByToken($token, false); - if ($share !== false) { - $currentUser = \OC::$server->getUserSession()->getUser()->getUID(); - $file = '/' . ltrim($file, '/'); - - // Check whether share belongs to the user and whether the file is the same - if ($share['file_target'] === $file && $share['uid_owner'] === $currentUser) { - - // Get the path for the user - $view = new \OC\Files\View('/' . $currentUser . '/files'); - $fileId = (int) $share['item_source']; - $path = $view->getPath((int) $share['item_source']); - - if ($path !== null) { - $event = \OC::$server->getActivityManager()->generateEvent(); - $event->setApp(\OCA\Files_Sharing\Activity::FILES_SHARING_APP) - ->setType(\OCA\Files_Sharing\Activity::TYPE_SHARED) - ->setAuthor($currentUser) - ->setAffectedUser($currentUser) - ->setObject('files', $fileId, $path) - ->setSubject(\OCA\Files_Sharing\Activity::SUBJECT_SHARED_EMAIL, [$path, $to_address]); - \OC::$server->getActivityManager()->publish($event); - } - } - } - - \OCP\JSON::success(); - } else { - $l = \OC::$server->getL10N('core'); - OCP\JSON::error(array( - 'data' => array( - 'message' => $l->t("Couldn't send mail to following users: %s ", - implode(', ', $result) - ) - ) - )); - } - - break; - } -} else if (isset($_GET['fetch'])) { - switch ($_GET['fetch']) { - case 'getItemsSharedStatuses': - if (isset($_GET['itemType'])) { - $return = OCP\Share::getItemsShared((string)$_GET['itemType'], OCP\Share::FORMAT_STATUSES); - is_array($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error(); - } - break; - case 'getItem': - if (isset($_GET['itemType']) - && isset($_GET['itemSource']) - && isset($_GET['checkReshare']) - && isset($_GET['checkShares'])) { - if ($_GET['checkReshare'] == 'true') { - $reshare = OCP\Share::getItemSharedWithBySource( - (string)$_GET['itemType'], - (string)$_GET['itemSource'], - OCP\Share::FORMAT_NONE, - null, - true - ); - } else { - $reshare = false; - } - if ($_GET['checkShares'] == 'true') { - $shares = OCP\Share::getItemShared( - (string)$_GET['itemType'], - (string)$_GET['itemSource'], - OCP\Share::FORMAT_NONE, - null, - true - ); - } else { - $shares = false; - } - OC_JSON::success(array('data' => array('reshare' => $reshare, 'shares' => $shares))); - } - break; - case 'getShareWithEmail': - $result = array(); - if (isset($_GET['search'])) { - $cm = OC::$server->getContactsManager(); - if (!is_null($cm) && $cm->isEnabled()) { - $contacts = $cm->search((string)$_GET['search'], array('FN', 'EMAIL')); - foreach ($contacts as $contact) { - if (!isset($contact['EMAIL'])) { - continue; - } - - $emails = $contact['EMAIL']; - if (!is_array($emails)) { - $emails = array($emails); - } - - foreach($emails as $email) { - $result[] = array( - 'id' => $contact['id'], - 'email' => $email, - 'displayname' => $contact['FN'], - ); - } - } - } - } - OC_JSON::success(array('data' => $result)); - break; - case 'getShareWith': - if (isset($_GET['search'])) { - $shareWithinGroupOnly = OC\Share\Share::shareWithGroupMembersOnly(); - $shareWith = array(); - $groups = OC_Group::getGroups((string)$_GET['search']); - if ($shareWithinGroupOnly) { - $usergroups = OC_Group::getUserGroups(OC_User::getUser()); - $groups = array_intersect($groups, $usergroups); - } - - $sharedUsers = []; - $sharedGroups = []; - if (isset($_GET['itemShares'])) { - if (isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) && - is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) { - $sharedUsers = $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]; - } - - if (isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) && - is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) { - $sharedGroups = $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]; - } - } - - $count = 0; - $users = array(); - $limit = 0; - $offset = 0; - // limit defaults to 15 if not specified via request parameter and can be no larger than 500 - $request_limit = min((int)$_GET['limit'] ?: 15, 500); - while ($count < $request_limit && count($users) == $limit) { - $limit = $request_limit - $count; - if ($shareWithinGroupOnly) { - $users = OC_Group::displayNamesInGroups($usergroups, (string)$_GET['search'], $limit, $offset); - } else { - $users = OC_User::getDisplayNames((string)$_GET['search'], $limit, $offset); - } - - $offset += $limit; - foreach ($users as $uid => $displayName) { - if (in_array($uid, $sharedUsers)) { - continue; - } - - if ((!isset($_GET['itemShares']) - || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) - || !in_array($uid, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) - && $uid != OC_User::getUser()) { - $shareWith[] = array( - 'label' => $displayName, - 'value' => array( - 'shareType' => OCP\Share::SHARE_TYPE_USER, - 'shareWith' => $uid) - ); - $count++; - } - } - } - $count = 0; - - // enable l10n support - $l = \OC::$server->getL10N('core'); - - foreach ($groups as $group) { - if (in_array($group, $sharedGroups)) { - continue; - } - - if ($count < $request_limit) { - if (!isset($_GET['itemShares']) - || !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) - || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) - || !in_array($group, $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) { - $shareWith[] = array( - 'label' => $group, - 'value' => array( - 'shareType' => OCP\Share::SHARE_TYPE_GROUP, - 'shareWith' => $group - ) - ); - $count++; - } - } else { - break; - } - } - - // allow user to add unknown remote addresses for server-to-server share - $backend = \OCP\Share::getBackend((string)$_GET['itemType']); - if ($backend->isShareTypeAllowed(\OCP\Share::SHARE_TYPE_REMOTE)) { - if (substr_count((string)$_GET['search'], '@') >= 1) { - $shareWith[] = array( - 'label' => (string)$_GET['search'], - 'value' => array( - 'shareType' => \OCP\Share::SHARE_TYPE_REMOTE, - 'shareWith' => (string)$_GET['search'] - ) - ); - } - $contactManager = \OC::$server->getContactsManager(); - $addressBookContacts = $contactManager->search($_GET['search'], ['CLOUD', 'FN']); - foreach ($addressBookContacts as $contact) { - if (isset($contact['CLOUD'])) { - foreach ($contact['CLOUD'] as $cloudId) { - $shareWith[] = array( - 'label' => $contact['FN'] . ' (' . $cloudId . ')', - 'value' => array( - 'shareType' => \OCP\Share::SHARE_TYPE_REMOTE, - 'shareWith' => $cloudId - ) - ); - } - } - } - } - - $sharingAutocompletion = \OC::$server->getConfig() - ->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'); - - if ($sharingAutocompletion !== 'yes') { - $searchTerm = strtolower($_GET['search']); - $shareWith = array_filter($shareWith, function($user) use ($searchTerm) { - return strtolower($user['label']) === $searchTerm - || strtolower($user['value']['shareWith']) === $searchTerm; - }); - } - - $sorter = new \OC\Share\SearchResultSorter((string)$_GET['search'], - 'label', - \OC::$server->getLogger()); - usort($shareWith, array($sorter, 'sort')); - OC_JSON::success(array('data' => $shareWith)); - } - break; - } -} diff --git a/core/css/apps.css b/core/css/apps.css index 0ccdb8a0398..24865cd6f6d 100644 --- a/core/css/apps.css +++ b/core/css/apps.css @@ -92,7 +92,7 @@ width: 44px; margin: 0; padding: 0; - background: none; background-image: url('../img/actions/triangle-s.svg'); + background: none; background-image: url('../img/actions/triangle-s.svg?v=1'); background-size: 16px; background-repeat: no-repeat; background-position: center; border: none; border-radius: 0; @@ -256,7 +256,7 @@ background-color: transparent; background-repeat: no-repeat; background-position: center; - background-image: url('../img/actions/more.svg'); + background-image: url('../img/actions/more.svg?v=1'); } #app-navigation .app-navigation-entry-utils-menu-button:hover button, @@ -497,7 +497,7 @@ padding: 0; margin: 0; background-color: #fff; - background-image: url('../img/actions/settings.svg'); + background-image: url('../img/actions/settings.svg?v=1'); background-position: 14px center; background-repeat: no-repeat; box-shadow: none; diff --git a/core/css/header.css b/core/css/header.css index 5a2b8009b15..efdd3be7ceb 100644 --- a/core/css/header.css +++ b/core/css/header.css @@ -68,7 +68,7 @@ } #header .logo { - background-image: url('../img/logo-icon.svg'); + background-image: url('../img/logo-icon.svg?v=1'); background-repeat: no-repeat; background-size: 175px; background-position: center; @@ -80,7 +80,7 @@ #header .logo-icon { /* display logo so appname can be shown next to it */ display: inline-block; - background-image: url('../img/logo-icon.svg'); + background-image: url('../img/logo-icon.svg?v=1'); background-repeat: no-repeat; background-position: center center; width: 62px; diff --git a/core/css/styles.css b/core/css/styles.css index 7f4f7896c94..428688060b7 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -26,7 +26,7 @@ body { #body-login { text-align: center; background-color: #0082c9; - background-image: url('../img/background.jpg'); + background-image: url('../img/background.jpg?v=1'); background-position: 50% 50%; background-repeat: no-repeat; background-size: cover; @@ -98,7 +98,7 @@ a.two-factor-cancel { font-size: 1.2em; padding: 3px; padding-left: 25px; - background: transparent url('../img/actions/search-white.svg') no-repeat 6px center; + background: transparent url('../img/actions/search-white.svg?v=1') no-repeat 6px center; color: #fff; border: 0; border-radius: 3px; @@ -465,7 +465,7 @@ label.infield { position: absolute !important; height: 20px; width: 24px; - background-image: url('../img/actions/toggle.svg'); + background-image: url('../img/actions/toggle.svg?v=1'); background-repeat: no-repeat; background-position: center; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"; @@ -757,15 +757,15 @@ a.bookmarklet { background-color:#ddd; border:1px solid #ccc; padding:5px;paddin .exception{color:#000;} .exception textarea{width:95%;height:200px;background:#ffe;border:0;} -.ui-icon-circle-triangle-e{ background-image:url('../img/actions/play-next.svg'); } -.ui-icon-circle-triangle-w{ background-image:url('../img/actions/play-previous.svg'); } +.ui-icon-circle-triangle-e{ background-image:url('../img/actions/play-next.svg?v=1'); } +.ui-icon-circle-triangle-w{ background-image:url('../img/actions/play-previous.svg?v=1'); } .ui-datepicker-prev,.ui-datepicker-next{ border:1px solid #ddd; background:#fff; } /* ---- DIALOGS ---- */ #oc-dialog-filepicker-content .dirtree {width:92%; overflow:hidden; } #oc-dialog-filepicker-content .dirtree .home { - background-image:url('../img/places/home.svg'); + background-image:url('../img/places/home.svg?v=1'); background-repeat:no-repeat; background-position: left center; width: 30px; @@ -848,7 +848,7 @@ span.ui-icon {float: left; margin: 3px 7px 30px 0;} } .popup.topright { top:7em; right:1em; } .popup.bottomleft { bottom:1em; left:33em; } -.popup .close { position:absolute; top:0.2em; right:0.2em; height:20px; width:20px; background:url('../img/actions/close.svg') no-repeat center; } +.popup .close { position:absolute; top:0.2em; right:0.2em; height:20px; width:20px; background:url('../img/actions/close.svg?v=1') no-repeat center; } .popup h2 { font-size:20px; } .arrow { border-bottom:10px solid white; border-left:10px solid transparent; border-right:10px solid transparent; display:block; height:0; position:absolute; width:0; z-index:201; } .arrow.left { left:-13px; bottom:1.2em; -webkit-transform:rotate(270deg); -ms-transform:rotate(270deg); transform:rotate(270deg); } @@ -860,7 +860,7 @@ span.ui-icon {float: left; margin: 3px 7px 30px 0;} div.crumb { float: left; display: block; - background-image: url('../img/breadcrumb.svg'); + background-image: url('../img/breadcrumb.svg?v=1'); background-repeat: no-repeat; background-position: right center; height: 44px; diff --git a/core/js/js.js b/core/js/js.js index ea621123fb0..4e8d3a01416 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1501,21 +1501,17 @@ function initCore() { $navigation.hide(); // show loading feedback - $navigation.delegate('a', 'mousedown', function(event) { + $navigation.delegate('a', 'click', function(event) { var $app = $(event.target); if(!$app.is('a')) { $app = $app.closest('a'); } - if(event.which === 1 && !event.ctrlKey && !event.metaKey) { + if(!event.ctrlKey) { $app.addClass('app-loading'); } else { - // On middle click or on first button click with ctrl key or meta key hold - if(event.which === 2 || (event.which === 1 && (event.ctrlKey || event.metaKey))) { - // Close navigation when opening app in - // a new tab - OC.hideMenus(); - window.open($app, '_blank'); - } + // Close navigation when opening app in + // a new tab + OC.hideMenus(); } }); } @@ -1523,26 +1519,14 @@ function initCore() { function setupUserMenu() { var $menu = $('#header #settings'); - // show loading feedback - $menu.delegate('a', 'mousedown', function(event) { + $menu.delegate('a', 'click', function(event) { var $page = $(event.target); if (!$page.is('a')) { $page = $page.closest('a'); } - if(event.which === 1 && !event.ctrlKey && !event.metaKey) { - $page.find('img').remove(); - $page.find('div').remove(); // prevent odd double-clicks - $page.prepend($('<div/>').addClass('icon-loading-small-dark')); - } else { - // On middle click or on first button click with ctrl key or meta key hold - if(event.which === 2 || (event.which === 1 && (event.ctrlKey || event.metaKey))) { - // Close navigation when opening menu entry in - // a new tab - OC.hideMenus(); - window.open($page, '_blank'); - } - } - $($page).click(); + $page.find('img').remove(); + $page.find('div').remove(); // prevent odd double-clicks + $page.prepend($('<div/>').addClass('icon-loading-small-dark')); }); } diff --git a/core/routes.php b/core/routes.php index 90b8b4d2ace..3eec1e58c33 100644 --- a/core/routes.php +++ b/core/routes.php @@ -70,9 +70,6 @@ $this->create('search_ajax_search', '/core/search') // AppConfig $this->create('core_ajax_appconfig', '/core/ajax/appconfig.php') ->actionInclude('core/ajax/appconfig.php'); -// Share -$this->create('core_ajax_share', '/core/ajax/share.php') - ->actionInclude('core/ajax/share.php'); // Tags $this->create('core_tags_tags', '/tags/{type}') ->get() diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 2c0d3f05297..17f895bc17d 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -81,14 +81,14 @@ <li> <a href="<?php print_unescaped($entry['href']); ?>" <?php if( $entry["active"] ): ?> class="active"<?php endif; ?>> - <img alt="" src="<?php print_unescaped($entry['icon']); ?>"> + <img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"> <?php p($entry['name']) ?> </a> </li> <?php endforeach; ?> <li> <a id="logout" <?php print_unescaped(OC_User::getLogoutAttribute()); ?>> - <img alt="" src="<?php print_unescaped(image_path('', 'actions/logout.svg')); ?>"> + <img alt="" src="<?php print_unescaped(image_path('', 'actions/logout.svg') . '?v=' . $_['versionHash']); ?>"> <?php p($l->t('Log out'));?> </a> </li> @@ -115,7 +115,7 @@ <?php if( $entry['active'] ): ?> class="active"<?php endif; ?>> <svg width="32" height="32" viewBox="0 0 32 32"> <defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs> - <image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped($entry['icon']); ?>" class="app-icon"></image> + <image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" class="app-icon"></image> </svg> <div class="icon-loading-dark" style="display:none;"></div> <span> @@ -133,7 +133,7 @@ <?php if( $_['appsmanagement_active'] ): ?> class="active"<?php endif; ?>> <svg width="32" height="32" viewBox="0 0 32 32" class="app-icon"> <defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs> - <image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped(image_path('settings', 'apps.svg')); ?>"></image> + <image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped(image_path('settings', 'apps.svg') . '?v=' . $_['versionHash']); ?>"></image> </svg> <div class="icon-loading-dark" style="display:none;"></div> <span> diff --git a/lib/private/App/CodeChecker/InfoChecker.php b/lib/private/App/CodeChecker/InfoChecker.php index 3ee99dc6478..77bf7e8182d 100644 --- a/lib/private/App/CodeChecker/InfoChecker.php +++ b/lib/private/App/CodeChecker/InfoChecker.php @@ -80,7 +80,7 @@ class InfoChecker extends BasicEmitter { $info = $this->infoParser->parse($appPath . '/appinfo/info.xml'); - if (isset($info['dependencies']['owncloud']['@attributes']['min-version']) && ($info['requiremin'] || $info['require'])) { + if (isset($info['dependencies']['owncloud']['@attributes']['min-version']) && (isset($info['requiremin']) || isset($info['require']))) { $this->emit('InfoChecker', 'duplicateRequirement', ['min']); $errors[] = [ 'type' => 'duplicateRequirement', @@ -90,7 +90,7 @@ class InfoChecker extends BasicEmitter { $this->emit('InfoChecker', 'missingRequirement', ['min']); } - if (isset($info['dependencies']['owncloud']['@attributes']['max-version']) && $info['requiremax']) { + if (isset($info['dependencies']['owncloud']['@attributes']['max-version']) && isset($info['requiremax'])) { $this->emit('InfoChecker', 'duplicateRequirement', ['max']); $errors[] = [ 'type' => 'duplicateRequirement', diff --git a/lib/private/Server.php b/lib/private/Server.php index 44fc605826c..eb49155adef 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1397,7 +1397,7 @@ class Server extends ServerContainer implements IServerContainer { * @return \OCA\Files_External\Service\BackendService */ public function getStoragesBackendService() { - return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\BackendService'); + return $this->query('OCA\\Files_External\\Service\\BackendService'); } /** @@ -1406,7 +1406,7 @@ class Server extends ServerContainer implements IServerContainer { * @return \OCA\Files_External\Service\GlobalStoragesService */ public function getGlobalStoragesService() { - return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\GlobalStoragesService'); + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); } /** @@ -1415,7 +1415,7 @@ class Server extends ServerContainer implements IServerContainer { * @return \OCA\Files_External\Service\UserGlobalStoragesService */ public function getUserGlobalStoragesService() { - return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); } /** @@ -1424,7 +1424,7 @@ class Server extends ServerContainer implements IServerContainer { * @return \OCA\Files_External\Service\UserStoragesService */ public function getUserStoragesService() { - return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserStoragesService'); + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); } /** diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 9e3bbf88470..7e5c120717f 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -153,6 +153,7 @@ class TemplateLayout extends \OC_Template { $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); $this->assign('cssfiles', array()); $this->assign('printcssfiles', []); + $this->assign('versionHash', self::$versionHash); foreach($cssFiles as $info) { $web = $info[1]; $file = $info[2]; diff --git a/settings/js/apps.js b/settings/js/apps.js index ac259dd7989..99246f323fe 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -236,10 +236,9 @@ OC.Settings.Apps = OC.Settings.Apps || { var img = '<svg width="72" height="72" viewBox="0 0 72 72">'; if (appfromstore) { - img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" xlink:href="' + url + '" class="app-icon" /></svg>'; + img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" xlink:href="' + url + '?v=' + oc_config.version + '" class="app-icon" /></svg>'; } else { - img += '<defs><filter id="invertIcon"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>'; - img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" filter="url(#invertIcon)" xlink:href="' + url + '" class="app-icon"></image></svg>'; + img += '<image x="0" y="0" width="72" height="72" preserveAspectRatio="xMinYMin meet" filter="url(#invertIcon)" xlink:href="' + url + '?v=' + oc_config.version + '" class="app-icon"></image></svg>'; } return img; }, diff --git a/settings/templates/apps.php b/settings/templates/apps.php index be8a911c1aa..ea62acd9945 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -180,6 +180,9 @@ script( </div> </div> <div id="app-content"> + <svg height="0"> + <defs><filter id="invertIcon"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs> + </svg> <div id="apps-list" class="icon-loading"></div> <div id="apps-list-empty" class="hidden emptycontent emptycontent-search"> <div class="icon-search"></div> |