diff options
77 files changed, 585 insertions, 395 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index b960e02ced7..eb99d0644f7 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -1,5 +1,7 @@ <?php +\OC::$server->getSession()->close(); + // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); @@ -7,7 +9,7 @@ OCP\JSON::setContentTypeHeader('text/plain'); // 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'); @@ -27,7 +29,7 @@ if (empty($_POST['dirToken'])) { \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']); @@ -36,7 +38,7 @@ if (empty($_POST['dirToken'])) { die(); } - if (!($linkItem['permissions'] & OCP\PERMISSION_CREATE)) { + if (!($linkItem['permissions'] & \OCP\Constants::PERMISSION_CREATE)) { OCP\JSON::checkLoggedIn(); } else { // resolve reshares @@ -64,13 +66,7 @@ if (empty($_POST['dirToken'])) { } } - OCP\JSON::callCheck(); -if (!\OCP\App::isEnabled('files_encryption')) { - // encryption app need to create keys later, so can't close too early - \OC::$server->getSession()->close(); -} - // get array with current storage stats (e.g. max file size) $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 55f2df783c4..a358a46a6e7 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -91,7 +91,6 @@ class Proxy extends \OC_FileProxy { private function shouldEncrypt($path, $mode = 'w') { $userId = Helper::getUser($path); - $session = new Session(new \OC\Files\View()); // don't call the crypt stream wrapper, if... if ( diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index 7bd4fd02421..132748b6ea5 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -29,6 +29,7 @@ namespace OCA\Encryption; class Session { private $view; + private static $publicShareKey = false; const NOT_INITIALIZED = '0'; const INIT_EXECUTED = '1'; @@ -92,7 +93,7 @@ class Session { } - if (\OCA\Encryption\Helper::isPublicAccess()) { + if (\OCA\Encryption\Helper::isPublicAccess() && !self::getPublicSharePrivateKey()) { // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; @@ -100,9 +101,7 @@ class Session { $encryptedKey = $this->view->file_get_contents( '/owncloud_private_key/' . $publicShareKeyId . '.private.key'); $privateKey = Crypt::decryptPrivateKey($encryptedKey, ''); - $this->setPublicSharePrivateKey($privateKey); - - $this->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL); + self::setPublicSharePrivateKey($privateKey); \OC_FileProxy::$enabled = $proxyStatus; } @@ -127,8 +126,8 @@ class Session { * remove keys from session */ public function removeKeys() { - \OC::$session->remove('publicSharePrivateKey'); - \OC::$session->remove('privateKey'); + \OC::$server->getSession()->remove('publicSharePrivateKey'); + \OC::$server->getSession()->remove('privateKey'); } /** @@ -164,6 +163,8 @@ class Session { public function getInitialized() { if (!is_null(\OC::$server->getSession()->get('encryptionInitialized'))) { return \OC::$server->getSession()->get('encryptionInitialized'); + } else if (\OCA\Encryption\Helper::isPublicAccess() && self::getPublicSharePrivateKey()) { + return self::INIT_SUCCESSFUL; } else { return self::NOT_INITIALIZED; } @@ -177,7 +178,7 @@ class Session { public function getPrivateKey() { // return the public share private key if this is a public access if (\OCA\Encryption\Helper::isPublicAccess()) { - return $this->getPublicSharePrivateKey(); + return self::getPublicSharePrivateKey(); } else { if (!is_null(\OC::$server->getSession()->get('privateKey'))) { return \OC::$server->getSession()->get('privateKey'); @@ -192,12 +193,9 @@ class Session { * @param string $privateKey * @return bool */ - public function setPublicSharePrivateKey($privateKey) { - - \OC::$server->getSession()->set('publicSharePrivateKey', $privateKey); - + private static function setPublicSharePrivateKey($privateKey) { + self::$publicShareKey = $privateKey; return true; - } /** @@ -205,13 +203,8 @@ class Session { * @return string $privateKey * */ - public function getPublicSharePrivateKey() { - - if (!is_null(\OC::$server->getSession()->get('publicSharePrivateKey'))) { - return \OC::$server->getSession()->get('publicSharePrivateKey'); - } else { - return false; - } + private static function getPublicSharePrivateKey() { + return self::$publicShareKey; } } diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php index 9ea84cc94c2..4b8be0c7c1c 100644 --- a/apps/files_encryption/tests/hooks.php +++ b/apps/files_encryption/tests/hooks.php @@ -256,7 +256,7 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { $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( diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php index 20ee2cc7064..24b828433d0 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -171,7 +171,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \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); @@ -232,7 +232,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { '/' . \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); @@ -328,7 +328,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \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); @@ -406,7 +406,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \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); @@ -437,7 +437,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $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); @@ -539,7 +539,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \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); @@ -617,7 +617,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \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); @@ -923,7 +923,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // 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")); } @@ -991,7 +991,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $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( @@ -1059,7 +1059,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $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); @@ -1117,7 +1117,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $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')); diff --git a/apps/files_external/lib/api.php b/apps/files_external/lib/api.php index 81ebd4e886a..3b5e0e1759a 100644 --- a/apps/files_external/lib/api.php +++ b/apps/files_external/lib/api.php @@ -45,10 +45,10 @@ class Api { $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( diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 6e53c4a9931..3f0b0f45bfb 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -139,13 +139,8 @@ class SMB extends \OC\Files\Storage\StreamWrapper{ * check if smbclient is installed */ public static function checkDependencies() { - if (function_exists('shell_exec')) { - $output=shell_exec('command -v smbclient 2> /dev/null'); - if (!empty($output)) { - return true; - } - } - return array('smbclient'); + $smbClientExists = (bool) \OC_Helper::findBinaryPath('smbclient'); + return $smbClientExists ? true : array('smbclient'); } } 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 076df3c46f6..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); @@ -203,7 +203,6 @@ class ShareController extends Controller { /** * @PublicPage * @NoCSRFRequired - * @UseSession * * @param string $token * @param string $files @@ -213,12 +212,6 @@ class ShareController extends Controller { public function downloadShare($token, $files = null, $path = '') { \OC_User::setIncognitoMode(true); - // FIXME: Use DI once there is a suitable class - if (!\OCP\App::isEnabled('files_encryption')) { - // encryption app requires the session to store the keys in - \OC::$server->getSession()->close(); - } - $linkItem = OCP\Share::getShareByToken($token, false); // Share is password protected - check whether the user is permitted to access the share @@ -244,7 +237,7 @@ class ShareController extends Controller { } // FIXME: The exit is required here because otherwise the AppFramework is trying to add headers as well - // after dispatching the request which results in a "Cannot modify header information" notice. + // after dispatching the request which results in a "Cannot modify header information" notice. OC_Files::get($originalSharePath, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD'); exit(); } else { 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), diff --git a/apps/files_trashbin/lib/helper.php b/apps/files_trashbin/lib/helper.php index c2b81e3dbc8..c99662480df 100644 --- a/apps/files_trashbin/lib/helper.php +++ b/apps/files_trashbin/lib/helper.php @@ -88,7 +88,7 @@ class Helper $entry = \OCA\Files\Helper::formatFileInfo($i); $entry['id'] = $id++; $entry['etag'] = $entry['mtime']; // add fake etag, it is only needed to identify the preview image - $entry['permissions'] = \OCP\PERMISSION_READ; + $entry['permissions'] = \OCP\Constants::PERMISSION_READ; if (\OCP\App::isEnabled('files_encryption')) { $entry['isPreviewAvailable'] = false; } diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php index 436863b28dc..6205a6881f0 100644 --- a/apps/files_versions/tests/versions.php +++ b/apps/files_versions/tests/versions.php @@ -277,7 +277,7 @@ class Test_Files_Versioning extends \Test\TestCase { $this->rootView->file_put_contents($v1, 'version1'); $this->rootView->file_put_contents($v2, 'version2'); - \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, OCP\PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL); self::loginHelper(self::TEST_VERSIONS_USER2); @@ -320,7 +320,7 @@ class Test_Files_Versioning extends \Test\TestCase { $this->rootView->file_put_contents($v1, 'version1'); $this->rootView->file_put_contents($v2, 'version2'); - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL); self::loginHelper(self::TEST_VERSIONS_USER2); diff --git a/apps/user_ldap/l10n/cs_CZ.js b/apps/user_ldap/l10n/cs_CZ.js index 2b8142bced6..f4782d57d66 100644 --- a/apps/user_ldap/l10n/cs_CZ.js +++ b/apps/user_ldap/l10n/cs_CZ.js @@ -33,6 +33,7 @@ OC.L10N.register( "Confirm Deletion" : "Potvrdit smazánÃ", "_%s group found_::_%s groups found_" : ["nalezena %s skupina","nalezeny %s skupiny","nalezeno %s skupin"], "_%s user found_::_%s users found_" : ["nalezen %s uživatel","nalezeni %s uživatelé","nalezeno %s uživatelů"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Nelze detekovat atribut pro zobrazenà jména uživatele. UpÅ™esnÄ›te ho prosÃm sami v rozÅ¡ÃÅ™eném nastavenà LDAP.", "Could not find the desired feature" : "Nelze nalézt požadovanou vlastnost", "Invalid Host" : "Neplatný hostitel", "Server" : "Server", diff --git a/apps/user_ldap/l10n/cs_CZ.json b/apps/user_ldap/l10n/cs_CZ.json index 819f4e6d534..e3e51560987 100644 --- a/apps/user_ldap/l10n/cs_CZ.json +++ b/apps/user_ldap/l10n/cs_CZ.json @@ -31,6 +31,7 @@ "Confirm Deletion" : "Potvrdit smazánÃ", "_%s group found_::_%s groups found_" : ["nalezena %s skupina","nalezeny %s skupiny","nalezeno %s skupin"], "_%s user found_::_%s users found_" : ["nalezen %s uživatel","nalezeni %s uživatelé","nalezeno %s uživatelů"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Nelze detekovat atribut pro zobrazenà jména uživatele. UpÅ™esnÄ›te ho prosÃm sami v rozÅ¡ÃÅ™eném nastavenà LDAP.", "Could not find the desired feature" : "Nelze nalézt požadovanou vlastnost", "Invalid Host" : "Neplatný hostitel", "Server" : "Server", diff --git a/apps/user_ldap/l10n/fr.js b/apps/user_ldap/l10n/fr.js index 3736ade73ce..d363530f5c5 100644 --- a/apps/user_ldap/l10n/fr.js +++ b/apps/user_ldap/l10n/fr.js @@ -33,6 +33,7 @@ OC.L10N.register( "Confirm Deletion" : "Confirmer la suppression", "_%s group found_::_%s groups found_" : ["%s groupe trouvé","%s groupes trouvés"], "_%s user found_::_%s users found_" : ["%s utilisateur trouvé","%s utilisateurs trouvés"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Impossible de détecter l'attribut contenant le nom d'affichage des utilisateurs. Veuillez l'indiquer vous-même dans les paramètres ldap avancés.", "Could not find the desired feature" : "Impossible de trouver la fonction souhaitée", "Invalid Host" : "Hôte invalide", "Server" : "Serveur", diff --git a/apps/user_ldap/l10n/fr.json b/apps/user_ldap/l10n/fr.json index 58ac6f3d248..9879534bac7 100644 --- a/apps/user_ldap/l10n/fr.json +++ b/apps/user_ldap/l10n/fr.json @@ -31,6 +31,7 @@ "Confirm Deletion" : "Confirmer la suppression", "_%s group found_::_%s groups found_" : ["%s groupe trouvé","%s groupes trouvés"], "_%s user found_::_%s users found_" : ["%s utilisateur trouvé","%s utilisateurs trouvés"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Impossible de détecter l'attribut contenant le nom d'affichage des utilisateurs. Veuillez l'indiquer vous-même dans les paramètres ldap avancés.", "Could not find the desired feature" : "Impossible de trouver la fonction souhaitée", "Invalid Host" : "Hôte invalide", "Server" : "Serveur", diff --git a/apps/user_ldap/l10n/nl.js b/apps/user_ldap/l10n/nl.js index e448b161f00..ae280e1a05e 100644 --- a/apps/user_ldap/l10n/nl.js +++ b/apps/user_ldap/l10n/nl.js @@ -33,6 +33,7 @@ OC.L10N.register( "Confirm Deletion" : "Bevestig verwijderen", "_%s group found_::_%s groups found_" : ["%s groep gevonden","%s groepen gevonden"], "_%s user found_::_%s users found_" : ["%s gebruiker gevonden","%s gebruikers gevonden"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Kon het weergavenaam attribuut van de gebruiker niet vinden. Geef het zelf op in de geavanceerde ldap instellingen.", "Could not find the desired feature" : "Kon de gewenste functie niet vinden", "Invalid Host" : "Ongeldige server", "Server" : "Server", diff --git a/apps/user_ldap/l10n/nl.json b/apps/user_ldap/l10n/nl.json index eb1eecf8201..ed0ce08501a 100644 --- a/apps/user_ldap/l10n/nl.json +++ b/apps/user_ldap/l10n/nl.json @@ -31,6 +31,7 @@ "Confirm Deletion" : "Bevestig verwijderen", "_%s group found_::_%s groups found_" : ["%s groep gevonden","%s groepen gevonden"], "_%s user found_::_%s users found_" : ["%s gebruiker gevonden","%s gebruikers gevonden"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Kon het weergavenaam attribuut van de gebruiker niet vinden. Geef het zelf op in de geavanceerde ldap instellingen.", "Could not find the desired feature" : "Kon de gewenste functie niet vinden", "Invalid Host" : "Ongeldige server", "Server" : "Server", diff --git a/apps/user_ldap/l10n/pt_BR.js b/apps/user_ldap/l10n/pt_BR.js index 32b7697df3e..a4a481524ba 100644 --- a/apps/user_ldap/l10n/pt_BR.js +++ b/apps/user_ldap/l10n/pt_BR.js @@ -33,6 +33,7 @@ OC.L10N.register( "Confirm Deletion" : "Confirmar Exclusão", "_%s group found_::_%s groups found_" : ["grupo% s encontrado","grupos% s encontrado"], "_%s user found_::_%s users found_" : ["usuário %s encontrado","usuários %s encontrados"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Não foi possÃvel detectar o nome de exibição do atributo do usuário. Por favor, indique-o você mesmo em configurações avançadas do LDAP.", "Could not find the desired feature" : "Não foi possÃvel encontrar a função desejada", "Invalid Host" : "Host Inválido", "Server" : "Servidor", diff --git a/apps/user_ldap/l10n/pt_BR.json b/apps/user_ldap/l10n/pt_BR.json index ea59ed7b4d8..4dd9088b727 100644 --- a/apps/user_ldap/l10n/pt_BR.json +++ b/apps/user_ldap/l10n/pt_BR.json @@ -31,6 +31,7 @@ "Confirm Deletion" : "Confirmar Exclusão", "_%s group found_::_%s groups found_" : ["grupo% s encontrado","grupos% s encontrado"], "_%s user found_::_%s users found_" : ["usuário %s encontrado","usuários %s encontrados"], + "Could not detect user display name attribute. Please specify it yourself in advanced ldap settings." : "Não foi possÃvel detectar o nome de exibição do atributo do usuário. Por favor, indique-o você mesmo em configurações avançadas do LDAP.", "Could not find the desired feature" : "Não foi possÃvel encontrar a função desejada", "Invalid Host" : "Host Inválido", "Server" : "Servidor", diff --git a/config/config.sample.php b/config/config.sample.php index 2287b7af7dd..2a9b43d5690 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -134,6 +134,12 @@ $CONFIG = array( ), /** + * sqlite3 journal mode can be specified using this config parameter - can be 'WAL' or 'DELETE' + * see for more details https://www.sqlite.org/wal.html + */ +'sqlite.journal_mode' => 'DELETE', + +/** * Indicates whether the ownCloud instance was installed successfully; ``true`` * indicates a successful installation, and ``false`` indicates an unsuccessful * installation. @@ -617,7 +623,7 @@ $CONFIG = array( * concerns: * * - OC\Preview\Illustrator - * - OC\Preview\Movies + * - OC\Preview\Movie * - OC\Preview\MSOffice2003 * - OC\Preview\MSOffice2007 * - OC\Preview\MSOfficeDoc diff --git a/core/l10n/fr.js b/core/l10n/fr.js index 87e8b017832..0155b0c90c4 100644 --- a/core/l10n/fr.js +++ b/core/l10n/fr.js @@ -62,7 +62,7 @@ OC.L10N.register( "So-so password" : "Mot de passe tout juste acceptable", "Good password" : "Mot de passe de sécurité suffisante", "Strong password" : "Mot de passe fort", - "Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." : "Votre serveur web n'est pas correctement configuré pour permettre la synchronisation des fichiers, car l'interface WebDav semble ne pas fonctionner.", + "Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." : "Votre serveur web n'est pas correctement configuré pour permettre la synchronisation des fichiers car l'interface WebDav semble ne pas fonctionner.", "This server has no working internet connection. This means that some of the features like mounting of external storage, notifications about updates or installation of 3rd party apps don´t work. Accessing files from remote and sending of notification emails might also not work. We suggest to enable internet connection for this server if you want to have all features." : "Ce serveur ne peut se connecter à internet. Cela signifie que certaines fonctionnalités, telles que le montage de supports de stockage distants, les notifications de mises à jour ou l'installation d'applications tierces ne fonctionneront pas. L'accès aux fichiers à distance, ainsi que les notifications par courriel ne fonctionneront pas non plus. Il est recommandé d'activer la connexion internet pour ce serveur si vous souhaitez disposer de l'ensemble des fonctionnalités offertes.", "Error occurred while checking server setup" : "Une erreur s'est produite lors de la vérification de la configuration du serveur", "Shared" : "Partagé", diff --git a/core/l10n/fr.json b/core/l10n/fr.json index 5b57d86f532..2ddd7d91a39 100644 --- a/core/l10n/fr.json +++ b/core/l10n/fr.json @@ -60,7 +60,7 @@ "So-so password" : "Mot de passe tout juste acceptable", "Good password" : "Mot de passe de sécurité suffisante", "Strong password" : "Mot de passe fort", - "Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." : "Votre serveur web n'est pas correctement configuré pour permettre la synchronisation des fichiers, car l'interface WebDav semble ne pas fonctionner.", + "Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." : "Votre serveur web n'est pas correctement configuré pour permettre la synchronisation des fichiers car l'interface WebDav semble ne pas fonctionner.", "This server has no working internet connection. This means that some of the features like mounting of external storage, notifications about updates or installation of 3rd party apps don´t work. Accessing files from remote and sending of notification emails might also not work. We suggest to enable internet connection for this server if you want to have all features." : "Ce serveur ne peut se connecter à internet. Cela signifie que certaines fonctionnalités, telles que le montage de supports de stockage distants, les notifications de mises à jour ou l'installation d'applications tierces ne fonctionneront pas. L'accès aux fichiers à distance, ainsi que les notifications par courriel ne fonctionneront pas non plus. Il est recommandé d'activer la connexion internet pour ce serveur si vous souhaitez disposer de l'ensemble des fonctionnalités offertes.", "Error occurred while checking server setup" : "Une erreur s'est produite lors de la vérification de la configuration du serveur", "Shared" : "Partagé", diff --git a/lib/private/api.php b/lib/private/api.php index f5576af2ad8..66b763fdc3e 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -132,7 +132,7 @@ class OC_API { * @return array|\OC_OCS_Result */ public static function mergeResponses($responses) { - // Sort into shipped and thirdparty + // Sort into shipped and third-party $shipped = array( 'succeeded' => array(), 'failed' => array(), @@ -162,7 +162,7 @@ class OC_API { if(!empty($shipped['failed'])) { // Which shipped response do we use if they all failed? // They may have failed for different reasons (different status codes) - // Which reponse code should we return? + // Which response code should we return? // Maybe any that are not OC_API::RESPOND_SERVER_ERROR // Merge failed responses if more than one $data = array(); @@ -273,26 +273,32 @@ class OC_API { // reuse existing login $loggedIn = OC_User::isLoggedIn(); - $ocsApiRequest = isset($_SERVER['HTTP_OCS_APIREQUEST']) ? $_SERVER['HTTP_OCS_APIREQUEST'] === 'true' : false; - if ($loggedIn === true && $ocsApiRequest) { + if ($loggedIn === true) { + $ocsApiRequest = isset($_SERVER['HTTP_OCS_APIREQUEST']) ? $_SERVER['HTTP_OCS_APIREQUEST'] === 'true' : false; + if ($ocsApiRequest) { - // initialize the user's filesystem - \OC_Util::setUpFS(\OC_User::getUser()); + // initialize the user's filesystem + \OC_Util::setUpFS(\OC_User::getUser()); - return OC_User::getUser(); + return OC_User::getUser(); + } + return false; } - // basic auth - $authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; - $authPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; - $return = OC_User::login($authUser, $authPw); - if ($return === true) { - self::$logoutRequired = true; + // basic auth - because OC_User::login will create a new session we shall only try to login + // if user and pass are set + if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) ) { + $authUser = $_SERVER['PHP_AUTH_USER']; + $authPw = $_SERVER['PHP_AUTH_PW']; + $return = OC_User::login($authUser, $authPw); + if ($return === true) { + self::$logoutRequired = true; - // initialize the user's filesystem - \OC_Util::setUpFS(\OC_User::getUser()); + // initialize the user's filesystem + \OC_Util::setUpFS(\OC_User::getUser()); - return $authUser; + return $authUser; + } } return false; diff --git a/lib/private/app.php b/lib/private/app.php index bc9ca0351ea..8e36d43bfb1 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -635,63 +635,10 @@ class OC_App { } $file = self::getAppPath($appId) . '/appinfo/info.xml'; } - $data = array(); - if (!file_exists($file)) { - return null; - } - $content = @file_get_contents($file); - if (!$content) { - return null; - } - $xml = new SimpleXMLElement($content); - $data['info'] = array(); - $data['remote'] = array(); - $data['public'] = array(); - foreach ($xml->children() as $child) { - /** - * @var $child SimpleXMLElement - */ - if ($child->getName() == 'remote') { - foreach ($child->children() as $remote) { - /** - * @var $remote SimpleXMLElement - */ - $data['remote'][$remote->getName()] = (string)$remote; - } - } elseif ($child->getName() == 'public') { - foreach ($child->children() as $public) { - /** - * @var $public SimpleXMLElement - */ - $data['public'][$public->getName()] = (string)$public; - } - } elseif ($child->getName() == 'types') { - $data['types'] = array(); - foreach ($child->children() as $type) { - /** - * @var $type SimpleXMLElement - */ - $data['types'][] = $type->getName(); - } - } elseif ($child->getName() == 'description') { - $xml = (string)$child->asXML(); - $data[$child->getName()] = substr($xml, 13, -14); //script <description> tags - } elseif ($child->getName() == 'documentation') { - foreach ($child as $subChild) { - $url = (string) $subChild; - - // If it is not an absolute URL we assume it is a key - // i.e. admin-ldap will get converted to go.php?to=admin-ldap - if(!\OC::$server->getHTTPHelper()->isHTTPURL($url)) { - $url = OC_Helper::linkToDocs($url); - } - $data["documentation"][$subChild->getName()] = $url; - } - } else { - $data[$child->getName()] = (string)$child; - } - } + $parser = new \OC\App\InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator()); + $data = $parser->parse($file); + self::$appInfo[$appId] = $data; return $data; diff --git a/lib/private/app/infoparser.php b/lib/private/app/infoparser.php new file mode 100644 index 00000000000..b4bdbea5c04 --- /dev/null +++ b/lib/private/app/infoparser.php @@ -0,0 +1,84 @@ +<?php + /** + * @author Thomas Müller + * @copyright 2014 Thomas Müller deepdiver@owncloud.com + * + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\App; + +use OCP\IURLGenerator; + +class InfoParser { + /** + * @var \OC\HTTPHelper + */ + private $httpHelper; + + /** + * @var IURLGenerator + */ + private $urlGenerator; + + /** + * @param \OC\HTTPHelper $httpHelper + * @param IURLGenerator $urlGenerator + */ + public function __construct(\OC\HTTPHelper $httpHelper, IURLGenerator $urlGenerator) { + $this->httpHelper = $httpHelper; + $this->urlGenerator = $urlGenerator; + } + + /** + * @param string $file the xml file to be loaded + * @return null|array where null is an indicator for an error + */ + public function parse($file) { + if (!file_exists($file)) { + return null; + } + + $loadEntities = libxml_disable_entity_loader(false); + $xml = @simplexml_load_file($file); + libxml_disable_entity_loader($loadEntities); + if ($xml == false) { + return null; + } + $array = json_decode(json_encode((array)$xml), TRUE); + if (is_null($array)) { + return null; + } + if (!array_key_exists('info', $array)) { + $array['info'] = array(); + } + if (!array_key_exists('remote', $array)) { + $array['remote'] = array(); + } + if (!array_key_exists('public', $array)) { + $array['public'] = array(); + } + + if (array_key_exists('documentation', $array)) { + foreach ($array['documentation'] as $key => $url) { + // If it is not an absolute URL we assume it is a key + // i.e. admin-ldap will get converted to go.php?to=admin-ldap + if (!$this->httpHelper->isHTTPURL($url)) { + $url = $this->urlGenerator->linkToDocs($url); + } + + $array['documentation'][$key] = $url; + } + } + if (array_key_exists('types', $array)) { + foreach ($array['types'] as $type => $v) { + unset($array['types'][$type]); + $array['types'][] = $type; + } + } + + return $array; + } +} diff --git a/lib/private/contacts/localaddressbook.php b/lib/private/contacts/localaddressbook.php index 483bbee83f8..91ddb5798f2 100644 --- a/lib/private/contacts/localaddressbook.php +++ b/lib/private/contacts/localaddressbook.php @@ -91,7 +91,7 @@ class LocalAddressBook implements \OCP\IAddressBook { * @return int */ public function getPermissions() { - return \OCP\PERMISSION_READ; + return \OCP\Constants::PERMISSION_READ; } /** diff --git a/lib/private/contactsmanager.php b/lib/private/contactsmanager.php index 338cc048651..737fc4f0e3a 100644 --- a/lib/private/contactsmanager.php +++ b/lib/private/contactsmanager.php @@ -62,7 +62,7 @@ namespace OC { return null; } - if ($addressBook->getPermissions() & \OCP\PERMISSION_DELETE) { + if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { return null; } @@ -83,7 +83,7 @@ namespace OC { return null; } - if ($addressBook->getPermissions() & \OCP\PERMISSION_CREATE) { + if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { return null; } diff --git a/lib/private/db/connectionfactory.php b/lib/private/db/connectionfactory.php index f6253e09b95..58043b30440 100644 --- a/lib/private/db/connectionfactory.php +++ b/lib/private/db/connectionfactory.php @@ -90,7 +90,8 @@ class ConnectionFactory { $eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\OracleSessionInit); break; case 'sqlite3': - $eventManager->addEventSubscriber(new SQLiteSessionInit); + $journalMode = $additionalConnectionParams['sqlite.journal_mode']; + $eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode)); break; } $connection = \Doctrine\DBAL\DriverManager::getConnection( @@ -153,6 +154,7 @@ class ConnectionFactory { } $connectionParams['tablePrefix'] = $config->getSystemValue('dbtableprefix', 'oc_'); + $connectionParams['sqlite.journal_mode'] = $config->getSystemValue('sqlite.journal_mode', 'WAL'); //additional driver options, eg. for mysql ssl $driverOptions = $config->getSystemValue('dbdriveroptions', null); diff --git a/lib/private/db/sqlitesessioninit.php b/lib/private/db/sqlitesessioninit.php index 7e1166be95b..1fff22b883a 100644 --- a/lib/private/db/sqlitesessioninit.php +++ b/lib/private/db/sqlitesessioninit.php @@ -19,12 +19,19 @@ class SQLiteSessionInit implements EventSubscriber { private $caseSensitiveLike; /** + * @var string + */ + private $journalMode; + + /** * Configure case sensitive like for each connection * * @param bool $caseSensitiveLike + * @param string $journalMode */ - public function __construct($caseSensitiveLike = true) { + public function __construct($caseSensitiveLike, $journalMode) { $this->caseSensitiveLike = $caseSensitiveLike; + $this->journalMode = $journalMode; } /** @@ -34,6 +41,7 @@ class SQLiteSessionInit implements EventSubscriber { public function postConnect(ConnectionEventArgs $args) { $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); + $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); } public function getSubscribedEvents() { diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php index d6d6a245e44..8bab51f0737 100644 --- a/lib/private/files/fileinfo.php +++ b/lib/private/files/fileinfo.php @@ -173,14 +173,14 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @return bool */ public function isReadable() { - return $this->checkPermissions(\OCP\PERMISSION_READ); + return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); } /** * @return bool */ public function isUpdateable() { - return $this->checkPermissions(\OCP\PERMISSION_UPDATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); } /** @@ -189,21 +189,21 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @return bool */ public function isCreatable() { - return $this->checkPermissions(\OCP\PERMISSION_CREATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); } /** * @return bool */ public function isDeletable() { - return $this->checkPermissions(\OCP\PERMISSION_DELETE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); } /** * @return bool */ public function isShareable() { - return $this->checkPermissions(\OCP\PERMISSION_SHARE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); } /** diff --git a/lib/private/files/node/file.php b/lib/private/files/node/file.php index 75d5e0166b6..81e251c20b8 100644 --- a/lib/private/files/node/file.php +++ b/lib/private/files/node/file.php @@ -16,7 +16,7 @@ class File extends Node implements \OCP\Files\File { * @throws \OCP\Files\NotPermittedException */ public function getContent() { - if ($this->checkPermissions(\OCP\PERMISSION_READ)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { /** * @var \OC\Files\Storage\Storage $storage; */ @@ -31,7 +31,7 @@ class File extends Node implements \OCP\Files\File { * @throws \OCP\Files\NotPermittedException */ public function putContent($data) { - if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { $this->sendHooks(array('preWrite')); $this->view->file_put_contents($this->path, $data); $this->sendHooks(array('postWrite')); @@ -55,7 +55,7 @@ class File extends Node implements \OCP\Files\File { public function fopen($mode) { $preHooks = array(); $postHooks = array(); - $requiredPermissions = \OCP\PERMISSION_READ; + $requiredPermissions = \OCP\Constants::PERMISSION_READ; switch ($mode) { case 'r+': case 'rb+': @@ -73,7 +73,7 @@ class File extends Node implements \OCP\Files\File { case 'ab': $preHooks[] = 'preWrite'; $postHooks[] = 'postWrite'; - $requiredPermissions |= \OCP\PERMISSION_UPDATE; + $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; break; } @@ -88,7 +88,7 @@ class File extends Node implements \OCP\Files\File { } public function delete() { - if ($this->checkPermissions(\OCP\PERMISSION_DELETE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { $this->sendHooks(array('preDelete')); $this->view->unlink($this->path); $nonExisting = new NonExistingFile($this->root, $this->view, $this->path); diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index 8c7acc339ae..83e20871528 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -180,7 +180,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @throws \OCP\Files\NotPermittedException */ public function newFolder($path) { - if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); @@ -201,7 +201,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @throws \OCP\Files\NotPermittedException */ public function newFile($path) { - if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFile($this->root, $this->view, $fullPath); $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); @@ -325,11 +325,11 @@ class Folder extends Node implements \OCP\Files\Folder { * @return bool */ public function isCreatable() { - return $this->checkPermissions(\OCP\PERMISSION_CREATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); } public function delete() { - if ($this->checkPermissions(\OCP\PERMISSION_DELETE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { $this->sendHooks(array('preDelete')); $this->view->rmdir($this->path); $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path); diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php index bc075911749..c52f5bbd54f 100644 --- a/lib/private/files/node/node.php +++ b/lib/private/files/node/node.php @@ -81,7 +81,7 @@ class Node implements \OCP\Files\Node { * @throws \OCP\Files\NotPermittedException */ public function touch($mtime = null) { - if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { $this->sendHooks(array('preTouch')); $this->view->touch($this->path, $mtime); $this->sendHooks(array('postTouch')); @@ -163,28 +163,28 @@ class Node implements \OCP\Files\Node { * @return bool */ public function isReadable() { - return $this->checkPermissions(\OCP\PERMISSION_READ); + return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); } /** * @return bool */ public function isUpdateable() { - return $this->checkPermissions(\OCP\PERMISSION_UPDATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); } /** * @return bool */ public function isDeletable() { - return $this->checkPermissions(\OCP\PERMISSION_DELETE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); } /** * @return bool */ public function isShareable() { - return $this->checkPermissions(\OCP\PERMISSION_SHARE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); } /** diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index 18e7a6b681a..1e8387dc5cb 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -262,7 +262,7 @@ class Root extends Folder implements Emitter { * @return int */ public function getPermissions() { - return \OCP\PERMISSION_CREATE; + return \OCP\Constants::PERMISSION_CREATE; } /** diff --git a/lib/private/files/objectstore/objectstorestorage.php b/lib/private/files/objectstore/objectstorestorage.php index ae8bff52896..b0095ad94bb 100644 --- a/lib/private/files/objectstore/objectstorestorage.php +++ b/lib/private/files/objectstore/objectstorestorage.php @@ -72,7 +72,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { 'size' => 0, 'mtime' => $mTime, 'storage_mtime' => $mTime, - 'permissions' => \OCP\PERMISSION_ALL, + 'permissions' => \OCP\Constants::PERMISSION_ALL, ); if ($dirName === '' && !$parentExists) { @@ -332,7 +332,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { 'size' => 0, 'mtime' => $mtime, 'storage_mtime' => $mtime, - 'permissions' => \OCP\PERMISSION_ALL, + 'permissions' => \OCP\Constants::PERMISSION_ALL, ); $fileId = $this->getCache()->put($path, $stat); try { @@ -357,7 +357,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { if (empty($stat)) { // create new file $stat = array( - 'permissions' => \OCP\PERMISSION_ALL, + 'permissions' => \OCP\Constants::PERMISSION_ALL, ); } // update stat with new data diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 518d3ec400c..d76c6aa031b 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -113,19 +113,19 @@ abstract class Common implements \OC\Files\Storage\Storage { public function getPermissions($path) { $permissions = 0; if ($this->isCreatable($path)) { - $permissions |= \OCP\PERMISSION_CREATE; + $permissions |= \OCP\Constants::PERMISSION_CREATE; } if ($this->isReadable($path)) { - $permissions |= \OCP\PERMISSION_READ; + $permissions |= \OCP\Constants::PERMISSION_READ; } if ($this->isUpdatable($path)) { - $permissions |= \OCP\PERMISSION_UPDATE; + $permissions |= \OCP\Constants::PERMISSION_UPDATE; } if ($this->isDeletable($path)) { - $permissions |= \OCP\PERMISSION_DELETE; + $permissions |= \OCP\Constants::PERMISSION_DELETE; } if ($this->isSharable($path)) { - $permissions |= \OCP\PERMISSION_SHARE; + $permissions |= \OCP\Constants::PERMISSION_SHARE; } return $permissions; } diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php index 26fa69408a8..a2832bce009 100644 --- a/lib/private/files/storage/dav.php +++ b/lib/private/files/storage/dav.php @@ -416,19 +416,19 @@ class DAV extends \OC\Files\Storage\Common { } public function isUpdatable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_UPDATE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE); } public function isCreatable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_CREATE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE); } public function isSharable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_SHARE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); } public function isDeletable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_DELETE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE); } public function getPermissions($path) { @@ -438,9 +438,9 @@ class DAV extends \OC\Files\Storage\Common { if (isset($response['{http://owncloud.org/ns}permissions'])) { return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); } else if ($this->is_dir($path)) { - return \OCP\PERMISSION_ALL; + return \OCP\Constants::PERMISSION_ALL; } else if ($this->file_exists($path)) { - return \OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE; + return \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE; } else { return 0; } @@ -451,19 +451,19 @@ class DAV extends \OC\Files\Storage\Common { * @return int */ protected function parsePermissions($permissionsString) { - $permissions = \OCP\PERMISSION_READ; + $permissions = \OCP\Constants::PERMISSION_READ; if (strpos($permissionsString, 'R') !== false) { - $permissions |= \OCP\PERMISSION_SHARE; + $permissions |= \OCP\Constants::PERMISSION_SHARE; } if (strpos($permissionsString, 'D') !== false) { - $permissions |= \OCP\PERMISSION_DELETE; + $permissions |= \OCP\Constants::PERMISSION_DELETE; } if (strpos($permissionsString, 'W') !== false) { - $permissions |= \OCP\PERMISSION_UPDATE; + $permissions |= \OCP\Constants::PERMISSION_UPDATE; } if (strpos($permissionsString, 'CK') !== false) { - $permissions |= \OCP\PERMISSION_CREATE; - $permissions |= \OCP\PERMISSION_UPDATE; + $permissions |= \OCP\Constants::PERMISSION_CREATE; + $permissions |= \OCP\Constants::PERMISSION_UPDATE; } return $permissions; } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 19676524a0e..331ab9ba6cd 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -933,7 +933,7 @@ class View { } if ($mount instanceof MoveableMount && $internalPath === '') { - $data['permissions'] |= \OCP\PERMISSION_DELETE | \OCP\PERMISSION_UPDATE; + $data['permissions'] |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; } $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data); @@ -988,7 +988,7 @@ class View { } // if sharing was disabled for the user we remove the share permissions if (\OCP\Util::isSharingDisabledForUser()) { - $content['permissions'] = $content['permissions'] & ~\OCP\PERMISSION_SHARE; + $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content); } @@ -1025,9 +1025,9 @@ class View { // do not allow renaming/deleting the mount point if they are not shared files/folders // for shared files/folders we use the permissions given by the owner if ($mount instanceof MoveableMount) { - $rootEntry['permissions'] = $permissions | \OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE; + $rootEntry['permissions'] = $permissions | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE; } else { - $rootEntry['permissions'] = $permissions & (\OCP\PERMISSION_ALL - (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE)); + $rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE)); } //remove any existing entry with the same name @@ -1041,7 +1041,7 @@ class View { // if sharing was disabled for the user we remove the share permissions if (\OCP\Util::isSharingDisabledForUser()) { - $content['permissions'] = $content['permissions'] & ~\OCP\PERMISSION_SHARE; + $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry); diff --git a/lib/private/helper.php b/lib/private/helper.php index be448b8ff9b..d43eefcdc52 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -58,12 +58,11 @@ class OC_Helper { } /** - * @param $key + * @param string $key * @return string url to the online documentation */ public static function linkToDocs($key) { - $theme = new OC_Defaults(); - return $theme->buildDocLinkToKey($key); + return OC::$server->getURLGenerator()->linkToDocs($key); } /** diff --git a/lib/private/installer.php b/lib/private/installer.php index cd1d8ce392f..f43969691c7 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -558,8 +558,8 @@ class OC_Installer{ // is the code checker enabled? if(OC_Config::getValue('appcodechecker', true)) { // check if grep is installed - $grep = exec('command -v grep'); - if($grep=='') { + $grep = \OC_Helper::findBinaryPath('grep'); + if (!$grep) { OC_Log::write('core', 'grep not installed. So checking the code of the app "'.$appname.'" was not possible', OC_Log::ERROR); diff --git a/lib/private/preview.php b/lib/private/preview.php index 778007b21fd..c9d8810be6f 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -17,7 +17,7 @@ use OC\Preview\Provider; use OCP\Files\NotFoundException; require_once 'preview/image.php'; -require_once 'preview/movies.php'; +require_once 'preview/movie.php'; require_once 'preview/mp3.php'; require_once 'preview/svg.php'; require_once 'preview/txt.php'; @@ -713,7 +713,7 @@ class Preview { * - OC\Preview\OpenDocument * - OC\Preview\StarOffice * - OC\Preview\SVG - * - OC\Preview\Movies + * - OC\Preview\Movie * - OC\Preview\PDF * - OC\Preview\TIFF * - OC\Preview\Illustrator diff --git a/lib/private/preview/movies.php b/lib/private/preview/movie.php index d69266ceb33..d69266ceb33 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movie.php diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 2418535c9d5..6bbb101db3a 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -189,20 +189,23 @@ class Helper extends \OC\Share\Constants { public static function calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate = null) { $expires = false; + $defaultExpires = null; if (!empty($defaultExpireSettings['defaultExpireDateSet'])) { - $expires = $creationTime + $defaultExpireSettings['expireAfterDays'] * 86400; + $defaultExpires = $creationTime + $defaultExpireSettings['expireAfterDays'] * 86400; } if (isset($userExpireDate)) { // if the admin decided to enforce the default expire date then we only take // the user defined expire date of it is before the default expire date - if ($expires && !empty($defaultExpireSettings['enforceExpireDate'])) { - $expires = min($userExpireDate, $expires); + if ($defaultExpires && !empty($defaultExpireSettings['enforceExpireDate'])) { + $expires = min($userExpireDate, $defaultExpires); } else { $expires = $userExpireDate; } + } else if ($defaultExpires && !empty($defaultExpireSettings['enforceExpireDate'])) { + $expires = $defaultExpires; } return $expires; diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 10fff9aeacf..c6fd1604ac7 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -547,7 +547,7 @@ class Share extends \OC\Share\Constants { // single file shares should never have delete permissions if ($itemType === 'file') { - $permissions = (int)$permissions & ~\OCP\PERMISSION_DELETE; + $permissions = (int)$permissions & ~\OCP\Constants::PERMISSION_DELETE; } // Verify share type and sharing conditions are met @@ -929,7 +929,7 @@ class Share extends \OC\Share\Constants { // Check if permissions were removed if ($item['permissions'] & ~$permissions) { // If share permission is removed all reshares must be deleted - if (($item['permissions'] & \OCP\PERMISSION_SHARE) && (~$permissions & \OCP\PERMISSION_SHARE)) { + if (($item['permissions'] & \OCP\Constants::PERMISSION_SHARE) && (~$permissions & \OCP\Constants::PERMISSION_SHARE)) { Helper::delete($item['id'], true); } else { $ids = array(); @@ -1458,8 +1458,8 @@ class Share extends \OC\Share\Constants { } // Switch ids if sharing permission is granted on only // one share to ensure correct parent is used if resharing - if (~(int)$items[$id]['permissions'] & \OCP\PERMISSION_SHARE - && (int)$row['permissions'] & \OCP\PERMISSION_SHARE) { + if (~(int)$items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE + && (int)$row['permissions'] & \OCP\Constants::PERMISSION_SHARE) { $items[$row['id']] = $items[$id]; $switchedItems[$id] = $row['id']; unset($items[$id]); @@ -1516,7 +1516,7 @@ class Share extends \OC\Share\Constants { } // Check if resharing is allowed, if not remove share permission if (isset($row['permissions']) && (!self::isResharingAllowed() | \OC_Util::isSharingDisabledForUser())) { - $row['permissions'] &= ~\OCP\PERMISSION_SHARE; + $row['permissions'] &= ~\OCP\Constants::PERMISSION_SHARE; } // Add display names to result if ( isset($row['share_with']) && $row['share_with'] != '' && @@ -1911,7 +1911,7 @@ class Share extends \OC\Share\Constants { } // Check if share permissions is granted - if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\PERMISSION_SHARE) { + if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) { if (~(int)$checkReshare['permissions'] & $permissions) { $message = 'Sharing %s failed, because the permissions exceed permissions granted to %s'; $message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner)); diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index e50e9eed6af..d263d25aeef 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -8,6 +8,7 @@ */ namespace OC; +use OC_Defaults; use OCP\IURLGenerator; use RuntimeException; @@ -156,7 +157,7 @@ class URLGenerator implements IURLGenerator { /** * Makes an URL absolute - * @param string $url the url in the owncloud host + * @param string $url the url in the ownCloud host * @return string the absolute version of the url */ public function getAbsoluteURL($url) { @@ -173,4 +174,13 @@ class URLGenerator implements IURLGenerator { return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost(). $webRoot . $separator . $url; } + + /** + * @param string $key + * @return string url to the online documentation + */ + public function linkToDocs($key) { + $theme = new OC_Defaults(); + return $theme->buildDocLinkToKey($key); + } } diff --git a/lib/private/util.php b/lib/private/util.php index 4190f0aa3d8..a18a4e44232 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1336,7 +1336,7 @@ class OC_Util { return false; } foreach (str_split($trimmed) as $char) { - if (strpos(\OCP\FILENAME_INVALID_CHARS, $char) !== false) { + if (strpos(\OCP\Constants::FILENAME_INVALID_CHARS, $char) !== false) { return false; } } diff --git a/lib/public/constants.php b/lib/public/constants.php index 350646a0ac0..78cafd11847 100644 --- a/lib/public/constants.php +++ b/lib/public/constants.php @@ -26,15 +26,37 @@ namespace OCP; -/** - * CRUDS permissions. - */ +/** @deprecated Use \OCP\Constants::PERMISSION_CREATE instead */ const PERMISSION_CREATE = 4; + +/** @deprecated Use \OCP\Constants::PERMISSION_READ instead */ const PERMISSION_READ = 1; + +/** @deprecated Use \OCP\Constants::PERMISSION_UPDATE instead */ const PERMISSION_UPDATE = 2; + +/** @deprecated Use \OCP\Constants::PERMISSION_DELETE instead */ const PERMISSION_DELETE = 8; + +/** @deprecated Use \OCP\Constants::PERMISSION_SHARE instead */ const PERMISSION_SHARE = 16; + +/** @deprecated Use \OCP\Constants::PERMISSION_ALL instead */ const PERMISSION_ALL = 31; +/** @deprecated Use \OCP\Constants::FILENAME_INVALID_CHARS instead */ const FILENAME_INVALID_CHARS = "\\/<>:\"|?*\n"; +class Constants { + /** + * CRUDS permissions. + */ + const PERMISSION_CREATE = 4; + const PERMISSION_READ = 1; + const PERMISSION_UPDATE = 2; + const PERMISSION_DELETE = 8; + const PERMISSION_SHARE = 16; + const PERMISSION_ALL = 31; + + const FILENAME_INVALID_CHARS = "\\/<>:\"|?*\n"; +} diff --git a/lib/public/files/fileinfo.php b/lib/public/files/fileinfo.php index ec81a541564..3a407ed67ca 100644 --- a/lib/public/files/fileinfo.php +++ b/lib/public/files/fileinfo.php @@ -103,12 +103,12 @@ interface FileInfo { /** * Get the permissions of the file or folder as bitmasked combination of the following constants - * \OCP\PERMISSION_CREATE - * \OCP\PERMISSION_READ - * \OCP\PERMISSION_UPDATE - * \OCP\PERMISSION_DELETE - * \OCP\PERMISSION_SHARE - * \OCP\PERMISSION_ALL + * \OCP\Constants::PERMISSION_CREATE + * \OCP\Constants::PERMISSION_READ + * \OCP\Constants::PERMISSION_UPDATE + * \OCP\Constants::PERMISSION_DELETE + * \OCP\Constants::PERMISSION_SHARE + * \OCP\Constants::PERMISSION_ALL * * @return int */ diff --git a/lib/public/files/node.php b/lib/public/files/node.php index a380394095b..35c20b487c9 100644 --- a/lib/public/files/node.php +++ b/lib/public/files/node.php @@ -128,11 +128,11 @@ interface Node { /** * Get the permissions of the file or folder as a combination of one or more of the following constants: - * - \OCP\PERMISSION_READ - * - \OCP\PERMISSION_UPDATE - * - \OCP\PERMISSION_CREATE - * - \OCP\PERMISSION_DELETE - * - \OCP\PERMISSION_SHARE + * - \OCP\Constants::PERMISSION_READ + * - \OCP\Constants::PERMISSION_UPDATE + * - \OCP\Constants::PERMISSION_CREATE + * - \OCP\Constants::PERMISSION_DELETE + * - \OCP\Constants::PERMISSION_SHARE * * @return int */ diff --git a/lib/public/iavatar.php b/lib/public/iavatar.php index 1e80682c4f7..213d2e6cef5 100644 --- a/lib/public/iavatar.php +++ b/lib/public/iavatar.php @@ -23,9 +23,9 @@ interface IAvatar { /** * sets the users avatar * @param Image $data mixed imagedata or path to set a new avatar - * @throws Exception if the provided file is not a jpg or png image - * @throws Exception if the provided image is not valid - * @throws \OCP\NotSquareException if the image is not square + * @throws \Exception if the provided file is not a jpg or png image + * @throws \Exception if the provided image is not valid + * @throws \OC\NotSquareException if the image is not square * @return void */ function set($data); diff --git a/lib/public/iurlgenerator.php b/lib/public/iurlgenerator.php index dbbd8a3bb63..fa817c10ea5 100644 --- a/lib/public/iurlgenerator.php +++ b/lib/public/iurlgenerator.php @@ -69,8 +69,14 @@ interface IURLGenerator { /** * Makes an URL absolute - * @param string $url the url in the owncloud host + * @param string $url the url in the ownCloud host * @return string the absolute version of the url */ public function getAbsoluteURL($url); + + /** + * @param string $key + * @return string url to the online documentation + */ + public function linkToDocs($key); } diff --git a/lib/public/template.php b/lib/public/template.php index 2e265bb5e8e..a1b650649ff 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -88,7 +88,7 @@ function human_file_size( $bytes ) { * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" * @param int $timestamp unix timestamp * @param boolean $dateOnly - * @return OC_L10N_String human readable interpretation of the timestamp + * @return \OC_L10N_String human readable interpretation of the timestamp */ function relative_modified_date( $timestamp, $dateOnly = false ) { return(\relative_modified_date($timestamp, null, $dateOnly)); diff --git a/lib/public/util.php b/lib/public/util.php index a87d26a4004..793a16c4d84 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -508,8 +508,8 @@ class Util { /** * Compare two strings to provide a natural sort - * @param $a first string to compare - * @param $b second string to compare + * @param string $a first string to compare + * @param string $b second string to compare * @return -1 if $b comes before $a, 1 if $a comes before $b * or 0 if the strings are identical */ diff --git a/settings/l10n/tr.js b/settings/l10n/tr.js index 0b6660fd076..e97674bf0fc 100644 --- a/settings/l10n/tr.js +++ b/settings/l10n/tr.js @@ -138,7 +138,7 @@ OC.L10N.register( "days" : "gün sonra dolsun", "Enforce expiration date" : "Son kullanma tarihini zorla", "Allow resharing" : "Yeniden paylaşıma izin ver", - "Restrict users to only share with users in their groups" : "Kullanıcıların sadece kendi gruplarındaki kullanıcılarla paylaÅŸmasına sınırla", + "Restrict users to only share with users in their groups" : "Kullanıcıların, dosyaları sadece kendi gruplarındaki kullanıcılarla paylaÅŸmasına izin ver", "Allow users to send mail notification for shared files" : "Paylaşılmış dosyalar için kullanıcıların posta bildirimi göndermesine izin ver", "Exclude groups from sharing" : "Grupları paylaÅŸma eyleminden hariç tut", "These groups will still be able to receive shares, but not to initiate them." : "Bu gruplar hala paylaşımları alabilecek, ancak baÅŸlatamayacaktır.", diff --git a/settings/l10n/tr.json b/settings/l10n/tr.json index 26f39922609..f1c869101a9 100644 --- a/settings/l10n/tr.json +++ b/settings/l10n/tr.json @@ -136,7 +136,7 @@ "days" : "gün sonra dolsun", "Enforce expiration date" : "Son kullanma tarihini zorla", "Allow resharing" : "Yeniden paylaşıma izin ver", - "Restrict users to only share with users in their groups" : "Kullanıcıların sadece kendi gruplarındaki kullanıcılarla paylaÅŸmasına sınırla", + "Restrict users to only share with users in their groups" : "Kullanıcıların, dosyaları sadece kendi gruplarındaki kullanıcılarla paylaÅŸmasına izin ver", "Allow users to send mail notification for shared files" : "Paylaşılmış dosyalar için kullanıcıların posta bildirimi göndermesine izin ver", "Exclude groups from sharing" : "Grupları paylaÅŸma eyleminden hariç tut", "These groups will still be able to receive shares, but not to initiate them." : "Bu gruplar hala paylaşımları alabilecek, ancak baÅŸlatamayacaktır.", diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json new file mode 100644 index 00000000000..c67d6d657d2 --- /dev/null +++ b/tests/data/app/expected-info.json @@ -0,0 +1,19 @@ +{ + "info": [], + "remote": [], + "public": [], + "id": "files_encryption", + "name": "Server-side Encryption", + "description": "\n\tThis application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost. \n\tNote that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation \n\t", + "licence": "AGPL", + "author": "Sam Tuke, Bjoern Schiessle, Florin Peter", + "requiremin": "4", + "shipped": "true", + "documentation": { + "user": "https://docs.example.com/server/go.php?to=user-encryption", + "admin": "https://docs.example.com/server/go.php?to=admin-encryption" + }, + "rememberlogin": "false", + "types": ["filesystem"], + "ocsid": "166047" +} diff --git a/tests/data/app/invalid-info.xml b/tests/data/app/invalid-info.xml new file mode 100644 index 00000000000..3947f5420c2 --- /dev/null +++ b/tests/data/app/invalid-info.xml @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<info + <id>files_encryption</id> + <name>Server-side Encryption</name> + <description> + This application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost. + Note that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation + </description> + <licence>AGPL</licence> + <author>Sam Tuke, Bjoern Schiessle, Florin Peter</author> + <requiremin>4</requiremin> + <shipped>true</shipped> + <documentation> + <user>user-encryption</user> + <admin>admin-encryption</admin> + </documentation> + <rememberlogin>false</rememberlogin> + <types> + <filesystem/> + </types> + <ocsid>166047</ocsid> +</info> diff --git a/tests/data/app/valid-info.xml b/tests/data/app/valid-info.xml new file mode 100644 index 00000000000..6fcef693bed --- /dev/null +++ b/tests/data/app/valid-info.xml @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<info> + <id>files_encryption</id> + <name>Server-side Encryption</name> + <description> + This application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost. + Note that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation + </description> + <licence>AGPL</licence> + <author>Sam Tuke, Bjoern Schiessle, Florin Peter</author> + <requiremin>4</requiremin> + <shipped>true</shipped> + <documentation> + <user>user-encryption</user> + <admin>admin-encryption</admin> + </documentation> + <rememberlogin>false</rememberlogin> + <types> + <filesystem/> + </types> + <ocsid>166047</ocsid> +</info> diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php new file mode 100644 index 00000000000..277e1582e45 --- /dev/null +++ b/tests/lib/app/infoparser.php @@ -0,0 +1,53 @@ +<?php + +/** + * @author Thomas Müller + * @copyright 2014 Thomas Müller deepdiver@owncloud.com + * later. + * See the COPYING-README file. + */ + +namespace Test\App; + +use OC; + +class InfoParser extends \PHPUnit_Framework_TestCase { + + /** + * @var \OC\App\InfoParser + */ + private $parser; + + public function setUp() { + $config = $this->getMockBuilder('\OC\AllConfig') + ->disableOriginalConstructor()->getMock(); + $httpHelper = $this->getMockBuilder('\OC\HTTPHelper') + ->setConstructorArgs(array($config)) + ->setMethods(array('getHeaders')) + ->getMock(); + $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + ->disableOriginalConstructor() + ->getMock(); + + //linkToDocs + $urlGenerator->expects($this->any()) + ->method('linkToDocs') + ->will($this->returnCallback(function ($url) { + return "https://docs.example.com/server/go.php?to=$url"; + })); + + $this->parser = new \OC\App\InfoParser($httpHelper, $urlGenerator); + } + + public function testParsingValidXml() { + $expectedData = json_decode(file_get_contents(OC::$SERVERROOT.'/tests/data/app/expected-info.json'), true); + $data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/valid-info.xml'); + + $this->assertEquals($expectedData, $data); + } + + public function testParsingInvalidXml() { + $data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/invalid-info.xml'); + $this->assertNull($data); + } +} diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php index cfc6e29ae74..b4fdd91f512 100644 --- a/tests/lib/connector/sabre/file.php +++ b/tests/lib/connector/sabre/file.php @@ -23,7 +23,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { ->will($this->returnValue('/test.txt')); $info = new \OC\Files\FileInfo('/test.txt', null, null, array( - 'permissions'=>\OCP\PERMISSION_ALL + 'permissions'=>\OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); @@ -58,7 +58,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { $_SERVER['REQUEST_METHOD'] = 'PUT'; $info = new \OC\Files\FileInfo('/test.txt', null, null, array( - 'permissions' => \OCP\PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); @@ -82,7 +82,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { ->will($this->returnValue('/super*star.txt')); $info = new \OC\Files\FileInfo('/super*star.txt', null, null, array( - 'permissions' => \OCP\PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); @@ -103,7 +103,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { ->will($this->returnValue('/super*star.txt')); $info = new \OC\Files\FileInfo('/super*star.txt', null, null, array( - 'permissions' => \OCP\PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); $file->setName('/super*star.txt'); @@ -135,7 +135,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { $_SERVER['REQUEST_METHOD'] = 'PUT'; $info = new \OC\Files\FileInfo('/test.txt', null, null, array( - 'permissions' => \OCP\PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); @@ -157,7 +157,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { ->will($this->returnValue(true)); $info = new \OC\Files\FileInfo('/test.txt', null, null, array( - 'permissions' => \OCP\PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); @@ -198,7 +198,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase { ->will($this->returnValue(false)); $info = new \OC\Files\FileInfo('/test.txt', null, null, array( - 'permissions' => \OCP\PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL )); $file = new OC_Connector_Sabre_File($view, $info); diff --git a/tests/lib/connector/sabre/node.php b/tests/lib/connector/sabre/node.php index 9a2bf41bd19..1e927deed44 100644 --- a/tests/lib/connector/sabre/node.php +++ b/tests/lib/connector/sabre/node.php @@ -15,15 +15,15 @@ use OC\Files\View; class Node extends \Test\TestCase { public function davPermissionsProvider() { return array( - array(\OCP\PERMISSION_ALL, 'file', false, false, 'RDNVW'), - array(\OCP\PERMISSION_ALL, 'dir', false, false, 'RDNVCK'), - array(\OCP\PERMISSION_ALL, 'file', true, false, 'SRDNVW'), - array(\OCP\PERMISSION_ALL, 'file', true, true, 'SRMDNVW'), - array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_SHARE, 'file', true, false, 'SDNVW'), - array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_UPDATE, 'file', false, false, 'RDNV'), - array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_DELETE, 'file', false, false, 'RW'), - array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE, 'file', false, false, 'RDNVW'), - array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE, 'dir', false, false, 'RDNV'), + array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RDNVW'), + array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RDNVCK'), + array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRDNVW'), + array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMDNVW'), + array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SDNVW'), + array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RDNV'), + array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RW'), + array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RDNVW'), + array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RDNV'), ); } diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php index 34ec7dee213..1ae312ab5a8 100644 --- a/tests/lib/files/node/file.php +++ b/tests/lib/files/node/file.php @@ -39,7 +39,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $view->expects($this->once()) ->method('unlink') @@ -89,7 +89,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL, 'fileid' => 1))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1))); $view->expects($this->once()) ->method('unlink') @@ -124,7 +124,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->delete(); @@ -156,7 +156,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $this->assertEquals('bar', $node->getContent()); @@ -201,7 +201,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $view->expects($this->once()) ->method('file_put_contents') @@ -226,7 +226,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->putContent('bar'); @@ -279,7 +279,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $fh = $node->fopen('r'); @@ -316,7 +316,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $fh = $node->fopen('w'); @@ -375,7 +375,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_UPDATE))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_UPDATE))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->fopen('w'); @@ -402,7 +402,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->fopen('w'); @@ -425,7 +425,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL, 'fileid' => 3))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($root, $view, '/bar'); @@ -469,7 +469,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ, 'fileid' => 3))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($root, $view, '/bar'); @@ -556,7 +556,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL, 'fileid' => 1))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($root, $view, '/bar'); @@ -587,7 +587,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $view->expects($this->never()) ->method('rename'); diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php index e348e452f6f..91aa3b82db2 100644 --- a/tests/lib/files/node/folder.php +++ b/tests/lib/files/node/folder.php @@ -39,7 +39,7 @@ class Folder extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $view->expects($this->once()) ->method('rmdir') @@ -87,7 +87,7 @@ class Folder extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL, 'fileid' => 1))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1))); $view->expects($this->once()) ->method('rmdir') @@ -121,7 +121,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->delete(); @@ -255,7 +255,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $view->expects($this->once()) ->method('mkdir') @@ -285,7 +285,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFolder('asd'); @@ -305,7 +305,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $view->expects($this->once()) ->method('touch') @@ -335,7 +335,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFile('asd'); diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php index 80e3ac6f80a..8820be5b0b2 100644 --- a/tests/lib/files/node/node.php +++ b/tests/lib/files/node/node.php @@ -246,7 +246,7 @@ class Node extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $node = new \OC\Files\Node\Node($root, $view, '/bar/foo'); $node->touch(100); @@ -299,7 +299,7 @@ class Node extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_ALL))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); $node = new \OC\Files\Node\Node($root, $view, '/bar/foo'); $node->touch(100); @@ -323,7 +323,7 @@ class Node extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\PERMISSION_READ))); + ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); $node = new \OC\Files\Node\Node($root, $view, '/bar/foo'); $node->touch(100); diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php index 76046d360bc..7a546410aea 100644 --- a/tests/lib/share/helper.php +++ b/tests/lib/share/helper.php @@ -27,8 +27,8 @@ class Test_Share_Helper extends \Test\TestCase { array(array('defaultExpireDateSet' => false), 2000000000, 2000010000, 2000010000), // no default expire date and no user defined expire date, return false array(array('defaultExpireDateSet' => false), 2000000000, null, false), - // unenforced expire data and no user defined expire date, take default expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, null, 2000086400), + // unenforced expire data and no user defined expire date, return false (because the default is not enforced) + array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, null, false), // enforced expire date and no user defined expire date, take default expire date array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true), 2000000000, null, 2000086400), // unenforced expire date and user defined date > default expire date, take users expire date @@ -49,6 +49,4 @@ class Test_Share_Helper extends \Test\TestCase { $result = \OC\Share\Helper::calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate); $this->assertSame($expected, $result); } - - } diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index b5cdab0025b..1f95502919d 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -89,7 +89,7 @@ class Test_Share extends \Test\TestCase { public function testShareInvalidShareType() { $message = 'Share type foobar is not valid for test.txt'; try { - OCP\Share::shareItem('test', 'test.txt', 'foobar', $this->user2, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', 'foobar', $this->user2, \OCP\Constants::PERMISSION_READ); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); } @@ -98,7 +98,7 @@ class Test_Share extends \Test\TestCase { public function testInvalidItemType() { $message = 'Sharing backend for foobar not found'; try { - OCP\Share::shareItem('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ); + OCP\Share::shareItem('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -134,7 +134,7 @@ class Test_Share extends \Test\TestCase { $this->assertEquals($message, $exception->getMessage()); } try { - OCP\Share::setPermissions('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_UPDATE); + OCP\Share::setPermissions('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_UPDATE); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -144,7 +144,7 @@ class Test_Share extends \Test\TestCase { protected function shareUserOneTestFileWithUserTwo() { OC_User::setUserId($this->user1); $this->assertTrue( - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ), + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), 'Failed asserting that user 1 successfully shared text.txt with user 2.' ); $this->assertContains( @@ -163,7 +163,7 @@ class Test_Share extends \Test\TestCase { protected function shareUserTestFileAsLink() { OC_User::setUserId($this->user1); - $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ); + $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $this->assertTrue(is_string($result)); } @@ -174,7 +174,7 @@ class Test_Share extends \Test\TestCase { protected function shareUserTestFileWithUser($sharer, $receiver) { OC_User::setUserId($sharer); $this->assertTrue( - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $receiver, OCP\PERMISSION_READ | OCP\PERMISSION_SHARE), + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $receiver, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE), 'Failed asserting that ' . $sharer . ' successfully shared text.txt with ' . $receiver . '.' ); $this->assertContains( @@ -195,21 +195,21 @@ class Test_Share extends \Test\TestCase { // Invalid shares $message = 'Sharing test.txt failed, because the user '.$this->user1.' is the item owner'; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); } $message = 'Sharing test.txt failed, because the user foobar does not exist'; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, 'foobar', OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, 'foobar', \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); } $message = 'Sharing foobar failed, because the sharing backend for test could not find its source'; try { - OCP\Share::shareItem('test', 'foobar', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'foobar', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -222,7 +222,7 @@ class Test_Share extends \Test\TestCase { OC_User::setUserId($this->user1); $message = 'Sharing test.txt failed, because this item is already shared with '.$this->user2; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -232,7 +232,7 @@ class Test_Share extends \Test\TestCase { OC_User::setUserId($this->user2); $message = 'Sharing test.txt failed, because the user '.$this->user1.' is the original sharer'; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -243,11 +243,11 @@ class Test_Share extends \Test\TestCase { $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2)); // Attempt reshare without share permission - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user2); $message = 'Sharing test.txt failed, because resharing is not allowed'; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -255,30 +255,30 @@ class Test_Share extends \Test\TestCase { // Owner grants share and update permission OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE | OCP\PERMISSION_SHARE)); + $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE)); // Attempt reshare with escalated permissions OC_User::setUserId($this->user2); $message = 'Sharing test.txt failed, because the permissions exceed permissions granted to '.$this->user2; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, OCP\PERMISSION_READ | OCP\PERMISSION_DELETE); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); } // Valid reshare - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE)); $this->assertEquals(array('test.txt'), OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE)); OC_User::setUserId($this->user3); $this->assertEquals(array('test.txt'), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE)); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); // Attempt to escalate permissions OC_User::setUserId($this->user2); $message = 'Setting permissions for test.txt failed, because the permissions exceed permissions granted to '.$this->user2; try { - OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, OCP\PERMISSION_READ | OCP\PERMISSION_DELETE); + OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -286,25 +286,25 @@ class Test_Share extends \Test\TestCase { // Remove update permission OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ | OCP\PERMISSION_SHARE)); + $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE)); OC_User::setUserId($this->user2); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_SHARE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); OC_User::setUserId($this->user3); - $this->assertEquals(array(OCP\PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); // Remove share permission OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user2); - $this->assertEquals(array(OCP\PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); OC_User::setUserId($this->user3); $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt')); // Reshare again, and then have owner unshare OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ | OCP\PERMISSION_SHARE)); + $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE)); OC_User::setUserId($this->user2); - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user1); $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2)); OC_User::setUserId($this->user2); @@ -314,9 +314,9 @@ class Test_Share extends \Test\TestCase { // Attempt target conflict OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user3); - $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user2); $to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET); @@ -333,9 +333,9 @@ class Test_Share extends \Test\TestCase { $this->assertEquals(array(), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user3); - $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user2); $to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET); @@ -412,7 +412,7 @@ class Test_Share extends \Test\TestCase { OC_User::setUserId($this->user1); $this->assertTrue( - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\PERMISSION_ALL), + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_ALL), 'Failed asserting that user 1 successfully shared text.txt with user 4.' ); $this->assertContains( @@ -429,7 +429,7 @@ class Test_Share extends \Test\TestCase { $share = OCP\Share::getItemSharedWith('test', 'test.txt'); - $this->assertSame(\OCP\PERMISSION_ALL & ~OCP\PERMISSION_SHARE, $share['permissions'], + $this->assertSame(\OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_SHARE, $share['permissions'], 'Failed asserting that user 4 is excluded from re-sharing'); \OC_Appconfig::deleteKey('core', 'shareapi_exclude_groups_list'); @@ -440,7 +440,7 @@ class Test_Share extends \Test\TestCase { protected function shareUserOneTestFileWithGroupOne() { OC_User::setUserId($this->user1); $this->assertTrue( - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\PERMISSION_READ), + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ), 'Failed asserting that user 1 successfully shared text.txt with group 1.' ); $this->assertContains( @@ -468,7 +468,7 @@ class Test_Share extends \Test\TestCase { // Invalid shares $message = 'Sharing test.txt failed, because the group foobar does not exist'; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, 'foobar', OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, 'foobar', \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -477,7 +477,7 @@ class Test_Share extends \Test\TestCase { OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes'); $message = 'Sharing test.txt failed, because '.$this->user1.' is not a member of the group '.$this->group2; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group2, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group2, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -491,7 +491,7 @@ class Test_Share extends \Test\TestCase { OC_User::setUserId($this->user1); $message = 'Sharing test.txt failed, because this item is already shared with '.$this->group1; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -501,7 +501,7 @@ class Test_Share extends \Test\TestCase { OC_User::setUserId($this->user2); $message = 'Sharing test.txt failed, because the user '.$this->user1.' is the original sharer'; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -510,7 +510,7 @@ class Test_Share extends \Test\TestCase { // Attempt to share back to group $message = 'Sharing test.txt failed, because this item is already shared with '.$this->group1; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -519,7 +519,7 @@ class Test_Share extends \Test\TestCase { // Attempt to share back to member of group $message ='Sharing test.txt failed, because this item is already shared with '.$this->user3; try { - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ); $this->fail('Exception was expected: '.$message); } catch (Exception $exception) { $this->assertEquals($message, $exception->getMessage()); @@ -530,18 +530,18 @@ class Test_Share extends \Test\TestCase { $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1)); // Valid share with same person - user then group - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ | OCP\PERMISSION_DELETE | OCP\PERMISSION_SHARE)); - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_SHARE)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE)); OC_User::setUserId($this->user2); $this->assertEquals(array('test.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE | OCP\PERMISSION_SHARE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_SHARE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); OC_User::setUserId($this->user3); $this->assertEquals(array('test.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); // Valid reshare OC_User::setUserId($this->user2); - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\PERMISSION_READ)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_READ)); OC_User::setUserId($this->user4); $this->assertEquals(array('test.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); @@ -549,26 +549,26 @@ class Test_Share extends \Test\TestCase { OC_User::setUserId($this->user1); $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2)); OC_User::setUserId($this->user2); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); OC_User::setUserId($this->user4); $this->assertEquals(array('test.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); // Valid share with same person - group then user OC_User::setUserId($this->user1); - $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ | OCP\PERMISSION_DELETE)); + $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE)); OC_User::setUserId($this->user2); $this->assertEquals(array('test.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); // Unshare from group only OC_User::setUserId($this->user1); $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1)); OC_User::setUserId($this->user2); - $this->assertEquals(array(OCP\PERMISSION_READ | OCP\PERMISSION_DELETE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); + $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS)); // Attempt user specific target conflict OC_User::setUserId($this->user3); - $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\PERMISSION_READ | OCP\PERMISSION_SHARE)); + $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE)); OC_User::setUserId($this->user2); $to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET); $this->assertEquals(2, count($to_test)); @@ -576,7 +576,7 @@ class Test_Share extends \Test\TestCase { $this->assertTrue(in_array('test1.txt', $to_test)); // Valid reshare - $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\PERMISSION_READ | OCP\PERMISSION_SHARE)); + $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE)); OC_User::setUserId($this->user4); $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); @@ -628,7 +628,7 @@ class Test_Share extends \Test\TestCase { $this->assertTrue(OCP\Share::unshareAll('test', 'test.txt')); $this->assertTrue( - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->groupAndUser, OCP\PERMISSION_READ), + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->groupAndUser, \OCP\Constants::PERMISSION_READ), 'Failed asserting that user 1 successfully shared text.txt with group 1.' ); @@ -704,7 +704,7 @@ class Test_Share extends \Test\TestCase { public function testShareItemWithLink() { OC_User::setUserId($this->user1); - $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ); + $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $this->assertInternalType( 'string', $token, @@ -750,7 +750,7 @@ class Test_Share extends \Test\TestCase { \OC_Appconfig::setValue('core', 'shareapi_default_expire_date', 'yes'); \OC_Appconfig::setValue('core', 'shareapi_expire_after_n_days', '2'); - $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ); + $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); $this->assertInternalType( 'string', $token, @@ -876,20 +876,20 @@ class Test_Share extends \Test\TestCase { // one array with one share array( array( // input - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_ALL, 'item_target' => 't1')), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1')), array( // expected result - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_ALL, 'item_target' => 't1'))), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1'))), // two shares both point to the same source array( array( // input - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_UPDATE, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), ), array( // expected result - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE, 'item_target' => 't1', + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1', 'grouped' => array( - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_UPDATE, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), ) ), ) @@ -897,29 +897,29 @@ class Test_Share extends \Test\TestCase { // two shares both point to the same source but with different targets array( array( // input - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_UPDATE, 'item_target' => 't2'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'), ), array( // expected result - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_UPDATE, 'item_target' => 't2'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'), ) ), // three shares two point to the same source array( array( // input - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 2, 'permissions' => \OCP\PERMISSION_CREATE, 'item_target' => 't2'), - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_UPDATE, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), + array('item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), ), array( // expected result - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE, 'item_target' => 't1', + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1', 'grouped' => array( - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\PERMISSION_UPDATE, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), + array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), ) ), - array('item_source' => 2, 'permissions' => \OCP\PERMISSION_CREATE, 'item_target' => 't2'), + array('item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'), ) ), ); diff --git a/tests/lib/tags.php b/tests/lib/tags.php index ab714bde3df..3f0c52d19ea 100644 --- a/tests/lib/tags.php +++ b/tests/lib/tags.php @@ -214,7 +214,7 @@ class Test_Tags extends \Test\TestCase { $this->assertFalse($other_tagger->hasTag($test_tag)); OC_User::setUserId($this->user); - OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $other_user, OCP\PERMISSION_READ); + OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $other_user, \OCP\Constants::PERMISSION_READ); OC_User::setUserId($other_user); $other_tagger = $other_tagMgr->load('test', array(), true); // Update tags, load shared ones. diff --git a/tests/lib/tempmanager.php b/tests/lib/tempmanager.php index 05311e820a7..c030eef2c9e 100644 --- a/tests/lib/tempmanager.php +++ b/tests/lib/tempmanager.php @@ -27,7 +27,7 @@ class TempManager extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->baseDir = get_temp_dir() . '/oc_tmp_test'; + $this->baseDir = get_temp_dir() . $this->getUniqueID('/oc_tmp_test'); if (!is_dir($this->baseDir)) { mkdir($this->baseDir); } @@ -39,7 +39,7 @@ class TempManager extends \Test\TestCase { } /** - * @param \Psr\Log\LoggerInterface $logger + * @param \OCP\ILogger $logger * @return \OC\TempManager */ protected function getManager($logger = null) { diff --git a/tests/preseed-config.php b/tests/preseed-config.php index 3fd5b3cb7fc..3f41573bf29 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -1,22 +1,21 @@ <?php $CONFIG = array ( - "appstoreenabled" => false, - 'apps_paths' => - array ( - 0 => - array ( - 'path' => OC::$SERVERROOT.'/apps', - 'url' => '/apps', - 'writable' => true, - ), - 1 => - array ( - 'path' => OC::$SERVERROOT.'/apps2', - 'url' => '/apps2', - 'writable' => false, - ) - ), - + "appstoreenabled" => false, + 'apps_paths' => + array ( + 0 => + array ( + 'path' => OC::$SERVERROOT.'/apps', + 'url' => '/apps', + 'writable' => true, + ), + 1 => + array ( + 'path' => OC::$SERVERROOT.'/apps2', + 'url' => '/apps2', + 'writable' => false, + ) + ), ); if(substr(strtolower(PHP_OS), 0, 3) == "win") { |