Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
mod_data\manager Class Reference

Public Member Functions

 __construct (cm_info $cm, stdClass $instance)
 Class constructor.
 
 can_export_entries (?int $userid=null)
 Check if the user can export entries on the current context.
 
 can_manage_templates (?int $userid=null)
 Check if the user can manage templates on the current context.
 
 can_view_preset (preset $preset, ?int $userid=null)
 Check if the user can view a specific preset.
 
 get_available_presets ()
 Returns an array of all the available presets.
 
 get_available_saved_presets ()
 Returns an array of all the presets that users have saved to the site.
 
 get_context ()
 Return the current context.
 
 get_coursemodule ()
 Return the current cm_info.
 
 get_field (stdClass $fieldrecord)
 Return a specific field instance from a field record.
 
 get_field_records ()
 Return the field records (the current data_fields records).
 
 get_fields ()
 Return the database fields.
 
 get_instance ()
 Return the current instance.
 
 get_renderer (?moodle_page $page=null)
 Return the current module renderer.
 
 get_template (string $templatename, array $options=[])
 Return a specific template.
 
 has_fields ()
 Return if the database has fields.
 
 has_records ()
 Return if the database has records.
 
 reset_all_templates ()
 Reset all templates.
 
 reset_template (string $templatename)
 Reset all templates related to a specific template.
 
 set_module_viewed (stdClass $course)
 Trigger module viewed event and set the module viewed for completion.
 
 set_template_viewed ()
 Trigger module template viewed event.
 
 update_templates (stdClass $newtemplates)
 Update the database templates.
 

Static Public Member Functions

static create_from_coursemodule ($cm)
 Create a manager instance from a course_modules record.
 
static create_from_data_record ($record)
 Create a manager instance from a data_record entry.
 
static create_from_instance (stdClass $instance)
 Create a manager instance from an instance record.
 
static get_available_plugin_presets ()
 Returns an array of all the available plugin presets.
 

Public Attributes

string $path
 plugin path.
 
const MODULE = 'data'
 Module name.
 
const PLUGINNAME = 'mod_data'
 The plugin name.
 
const TEMPLATES_LIST
 Template list with their files required to save the information of a preset.
 

Constructor & Destructor Documentation

◆ __construct()

mod_data\manager::__construct ( cm_info $cm,
stdClass $instance )

Class constructor.

Parameters
cm_info$cmcourse module info object
stdClass$instanceactivity instance object.

Member Function Documentation

◆ can_export_entries()

mod_data\manager::can_export_entries ( ?int $userid = null)

Check if the user can export entries on the current context.

Parameters
int$useridthe user id to check ($USER->id if null).
Return values
boolif the user can export entries on current context.

◆ can_manage_templates()

mod_data\manager::can_manage_templates ( ?int $userid = null)

Check if the user can manage templates on the current context.

Parameters
int$useridthe user id to check ($USER->id if null).
Return values
boolif the user can manage templates on current context.

◆ can_view_preset()

mod_data\manager::can_view_preset ( preset $preset,
?int $userid = null )

Check if the user can view a specific preset.

Parameters
preset$presetthe preset instance.
int$useridthe user id to check ($USER->id if null).
Return values
boolif the user can view the preset.

◆ create_from_coursemodule()

static mod_data\manager::create_from_coursemodule ( $cm)
static

Create a manager instance from a course_modules record.

Parameters
stdClass | cm_info$cman activity record
Return values
manager

◆ create_from_data_record()

static mod_data\manager::create_from_data_record ( $record)
static

Create a manager instance from a data_record entry.

Parameters
stdClass$recordthe data_record record
Return values
manager

◆ create_from_instance()

static mod_data\manager::create_from_instance ( stdClass $instance)
static

Create a manager instance from an instance record.

Parameters
stdClass$instancean activity record
Return values
manager

◆ get_available_plugin_presets()

static mod_data\manager::get_available_plugin_presets ( )
static

Returns an array of all the available plugin presets.

Return values
arrayA list with the datapreset plugins.

◆ get_available_presets()

mod_data\manager::get_available_presets ( )

Returns an array of all the available presets.

Return values
arrayA list with the datapreset plugins and the presets saved by users.

◆ get_available_saved_presets()

mod_data\manager::get_available_saved_presets ( )

Returns an array of all the presets that users have saved to the site.

Return values
arrayA list with the preset saved by the users.

◆ get_context()

mod_data\manager::get_context ( )

Return the current context.

Return values
context_module

◆ get_coursemodule()

mod_data\manager::get_coursemodule ( )

Return the current cm_info.

Return values
cm_infothe course module

◆ get_field()

mod_data\manager::get_field ( stdClass $fieldrecord)

Return a specific field instance from a field record.

Parameters
stdClass$fieldrecordthe fieldrecord to convert
Return values
data_field_basethe data field class instance

◆ get_field_records()

mod_data\manager::get_field_records ( )

Return the field records (the current data_fields records).

Return values
stdClass[]an array of records

◆ get_fields()

mod_data\manager::get_fields ( )

Return the database fields.

Return values
data_field_base[]the field instances.

◆ get_instance()

mod_data\manager::get_instance ( )

Return the current instance.

Return values
stdClassthe instance record

◆ get_renderer()

mod_data\manager::get_renderer ( ?moodle_page $page = null)

Return the current module renderer.

Parameters
moodle_page | null$pagethe current page
Return values
mod_data_rendererthe module renderer

◆ get_template()

mod_data\manager::get_template ( string $templatename,
array $options = [] )

Return a specific template.

NOTE: this method returns a default template if the module template is empty. However, it won't update the template database field.

Some possible options:

  • search: string with the current searching text.
  • page: integer repesenting the current pagination page numbre (if any)
  • baseurl: a moodle_url object to the current page.
Parameters
string$templatename
array$optionsextra display options array
Return values
templatethe template instance

◆ has_fields()

mod_data\manager::has_fields ( )

Return if the database has fields.

Return values
booltrue if the database has fields

◆ has_records()

mod_data\manager::has_records ( )

Return if the database has records.

Return values
booltrue if the database has records

◆ reset_all_templates()

mod_data\manager::reset_all_templates ( )

Reset all templates.

Return values
boolif the reset is done or not

◆ reset_template()

mod_data\manager::reset_template ( string $templatename)

Reset all templates related to a specific template.

Parameters
string$templatenamethe template name
Return values
boolif the reset is done or not

◆ set_module_viewed()

mod_data\manager::set_module_viewed ( stdClass $course)

Trigger module viewed event and set the module viewed for completion.

Parameters
stdClass$coursecourse object

◆ update_templates()

mod_data\manager::update_templates ( stdClass $newtemplates)

Update the database templates.

Parameters
stdClass$newtemplatesan object with all the new templates
Return values
boolif updated successfully.

Member Data Documentation

◆ TEMPLATES_LIST

const mod_data\manager::TEMPLATES_LIST
Initial value:
= [
'listtemplate' => 'listtemplate.html',
'singletemplate' => 'singletemplate.html',
'asearchtemplate' => 'asearchtemplate.html',
'addtemplate' => 'addtemplate.html',
'rsstemplate' => 'rsstemplate.html',
'csstemplate' => 'csstemplate.css',
'jstemplate' => 'jstemplate.js',
'listtemplateheader' => 'listtemplateheader.html',
'listtemplatefooter' => 'listtemplatefooter.html',
'rsstitletemplate' => 'rsstitletemplate.html',
]

Template list with their files required to save the information of a preset.


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