Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

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

Defines 2 classes


Class: data_portfolio_caller  - X-Ref

The class to handle entry exports of a database module

expected_callbackargs()   X-Ref
the required callback arguments for a single-record export

return: array

__construct($callbackargs)   X-Ref

param: array $callbackargs the arguments passed through

load_data()   X-Ref
load up the data needed for the export


expected_time()   X-Ref
How long we think the export will take
Single entry is probably not too long.
But we check for filesizes
Else base it on the number of records

return: one of PORTFOLIO_TIME_XX constants

get_sha1()   X-Ref
Calculate the shal1 of this export
Dependent on the export format.

return: string

prepare_package()   X-Ref
Prepare the package for export

return: stored_file object

check_permissions()   X-Ref
Verify the user can still export this entry

return: bool

display_name()   X-Ref

return: string

__wakeup()   X-Ref

return: bool|void

exportentry($record)   X-Ref
Prepare a single entry for export, replacing all the content etc

param: stdclass $record the entry to export
return: array with key 0 = the html content, key 1 = array of attachments

formats($fields, $record)   X-Ref
Given the fields being exported, and the single record,
work out which export format(s) we can use

param: array $fields array of field objects
param: object $record The data record object
return: array of PORTFOLIO_XX constants

has_files($data)   X-Ref
No description

base_supported_formats()   X-Ref
base supported formats before we know anything about the export


has_export_config()   X-Ref
No description

export_config_form(&$mform, $instance)   X-Ref
No description

get_allowed_export_config()   X-Ref
No description

Class: data_file_info_container  - X-Ref

Class representing the virtual node with all itemids in the file browser

__construct($browser, $course, $cm, $context, $areas, $filearea)   X-Ref
Constructor (in case you did not realize it ;-)

param: file_browser $browser
param: stdClass $course
param: stdClass $cm
param: stdClass $context
param: array $areas
param: string $filearea

get_params()   X-Ref

return: array with keys contextid, filearea, itemid, filepath and filename

is_writable()   X-Ref
Can new files or directories be added via the file browser

return: bool

is_directory()   X-Ref
Should this node be considered as a folder in the file browser

return: bool

get_visible_name()   X-Ref
Returns localised visible name of this node

return: string

get_children()   X-Ref
Returns list of children nodes

return: array of file_info instances

get_filtered_children($extensions = '*', $countonly = false, $returnemptyfolders = false)   X-Ref
Help function to return files matching extensions or their count

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
param: bool|int $countonly if false returns the children, if an int returns just the
param: bool $returnemptyfolders if true returns items that don't have matching files inside
return: array|int array of file_info instances or the count

get_non_empty_children($extensions = '*')   X-Ref
Returns list of children which are either files matching the specified extensions
or folders that contain at least one such file.

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
return: array of file_info instances

count_non_empty_children($extensions = '*', $limit = 1)   X-Ref
Returns the number of children which are either files matching the specified extensions
or folders containing at least one such file.

param: string|array $extensions, for example '*' or array('.gif','.jpg')
param: int $limit stop counting after at least $limit non-empty children are found
return: int

get_parent()   X-Ref
Returns parent file_info instance

return: file_info or null for root

data_set_events($data)   X-Ref
This creates new calendar events given as timeavailablefrom and timeclose by $data.

param: stdClass $data
return: void

data_get_time_availability_status($data, $canmanageentries = null, $context = null)   X-Ref
Check if a database is available for the current user.

param: stdClass  $data            database record
param: boolean $canmanageentries  optional, if the user can manage entries
param: stdClass  $context         Module context, required if $canmanageentries is not set
return: array                      status (available or not and possible warnings)

data_require_time_available($data, $canmanageentries = null, $context = null)   X-Ref
Requires a database to be available for the current user.

param: stdClass  $data            database record
param: boolean $canmanageentries  optional, if the user can manage entries
param: stdClass  $context          Module context, required if $canmanageentries is not set

data_get_entries_left_to_add($data, $numentries, $canmanageentries)   X-Ref
Return the number of entries left to add to complete the activity.

param: stdClass $data           database object
param: int $numentries          the number of entries the current user has created
param: bool $canmanageentries   whether the user can manage entries (teachers, managers)
return: int the number of entries left, 0 if no entries left or if is not required

