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.
/mod/label/ -> lib.php (source)

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]

Library of functions and constants for module label

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 383 lines (14 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 12 functions


Functions that are not part of a class:

get_label_name($label)   X-Ref

param: object $label
return: string

label_add_instance($label)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod_form.php) this function
will create a new instance and return the id number
of the new instance.

param: object $label
return: bool|int

label_update_instance($label)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod_form.php) this function
will update an existing instance with new data.

param: object $label
return: bool

label_delete_instance($id)   X-Ref
Given an ID of an instance of this module,
this function will permanently delete the instance
and any data that depends on it.

param: int $id
return: bool

label_get_coursemodule_info($coursemodule)   X-Ref
Given a course_module object, this function returns any
"extra" information that may be needed when printing
this activity in a course listing.
See get_array_of_activities() in course/lib.php

param: object $coursemodule
return: cached_cm_info|null

label_reset_userdata($data)   X-Ref
This function is used by the reset_course_userdata function in moodlelib.

param: object $data the data submitted from the reset course.
return: array status array

label_supports($feature)   X-Ref

param: string $feature FEATURE_xx constant for requested feature
return: bool|null True if module supports feature, false if not, null if doesn't know

label_dndupload_register()   X-Ref
Register the ability to handle drag and drop file uploads

return: array containing details of the files / types the mod can handle

label_dndupload_handle($uploadinfo)   X-Ref
Handle a file that has been uploaded

param: object $uploadinfo details of the file / content that has been uploaded
return: int instance id of the newly created mod

label_generate_resized_image(stored_file $file, $maxwidth, $maxheight)   X-Ref
Resize the image, if required, then generate an img tag and, if required, a link to the full-size image

param: stored_file $file the image file to process
param: int $maxwidth the maximum width allowed for the image
param: int $maxheight the maximum height allowed for the image
return: string HTML fragment to add to the label

label_check_updates_since(cm_info $cm, $from, $filter = array()   X-Ref
Check if the module has any update that affects the current user since a given time.

param: cm_info $cm course module data
param: int $from the time to check updates from
param: array $filter  if we need to check only specific updates
return: stdClass an object with the different type of areas indicating if they were updated or not

mod_label_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory,int $userid = 0)   X-Ref
This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
is not displayed on the block.

param: calendar_event $event
param: \core_calendar\action_factory $factory
param: int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).
return: \core_calendar\local\event\entities\action_interface|null