ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarAppointmentPanelGUI Class Reference

GUI class for YUI appointment panels. More...

+ Collaboration diagram for ilCalendarAppointmentPanelGUI:

Public Member Functions

 getSeed ()
 Get seed date. More...
 
 getHTML ($a_app)
 get HTML More...
 

Static Public Member Functions

static _getInstance (ilDate $seed)
 get singleton instance More...
 

Protected Member Functions

 __construct (ilDate $seed=null)
 Singleton. More...
 

Protected Attributes

 $seed = null
 
 $settings = null
 
 $tpl = null
 
 $lng = null
 
 $ctrl = null
 

Static Protected Attributes

static $counter = 0
 
static $instance = null
 

Detailed Description

GUI class for YUI appointment panels.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 34 of file class.ilCalendarAppointmentPanelGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarAppointmentPanelGUI::__construct ( ilDate  $seed = null)
protected

Singleton.

public

Parameters

Definition at line 54 of file class.ilCalendarAppointmentPanelGUI.php.

References $ilCtrl, $lng, $seed, ilCalendarSettings\_getInstance(), and settings().

55  {
56  global $lng,$ilCtrl;
57 
58  $this->lng = $lng;
59  $this->ctrl = $ilCtrl;
61 
62  $this->seed = $seed;
63  }
static _getInstance()
get singleton instance
global $ilCtrl
Definition: ilias.php:18
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstance()

static ilCalendarAppointmentPanelGUI::_getInstance ( ilDate  $seed)
static

get singleton instance

public

Parameters

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

74  {
75  if (isset(self::$instance) and self::$instance) {
76  return self::$instance;
77  }
78  return self::$instance = new ilCalendarAppointmentPanelGUI($seed);
79  }
GUI class for YUI appointment panels.

◆ getHTML()

ilCalendarAppointmentPanelGUI::getHTML (   $a_app)

get HTML

public

Parameters

Definition at line 97 of file class.ilCalendarAppointmentPanelGUI.php.

References $counter, $GLOBALS, $ilUser, $lng, $r, $title, $type, $users, ilDateTime\_after(), ilObject\_getAllReferences(), ilCalendarCategories\_getInstance(), ilLink\_getLink(), ilLink\_getStaticLink(), ilCalendarCategoryAssignments\_lookupCategory(), ilObjUser\_lookupFullname(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), array, ilDatePresentation\formatPeriod(), ilConsultationHourAppointments\getAppointmentIds(), getSeed(), IL_CAL_DATE, IL_CAL_UNIX, ilUtil\makeClickable(), ilCalendarCategories\MODE_PORTFOLIO_CONSULTATION, settings(), time, ilCalendarCategory\TYPE_BOOK, ilCalendarCategory\TYPE_CH, ilCalendarCategory\TYPE_GLOBAL, ilCalendarCategory\TYPE_OBJ, and ilCalendarCategory\TYPE_USR.

