ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
VCalendarGenerator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  protected \ilLanguage $lng;
26 
27  public function __construct(\ilLanguage $lng)
28  {
29  $this->lng = $lng;
30  }
31 
32  public function fromTalkSeries(
33  \ilObjEmployeeTalkSeries $series,
34  \ilObjUser $employee,
35  \ilObjUser $superior,
36  Method $method = Method::PUBLISH
37  ): string {
38  $events = [];
39  foreach ($series->getChildTalks() as $talk) {
40  $events[] = $this->getEventfromTalk($talk, $employee, $superior);
41  }
42 
43  $calendar = new VCalendar(
44  $method,
45  $series->getTitle(),
46  md5($series->getType() . $series->getId()),
47  ...$events
48  );
49 
50  return $calendar->render();
51  }
52 
53  protected function getEventfromTalk(
54  \ilObjEmployeeTalk $talk,
55  \ilObjUser $employee,
56  \ilObjUser $superior,
57  EventStatus $status = EventStatus::CONFIRMED
58  ): VEvent {
59  $data = $talk->getData();
60 
61  //The string \n must not be parsed by PHP, the email / calendar clients handel the line breaks by them self
62  $description = $this->lng->txt('title') . ': ' . $talk->getTitle() . '\n';
63  $description .= $this->lng->txt('desc') . ': ' . $talk->getLongDescription() . '\n';
64  $description .= $this->lng->txt('location') . ': ' . $talk->getLongDescription() . '\n';
65  $description .= $this->lng->txt('il_orgu_superior') . ': ' . $superior->getFullname() . '\n';
66  $description .= $this->lng->txt('il_orgu_employee') . ': ' . $employee->getFullname() . '\n';
67 
68  return new VEvent(
69  md5($talk->getType() . $talk->getId()),
70  $description,
71  $talk->getTitle(),
72  0,
73  $status,
74  $superior->getFullname(),
75  $superior->getEmail(),
76  $employee->getFullname(),
77  $employee->getEmail(),
78  $data->getStartDate()->getUnixTime(),
79  $data->getEndDate()->getUnixTime(),
80  $data->isAllDay(),
81  '',
82  $data->getLocation()
83  );
84  }
85 }
getFullname(int $a_max_strlen=0)
getEventfromTalk(\ilObjEmployeeTalk $talk, \ilObjUser $employee, \ilObjUser $superior, EventStatus $status=EventStatus::CONFIRMED)
fromTalkSeries(\ilObjEmployeeTalkSeries $series, \ilObjUser $employee, \ilObjUser $superior, Method $method=Method::PUBLISH)
getLongDescription()
get object long description (stored in object_description)