Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Public Member Functions | |
__construct (course_modinfo $modinfo, $notused1, $mod, $notused2) | |
Constructor should not be called directly; use get_fast_modinfo(). | |
__call ($name, $arguments) | |
Magic method to call functions that are now declared as private but were public in Moodle before 2.6. | |
__empty ($name) | |
Magic method for function empty() | |
__get ($name) | |
Magic method getter. | |
__isset ($name) | |
Magic method for function isset() | |
__set ($name, $value) | |
Magic method setter. | |
get_activitybadge (?renderer_base $output=null) | |
Get the activity badge data associated to this course module (if the module supports it). | |
get_course () | |
Returns course object that was used in the first get_fast_modinfo() call. | |
get_course_module_record ($additionalfields=false) | |
Returns itself in the form of stdClass. | |
get_custom_data () | |
Getter method for property $customdata, ensures that dynamic data is retrieved. | |
get_formatted_content ($options=array()) | |
Returns the content to display on course/overview page, formatted and passed through filters. | |
get_formatted_name ($options=array()) | |
Returns the name to display on course/overview page, formatted and passed through filters. | |
get_grouping_label ($textclasses='') | |
get_icon_url ($output=null) | |
Fetch the module's icon URL. | |
get_modinfo () | |
get_module_type_name ($plural=false) | |
Returns a localised human-readable name of the module type. | |
get_name () | |
Getter method for property $name, ensures that dynamic data is obtained. | |
get_section_info () | |
Returns the section this module belongs to. | |
get_url () | |
Gets the URL to link to for this module. | |
get_user_visible () | |
Getter method for property $uservisible, ensures that dynamic data is retrieved. | |
getIterator () | |
Implementation of IteratorAggregate\getIterator(), allows to cycle through properties and use convert_to_array(). | |
has_custom_cmlist_item () | |
Return the module custom cmlist item flag. | |
has_view () | |
is_stealth () | |
Whether this module is available but hidden from course page. | |
is_user_access_restricted_by_capability () | |
Checks whether mod/...:view capability restricts the current user's access. | |
is_user_access_restricted_by_conditional_access () | |
Checks whether the module's conditional access settings mean that the user cannot see the activity at all. | |
is_user_access_restricted_by_group () | |
This method has been deprecated and should not be used. | |
is_visible_on_course_page () | |
Returns whether this module is visible to the current user on course page. | |
override_customdata ($name, $value) | |
Overrides the value of an element in the customdata array. | |
set_after_edit_icons ($afterediticons) | |
Sets HTML that displays after edit icons on course view page. | |
set_after_link ($afterlink) | |
Sets HTML that displays after link on course view page. | |
set_available ($available, $showavailability=0, $availableinfo='') | |
Sets the 'available' flag and related details. | |
set_content ($content, $isformatted=false) | |
Sets content to display on course view page below link (if present). | |
set_custom_cmlist_item (bool $customcmlistitem) | |
Sets the 'customcmlistitem' flag. | |
set_extra_classes ($extraclasses) | |
Sets extra classes to include in CSS. | |
set_icon_url (moodle_url $iconurl) | |
Sets the external full url that points to the icon being used by the activity. | |
set_name ($name) | |
Changes the name (text of link) for this module instance. | |
set_no_view_link () | |
Turns off the view link for this module instance. | |
set_on_click ($onclick) | |
Sets value of on-click attribute for JavaScript. | |
set_user_visible ($uservisible) | |
Sets the 'uservisible' flag. | |
Static Public Member Functions | |
static | create ($cm, $userid=0) |
Creates a cm_info object from a database record (also accepts cm_info in which case it is just returned unchanged). | |
cm_info::__construct | ( | course_modinfo | $modinfo, |
$notused1, | |||
$mod, | |||
$notused2 ) |
Constructor should not be called directly; use get_fast_modinfo().
course_modinfo | $modinfo | Parent object |
mixed | $notused1 | Argument not used |
stdClass | $mod | Module object from the modinfo field of course table |
mixed | $notused2 | Argument not used |
cm_info::__call | ( | $name, | |
$arguments ) |
Magic method to call functions that are now declared as private but were public in Moodle before 2.6.
These private methods can not be used anymore.
string | $name | |
array | $arguments |
mixed |
coding_exception |
cm_info::__empty | ( | $name | ) |
Magic method for function empty()
string | $name |
bool |
cm_info::__get | ( | $name | ) |
Magic method getter.
string | $name |
mixed |
cm_info::__isset | ( | $name | ) |
Magic method for function isset()
string | $name |
bool |
cm_info::__set | ( | $name, | |
$value ) |
Magic method setter.
Will display the developer warning when trying to set/overwrite property.
string | $name | |
mixed | $value |
|
static |
Creates a cm_info object from a database record (also accepts cm_info in which case it is just returned unchanged).
stdClass | cm_info | null | bool | $cm | Stdclass or cm_info (or null or false) |
int | $userid | Optional userid (default to current) |
cm_info|null | Object as cm_info, or null if input was null/false |
cm_info::get_activitybadge | ( | ?renderer_base | $output = null | ) |
Get the activity badge data associated to this course module (if the module supports it).
Modules can use this method to provide additional data to be displayed in the activity badge.
renderer_base | $output | Output render to use, or null for default (global) |
stdClass|null | The activitybadge data (badgecontent, badgestyle...) or null if the module doesn't implement it. |
cm_info::get_course | ( | ) |
Returns course object that was used in the first get_fast_modinfo() call.
It may not contain all fields from DB table {course} but always has at least the following: id,shortname,fullname,format,enablecompletion,groupmode,groupmodeforce,cacherev
If the course object lacks the field you need you can use the global function get_course() that will save extra query if you access current course or frontpage course.
stdClass |
cm_info::get_course_module_record | ( | $additionalfields = false | ) |
Returns itself in the form of stdClass.
The object includes all fields that table course_modules has and additionally fields 'name', 'modname', 'sectionnum' (if requested).
This can be used as a faster alternative to get_coursemodule_from_id()
bool | $additionalfields | include additional fields 'name', 'modname', 'sectionnum' |
stdClass |
cm_info::get_custom_data | ( | ) |
Getter method for property $customdata, ensures that dynamic data is retrieved.
This method is normally called by the property ->customdata, but can be called directly if there is a case when it might be called recursively (you can't call property values recursively).
mixed | Optional custom data stored in modinfo cache for this activity, or null if none |
cm_info::get_formatted_content | ( | $options = array() | ) |
Returns the content to display on course/overview page, formatted and passed through filters.
if $options['context'] is not specified, the module context is used
array | stdClass | $options | formatting options, see format_text() |
string |
cm_info::get_formatted_name | ( | $options = array() | ) |
Returns the name to display on course/overview page, formatted and passed through filters.
if $options['context'] is not specified, the module context is used
array | stdClass | $options | formatting options, see format_string() |
string |
cm_info::get_grouping_label | ( | $textclasses = '' | ) |
string | $textclasses | additionnal classes for grouping label |
string | An empty string or HTML grouping label span tag |
cm_info::get_icon_url | ( | $output = null | ) |
Fetch the module's icon URL.
This function fetches the course module instance's icon URL. This method adds a filtericon
parameter in the URL when rendering the monologo version of the course module icon or when the plugin declares, via its filtericon
custom data, that the icon needs to be filtered. This additional information can be used by plugins when rendering the module icon to determine whether to apply CSS filtering to the icon.
core_renderer | $output | Output render to use, or null for default (global) |
moodle_url | Icon URL for a suitable icon to put beside this cm |
cm_info::get_modinfo | ( | ) |
course_modinfo | Modinfo object that this came from |
cm_info::get_module_type_name | ( | $plural = false | ) |
Returns a localised human-readable name of the module type.
bool | $plural | If true, the function returns the plural form of the name. |
?lang_string |
cm_info::get_name | ( | ) |
Getter method for property $name, ensures that dynamic data is obtained.
This method is normally called by the property ->name, but can be called directly if there is a case when it might be called recursively (you can't call property values recursively).
string |
cm_info::get_section_info | ( | ) |
Returns the section this module belongs to.
section_info |
cm_info::get_url | ( | ) |
Gets the URL to link to for this module.
This method is normally called by the property ->url, but can be called directly if there is a case when it might be called recursively (you can't call property values recursively).
moodle_url | URL to link to for this module, or null if it doesn't have a view page |
cm_info::get_user_visible | ( | ) |
Getter method for property $uservisible, ensures that dynamic data is retrieved.
This method is normally called by the property ->uservisible, but can be called directly if there is a case when it might be called recursively (you can't call property values recursively).
bool |
cm_info::getIterator | ( | ) |
Implementation of IteratorAggregate\getIterator(), allows to cycle through properties and use convert_to_array().
ArrayIterator |
cm_info::has_custom_cmlist_item | ( | ) |
Return the module custom cmlist item flag.
Activities like label uses this flag to indicate that it should be displayed as a custom course item instead of a tipical activity card.
bool |
cm_info::has_view | ( | ) |
bool | True if this module has a 'view' page that should be linked to in navigation etc (note: modules may still have a view.php file, but return false if this is not intended to be linked to from 'normal' parts of the interface; this is what label does). |
cm_info::is_stealth | ( | ) |
Whether this module is available but hidden from course page.
"Stealth" modules are the ones that are not shown on course page but available by following url. They are normally also displayed in grade reports and other reports. Module will be stealth either if visibleoncoursepage=0 or it is a visible module inside the hidden section.
bool |
cm_info::is_user_access_restricted_by_capability | ( | ) |
Checks whether mod/...:view capability restricts the current user's access.
bool | True if the user access is restricted. |
cm_info::is_user_access_restricted_by_conditional_access | ( | ) |
Checks whether the module's conditional access settings mean that the user cannot see the activity at all.
cm_info::is_user_access_restricted_by_group | ( | ) |
This method has been deprecated and should not be used.
cm_info::is_visible_on_course_page | ( | ) |
Returns whether this module is visible to the current user on course page.
Activity may be visible on the course page but not available, for example when it is hidden conditionally but the condition information is displayed.
bool |
cm_info::override_customdata | ( | $name, | |
$value ) |
Overrides the value of an element in the customdata array.
string | $name | The key in the customdata array |
mixed | $value | The value |
cm_info::set_after_edit_icons | ( | $afterediticons | ) |
Sets HTML that displays after edit icons on course view page.
string | $afterediticons | HTML string (empty string if none) |
void |
cm_info::set_after_link | ( | $afterlink | ) |
Sets HTML that displays after link on course view page.
string | $afterlink | HTML string (empty string if none) |
void |
cm_info::set_available | ( | $available, | |
$showavailability = 0, | |||
$availableinfo = '' ) |
Sets the 'available' flag and related details.
This flag is normally used to make course modules unavailable until a certain date or condition is met. (When a course module is unavailable, it is still visible to users who have viewhiddenactivities permission.)
When this is function is called, user-visible status is recalculated automatically.
The $showavailability flag does not really do anything any more, but is retained for backward compatibility. Setting this to false will cause $availableinfo to be ignored.
Note: May not be called from _cm_info_view (only _cm_info_dynamic).
bool | $available | False if this item is not 'available' |
int | $showavailability | 0 = do not show this item at all if it's not available, 1 = show this item greyed out with the following message |
string | $availableinfo | Information about why this is not available, or empty string if not displaying |
void |
cm_info::set_content | ( | $content, | |
$isformatted = false ) |
Sets content to display on course view page below link (if present).
string | $content | New content as HTML string (empty string if none) |
bool | $isformatted | Whether user content is already passed through format_text/format_string and should not be formatted again. This can be useful when module adds interactive elements on top of formatted user text. |
void |
cm_info::set_custom_cmlist_item | ( | bool | $customcmlistitem | ) |
Sets the 'customcmlistitem' flag.
This can be used (by setting true) to prevent the course from rendering the activity item as a regular activity card. This is applied to activities like labels.
bool | $customcmlistitem | if the cmlist item of that activity has a special dysplay other than a card. |
cm_info::set_extra_classes | ( | $extraclasses | ) |
Sets extra classes to include in CSS.
string | $extraclasses | Extra classes (empty string if none) |
void |
cm_info::set_icon_url | ( | moodle_url | $iconurl | ) |
Sets the external full url that points to the icon being used by the activity.
Useful for external-tool modules (lti...) If set, takes precedence over $icon and $iconcomponent
moodle_url | $iconurl | full external url pointing to icon image for activity |
void |
cm_info::set_name | ( | $name | ) |
Changes the name (text of link) for this module instance.
Note: May not be called from _cm_info_view (only _cm_info_dynamic).
string | $name | Name of activity / link text |
void |
cm_info::set_no_view_link | ( | ) |
Turns off the view link for this module instance.
Note: May not be called from _cm_info_view (only _cm_info_dynamic).
void |
cm_info::set_on_click | ( | $onclick | ) |
Sets value of on-click attribute for JavaScript.
Note: May not be called from _cm_info_view (only _cm_info_dynamic).
string | $onclick | New onclick attribute which should be HTML-escaped (empty string if none) |
void |
cm_info::set_user_visible | ( | $uservisible | ) |
Sets the 'uservisible' flag.
This can be used (by setting false) to prevent access and display of this module link for the current user. Note: May not be called from _cm_info_view (only _cm_info_dynamic).
bool | $uservisible |
void |