Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Google Docs Plugin. More...
Public Member Functions | |
__construct ($repositoryid, $context=SYSCONTEXTID, $options=array(), $readonly=0) | |
Constructor. More... | |
cache_file_by_reference ($reference, $storedfile) | |
Cache file from external repository by reference repository::get_file_reference() repository::get_file() Invoked at MOODLE/repository/repository_ajax.php. More... | |
callback () | |
Store the access token. More... | |
can_be_edited_by_user () | |
Can the instance be edited by the current user? More... | |
check_capability () | |
Checks if user has a capability to view the current repository. More... | |
check_login () | |
Checks whether the user is authenticate or not. More... | |
contains_private_data () | |
Is this repository accessing private data? More... | |
convert_references_to_local () | |
Find all external files in this repo and import them. | |
copy_to_area ($source, $filerecord, $maxbytes=-1, $areamaxbytes=FILE_AREA_MAX_BYTES_UNLIMITED) | |
This function is used to copy a moodle file to draft area. More... | |
cron () | |
Defines operations that happen occasionally on cron. More... | |
default_returntype () | |
Which return type should be selected by default. More... | |
delete ($downloadcontents=false) | |
delete a repository instance More... | |
file_is_accessible ($source) | |
Repository method to make sure that user can access particular file. More... | |
filter (&$value) | |
Filter file listing to display specific types. More... | |
get_file ($reference, $filename='') | |
Get a file. More... | |
get_file_reference ($source) | |
Prepare file reference information. More... | |
get_file_size ($source) | |
Return size of a file in bytes. More... | |
get_file_source_info ($source) | |
Return the source information. More... | |
get_link ($url) | |
Return file URL, for most plugins, the parameter is the original url, but some plugins use a file id, so we need this function to convert file id to original url. More... | |
get_listing ($path='', $page='') | |
List the files and folders. More... | |
get_meta () | |
Provide repository instance information for Ajax. More... | |
get_name () | |
Return the name of this instance, can be overridden. More... | |
get_option ($config='') | |
Get settings for repository instance. More... | |
get_reference_details ($reference, $filestatus=0) | |
Get human readable file info from a the reference. More... | |
get_short_filename ($str, $maxlength) | |
Create a shorten filename. More... | |
get_typename () | |
Returns the type name of the repository. More... | |
global_search () | |
is it possible to do glboal search? More... | |
has_moodle_files () | |
Does this repository used to browse moodle files? More... | |
hide ($hide='toggle') | |
Hide/Show a repository. More... | |
import_external_file_contents (stored_file $file, $maxbytes=0) | |
Downloads the file from external repository and saves it in moodle filepool. More... | |
is_visible () | |
Return is the instance is visible (is the type visible ? is the context enable ?) More... | |
logout () | |
Logout. More... | |
prepare_file ($filename) | |
Get a unique file path in which to save the file. More... | |
prepare_to_cache () | |
Prepares the repository to be cached. More... | |
print_login () | |
Print or return the login form. More... | |
print_login_popup ($attr=null) | |
Print the login in a popup. More... | |
print_search () | |
Show the search screen, if required. More... | |
reference_file_selected ($reference, $context, $component, $filearea, $itemid) | |
Called when a file is selected as a "link". More... | |
remove_files () | |
Find all external files linked to this repository and delete them. | |
search ($searchtext, $page=0) | |
Search throughout the Google Drive. More... | |
send_file ($storedfile, $lifetime=null, $filter=0, $forcedownload=false, array $options=null) | |
Repository method to serve the referenced file. More... | |
send_relative_file (stored_file $mainfile, $relativepath) | |
Gets a file relative to this file in the repository and sends it to the browser. More... | |
set_option ($options=array()) | |
Save settings for repository instance $repo->set_option(array('api_key'=>'f2188bde132', 'name'=>'dongsheng'));. More... | |
supported_filetypes () | |
What kind of files will be in this repository? More... | |
supported_returntypes () | |
Tells how the file can be picked from this repository. More... | |
supports_relative_file () | |
helper function to check if the repository supports send_relative_file. More... | |
sync_reference (stored_file $file) | |
Performs synchronisation of an external file if the previous one has expired. More... | |
uses_post_requests () | |
Helper function to indicate if this repository uses post requests for uploading files. More... | |
Static Public Member Functions | |
static | antivir_scan_file ($thefile, $filename, $deleteinfected) |
Scan file, throws exception in case of infected file. More... | |
static | append_suffix ($filename) |
Append a suffix to filename. More... | |
static | build_source_field ($source) |
Build draft file's source field. More... | |
static | build_tree ($fileinfo, $search, $dynamicmode, &$list) |
Builds a tree of files This function is then called recursively. More... | |
static | create ($type, $userid, $context, $params, $readonly=0) |
Create an instance for this plug-in. More... | |
static | delete_all_for_context ($contextid, $downloadcontents=true) |
Delete all the instances associated to a context. More... | |
static | delete_tempfile_from_draft ($draftitemid, $filepath, $filename) |
Delete a temp file from draft area. More... | |
static | display_instances_list ($context, $typename=null) |
Display a repository instance list (with edit/delete/create links) More... | |
static | draftfile_exists ($itemid, $filepath, $filename) |
Check if file already exists in draft area. More... | |
static | get_editable_types ($context=null) |
Return all types that you a user can create/edit and which are also visible Note: Mostly used in order to know if at least one editable type can be set. More... | |
static | get_instance ($id) |
Get single repository instance for administrative actions. More... | |
static | get_instance_option_names () |
Return names of the instance options. More... | |
static | get_instances ($args=array()) |
Return repository instances. More... | |
static | get_moodle_file ($reference) |
Parses the moodle file reference and returns an instance of stored_file. More... | |
static | get_repository_by_id ($repositoryid, $context, $options=array()) |
Get repository instance using repository id. More... | |
static | get_secret_key () |
Generate a secret key to be used for passing sensitive information around. More... | |
static | get_type_by_id ($id) |
Get the repository type by a given repository type id. More... | |
static | get_type_by_typename ($typename) |
Get a repository type object by a given type name. More... | |
static | get_type_option_names () |
Return names of the general options. More... | |
static | get_types ($visible=null) |
Return all repository types ordered by sortorder field first repository type in returnedarray[0], second repository type in returnedarray[1], ... More... | |
static | get_unused_filename ($itemid, $filepath, $filename) |
Get an unused filename from the current draft area. More... | |
static | instance_config_form ($mform) |
Edit/Create Instance Settings Moodle form. More... | |
static | instance_form_validation ($mform, $data, $errors) |
Validate repository plugin instance form. More... | |
static | move_to_filepool ($thefile, $record) |
Move file from download folder to file pool using FILE API. More... | |
static | overwrite_existing_draftfile ($itemid, $filepath, $filename, $newfilepath, $newfilename) |
Overwrite an existing file. More... | |
static | plugin_init () |
function which is run when the type is created (moodle administrator add the plugin) More... | |
static | prepare_listing ($listing) |
Prepares list of files before passing it to AJAX, makes sure data is in the correct format and stores formatted values. More... | |
static | reset_caches () |
Function repository::reset_caches() is deprecated, cache is handled by MUC now. More... | |
static | static_function ($plugin, $function) |
Call a static function. More... | |
static | sync_external_file ($file, $resetsynchistory=false) |
Function repository::sync_external_file() is deprecated. More... | |
static | type_config_form ($mform, $classname='repository') |
Edit/Create Admin Settings Moodle form. More... | |
static | type_form_validation ($mform, $data, $errors) |
Validate Admin Settings Moodle form. More... | |
static | update_draftfile ($draftid, $filepath, $filename, $updatedata) |
Updates a file in draft filearea. More... | |
static | wake_from_cache ($data) |
Restores the repository from cache. More... | |
Public Attributes | |
stdClass | $context |
current context | |
bool | $disabled = false |
force disable repository instance | |
int | $id |
repository instance id | |
stdClass | $instance |
repository instance database record | |
array | $options |
repository options | |
bool | $readonly |
Whether or not the repository instance is editable. | |
int | $returntypes |
return types | |
const | GETFILE_TIMEOUT = 30 |
Timeout in seconds for downloading the external file into moodle. More... | |
const | SCOPES = 'https://www.googleapis.com/auth/drive' |
Additional scopes required for drive. | |
const | SYNCFILE_TIMEOUT = 1 |
Timeout in seconds for syncronising the external file size. More... | |
const | SYNCIMAGE_TIMEOUT = 3 |
Timeout in seconds for downloading an image file from external repository during syncronisation. More... | |
Protected Member Functions | |
add_temp_writer_to_file (\repository_googledocs\rest $client, $fileid, $email) | |
Add a writer to the permissions on the file (temporary). More... | |
add_writer_to_file (\repository_googledocs\rest $client, $fileid, $email) | |
Add a writer to the permissions on the file. More... | |
build_breadcrumb ($path) | |
Build the breadcrumb from a path. More... | |
build_node_path ($id, $name='', $root='') | |
Generates a safe path to a node. More... | |
copy_file (\repository_googledocs\rest $client, $fileid, $name) | |
Copy a file and return the new file details. More... | |
create_folder_in_folder (\repository_googledocs\rest $client, $foldername, $parentid) | |
Create a folder within a folder. More... | |
explode_node_path ($node) | |
Returns information about a node in a path. More... | |
folder_exists_in_folder (\repository_googledocs\rest $client, $foldername, $parentid) | |
See if a folder exists within a folder. More... | |
get_file_summary (\repository_googledocs\rest $client, $fileid) | |
Get simple file info for humans. More... | |
get_user_oauth_client ($overrideurl=false) | |
Get a cached user authenticated oauth client. More... | |
move_file_from_root_to_folder (\repository_googledocs\rest $client, $fileid, $folderid) | |
Move from root to folder. More... | |
prevent_writers_from_sharing_file (\repository_googledocs\rest $client, $fileid) | |
Prevent writers from sharing. More... | |
query ($q, $path=null, $page=0) | |
Query Google Drive for files and folders using a search query. More... | |
set_file_sharing_anyone_with_link_can_read (\repository_googledocs\rest $client, $fileid) | |
Allow anyone with the link to read the file. More... | |
Static Protected Member Functions | |
static | prepare_breadcrumb ($breadcrumb) |
Prepare the breadcrumb. More... | |
static | prepare_list ($list) |
Prepare the file/folder listing. More... | |
Protected Attributes | |
string | $typename |
Type of repository (webdav, google_docs, dropbox, ...). More... | |
Google Docs Plugin.
repository_googledocs::__construct | ( | $repositoryid, | |
$context = SYSCONTEXTID , |
|||
$options = array() , |
|||
$readonly = 0 |
|||
) |
Constructor.
int | $repositoryid | repository instance id. |
int | stdClass | $context | a context id or context object. |
array | $options | repository options. |
int | $readonly | indicate this repo is readonly or not. |
void |
Reimplemented from repository.
|
protected |
Add a writer to the permissions on the file (temporary).
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are updating. |
string | The email of the writer account to add. |
boolean |
|
protected |
Add a writer to the permissions on the file.
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are updating. |
string | The email of the writer account to add. |
boolean |
|
staticinherited |
Scan file, throws exception in case of infected file.
Please note that the scanning engine must be able to access the file, permissions of the file are not modified here!
string | $thefile | |
string | $filename | name of the file |
bool | $deleteinfected |
|
staticinherited |
|
protected |
Build the breadcrumb from a path.
string | $path | to create a breadcrumb from. |
array | containing name and path of each crumb. |
|
protected |
Generates a safe path to a node.
Typically, a node will be id|Name of the node.
string | $id | of the node. |
string | $name | of the node, will be URL encoded. |
string | $root | to append the node on, must be a result of this function. |
string | path to the node. |
|
staticinherited |
Build draft file's source field.
file_restore_source_field_from_draft_file() XXX: This is a hack for file manager (MDL-28666) For newly created draft files we have to construct source filed in php serialized data format. File manager needs to know the original file information before copying to draft area, so we append these information in mdl_files.source field
string | $source |
string | serialised source field |
|
staticinherited |
Builds a tree of files This function is then called recursively.
file_info | $fileinfo | an object returned by file_browser::get_file_info() |
string | $search | searched string |
bool | $dynamicmode | no recursive call is done when in dynamic mode |
array | $list | the array containing the files under the passed $fileinfo |
int | the number of files found |
|
inherited |
Cache file from external repository by reference repository::get_file_reference() repository::get_file() Invoked at MOODLE/repository/repository_ajax.php.
string | $reference | this reference is generated by repository::get_file_reference() |
stored_file | $storedfile | created file reference |
Reimplemented in repository_dropbox.
repository_googledocs::callback | ( | ) |
Store the access token.
Reimplemented from repository.
|
finalinherited |
Can the instance be edited by the current user?
The property $readonly must not be used within this method because it only controls if the options from self::get_instance_option_names() can be edited.
bool | true if the user can edit the instance. |
|
finalinherited |
Checks if user has a capability to view the current repository.
bool | true when the user can, otherwise throws an exception. |
repository_exception | when the user does not meet the requirements. |
repository_googledocs::check_login | ( | ) |
Checks whether the user is authenticate or not.
bool | true when logged in. |
Reimplemented from repository.
|
inherited |
Is this repository accessing private data?
This function should return true for the repositories which access external private data from a user. This is the case for repositories such as Dropbox, Google Docs or Box.net which authenticate the user and then store the auth token.
Of course, many repositories store 'private data', but we only want to set contains_private_data() to repositories which are external to Moodle and shouldn't be accessed to by the users having the capability to 'login as' someone else. For instance, the repository 'Private files' is not considered as private because it's part of Moodle.
You should not set contains_private_data() to true on repositories which allow different types of instances as the levels other than 'user' are, by definition, not private. Also the user instances will be protected when they need to.
boolean | True when the repository accesses private external data. |
Reimplemented in repository_contentbank, repository_coursefiles, repository_equella, repository_filesystem, repository_flickr_public, repository_local, repository_merlot, repository_recent, repository_s3, repository_upload, repository_url, repository_user, repository_webdav, repository_wikimedia, and repository_youtube.
|
protected |
Copy a file and return the new file details.
A side effect of the copy is that the owner will be the account authenticated with this oauth client.
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are copying. |
string | $name | The original filename (don't change it). |
stdClass | file details. |
|
inherited |
This function is used to copy a moodle file to draft area.
It DOES NOT check if the user is allowed to access this file because the actual file can be located in the area where user does not have access to but there is an alias to this file in the area where user CAN access it. file_is_accessible should be called for alias location before calling this function.
string | $source | The metainfo of file, it is base64 encoded php serialized data |
stdClass | array | $filerecord | contains itemid, filepath, filename and optionally other attributes of the new file |
int | $maxbytes | maximum allowed size of file, -1 if unlimited. If size of file exceeds the limit, the file_exception is thrown. |
int | $areamaxbytes | the maximum size of the area. A file_exception is thrown if the new file will reach the limit. |
array | The information about the created file |
|
staticinherited |
Create an instance for this plug-in.
string | $type | the type of the repository |
int | $userid | the user id |
stdClass | $context | the context |
array | $params | the options for this instance |
int | $readonly | whether to create it readonly or not (defaults to not) |
mixed |
Reimplemented in repository_filesystem, and repository_nextcloud.
|
protected |
Create a folder within a folder.
repository_googledocs::rest | $client | Authenticated client. |
string | $foldername | The folder we are creating. |
string | $parentid | The parent folder we are creating in. |
string | The file id of the new folder. |
|
inherited |
Defines operations that happen occasionally on cron.
bool |
Reimplemented in repository_dropbox.
repository_googledocs::default_returntype | ( | ) |
|
finalinherited |
delete a repository instance
bool | $downloadcontents |
bool |
|
staticfinalinherited |
Delete all the instances associated to a context.
This method is intended to be a callback when deleting a course or a user to delete all the instances associated to their context. The usual way to delete a single instance is to use self::delete().
int | $contextid | context ID. |
boolean | $downloadcontents | true to convert references to hard copies. |
void |
|
staticinherited |
Delete a temp file from draft area.
int | $draftitemid | |
string | $filepath | |
string | $filename |
bool |
|
staticinherited |
Display a repository instance list (with edit/delete/create links)
stdClass | $context | the context for which we display the instance |
string | $typename | if set, we display only one type of instance |
|
staticinherited |
Check if file already exists in draft area.
int | $itemid | of the draft area. |
string | $filepath | path to the file. |
string | $filename | file name. |
bool |
|
protected |
Returns information about a node in a path.
string | $node | to extrat information from. |
array | about the node. |
|
inherited |
Repository method to make sure that user can access particular file.
This is checked when user tries to pick the file from repository to deal with potential parameter substitutions is request
string | $source | source of the file, returned by repository as 'source' and received back from user (not cleaned) |
bool | whether the file is accessible by current user |
Reimplemented in repository_contentbank, and repository_recent.
|
inherited |
Filter file listing to display specific types.
array | $value |
bool |
|
protected |
See if a folder exists within a folder.
repository_googledocs::rest | $client | Authenticated client. |
string | $foldername | The folder we are looking for. |
string | $parentid | The parent folder we are looking in. |
string|boolean | The file id if it exists or false. |
|
staticinherited |
Return all types that you a user can create/edit and which are also visible Note: Mostly used in order to know if at least one editable type can be set.
stdClass | $context | the context for which we want the editable types |
array | types |
repository_googledocs::get_file | ( | $reference, | |
$filename = '' |
|||
) |
Get a file.
string | $reference | reference of the file. |
string | $file | name to save the file to. |
string | JSON encoded array of information about the file. |
Reimplemented from repository.
repository_googledocs::get_file_reference | ( | $source | ) |
Prepare file reference information.
We are using this method to clean up the source to make sure that it is a valid source.
string | $source | of the file. |
string | file reference. |
Reimplemented from repository.
|
inherited |
Return size of a file in bytes.
string | $source | encoded and serialized data of file |
int | file size in bytes |
|
inherited |
Return the source information.
The result of the function is stored in files.source field. It may be analysed when the source file is lost or repository may use it to display human-readable location of reference original.
This method is called when file is picked for the first time only. When file (either copy or a reference) is already in moodle and it is being picked again to another file area (also as a copy or as a reference), the value of files.source is copied.
string | $source | source of the file, returned by repository as 'source' and received back from user (not cleaned) |
string|null |
Reimplemented in repository_filesystem, repository_s3, repository_flickr, repository_flickr_public, repository_boxnet, repository_dropbox, repository_equella, repository_url, and repository_wikimedia.
|
protected |
Get simple file info for humans.
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are querying. |
stdClass |
|
staticinherited |
Get single repository instance for administrative actions.
Do not use this function to access repository contents, because it does not set the current context
integer | $id | repository instance id |
repository |
|
staticinherited |
Return names of the instance options.
By default: no instance option name
array |
Reimplemented in repository_equella, repository_filesystem, repository_flickr_public, repository_nextcloud, and repository_webdav.
|
staticinherited |
Return repository instances.
array | $args | Array containing the following keys: currentcontext : instance of context (default system context) context : array of instances of context (default empty array) onlyvisible : bool (default true) type : string return instances of this type only accepted_types : string|array return instances that contain files of those types (*, web_image, .pdf, ...) return_types : int combination of FILE_INTERNAL & FILE_EXTERNAL & FILE_REFERENCE & FILE_CONTROLLED_LINK. 0 means every type. The default is FILE_INTERNAL | FILE_EXTERNAL. userid : int if specified, instances belonging to other users will not be returned |
array | repository instances |
|
inherited |
Return file URL, for most plugins, the parameter is the original url, but some plugins use a file id, so we need this function to convert file id to original url.
string | $url | the url of file |
string |
Reimplemented in repository_coursefiles, repository_flickr, repository_flickr_public, repository_boxnet, repository_dropbox, and repository_nextcloud.
repository_googledocs::get_listing | ( | $path = '' , |
|
$page = '' |
|||
) |
List the files and folders.
string | $path | path to browse. |
string | $page | page to browse. |
array | of result. |
Reimplemented from repository.
|
finalinherited |
Provide repository instance information for Ajax.
stdClass |
|
staticinherited |
Parses the moodle file reference and returns an instance of stored_file.
string | $reference | reference to the moodle internal file as retruned by repository::get_file_reference() or file_storage::pack_reference() |
stored_file|null |
|
inherited |
Return the name of this instance, can be overridden.
string |
Reimplemented in repository_coursefiles.
|
inherited |
Get settings for repository instance.
string | $config | a specific option to get. |
mixed | returns an array of options. If $config is not empty, then it returns that option, or null if the option does not exist. |
Reimplemented in repository_dropbox, repository_flickr, repository_flickr_public, and repository_youtube.
repository_googledocs::get_reference_details | ( | $reference, | |
$filestatus = 0 |
|||
) |
Get human readable file info from a the reference.
string | $reference | |
int | $filestatus |
Reimplemented from repository.
|
staticinherited |
Get repository instance using repository id.
Note that this function does not check permission to access repository contents
repository_exception |
int | $repositoryid | repository instance ID |
context | int | $context | context instance or context ID where this repository will be used |
array | $options | additional repository options |
repository |
|
staticfinalinherited |
Generate a secret key to be used for passing sensitive information around.
string | repository secret key. |
|
inherited |
Create a shorten filename.
string | $str | filename |
int | $maxlength | max file name length |
string | short filename |
|
staticinherited |
Get the repository type by a given repository type id.
int | $id | the type id |
object |
|
staticinherited |
Get a repository type object by a given type name.
string | $typename | the repository type name |
repository_type|bool |
|
static |
Return names of the general options.
By default: no general option name.
array |
Reimplemented from repository.
|
inherited |
Returns the type name of the repository.
string | type name of the repository. |
|
staticinherited |
Return all repository types ordered by sortorder field first repository type in returnedarray[0], second repository type in returnedarray[1], ...
bool | $visible | can return types by visiblity, return all types if null |
array | Repository types |
|
staticinherited |
Get an unused filename from the current draft area.
Will check if the file ends with ([0-9]) and increase the number.
int | $itemid | draft item ID. |
string | $filepath | path to the file. |
string | $filename | name of the file. |
string | an unused file name. |
|
protected |
Get a cached user authenticated oauth client.
moodle_url | $overrideurl | - Use this url instead of the repo callback. |
core::oauth2::client |
|
inherited |
is it possible to do glboal search?
bool |
Reimplemented in repository_filesystem, repository_flickr, repository_flickr_public, repository_merlot, repository_s3, repository_skydrive, repository_webdav, repository_wikimedia, and repository_youtube.
|
inherited |
Does this repository used to browse moodle files?
bool |
Reimplemented in repository_contentbank, repository_coursefiles, repository_local, repository_recent, and repository_user.
|
finalinherited |
Hide/Show a repository.
string | $hide |
bool |
|
inherited |
Downloads the file from external repository and saves it in moodle filepool.
This function is different from repository::sync_reference() because it has bigger request timeout and always downloads the content.
This function is invoked when we try to unlink the file from the source and convert a reference into a true copy.
exception | when file could not be imported |
stored_file | $file | |
int | $maxbytes | throw an exception if file size is bigger than $maxbytes (0 means no limit) |
|
staticinherited |
Edit/Create Instance Settings Moodle form.
moodleform | $mform | Moodle form (passed by reference) |
Reimplemented in repository_equella, repository_filesystem, repository_flickr_public, repository_nextcloud, and repository_webdav.
|
staticinherited |
Validate repository plugin instance form.
moodleform | $mform | moodle form |
array | $data | form data |
array | $errors | errors |
array | errors |
Reimplemented in repository_filesystem.
|
inherited |
Return is the instance is visible (is the type visible ? is the context enable ?)
bool |
Reimplemented in repository_coursefiles.
repository_googledocs::logout | ( | ) |
|
protected |
Move from root to folder.
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are updating. |
string | $folderid | The id of the folder we are moving to |
boolean |
|
staticinherited |
|
staticinherited |
Overwrite an existing file.
int | $itemid | |
string | $filepath | |
string | $filename | |
string | $newfilepath | |
string | $newfilename |
bool |
|
staticinherited |
function which is run when the type is created (moodle administrator add the plugin)
bool | success or fail? |
Reimplemented in repository_flickr_public.
|
staticprotectedinherited |
Prepare the breadcrumb.
array | $breadcrumb | contains each element of the breadcrumb. |
array | of breadcrumb elements. |
|
inherited |
Get a unique file path in which to save the file.
The filename returned will be removed at the end of the request and should not be relied upon to exist in subsequent requests.
string | $filename | file name |
file | path |
|
staticprotectedinherited |
Prepare the file/folder listing.
array | $list | of files and folders. |
array | of files and folders. |
|
staticinherited |
Prepares list of files before passing it to AJAX, makes sure data is in the correct format and stores formatted values.
array | stdClass | $listing | result of get_listing() or search() or file_get_drafarea_files() |
array |
|
inherited |
Prepares the repository to be cached.
Implements method from cacheable_object interface.
array |
Implements cacheable_object.
|
protected |
Prevent writers from sharing.
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are updating. |
boolean |
repository_googledocs::print_login | ( | ) |
repository_googledocs::print_login_popup | ( | $attr = null | ) |
Print the login in a popup.
array | null | $attr | Custom attributes to be applied to popup div. |
|
inherited |
Show the search screen, if required.
string |
Reimplemented in repository_flickr_public.
|
protected |
Query Google Drive for files and folders using a search query.
Documentation about the query format can be found here: https://developers.google.com/drive/search-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().
string | $q | search query as expected by the Google API. |
string | $path | parent path of the current files, will not be used for the query. |
int | $page | page. |
array | of files and folders. |
repository_googledocs::reference_file_selected | ( | $reference, | |
$context, | |||
$component, | |||
$filearea, | |||
$itemid | |||
) |
Called when a file is selected as a "link".
Invoked at MOODLE/repository/repository_ajax.php
This is called at the point the reference files are being copied from the draft area to the real area (when the file has really really been selected.
string | $reference | this reference is generated by repository::get_file_reference() |
context | $context | the target context for this new file. |
string | $component | the target component for this new file. |
string | $filearea | the target filearea for this new file. |
string | $itemid | the target itemid for this new file. |
string | updated reference (final one before it's saved to db). |
Reimplemented from repository.
|
staticinherited |
Function repository::reset_caches() is deprecated, cache is handled by MUC now.
repository_googledocs::search | ( | $searchtext, | |
$page = 0 |
|||
) |
Search throughout the Google Drive.
string | $searchtext | text to search for. |
int | $page | search page. |
array | of results. |
Reimplemented from repository.
repository_googledocs::send_file | ( | $storedfile, | |
$lifetime = null , |
|||
$filter = 0 , |
|||
$forcedownload = false , |
|||
array | $options = null |
||
) |
Repository method to serve the referenced file.
stored_file | $storedfile | the file that contains the reference |
int | $lifetime | Number of seconds before the file should expire from caches (null means $CFG->filelifetime) |
int | $filter | 0 (default)=no filtering, 1=all files, 2=html files only |
bool | $forcedownload | If true (default false), forces download of file rather than view in browser/plugin |
array | $options | additional options affecting the file serving |
Reimplemented from repository.
|
inherited |
Gets a file relative to this file in the repository and sends it to the browser.
Used to allow relative file linking within a repository without creating file records for linked files
Repositories that overwrite this must be very careful - see filesystem repository for example.
stored_file | $mainfile | The main file we are trying to access relative files for. |
string | $relativepath | the relative path to the file we are trying to access. |
Reimplemented in repository_filesystem.
|
protected |
Allow anyone with the link to read the file.
repository_googledocs::rest | $client | Authenticated client. |
string | $fileid | The file we are updating. |
boolean |
|
inherited |
Save settings for repository instance $repo->set_option(array('api_key'=>'f2188bde132', 'name'=>'dongsheng'));.
array | $options | settings |
bool |
Reimplemented in repository_dropbox, repository_filesystem, repository_flickr, repository_flickr_public, repository_nextcloud, and repository_youtube.
|
staticinherited |
Call a static function.
Any additional arguments than plugin and function will be passed through.
string | $plugin | repository plugin name |
string | $function | function name |
mixed |
repository_googledocs::supported_filetypes | ( | ) |
What kind of files will be in this repository?
array | return '*' means this repository support any files, otherwise return mimetypes of files, it can be an array |
Reimplemented from repository.
repository_googledocs::supported_returntypes | ( | ) |
Tells how the file can be picked from this repository.
int |
Reimplemented from repository.
|
inherited |
helper function to check if the repository supports send_relative_file.
true|false |
Reimplemented in repository_filesystem.
|
staticinherited |
Function repository::sync_external_file() is deprecated.
Use repository::sync_reference instead
|
inherited |
Performs synchronisation of an external file if the previous one has expired.
This function must be implemented for external repositories supporting FILE_REFERENCE, it is called for existing aliases when their filesize, contenthash or timemodified are requested. It is not called for internal repositories (see repository::has_moodle_files()), references to internal files are updated immediately when source is modified.
Referenced files may optionally keep their content in Moodle filepool (for thumbnail generation or to be able to serve cached copy). In this case both contenthash and filesize need to be synchronized. Otherwise repositories should use contenthash of empty file and correct filesize in bytes.
Note that this function may be run for EACH file that needs to be synchronised at the moment. If anything is being downloaded or requested from external sources there should be a small timeout. The synchronisation is performed to update the size of the file and/or to update image and re-generated image preview. There is nothing fatal if syncronisation fails but it is fatal if syncronisation takes too long and hangs the script generating a page.
Note: If you wish to call $file->get_filesize(), $file->get_contenthash() or $file->get_timemodified() make sure that recursion does not happen.
Called from stored_file::sync_external_file()
@uses stored_file::set_missingsource() @uses stored_file::set_synchronized()
stored_file | $file |
bool | false when file does not need synchronisation, true if it was synchronised |
Reimplemented in repository_boxnet, repository_dropbox, repository_equella, and repository_filesystem.
|
static |
Edit/Create Admin Settings Moodle form.
moodleform | $mform | Moodle form (passed by reference). |
string | $classname | repository class name. |
Reimplemented from repository.
|
staticinherited |
Validate Admin Settings Moodle form.
moodleform | $mform | Moodle form (passed by reference) |
array | $data | array of ("fieldname"=>value) of submitted data |
array | $errors | array of ("fieldname"=>errormessage) of errors |
array | array of errors |
|
staticinherited |
Updates a file in draft filearea.
This function can only update fields filepath, filename, author, license. If anything (except filepath) is updated, timemodified is set to current time. If filename or filepath is updated the file unconnects from it's origin and therefore all references to it will be converted to copies when filearea is saved.
int | $draftid | |
string | $filepath | path to the directory containing the file, or full path in case of directory |
string | $filename | name of the file, or '.' in case of directory |
array | $updatedata | array of fields to change (only filename, filepath, license and/or author can be updated) |
moodle_exception | if for any reason file can not be updated (file does not exist, target already exists, etc.) |
|
inherited |
Helper function to indicate if this repository uses post requests for uploading files.
bool |
|
staticinherited |
Restores the repository from cache.
Implements method from cacheable_object interface.
array |
Implements cacheable_object.
|
protectedinherited |
Type of repository (webdav, google_docs, dropbox, ...).
Read from $this->get_typename().
|
inherited |
Timeout in seconds for downloading the external file into moodle.
|
inherited |
Timeout in seconds for syncronising the external file size.
|
inherited |
Timeout in seconds for downloading an image file from external repository during syncronisation.