diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-11-26 08:31:23 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-11-26 08:31:23 +0100 |
commit | c5fa8f1bdc08b07d03fcc9f9c84033960ec4e20f (patch) | |
tree | b2e989a445cf6afce925dea68765dc779dbc772a /apps/files_sharing | |
parent | 3766d98df6845397d810d583575c1fcedb51df90 (diff) | |
parent | 2c39aec8cb8ce7f74c8edd1111e7f7b6a70cf7c5 (diff) | |
download | nextcloud-server-c5fa8f1bdc08b07d03fcc9f9c84033960ec4e20f.tar.gz nextcloud-server-c5fa8f1bdc08b07d03fcc9f9c84033960ec4e20f.zip |
Merge pull request #12421 from owncloud/issue/6101-remove-namespace-permission-constants
Issue/6101 remove namespace permission constants
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/ajax/list.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/ajax/shareinfo.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/controllers/sharecontroller.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/readonlycache.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/lib/readonlywrapper.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 14 | ||||
-rw-r--r-- | apps/files_sharing/publicwebdav.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/api.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/tests/cache.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/tests/share.php | 28 |
10 files changed, 34 insertions, 34 deletions
diff --git a/apps/files_sharing/ajax/list.php b/apps/files_sharing/ajax/list.php index 7e2e54a1bd9..073c86365be 100644 --- a/apps/files_sharing/ajax/list.php +++ b/apps/files_sharing/ajax/list.php @@ -65,7 +65,7 @@ $formattedFiles = array(); foreach ($files as $file) { $entry = \OCA\Files\Helper::formatFileInfo($file); unset($entry['directory']); // for now - $entry['permissions'] = \OCP\PERMISSION_READ; + $entry['permissions'] = \OCP\Constants::PERMISSION_READ; $formattedFiles[] = $entry; } @@ -78,7 +78,7 @@ $permissions = $linkItem['permissions']; // if globally disabled if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') { // only allow reading - $permissions = \OCP\PERMISSION_READ; + $permissions = \OCP\Constants::PERMISSION_READ; } $data['permissions'] = $permissions; diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php index e87b0779e8d..f196a67a9dd 100644 --- a/apps/files_sharing/ajax/shareinfo.php +++ b/apps/files_sharing/ajax/shareinfo.php @@ -31,7 +31,7 @@ $linkItem = $data['linkItem']; // Load the files $path = $data['realPath']; -$isWritable = $linkItem['permissions'] & (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_CREATE); +$isWritable = $linkItem['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); if (!$isWritable) { \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage)); diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php index 7518292131c..0a0594ed8ff 100644 --- a/apps/files_sharing/lib/controllers/sharecontroller.php +++ b/apps/files_sharing/lib/controllers/sharecontroller.php @@ -182,7 +182,7 @@ class ShareController extends Controller { $folder = new Template('files', 'list', ''); $folder->assign('dir', $getPath); $folder->assign('dirToken', $linkItem['token']); - $folder->assign('permissions', OCP\PERMISSION_READ); + $folder->assign('permissions', \OCP\Constants::PERMISSION_READ); $folder->assign('isPublic', true); $folder->assign('publicUploadEnabled', 'no'); $folder->assign('files', $files); diff --git a/apps/files_sharing/lib/readonlycache.php b/apps/files_sharing/lib/readonlycache.php index f129ca49433..6dd3b9cf61d 100644 --- a/apps/files_sharing/lib/readonlycache.php +++ b/apps/files_sharing/lib/readonlycache.php @@ -13,14 +13,14 @@ use OC\Files\Cache\Cache; class ReadOnlyCache extends Cache { public function get($path) { $data = parent::get($path); - $data['permissions'] &= (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE); + $data['permissions'] &= (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE); return $data; } public function getFolderContents($path) { $content = parent::getFolderContents($path); foreach ($content as &$data) { - $data['permissions'] &= (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE); + $data['permissions'] &= (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE); } return $content; } diff --git a/apps/files_sharing/lib/readonlywrapper.php b/apps/files_sharing/lib/readonlywrapper.php index 45ed3fd68bb..58a5695aff8 100644 --- a/apps/files_sharing/lib/readonlywrapper.php +++ b/apps/files_sharing/lib/readonlywrapper.php @@ -24,7 +24,7 @@ class ReadOnlyWrapper extends Wrapper { } public function getPermissions($path) { - return $this->storage->getPermissions($path) & (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE); + return $this->storage->getPermissions($path) & (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE); } public function rename($path1, $path2) { diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 19ee6085e47..1ac57053e25 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -67,7 +67,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { if ($source) { $source['path'] .= '.part'; // All partial files have delete permission - $source['permissions'] |= \OCP\PERMISSION_DELETE; + $source['permissions'] |= \OCP\Constants::PERMISSION_DELETE; } } else { $source = \OC_Share_Backend_File::getSource($target, $this->getMountPoint(), $this->getItemType()); @@ -109,11 +109,11 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { $permissions = $this->share['permissions']; // part files and the mount point always have delete permissions if ($target === '' || pathinfo($target, PATHINFO_EXTENSION) === 'part') { - $permissions |= \OCP\PERMISSION_DELETE; + $permissions |= \OCP\Constants::PERMISSION_DELETE; } if (\OC_Util::isSharingDisabledForUser()) { - $permissions &= ~\OCP\PERMISSION_SHARE; + $permissions &= ~\OCP\Constants::PERMISSION_SHARE; } return $permissions; @@ -197,7 +197,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { } public function isCreatable($path) { - return ($this->getPermissions($path) & \OCP\PERMISSION_CREATE); + return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE); } public function isReadable($path) { @@ -205,18 +205,18 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { } public function isUpdatable($path) { - return ($this->getPermissions($path) & \OCP\PERMISSION_UPDATE); + return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE); } public function isDeletable($path) { - return ($this->getPermissions($path) & \OCP\PERMISSION_DELETE); + return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE); } public function isSharable($path) { if (\OCP\Util::isSharingDisabledForUser()) { return false; } - return ($this->getPermissions($path) & \OCP\PERMISSION_SHARE); + return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); } public function file_exists($path) { diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php index 03e43967a40..2c7ccf8d92c 100644 --- a/apps/files_sharing/publicwebdav.php +++ b/apps/files_sharing/publicwebdav.php @@ -41,7 +41,7 @@ $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav')); $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree, $authBackend) { $share = $authBackend->getShare(); $owner = $share['uid_owner']; - $isWritable = $share['permissions'] & (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_CREATE); + $isWritable = $share['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); $fileId = $share['file_source']; if (!$isWritable) { diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index e550dcc27db..1259197423b 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -788,7 +788,7 @@ class Test_Files_Sharing_Api extends TestCase { $fileInfo = $this->view->getFileInfo($this->filename); $result = \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, - \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL); // share was successful? $this->assertTrue($result); @@ -822,7 +822,7 @@ class Test_Files_Sharing_Api extends TestCase { // check if share have expected permissions, single shared files never have // delete permissions - $this->assertEquals(\OCP\PERMISSION_ALL & ~\OCP\PERMISSION_DELETE, $userShare['permissions']); + $this->assertEquals(\OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_DELETE, $userShare['permissions']); // update permissions @@ -1228,7 +1228,7 @@ class Test_Files_Sharing_Api extends TestCase { $info = OC\Files\Filesystem::getFileInfo($this->filename); $this->assertTrue($info instanceof \OC\Files\FileInfo); - $result = \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, null, \OCP\PERMISSION_READ); + $result = \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $this->assertTrue(is_string($result)); $result = \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31); diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php index b6a44f464f9..aec1983bad3 100644 --- a/apps/files_sharing/tests/cache.php +++ b/apps/files_sharing/tests/cache.php @@ -348,7 +348,7 @@ class Test_Files_Sharing_Cache extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); \OC\Files\Filesystem::file_put_contents('test.txt', 'foo'); $info = \OC\Files\Filesystem::getFileInfo('test.txt'); - \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL); \OC_Util::tearDownFS(); self::loginHelper(self::TEST_FILES_SHARING_API_USER2); @@ -369,7 +369,7 @@ class Test_Files_Sharing_Cache extends TestCase { \OC\Files\Filesystem::touch('foo/bar/test.txt'); $folderInfo = \OC\Files\Filesystem::getFileInfo('foo'); $fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt'); - \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL); \OC_Util::tearDownFS(); self::loginHelper(self::TEST_FILES_SHARING_API_USER2); diff --git a/apps/files_sharing/tests/share.php b/apps/files_sharing/tests/share.php index 4318d3c510e..f76f92734d0 100644 --- a/apps/files_sharing/tests/share.php +++ b/apps/files_sharing/tests/share.php @@ -105,12 +105,12 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { $fileinfo = $this->view->getFileInfo($this->filename); $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, - \Test_Files_Sharing::TEST_FILES_SHARING_API_GROUP1, \OCP\PERMISSION_READ); + \Test_Files_Sharing::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_READ); $this->assertTrue($result); $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, - \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_UPDATE); + \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_UPDATE); $this->assertTrue($result); @@ -124,7 +124,7 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { $this->assertSame(1, count($result)); $share = reset($result); - $this->assertSame(\OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE, $share['permissions']); + $this->assertSame(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, $share['permissions']); \OC\Files\Filesystem::rename($this->filename, $this->filename . '-renamed'); @@ -136,7 +136,7 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { $this->assertSame(1, count($result)); $share = reset($result); - $this->assertSame(\OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE, $share['permissions']); + $this->assertSame(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, $share['permissions']); $this->assertSame($this->filename . '-renamed', $share['file_target']); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); @@ -157,7 +157,7 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { $share = reset($result); // only the group share permissions should be available now - $this->assertSame(\OCP\PERMISSION_READ, $share['permissions']); + $this->assertSame(\OCP\Constants::PERMISSION_READ, $share['permissions']); $this->assertSame($this->filename . '-renamed', $share['file_target']); } @@ -172,8 +172,8 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { $fileinfo = $this->view->getFileInfo($this->filename); // share the file to group1 (user2 is a member of this group) and explicitely to user2 - \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, \OCP\PERMISSION_ALL); - \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL); // user1 should have to shared files $shares = \OCP\Share::getItemsShared('file'); @@ -203,7 +203,7 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { $this->assertSame(1, count($shares)); // user1 shares a gain the file directly to user2 - \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL); // user2 should see again welcome.txt and the shared file \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2); @@ -271,14 +271,14 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase { } function DataProviderTestFileSharePermissions() { - $permission1 = \OCP\PERMISSION_ALL; - $permission3 = \OCP\PERMISSION_READ; - $permission4 = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE; - $permission5 = \OCP\PERMISSION_READ | \OCP\PERMISSION_DELETE; - $permission6 = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE; + $permission1 = \OCP\Constants::PERMISSION_ALL; + $permission3 = \OCP\Constants::PERMISSION_READ; + $permission4 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE; + $permission5 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE; + $permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE; return array( - array($permission1, \OCP\PERMISSION_ALL & ~\OCP\PERMISSION_DELETE), + array($permission1, \OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_DELETE), array($permission3, $permission3), array($permission4, $permission4), array($permission5, $permission3), |