Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
repository_nextcloud\ocs_client Class Reference

REST interface to Nextcloud's implementation of Open Collaboration Services. More...

Inheritance diagram for repository_nextcloud\ocs_client:
core\oauth2\rest

Public Member Functions

 __construct (client $oauthclient)
 Get endpoint URLs from the used issuer to use them in get_api_functions().
 
 call ($functionname, $functionargs, $rawpost=false, $contenttype=false)
 In POST requests, Moodle's REST API assumes that params are.
 
 get_api_functions ()
 Define relevant functions of the OCS API.
 

Public Attributes

const SHARE_PERMISSION_ALL = 31
 permissions=1 gives read permission for a share.
 
const SHARE_PERMISSION_READ = 1
 permissions=1 gives read permission for a share.
 
const SHARE_TYPE_PUBLIC = 3
 shareType=3 creates a public share.
 
const SHARE_TYPE_USER = 0
 shareType=0 creates a private user share.
 

Protected Attributes

curl $curl
 $curl
 

Detailed Description

REST interface to Nextcloud's implementation of Open Collaboration Services.

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

Constructor & Destructor Documentation

◆ __construct()

repository_nextcloud\ocs_client::__construct ( client $oauthclient)

Get endpoint URLs from the used issuer to use them in get_api_functions().

Parameters
client$oauthclientOAuth-authenticated Nextcloud client
Exceptions
configuration_exceptionException if critical endpoints are missing.
moodle_exceptionwhen trying to construct a moodleurl

Member Function Documentation

◆ call()

repository_nextcloud\ocs_client::call ( $functionname,
$functionargs,
$rawpost = false,
$contenttype = false )

In POST requests, Moodle's REST API assumes that params are.

  • transmitted as part of the URL or
  • expressed in JSON. Neither is true; we are passing an array to $functionargs which is then put into CURLOPT_POSTFIELDS. Curl assumes the content type to be multipart/form-data then, but the Moodle REST API tries to put a JSON content type. As a result, clients would fail. To make this less tedious to use, we assume that the params-as-array-in-$functionargs is the default for us.
Parameters
string$functionnameName of a function from get_api_functions()
array$functionargsRequest parameters
bool | string$rawpostOptional param to include in the body of a post
bool | string$contenttypeContent type of the request body. Default: multipart/form-data if !$rawpost, JSON otherwise
Return values
object|string
Exceptions
coding_exception
core\oauth2\rest_exception

Reimplemented from core\oauth2\rest.

◆ get_api_functions()

repository_nextcloud\ocs_client::get_api_functions ( )

Define relevant functions of the OCS API.

Previously, the instruction to create a oauthclient recommended the user to enter the return format (format=xml). However, in this case the shareid is appended at the wrong place. Therefore, a new url is build which inserts the shareid at the suitable place for delete_share and get_information_of_share. create_share docs: https://docs.nextcloud.com/server/13/developer_manual/core/ocs-share-api.html#create-a-new-share

Reimplemented from core\oauth2\rest.


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