Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 403]

Content type manager class

Copyright: 2020 Amaia Anabitarte <amaia@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 516 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: contenttype  - X-Ref

Content type manager class

__construct(\context $context = null)   X-Ref
Content type constructor

param: \context $context Optional context to check (default null)

create_content(\stdClass $record = null)   X-Ref
Fills content_bank table with appropiate information.

return: content  Object with content bank information.
param: \stdClass $record An optional content record compatible object (default null)

upload_content(stored_file $file, \stdClass $record = null)   X-Ref
Create a new content from an uploaded file.

return: content  Object with content bank information.
param: stored_file $file the uploaded file
param: \stdClass|null $record an optional content record

replace_content(stored_file $file, content $content)   X-Ref
Replace a content using an uploaded file.

return: content Object with the updated content bank information.
param: stored_file $file the uploaded file
param: content $content the original content record

delete_content(content $content)   X-Ref
Delete this content from the content_bank.
This method can be overwritten by the plugins if they need to delete specific information.

return: boolean true if the content has been deleted; false otherwise.
param: content $content The content to delete.

rename_content(content $content, string $name)   X-Ref
Rename this content from the content_bank.
This method can be overwritten by the plugins if they need to change some other specific information.

return: boolean true if the content has been renamed; false otherwise.
param: content $content The content to rename.
param: string $name  The name of the content.

move_content(content $content, \context $context)   X-Ref
Move content to another context.
This method can be overwritten by the plugins if they need to change some other specific information.

return: boolean true if the content has been renamed; false otherwise.
param: content $content The content to rename.
param: \context $context  The new context.

get_contenttype_name()   X-Ref
Returns the contenttype name of this content.

return: string   Content type of the current instance

get_plugin_name()   X-Ref
Returns the plugin name of the current instance.

return: string   Plugin name of the current instance

get_view_url(content $content)   X-Ref
Returns the URL where the content will be visualized.

return: string           URL where to visualize the given content.
param: content $content The content to be displayed.

get_view_content(content $content)   X-Ref
Returns the HTML content to add to view.php visualizer.

return: string           HTML code to include in view.php.
param: content $content The content to be displayed.

get_download_url(content $content)   X-Ref
Returns the URL to download the content.

return: string           URL with the content to download.
param: content $content The content to be downloaded.

get_icon(content $content)   X-Ref
Returns the HTML code to render the icon for content bank contents.

return: string               HTML code to render the icon
param: content $content The content to be displayed.

can_access()   X-Ref
Returns user has access capability for the main content bank and the content itself (base on is_access_allowed from plugin).

return: bool     True if content could be accessed. False otherwise.

is_access_allowed()   X-Ref
Returns user has access capability for the content itself.

return: bool     True if content could be accessed. False otherwise.

can_upload()   X-Ref
Returns the user has permission to upload new content.

return: bool     True if content could be uploaded. False otherwise.

is_upload_allowed()   X-Ref
Returns plugin allows uploading.

return: bool     True if plugin allows uploading. False otherwise.

can_delete(content $content)   X-Ref
Check if the user can delete this content.

return: bool True if content could be uploaded. False otherwise.
param: content $content The content to be deleted.

is_delete_allowed(content $content)   X-Ref
Returns if content allows deleting.

return: bool True if content allows uploading. False otherwise.
param: content $content The content to be deleted.

can_manage(content $content)   X-Ref
Check if the user can managed this content.

return: bool     True if content could be managed. False otherwise.
param: content $content The content to be managed.

is_manage_allowed(content $content)   X-Ref
Returns if content allows managing.

return: bool True if content allows uploading. False otherwise.
param: content $content The content to be managed.

can_edit(?content $content = null)   X-Ref
Returns whether or not the user has permission to use the editor.
This function will be called with the content to be edited as parameter,
or null when is checking permission to create a new content using the editor.

return: bool     True if the user can edit content. False otherwise.
param: content $content The content to be edited or null when creating a new content.

is_edit_allowed(?content $content)   X-Ref
Returns plugin allows edition.

return: bool     True if plugin allows edition. False otherwise.
param: content $content The content to be edited.

can_download(content $content)   X-Ref
Returns whether or not the user has permission to download the content.

return: bool    True if the user can download the content. False otherwise.
param: content $content The content to be downloaded.

is_download_allowed(content $content)   X-Ref
Returns plugin allows downloading.

return: bool    True if plugin allows downloading. False otherwise.
param: content $content The content to be downloaed.

is_feature_supported(string $feature)   X-Ref
Returns the plugin supports the feature.

return: bool     True if content could be uploaded. False otherwise.
param: string $feature Feature code e.g CAN_UPLOAD