Event vault class.
More...
|
| __construct (event_factory_interface $factory, raw_event_retrieval_strategy_interface $retrievalstrategy) |
| Create an event vault.
|
|
| get_action_events_by_course (stdClass $user, stdClass $course, $timesortfrom=null, $timesortto=null, event_interface $afterevent=null, $limitnum=20, ?string $searchvalue=null) |
| Retrieve an array of events for the given user filtered by the course and time constraints.
|
|
| get_action_events_by_timesort (stdClass $user, $timesortfrom=null, $timesortto=null, event_interface $afterevent=null, $limitnum=20, $limittononsuspendedevents=false, ?string $searchvalue=null) |
| Retrieve an array of events for the given user and time constraints.
|
|
| get_event_by_id ($id) |
| Retrieve an event for the given id.
|
|
| get_events ( $timestartfrom=null, $timestartto=null, $timesortfrom=null, $timesortto=null, event_interface $timestartafterevent=null, event_interface $timesortafterevent=null, $limitnum=20, $type=null, array $usersfilter=null, array $groupsfilter=null, array $coursesfilter=null, array $categoriesfilter=null, $withduration=true, $ignorehidden=true, callable $filter=null, ?string $searchvalue=null) |
| Get all events restricted by various parameters, taking in to account user and group overrides.
|
|
|
| generate_search_subquery (?string $searchvalue) |
| Generates SQL subquery and parameters for event searching.
|
|
| get_from_db ( $userid, $whereconditions, $whereparams, $ordersql, $offset, $limitnum) |
| Fetches records from DB.
|
|
| timefield_pagination_from ( $field, $timefrom, $lastseentime=null, $lastseenid=null, $withduration=true) |
| Generates SQL subquery and parameters for 'from' pagination.
|
|
| timefield_pagination_to ( $field, $timeto, $lastseentime=null, $lastseenid=null) |
| Generates SQL subquery and parameters for 'to' pagination.
|
|
| transform_from_database_record (\stdClass $record) |
| Create an event from a database record.
|
|
Event vault class.
This class will handle interacting with the database layer to retrieve the records. This is required to house the complex logic required for pagination because it's not a one-to-one mapping between database records and users.
This is a repository. It's called a vault to reduce confusion because Moodle has already taken the name repository. Vault is cooler anyway.
- Copyright
- 2017 Ryan Wyllie ryan@.nosp@m.mood.nosp@m.le.co.nosp@m.m
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
Create an event vault.
- Parameters
-
event_factory_interface | $factory | An event factory |
raw_event_retrieval_strategy_interface | $retrievalstrategy | |
◆ generate_search_subquery()
core_calendar\local\event\data_access\event_vault::generate_search_subquery |
( |
?string | $searchvalue | ) |
|
|
protected |
Generates SQL subquery and parameters for event searching.
- Parameters
-
string | null | $searchvalue | Search value. |
- Return values
-
◆ get_action_events_by_course()
core_calendar\local\event\data_access\event_vault::get_action_events_by_course |
( |
stdClass | $user, |
|
|
stdClass | $course, |
|
|
| $timesortfrom = null, |
|
|
| $timesortto = null, |
|
|
event_interface | $afterevent = null, |
|
|
| $limitnum = 20, |
|
|
?string | $searchvalue = null ) |
Retrieve an array of events for the given user filtered by the course and time constraints.
If using this function for pagination then you can provide the last event that you've seen ($afterevent) and it will be used to appropriately offset the result set so that you don't receive the same events again.
- Parameters
-
stdClass | $user | The user for whom the events belong |
stdClass | $course | The course to filter by |
int | $timesortfrom | Events with timesort from this value (inclusive) |
int | $timesortto | Events with timesort until this value (inclusive) |
event_interface | $afterevent | Only return events after this one |
int | $limitnum | Return at most this number of events |
string | null | $searchvalue | The value a user wishes to search against |
- Return values
-
Implements core_calendar\local\event\data_access\event_vault_interface.
◆ get_action_events_by_timesort()
core_calendar\local\event\data_access\event_vault::get_action_events_by_timesort |
( |
stdClass | $user, |
|
|
| $timesortfrom = null, |
|
|
| $timesortto = null, |
|
|
event_interface | $afterevent = null, |
|
|
| $limitnum = 20, |
|
|
| $limittononsuspendedevents = false, |
|
|
?string | $searchvalue = null ) |
Retrieve an array of events for the given user and time constraints.
If using this function for pagination then you can provide the last event that you've seen ($afterevent) and it will be used to appropriately offset the result set so that you don't receive the same events again.
- Parameters
-
stdClass | $user | The user for whom the events belong |
int | $timesortfrom | Events with timesort from this value (inclusive) |
int | $timesortto | Events with timesort until this value (inclusive) |
event_interface | $afterevent | Only return events after this one |
int | $limitnum | Return at most this number of events |
bool | $lmittononsuspendedevents | Limit course events to courses the user is active in (not suspended). |
string | null | $searchvalue | The value a user wishes to search against |
- Return values
-
Implements core_calendar\local\event\data_access\event_vault_interface.
◆ get_event_by_id()
core_calendar\local\event\data_access\event_vault::get_event_by_id |
( |
| $id | ) |
|
◆ get_events()
core_calendar\local\event\data_access\event_vault::get_events |
( |
| $timestartfrom = null, |
|
|
| $timestartto = null, |
|
|
| $timesortfrom = null, |
|
|
| $timesortto = null, |
|
|
event_interface | $timestartafterevent = null, |
|
|
event_interface | $timesortafterevent = null, |
|
|
| $limitnum = 20, |
|
|
| $type = null, |
|
|
array | $usersfilter = null, |
|
|
array | $groupsfilter = null, |
|
|
array | $coursesfilter = null, |
|
|
array | $categoriesfilter = null, |
|
|
| $withduration = true, |
|
|
| $ignorehidden = true, |
|
|
callable | $filter = null, |
|
|
?string | $searchvalue = null ) |
Get all events restricted by various parameters, taking in to account user and group overrides.
- Parameters
-
int | null | $timestartfrom | Events with timestart from this value (inclusive). |
int | null | $timestartto | Events with timestart until this value (inclusive). |
int | null | $timesortfrom | Events with timesort from this value (inclusive). |
int | null | $timesortto | Events with timesort until this value (inclusive). |
event_interface | null | $timestartafterevent | Restrict the events in the timestart range to ones after this one. |
event_interface | null | $timesortafterevent | Restrict the events in the timesort range to ones after this one. |
int | $limitnum | Return at most this number of events. |
int | null | $type | Return only events of this type. |
array | null | $usersfilter | Return only events for these users. |
array | null | $groupsfilter | Return only events for these groups. |
array | null | $coursesfilter | Return only events for these courses. |
bool | $withduration | If true return only events starting within specified timestart otherwise return in progress events as well. |
bool | $ignorehidden | If true don't return hidden events. |
callable | null | $filter | Additional logic to filter out unwanted events. Must return true to keep the event, false to discard it. |
string | null | $searchvalue | The value a user wishes to search against |
- Return values
-
event_interface[] | Array of event_interfaces. |
Implements core_calendar\local\event\data_access\event_vault_interface.
◆ get_from_db()
core_calendar\local\event\data_access\event_vault::get_from_db |
( |
| $userid, |
|
|
| $whereconditions, |
|
|
| $whereparams, |
|
|
| $ordersql, |
|
|
| $offset, |
|
|
| $limitnum ) |
|
protected |
Fetches records from DB.
- Parameters
-
int | $userid | |
array | null | $whereconditions | |
array | $whereparams | |
string | $ordersql | |
int | $offset | |
int | $limitnum | |
- Return values
-
◆ timefield_pagination_from()
core_calendar\local\event\data_access\event_vault::timefield_pagination_from |
( |
| $field, |
|
|
| $timefrom, |
|
|
| $lastseentime = null, |
|
|
| $lastseenid = null, |
|
|
| $withduration = true ) |
|
protected |
Generates SQL subquery and parameters for 'from' pagination.
- Parameters
-
string | $field | |
int | $timefrom | |
int | null | $lastseentime | |
int | null | $lastseenid | |
bool | $withduration | |
- Return values
-
◆ timefield_pagination_to()
core_calendar\local\event\data_access\event_vault::timefield_pagination_to |
( |
| $field, |
|
|
| $timeto, |
|
|
| $lastseentime = null, |
|
|
| $lastseenid = null ) |
|
protected |
Generates SQL subquery and parameters for 'to' pagination.
- Parameters
-
string | $field | |
int | $timeto | |
int | null | $lastseentime | |
int | null | $lastseenid | |
- Return values
-
◆ transform_from_database_record()
core_calendar\local\event\data_access\event_vault::transform_from_database_record |
( |
\stdClass | $record | ) |
|
|
protected |
Create an event from a database record.
- Parameters
-
stdClass | $record | The database record |
- Return values
-
The documentation for this class was generated from the following file:
- calendar/classes/local/event/data_access/event_vault.php