data_get_entries_left_to_view($data, $numentries, $canmanageentries)   X-Ref
Return the number of entires left to add to view other users entries..

param: stdClass $data           database object
param: int $numentries          the number of entries the current user has created
param: bool $canmanageentries   whether the user can manage entries (teachers, managers)
return: int the number of entries left, 0 if no entries left or if is not required

mod_data_get_tagged_records($tag, $exclusivemode = false, $fromctx = 0, $ctx = 0, $rec = true, $page = 0)   X-Ref
Returns data records tagged with a specified tag.

This is a callback used by the tag area mod_data/data_records to search for data records
tagged with a specific tag.

param: core_tag_tag $tag
param: bool $exclusivemode if set to true it means that no other entities tagged with this tag
param: int $fromctx context id where the link was displayed, may be used by callbacks
param: int $ctx context id where to search for records
param: bool $rec search in subcontexts as well
param: int $page 0-based number of page being displayed
return: \core_tag\output\tagindex

data_get_tag_title_field($dataid)   X-Ref
Get the title of a field to show when displaying tag results.

param: int $dataid The id of the data field
return: stdClass The field data from the 'data_fields' table as well as it's priority

data_get_tag_title_for_entry($field, $entry)   X-Ref
Get the title of an entry to show when displaying tag results.

param: stdClass $field The field from the 'data_fields' table
param: stdClass $entry The entry from the 'data_records' table
return: string|null It will return the title of the entry or null if the field type is not available.

data_search_entries($data, $cm, $context, $mode, $currentgroup, $search = '', $sort = null, $order = null, $page = 0,$perpage = 0, $advanced = null, $searcharray = null, $record = null)   X-Ref
Search entries in a database.

param: stdClass  $data         database object
param: stdClass  $cm           course module object
param: stdClass  $context      context object
param: stdClass  $mode         in which mode we are viewing the database (list, single)
param: int  $currentgroup      the current group being used
param: str  $search            search for this text in the entry data
param: str  $sort              the field to sort by
param: str  $order             the order to use when sorting
param: int $page               for pagination, the current page
param: int $perpage            entries per page
param: bool  $advanced         whether we are using or not advanced search
param: array  $searcharray     when using advanced search, the advanced data to use
param: stdClass  $record       if we jsut want this record after doing all the access checks
return: array the entries found among other data related to the search

data_can_view_record($data, $record, $currentgroup, $canmanageentries)   X-Ref
Check if the current user can view the given record.

param: stdClass $data           database record
param: stdClass $record         the record (entry) to check
param: int $currentgroup        current group
param: bool $canmanageentries   if the user can manage entries
return: bool true if the user can view the entry

data_get_field_instances($data)   X-Ref
Return all the field instances for a given database.

param: stdClass $data database object
return: array field instances

data_build_search_array($data, $paging, $searcharray, $defaults = null, $fn = '', $ln = '')   X-Ref
Build the search array.

param: stdClass $data      the database object
param: bool $paging        if paging is being used
param: array $searcharray  the current search array (saved by session)
param: array $defaults     default values for the searchable fields
param: str $fn             the first name to search (optional)
param: str $ln             the last name to search (optional)
return: array               the search array and plain search build based on the different elements

data_approve_entry($entryid, $approve)   X-Ref
Approves or unapproves an entry.

param: int $entryid the entry to approve or unapprove.
param: bool $approve Whether to approve or unapprove (true for approve false otherwise).

data_add_fields_contents_to_new_record($data, $context, $recordid, $fields, $datarecord, $processeddata)   X-Ref
Populate the field contents of a new record with the submitted data.
An event has been previously triggered upon the creation of the new record in data_add_record().

param: stdClass $data           database object
param: stdClass $context        context object
param: int $recordid            the new record id
param: array $fields            list of fields of the database
param: stdClass $datarecord     the submitted data
param: stdClass $processeddata  pre-processed submitted fields

data_update_record_fields_contents($data, $record, $context, $datarecord, $processeddata)   X-Ref
Updates the fields contents of an existing record.

param: stdClass $data           database object
param: stdClass $record         record to update object
param: stdClass $context        context object
param: stdClass $datarecord     the submitted data
param: stdClass $processeddata  pre-processed submitted fields