ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\EmployeeTalk\Notification\NotificationHandler Class Reference
+ Inheritance diagram for ILIAS\EmployeeTalk\Notification\NotificationHandler:
+ Collaboration diagram for ILIAS\EmployeeTalk\Notification\NotificationHandler:

Public Member Functions

 __construct (VCalendarGeneratorInterface $vcalendar_generator)
 
 send (NotificationType $type, \ilObjEmployeeTalk ... $affected_talks)
 All affected talks must come from the same series. More...
 

Protected Member Functions

 extractFormattedDates (string $format, string $timezone, \ilObjEmployeeTalk ... $talks)
 

Protected Attributes

VCalendarGeneratorInterface $vcalendar_generator
 

Detailed Description

Definition at line 25 of file NotificationHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\EmployeeTalk\Notification\NotificationHandler::__construct ( VCalendarGeneratorInterface  $vcalendar_generator)

Definition at line 29 of file NotificationHandler.php.

References ILIAS\EmployeeTalk\Notification\NotificationHandler\$vcalendar_generator.

31  {
32  $this->vcalendar_generator = $vcalendar_generator;
33  }

Member Function Documentation

◆ extractFormattedDates()

ILIAS\EmployeeTalk\Notification\NotificationHandler::extractFormattedDates ( string  $format,
string  $timezone,
\ilObjEmployeeTalk ...  $talks 
)
protected
Returns
string[]

Definition at line 90 of file NotificationHandler.php.

References Vendor\Package\$a, Vendor\Package\$b, ilDateTime\getUnixTime(), and IL_CAL_FKT_DATE.

Referenced by ILIAS\EmployeeTalk\Notification\NotificationHandler\send().

94  : array {
95  $dates = [];
96  foreach ($talks as $talk) {
97  $dates[] = $talk->getData()->getStartDate();
98  }
99 
100  usort($dates, function (\ilDateTime $a, \ilDateTime $b) {
101  $a = $a->getUnixTime();
102  $b = $b->getUnixTime();
103  if ($a === $b) {
104  return 0;
105  }
106  return $a < $b ? -1 : 1;
107  });
108 
109  $formatted_dates = [];
110  foreach ($dates as $date) {
111  $formatted_dates[] = $date->get(IL_CAL_FKT_DATE, $format, $timezone);
112  }
113  return $formatted_dates;
114  }
const IL_CAL_FKT_DATE
$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:

◆ send()

ILIAS\EmployeeTalk\Notification\NotificationHandler::send ( NotificationType  $type,
\ilObjEmployeeTalk ...  $affected_talks 
)

All affected talks must come from the same series.

Implements ILIAS\EmployeeTalk\Notification\NotificationHandlerInterface.

Definition at line 35 of file NotificationHandler.php.

References ILIAS\EmployeeTalk\Notification\CANCELLATION, ILIAS\EmployeeTalk\Notification\NotificationHandler\extractFormattedDates(), ilObjEmployeeTalk\getData(), ilObjEmployeeTalk\getParent(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), ilCalendarUtil\getUserDateFormat(), and ILIAS\EmployeeTalk\Notification\Notification\send().

38  : void {
39  if (count($affected_talks) === 0) {
40  return;
41  }
42 
43  $superior = new \ilObjUser($affected_talks[0]->getOwner());
44  $employee = new \ilObjUser($affected_talks[0]->getData()->getEmployee());
45 
46  switch ($type) {
47  case NotificationType::INVITATION:
48  $subject_key = 'notification_talks_subject';
49  $message_key = 'notification_talks_created';
50  $add_goto = true;
51  break;
52 
54  $subject_key = 'notification_talks_subject_update';
55  $message_key = 'notification_talks_removed';
56  $add_goto = false;
57  break;
58 
59  case NotificationType::UPDATE:
60  default:
61  $subject_key = 'notification_talks_subject_update';
62  $message_key = 'notification_talks_updated';
63  $add_goto = true;
64  break;
65  }
66 
67  $add_time = $affected_talks[0]->getData()->isAllDay() ? 0 : 1;
68  $format = \ilCalendarUtil::getUserDateFormat($add_time, true);
69  $timezone = $employee->getTimeZone();
70 
71  $notification = new Notification(
72  $employee,
73  $superior,
74  $affected_talks[0]->getRefId(),
75  $affected_talks[0]->getTitle(),
76  $affected_talks[0]->getDescription(),
77  $affected_talks[0]->getData()->getLocation(),
78  $subject_key,
79  $message_key,
80  $this->vcalendar_generator->fromTalkSeries($affected_talks[0]->getParent(), $employee, $superior),
81  $add_goto,
82  ...$this->extractFormattedDates($format, $timezone, ...$affected_talks)
83  );
84  $notification->send();
85  }
extractFormattedDates(string $format, string $timezone, \ilObjEmployeeTalk ... $talks)
static getUserDateFormat(int $a_add_time=0, bool $a_for_parsing=false)
Parse current user setting into date/time format.
+ Here is the call graph for this function:

Field Documentation

◆ $vcalendar_generator

VCalendarGeneratorInterface ILIAS\EmployeeTalk\Notification\NotificationHandler::$vcalendar_generator
protected

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