ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilEmployeeTalkAppointmentGUI Class Reference

Class ilEmployeeTalkAppointmentGUI. More...

+ Inheritance diagram for ilEmployeeTalkAppointmentGUI:
+ Collaboration diagram for ilEmployeeTalkAppointmentGUI:

Public Member Functions

 __construct (ilGlobalTemplateInterface $template, ilLanguage $language, ilCtrl $ctrl, HttpServices $http, Refinery $refinery, ilTabsGUI $tabs, NotificationHandlerInterface $notif_handler, ilObjEmployeeTalk $talk)
 
 executeCommand ()
 
 executeCommand ()
 

Data Fields

const string EDIT_MODE_APPOINTMENT = 'appointment'
 
const string EDIT_MODE_SERIES = 'series'
 
const string EDIT_MODE = 'edit-mode'
 

Protected Member Functions

 getPendingTalkDates ()
 

Protected Attributes

NotificationHandlerInterface $notif_handler
 

Private Member Functions

 executeSeriesCommand (string $cmd)
 
 executeAppointmentCommand (string $cmd)
 
 editSeries ()
 
 updateSeries ()
 
 initTalkEditForm (?EmployeeTalk $employeeTalk=null)
 
 initSeriesEditForm (?EmployeeTalk $employeeTalk=null)
 
 editAppointment ()
 
 sendNotification (ilObjEmployeeTalk ... $talks)
 
 editMode ()
 
 getEditModeParameter (string $mode)
 
 loadRecurrenceSettings (ilPropertyFormGUI $form)
 
 getPendingTalksInSeries (ilObjEmployeeTalkSeries $series)
 
 deleteTalks (array $talks)
 

Private Attributes

ilGlobalTemplateInterface $template
 
ilLanguage $language
 
ilCtrl $ctrl
 
HttpServices $http
 
Refinery $refinery
 
ilTabsGUI $tabs
 
ilObjEmployeeTalk $talk
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilEmployeeTalkAppointmentGUI::__construct ( ilGlobalTemplateInterface  $template,
ilLanguage  $language,
ilCtrl  $ctrl,
HttpServices  $http,
Refinery  $refinery,
ilTabsGUI  $tabs,
NotificationHandlerInterface  $notif_handler,
ilObjEmployeeTalk  $talk 
)

Definition at line 51 of file class.ilEmployeeTalkAppointmentGUI.php.

60 {
61 $this->template = $template;
62 $this->language = $language;
63 $this->ctrl = $ctrl;
64 $this->http = $http;
65 $this->refinery = $refinery;
66 $this->tabs = $tabs;
67 $this->notif_handler = $notif_handler;
68 $this->talk = $talk;
69
70 $this->language->loadLanguageModule('cal');
71 }
static http()
Fetches the global http state from ILIAS.

