ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBookingPrefBasedBookGatewayRepository Class Reference

Manages the booking storage of the preference based calculated bookings. More...

+ Collaboration diagram for ilBookingPrefBasedBookGatewayRepository:

Public Member Functions

 __construct (ilDBInterface $db=null)
 Constructor. More...
 
 getPoolsWithOverdueBooking ()
 Get pools with overdue preference booking. More...
 
 storeBookings (int $pool_id, $bookings)
 Store bookings see similar code in ilObjBookingPoolGUI::confirmedBookingObject this should got to a reservation repo/manager in the future. More...
 
 getBookings (array $obj_ids)
 Get bookings. More...
 

Protected Member Functions

 checkProcessHash ($pool_id)
 Semaphore like hash setting/checking to ensure that no other process is doing the same. More...
 

Protected Attributes

 $db
 

Detailed Description

Manages the booking storage of the preference based calculated bookings.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 10 of file class.ilBookingPrefBaseBookGatewayRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookingPrefBasedBookGatewayRepository::__construct ( ilDBInterface  $db = null)

Constructor.

Definition at line 20 of file class.ilBookingPrefBaseBookGatewayRepository.php.

References $db, and $DIC.

21  {
22  global $DIC;
23 
24  $this->db = ($db)
25  ? $db
26  : $DIC->database();
27  }
$DIC
Definition: xapitoken.php:46

Member Function Documentation

◆ checkProcessHash()

ilBookingPrefBasedBookGatewayRepository::checkProcessHash (   $pool_id)
protected

Semaphore like hash setting/checking to ensure that no other process is doing the same.

Returns
bool

Definition at line 60 of file class.ilBookingPrefBaseBookGatewayRepository.php.

References $db.

Referenced by storeBookings().

61  {
62  $db = $this->db;
63 
64  $hash = uniqid("", true);
65 
66  $db->update("booking_settings", array(
67  "pref_booking_hash" => array("text", $hash)
68  ), array( // where
69  "booking_pool_id" => array("integer", $pool_id),
70  "pref_booking_hash" => array("text", "0"),
71  ));
72 
73  $set = $db->queryF(
74  "SELECT pref_booking_hash FROM booking_settings " .
75  " WHERE booking_pool_id = %s ",
76  array("integer"),
77  array($pool_id)
78  );
79  $rec = $db->fetchAssoc($set);
80 
81  if ($rec["pref_booking_hash"] == $hash) {
82  return true;
83  }
84  return false;
85  }
+ Here is the caller graph for this function:

◆ getBookings()

ilBookingPrefBasedBookGatewayRepository::getBookings ( array  $obj_ids)

Get bookings.

Parameters
array$obj_ids
Returns
array

Definition at line 120 of file class.ilBookingPrefBaseBookGatewayRepository.php.

References ilBookingReservation\getList(), and ilBookingReservation\STATUS_CANCELLED.

121  {
122  $bookings = [];
124  $obj_ids,
125  10000,
126  0,
128  )["data"] as $book) {
129  $bookings[$book["user_id"]][] = $book["object_id"];
130  }
131  return $bookings;
132  }
static getList($a_object_ids, $a_limit=10, $a_offset=0, array $filter=[])
List all reservations.
+ Here is the call graph for this function:

◆ getPoolsWithOverdueBooking()

ilBookingPrefBasedBookGatewayRepository::getPoolsWithOverdueBooking ( )

Get pools with overdue preference booking.

Returns
int[]

Definition at line 34 of file class.ilBookingPrefBaseBookGatewayRepository.php.

References $db, and ilObjBookingPool\TYPE_NO_SCHEDULE_PREFERENCES.

35  {
36  $db = $this->db;
37 
38  $pool_ids = [];
39  $set = $db->queryF(
40  "SELECT booking_pool_id FROM booking_settings " .
41  " WHERE schedule_type = %s " .
42  " AND pref_deadline < %s " .
43  " AND pref_booking_hash = %s ",
44  array("integer", "integer", "text"),
46  );
47  while ($rec = $db->fetchAssoc($set)) {
48  $pool_ids[] = $rec["booking_pool_id"];
49  }
50  return $pool_ids;
51  }

◆ storeBookings()

ilBookingPrefBasedBookGatewayRepository::storeBookings ( int  $pool_id,
  $bookings 
)

Store bookings see similar code in ilObjBookingPoolGUI::confirmedBookingObject this should got to a reservation repo/manager in the future.

Parameters
int[][]$bookings

Definition at line 94 of file class.ilBookingPrefBaseBookGatewayRepository.php.

References checkProcessHash(), ilBookingReservation\getObjectReservationForUser(), and ilBookingReservation\isObjectAvailableNoSchedule().

95  {
96  if ($this->checkProcessHash($pool_id)) {
97  foreach ($bookings as $user_id => $obj_ids) {
98  foreach ($obj_ids as $obj_id) {
100  !ilBookingReservation::getObjectReservationForUser($obj_id, $user_id)) { // #18304
101  $reservation = new ilBookingReservation();
102  $reservation->setObjectId($obj_id);
103  $reservation->setUserId($user_id);
104  $reservation->setAssignerId($user_id);
105  $reservation->setFrom(null);
106  $reservation->setTo(null);
107  $reservation->save();
108  }
109  }
110  }
111  }
112  }
static isObjectAvailableNoSchedule($a_obj_id)
checkProcessHash($pool_id)
Semaphore like hash setting/checking to ensure that no other process is doing the same...
static getObjectReservationForUser($a_object_id, $a_user_id, $a_multi=false)
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilBookingPrefBasedBookGatewayRepository::$db
protected

The documentation for this class was generated from the following file: