See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
Search area base class for areas working at module level.
Copyright: | 2015 David Monllao {@link http://www.davidmonllao.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 308 lines (12 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
base_mod:: (9 methods):
get_module_name()
get_cm()
get_context_restriction_sql()
get_contexts_to_reindex_extra_sql()
get_contexts_to_reindex()
supports_group_restriction()
restrict_cm_access_by_group()
get_doc_icon()
get_category_names()
get_module_name() X-Ref |
Returns the module name. return: string |
get_cm($modulename, $instanceid, $courseid) X-Ref |
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. param: string $modulename The module name param: int $instanceid Module instance id (depends on the module) param: int $courseid Helps speeding up things return: \cm_info |
get_context_restriction_sql(?\context $context, $modname, $modtable,$paramtype = SQL_PARAMS_QM) X-Ref |
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. param: \context|null $context Context to restrict the query param: string $modname Name of module e.g. 'forum' param: string $modtable Alias of table containing module id param: int $paramtype Type of SQL parameters to use (default question mark) return: array Array with SQL and parameters; both null if no need to query |
get_contexts_to_reindex_extra_sql() X-Ref |
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: string[] Array with 2 elements; extra joins for the query, and ORDER BY value |
get_contexts_to_reindex() X-Ref |
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). return: \Iterator Iterator of contexts to reindex |
supports_group_restriction() X-Ref |
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: bool |
restrict_cm_access_by_group(\cm_info $cm) X-Ref |
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. param: \cm_info $cm return: bool True to restrict by group |
get_doc_icon(document $doc) X-Ref |
Returns an icon instance for the document. param: \core_search\document $doc return: \core_search\document_icon |
get_category_names() X-Ref |
Returns a list of category names associated with the area. return: array |