Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
Microsoft Live Skydrive Repository Plugin
Author: | Dan Poltawski <dan.poltawski@luns.net.uk> |
Copyright: | 2012 Lancaster University Network Services Ltd |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1142 lines (44 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
repository_onedrive:: (34 methods):
__construct()
get_user_oauth_client()
check_login()
print_login()
print_login_popup()
build_breadcrumb()
build_node_path()
explode_node_path()
get_listing()
search()
query()
logout()
get_file()
get_file_reference()
supported_filetypes()
supported_returntypes()
default_returntype()
get_type_option_names()
callback()
send_file()
get_file_id_by_path()
delete_file_by_path()
create_folder_in_folder()
get_file_summary()
add_temp_writer_to_file()
set_file_sharing_anyone_with_link_can_read()
get_mimetype_from_filename()
upload_file()
reference_file_selected()
get_reference_details()
can_import_skydrive_files()
import_skydrive_files()
type_config_form()
repository_onedrive_oauth2_system_scopes()
Class: repository_onedrive - X-Ref
Microsoft onedrive repository plugin.__construct($repositoryid, $context = SYSCONTEXTID, $options = array() X-Ref |
Constructor. param: int $repositoryid repository instance id. param: int|stdClass $context a context id or context object. param: array $options repository options. param: int $readonly indicate this repo is readonly or not. return: void |
get_user_oauth_client($overrideurl = false) X-Ref |
Get a cached user authenticated oauth client. param: moodle_url $overrideurl - Use this url instead of the repo callback. return: \core\oauth2\client |
check_login() X-Ref |
Checks whether the user is authenticate or not. return: bool true when logged in. |
print_login() X-Ref |
Print or return the login form. return: void|array for ajax. |
print_login_popup($attr = null) X-Ref |
Print the login in a popup. param: array|null $attr Custom attributes to be applied to popup div. |
build_breadcrumb($path) X-Ref |
Build the breadcrumb from a path. param: string $path to create a breadcrumb from. return: array containing name and path of each crumb. |
build_node_path($id, $name = '', $root = '') X-Ref |
Generates a safe path to a node. Typically, a node will be id|Name of the node. param: string $id of the node. param: string $name of the node, will be URL encoded. param: string $root to append the node on, must be a result of this function. return: string path to the node. |
explode_node_path($node) X-Ref |
Returns information about a node in a path. param: string $node to extrat information from. return: array about the node. |
get_listing($path='', $page = '') X-Ref |
List the files and folders. param: string $path path to browse. param: string $page page to browse. return: array of result. |
search($searchtext, $page = 0) X-Ref |
Search throughout the OneDrive param: string $searchtext text to search for. param: int $page search page. return: array of results. |
query($q, $path = null, $parent = null, $page = 0) X-Ref |
Query OneDrive for files and folders using a search query. Documentation about the query format can be found here: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/driveitem https://developer.microsoft.com/en-us/graph/docs/overview/query_parameters This returns a list of files and folders with their details as they should be formatted and returned by functions such as get_listing() or search(). param: string $q search query as expected by the Graph API. param: string $path parent path of the current files, will not be used for the query. param: string $parent Parent id. param: int $page page. return: array of files and folders. |
logout() X-Ref |
Logout. return: string |
get_file($reference, $filename = '') X-Ref |
Get a file. param: string $reference reference of the file. param: string $filename filename to save the file to. return: string JSON encoded array of information about the file. |
get_file_reference($source) X-Ref |
Prepare file reference information. We are using this method to clean up the source to make sure that it is a valid source. param: string $source of the file. return: string file reference. |
supported_filetypes() X-Ref |
What kind of files will be in this repository? return: array return '*' means this repository support any files, otherwise |
supported_returntypes() X-Ref |
Tells how the file can be picked from this repository. return: int |
default_returntype() X-Ref |
Which return type should be selected by default. return: int |
get_type_option_names() X-Ref |
Return names of the general options. By default: no general option name. return: array |
callback() X-Ref |
Store the access token. |
send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) X-Ref |
Repository method to serve the referenced file param: stored_file $storedfile the file that contains the reference param: int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime) param: int $filter 0 (default)=no filtering, 1=all files, 2=html files only param: bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin param: array $options additional options affecting the file serving |
get_file_id_by_path(\repository_onedrive\rest $client, $fullpath) X-Ref |
See if a folder exists within a folder param: \repository_onedrive\rest $client Authenticated client. param: string $fullpath return: string|boolean The file id if it exists or false. |
delete_file_by_path(\repository_onedrive\rest $client, $fullpath) X-Ref |
Delete a file by full path. param: \repository_onedrive\rest $client Authenticated client. param: string $fullpath return: boolean |
create_folder_in_folder(\repository_onedrive\rest $client, $foldername, $parentid) X-Ref |
Create a folder within a folder param: \repository_onedrive\rest $client Authenticated client. param: string $foldername The folder we are creating. param: string $parentid The parent folder we are creating in. return: string The file id of the new folder. |
get_file_summary(\repository_onedrive\rest $client, $fileid) X-Ref |
Get simple file info for humans. param: \repository_onedrive\rest $client Authenticated client. param: string $fileid The file we are querying. return: stdClass |
add_temp_writer_to_file(\repository_onedrive\rest $client, $fileid, $email) X-Ref |
Add a writer to the permissions on the file (temporary). param: \repository_onedrive\rest $client Authenticated client. param: string $fileid The file we are updating. param: string $email The email of the writer account to add. return: boolean |
set_file_sharing_anyone_with_link_can_read(\repository_onedrive\rest $client, $fileid) X-Ref |
Allow anyone with the link to read the file. param: \repository_onedrive\rest $client Authenticated client. param: string $fileid The file we are updating. return: boolean |
get_mimetype_from_filename($filename) X-Ref |
Given a filename, use the core_filetypes registered types to guess a mimetype. If no mimetype is known, return 'application/unknown'; param: string $filename return: string $mimetype |
upload_file(\repository_onedrive\rest $service, \curl $curl, \curl $authcurl,$filepath, $mimetype, $parentid, $filename) X-Ref |
Upload a file to onedrive. param: \repository_onedrive\rest $service Authenticated client. param: \curl $curl Curl client to perform the put operation (with no auth headers). param: \curl $authcurl Curl client that will send authentication headers param: string $filepath The local path to the file to upload param: string $mimetype The new mimetype param: string $parentid The folder to put it. param: string $filename The name of the new file return: string $fileid |
reference_file_selected($reference, $context, $component, $filearea, $itemid) X-Ref |
Called when a file is selected as a "link". Invoked at MOODLE/repository/repository_ajax.php What should happen here is that the file should be copied to a new file owned by the moodle system user. It should be organised in a folder based on the file context. It's sharing permissions should allow read access with the link. The returned reference should point to the newly copied file - not the original. param: string $reference this reference is generated by param: context $context the target context for this new file. param: string $component the target component for this new file. param: string $filearea the target filearea for this new file. param: string $itemid the target itemid for this new file. return: string $modifiedreference (final one before saving to DB) |
get_reference_details($reference, $filestatus = 0) X-Ref |
Get human readable file info from the reference. param: string $reference param: int $filestatus |
can_import_skydrive_files() X-Ref |
Return true if any instances of the skydrive repo exist - and we can import them. return: bool |
import_skydrive_files() X-Ref |
Import all the files that were created with the skydrive repo to this repo. return: bool |
type_config_form($mform, $classname = 'repository') X-Ref |
Edit/Create Admin Settings Moodle form. param: moodleform $mform Moodle form (passed by reference). param: string $classname repository class name. |
repository_onedrive_oauth2_system_scopes(\core\oauth2\issuer $issuer) X-Ref |
Callback to get the required scopes for system account. param: \core\oauth2\issuer $issuer return: string |