Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

Content manager class

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

Defines 1 class


Class: content  - X-Ref

Content manager class

__construct(stdClass $record)   X-Ref
Content bank constructor

param: stdClass $record A contentbank_content record.

get_content()   X-Ref
Returns $this->content.

return: stdClass  $this->content.

get_content_type()   X-Ref
Returns $this->content->contenttype.

return: string  $this->content->contenttype.

get_content_type_instance()   X-Ref
Return the contenttype instance of this content.

return: contenttype The content type instance

get_timemodified()   X-Ref
Returns $this->content->timemodified.

return: int  $this->content->timemodified.

update_content()   X-Ref
Updates content_bank table with information in $this->content.

return: boolean  True if the content has been succesfully updated. False otherwise.

set_name(string $name)   X-Ref
Set a new name to the content.

param: string $name  The name of the content.
return: bool  True if the content has been succesfully updated. False otherwise.

get_name()   X-Ref
Returns the name of the content.

return: string   The name of the content.

set_contextid(int $contextid)   X-Ref
Set a new contextid to the content.

param: int $contextid  The new contextid of the content.
return: bool  True if the content has been succesfully updated. False otherwise.

get_contextid()   X-Ref
Returns the contextid of the content.

return: int   The id of the content context.

get_id()   X-Ref
Returns the content ID.

return: int   The content ID.

set_instanceid(int $instanceid)   X-Ref
Change the content instanceid value.

param: int $instanceid    New instanceid for this content
return: boolean           True if the instanceid has been succesfully updated. False otherwise.

get_instanceid()   X-Ref
Returns the $instanceid of this content.

return: int   contentbank instanceid

set_configdata(string $configdata)   X-Ref
Change the content config values.

param: string $configdata    New config information for this content
return: boolean              True if the configdata has been succesfully updated. False otherwise.

get_configdata()   X-Ref
Return the content config values.

return: mixed   Config information for this content (json decoded)

import_file(stored_file $file)   X-Ref
Import a file as a valid content.

By default, all content has a public file area to interact with the content bank
repository. This method should be overridden by contentypes which does not simply
upload to the public file area.

If any, the method will return the final stored_file. This way it can be invoked
as parent::import_file in case any plugin want to store the file in the public area
and also parse it.

param: stored_file $file File to store in the content file area.
return: stored_file|null the stored content file or null if the file is discarted.

get_file()   X-Ref
Returns the $file related to this content.

return: stored_file  File stored in content bank area related to the given itemid.

get_file_url()   X-Ref
Returns the file url related to this content.

return: string       URL of the file stored in content bank area related to the given itemid.

is_view_allowed()   X-Ref
Returns user has access permission for the content itself (based on what plugin needs).

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