ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAppointmentPresentationCourseGUI.php
Go to the documentation of this file.
1 <?php
2 include_once './Services/Calendar/interfaces/interface.ilCalendarAppointmentPresentation.php';
3 include_once './Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationGUI.php';
4 
15 {
16  protected $ctrl;
17 
18 
19  public function collectPropertiesAndActions()
20  {
21  global $DIC;
22 
24  $user = $DIC->user();
25 
26  include_once('./Services/Link/classes/class.ilLink.php');
27 
28  $this->lng->loadLanguageModule("crs");
29 
30  $app = $this->appointment;
31 
32  $this->ctrl = $DIC->ctrl();
33 
34  include_once "./Modules/Course/classes/class.ilObjCourse.php";
35  include_once "./Modules/Course/classes/class.ilCourseFile.php";
36 
37  $cat_info = $this->getCatInfo();
38 
39  $crs = new ilObjCourse($cat_info['obj_id'], false);
40  $files = ilCourseFile::_readFilesByCourse($cat_info['obj_id']);
41 
42  // get course ref id (this is possible, since courses only have one ref id)
43  $refs = ilObject::_getAllReferences($cat_info['obj_id']);
44  $crs_ref_id = current($refs);
45 
46  // add common section (title, description, object/calendar, location)
47  $this->addCommonSection($app, $cat_info['obj_id']);
48 
49  //count number of files
50  if (count($files)) {
51  $this->has_files = true;
52  }
53  // add specific section only if the event is autogenerated.
54  if ($app['event']->isAutoGenerated()) {
55  $this->addInfoSection($this->lng->txt("cal_crs_info"));
56 
57  if ($crs->getImportantInformation()) {
58  $this->addInfoProperty($this->lng->txt("crs_important_info"), ilUtil::makeClickable(nl2br($crs->getImportantInformation())));
59  }
60 
61  if ($crs->getSyllabus()) {
62  $this->addInfoProperty($this->lng->txt("crs_syllabus"), ilUtil::makeClickable(nl2br($crs->getSyllabus())));
63  }
64 
65  if ($this->has_files) {
66  $links = array();
67  foreach ($files as $file) {
68  $this->ctrl->setParameter($this, 'file_id', $file->getFileId());
69  $this->ctrl->setParameterByClass('ilobjcoursegui', 'file_id', $file->getFileId());
70  $this->ctrl->setParameterByClass('ilobjcoursegui', 'ref_id', $crs_ref_id);
71 
72  $file_name = $file->getFileName();
73  $links[$file_name] = $this->ui->renderer()->render(($this->ui->factory()->button()->shy(
74  $file_name,
75  $this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilobjcoursegui"), 'sendfile')
76  )));
77 
78  $this->ctrl->setParameterByClass('ilobjcoursegui', 'ref_id', $_GET["ref_id"]);
79  }
80  ksort($links, SORT_NATURAL | SORT_FLAG_CASE);
81 
82  $this->addInfoProperty($this->lng->txt("files"), implode("<br>", $links));
83  $this->addListItemProperty($this->lng->txt("files"), implode(", ", $links));
84  }
85 
86  // tutorial support members
87  $parts = ilParticipants::getInstanceByObjId($cat_info['obj_id']);
88  //contacts is an array of user ids.
89  $contacts = $parts->getContacts();
90  $sorted_ids = ilUtil::_sortIds($contacts, 'usr_data', 'lastname', 'usr_id');
91 
92  $names = [];
93  foreach ($sorted_ids as $usr_id) {
94  $name_presentation = $this->getUserName($usr_id, true);
95  if (strlen($name_presentation)) {
96  $names[] = $name_presentation;
97  }
98  }
99  if (count($names)) {
100  $this->addInfoProperty($this->lng->txt('crs_mem_contacts'), implode('<br/>', $names));
101  $this->addListItemProperty($this->lng->txt('crs_mem_contacts'), implode('<br />', $names));
102  }
103 
104  //course contact
105  $contact_fields = false;
106  $str = "";
107  if ($crs->getContactName()) {
108  $str .= $crs->getContactName() . "<br>";
109  }
110 
111  if ($crs->getContactEmail()) {
112  //TODO: optimize this
113  //$courseGUI = new ilObjCourseGUI("", $crs_ref_id);
114  $emails = explode(",", $crs->getContactEmail());
115  foreach ($emails as $email) {
116  $email = trim($email);
117  $etpl = new ilTemplate("tpl.crs_contact_email.html", true, true, 'Modules/Course');
118  $etpl->setVariable(
119  "EMAIL_LINK",
121  $this->getInfoScreen(),
122  'showSummary',
123  array(),
124  array(
125  'type' => 'new',
126  'rcp_to' => $email,
127  //'sig' => $courseGUI->createMailSignature()
128  ),
129  array(
131  'ref_id' => $crs->getRefId(),
132  'ts' => time()
133  )
134  )
135  );
136  $etpl->setVariable("CONTACT_EMAIL", $email);
137  $str .= $etpl->get() . "<br />";
138  }
139  }
140 
141  if ($crs->getContactPhone()) {
142  $str .= $this->lng->txt("crs_contact_phone") . ": " . $crs->getContactPhone() . "<br>";
143  }
144  if ($crs->getContactResponsibility()) {
145  $str .= $crs->getContactResponsibility() . "<br>";
146  }
147  if ($crs->getContactConsultation()) {
148  $str .= $crs->getContactConsultation() . "<br>";
149  }
150 
151  if ($str != "") {
152  $this->addInfoProperty($this->lng->txt("crs_contact"), $str);
153  $this->addListItemProperty($this->lng->txt("crs_contact"), str_replace("<br>", ", ", $str));
154  }
155 
156  $this->addMetaData('crs', $cat_info['obj_id']);
157 
158  // last edited
159  $this->addLastUpdate($app);
160  }
161 
162  $this->addAction($this->lng->txt("crs_open"), ilLink::_getStaticLink($crs_ref_id, "crs"));
163 
164  // register/unregister to appointment
165  if ($settings->isCGRegistrationEnabled()) {
166  if (!$app['event']->isAutoGenerated()) {
167  include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
168  $reg = new ilCalendarRegistration($app['event']->getEntryId());
169 
170  if ($reg->isRegistered($user->getId(), new ilDateTime($app['dstart'], IL_CAL_UNIX), new ilDateTime($app['dend'], IL_CAL_UNIX))) {
171  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
172  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $app['event']->getEntryId());
173  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $app['dstart']);
174  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $app['dend']);
175 
176  $this->addAction($this->lng->txt('cal_reg_unregister'), $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmUnregister'));
177  } else {
178  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->getSeed()->get(IL_CAL_DATE));
179  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $app['event']->getEntryId());
180  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $app['dstart']);
181  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $app['dend']);
182 
183  $this->addAction($this->lng->txt('cal_reg_register'), $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmRegister'));
184  }
185 
186  $registered = $reg->getRegisteredUsers(
187  new \ilDateTime($app['dstart'], IL_CAL_UNIX),
188  new \ilDateTime($app['dend'], IL_CAL_UNIX)
189  );
190 
191  $users = "";
192  foreach ($registered as $user) {
193  $users .= $this->getUserName($user) . '<br />';
194  }
195  if ($users != "") {
196  $this->addInfoProperty($this->lng->txt("cal_reg_registered_users"), $users);
197  }
198  }
199  }
200  }
201 }
addInfoProperty($a_txt, $a_val)
Add info property.
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
static _getInstance()
get singleton instance
getUserName($a_user_id, $a_force_name=false)
Get (linked if possible) user name.
$files
Definition: metarefresh.php:49
global $DIC
Definition: saml.php:7
$_GET["client_id"]
const IL_CAL_UNIX
static _getAllReferences($a_id)
get all reference ids of object
static getLinkTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), $context_params=array())
Class ilObjCourse.
addCommonSection($a_app, $a_obj_id=0, $cat_info=null, $a_container_info=false)
Add common section.
static _sortIds($a_ids, $a_table, $a_field, $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 makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
registration for calendar appointments
special template class to simplify handling of ITX/PEAR
Date and time handling
$user
Definition: migrateto20.php:57
static _readFilesByCourse($a_course_id)
$users
Definition: authpage.php:44
const CONTEXT_KEY
Session parameter for the context.
addMetaData($a_obj_type, $a_obj_id, $a_sub_obj_type=null, $a_sub_obj_id=null)
Add metadata.
addListItemProperty($a_txt, $a_val)
Add list item property.
$links
static getInstanceByObjId($a_obj_id)
Get instance by obj type.