Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

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: 356 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: contentbank  - X-Ref

Content bank class

get_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.

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