Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
Content bank class
Copyright: | 2020 Amaia Anabitarte <amaia@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 385 lines (15 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
contentbank:: (14 methods):
get_enabled_content_types()
load_all_supported_extensions()
load_context_supported_extensions()
get_supported_extensions_as_string()
get_extension()
get_extension_supporter()
search_contents()
get_contexts_with_capabilities_by_user()
create_content_from_file()
delete_contents()
move_contents()
get_contenttypes_with_capability_feature()
get_content_from_id()
is_context_allowed()
Class: contentbank - X-Ref
Content bank classget_enabled_content_types() X-Ref |
Obtains the list of core_contentbank_content objects currently active. The list does not include players which are disabled. return: string[] Array of contentbank contenttypes. |
load_all_supported_extensions() X-Ref |
Obtains an array of supported extensions by active plugins. return: array The array with all the extensions supported and the supporting plugin names. |
load_context_supported_extensions(context $context = null) X-Ref |
Obtains an array of supported extensions in the given context. param: context $context Optional context to check (default null) return: array The array with all the extensions supported and the supporting plugin names. |
get_supported_extensions_as_string(context $context = null) X-Ref |
Obtains a string with all supported extensions by active plugins. Mainly to use as filepicker options parameter. param: context $context Optional context to check (default null) return: string A string with all the extensions supported. |
get_extension(string $filename) X-Ref |
Returns the file extension for a file. param: string $filename The name of the file return: string The extension of the file |
get_extension_supporter(string $extension, context $context = null) X-Ref |
Get the first content bank plugin supports a file extension. param: string $extension Content file extension param: context $context $context Optional context to check (default null) return: string contenttype name supports the file extension or null if the extension is not supported by any allowed plugin. |
search_contents(?string $search = null, ?int $contextid = 0, ?array $contenttypenames = null) X-Ref |
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(). param: string|null $search Optional string to search (for now it will search only into the name). param: int $contextid Optional contextid to search. param: array $contenttypenames Optional array with the list of content-type names to search. return: array The contents for the enabled contentbank-type plugins having $search as name and placed in $contextid. |
get_contexts_with_capabilities_by_user($capability = 'moodle/contentbank:access', $userid = null) X-Ref |
Return all the context where a user has all the given capabilities. param: string $capability The capability the user needs to have. param: int|null $userid Optional userid. $USER by default. return: array Array of the courses and course categories where the user has the given capability. |
create_content_from_file(\context $context, int $userid, stored_file $file) X-Ref |
Create content from a file information. param: \context $context Context where to upload the file and content. param: int $userid Id of the user uploading the file. param: stored_file $file The file to get information from return: content |
delete_contents(context $context) X-Ref |
Delete content bank content by context. param: context $context The context to delete content from. return: bool |
move_contents(context $from, context $to) X-Ref |
Move content bank content from a context to another. param: context $from The context to get content from. param: context $to The context to move content to. return: bool |
get_contenttypes_with_capability_feature(string $feature, \context $context = null, bool $enabled = true) X-Ref |
Get the list of content types that have the requested feature. param: string $feature Feature code e.g CAN_UPLOAD. param: null|\context $context Optional context to check the permission to use the feature. param: bool $enabled Whether check only the enabled content types or all of them. return: string[] List of content types where the user has permission to access the feature. |
get_content_from_id(int $id) X-Ref |
Return a content class form a content id. param: int $id the content id return: content the content class instance |
is_context_allowed(context $context) X-Ref |
Whether the context is allowed. param: context $context Context to check. return: bool |