1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Event vault interface
|
|
|
19 |
*
|
|
|
20 |
* @package core_calendar
|
|
|
21 |
* @copyright 2017 Ryan Wyllie <ryan@moodle.com>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace core_calendar\local\event\data_access;
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
use core_calendar\local\event\entities\event_interface;
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Interface for an event vault class
|
|
|
33 |
*
|
|
|
34 |
* @copyright 2017 Ryan Wyllie <ryan@moodle.com>
|
|
|
35 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
36 |
*/
|
|
|
37 |
interface event_vault_interface {
|
|
|
38 |
/**
|
|
|
39 |
* Retrieve an event for the given id.
|
|
|
40 |
*
|
|
|
41 |
* @param int $id The event id
|
|
|
42 |
* @return event_interface|false
|
|
|
43 |
*/
|
|
|
44 |
public function get_event_by_id($id);
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Get all events restricted by various parameters, taking in to account user and group overrides.
|
|
|
48 |
*
|
|
|
49 |
* @param int|null $timestartfrom Events with timestart from this value (inclusive).
|
|
|
50 |
* @param int|null $timestartto Events with timestart until this value (inclusive).
|
|
|
51 |
* @param int|null $timesortfrom Events with timesort from this value (inclusive).
|
|
|
52 |
* @param int|null $timesortto Events with timesort until this value (inclusive).
|
|
|
53 |
* @param event_interface|null $timestartafterevent Restrict the events in the timestart range to ones after this one.
|
|
|
54 |
* @param event_interface|null $timesortafterevent Restrict the events in the timesort range to ones after this one.
|
|
|
55 |
* @param int $limitnum Return at most this number of events.
|
|
|
56 |
* @param int|null $type Return only events of this type.
|
|
|
57 |
* @param array|null $usersfilter Return only events for these users.
|
|
|
58 |
* @param array|null $groupsfilter Return only events for these groups.
|
|
|
59 |
* @param array|null $coursesfilter Return only events for these courses.
|
|
|
60 |
* @param bool $withduration If true return only events starting within specified
|
|
|
61 |
* timestart otherwise return in progress events as well.
|
|
|
62 |
* @param bool $ignorehidden If true don't return hidden events.
|
|
|
63 |
* @param callable|null $filter Additional logic to filter out unwanted events.
|
|
|
64 |
* Must return true to keep the event, false to discard it.
|
|
|
65 |
* @param string|null $searchvalue The value a user wishes to search against
|
|
|
66 |
* @return event_interface[] Array of event_interfaces.
|
|
|
67 |
*/
|
|
|
68 |
public function get_events(
|
|
|
69 |
$timestartfrom = null,
|
|
|
70 |
$timestartto = null,
|
|
|
71 |
$timesortfrom = null,
|
|
|
72 |
$timesortto = null,
|
|
|
73 |
event_interface $timestartafterevent = null,
|
|
|
74 |
event_interface $timesortafterevent = null,
|
|
|
75 |
$limitnum = 20,
|
|
|
76 |
$type = null,
|
|
|
77 |
array $usersfilter = null,
|
|
|
78 |
array $groupsfilter = null,
|
|
|
79 |
array $coursesfilter = null,
|
|
|
80 |
array $categoriesfilter = null,
|
|
|
81 |
$withduration = true,
|
|
|
82 |
$ignorehidden = true,
|
|
|
83 |
callable $filter = null,
|
|
|
84 |
?string $searchvalue = null
|
|
|
85 |
);
|
|
|
86 |
|
|
|
87 |
/**
|
|
|
88 |
* Retrieve an array of events for the given user and time constraints.
|
|
|
89 |
*
|
|
|
90 |
* If using this function for pagination then you can provide the last event that you've seen
|
|
|
91 |
* ($afterevent) and it will be used to appropriately offset the result set so that you don't
|
|
|
92 |
* receive the same events again.
|
|
|
93 |
* @param \stdClass $user The user for whom the events belong
|
|
|
94 |
* @param int $timesortfrom Events with timesort from this value (inclusive)
|
|
|
95 |
* @param int $timesortto Events with timesort until this value (inclusive)
|
|
|
96 |
* @param event_interface $afterevent Only return events after this one
|
|
|
97 |
* @param int $limitnum Return at most this number of events
|
|
|
98 |
* @param bool $lmittononsuspendedevents Limit course events to courses the user is active in (not suspended).
|
|
|
99 |
* @param string|null $searchvalue The value a user wishes to search against
|
|
|
100 |
* @return event_interface
|
|
|
101 |
*/
|
|
|
102 |
public function get_action_events_by_timesort(
|
|
|
103 |
\stdClass $user,
|
|
|
104 |
$timesortfrom,
|
|
|
105 |
$timesortto,
|
|
|
106 |
event_interface $afterevent,
|
|
|
107 |
$limitnum,
|
|
|
108 |
$limittononsuspendedevents,
|
|
|
109 |
?string $searchvalue = null
|
|
|
110 |
);
|
|
|
111 |
|
|
|
112 |
/**
|
|
|
113 |
* Retrieve an array of events for the given user filtered by the course and time constraints.
|
|
|
114 |
*
|
|
|
115 |
* If using this function for pagination then you can provide the last event that you've seen
|
|
|
116 |
* ($afterevent) and it will be used to appropriately offset the result set so that you don't
|
|
|
117 |
* receive the same events again.
|
|
|
118 |
*
|
|
|
119 |
* @param \stdClass $user The user for whom the events belong
|
|
|
120 |
* @param \stdClass $course The course to filter by
|
|
|
121 |
* @param int $timesortfrom Events with timesort from this value (inclusive)
|
|
|
122 |
* @param int $timesortto Events with timesort until this value (inclusive)
|
|
|
123 |
* @param event_interface $afterevent Only return events after this one
|
|
|
124 |
* @param int $limitnum Return at most this number of events
|
|
|
125 |
* @param string|null $searchvalue The value a user wishes to search against
|
|
|
126 |
* @return action_event_interface
|
|
|
127 |
*/
|
|
|
128 |
public function get_action_events_by_course(
|
|
|
129 |
\stdClass $user,
|
|
|
130 |
\stdClass $course,
|
|
|
131 |
$timesortfrom,
|
|
|
132 |
$timesortto,
|
|
|
133 |
event_interface $afterevent,
|
|
|
134 |
$limitnum,
|
|
|
135 |
?string $searchvalue = null
|
|
|
136 |
);
|
|
|
137 |
}
|