Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_contentbank\content Class Reference

Content manager class. More...

Inheritance diagram for core_contentbank\content:
contenttype_h5p\content

Public Member Functions

 __construct (stdClass $record)
 Content bank constructor.
 
 get_configdata ()
 Return the content config values.
 
 get_content ()
 Returns $this->content.
 
 get_content_type ()
 Returns $this->content->contenttype.
 
 get_content_type_instance ()
 Return the contenttype instance of this content.
 
 get_contextid ()
 Returns the contextid of the content.
 
 get_file ()
 Returns the $file related to this content.
 
 get_file_url ()
 Returns the file url related to this content.
 
 get_id ()
 Returns the content ID.
 
 get_instanceid ()
 Returns the $instanceid of this content.
 
 get_name ()
 Returns the name of the content.
 
 get_timemodified ()
 Returns $this->content->timemodified.
 
 get_uses ()
 Returns the places where the file associated to this content is used or an empty array if the content has no file.
 
 get_visibility ()
 Return true if the content may be shown to other users in the content bank.
 
 import_file (stored_file $file)
 Import a file as a valid content.
 
 is_view_allowed ()
 Returns user has access permission for the content itself (based on what plugin needs).
 
 set_configdata (string $configdata)
 Change the content config values.
 
 set_contextid (int $contextid)
 Set a new contextid to the content.
 
 set_instanceid (int $instanceid)
 Change the content instanceid value.
 
 set_name (string $name)
 Set a new name to the content.
 
 set_visibility (int $visibility)
 Sets a new content visibility and saves it to database.
 
 update_content ()
 Updates content_bank table with information in $this->content.
 

Public Attributes

int const VISIBILITY_PUBLIC = 1
 Visibility value.
 
int const VISIBILITY_UNLISTED = 2
 Visibility value.
 

Protected Attributes

stdClass $content = null
 $content The content of the current instance.
 

Detailed Description

Content manager class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_contentbank\content::__construct ( stdClass $record)

Content bank constructor.

Parameters
stdClass$recordA contentbank_content record.
Exceptions
coding_exceptionIf content type is not right.

Member Function Documentation

◆ get_configdata()

core_contentbank\content::get_configdata ( )

Return the content config values.

Return values
mixedConfig information for this content (json decoded)

◆ get_content()

core_contentbank\content::get_content ( )

Returns $this->content.

Return values
stdClass\$this-,>content.

◆ get_content_type()

core_contentbank\content::get_content_type ( )

Returns $this->content->contenttype.

Return values
string\$this-,>content->contenttype.

◆ get_content_type_instance()

core_contentbank\content::get_content_type_instance ( )

Return the contenttype instance of this content.

Return values
contenttypeThe content type instance

◆ get_contextid()

core_contentbank\content::get_contextid ( )

Returns the contextid of the content.

Return values
intThe id of the content context.

◆ get_file()

core_contentbank\content::get_file ( )

Returns the $file related to this content.

Return values
stored_fileFile stored in content bank area related to the given itemid.
Exceptions
coding_exceptionif not loaded.

◆ get_file_url()

core_contentbank\content::get_file_url ( )

Returns the file url related to this content.

Return values
stringURL of the file stored in content bank area related to the given itemid.
Exceptions
coding_exceptionif not loaded.

◆ get_id()

core_contentbank\content::get_id ( )

Returns the content ID.

Return values
intThe content ID.

◆ get_instanceid()

core_contentbank\content::get_instanceid ( )

Returns the $instanceid of this content.

Return values
intcontentbank instanceid

◆ get_name()

core_contentbank\content::get_name ( )

Returns the name of the content.

Return values
stringThe name of the content.

◆ get_timemodified()

core_contentbank\content::get_timemodified ( )

Returns $this->content->timemodified.

Return values
int\$this-,>content->timemodified.

◆ get_uses()

core_contentbank\content::get_uses ( )

Returns the places where the file associated to this content is used or an empty array if the content has no file.

Return values
arrayof stored_file where current file content is used or empty array if it hasn't any file.
Since
3.11

◆ get_visibility()

core_contentbank\content::get_visibility ( )

Return true if the content may be shown to other users in the content bank.

Return values
boolean

◆ import_file()

core_contentbank\content::import_file ( stored_file $file)

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.

Exceptions
file_exceptionIf file operations fail
Parameters
stored_file$fileFile to store in the content file area.
Return values
stored_file|nullthe stored content file or null if the file is discarted.

◆ is_view_allowed()

core_contentbank\content::is_view_allowed ( )

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

Return values
boolTrue if content could be accessed. False otherwise.

Reimplemented in contenttype_h5p\content.

◆ set_configdata()

core_contentbank\content::set_configdata ( string $configdata)

Change the content config values.

Parameters
string$configdataNew config information for this content
Return values
booleanTrue if the configdata has been succesfully updated. False otherwise.

◆ set_contextid()

core_contentbank\content::set_contextid ( int $contextid)

Set a new contextid to the content.

Parameters
int$contextidThe new contextid of the content.
Return values
boolTrue if the content has been succesfully updated. False otherwise.

◆ set_instanceid()

core_contentbank\content::set_instanceid ( int $instanceid)

Change the content instanceid value.

Parameters
int$instanceidNew instanceid for this content
Return values
booleanTrue if the instanceid has been succesfully updated. False otherwise.

◆ set_name()

core_contentbank\content::set_name ( string $name)

Set a new name to the content.

Parameters
string$nameThe name of the content.
Return values
boolTrue if the content has been succesfully updated. False otherwise.
Exceptions
coding_exceptionif not loaded.

◆ set_visibility()

core_contentbank\content::set_visibility ( int $visibility)

Sets a new content visibility and saves it to database.

Parameters
int$visibilityMust be self\PUBLIC or self\UNLISTED
Return values
bool
Exceptions
coding_exception

◆ update_content()

core_contentbank\content::update_content ( )

Updates content_bank table with information in $this->content.

Return values
booleanTrue if the content has been succesfully updated. False otherwise.
Exceptions
coding_exceptionif not loaded.

Member Data Documentation

◆ VISIBILITY_PUBLIC

int const core_contentbank\content::VISIBILITY_PUBLIC = 1

Visibility value.

Public content is visible to all users with access to the content bank of the appropriate context.

◆ VISIBILITY_UNLISTED

int const core_contentbank\content::VISIBILITY_UNLISTED = 2

Visibility value.

Unlisted content is only visible to the author and to users with moodle/contentbank:viewunlistedcontent capability.


The documentation for this class was generated from the following file: