Skip to content

Commit

Permalink
Replace deprecated constant with new class constant
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Nov 25, 2014
1 parent 711912a commit 2c39aec
Show file tree
Hide file tree
Showing 41 changed files with 237 additions and 237 deletions.
6 changes: 3 additions & 3 deletions apps/files/ajax/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// If not, check the login.
// If no token is sent along, rely on login only

$allowedPermissions = OCP\PERMISSION_ALL;
$allowedPermissions = \OCP\Constants::PERMISSION_ALL;
$errorCode = null;

$l = \OC::$server->getL10N('files');
Expand All @@ -27,7 +27,7 @@
\OC_User::setIncognitoMode(true);

// return only read permissions for public upload
$allowedPermissions = OCP\PERMISSION_READ;
$allowedPermissions = \OCP\Constants::PERMISSION_READ;
$publicDirectory = !empty($_POST['subdir']) ? $_POST['subdir'] : '/';

$linkItem = OCP\Share::getShareByToken($_POST['dirToken']);
Expand All @@ -36,7 +36,7 @@
die();
}

if (!($linkItem['permissions'] & OCP\PERMISSION_CREATE)) {
if (!($linkItem['permissions'] & \OCP\Constants::PERMISSION_CREATE)) {
OCP\JSON::checkLoggedIn();
} else {
// resolve reshares
Expand Down
2 changes: 1 addition & 1 deletion apps/files_encryption/tests/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function testDeleteHooksForSharedFiles() {
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);

// share the file with user2
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2, \OCP\Constants::PERMISSION_ALL);

// check if new share key exists
$this->assertTrue($this->rootView->file_exists(
Expand Down
22 changes: 11 additions & 11 deletions apps/files_encryption/tests/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function testShareFile($withTeardown = true) {
\OC_FileProxy::$enabled = $proxyStatus;

// share the file
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -232,7 +232,7 @@ function testReShareFile($withTeardown = true) {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);

// share the file with user3
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -328,7 +328,7 @@ function testShareFolder($withTeardown = true) {
\OC_FileProxy::$enabled = $proxyStatus;

// share the folder with user1
\OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -406,7 +406,7 @@ function testReShareFolder($withTeardown = true) {
\OC_FileProxy::$enabled = $proxyStatus;

// share the file with user3
\OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -437,7 +437,7 @@ function testReShareFolder($withTeardown = true) {
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);

// share the file with user3
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -539,7 +539,7 @@ function testPublicShareFile() {
\OC_FileProxy::$enabled = $proxyStatus;

// share the file
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, false, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, false, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -617,7 +617,7 @@ function testShareFileWithGroup() {
\OC_FileProxy::$enabled = $proxyStatus;

// share the file
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL);

// login as admin
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
Expand Down Expand Up @@ -923,7 +923,7 @@ function testFailShareFile() {

// share the file
try {
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL);
} catch (Exception $e) {
$this->assertEquals(0, strpos($e->getMessage(), "Following users are not set up for encryption"));
}
Expand Down Expand Up @@ -991,7 +991,7 @@ function testRename() {
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);

// share the file
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL);

// check if share key for user2 exists
$this->assertTrue($this->view->file_exists(
Expand Down Expand Up @@ -1059,7 +1059,7 @@ function testMoveFolder() {
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);

// share the folder
\OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL);

\OC\Files\Filesystem::rename($folder, $newFolder);

Expand Down Expand Up @@ -1117,7 +1117,7 @@ function testMoveFileToFolder($userId) {
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);

// share the folder
\OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
\OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL);

// check that the share keys exist
$this->assertTrue($view->file_exists('files_encryption/share-keys' . $folder . '/' . $filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey'));
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ private static function formatMount($mountPoint, $mountConfig) {

$isSystemMount = !$mountConfig['personal'];

$permissions = \OCP\PERMISSION_READ;
$permissions = \OCP\Constants::PERMISSION_READ;
// personal mounts can be deleted
if (!$isSystemMount) {
$permissions |= \OCP\PERMISSION_DELETE;
$permissions |= \OCP\Constants::PERMISSION_DELETE;
}

$entry = array(
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/ajax/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
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;
}

Expand All @@ -78,7 +78,7 @@
// 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;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/ajax/shareinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// 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));
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/controllers/sharecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function showShare($token, $path = '') {
$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);
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/lib/readonlycache.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
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;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/readonlywrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function isDeletable($path) {
}

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) {
Expand Down
14 changes: 7 additions & 7 deletions apps/files_sharing/lib/sharedstorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getFile($target) {
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());
Expand Down Expand Up @@ -109,11 +109,11 @@ public function getPermissions($target = '') {
$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;
Expand Down Expand Up @@ -197,26 +197,26 @@ public function filesize($path) {
}

public function isCreatable($path) {
return ($this->getPermissions($path) & \OCP\PERMISSION_CREATE);
return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE);
}

public function isReadable($path) {
return $this->file_exists($path);
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/publicwebdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$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) {
Expand Down
6 changes: 3 additions & 3 deletions apps/files_sharing/tests/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ function testUpdateShare() {
$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);
Expand Down Expand Up @@ -822,7 +822,7 @@ function testUpdateShare() {

// 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

Expand Down Expand Up @@ -1228,7 +1228,7 @@ public function testDefaultExpireDate() {
$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);
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/tests/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function testGetPathByIdDirectShare() {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OC\Files\Filesystem::file_put_contents('test.txt', 'foo');
$info = \OC\Files\Filesystem::getFileInfo('test.txt');
\OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL);
\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);
Expand All @@ -369,7 +369,7 @@ public function testGetPathByIdShareSubFolder() {
\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);
Expand Down
Loading

0 comments on commit 2c39aec

Please sign in to comment.