ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Calendar\ConsultationHours\BookingDataProvider Class Reference
+ Collaboration diagram for ILIAS\Calendar\ConsultationHours\BookingDataProvider:

Public Member Functions

 __construct (int $user_id, string $vm_period, string $vm_status)
 
 getUserId ()
 
 isFiltered (ilCalendarEntry $entry, ilBookingEntry $booking, array $booked_users)
 
 getData ()
 
 sortData (Order $order)
 
 limitData (Range $range, Order $order)
 

Protected Member Functions

 read ()
 

Private Attributes

int $user_id
 
array $data = []
 
StaticURL Services $static_url_service
 
ILIAS UI Factory $ui_factory
 
string $vm_period = ilConsultationHoursGUI::VIEW_MODE_PERIOD_ALL
 
string $vm_status = ilConsultationHoursGUI::VIEW_MODE_STATUS_ALL
 

Detailed Description

Definition at line 41 of file BookingDataProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::__construct ( int  $user_id,
string  $vm_period,
string  $vm_status 
)

Member Function Documentation

◆ getData()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::getData ( )

Definition at line 179 of file BookingDataProvider.php.

References ILIAS\Calendar\ConsultationHours\BookingDataProvider\$data.

Referenced by ILIAS\Calendar\ConsultationHours\BookingDataProvider\sortData().

179  : array
180  {
181  return $this->data;
182  }
+ Here is the caller graph for this function:

◆ getUserId()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::getUserId ( )

Definition at line 64 of file BookingDataProvider.php.

References ILIAS\Calendar\ConsultationHours\BookingDataProvider\$user_id.

Referenced by ILIAS\Calendar\ConsultationHours\BookingDataProvider\read().

+ Here is the caller graph for this function:

◆ isFiltered()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::isFiltered ( ilCalendarEntry  $entry,
ilBookingEntry  $booking,
array  $booked_users 
)

Definition at line 147 of file BookingDataProvider.php.

References ilDateTime\_after(), ilDateTime\_before(), ilBookingEntry\getNumberOfBookings(), ilCalendarEntry\getStart(), IL_CAL_DAY, IL_CAL_UNIX, ilConsultationHoursGUI\VIEW_MODE_PERIOD_ALL, ilConsultationHoursGUI\VIEW_MODE_PERIOD_PAST, ilConsultationHoursGUI\VIEW_MODE_PERIOD_UPCOMING, ilConsultationHoursGUI\VIEW_MODE_STATUS_ALL, ilConsultationHoursGUI\VIEW_MODE_STATUS_BOOKED, and ilConsultationHoursGUI\VIEW_MODE_STATUS_OPEN.

Referenced by ILIAS\Calendar\ConsultationHours\BookingDataProvider\read().

147  : bool
148  {
149  if (
150  $this->vm_status == ilConsultationHoursGUI::VIEW_MODE_STATUS_ALL &&
152  ) {
153  return false;
154  }
155  $now = new ilDate(time(), IL_CAL_UNIX);
156  if ($this->vm_period === ilConsultationHoursGUI::VIEW_MODE_PERIOD_UPCOMING) {
157  if (ilDateTime::_before($entry->getStart(), $now, IL_CAL_DAY)) {
158  return true;
159  }
160  }
161  if ($this->vm_period === ilConsultationHoursGUI::VIEW_MODE_PERIOD_PAST) {
162  if (ilDateTime::_after($entry->getStart(), $now, IL_CAL_DAY)) {
163  return true;
164  }
165  }
166  if ($this->vm_status === ilConsultationHoursGUI::VIEW_MODE_STATUS_OPEN) {
167  if (count($booked_users) >= $booking->getNumberOfBookings()) {
168  return true;
169  }
170  }
171  if ($this->vm_status === ilConsultationHoursGUI::VIEW_MODE_STATUS_BOOKED) {
172  if (count($booked_users) < $booking->getNumberOfBookings()) {
173  return true;
174  }
175  }
176  return false;
177  }
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
const IL_CAL_UNIX
const IL_CAL_DAY
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
getStart()
Get start of date period.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ limitData()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::limitData ( Range  $range,
Order  $order 
)

Definition at line 195 of file BookingDataProvider.php.

References ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and ILIAS\Calendar\ConsultationHours\BookingDataProvider\sortData().

195  : array
196  {
197  return array_slice($this->sortData($order), $range->getStart(), $range->getLength());
198  }
+ Here is the call graph for this function:

◆ read()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::read ( )
protected

Definition at line 69 of file BookingDataProvider.php.

