Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

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

Defines 1 class

content:: (18 methods):
  __construct()
  get_content()
  get_content_type()
  get_timemodified()
  update_content()
  set_name()
  get_name()
  set_contextid()
  get_contextid()
  get_id()
  set_instanceid()
  get_instanceid()
  set_configdata()
  get_configdata()
  import_file()
  get_file()
  get_file_url()
  is_view_allowed()


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