98  {
99  global $tree,$lng,$ilUser;
100 
101  self::$counter++;
102 
103  $this->tpl = new ilTemplate('tpl.appointment_panel.html', true, true, 'Services/Calendar');
104 
105  // Panel variables
106  $this->tpl->setVariable('PANEL_NUM', self::$counter);
107  $this->tpl->setVariable('PANEL_TITLE', str_replace(' ()', '', $a_app['event']->getPresentationTitle(false)));
108  if ($a_app["event"]->isMilestone()) {
109  $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_ms_details'));
110  } else {
111  $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_details'));
112  }
113  $this->tpl->setVariable('PANEL_TXT_DATE', $this->lng->txt('date'));
114 
115  if ($a_app['fullday']) {
116  $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(
117  new ilDate($a_app['dstart'], IL_CAL_UNIX),
118  new ilDate($a_app['dend'], IL_CAL_UNIX)
119  ));
120  } else {
121  $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(
122  new ilDateTime($a_app['dstart'], IL_CAL_UNIX),
123  new ilDateTime($a_app['dend'], IL_CAL_UNIX)
124  ));
125  }
126  if ($a_app['event']->getLocation()) {
127  $this->tpl->setVariable('PANEL_TXT_WHERE', $this->lng->txt('cal_where'));
128  $this->tpl->setVariable('PANEL_WHERE', ilUtil::makeClickable($a_app['event']->getLocation()), true);
129  }
130  if ($a_app['event']->getDescription()) {
131  $this->tpl->setVariable('PANEL_TXT_DESC', $this->lng->txt('description'));
132  $this->tpl->setVariable('PANEL_DESC', ilUtil::makeClickable(nl2br($a_app['event']->getDescription())));
133  }
134 
135  if ($a_app['event']->isMilestone() && $a_app['event']->getCompletion() > 0) {
136  $this->tpl->setVariable('PANEL_TXT_COMPL', $this->lng->txt('cal_task_completion'));
137  $this->tpl->setVariable('PANEL_COMPL', $a_app['event']->getCompletion() . " %");
138  }
139 
140  if ($a_app['event']->isMilestone()) {
141  // users responsible
142  $users = $a_app['event']->readResponsibleUsers();
143  $delim = "";
144  foreach ($users as $r) {
145  $value.= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
146  $delim = "<br />";
147  }
148  if (count($users) > 0) {
149  $this->tpl->setVariable('PANEL_TXT_RESP', $this->lng->txt('cal_responsible'));
150  $this->tpl->setVariable('PANEL_RESP', $value);
151  }
152  }
153 
154  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
155  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($a_app['event']->getEntryId());
156  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
157  $entry_obj_id = isset($cat_info['subitem_obj_ids'][$cat_id]) ?
158  $cat_info['subitem_obj_ids'][$cat_id] :
159  $cat_info['obj_id'];
160 
161  $this->tpl->setVariable('PANEL_TXT_CAL_TYPE', $this->lng->txt('cal_cal_type'));
162  switch ($cat_info['type']) {
164  $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_system'));
165  break;
166 
168  $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_personal'));
169  break;
170 
172  $type = ilObject::_lookupType($cat_info['obj_id']);
173  $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_' . $type));
174 
175  // Course group appointment registration
176  if ($this->settings->isCGRegistrationEnabled() and $type == 'crs' or $type == 'grp') {
177  if (!$a_app['event']->isAutoGenerated()) {
178  include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
179  $reg = new ilCalendarRegistration($a_app['event']->getEntryId());
180 
181  if ($reg->isRegistered($ilUser->getId(), new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX))) {
182  $this->tpl->setCurrentBlock('panel_cancel_book_link');
183  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
184  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
185  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']);
186  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']);
187 
188  $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_reg_unregister'));
189  $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmUnregister'));
190  $this->tpl->parseCurrentBlock();
191  } else {
192  $this->tpl->setCurrentBlock('panel_book_link');
193  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
194  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
195  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']);
196  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']);
197  $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_reg_register'));
198  $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmRegister'));
199  $this->tpl->parseCurrentBlock();
200  }
201 
202  include_once './Services/Link/classes/class.ilLink.php';
203  $registrations = array();
204  foreach ($reg->getRegisteredUsers(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX)) as $usr_data) {
205  $usr_id = $usr_data['usr_id'];
206  $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $usr_id);
207  $registrations[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($usr_id);
208  $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', '');
209  }
210  if (count($registrations)) {
211  $this->tpl->setCurrentBlock('panel_current_booking');
212  $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_reg_registered_users'));
213  $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $registrations));
214  $this->tpl->parseCurrentBlock();
215  }
216  }
217  }
218  break;
219 
221  $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_ch'));
222 
223  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
224  $entry = new ilBookingEntry($a_app['event']->getContextId());
225 
226  $is_owner = $entry->isOwner();
227  $user_entry = ($cat_info['obj_id'] == $ilUser->getId());
228 
229  if ($user_entry && !$is_owner) {
230  // find source calendar entry in owner calendar
231  include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
232  $apps = ilConsultationHourAppointments::getAppointmentIds($entry->getObjId(), $a_app['event']->getContextId(), $a_app['event']->getStart());
233  $ref_event = $apps[0];
234  } else {
235  $ref_event = $a_app['event']->getEntryId();
236  }
237 
238  $this->tpl->setCurrentBlock('panel_booking_owner');
239  $this->tpl->setVariable('PANEL_TXT_BOOKING_OWNER', $this->lng->txt('cal_ch_booking_owner'));
240  $this->tpl->setVariable('PANEL_BOOKING_OWNER', ilObjUser::_lookupFullname($entry->getObjId()));
241  $this->tpl->parseCurrentBlock();
242 
243  $this->tpl->setCurrentBlock('panel_max_booking');
244  $this->tpl->setVariable('PANEL_TXT_MAX_BOOKING', $this->lng->txt('cal_ch_num_bookings'));
245  $this->tpl->setVariable('PANEL_MAX_BOOKING', $entry->getNumberOfBookings());
246  $this->tpl->parseCurrentBlock();
247 
248  if (!$is_owner) {
249  if ($entry->hasBooked($ref_event)) {
250  if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) {
251  $this->tpl->setCurrentBlock('panel_cancel_book_link');
252  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
253  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
254  $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking'));
255  $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking'));
256  $this->tpl->parseCurrentBlock();
257  }
258  }
259  #else if(!$entry->isBookedOut($ref_event))
260  elseif ($entry->isAppointmentBookableForUser($ref_event, $GLOBALS['ilUser']->getId())) {
261  $this->tpl->setCurrentBlock('panel_book_link');
262  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
263  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
264  $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_ch_book'));
265  $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book'));
266  $this->tpl->parseCurrentBlock();
267  }
268 
269  $this->tpl->setCurrentBlock('panel_current_booking');
270  $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings'));
271  $this->tpl->setVariable('PANEL_CURRENT_BOOKING', $entry->getCurrentNumberOfBookings($ref_event));
272  $this->tpl->parseCurrentBlock();
273  } else {
274  $obj_ids = $entry->getTargetObjIds();
275  foreach ($obj_ids as $obj_id) {
276  $title = ilObject::_lookupTitle($obj_id);
277  $refs = ilObject::_getAllReferences($obj_id);
278  include_once './Services/Link/classes/class.ilLink.php';
279  $this->tpl->setCurrentBlock('panel_booking_target_row');
280  $this->tpl->setVariable('PANEL_BOOKING_TARGET_TITLE', $title);
281  $this->tpl->setVariable('PANEL_BOOKING_TARGET', ilLink::_getLink(end($refs)));
282  $this->tpl->parseCurrentBlock();
283  }
284  if ($obj_ids) {
285  $this->tpl->setCurrentBlock('panel_booking_target');
286  $this->tpl->setVariable('PANEL_TXT_BOOKING_TARGET', $this->lng->txt('cal_ch_target_object'));
287  $this->tpl->parseCurrentBlock();
288  }
289 
290  $link_users = true;
292  $link_users = false;
293  }
294 
295  include_once './Services/Link/classes/class.ilLink.php';
296  $bookings = array();
297  $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', 1);
298  foreach ($entry->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) {
299  if ($link_users) {
300  $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $user_id);
301  $bookings[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' .
302  ilObjUser::_lookupFullname($user_id) . '</a>';
303  $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', '');
304  } else {
305  $bookings[] = ilObjUser::_lookupFullname($user_id);
306  }
307  }
308  $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', '');
309  $this->tpl->setCurrentBlock('panel_current_booking');
310  $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings'));
311  $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $bookings));
312  $this->tpl->parseCurrentBlock();
313  }
314  break;
315 
317  $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_booking'));
318 
319  $this->tpl->setCurrentBlock('panel_cancel_book_link');
320  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
321  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
322  $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking'));
323  $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking'));
324  $this->tpl->parseCurrentBlock();
325  break;
326  }
327 
328  $this->tpl->setVariable('PANEL_TXT_CAL_NAME', $this->lng->txt('cal_calendar_name'));
329  $this->tpl->setVariable('PANEL_CAL_NAME', $cat_info['title']);
330 
331 
332  if ($cat_info['editable'] and !$a_app['event']->isAutoGenerated()) {
333  $this->tpl->setCurrentBlock('panel_edit_link');
334  $this->tpl->setVariable('TXT_PANEL_EDIT', $this->lng->txt('edit'));
335 
336  $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
337  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
338  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
339  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']);
340  $this->tpl->setVariable('PANEL_EDIT_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askEdit'));
341 
342  $this->tpl->setCurrentBlock('panel_delete_link');
343  $this->tpl->setVariable('TXT_PANEL_DELETE', $this->lng->txt('delete'));
344 
345  $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
346  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
347  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
348  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']);
349  $this->tpl->setVariable('PANEL_DELETE_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askdelete'));
350  $this->tpl->parseCurrentBlock();
351  }
352  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
353  if ($cat_info['type'] == ilCalendarCategory::TYPE_OBJ) {
354  $refs = ilObject::_getAllReferences($entry_obj_id);
355  $type = ilObject::_lookupType($entry_obj_id);
356  $title = ilObject::_lookupTitle($entry_obj_id) ?
357  ilObject::_lookupTitle($entry_obj_id) :
358  $lng->txt('obj_' . $type);
359 
360  include_once('./Services/Link/classes/class.ilLink.php');
361  $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($entry_obj_id));
362  $parent = $tree->getParentId(current($refs));
363  $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($parent));
364  $this->tpl->setVariable('PANEL_TXT_LINK', $this->lng->txt('ext_link'));
365  $this->tpl->setVariable('PANEL_LINK_HREF', $href);
366  $this->tpl->setVariable('PANEL_LINK_NAME', $title);
367  $this->tpl->setVariable('PANEL_PARENT', $parent_title);
368  }
369 
370  return $this->tpl->get();
371  }
static _lookupCategory($a_cal_id)
Lookup category id.
$type
static _lookupFullname($a_user_id)
Lookup Full Name.
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static getAppointmentIds($a_user_id, $a_context_id=null, $a_start=null, $a_type=null, $a_check_owner=true)
Get all appointment ids.
Booking definition.
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
static _getAllReferences($a_id)
get all reference ids of object
$counter
$r
Definition: example_031.php:79
Class for single dates.
static _lookupObjId($a_id)
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
$ilUser
Definition: imgupload.php:18
static _getInstance($a_usr_id=0)
get singleton instance
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
$users
Definition: authpage.php:44
const IL_CAL_DATE
settings()
Definition: settings.php:2
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ getSeed()

