Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

This file contains components used by the restore UI

Copyright: 2010 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 433 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 classes

restore_search_base:: (10 methods):
  __construct()
  get_url()
  get_search()
  get_count()
  get_results()
  set_url()
  invalidate_results()
  require_capability()
  search()
  has_more_results()

restore_course_search:: (7 methods):
  __construct()
  setup_restrictions()
  get_searchsql()
  get_itemcontextlevel()
  format_results()
  get_varsearch()
  set_include_currentcourse()

restore_category_search:: (5 methods):
  __construct()
  get_searchsql()
  get_itemcontextlevel()
  format_results()
  get_varsearch()


Class: restore_search_base  - X-Ref

A base class that can be used to build a specific search upon

__construct(array $config = array()   X-Ref
Constructor

param: array $config Config options

get_url()   X-Ref
The URL for this search

return: moodle_url The URL for this page

get_search()   X-Ref
The current search string

return: string

get_count()   X-Ref
The total number of results

return: int

get_results()   X-Ref
Returns an array of results from the search

return: array

set_url(moodle_url $url)   X-Ref
Sets the page URL

param: moodle_url $url

invalidate_results()   X-Ref
Invalidates the results collected so far


require_capability($capability, $user = null)   X-Ref
Adds a required capability which all results will be checked against

param: string $capability
param: int|null $user

search()   X-Ref
Executes the search

return: int The number of results

has_more_results()   X-Ref
Returns true if there are more search results.

return: bool

Class: restore_course_search  - X-Ref

A course search component

__construct(array $config = array()   X-Ref
Constructor

param: array $config
param: int $currentcouseid The current course id so it can be ignored

setup_restrictions()   X-Ref
Sets up any access restrictions for the courses to be displayed in the search.

This will typically call $this->require_capability().

get_searchsql()   X-Ref
Get the search SQL.

return: array

get_itemcontextlevel()   X-Ref
Gets the context level for the search result items.

return: CONTEXT_|int

format_results()   X-Ref
Formats results.


get_varsearch()   X-Ref
Returns the name the search variable should use

return: string

set_include_currentcourse()   X-Ref
Returns true if the current course should be included in the results.


Class: restore_category_search  - X-Ref

A category search component

__construct(array $config = array()   X-Ref
Constructor

param: array $config

get_searchsql()   X-Ref
Returns the search SQL.

return: array

get_itemcontextlevel()   X-Ref
Returns the context level of the search results.

return: CONTEXT_COURSECAT

format_results()   X-Ref
Formats the results.


get_varsearch()   X-Ref
Returns the name to use for the search variable.

return: string