ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilAppointmentPresentationCourseGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
28  public function collectPropertiesAndActions(): void
29  {
31  $this->lng->loadLanguageModule("crs");
32 
33  $app = $this->appointment;
34 
35  $cat_info = $this->getCatInfo();
36 
37  $crs = new ilObjCourse($cat_info['obj_id'], false);
38  $files = ilCourseFile::_readFilesByCourse($cat_info['obj_id']);
39 
40  // get course ref id (this is possible, since courses only have one ref id)
41  $refs = ilObject::_getAllReferences($cat_info['obj_id']);
42  $crs_ref_id = current($refs);
43 
44  // add common section (title, description, object/calendar, location)
45  $this->addCommonSection($app, $cat_info['obj_id']);
46 
47  // add specific section only if the event is autogenerated.
48  if ($app['event']->isAutoGenerated()) {
49  //count number of files
50  if (count($files)) {
51  $this->has_files = true;
52  }
53 
54  $this->addInfoSection($this->lng->txt("cal_crs_info"));
55 
56  if ($crs->getImportantInformation()) {
57  $this->addInfoProperty(
58  $this->lng->txt("crs_important_info"),
59  ilUtil::makeClickable(nl2br($crs->getImportantInformation()))
60  );
61  }
62 
63  if ($crs->getSyllabus()) {
64  $this->addInfoProperty(
65  $this->lng->txt("crs_syllabus"),
66  ilUtil::makeClickable(nl2br($crs->getSyllabus()))
67  );
68  }
69 
70  if ($this->has_files) {
71  $links = array();
72  foreach ($files as $file) {
73  $this->ctrl->setParameter($this, 'file_id', $file->getFileId());
74  $this->ctrl->setParameterByClass('ilobjcoursegui', 'file_id', $file->getFileId());
75  $this->ctrl->setParameterByClass('ilobjcoursegui', 'ref_id', $crs_ref_id);
76 
77  $file_name = $file->getFileName();
78  $links[$file_name] = $this->ui->renderer()->render(($this->ui->factory()->button()->shy(
79  $file_name,
80  $this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilobjcoursegui"), 'sendfile')
81  )));
82 
83  $this->ctrl->setParameterByClass('ilobjcoursegui', 'ref_id', '');
84  }
85  ksort($links, SORT_NATURAL | SORT_FLAG_CASE);
86 
87  $this->addInfoProperty($this->lng->txt("files"), implode("<br>", $links));
88  $this->addListItemProperty($this->lng->txt("files"), implode(", ", $links));
89  }
90 
91  // tutorial support members
92  $parts = ilParticipants::getInstanceByObjId($cat_info['obj_id']);
93  //contacts is an array of user ids.
94  $contacts = $parts->getContacts();
95  $sorted_ids = ilUtil::_sortIds($contacts, 'usr_data', 'lastname', 'usr_id');
96 
97  $names = [];
98  foreach ($sorted_ids as $usr_id) {
99  $name_presentation = $this->getUserName((int) $usr_id, true);
100  if (strlen($name_presentation)) {
101  $names[] = $name_presentation;
102  }
103  }
104  if (count($names)) {
105  $this->addInfoProperty($this->lng->txt('crs_mem_contacts'), implode('<br/>', $names));
106  $this->addListItemProperty($this->lng->txt('crs_mem_contacts'), implode('<br />', $names));
107  }
108 
109  //course contact
110  $contact_info = [];
111  if ($crs->getContactName()) {
112  $contact_info[] = [
113  'name' => $this->lng->txt('crs_contact_name'),
114  'value' => $crs->getContactName()
115  ];
116  }
117 
118  if ($crs->getContactEmail()) {
119  //TODO: optimize this
120  //$courseGUI = new ilObjCourseGUI("", $crs_ref_id);
121  $emails = explode(",", $crs->getContactEmail());
122  foreach ($emails as $email) {
123  $email = trim($email);
124  $etpl = new ilTemplate("tpl.crs_contact_email.html", true, true, 'components/ILIAS/Course');
125  $etpl->setVariable(
126  "EMAIL_LINK",
128  $this->getInfoScreen(),
129  'showSummary',
130  array(),
131  array(
132  'type' => 'new',
133  'rcp_to' => $email,
134  //'sig' => $courseGUI->createMailSignature()
135  ),
136  array(
138  'ref_id' => $crs->getRefId(),
139  'ts' => time()
140  )
141  )
142  );
143  $etpl->setVariable("CONTACT_EMAIL", $email);
144  $contact_info[] = [
145  'name' => $this->lng->txt('crs_contact_email'),
146  'value' => $etpl->get()
147  ];
148  }
149  }
150 
151  if ($crs->getContactPhone()) {
152  $contact_info[] = [
153  'name' => $this->lng->txt('crs_contact_phone'),
154  'value' => $crs->getContactPhone()
155  ];
156  }
157  if ($crs->getContactResponsibility()) {
158  $contact_info[] = [
159  'name' => $this->lng->txt('crs_contact_responsibility'),
160  'value' => $crs->getContactResponsibility()
161  ];
162  }
163  if ($crs->getContactConsultation()) {
164  $contact_info[] = [
165  'name' => $this->lng->txt('crs_contact_consultation'),
166  'value' => nl2br($crs->getContactConsultation())
167  ];
168  }
169  if ($contact_info !== []) {
170  $this->addInfoSection($this->lng->txt('crs_contact'));
171  foreach ($contact_info as $info) {
172  $this->addInfoProperty(
173  $info['name'],
174  $info['value']
175  );
176  }
177  }
178  $this->addMetaData('crs', $cat_info['obj_id']);
179 
180  // last edited
181  $this->addLastUpdate($app);
182  }
183 
184  $this->addAction($this->lng->txt("crs_open"), ilLink::_getStaticLink($crs_ref_id, "crs"));
185 
186  // register/unregister to appointment
187  if ($settings->isCGRegistrationEnabled()) {
188  if (!$app['event']->isAutoGenerated()) {
189  $reg = new ilCalendarRegistration($app['event']->getEntryId());
190 
191  if ($reg->isRegistered(
192  $this->user->getId(),
193  new ilDateTime($app['dstart'], IL_CAL_UNIX),
194  new ilDateTime($app['dend'], IL_CAL_UNIX)
195  )) {
196  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
197  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $app['event']->getEntryId());
198  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $app['dstart']);
199  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $app['dend']);
200 
201  $this->addAction(
202  $this->lng->txt('cal_reg_unregister'),
203  $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmUnregister')
204  );
205  } else {
206  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
207  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $app['event']->getEntryId());
208  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $app['dstart']);
209  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $app['dend']);
210 
211  $this->addAction(
212  $this->lng->txt('cal_reg_register'),
213  $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmRegister')
214  );
215  }
216 
217  $registered = $reg->getRegisteredUsers(
218  new \ilDateTime($app['dstart'], IL_CAL_UNIX),
219  new \ilDateTime($app['dend'], IL_CAL_UNIX)
220  );
221 
222  $users = "";
223  foreach ($registered as $user) {
224  $users .= $this->getUserName($user) . '<br />';
225  }
226  if ($users != "") {
227  $this->addInfoProperty($this->lng->txt("cal_reg_registered_users"), $users);
228  }
229  }
230  }
231  }
232 }
addListItemProperty(string $a_txt, string $a_val)
Add list item property.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
static _getAllReferences(int $id)
get all reference ids for object ID
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
static getLinkTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
static _readFilesByCourse(int $a_course_id)
const IL_CAL_UNIX
addInfoSection(string $a_txt)
Add info section.
addInfoProperty(string $a_txt, string $a_val)
Add info property.
addLastUpdate(array $a_app)
Add last update.
registration for calendar appointments
getUserName(int $a_user_id, bool $a_force_name=false)
Get (linked if possible) user name.
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.
addCommonSection(array $a_app, int $a_obj_id=0, ?array $cat_info=null, bool $a_container_info=false)
final const string CONTEXT_KEY
addAction(string $a_txt, string $a_link)
Add action.
$info
Definition: entry_point.php:21
addMetaData(string $a_obj_type, int $a_obj_id, ?string $a_sub_obj_type=null, ?int $a_sub_obj_id=null)
static makeClickable(string $a_text, bool $detectGotoLinks=false)