Environment

Builds the environment so that the services have access to the files and folders' owner

package

OCA\Gallery\Environment

Methods

__construct

__construct( $appName,  $userId,  $userFolder, \OCP\IUserManager $userManager, \OCP\Files\IRootFolder $rootFolder, \OCP\ILogger $logger) 

Arguments

$appName

$userId

$userFolder

$userManager

\OCP\IUserManager

$rootFolder

\OCP\Files\IRootFolder

$logger

\OCP\ILogger

Returns the path from the shared folder to the root folder in the original owner's filesystem: /userId/files/parent_folder/shared_folder

buildFromRootToFolder(string $fileSource) : string

This cannot be calculated with paths and IDs, the share's file source is required

Arguments

$fileSource

string

Response

string

Returns the name of the user sharing files publicly

getDisplayName() : string
Throws
\OCA\Gallery\Environment\NotFoundEnvException

Response

string

Returns the Node based on a path starting from the files' owner user folder

getNodeFromUserFolder(string $path) : \OCP\Files\File|\OCP\Files\Folder

When logged in, this is the current user's user folder When visiting a link, this is the sharer's user folder

Throws
\OCA\Gallery\Environment\NotFoundEnvException

Arguments

$path

string

Response

\OCP\Files\File|\OCP\Files\Folder

Returns the Node based on a path starting from the virtual root

getNodeFromVirtualRoot(string $subPath) : \OCP\Files\File|\OCP\Files\Folder

Arguments

$subPath

string

Response

\OCP\Files\File|\OCP\Files\Folder

Returns the path which goes from the file, up to the user folder, based on a node: parent_folder/current_folder/my_file

getPathFromUserFolder(\OCP\Files\Node $file) : string

This is used for the preview system, which needs a full path

getPath() on the file produces a path like: '/userId/files/my_folder/my_sub_folder/my_file'

So we substract the path to the folder, giving us a relative path 'my_folder/my_sub_folder/my_file'

Arguments

$file

\OCP\Files\Node

Response

string

Returns the path which goes from the file, up to the root folder of the Gallery: current_folder/my_file

getPathFromVirtualRoot(\OCP\Files\File|\OCP\Files\Folder|\OCP\Files\Node $node) : string

That root folder changes when folders are shared publicly

Arguments

$node

\OCP\Files\File|\OCP\Files\Folder|\OCP\Files\Node

Response

string

Returns the path which goes from the file, up to the user folder, based on a path: parent_folder/current_folder/my_file

getRelativePath(string $fullPath) : string

getPath() on the file produces a path like: '/userId/files/my_folder/my_sub_folder/my_file'

So we substract the path to the user folder, giving us a relative path 'my_folder/my_sub_folder'

Arguments

$fullPath

string

Response

string

Returns the resource found in a specific folder and identified by the given ID

getResourceFromFolderAndId(\OCP\Files\Folder $folder, integer $resourceId) : \OCP\Files\Node
Throws
\OCA\Gallery\Environment\NotFoundEnvException

Arguments

$folder

\OCP\Files\Folder

$resourceId

integer

Response

\OCP\Files\Node

Returns the resource identified by the given ID

getResourceFromId(integer $resourceId) : \OCP\Files\Node
Throws
\OCA\Gallery\Environment\NotFoundEnvException

Arguments

$resourceId

integer

Response

\OCP\Files\Node

Returns the name of shared folder

getSharedFolderName() : string

Response

string

Returns the shared node

getSharedNode() : \OCP\Files\File|\OCP\Files\Folder

Response

\OCP\Files\File|\OCP\Files\Folder

Returns the password for the share, if there is one

getSharePassword() : string|null

Response

string|null

Returns the userId of the currently logged-in user or the sharer

getUserId() : string

Response

string

Returns the virtual root where the user lands after logging in or when following a link

getVirtualRootFolder() : \OCP\Files\Folder
Throws
\OCA\Gallery\Environment\NotFoundEnvException

Response

\OCP\Files\Folder

Returns true if the environment has been setup using a token

isTokenBasedEnv() : boolean

Response

boolean

Creates the environment for a logged-in user

setStandardEnv() 

userId and userFolder are already known, we define fromRootToFolder so that the services can use one method to have access to resources without having to know whether they're private or public

Creates the environment based on the share the token links to

setTokenBasedEnv(\OCP\Share\IShare $share) 

Arguments

$share

\OCP\Share\IShare

Properties

appName

appName : string
var

Type(s)

string

The userId of the logged-in user or the person sharing a folder publicly

userId : string
var

Type(s)

string

The userFolder of the logged-in user or the ORIGINAL owner of the files which are shared publicly

userFolder : \OCP\Files\Folder|null

A share needs to be tracked back to its original owner in order to be able to access the resource

var

Type(s)

\OCP\Files\Folder|null

userManager

userManager : \OCP\IUserManager
var

Type(s)

\OCP\IUserManager

sharedNodeId

sharedNodeId : integer
var

Type(s)

integer

sharedNode

sharedNode : \OCP\Files\File|\OCP\Files\Folder
var

Type(s)

\OCP\Files\File|\OCP\Files\Folder

rootFolder

rootFolder : \OCP\Files\IRootFolder
var

Type(s)

\OCP\Files\IRootFolder

logger

logger : \OCP\ILogger
var

Type(s)

\OCP\ILogger

The path to the userFolder for users with accounts: /userId/files

fromRootToFolder : string

For public folders, it's the path from the shared folder to the root folder in the original owner's filesystem: /userId/files/parent_folder/shared_folder

var

Type(s)

string

The name of the shared folder

folderName : string
var

Type(s)

string

sharePassword

sharePassword : string|null
var

Type(s)

string|null