ilCalendarAppointmentPanelGUI::getSeed ( )

Get seed date.

Definition at line 84 of file class.ilCalendarAppointmentPanelGUI.php.

References $seed.

Referenced by getHTML().

+ Here is the caller graph for this function:

Field Documentation

◆ $counter

ilCalendarAppointmentPanelGUI::$counter = 0
staticprotected

Definition at line 38 of file class.ilCalendarAppointmentPanelGUI.php.

◆ $ctrl

ilCalendarAppointmentPanelGUI::$ctrl = null
protected

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

◆ $instance

ilCalendarAppointmentPanelGUI::$instance = null
staticprotected

Definition at line 39 of file class.ilCalendarAppointmentPanelGUI.php.

◆ $lng

ilCalendarAppointmentPanelGUI::$lng = null
protected

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

Referenced by __construct(), and getHTML().

◆ $seed

ilCalendarAppointmentPanelGUI::$seed = null
protected

Definition at line 36 of file class.ilCalendarAppointmentPanelGUI.php.

Referenced by __construct(), and getSeed().

◆ $settings

ilCalendarAppointmentPanelGUI::$settings = null
protected

Definition at line 41 of file class.ilCalendarAppointmentPanelGUI.php.

◆ $tpl

ilCalendarAppointmentPanelGUI::$tpl = null
protected

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


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