|
| get_cm ($modulename, $instanceid, $courseid) |
| Gets the course module for the required instanceid + modulename.
|
|
| get_context_restriction_sql (?\context $context, $modname, $modtable, $paramtype=SQL_PARAMS_QM) |
| Helper function that gets SQL useful for restricting a search query given a passed-in context.
|
|
| get_contexts_to_reindex_extra_sql () |
| This can be used in subclasses to change ordering within the get_contexts_to_reindex function.
|
|
| get_course_level_context_restriction_sql (?\context $context, $coursetable, $paramtype=SQL_PARAMS_QM) |
| Helper function that gets SQL useful for restricting a search query given a passed-in context, for data stored at course level.
|
|
| get_entry ($entryid) |
| Returns the specified glossary entry checking the internal cache.
|
|
| get_module_name () |
| Returns the module name.
|
|
core_search\base::attach_files |
( |
| $document | ) |
|
|
inherited |
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.
- Parameters
-
document | $document | The current document |
- Return values
-
Reimplemented in block_html\search\content, core_search\base_activity, mod_data\search\entry, and mod_forum\search\post.
core_search\base_mod::get_context_restriction_sql |
( |
?\context | $context, |
|
|
| $modname, |
|
|
| $modtable, |
|
|
| $paramtype = SQL_PARAMS_QM ) |
|
protectedinherited |
Helper function that gets SQL useful for restricting a search query given a passed-in context.
The SQL returned will be zero or more JOIN statements, surrounded by whitespace, which act as restrictions on the query based on the rows in a module table.
You can pass in a null or system context, which will both return an empty string and no params.
Returns an array with two nulls if there can be no results for the activity within this context (e.g. it is a block context).
If named parameters are used, these will be named gcrs0, gcrs1, etc. The table aliases used in SQL also all begin with gcrs, to avoid conflicts.
- Parameters
-
context | null | $context | Context to restrict the query |
string | $modname | Name of module e.g. 'forum' |
string | $modtable | Alias of table containing module id |
int | $paramtype | Type of SQL parameters to use (default question mark) |
- Return values
-
array | Array with SQL and parameters; both null if no need to query |
- Exceptions
-
coding_exception | If called with invalid params |
core_search\base_mod::get_contexts_to_reindex_extra_sql |
( |
| ) |
|
|
protectedinherited |
This can be used in subclasses to change ordering within the get_contexts_to_reindex function.
It returns 2 values:
- Extra SQL joins (tables course_modules 'cm' and context 'x' already exist).
- An ORDER BY value which must use aggregate functions, by default 'MAX(cm.added) DESC'.
Note the query already includes a GROUP BY on the context fields, so if your joins result in multiple rows, you can use aggregate functions in the ORDER BY. See forum for an example.
- Return values
-
string[] | Array with 2 elements; extra joins for the query, and ORDER BY value |
Reimplemented in mod_forum\search\post.
core_search\base::get_course_level_context_restriction_sql |
( |
?\context | $context, |
|
|
| $coursetable, |
|
|
| $paramtype = SQL_PARAMS_QM ) |
|
protectedinherited |
Helper function that gets SQL useful for restricting a search query given a passed-in context, for data stored at course level.
The SQL returned will be zero or more JOIN statements, surrounded by whitespace, which act as restrictions on the query based on the rows in a module table.
You can pass in a null or system context, which will both return an empty string and no params.
Returns an array with two nulls if there can be no results for a course within this context.
If named parameters are used, these will be named gclcrs0, gclcrs1, etc. The table aliases used in SQL also all begin with gclcrs, to avoid conflicts.
- Parameters
-
context | null | $context | Context to restrict the query |
string | $coursetable | Name of alias for course table e.g. 'c' |
int | $paramtype | Type of SQL parameters to use (default question mark) |
- Return values
-
array | Array with SQL and parameters; both null if no need to query |
- Exceptions
-
coding_exception | If called with invalid params |
core_search\base::get_recordset_by_timestamp |
( |
| $modifiedfrom = 0 | ) |
|
|
inherited |
Returns a recordset ordered by modification date ASC.
Each record can include any data self::get_document might need but it must:
- Include an 'id' field: Unique identifier (in this area's scope) of a document to index in the search engine If the indexed content field can contain embedded files, the 'id' value should match the filearea itemid.
- Only return data modified since $modifiedfrom, including $modifiedform to prevent some records from not being indexed (e.g. your-timemodified-fieldname >= $modifiedfrom)
- Order the returned data by time modified in ascending order, as core_search\manager will need to store the modified time of the last indexed document.
Since Moodle 3.4, subclasses should instead implement get_document_recordset, which has an additional context parameter. This function continues to work for implementations which haven't been updated, or where the context parameter is not required.
- Parameters
-
- Return values
-
core_search\base_mod::restrict_cm_access_by_group |
( |
\cm_info | $cm | ) |
|
|
inherited |
Checks whether the content of this search area should be restricted by group for a specific module.
Called at query time.
The default behaviour simply checks if the effective group mode is SEPARATEGROUPS, which is probably correct for most cases.
If restricted by group, the search query will (where supported by the engine) filter out results for groups the user does not belong to, unless the user has 'access all groups' for the activity. This affects only documents which set the 'groupid' field; results with no groupid will not be restricted.
Even if you return true to this function, you may still need to do group access checks in check_access, because the search engine may not support group restrictions.
- Parameters
-
- Return values
-
bool | True to restrict by group |
core_search\base_mod::supports_group_restriction |
( |
| ) |
|
|
inherited |
Indicates whether this search area may restrict access by group.
This should return true if the search area (sometimes) sets the 'groupid' schema field, and false if it never sets that field.
(If this function returns false, but the field is set, then results may be restricted unintentionally.)
If this returns true, the search engine will automatically apply group restrictions in some cases (by default, where a module is configured to use separate groups). See function restrict_cm_access_by_group().
- Return values
-
Reimplemented in mod_data\search\entry, mod_forum\search\post, and mod_wiki\search\collaborative_page.