Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

Search area base class for activities.

Copyright: 2016 Dan Poltawski
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 241 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

base_activity:: (8 methods):
  get_document_recordset()
  get_document()
  check_access()
  get_doc_url()
  get_context_url()
  get_activity()
  get_search_fileareas()
  attach_files()


Class: base_activity  - X-Ref

Base implementation for activity modules.

get_document_recordset($modifiedfrom = 0, \context $context = null)   X-Ref
Returns recordset containing all activities within the given context.

return: \moodle_recordset|null Recordset, or null if no possible activities in given context
param: \context|null $context Context
param: int $modifiedfrom Return only records modified after this date

get_document($record, $options = array()   X-Ref
Returns the document associated with this activity.

This default implementation for activities sets the activity name to title and the activity intro to
content. Any activity can overwrite this function if it is interested in setting other fields than the
default ones, or to fill description optional fields with extra stuff.

return: \core_search\document
param: stdClass $record
param: array    $options

check_access($id)   X-Ref
Whether the user can access the document or not.

return: bool
param: int $id The activity instance id.

get_doc_url(\core_search\document $doc)   X-Ref
Link to the module instance.

return: \moodle_url
param: \core_search\document $doc

get_context_url(\core_search\document $doc)   X-Ref
Link to the module instance.

return: \moodle_url
param: \core_search\document $doc

get_activity($instanceid)   X-Ref
Returns an activity instance. Internally uses the class component to know which activity module should be retrieved.

return: stdClass
param: int $instanceid

get_search_fileareas()   X-Ref
Return the context info required to index files for
this search area.

Should be onerridden by each search area.

return: array

attach_files($document)   X-Ref
Files related to the current document are attached,
to the document object ready for indexing by
Global Search.

The default implementation retrieves all files for
the file areas returned by get_search_fileareas().
If you need to filter files to specific items per
file area, you will need to override this method
and explicitly provide the items.

return: void
param: document $document The current document