References $ctrl, $http, $language, $notif_handler, $refinery, $tabs, $talk, $template, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\refinery(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

Member Function Documentation

◆ deleteTalks()

ilEmployeeTalkAppointmentGUI::deleteTalks ( array  $talks)
private
Parameters
ilObjEmployeeTalk[]$talks

Definition at line 534 of file class.ilEmployeeTalkAppointmentGUI.php.

534 : void
535 {
536 foreach ($talks as $talk) {
537 $talk->delete();
538 }
539 }
delete()
delete object or referenced object (in the case of a referenced object, object data is only deleted i...

References $talk, and ilObject\delete().

Referenced by updateSeries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editAppointment()

ilEmployeeTalkAppointmentGUI::editAppointment ( )
private

Definition at line 264 of file class.ilEmployeeTalkAppointmentGUI.php.

264 : void
265 {
266 $form = $this->initTalkEditForm($this->talk->getData());
267
268 $this->template->setContent($form->getHTML());
269 }
initTalkEditForm(?EmployeeTalk $employeeTalk=null)

References initTalkEditForm().

Referenced by executeAppointmentCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editMode()

ilEmployeeTalkAppointmentGUI::editMode ( )
private

Definition at line 318 of file class.ilEmployeeTalkAppointmentGUI.php.

318 : string
319 {
320 $mode = '';
321 if ($this->http->wrapper()->query()->has(self::EDIT_MODE)) {
322 $mode = $this->http->wrapper()->query()->retrieve(
323 self::EDIT_MODE,
324 $this->refinery->kindlyTo()->string()
325 );
326 }
327 if ($mode === self::EDIT_MODE_SERIES || $mode === self::EDIT_MODE_APPOINTMENT) {
328 return $mode;
329 }
330 return 'invalid';
331 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editSeries()

ilEmployeeTalkAppointmentGUI::editSeries ( )
private

Definition at line 135 of file class.ilEmployeeTalkAppointmentGUI.php.

135 : void
136 {
137 if (($dates_string = $this->getPendingTalkDates()) !== '') {
138 $message = $this->language->txt('pending_talks_warning');
139 $this->template->setOnScreenMessage('info', $message . $dates_string);
140 }
141 $form = $this->initSeriesEditForm($this->talk->getData());
142
143 $this->template->setContent($form->getHTML());
144 }
initSeriesEditForm(?EmployeeTalk $employeeTalk=null)
$message
Definition: xapiexit.php:31

References $message, getPendingTalkDates(), initSeriesEditForm(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by executeSeriesCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeAppointmentCommand()

ilEmployeeTalkAppointmentGUI::executeAppointmentCommand ( string  $cmd)
private

Definition at line 121 of file class.ilEmployeeTalkAppointmentGUI.php.

121 : void
122 {
123 $this->template->setTitle($this->language->txt('etal_date_appointment_edit'));
124
125 switch ($cmd) {
126 case ControlFlowCommand::UPDATE_INDEX:
127 $this->editAppointment();
128 return;
129 case ControlFlowCommand::UPDATE:
130 $this->updateAppointment();
131 return;
132 }
133 }

References editAppointment(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilEmployeeTalkAppointmentGUI::executeCommand ( )

Implements ILIAS\EmployeeTalk\UI\ControlFlowCommandHandler.

Definition at line 73 of file class.ilEmployeeTalkAppointmentGUI.php.

73 : void
74 {
75 $cmd = $this->ctrl->getCmd(ControlFlowCommand::DEFAULT);
76 if ($this->http->wrapper()->query()->has('ref_id')) {
77 $ref_id = $this->http->wrapper()->query()->retrieve(
78 'ref_id',
79 $this->refinery->kindlyTo()->int()
80 );
81 } else {
83 'No ref_id found'
84 );
85 }
86
87 $backClass = strtolower(ilObjEmployeeTalkGUI::class);
88 $this->ctrl->setParameterByClass($backClass, 'ref_id', $ref_id);
89 $this->tabs->setBackTarget(
90 $this->language->txt('back'),
91 $this->ctrl->getLinkTargetByClass(strtolower(ilObjEmployeeTalkGUI::class), ControlFlowCommand::UPDATE)
92 );
93
94 switch ($this->editMode()) {
96 $this->executeSeriesCommand($cmd);
97 break;
99 $this->executeAppointmentCommand($cmd);
100 break;
101 default:
102 $this->ctrl->redirectByClass(strtolower(ilObjEmployeeTalkGUI::class), ControlFlowCommand::UPDATE);
103 break;
104 }
105 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, ILIAS\Repository\ctrl(), ILIAS\Forum\Notification\DEFAULT, EDIT_MODE_APPOINTMENT, EDIT_MODE_SERIES, editMode(), executeAppointmentCommand(), executeSeriesCommand(), ILIAS\FileDelivery\http(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\refinery(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ executeSeriesCommand()

ilEmployeeTalkAppointmentGUI::executeSeriesCommand ( string  $cmd)
private

Definition at line 107 of file class.ilEmployeeTalkAppointmentGUI.php.

107 : void
108 {
109 $this->template->setTitle($this->language->txt('etal_date_series_edit'));
110
111 switch ($cmd) {
112 case ControlFlowCommand::UPDATE_INDEX:
113 $this->editSeries();
114 return;
115 case ControlFlowCommand::UPDATE:
116 $this->updateSeries();
117 return;
118 }
119 }

References editSeries(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and updateSeries().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEditModeParameter()

ilEmployeeTalkAppointmentGUI::getEditModeParameter ( string  $mode)
private

Definition at line 333 of file class.ilEmployeeTalkAppointmentGUI.php.

333 : string
334 {
335 return '&' . ilEmployeeTalkAppointmentGUI::EDIT_MODE . '=' . $mode;
336 }

References EDIT_MODE.

Referenced by initSeriesEditForm(), initTalkEditForm(), and updateSeries().

+ Here is the caller graph for this function:

◆ getPendingTalkDates()

ilEmployeeTalkAppointmentGUI::getPendingTalkDates ( )
protected

Definition at line 146 of file class.ilEmployeeTalkAppointmentGUI.php.

146 : string
147 {
148 $parent = $this->talk->getParent();
149 $talks = $this->getPendingTalksInSeries($parent);
150
151 usort($talks, function (ilObjEmployeeTalk $a, ilObjEmployeeTalk $b) {
152 $a = $a->getData()->getStartDate()->getUnixTime();
153 $b = $b->getData()->getStartDate()->getUnixTime();
154 if ($a === $b) {
155 return 0;
156 }
157 return $a < $b ? -1 : 1;
158 });
159
160 $dates = '';
163 foreach ($talks as $talk) {
164 $dates .= "</br>" . ilDatePresentation::formatDate($talk->getData()->getStartDate());
165 }
167 return $dates;
168 }
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
getPendingTalksInSeries(ilObjEmployeeTalkSeries $series)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, $talk, ilDatePresentation\formatDate(), ilObjEmployeeTalk\getData(), getPendingTalksInSeries(), ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

Referenced by editSeries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPendingTalksInSeries()

ilEmployeeTalkAppointmentGUI::getPendingTalksInSeries ( ilObjEmployeeTalkSeries  $series)
private
Returns
ilObjEmployeeTalk[]

Definition at line 511 of file class.ilEmployeeTalkAppointmentGUI.php.

511 : array
512 {
513 $talks = [];
514 $subItems = $series->getSubItems()['_all'];
515
516 foreach ($subItems as $subItem) {
517 if ($subItem['type'] === 'etal') {
518 $refId = intval($subItem['ref_id']);
519 $talk = new ilObjEmployeeTalk($refId, true);
520 $talk_data = $talk->getData();
521 if ($talk_data->isStandalone() || $talk_data->isCompleted()) {
522 continue;
523 }
524 $talks[] = $talk;
525 }
526 }
527
528 return $talks;
529 }
getSubItems(bool $a_admin_panel_enabled=false, bool $a_include_side_block=false, int $a_get_single=0, ?ilContainerUserFilter $container_user_filter=null)
$refId
Definition: xapitoken.php:58

References $refId, $talk, ilObjEmployeeTalk\getData(), and ilContainer\getSubItems().

Referenced by getPendingTalkDates(), and updateSeries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSeriesEditForm()

ilEmployeeTalkAppointmentGUI::initSeriesEditForm ( ?EmployeeTalk  $employeeTalk = null)
private

Definition at line 223 of file class.ilEmployeeTalkAppointmentGUI.php.

224 {
225 $form = new ilPropertyFormGUI();
227 $form->setFormAction($this->ctrl->getFormActionByClass(
228 strtolower(self::class)
229 ) . $editMode);
230
231 $header = new ilFormSectionHeaderGUI();
232 $header->setTitle($this->language->txt('appointments'));
233 $form->addItem($header);
234
235 $dur = new ilDateDurationInputGUI($this->language->txt('cal_fullday'), 'event');
236 $dur->setRequired(true);
237 $dur->setShowTime(true);
238
239 if ($employeeTalk !== null) {
240 $dur->enableToggleFullTime(
241 $this->language->txt('cal_fullday_title'),
242 $employeeTalk->isAllDay()
243 );
244
245 $dur->setStart($employeeTalk->getStartDate());
246 $dur->setEnd($employeeTalk->getEndDate());
247 }
248
249 $form->addItem($dur);
250
251 // Recurrence
252 $cal = new ilRecurrenceInputGUI($this->language->txt('cal_recurrences'), "frequence");
253 $event = new ilCalendarRecurrence();
254
255 $cal->allowUnlimitedRecurrences(false);
256 $cal->setRecurrence($event);
257
258 $form->addItem($cal);
259 $form->addCommandButton(ControlFlowCommand::UPDATE, $this->language->txt('save'), 'etal_series_save');
260
261 return $form;
262 }
Model of calendar entry recurrcences based on iCalendar-RFC-5545.
input GUI for a time span (start and end date)
This class represents a section header in a property form.
This class represents a property form user interface.
This class represents an input GUI for recurring events/appointments (course events or calendar appoi...

References ILIAS\Repository\ctrl(), EDIT_MODE_SERIES, getEditModeParameter(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by editSeries(), and updateSeries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTalkEditForm()

ilEmployeeTalkAppointmentGUI::initTalkEditForm ( ?EmployeeTalk  $employeeTalk = null)
private

Definition at line 191 of file class.ilEmployeeTalkAppointmentGUI.php.

192 {
193 $form = new ilPropertyFormGUI();
195 $form->setFormAction($this->ctrl->getFormActionByClass(
196 strtolower(self::class)
197 ) . $editMode);
198
199 $header = new ilFormSectionHeaderGUI();
200 $header->setTitle($this->language->txt('appointment'));
201 $form->addItem($header);
202
203 $dur = new ilDateDurationInputGUI($this->language->txt('cal_fullday'), 'event');
204 $dur->setRequired(true);
205 $dur->setShowTime(true);
206
207 if ($employeeTalk !== null) {
208 $dur->enableToggleFullTime(
209 $this->language->txt('cal_fullday_title'),
210 $employeeTalk->isAllDay()
211 );
212
213 $dur->setStart($employeeTalk->getStartDate());
214 $dur->setEnd($employeeTalk->getEndDate());
215 }
216
217 $form->addItem($dur);
218 $form->addCommandButton(ControlFlowCommand::UPDATE, $this->language->txt('save'), 'etal_date_save');
219
220 return $form;
221 }

References ILIAS\Repository\ctrl(), EDIT_MODE_APPOINTMENT, getEditModeParameter(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by editAppointment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadRecurrenceSettings()

ilEmployeeTalkAppointmentGUI::loadRecurrenceSettings ( ilPropertyFormGUI  $form)
private

Definition at line 338 of file class.ilEmployeeTalkAppointmentGUI.php.

339 {
340 $rec = new ilCalendarRecurrence();
341
342 switch ($form->getInput('frequence')) {
344 $rec->setFrequenceType($form->getInput('frequence'));
345 $rec->setInterval((int) $form->getInput('count_DAILY'));
346 break;
347
349 $rec->setFrequenceType($form->getInput('frequence'));
350 $rec->setInterval((int) $form->getInput('count_WEEKLY'));
351 if (is_array($form->getInput('byday_WEEKLY'))) {
352 $rec->setBYDAY(ilUtil::stripSlashes(implode(',', $form->getInput('byday_WEEKLY'))));
353 }
354 break;
355
357 $rec->setFrequenceType($form->getInput('frequence'));
358 $rec->setInterval((int) $form->getInput('count_MONTHLY'));
359 switch ((int) $form->getInput('subtype_MONTHLY')) {
360 case 0:
361 // nothing to do;
362 break;
363
364 case 1:
365 switch ((int) $form->getInput('monthly_byday_day')) {
366 case 8:
367 // Weekday
368 $rec->setBYSETPOS($form->getInput('monthly_byday_num'));
369 $rec->setBYDAY('MO,TU,WE,TH,FR');
370 break;
371
372 case 9:
373 // Day of month
374 $rec->setBYMONTHDAY($form->getInput('monthly_byday_num'));
375 break;
376
377 default:
378 $rec->setBYDAY(($form->getInput('monthly_byday_num') . $form->getInput('monthly_byday_day')));
379 break;
380 }
381 break;
382
383 case 2:
384 $rec->setBYMONTHDAY($form->getInput('monthly_bymonthday'));
385 break;
386 }
387 break;
388
390 $rec->setFrequenceType($form->getInput('frequence'));
391 $rec->setInterval((int) $form->getInput('count_YEARLY'));
392 switch ((int) $form->getInput('subtype_YEARLY')) {
393 case 0:
394 // nothing to do;
395 break;
396
397 case 1:
398 $rec->setBYMONTH($form->getInput('yearly_bymonth_byday'));
399 $rec->setBYDAY(($form->getInput('yearly_byday_num') . $form->getInput('yearly_byday')));
400 break;
401
402 case 2:
403 $rec->setBYMONTH($form->getInput('yearly_bymonth_by_monthday'));
404 $rec->setBYMONTHDAY($form->getInput('yearly_bymonthday'));
405 break;
406 }
407 break;
408 }
409
410 // UNTIL
411 switch ((int) $form->getInput('until_type')) {
412 case 1:
413 $rec->setFrequenceUntilDate(null);
414 // nothing to do
415 break;
416
417 case 2:
418 $rec->setFrequenceUntilDate(null);
419 $rec->setFrequenceUntilCount((int) $form->getInput('count'));
420 break;
421
422 case 3:
423 $frequence = $form->getItemByPostVar('frequence');
424 $end = $frequence->getRecurrence()->getFrequenceUntilDate();
425 $rec->setFrequenceUntilCount(0);
426 $rec->setFrequenceUntilDate($end);
427 break;
428 }
429
430 return $rec;
431 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilCalendarRecurrence\FREQ_DAILY, ilCalendarRecurrence\FREQ_MONTHLY, ilCalendarRecurrence\FREQ_WEEKLY, ilCalendarRecurrence\FREQ_YEARLY, ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), and ilUtil\stripSlashes().

Referenced by updateSeries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNotification()

ilEmployeeTalkAppointmentGUI::sendNotification ( ilObjEmployeeTalk ...  $talks)
private

Definition at line 313 of file class.ilEmployeeTalkAppointmentGUI.php.

313 : void
314 {
315 $this->notif_handler->send(NotificationType::UPDATE, ...$talks);
316 }

◆ updateSeries()

ilEmployeeTalkAppointmentGUI::updateSeries ( )
private

Definition at line 170 of file class.ilEmployeeTalkAppointmentGUI.php.

170 : void
171 {
172 $form = $this->initSeriesEditForm();
173 if ($form->checkInput()) {
174 $reoccurrence = $this->loadRecurrenceSettings($form);
175 $parent = $this->talk->getParent();
176 $old_talks = $this->getPendingTalksInSeries($parent);
177 $this->createRecurringTalks($form, $reoccurrence, $parent);
178 $this->deleteTalks($old_talks);
179
180 $this->template->setOnScreenMessage('success', $this->language->txt('saved_successfully'), true);
181 }
182
183 $this->ctrl->redirectToURL(
184 $this->ctrl->getLinkTargetByClass(
185 strtolower(ilEmployeeTalkMyStaffListGUI::class),
186 ControlFlowCommand::UPDATE_INDEX
188 );
189 }

References ILIAS\Repository\ctrl(), deleteTalks(), EDIT_MODE_SERIES, getEditModeParameter(), getPendingTalksInSeries(), initSeriesEditForm(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and loadRecurrenceSettings().

Referenced by executeSeriesCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilEmployeeTalkAppointmentGUI::$ctrl
private

Definition at line 44 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ $http

HttpServices ilEmployeeTalkAppointmentGUI::$http
private

Definition at line 45 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ $language

ilLanguage ilEmployeeTalkAppointmentGUI::$language
private

Definition at line 43 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ $notif_handler

NotificationHandlerInterface ilEmployeeTalkAppointmentGUI::$notif_handler
protected

Definition at line 48 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ $refinery

Refinery ilEmployeeTalkAppointmentGUI::$refinery
private

Definition at line 46 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ $tabs

ilTabsGUI ilEmployeeTalkAppointmentGUI::$tabs
private

Definition at line 47 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ $talk

ilObjEmployeeTalk ilEmployeeTalkAppointmentGUI::$talk
private

◆ $template

ilGlobalTemplateInterface ilEmployeeTalkAppointmentGUI::$template
private

Definition at line 42 of file class.ilEmployeeTalkAppointmentGUI.php.

Referenced by __construct().

◆ EDIT_MODE

const string ilEmployeeTalkAppointmentGUI::EDIT_MODE = 'edit-mode'

◆ EDIT_MODE_APPOINTMENT

const string ilEmployeeTalkAppointmentGUI::EDIT_MODE_APPOINTMENT = 'appointment'

◆ EDIT_MODE_SERIES

const string ilEmployeeTalkAppointmentGUI::EDIT_MODE_SERIES = 'series'

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