Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Attributes | List of all members
repository_nextcloud\access_controlled_link_manager Class Reference

Manages the creation and usage of access controlled links. More...

Public Member Functions

 __construct ($ocsclient, $systemoauthclient, $systemocsclient, $issuer, $repositoryname)
 Access_controlled_link_manager constructor. More...
 
 create_folder_path_access_controlled_links ($context, $component, $filearea, $itemid)
 Creates a unique folder path for the access controlled link. More...
 
 create_share_user_sysaccount ($path, $username=null, $maywrite=false)
 Creates a share between a user and the system account. More...
 
 create_storage_folder ($controlledlinkfoldername, $webdavclient)
 Creates a folder to store access controlled links. More...
 
 create_system_dav ()
 Creates a new webdav_client for the system account. More...
 
 delete_share_dataowner_sysaccount ($shareid)
 Deletes the share of the systemaccount and a user. More...
 
 download_for_offline_usage (string $srcpath, string $targetpath)
 Download a file from the system account for the purpose of offline usage. More...
 
 find_share_in_sysaccount ($path)
 Find a file that has previously been shared with the system account. More...
 
 get_share_information_from_shareid ($shareid, $username)
 This method can only be used if the response is from a newly created share. More...
 
 get_shares_from_path ($path, $username)
 Gets all shares from a path (the path is file specific) and extracts the share of a specific user. More...
 
 transfer_file_to_path ($srcpath, $dstpath, $operation, $webdavclient=null)
 Copy or moves a file to a new path. More...
 

Protected Attributes

core oauth2 issuer $issuer
 Issuer from the oauthclient.
 
ocs_client $ocsclient
 OCS client that uses the Open Collaboration Services REST API.
 
string $repositoryname
 Name of the related repository.
 
core oauth2 client $systemoauthclient
 Client to manage oauth2 features from the systemaccount.
 
ocs_client $systemocsclient
 ocsclient of the systemaccount.
 
webdav_client $systemwebdavclient
 Client to manage webdav request from the systemaccount. More...
 

Detailed Description

Manages the creation and usage of access controlled links.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

repository_nextcloud\access_controlled_link_manager::__construct (   $ocsclient,
  $systemoauthclient,
  $systemocsclient,
  $issuer,
  $repositoryname 
)

Access_controlled_link_manager constructor.

Parameters
ocs_client$ocsclient
core\oauth2\client$systemoauthclient
ocs_client$systemocsclient
core\oauth2\issuer$issuer
string$repositoryname
Exceptions
configuration_exception

Member Function Documentation

◆ create_folder_path_access_controlled_links()

repository_nextcloud\access_controlled_link_manager::create_folder_path_access_controlled_links (   $context,
  $component,
  $filearea,
  $itemid 
)

Creates a unique folder path for the access controlled link.

Parameters
context$context
string$component
string$filearea
string$itemid
Return values
string::$resultfull generated path.
Exceptions
request_exceptionIf the folder path cannot be created.

◆ create_share_user_sysaccount()

repository_nextcloud\access_controlled_link_manager::create_share_user_sysaccount (   $path,
  $username = null,
  $maywrite = false 
)

Creates a share between a user and the system account.

If $username is set the sharing direction is system account -> user, otherwise user -> system account.

Parameters
string$pathRemote path of the file that will be shared
string$usernameoptional when set the file is shared with the corresponding user otherwise with the systemaccount.
bool$maywriteif false, only(!) read access is granted.
Return values
arraystatuscode, shareid, and filetarget
Exceptions
request_exception

◆ create_storage_folder()

repository_nextcloud\access_controlled_link_manager::create_storage_folder (   $controlledlinkfoldername,
  $webdavclient 
)

Creates a folder to store access controlled links.

Parameters
string$controlledlinkfoldername
webdav_client$webdavclient
Exceptions
coding_exception
configuration_exception
request_exception

◆ create_system_dav()

repository_nextcloud\access_controlled_link_manager::create_system_dav ( )

Creates a new webdav_client for the system account.

Return values
webdav_client
Exceptions
configuration_exception

◆ delete_share_dataowner_sysaccount()

repository_nextcloud\access_controlled_link_manager::delete_share_dataowner_sysaccount (   $shareid)

Deletes the share of the systemaccount and a user.

In case the share could not be deleted a notification is displayed.

Parameters
int$shareidRemote ID of the share to be deleted.

◆ download_for_offline_usage()

repository_nextcloud\access_controlled_link_manager::download_for_offline_usage ( string  $srcpath,
string  $targetpath 
)

Download a file from the system account for the purpose of offline usage.

Parameters
string$srcpathName of a file owned by the system account
string$targetpathTemporary filename in Moodle
Exceptions
repository_exceptionThe download was unsuccessful, maybe the file does not exist.

◆ find_share_in_sysaccount()

repository_nextcloud\access_controlled_link_manager::find_share_in_sysaccount (   $path)

Find a file that has previously been shared with the system account.

Parameters
string$pathPath to file in user context.
Return values
arrayshareid: ID of share, filetarget: path to file in sys account.
Exceptions
request_exceptionIf the share cannot be resolved.

◆ get_share_information_from_shareid()

repository_nextcloud\access_controlled_link_manager::get_share_information_from_shareid (   $shareid,
  $username 
)

This method can only be used if the response is from a newly created share.

In this case there is more information in the response. For a reference refer to https://docs.nextcloud.com/server/13/developer_manual/core/ocs-share-api.html#get-information-about-a-known-share.

Parameters
int$shareid
string$username
Return values
mixedthe id of the share
Exceptions
coding_exception
repository_nextcloud

◆ get_shares_from_path()

repository_nextcloud\access_controlled_link_manager::get_shares_from_path (   $path,
  $username 
)

Gets all shares from a path (the path is file specific) and extracts the share of a specific user.

In case multiple shares exist the first one is taken. Multiple shares can only appear when shares are created outside of this plugin, therefore this case is not handled.

Parameters
string$path
string$username
Return values
SimpleXMLElement
Exceptions
moodle_exception

◆ transfer_file_to_path()

repository_nextcloud\access_controlled_link_manager::transfer_file_to_path (   $srcpath,
  $dstpath,
  $operation,
  $webdavclient = null 
)

Copy or moves a file to a new path.

Parameters
string$srcpathsource path
string$dstpath
string$operationmove or copy
webdav_client$webdavclientneeded when moving files.
Return values
StringHttp-status of the request
Exceptions
configuration_exception
coding_exception
moodle_exception
repository_nextcloud

Member Data Documentation

◆ $systemwebdavclient

webdav_client repository_nextcloud\access_controlled_link_manager::$systemwebdavclient
protected

Client to manage webdav request from the systemaccount.


The documentation for this class was generated from the following file: