Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Public Member Functions | |
__construct (course_modinfo $modinfo, $notused1, $mod, $notused2) | |
Constructor should not be called directly; use get_fast_modinfo(). More... | |
__call ($name, $arguments) | |
Magic method to call functions that are now declared as private but were public in Moodle before 2.6. More... | |
__empty ($name) | |
Magic method for function empty() More... | |
__get ($name) | |
Magic method getter. More... | |
__isset ($name) | |
Magic method for function isset() More... | |
__set ($name, $value) | |
Magic method setter. More... | |
get_course () | |
Returns course object that was used in the first get_fast_modinfo() call. More... | |
get_course_module_record ($additionalfields=false) | |
Returns itself in the form of stdClass. More... | |
get_formatted_content ($options=array()) | |
Returns the content to display on course/overview page, formatted and passed through filters. More... | |
get_formatted_name ($options=array()) | |
Returns the name to display on course/overview page, formatted and passed through filters. More... | |
get_grouping_label ($textclasses='') | |
get_icon_url ($output=null) | |
get_modinfo () | |
get_module_type_name ($plural=false) | |
Returns a localised human-readable name of the module type. More... | |
get_section_info () | |
Returns the section this module belongs to. More... | |
getIterator () | |
Implementation of IteratorAggregate::getIterator(), allows to cycle through properties and use convert_to_array(). More... | |
has_view () | |
is_stealth () | |
Whether this module is available but hidden from course page. More... | |
is_user_access_restricted_by_capability () | |
Checks whether mod/...:view capability restricts the current user's access. More... | |
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. More... | |
is_user_access_restricted_by_group () | |
This method has been deprecated and should not be used. More... | |
is_visible_on_course_page () | |
Returns whether this module is visible to the current user on course page. More... | |
set_after_edit_icons ($afterediticons) | |
Sets HTML that displays after edit icons on course view page. More... | |
set_after_link ($afterlink) | |
Sets HTML that displays after link on course view page. More... | |
set_available ($available, $showavailability=0, $availableinfo='') | |
Sets the 'available' flag and related details. More... | |
set_content ($content, $isformatted=false) | |
Sets content to display on course view page below link (if present). More... | |
set_extra_classes ($extraclasses) | |
Sets extra classes to include in CSS. More... | |
set_icon_url (moodle_url $iconurl) | |
Sets the external full url that points to the icon being used by the activity. More... | |
set_name ($name) | |
Changes the name (text of link) for this module instance. More... | |
set_no_view_link () | |
Turns off the view link for this module instance. More... | |
set_on_click ($onclick) | |
Sets value of on-click attribute for JavaScript. More... | |
set_user_visible ($uservisible) | |
Sets the 'uservisible' flag. More... | |
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). More... | |
Public Attributes | |
const | STATE_BASIC = 0 |
State: Only basic data from modinfo cache is available. | |
const | STATE_BUILDING_DYNAMIC = 1 |
State: In the process of building dynamic data (to avoid recursive calls to obtain_dynamic_data()) | |
const | STATE_BUILDING_VIEW = 3 |
State: In the process of building view data (to avoid recursive calls to obtain_view_data()) | |
const | STATE_DYNAMIC = 2 |
State: Dynamic data is available too. | |
const | STATE_VIEW = 4 |
State: View data (for course page) is available. | |
cm_info::__construct | ( | course_modinfo | $modinfo, |
$notused1, | |||
$mod, | |||
$notused2 | |||
) |
Constructor should not be called directly; use get_fast_modinfo().
course_modinfo | $modinfo | Parent object |
stdClass | $notused1 | Argument not used |
stdClass | $mod | Module object from the modinfo field of course table |
stdClass | $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_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_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 | ) |
moodle_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 | return plural form |
string |
cm_info::get_section_info | ( | ) |
Returns the section this module belongs to.
section_info |
cm_info::getIterator | ( | ) |
Implementation of IteratorAggregate::getIterator(), allows to cycle through properties and use convert_to_array().
ArrayIterator |
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::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_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 |