This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
More...
|
| __construct (ilDBInterface $db, ?array $preload_context_obj_ids=null) |
| Do not call this constructor directly, use ilBookingReservationDBRepositoryFactory instead. More...
|
|
| getForId (int $id) |
| Get reservation data for id. More...
|
|
| create (int $user_id, int $assigner_id, int $object_id, int $context_obj_id, int $from, int $to, int $status, int $group_id) |
|
| update (int $id, int $user_id, int $assigner_id, int $object_id, int $context_obj_id, int $from, int $to, int $status, int $group_id) |
|
| delete (int $id) |
|
| getNewGroupId () |
|
| getNumberOfReservations (array $ids, int $from, int $to, bool $only_not_over_yet=false) |
| Get number of uncancelled reservations in time frame. More...
|
|
| getListByDate (bool $a_has_schedule, array $a_object_ids=null, array $filter=null, array $a_pool_ids=null) |
| List all reservations by date. More...
|
|
| getCachedContextObjBookingInfo (int $context_obj_id) |
| Get context object properties info. More...
|
|
| getReservationIdsByBookingObjectId (int $booking_object_id) |
|
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Repo class for reservations Acts on tables booking_reservation (rw), booking_reservation_group (rw) and booking_object (r)
- Author
- Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Definition at line 24 of file class.ilBookingReservationDBRepository.php.
◆ __construct()
ilBookingReservationDBRepository::__construct |
( |
ilDBInterface |
$db, |
|
|
?array |
$preload_context_obj_ids = null |
|
) |
| |
◆ create()
ilBookingReservationDBRepository::create |
( |
int |
$user_id, |
|
|
int |
$assigner_id, |
|
|
int |
$object_id, |
|
|
int |
$context_obj_id, |
|
|
int |
$from, |
|
|
int |
$to, |
|
|
int |
$status, |
|
|
int |
$group_id |
|
) |
| |
- Returns
- int new reservation id
Definition at line 59 of file class.ilBookingReservationDBRepository.php.
References $db, $id, and $ilDB.
71 $id =
$ilDB->nextId(
'booking_reservation');
72 $ilDB->manipulate(
'INSERT INTO booking_reservation' .
73 ' (booking_reservation_id,user_id,assigner_id,object_id,context_obj_id,date_from,date_to,status,group_id)' .
74 ' VALUES (' .
$ilDB->quote(
$id,
'integer') .
75 ',' .
$ilDB->quote($user_id,
'integer') .
76 ',' .
$ilDB->quote($assigner_id,
'integer') .
77 ',' .
$ilDB->quote($object_id,
'integer') .
78 ',' .
$ilDB->quote($context_obj_id,
'integer') .
79 ',' .
$ilDB->quote($from,
'integer') .
80 ',' .
$ilDB->quote($to,
'integer') .
81 ',' .
$ilDB->quote($status,
'integer') .
82 ',' .
$ilDB->quote($group_id,
'integer') .
')');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ delete()
ilBookingReservationDBRepository::delete |
( |
int |
$id | ) |
|
◆ getCachedContextObjBookingInfo()
ilBookingReservationDBRepository::getCachedContextObjBookingInfo |
( |
int |
$context_obj_id | ) |
|
Get context object properties info.
- Exceptions
-
Definition at line 321 of file class.ilBookingReservationDBRepository.php.
Referenced by ilBookingInfoListItemPropertiesAdapter\appendProperties().
324 if (!is_array($this->preloaded_by_context_list)) {
327 return array_filter($this->preloaded_by_context_list,
static function ($row) use ($context_obj_id) {
328 return ($row[
"context_obj_id"] == $context_obj_id);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
◆ getForId()
ilBookingReservationDBRepository::getForId |
( |
int |
$id | ) |
|
Get reservation data for id.
- Returns
- string[]
Definition at line 47 of file class.ilBookingReservationDBRepository.php.
References $db, and $ilDB.
50 $set =
$ilDB->query(
'SELECT *' .
51 ' FROM booking_reservation' .
52 ' WHERE booking_reservation_id = ' .
$ilDB->quote(
$id,
'integer'));
53 return $ilDB->fetchAssoc($set);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ getListByDate()
ilBookingReservationDBRepository::getListByDate |
( |
bool |
$a_has_schedule, |
|
|
array |
$a_object_ids = null , |
|
|
array |
$filter = null , |
|
|
array |
$a_pool_ids = null |
|
) |
| |
List all reservations by date.
Definition at line 170 of file class.ilBookingReservationDBRepository.php.
References $db, $ilDB, $res, ilObjUser\_lookupName(), and ilBookingReservation\STATUS_CANCELLED.
180 $sql =
'SELECT r.*, o.title, o.pool_id' .
181 ' FROM booking_reservation r' .
182 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)';
185 if ($a_pool_ids !== null) {
186 $where = array(
$ilDB->in(
'pool_id', $a_pool_ids,
'',
'integer'));
189 if ($a_object_ids !== null) {
190 $where = array(
$ilDB->in(
'object_id', $a_object_ids,
'',
'integer'));
193 if (isset($filter[
'context_obj_ids']) && count($filter[
'context_obj_ids']) > 0) {
194 $where = array(
$ilDB->in(
'context_obj_id', $filter[
'context_obj_ids'],
'',
'integer'));
197 if ($filter[
'status'] ??
false) {
198 if ($filter[
'status'] > 0) {
199 $where[] =
'status = ' .
$ilDB->quote($filter[
'status'],
'integer');
201 $where[] =
'(status != ' .
$ilDB->quote(-$filter[
'status'],
'integer') .
202 ' OR status IS NULL)';
205 if (isset($filter[
'title']) && is_string($filter[
'title'])) {
206 $where[] =
'(' .
$ilDB->like(
'title',
'text',
'%' . $filter[
'title'] .
'%') .
207 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $filter[
'title'] .
'%') .
')';
209 if ($a_has_schedule) {
210 if (isset($filter[
'from']) && (
int) $filter[
'from'] > 0) {
211 $where[] =
'date_from >= ' .
$ilDB->quote($filter[
'from'],
'integer');
213 if (isset($filter[
'to']) && (
int) $filter[
'to'] > 0) {
214 $where[] =
'date_to <= ' .
$ilDB->quote($filter[
'to'],
'integer');
216 if (!isset($filter[
'past']) || !$filter[
'past']) {
217 $where[] =
'date_to > ' .
$ilDB->quote(time(),
'integer');
220 if (isset($filter[
'user_id']) && is_numeric($filter[
'user_id'])) {
221 $where[] =
'user_id = ' .
$ilDB->quote($filter[
'user_id'],
'integer');
223 if (count($where) > 0) {
224 $sql .=
' WHERE ' . implode(
' AND ', $where);
227 if ($a_has_schedule) {
228 $sql .=
' ORDER BY date_from DESC';
231 $sql .=
' ORDER BY status';
233 $set =
$ilDB->query($sql);
234 while ($row =
$ilDB->fetchAssoc($set)) {
235 $obj_id = $row[
"object_id"];
236 $user_id = $row[
"user_id"];
238 if ($a_has_schedule) {
239 $slot = $row[
"date_from"] .
"_" . $row[
"date_to"];
240 $idx = $obj_id .
"_" . $user_id .
"_" . $slot;
242 $idx = $obj_id .
"_" . $user_id;
244 $idx .=
"_" . $row[
"context_obj_id"];
246 if ($a_has_schedule && ($filter[
"slot"] ??
false)) {
247 $slot_idx = date(
"w", $row[
"date_from"]) .
"_" . date(
"H:i", $row[
"date_from"]) .
248 "-" . date(
"H:i", $row[
"date_to"] + 1);
249 if ($filter[
"slot"] != $slot_idx) {
254 if (!isset(
$res[$idx])) {
258 "object_id" => $obj_id
259 ,
"title" => $row[
"title"]
260 ,
"pool_id" => $row[
"pool_id"]
261 ,
"context_obj_id" => (
int) $row[
"context_obj_id"]
262 ,
"user_id" => $user_id
264 ,
"user_name" => $uname[
"lastname"] .
", " . $uname[
"firstname"]
265 ,
"login" => $uname[
"login"]
268 if ($a_has_schedule) {
269 $res[$idx][
"booking_reservation_id"] = $idx;
270 $res[$idx][
"date"] = date(
"Y-m-d", $row[
"date_from"]);
271 $res[$idx][
"slot"] = date(
"H:i", $row[
"date_from"]) .
" - " .
272 date(
"H:i", $row[
"date_to"] + 1);
273 $res[$idx][
"week"] = date(
"W", $row[
"date_from"]);
274 $res[$idx][
"weekday"] = date(
"w", $row[
"date_from"]);
276 $row[
"date_from"] > time());
277 $res[$idx][
"_sortdate"] = $row[
"date_from"];
280 $res[$idx][
"status"] = $row[
"status"];
282 $res[$idx][
"booking_reservation_id"] = $row[
"booking_reservation_id"];
283 $res[$idx][
"status"] = $row[
"status"];
287 $res[$idx][
"counter"]++;
static _lookupName(int $a_user_id)
lookup user name
◆ getNewGroupId()
ilBookingReservationDBRepository::getNewGroupId |
( |
| ) |
|
◆ getNumberOfReservations()
ilBookingReservationDBRepository::getNumberOfReservations |
( |
array |
$ids, |
|
|
int |
$from, |
|
|
int |
$to, |
|
|
bool |
$only_not_over_yet = false |
|
) |
| |
Get number of uncancelled reservations in time frame.
- Parameters
-
int[] | $ids booking object ids |
Definition at line 136 of file class.ilBookingReservationDBRepository.php.
References $db, $ilDB, $res, and ilBookingReservation\STATUS_CANCELLED.
Referenced by ilBookingReservation\getAvailableObject(), and ilBookingReservation\isObjectAvailableInPeriod().
144 $from =
$ilDB->quote($from,
'integer');
145 $to =
$ilDB->quote($to,
'integer');
147 $date = $only_not_over_yet
148 ?
' AND date_to > ' .
$ilDB->quote(time(),
"integer")
151 $set =
$ilDB->query(
'SELECT count(*) cnt, object_id' .
152 ' FROM booking_reservation' .
153 ' WHERE ' .
$ilDB->in(
'object_id', $ids,
'',
'integer') . $date .
154 ' AND (status IS NULL OR status <> ' .
$ilDB->quote(
158 ' AND date_from <= ' . $to .
' AND date_to >= ' . $from .
159 ' GROUP BY object_id');
161 while ($row =
$ilDB->fetchAssoc($set)) {
162 $res[$row[
"object_id"]] = $row;
◆ getReservationIdsByBookingObjectId()
ilBookingReservationDBRepository::getReservationIdsByBookingObjectId |
( |
int |
$booking_object_id | ) |
|
◆ preloadByContextIds()
ilBookingReservationDBRepository::preloadByContextIds |
( |
array |
$context_obj_ids | ) |
|
|
protected |
Preload reservation information for context obj ids.
- Parameters
-
Definition at line 302 of file class.ilBookingReservationDBRepository.php.
References Vendor\Package\$f, ilArrayUtil\sortArray(), ilArrayUtil\stableSortArray(), and ilBookingReservation\STATUS_CANCELLED.
Referenced by __construct().
305 $filter = [
"context_obj_ids" => ($context_obj_ids)];
306 $filter[
'past'] =
true;
309 $repo =
$f->getRepo();
310 $list = $repo->getListByDate(
true, null, $filter);
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
◆ update()
ilBookingReservationDBRepository::update |
( |
int |
$id, |
|
|
int |
$user_id, |
|
|
int |
$assigner_id, |
|
|
int |
$object_id, |
|
|
int |
$context_obj_id, |
|
|
int |
$from, |
|
|
int |
$to, |
|
|
int |
$status, |
|
|
int |
$group_id |
|
) |
| |
- Returns
- int number of affected records
Definition at line 89 of file class.ilBookingReservationDBRepository.php.
References $db, and $ilDB.
101 return $ilDB->manipulate(
'UPDATE booking_reservation' .
102 ' SET object_id = ' .
$ilDB->quote($object_id,
'text') .
103 ', user_id = ' .
$ilDB->quote($user_id,
'integer') .
104 ', assigner_id = ' .
$ilDB->quote($assigner_id,
'integer') .
105 ', date_from = ' .
$ilDB->quote($from,
'integer') .
106 ', date_to = ' .
$ilDB->quote($to,
'integer') .
107 ', status = ' .
$ilDB->quote($status,
'integer') .
108 ', group_id = ' .
$ilDB->quote($group_id,
'integer') .
109 ', context_obj_id = ' .
$ilDB->quote($context_obj_id,
'integer') .
110 ' WHERE booking_reservation_id = ' .
$ilDB->quote(
$id,
'integer'));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ $db
◆ $preloaded_by_context_list
array ilBookingReservationDBRepository::$preloaded_by_context_list = null |
|
protected |
The documentation for this class was generated from the following file: