Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250530) (c39b7370636)
|
Public Member Functions | |
create_content_from_file (\context $context, int $userid, stored_file $file) | |
Create content from a file information. | |
delete_contents (context $context) | |
Delete content bank content by context. | |
get_content_from_id (int $id) | |
Return a content class form a content id. | |
get_contenttypes_with_capability_feature (string $feature, ?\context $context=null, bool $enabled=true) | |
Get the list of content types that have the requested feature. | |
get_contexts_with_capabilities_by_user ($capability='moodle/contentbank:access', $userid=null) | |
Return all the context where a user has all the given capabilities. | |
get_enabled_content_types () | |
Obtains the list of core_contentbank_content objects currently active. | |
get_extension (string $filename) | |
Returns the file extension for a file. | |
get_extension_supporter (string $extension, ?context $context=null) | |
Get the first content bank plugin supports a file extension. | |
get_supported_extensions_as_string (?context $context=null) | |
Obtains a string with all supported extensions by active plugins. | |
is_context_allowed (context $context) | |
Whether the context is allowed. | |
load_all_supported_extensions () | |
Obtains an array of supported extensions by active plugins. | |
load_context_supported_extensions (?context $context=null) | |
Obtains an array of supported extensions in the given context. | |
move_contents (context $from, context $to) | |
Move content bank content from a context to another. | |
search_contents (?string $search=null, ?int $contextid=0, ?array $contenttypenames=null) | |
Find the contents with $search% in the contextid defined. | |
core_contentbank\contentbank::create_content_from_file | ( | \context | $context, |
int | $userid, | ||
stored_file | $file ) |
Create content from a file information.
context | $context | Context where to upload the file and content. |
int | $userid | Id of the user uploading the file. |
stored_file | $file | The file to get information from |
content |
core_contentbank\contentbank::delete_contents | ( | context | $context | ) |
Delete content bank content by context.
context | $context | The context to delete content from. |
bool |
core_contentbank\contentbank::get_content_from_id | ( | int | $id | ) |
Return a content class form a content id.
coding_exception | if the ID is not valid or some class does no exists |
int | $id | the content id |
content | the content class instance |
core_contentbank\contentbank::get_contenttypes_with_capability_feature | ( | string | $feature, |
?\context | $context = null, | ||
bool | $enabled = true ) |
Get the list of content types that have the requested feature.
string | $feature | Feature code e.g CAN_UPLOAD. |
null | context | $context | Optional context to check the permission to use the feature. |
bool | $enabled | Whether check only the enabled content types or all of them. |
string[] | List of content types where the user has permission to access the feature. |
core_contentbank\contentbank::get_contexts_with_capabilities_by_user | ( | $capability = 'moodle/contentbank:access', | |
$userid = null ) |
Return all the context where a user has all the given capabilities.
string | $capability | The capability the user needs to have. |
int | null | $userid | Optional userid. $USER by default. |
array | Array of the courses and course categories where the user has the given capability. |
core_contentbank\contentbank::get_enabled_content_types | ( | ) |
Obtains the list of core_contentbank_content objects currently active.
The list does not include players which are disabled.
string[] | Array of contentbank contenttypes. |
core_contentbank\contentbank::get_extension | ( | string | $filename | ) |
Returns the file extension for a file.
string | $filename | The name of the file |
string | The extension of the file |
core_contentbank\contentbank::get_extension_supporter | ( | string | $extension, |
?context | $context = null ) |
Get the first content bank plugin supports a file extension.
string | $extension | Content file extension |
context | $context | $context Optional context to check (default null) |
string | contenttype name supports the file extension or null if the extension is not supported by any allowed plugin. |
core_contentbank\contentbank::get_supported_extensions_as_string | ( | ?context | $context = null | ) |
Obtains a string with all supported extensions by active plugins.
Mainly to use as filepicker options parameter.
context | $context | Optional context to check (default null) |
string | A string with all the extensions supported. |
core_contentbank\contentbank::is_context_allowed | ( | context | $context | ) |
Whether the context is allowed.
context | $context | Context to check. |
bool |
core_contentbank\contentbank::load_all_supported_extensions | ( | ) |
Obtains an array of supported extensions by active plugins.
array | The array with all the extensions supported and the supporting plugin names. |
core_contentbank\contentbank::load_context_supported_extensions | ( | ?context | $context = null | ) |
Obtains an array of supported extensions in the given context.
context | $context | Optional context to check (default null) |
array | The array with all the extensions supported and the supporting plugin names. |
core_contentbank\contentbank::move_contents | ( | context | $from, |
context | $to ) |
Move content bank content from a context to another.
context | $from | The context to get content from. |
context | $to | The context to move content to. |
bool |
core_contentbank\contentbank::search_contents | ( | ?string | $search = null, |
?int | $contextid = 0, | ||
?array | $contenttypenames = null ) |
Find the contents with $search% in the contextid defined.
If contextid and search are empty, all contents are returned. In all the cases, only the contents for the enabled contentbank-type plugins are returned. No content-type permissions are validated here. It is the caller responsability to check that the user can access to them. The only validation done here is, for each content, a call to the method $content->is_view_allowed().
string | null | $search | Optional string to search (for now it will search only into the name). |
int | $contextid | Optional contextid to search. |
array | $contenttypenames | Optional array with the list of content-type names to search. |
array | The contents for the enabled contentbank-type plugins having $search as name and placed in $contextid. |