Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Public Member Functions | |
__construct ($server='', $user='', $pass='', $auth=false, $socket='', $oauthtoken='') | |
#- More... | |
__set ($key, $value) | |
check_webdav () | |
Check's if server is a webdav compliant server. More... | |
close () | |
Closes an open socket. | |
copy_coll ($src_path, $dst_path, $overwrite) | |
Public method copy_coll. More... | |
copy_file ($src_path, $dst_path, $overwrite) | |
Public method copy_file. More... | |
delete ($path) | |
Public method delete. More... | |
get ($path, &$buffer, $fp=null) | |
Public method get. More... | |
get_file ($srcpath, $localpath) | |
Public method get_file. More... | |
gpi ($path) | |
Public method gpi. More... | |
is_dir ($path) | |
Public method is_dir. More... | |
is_file ($path) | |
Public method is_file. More... | |
lock ($path) | |
Public method lock. More... | |
ls ($path) | |
Public method ls. More... | |
mget ($filelist) | |
Public method mget. More... | |
mkcol ($path) | |
Public method mkcol. More... | |
move ($src_path, $dst_path, $overwrite) | |
Public method move. More... | |
mput ($filelist) | |
Public method mput. More... | |
open () | |
Open's a socket to a webdav server. More... | |
options () | |
Get options from webdav server. More... | |
put ($path, $data) | |
Public method put. More... | |
put_file ($path, $filename) | |
Public method put_file. More... | |
set_protocol ($version) | |
Set which HTTP protocol will be used. More... | |
unlock ($path, $locktoken) | |
Public method unlock. More... | |
webdav_client::__construct | ( | $server = '' , |
|
$user = '' , |
|||
$pass = '' , |
|||
$auth = false , |
|||
$socket = '' , |
|||
$oauthtoken = '' |
|||
) |
#-
Constructor - Initialise class variables
string | $server | Hostname of the server to connect to |
string | $user | Username (for basic/digest auth, see $auth) |
string | $pass | Password (for basic/digest auth, see $auth) |
bool | $auth | Authentication type; one of ['basic', 'digest', 'bearer'] |
string | $socket | Used protocol for fsockopen, usually: '' (empty) or 'ssl://' |
string | $oauthtoken | OAuth 2 bearer token (for bearer auth, see $auth) |
webdav_client::check_webdav | ( | ) |
Check's if server is a webdav compliant server.
True if server returns a DAV Element in Header and when schema 1,2 is supported.
bool | true if server is webdav server. Otherwise false. |
webdav_client::copy_coll | ( | $src_path, | |
$dst_path, | |||
$overwrite | |||
) |
Public method copy_coll.
Copies a collection on a webdav server
Duplicates a collection on the webdav server (serverside). All work is done on the webdav server. If you set param overwrite as true, the target will be overwritten.
string | src_path, string dest_path, bool overwrite |
int | status code (look at rfc 2518). false on error. |
webdav_client::copy_file | ( | $src_path, | |
$dst_path, | |||
$overwrite | |||
) |
Public method copy_file.
Copies a file on a webdav server
Duplicates a file on the webdav server (serverside). All work is done on the webdav server. If you set param overwrite as true, the target will be overwritten.
string | src_path, string dest_path, bool overwrite |
int | status code (look at rfc 2518). false on error. |
webdav_client::delete | ( | $path | ) |
Public method delete.
deletes a collection/directory on a webdav server
string | path |
int | status code (look at rfc 2518). false on error. |
webdav_client::get | ( | $path, | |
& | $buffer, | ||
$fp = null |
|||
) |
Public method get.
Gets a file from a webdav collection.
string | $path | the path to the file on the webdav server |
string | &$buffer | the buffer to store the data in |
resource | $fp | optional if included, the data is written directly to this resource and not to the buffer |
string|bool | status code and &$buffer (by reference) with response data from server on success. False on error. |
webdav_client::get_file | ( | $srcpath, | |
$localpath | |||
) |
Public method get_file.
Gets a file from a collection into local filesystem.
fopen() is used.
string | $srcpath | |
string | $localpath |
bool | true on success. false on error. |
webdav_client::gpi | ( | $path | ) |
Public method gpi.
Get's path information from webdav server for one element.
string | path |
array | dirinfo. false on error |
webdav_client::is_dir | ( | $path | ) |
Public method is_dir.
Gather whether a path points to a directory
string | path return bool true or false |
webdav_client::is_file | ( | $path | ) |
Public method is_file.
Gathers whether a path points to a file or not.
string | path |
bool | true or false |
webdav_client::lock | ( | $path | ) |
Public method lock.
Locks a file or collection.
Lock uses this->_user as lock owner.
string | path |
int | status code (look at rfc 2518). false on error. |
webdav_client::ls | ( | $path | ) |
Public method ls.
Get's directory information from webdav server into flat a array using PROPFIND
All filenames are UTF-8 encoded. Have a look at _propfind_startElement what keys are used in array returned.
string | path |
array | dirinfo, false on error |
webdav_client::mget | ( | $filelist | ) |
Public method mget.
Gets multiple files and directories.
FileList must be in format array("remotepath" => "localpath"). Filenames are UTF-8 encoded.
array | filelist |
bool | true on succes, other int status code on error |
webdav_client::mkcol | ( | $path | ) |
Public method mkcol.
Creates a new collection/directory on a webdav server
string | path |
int | status code received as response from webdav server (see rfc 2518) |
webdav_client::move | ( | $src_path, | |
$dst_path, | |||
$overwrite | |||
) |
Public method move.
Moves a file or collection on webdav server (serverside)
If you set param overwrite as true, the target will be overwritten.
string | src_path, string dest_path, bool overwrite |
int | status code (look at rfc 2518). false on error. |
webdav_client::mput | ( | $filelist | ) |
Public method mput.
Puts multiple files and/or directories onto a webdav server.
Filenames should be allready UTF-8 encoded. Param fileList must be in format array("localpath" => "destpath").
array | filelist |
bool | true on success. otherwise int status code on error |
webdav_client::open | ( | ) |
Open's a socket to a webdav server.
bool | true on success. Otherwise false. |
webdav_client::options | ( | ) |
Get options from webdav server.
array | with all header fields returned from webdav server. false if server does not speak http. |
webdav_client::put | ( | $path, | |
$data | |||
) |
Public method put.
Puts a file into a collection. Data is putted as one chunk!
string | path, string data |
int | status-code read from webdavserver. False on error. |
webdav_client::put_file | ( | $path, | |
$filename | |||
) |
Public method put_file.
Read a file as stream and puts it chunk by chunk into webdav server collection.
Look at php documenation for legal filenames with fopen(); The filename will be translated into utf-8 if not allready in utf-8.
string | targetpath, string filename |
int | status code. False on error. |
webdav_client::set_protocol | ( | $version | ) |
Set which HTTP protocol will be used.
Value 1 defines that HTTP/1.1 should be used (Keeps Connection to webdav server alive). Otherwise HTTP/1.0 will be used.
int | version |
webdav_client::unlock | ( | $path, | |
$locktoken | |||
) |
Public method unlock.
Unlocks a file or collection.
string | path, string locktoken |
int | status code (look at rfc 2518). false on error. |