Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 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.

Differences Between: [Versions 310 and 402] [Versions 310 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.

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

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.

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

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

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

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

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

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

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

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

param: int $instanceid
return: stdClass

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.

param: document $document The current document
return: void