References $comment, $comments, ILIAS\Calendar\ConsultationHours\BookingDataProvider\$data, $ref_id, ilObject\_getAllReferences(), ilObjUser\_lookupFullname(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilUtil\_sortIds(), ilConsultationHourAppointments\getAppointments(), ilUserUtil\getProfileLink(), ILIAS\Calendar\ConsultationHours\BookingDataProvider\getUserId(), ILIAS\Repository\int(), ILIAS\Calendar\ConsultationHours\BookingDataProvider\isFiltered(), ilBookingEntry\lookupBookingMessage(), and null.

Referenced by ILIAS\Calendar\ConsultationHours\BookingDataProvider\__construct().

69  : void
70  {
71  $data = [];
72  $counter = 0;
73  foreach (ilConsultationHourAppointments::getAppointments($this->getUserId()) as $appointment) {
74  $booking = new ilBookingEntry($appointment->getContextId());
75  $booked_user_ids = $booking->getCurrentBookings($appointment->getEntryId());
76  if ($this->isFiltered($appointment, $booking, $booked_user_ids)) {
77  continue;
78  }
79 
80  $row = [];
81  $row['id'] = (string) $appointment->getEntryId();
82  $row['booking_start'] = (new \DateTimeImmutable())->setTimestamp($appointment->getStart()->getUnixTime());
83  $row['booking_duration'] =
84  (int) ($appointment->getEnd()->getUnixTime() - $appointment->getStart()->getUnixTime()) / 60;
85  $row['booking_title'] = $appointment->getTitle();
86 
87  $obj_ids = array_map(
88  'intval',
89  ilUtil::_sortIds($booking->getTargetObjIds(), 'object_data', 'title', 'obj_id')
90  );
91  // locations
92  $locations = [];
93  foreach ($obj_ids as $obj_id) {
94  $link = null;
95  foreach (ilObject::_getAllReferences($obj_id) as $ref_id) {
96  $link = $this->static_url_service->builder()->build(
97  ilObject::_lookupType($obj_id),
98  new ReferenceId($ref_id)
99  );
100  $locations[] = $this->ui_factory->link()->standard(
101  ilObject::_lookupTitle($obj_id),
102  (string) $link
103  );
104  break;
105  }
106  }
107  $row['booking_location'] = $this->ui_factory->listing()->unordered($locations);
108 
109  // booking users
110  $booked_user_ids = array_map('intval', ilUtil::_sortIds($booked_user_ids, 'usr_data', 'lastname', 'usr_id'));
111  $bookings = [];
112  $comments = [];
113  foreach ($booked_user_ids as $booked_user_id) {
114  $fullname = ilObjUser::_lookupFullname($booked_user_id);
115  $link = \ilUserUtil::getProfileLink($booked_user_id);
116  $ui_link = $this->ui_factory->link()->standard(
117  $fullname,
118  $link ? $link : '#'
119  );
120  if ($link === '') {
121  $ui_link = $ui_link->withDisabled(true);
122  }
123  $bookings[] = $ui_link;
124 
126  $appointment->getEntryId(),
127  $booked_user_id
128  );
129  if (trim($comment) !== '') {
130  $ui_link = $this->ui_factory->link()
131  ->standard(
132  $fullname . ': "' . $comment . '"',
133  '#'
134  )
135  ->withDisabled(true);
136  $comments[] = $ui_link;
137  }
138 
139  }
140  $row['booking_participant'] = $this->ui_factory->listing()->unordered($bookings);
141  $row['booking_comment'] = $this->ui_factory->listing()->unordered($comments);
142  $data[$counter++] = $row;
143  }
144  $this->data = $data;
145  }
static _lookupFullname(int $a_user_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static getProfileLink(int $a_usr_id)
Get link to personal profile Return empty string in case of not public profile.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
$comments
$comment
Definition: buildRTE.php:72
static getAppointments(int $a_user_id)
Get all appointments.
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),&#39;usr_data&#39;,&#39;lastname&#39;,&#39;usr_id&#39;) => sorts by lastname.
static lookupBookingMessage(int $a_entry_id, int $a_usr_id)
isFiltered(ilCalendarEntry $entry, ilBookingEntry $booking, array $booked_users)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sortData()

ILIAS\Calendar\ConsultationHours\BookingDataProvider::sortData ( Order  $order)

Definition at line 184 of file BookingDataProvider.php.

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\Calendar\ConsultationHours\BookingDataProvider\$data, ILIAS\Calendar\ConsultationHours\BookingDataProvider\getData(), and ILIAS\Data\Order\join().

Referenced by ILIAS\Calendar\ConsultationHours\BookingDataProvider\limitData().

184  : array
185  {
186  $data = $this->getData();
187  [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
188  usort($data, fn($a, $b) => $a[$order_field] <=> $b[$order_field]);
189  if ($order_direction === 'DESC') {
190  $data = array_reverse($data);
191  }
192  return $data;
193  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data

◆ $static_url_service

StaticURL Services ILIAS\Calendar\ConsultationHours\BookingDataProvider::$static_url_service
private

Definition at line 46 of file BookingDataProvider.php.

◆ $ui_factory

ILIAS UI Factory ILIAS\Calendar\ConsultationHours\BookingDataProvider::$ui_factory
private

Definition at line 47 of file BookingDataProvider.php.

◆ $user_id

int ILIAS\Calendar\ConsultationHours\BookingDataProvider::$user_id
private

◆ $vm_period

string ILIAS\Calendar\ConsultationHours\BookingDataProvider::$vm_period = ilConsultationHoursGUI::VIEW_MODE_PERIOD_ALL
private

◆ $vm_status

string ILIAS\Calendar\ConsultationHours\BookingDataProvider::$vm_status = ilConsultationHoursGUI::VIEW_MODE_STATUS_ALL
private

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