Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Forum posts search area. More...
Public Member Functions | |
attach_files ($document) | |
Add the forum post attachments. | |
check_access ($id) | |
Whether the user can access the document or not. | |
get_area_id () | |
Returns the area id. | |
get_category_names () | |
Returns a list of category names associated with the area. | |
get_component_name () | |
Returns the moodle component name. | |
get_component_type () | |
Returns the component type. | |
get_config () | |
Returns all the search area configuration. | |
get_config_var_name () | |
Returns the config var name. | |
get_context_url (\core_search\document $doc) | |
Returns a url to the document context. | |
get_context_url (\core_search\document $doc) | |
Link to the forum. | |
get_contexts_to_reindex () | |
Gets a list of all contexts to reindex when reindexing this search area. | |
get_doc_icon (document $doc) | |
Returns an icon instance for the document. | |
get_doc_url (\core_search\document $doc) | |
Returns a url to the document, it might match self\get_context_url(). | |
get_doc_url (\core_search\document $doc) | |
Link to the forum post discussion. | |
get_document ($record, $options=array()) | |
Returns the document associated with this post id. | |
get_document_display_title (\core_search\document $doc) | |
Returns the document title to display. | |
get_document_recordset ($modifiedfrom=0, context $context=null) | |
Returns recordset containing required data for indexing forum posts. | |
get_last_indexing_duration () | |
Gets the length of time spent indexing this area (the last time it was indexed). | |
get_recordset_by_timestamp ($modifiedfrom=0) | |
Returns a recordset ordered by modification date ASC. | |
get_search_fileareas () | |
Return the context info required to index files for this search area. | |
get_visible_name ($lazyload=false) | |
Returns the area visible name. | |
is_enabled () | |
Is the search component enabled by the system administrator? | |
restrict_cm_access_by_group (\cm_info $cm) | |
Checks whether the content of this search area should be restricted by group for a specific module. | |
set_enabled ($isenabled) | |
supports_get_document_recordset () | |
Checks if get_document_recordset is supported for this search area. | |
supports_group_restriction () | |
Confirms that data entries support group restrictions. | |
uses_file_indexing () | |
Returns true if this area uses file indexing. | |
Static Public Member Functions | |
static | get_levels () |
Returns context levels property. | |
static | get_settingnames () |
Return a list of all required setting names. | |
Public Attributes | |
string | $areaid |
An area id from the componentname and the area name. | |
Protected Member Functions | |
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 () | |
Changes the context ordering so that the forums with most recent discussions are indexed first. | |
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_discussion ($discussionid) | |
Returns the discussion checking the internal cache. | |
get_forum ($forumid) | |
Returns the specified forum checking the internal cache. | |
get_module_name () | |
Returns the module name. | |
get_post ($postid) | |
Returns the specified forum post from its internal cache. | |
Static Protected Attributes | |
static array | $levels = [CONTEXT_MODULE] |
The context levels the search area is working on. | |
Forum posts search area.
mod_forum\search\post::attach_files | ( | $document | ) |
Add the forum post attachments.
document | $document | The current document |
null |
Reimplemented from core_search\base.
mod_forum\search\post::check_access | ( | $id | ) |
Whether the user can access the document or not.
dml_missing_record_exception | |
dml_exception |
int | $id | Forum post id |
bool |
Reimplemented from core_search\base.
|
inherited |
Returns the area id.
string |
|
inherited |
Returns a list of category names associated with the area.
array |
Reimplemented from core_search\base.
|
protectedinherited |
Gets the course module for the required instanceid + modulename.
The returned data depends on the logged user, when calling this through self\get_document the admin user is used so everything would be returned.
No need more internal caching here, modinfo is already cached.
dml_missing_record_exception |
string | $modulename | The module name |
int | $instanceid | Module instance id (depends on the module) |
int | $courseid | Helps speeding up things |
cm_info |
|
inherited |
Returns the moodle component name.
It might be the plugin name (whole frankenstyle name) or the core subsystem name.
string |
Reimplemented in core_course\search\course, core_course\search\customfield, core_course\search\section, core_user\search\course_teacher, and core_user\search\user.
|
inherited |
Returns the component type.
It might be a plugintype or 'core' for core subsystems.
string |
|
inherited |
Returns all the search area configuration.
array |
|
inherited |
Returns the config var name.
It depends on whether it is a moodle subsystem or a plugin as plugin-related config should remain in their own scope.
string | Config var path including the plugin (or component) and the varname |
|
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.
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) |
array | Array with SQL and parameters; both null if no need to query |
coding_exception | If called with invalid params |
|
abstractinherited |
Returns a url to the document context.
core_search\document | $doc |
moodle_url |
Reimplemented in core_search\base_activity, and core_search\base_block.
mod_forum\search\post::get_context_url | ( | \core_search\document | $doc | ) |
|
inherited |
Gets a list of all contexts to reindex when reindexing this search area.
For modules, the default is to return all contexts for modules of that type, in order of time added (most recent first).
Iterator | Iterator of contexts to reindex |
moodle_exception | If any DB error |
Reimplemented from core_search\base.
|
protected |
Changes the context ordering so that the forums with most recent discussions are indexed first.
string[] | SQL join and ORDER BY |
Reimplemented from core_search\base_mod.
|
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.
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) |
array | Array with SQL and parameters; both null if no need to query |
coding_exception | If called with invalid params |
|
protected |
Returns the discussion checking the internal cache.
dml_missing_record_exception |
int | $discussionid |
stdClass |
|
inherited |
Returns an icon instance for the document.
core_search\document | $doc |
core_search\document_icon |
Reimplemented from core_search\base.
|
abstractinherited |
Returns a url to the document, it might match self\get_context_url().
core_search\document | $doc |
moodle_url |
Reimplemented in core_search\base_activity, and core_search\base_block.
mod_forum\search\post::get_doc_url | ( | \core_search\document | $doc | ) |
mod_forum\search\post::get_document | ( | $record, | |
$options = array() ) |
Returns the document associated with this post id.
stdClass | $record | Post info. |
array | $options |
core_search\document |
Reimplemented from core_search\base.
|
inherited |
Returns the document title to display.
Allow to customize the document title string to display.
core_search\document | $doc |
string | Document title to display in the search results page |
mod_forum\search\post::get_document_recordset | ( | $modifiedfrom = 0, | |
context | $context = null ) |
Returns recordset containing required data for indexing forum posts.
int | $modifiedfrom | timestamp |
context | null | $context | Optional context to restrict scope of returned results |
moodle_recordset|null | Recordset (or null if no results) |
Reimplemented from core_search\base.
|
protected |
Returns the specified forum checking the internal cache.
Store minimal information as this might grow.
dml_exception |
int | $forumid |
stdClass |
|
inherited |
Gets the length of time spent indexing this area (the last time it was indexed).
int|bool | Time in seconds spent indexing this area last time, false if never indexed |
|
staticinherited |
Returns context levels property.
int |
|
protectedinherited |
Returns the module name.
string |
|
protected |
Returns the specified forum post from its internal cache.
dml_missing_record_exception |
int | $postid |
stdClass |
|
inherited |
Returns a recordset ordered by modification date ASC.
Each record can include any data self\get_document might need but it must:
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.
int | $modifiedfrom |
moodle_recordset |
mod_forum\search\post::get_search_fileareas | ( | ) |
Return the context info required to index files for this search area.
array |
Reimplemented from core_search\base.
|
staticinherited |
Return a list of all required setting names.
array |
|
inherited |
Returns the area visible name.
bool | $lazyload | Usually false, unless when in admin settings. |
string |
|
inherited |
Is the search component enabled by the system administrator?
bool |
|
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.
cm_info | $cm |
bool | True to restrict by group |
|
inherited |
Checks if get_document_recordset is supported for this search area.
For many uses you can simply call get_document_recordset and see if it returns false, but this function is useful when you don't want to actually call the function right away.
mod_forum\search\post::supports_group_restriction | ( | ) |
Confirms that data entries support group restrictions.
bool | True |
Reimplemented from core_search\base_mod.
mod_forum\search\post::uses_file_indexing | ( | ) |
Returns true if this area uses file indexing.
bool |
Reimplemented from core_search\base.
|
staticprotectedinherited |
The context levels the search area is working on.
This can be overwriten by the search area if it works at multiple levels.