public function isValidEvent(ilCalendarEntry $a_event)
 {
     global $ilUser;
     $booking = new ilBookingEntry($a_event->getContextId());
     // portfolio embedded: filter by consultation hour groups?
     if (!is_array($this->group_ids) || in_array($booking->getBookingGroup(), $this->group_ids)) {
         // do not filter against course/group in portfolio
         if ($this->cats->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
             $booking->setTargetObjIds(null);
         }
         if (($this->user_id == $ilUser->getId() || !$booking->isBookedOut($a_event->getEntryId(), true)) && $booking->isTargetObjectVisible($this->cats->getTargetRefId())) {
             return true;
         }
     }
     return false;
 }
 public function delete()
 {
     global $ilDB;
     $query = 'DELETE FROM cal_ch_group ' . 'WHERE grp_id = ' . $ilDB->quote($this->getGroupId(), 'integer');
     $ilDB->manipulate($query);
     include_once './Services/Booking/classes/class.ilBookingEntry.php';
     ilBookingEntry::resetGroup($this->getGroupId());
 }
 /**
  * Cancel a booking
  * @param type $a_usr_id
  * @param type $a_app_id
  * @return bool
  */
 public static function cancelBooking($a_usr_id, $a_app_id, $a_send_notification = true)
 {
     // Delete personal copy of appointment
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     $app = new ilCalendarEntry($a_app_id);
     include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
     $user_apps = ilConsultationHourAppointments::getAppointmentIds($a_usr_id, $app->getContextId(), $app->getStart(), ilCalendarCategory::TYPE_CH, false);
     foreach ($user_apps as $uapp_id) {
         $uapp = new ilCalendarEntry($uapp_id);
         $uapp->delete();
         include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         ilCalendarCategoryAssignments::_deleteByAppointmentId($uapp_id);
         break;
     }
     // Delete booking entries
     // Send notification
     $booking = new ilBookingEntry($app->getContextId());
     if ($a_send_notification) {
         $booking->cancelBooking($a_app_id, $a_usr_id);
     } else {
         $booking->deleteBooking($a_app_id, $a_usr_id);
     }
     return true;
 }
 /**
  * Parse data
  * @return
  *
  * @global ilRbacReview $rbacreview
  */
 public function parse()
 {
     global $rbacreview;
     $this->determineOffsetAndOrder();
     include_once './Services/User/classes/class.ilUserQuery.php';
     $additional_fields = $this->getSelectedColumns();
     unset($additional_fields["firstname"]);
     unset($additional_fields["lastname"]);
     unset($additional_fields["last_login"]);
     unset($additional_fields["access_until"]);
     unset($additional_fields['consultation_hour']);
     unset($additional_fields['prtf']);
     $udf_ids = $usr_data_fields = $odf_ids = array();
     foreach ($additional_fields as $field) {
         if (substr($field, 0, 3) == 'udf') {
             $udf_ids[] = substr($field, 4);
             continue;
         }
         if (substr($field, 0, 3) == 'odf') {
             $odf_ids[] = substr($field, 4);
             continue;
         }
         $usr_data_fields[] = $field;
     }
     $usr_data = ilUserQuery::getUserListData($this->getOrderField(), $this->getOrderDirection(), $this->getOffset(), $this->getLimit(), '', '', null, false, false, 0, $this->getRoleId(), null, $usr_data_fields, $part);
     foreach ((array) $usr_data['set'] as $user) {
         $usr_ids[] = $user['usr_id'];
     }
     // merge course data
     $course_user_data = $this->getParentObject()->readMemberData($usr_ids, $this->type == 'admin', $this->getSelectedColumns());
     $a_user_data = array();
     foreach ((array) $usr_data['set'] as $ud) {
         $a_user_data[$ud['usr_id']] = array_merge($ud, $course_user_data[$ud['usr_id']]);
         if ($this->show_lp_status_sync) {
             // #9912 / #13208
             $passed_info = "";
             if ($a_user_data[$ud['usr_id']]["passed_info"]) {
                 $pinfo = $a_user_data[$ud['usr_id']]["passed_info"];
                 if ($pinfo["user_id"]) {
                     if ($pinfo["user_id"] < 0) {
                         $passed_info = $this->lng->txt("crs_passed_status_system");
                     } else {
                         if ($pinfo["user_id"] > 0) {
                             $name = ilObjUser::_lookupName($pinfo["user_id"]);
                             $passed_info = $this->lng->txt("crs_passed_status_manual_by") . ": " . $name["login"];
                         }
                     }
                 }
                 if ($pinfo["timestamp"]) {
                     $passed_info .= "<br />" . ilDatePresentation::formatDate($pinfo["timestamp"]);
                 }
             }
             $a_user_data[$ud['usr_id']]["passed_info"] = $passed_info;
         }
     }
     // Custom user data fields
     if ($udf_ids) {
         include_once './Services/User/classes/class.ilUserDefinedData.php';
         $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
         foreach ($data as $usr_id => $fields) {
             if (!$this->checkAcceptance($usr_id)) {
                 continue;
             }
             foreach ($fields as $field_id => $value) {
                 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
             }
         }
     }
     // Object specific user data fields
     if ($odf_ids) {
         include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
         $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId());
         foreach ($data as $usr_id => $fields) {
             // #7264: as we get data for all course members filter against user data
             if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) {
                 continue;
             }
             foreach ($fields as $field_id => $value) {
                 $a_user_data[$usr_id]['odf_' . $field_id] = $value;
             }
         }
         // add last edit date
         include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
         foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getParentObject()->object->getId()) as $usr_id => $edit_info) {
             if (!isset($a_user_data[$usr_id])) {
                 continue;
             }
             include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
             if ($usr_id == $edit_info['update_user']) {
                 $a_user_data[$usr_id]['odf_last_update'] = '';
                 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self');
                 if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getParentObject()->object->getType())) {
                     $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX);
                     $a_user_data[$usr_id]['odf_info_txt'] .= ', ' . ilDatePresentation::formatDate($edit_info['editing_time']);
                 }
             } else {
                 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user'];
                 $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX);
                 $name = ilObjUser::_lookupName($edit_info['update_user']);
                 $a_user_data[$usr_id]['odf_info_txt'] = $name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']);
             }
         }
     }
     foreach ($usr_data['set'] as $user) {
         // Check acceptance
         if (!$this->checkAcceptance($user['usr_id'])) {
             continue;
         }
         // DONE: accepted
         foreach ($usr_data_fields as $field) {
             $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
         }
     }
     // consultation hours
     if ($this->isColumnSelected('consultation_hour')) {
         include_once './Services/Booking/classes/class.ilBookingEntry.php';
         foreach (ilBookingEntry::lookupManagedBookingsForObject($this->getParentObject()->object->getId(), $GLOBALS['ilUser']->getId()) as $buser => $booking) {
             if (isset($a_user_data[$buser])) {
                 $a_user_data[$buser]['consultation_hour'] = $booking[0]['dt'];
                 $a_user_data[$buser]['consultation_hour_end'] = $booking[0]['dtend'];
                 $a_user_data[$buser]['consultation_hours'] = $booking;
             }
         }
     }
     $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
     return $this->setData($a_user_data);
 }
 /**
  * Cancel consultation appointment or ressource booking, was confirmed
  * This will delete the calendar entry
  */
 public function cancelConfirmed()
 {
     global $ilUser;
     $entry = (int) $_POST['app_id'];
     $user = (int) $_GET['bkid'];
     include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
     $entry = new ilCalendarEntry($entry);
     $category = $this->calendarEntryToCategory($entry);
     if ($category->getType() == ilCalendarCategory::TYPE_CH) {
         // find cloned calendar entry in user calendar
         include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
         $GLOBALS['ilLog']->dump($entry->getStart());
         $apps = ilConsultationHourAppointments::getAppointmentIds($ilUser->getId(), $entry->getContextId(), $entry->getStart(), ilCalendarCategory::TYPE_CH, false);
         $GLOBALS['ilLog']->dump($apps);
         // Fix for wrong, old entries
         foreach ((array) $apps as $own_app) {
             $ref_entry = new ilCalendarEntry($own_app);
             $ref_entry->delete();
         }
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         $booking = new ilBookingEntry($entry->getContextId());
         $booking->cancelBooking($entry->getEntryId());
         // do NOT delete original entry
     } else {
         if ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
             include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
             $booking = new ilBookingReservation($entry->getContextId());
             $booking->setStatus(ilBookingReservation::STATUS_CANCELLED);
             $booking->update();
             $entry->delete();
         }
     }
     ilUtil::sendSuccess($this->lng->txt('cal_cancel_booking_confirmed'), true);
     $this->ctrl->returnToParent($this);
 }
 /**
  * Show list of export files
  *
  * @access public
  * 
  */
 public function show($a_deliver_file = false)
 {
     $this->showFileList();
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.member_export.html', 'Modules/Course');
     $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this));
     $this->tpl->setVariable('TXT_EXPORT_SETTINGS', $this->lng->txt('ps_export_settings'));
     $this->tpl->setVariable('TXT_USER_SELECTION', $this->lng->txt('ps_user_selection'));
     $this->tpl->setVariable('TXT_EXPORT_ADMIN', $this->lng->txt('ps_export_admin'));
     $this->tpl->setVariable('TXT_EXPORT_MEMBER', $this->lng->txt('ps_export_member'));
     $this->tpl->setVariable('TXT_EXPORT_WAIT', $this->lng->txt('ps_export_wait'));
     $this->tpl->setVariable('TXT_EXPORT_SUB', $this->lng->txt('ps_export_sub'));
     // Check user selection
     $this->exportSettings = new ilUserFormSettings('memexp');
     $this->tpl->setVariable('CHECK_EXPORT_ADMIN', ilUtil::formCheckbox($this->exportSettings->enabled('admin'), 'export_members[admin]', 1));
     if ($this->type == 'crs') {
         $this->tpl->setVariable('CHECK_EXPORT_TUTOR', ilUtil::formCheckbox($this->exportSettings->enabled('tutor'), 'export_members[tutor]', 1));
         $this->tpl->setVariable('TXT_EXPORT_TUTOR', $this->lng->txt('ps_export_tutor'));
     }
     $this->tpl->setVariable('CHECK_EXPORT_MEMBER', ilUtil::formCheckbox($this->exportSettings->enabled('member'), 'export_members[member]', 1));
     $this->tpl->setVariable('CHECK_EXPORT_SUB', ilUtil::formCheckbox($this->exportSettings->enabled('subscribers'), 'export_members[subscribers]', 1));
     $this->tpl->setVariable('CHECK_EXPORT_WAIT', ilUtil::formCheckbox($this->exportSettings->enabled('waiting_list'), 'export_members[waiting_list]', 1));
     $this->tpl->setVariable('TXT_EXPORT', $this->lng->txt('ps_perform_export'));
     $this->tpl->setVariable('TXT_EXPORT_EXCEL', $this->lng->txt('ps_export_excel'));
     // User Data
     $this->tpl->setVariable('TXT_USER_DATA_SELECTION', $this->lng->txt('ps_export_data'));
     $this->tpl->setVariable('TXT_EXPORT_USER_DATA_HEADER', $this->lng->txt('ps_export_user_data'));
     include_once './Services/Booking/classes/class.ilBookingEntry.php';
     if (ilBookingEntry::hasObjectBookingEntries($this->obj_id, $GLOBALS['ilUser']->getId())) {
         $this->tpl->setCurrentBlock('consultation');
         $this->lng->loadLanguageModule('dateplaner');
         $this->tpl->setVariable('TXT_CH', $this->lng->txt('cal_ch_field_ch'));
         $this->tpl->setVariable('TXT_EXPORT_CH', $this->lng->txt('cal_ch_export_apps'));
         $this->tpl->setVariable('CHECK_EXPORT_CH', ilUtil::formCheckbox($this->exportSettings->enabled('consultation_hour'), 'export_members[consultation_hour]', 1));
         $this->tpl->parseCurrentBlock();
     }
     $fields = $this->fields_info->getFieldsInfo();
     foreach ($fields as $field => $exportable) {
         if (!$exportable) {
             continue;
         }
         $this->tpl->setCurrentBlock('user_data_row');
         $this->tpl->setVariable('CHECK_EXPORT_USER_DATA', ilUtil::formCheckbox($this->exportSettings->enabled($field), 'export_members[' . $field . ']', 1));
         $this->tpl->setVariable('TXT_EXPORT_USER_DATA', $this->lng->txt($field));
         $this->tpl->parseCurrentBlock();
     }
     $udf = ilUserDefinedFields::_getInstance();
     foreach ($exp = $udf->getExportableFields($this->obj_id) as $field_id => $udf_data) {
         $this->tpl->setCurrentBlock('user_data_row');
         $this->tpl->setVariable('CHECK_EXPORT_USER_DATA', ilUtil::formCheckbox($this->exportSettings->enabled('udf_' . $field_id), 'export_members[udf_' . $field_id . ']', 1));
         $this->tpl->setVariable('TXT_EXPORT_USER_DATA', $udf_data['field_name']);
         $this->tpl->parseCurrentBlock();
     }
     $cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id);
     foreach ($cdf_fields as $field_obj) {
         $this->tpl->setCurrentBlock('cdf_row');
         $this->tpl->setVariable('CHECK_CDF_DATA', ilUtil::formCheckbox($this->exportSettings->enabled('cdf_' . $field_obj->getId()), 'export_members[cdf_' . $field_obj->getId() . ']', 1));
         $this->tpl->setVariable('TXT_CDF_NAME', $field_obj->getName());
         $this->tpl->parseCurrentBlock();
     }
     if (count($cdf_fields)) {
         $this->tpl->setCurrentBlock('cdf_fields');
         $this->tpl->setVariable('TXT_CDF_SELECTION', $this->lng->txt('ps_' . $this->type . '_user_fields'));
         $this->tpl->parseCurrentBlock();
     }
     if ($a_deliver_file and 0) {
         $this->tpl->setCurrentBlock('iframe');
         $this->tpl->setVariable('SOURCE', $this->ctrl->getLinkTarget($this, 'deliverData'));
     }
 }
 /**
  * 
  * @return 
  */
 public function send()
 {
     global $rbacreview, $lng;
     switch ($this->getType()) {
         case self::TYPE_USER:
             $rcp = array_pop($this->getRecipients());
             $this->initLanguage($rcp);
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_mail_notification_subject'), $this->getAppointment()->getTitle()));
             $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_mail_notification_body'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail($this->getRecipients(), array('system'), true);
             break;
         case self::TYPE_USER_ANONYMOUS:
             $rcp = array_pop($this->getRecipients());
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->getLanguage()->loadLanguageModule('mail');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_mail_notification_subject'), $this->getAppointment()->getTitle()));
             $this->setBody(ilMail::getSalutation(0, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_mail_notification_body'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail($this->getRecipients(), array('email'), false);
             break;
         case self::TYPE_GRP_NEW_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('grp');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_grp_new_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('grp_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_grp_new_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_grp_admin_' . $this->getRefId(), '#il_grp_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_GRP_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('grp');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_grp_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('grp_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_grp_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('grp_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_grp_admin_' . $this->getRefId(), '#il_grp_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_CRS_NEW_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('crs');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_crs_new_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('crs_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_crs_new_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_crs_admin_' . $this->getRefId(), '#il_crs_tutor_' . $this->getRefId(), '#il_crs_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_CRS_NOTIFICATION:
             $this->setLanguage(ilLanguageFactory::_getLanguage($lng->getDefaultLanguage()));
             $this->getLanguage()->loadLanguageModule('crs');
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_crs_notification_sub'), $this->getObjectTitle(true)));
             $this->setBody($this->getLanguageText('crs_notification_salutation'));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_crs_notification_body'), $this->getObjectTitle(true)));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails();
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('crs_mail_permanent_link'));
             $this->appendBody("\n\n");
             $this->appendBody($this->createPermanentLink());
             $this->getMail()->appendInstallationSignature(true);
             $this->addAttachment();
             $this->sendMail(array('#il_crs_admin_' . $this->getRefId(), '#il_crs_tutor_' . $this->getRefId(), '#il_crs_member_' . $this->getRefId()), array('system'), false);
             break;
         case self::TYPE_BOOKING_CONFIRMATION:
             $user_id = array_pop($this->getRecipients());
             include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $entry = new ilCalendarEntry($this->getAppointmentId());
             $booking = new ilBookingEntry($entry->getContextId());
             $this->initLanguage($user_id);
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_booking_confirmation_subject'), $entry->getTitle()));
             $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_booking_confirmation_body'), ilObjUser::_lookupFullname($booking->getObjId())));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails($booking);
             /*
             				$this->appendBody("\n\n");
             				$this->appendBody($this->getLanguageText('cal_booking_confirmation_link'));
             				$this->appendBody("\n\n");
             				$this->appendBody($this->createPermanentLink());
             */
             $this->getMail()->appendInstallationSignature(true);
             $this->sendMail(array($user_id), array('system'), true);
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_booking_confirmation_user') . "\n");
             $this->appendBody(ilObjUser::_lookupFullname($user_id));
             $this->sendMail(array($booking->getObjId()), array('system'), true);
             break;
         case self::TYPE_BOOKING_CANCELLATION:
             $user_id = array_pop($this->getRecipients());
             include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $entry = new ilCalendarEntry($this->getAppointmentId());
             $booking = new ilBookingEntry($entry->getContextId());
             $user_id = array_pop($this->getRecipients());
             $this->initLanguage($user_id);
             $this->getLanguage()->loadLanguageModule('dateplaner');
             $this->initMail();
             $this->setSubject(sprintf($this->getLanguageText('cal_booking_cancellation_subject'), $entry->getTitle()));
             $this->setBody(ilMail::getSalutation($user_id, $this->getLanguage()));
             $this->appendBody("\n\n");
             $this->appendBody(sprintf($this->getLanguageText('cal_booking_cancellation_body'), ilObjUser::_lookupFullname($booking->getObjId())));
             $this->appendBody("\n\n");
             $this->appendAppointmentDetails($booking);
             $this->getMail()->appendInstallationSignature(true);
             $this->sendMail(array($user_id), array('system'), true);
             $this->appendBody("\n\n");
             $this->appendBody($this->getLanguageText('cal_booking_cancellation_user') . "\n");
             $this->appendBody(ilObjUser::_lookupFullname($user_id));
             $this->sendMail(array($booking->getObjId()), array('system'), true);
             break;
     }
     $this->deleteAttachments();
 }
 /**
  * get HTML
  *
  * @access public
  * @param 
  * @return
  */
 public function getHTML($a_app)
 {
     global $tree, $lng, $ilUser;
     self::$counter++;
     $this->tpl = new ilTemplate('tpl.appointment_panel.html', true, true, 'Services/Calendar');
     // Panel variables
     $this->tpl->setVariable('PANEL_NUM', self::$counter);
     $this->tpl->setVariable('PANEL_TITLE', str_replace(' ()', '', $a_app['event']->getPresentationTitle(false)));
     if ($a_app["event"]->isMilestone()) {
         $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_ms_details'));
     } else {
         $this->tpl->setVariable('PANEL_DETAILS', $this->lng->txt('cal_details'));
     }
     $this->tpl->setVariable('PANEL_TXT_DATE', $this->lng->txt('date'));
     if ($a_app['fullday']) {
         $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(new ilDate($a_app['dstart'], IL_CAL_UNIX), new ilDate($a_app['dend'], IL_CAL_UNIX)));
     } else {
         $this->tpl->setVariable('PANEL_DATE', ilDatePresentation::formatPeriod(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX)));
     }
     if ($a_app['event']->getLocation()) {
         $this->tpl->setVariable('PANEL_TXT_WHERE', $this->lng->txt('cal_where'));
         $this->tpl->setVariable('PANEL_WHERE', ilUtil::makeClickable($a_app['event']->getLocation()), true);
     }
     if ($a_app['event']->getDescription()) {
         $this->tpl->setVariable('PANEL_TXT_DESC', $this->lng->txt('description'));
         $this->tpl->setVariable('PANEL_DESC', ilUtil::makeClickable(nl2br($a_app['event']->getDescription())));
     }
     if ($a_app['event']->isMilestone() && $a_app['event']->getCompletion() > 0) {
         $this->tpl->setVariable('PANEL_TXT_COMPL', $this->lng->txt('cal_task_completion'));
         $this->tpl->setVariable('PANEL_COMPL', $a_app['event']->getCompletion() . " %");
     }
     if ($a_app['event']->isMilestone()) {
         // users responsible
         $users = $a_app['event']->readResponsibleUsers();
         $delim = "";
         foreach ($users as $r) {
             $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
             $delim = "<br />";
         }
         if (count($users) > 0) {
             $this->tpl->setVariable('PANEL_TXT_RESP', $this->lng->txt('cal_responsible'));
             $this->tpl->setVariable('PANEL_RESP', $value);
         }
     }
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     $cat_id = ilCalendarCategoryAssignments::_lookupCategory($a_app['event']->getEntryId());
     $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
     $entry_obj_id = isset($cat_info['subitem_obj_ids'][$cat_id]) ? $cat_info['subitem_obj_ids'][$cat_id] : $cat_info['obj_id'];
     $this->tpl->setVariable('PANEL_TXT_CAL_TYPE', $this->lng->txt('cal_cal_type'));
     switch ($cat_info['type']) {
         case ilCalendarCategory::TYPE_GLOBAL:
             $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_system'));
             break;
         case ilCalendarCategory::TYPE_USR:
             $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_personal'));
             break;
         case ilCalendarCategory::TYPE_OBJ:
             $type = ilObject::_lookupType($cat_info['obj_id']);
             $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_type_' . $type));
             // Course group appointment registration
             if ($this->settings->isCGRegistrationEnabled() and $type == 'crs' or type == 'grp') {
                 if (!$a_app['event']->isAutoGenerated()) {
                     include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
                     $reg = new ilCalendarRegistration($a_app['event']->getEntryId());
                     if ($reg->isRegistered($ilUser->getId(), new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX))) {
                         $this->tpl->setCurrentBlock('panel_cancel_book_link');
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']);
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']);
                         $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_reg_unregister'));
                         $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmUnregister'));
                         $this->tpl->parseCurrentBlock();
                     } else {
                         $this->tpl->setCurrentBlock('panel_book_link');
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dstart', $a_app['dstart']);
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dend', $a_app['dend']);
                         $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_reg_register'));
                         $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'confirmRegister'));
                         $this->tpl->parseCurrentBlock();
                     }
                     include_once './Services/Link/classes/class.ilLink.php';
                     $registrations = array();
                     foreach ($reg->getRegisteredUsers(new ilDateTime($a_app['dstart'], IL_CAL_UNIX), new ilDateTime($a_app['dend'], IL_CAL_UNIX)) as $usr_data) {
                         $usr_id = $usr_data['usr_id'];
                         $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $usr_id);
                         $registrations[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($usr_id);
                         $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', '');
                     }
                     if (count($registrations)) {
                         $this->tpl->setCurrentBlock('panel_current_booking');
                         $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_reg_registered_users'));
                         $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $registrations));
                         $this->tpl->parseCurrentBlock();
                     }
                 }
             }
             break;
         case ilCalendarCategory::TYPE_CH:
             $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_ch'));
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $entry = new ilBookingEntry($a_app['event']->getContextId());
             $is_owner = $entry->isOwner();
             $user_entry = $cat_info['obj_id'] == $ilUser->getId();
             if ($user_entry && !$is_owner) {
                 // find source calendar entry in owner calendar
                 include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
                 $apps = ilConsultationHourAppointments::getAppointmentIds($entry->getObjId(), $a_app['event']->getContextId(), $a_app['event']->getStart());
                 $ref_event = $apps[0];
             } else {
                 $ref_event = $a_app['event']->getEntryId();
             }
             $this->tpl->setCurrentBlock('panel_booking_owner');
             $this->tpl->setVariable('PANEL_TXT_BOOKING_OWNER', $this->lng->txt('cal_ch_booking_owner'));
             $this->tpl->setVariable('PANEL_BOOKING_OWNER', ilObjUser::_lookupFullname($entry->getObjId()));
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock('panel_max_booking');
             $this->tpl->setVariable('PANEL_TXT_MAX_BOOKING', $this->lng->txt('cal_ch_num_bookings'));
             $this->tpl->setVariable('PANEL_MAX_BOOKING', $entry->getNumberOfBookings());
             $this->tpl->parseCurrentBlock();
             if (!$is_owner) {
                 if ($entry->hasBooked($ref_event)) {
                     if (ilDateTime::_after($a_app['event']->getStart(), new ilDateTime(time(), IL_CAL_UNIX))) {
                         $this->tpl->setCurrentBlock('panel_cancel_book_link');
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
                         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
                         $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking'));
                         $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking'));
                         $this->tpl->parseCurrentBlock();
                     }
                 } elseif ($entry->isAppointmentBookableForUser($ref_event, $GLOBALS['ilUser']->getId())) {
                     $this->tpl->setCurrentBlock('panel_book_link');
                     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $ref_event);
                     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
                     $this->tpl->setVariable('TXT_PANEL_BOOK', $this->lng->txt('cal_ch_book'));
                     $this->tpl->setVariable('PANEL_BOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'book'));
                     $this->tpl->parseCurrentBlock();
                 }
                 $this->tpl->setCurrentBlock('panel_current_booking');
                 $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings'));
                 $this->tpl->setVariable('PANEL_CURRENT_BOOKING', $entry->getCurrentNumberOfBookings($ref_event));
                 $this->tpl->parseCurrentBlock();
             } else {
                 $obj_ids = $entry->getTargetObjIds();
                 foreach ($obj_ids as $obj_id) {
                     $title = ilObject::_lookupTitle($obj_id);
                     $refs = ilObject::_getAllReferences($obj_id);
                     include_once './Services/Link/classes/class.ilLink.php';
                     $this->tpl->setCurrentBlock('panel_booking_target_row');
                     $this->tpl->setVariable('PANEL_BOOKING_TARGET_TITLE', $title);
                     $this->tpl->setVariable('PANEL_BOOKING_TARGET', ilLink::_getLink(end($refs)));
                     $this->tpl->parseCurrentBlock();
                 }
                 if ($obj_ids) {
                     $this->tpl->setCurrentBlock('panel_booking_target');
                     $this->tpl->setVariable('PANEL_TXT_BOOKING_TARGET', $this->lng->txt('cal_ch_target_object'));
                     $this->tpl->parseCurrentBlock();
                 }
                 $link_users = true;
                 if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
                     $link_users = false;
                 }
                 include_once './Services/Link/classes/class.ilLink.php';
                 $bookings = array();
                 $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', 1);
                 foreach ($entry->getCurrentBookings($a_app['event']->getEntryId()) as $user_id) {
                     if ($link_users) {
                         $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', $user_id);
                         $bookings[] = '<a href="' . $this->ctrl->getLinkTargetByClass('ilconsultationhoursgui', 'showprofile') . '">' . ilObjUser::_lookupFullname($user_id) . '</a>';
                         $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'user', '');
                     } else {
                         $bookings[] = ilObjUser::_lookupFullname($user_id);
                     }
                 }
                 $this->ctrl->setParameterByClass('ilconsultationhoursgui', 'panel', '');
                 $this->tpl->setCurrentBlock('panel_current_booking');
                 $this->tpl->setVariable('PANEL_TXT_CURRENT_BOOKING', $this->lng->txt('cal_ch_current_bookings'));
                 $this->tpl->setVariable('PANEL_CURRENT_BOOKING', implode('<br />', $bookings));
                 $this->tpl->parseCurrentBlock();
             }
             break;
         case ilCalendarCategory::TYPE_BOOK:
             $this->tpl->setVariable('PANEL_CAL_TYPE', $this->lng->txt('cal_ch_booking'));
             $this->tpl->setCurrentBlock('panel_cancel_book_link');
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
             $this->tpl->setVariable('TXT_PANEL_CANCELBOOK', $this->lng->txt('cal_ch_cancel_booking'));
             $this->tpl->setVariable('PANEL_CANCELBOOK_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'cancelBooking'));
             $this->tpl->parseCurrentBlock();
             break;
     }
     $this->tpl->setVariable('PANEL_TXT_CAL_NAME', $this->lng->txt('cal_calendar_name'));
     $this->tpl->setVariable('PANEL_CAL_NAME', $cat_info['title']);
     if ($cat_info['editable'] and !$a_app['event']->isAutoGenerated()) {
         $this->tpl->setCurrentBlock('panel_edit_link');
         $this->tpl->setVariable('TXT_PANEL_EDIT', $this->lng->txt('edit'));
         $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']);
         $this->tpl->setVariable('PANEL_EDIT_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askEdit'));
         $this->tpl->setCurrentBlock('panel_delete_link');
         $this->tpl->setVariable('TXT_PANEL_DELETE', $this->lng->txt('delete'));
         $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->getSeed()->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'dt', $a_app['dstart']);
         $this->tpl->setVariable('PANEL_DELETE_HREF', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'askdelete'));
         $this->tpl->parseCurrentBlock();
     }
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     if ($cat_info['type'] == ilCalendarCategory::TYPE_OBJ) {
         $refs = ilObject::_getAllReferences($entry_obj_id);
         $type = ilObject::_lookupType($entry_obj_id);
         $title = ilObject::_lookupTitle($entry_obj_id) ? ilObject::_lookupTitle($entry_obj_id) : $lng->txt('obj_' . $type);
         include_once './Services/Link/classes/class.ilLink.php';
         $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($entry_obj_id));
         $parent = $tree->getParentId(current($refs));
         $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($parent));
         $this->tpl->setVariable('PANEL_TXT_LINK', $this->lng->txt('ext_link'));
         $this->tpl->setVariable('PANEL_LINK_HREF', $href);
         $this->tpl->setVariable('PANEL_LINK_NAME', $title);
         $this->tpl->setVariable('PANEL_PARENT', $parent_title);
     }
     return $this->tpl->get();
 }
 /**
  * Get bloch HTML code.
  */
 function getHTML()
 {
     global $ilCtrl, $lng, $ilUser, $ilAccess;
     if ($this->getCurrentDetailLevel() == 0) {
         return "";
     }
     // add edit commands
     #if ($this->getEnableEdit())
     if ($this->mode == ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS or $this->mode == ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP) {
         include_once "./Services/News/classes/class.ilRSSButtonGUI.php";
         $this->addBlockCommand($this->ctrl->getLinkTarget($this, 'showCalendarSubscription'), $lng->txt('ical_export'), "", "", true, false, ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_ICAL));
     }
     if ($this->mode == ilCalendarCategories::MODE_REPOSITORY) {
         if (!isset($_GET["bkid"])) {
             if ($ilAccess->checkAccess('edit_event', '', (int) $_GET['ref_id'])) {
                 $ilCtrl->setParameter($this, "add_mode", "block");
                 $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI", "add"), $lng->txt("add_appointment"));
                 $ilCtrl->setParameter($this, "add_mode", "");
             }
             global $ilObjDataCache;
             include_once "Modules/Course/classes/class.ilCourseParticipants.php";
             $obj_id = $ilObjDataCache->lookupObjId((int) $_GET['ref_id']);
             $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
             $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
             //$users = $participants->getParticipants();
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             //$users = ilBookingEntry::isBookable($users, $obj_id);
             $users = ilBookingEntry::lookupBookableUsersForObject($obj_id, $users);
             if ($users) {
                 foreach ($users as $user_id) {
                     if (!isset($_GET["bkid"])) {
                         $ilCtrl->setParameter($this, "bkid", $user_id);
                         $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilCalendarMonthGUI", ""), $lng->txt("cal_consultation_hours_for") . ' ' . ilObjUser::_lookupFullname($user_id));
                         $this->cal_footer[] = array('link' => $ilCtrl->getLinkTargetByClass('ilCalendarMonthGUI', ''), 'txt' => $lng->txt("cal_consultation_hours_for") . ' ' . ilObjUser::_lookupFullname($user_id));
                     }
                 }
                 $ilCtrl->setParameter($this, "bkid", "");
             }
         } else {
             $ilCtrl->setParameter($this, "bkid", "");
             $this->addBlockCommand($ilCtrl->getLinkTarget($this), $lng->txt("back"));
             $ilCtrl->setParameter($this, "bkid", (int) $_GET["bkid"]);
         }
     }
     if ($this->getProperty("settings") == true) {
         $this->addBlockCommand($ilCtrl->getLinkTarget($this, "editSettings"), $lng->txt("settings"));
     }
     $ilCtrl->setParameterByClass("ilcolumngui", "seed", isset($_GET["seed"]) ? $_GET["seed"] : "");
     $ret = parent::getHTML();
     $ilCtrl->setParameterByClass("ilcolumngui", "seed", "");
     return $ret;
 }
 /**
  * Parse user data
  * @param array $a_user_data
  * @return 
  */
 public function parse($a_user_data)
 {
     include_once './Services/User/classes/class.ilUserQuery.php';
     $additional_fields = $this->getSelectedColumns();
     unset($additional_fields["firstname"]);
     unset($additional_fields["lastname"]);
     unset($additional_fields["last_login"]);
     unset($additional_fields["access_until"]);
     unset($additional_fields['consultation_hour']);
     unset($additional_fields['prtf']);
     switch ($this->type) {
         case 'admin':
             $part = ilGroupParticipants::_getInstanceByObjId($this->getParentObject()->object->getId())->getAdmins();
             break;
         case 'member':
             $part = $GLOBALS['rbacreview']->assignedUsers($this->getRole());
             break;
         case 'role':
             $part = $GLOBALS['rbacreview']->assignedUsers($this->getRole());
             break;
     }
     $udf_ids = $usr_data_fields = $odf_ids = array();
     foreach ($additional_fields as $field) {
         if (substr($field, 0, 3) == 'udf') {
             $udf_ids[] = substr($field, 4);
             continue;
         }
         if (substr($field, 0, 3) == 'odf') {
             $odf_ids[] = substr($field, 4);
             continue;
         }
         $usr_data_fields[] = $field;
     }
     $usr_data = ilUserQuery::getUserListData('login', 'ASC', 0, 9999, '', '', null, false, false, 0, 0, null, $usr_data_fields, $part);
     // Custom user data fields
     if ($udf_ids) {
         include_once './Services/User/classes/class.ilUserDefinedData.php';
         $data = ilUserDefinedData::lookupData($part, $udf_ids);
         foreach ($data as $usr_id => $fields) {
             if (!$this->checkAcceptance($usr_id)) {
                 continue;
             }
             foreach ($fields as $field_id => $value) {
                 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
             }
         }
     }
     // Object specific user data fields
     if ($odf_ids) {
         include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
         $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId());
         foreach ($data as $usr_id => $fields) {
             if (!$this->checkAcceptance($usr_id)) {
                 continue;
             }
             foreach ($fields as $field_id => $value) {
                 if ($a_user_data[$usr_id]) {
                     $a_user_data[$usr_id]['odf_' . $field_id] = $value;
                 }
             }
         }
     }
     foreach ($usr_data['set'] as $user) {
         // Check acceptance
         if (!$this->checkAcceptance($user['usr_id'])) {
             continue;
         }
         // DONE: accepted
         foreach ($usr_data_fields as $field) {
             $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
         }
     }
     // consultation hours
     if ($this->isColumnSelected('consultation_hour')) {
         include_once './Services/Booking/classes/class.ilBookingEntry.php';
         foreach (ilBookingEntry::lookupManagedBookingsForObject($this->getParentObject()->object->getId(), $GLOBALS['ilUser']->getId()) as $buser => $booking) {
             if (isset($a_user_data[$buser])) {
                 $a_user_data[$buser]['consultation_hour'] = $booking[0]['dt'];
                 $a_user_data[$buser]['consultation_hour_end'] = $booking[0]['dtend'];
                 $a_user_data[$buser]['consultation_hours'] = $booking;
             }
         }
     }
     return $this->setData($a_user_data);
 }
 /**
  * Parse user data
  * @param array $a_user_data
  * @return 
  */
 public function parse($a_user_data)
 {
     include_once './Services/User/classes/class.ilUserQuery.php';
     $additional_fields = $this->getSelectedColumns();
     unset($additional_fields["firstname"]);
     unset($additional_fields["lastname"]);
     unset($additional_fields["last_login"]);
     unset($additional_fields["access_until"]);
     unset($additional_fields['consultation_hour']);
     unset($additional_fields['prtf']);
     switch ($this->type) {
         case 'admin':
             $part = ilGroupParticipants::_getInstanceByObjId($this->getParentObject()->object->getId())->getAdmins();
             break;
         case 'member':
             $part = $GLOBALS['rbacreview']->assignedUsers($this->getRole());
             break;
         case 'role':
             $part = $GLOBALS['rbacreview']->assignedUsers($this->getRole());
             break;
     }
     $udf_ids = $usr_data_fields = $odf_ids = array();
     foreach ($additional_fields as $field) {
         if (substr($field, 0, 3) == 'udf') {
             $udf_ids[] = substr($field, 4);
             continue;
         }
         if (substr($field, 0, 3) == 'odf') {
             $odf_ids[] = substr($field, 4);
             continue;
         }
         $usr_data_fields[] = $field;
     }
     $usr_data = ilUserQuery::getUserListData('login', 'ASC', 0, 9999, '', '', null, false, false, 0, 0, null, $usr_data_fields, $part);
     // Custom user data fields
     if ($udf_ids) {
         include_once './Services/User/classes/class.ilUserDefinedData.php';
         $data = ilUserDefinedData::lookupData($part, $udf_ids);
         foreach ($data as $usr_id => $fields) {
             if (!$this->checkAcceptance($usr_id)) {
                 continue;
             }
             foreach ($fields as $field_id => $value) {
                 $a_user_data[$usr_id]['udf_' . $field_id] = $value;
             }
         }
     }
     // Object specific user data fields
     if ($odf_ids) {
         include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
         $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId());
         foreach ($data as $usr_id => $fields) {
             if (!$this->checkAcceptance($usr_id)) {
                 continue;
             }
             foreach ($fields as $field_id => $value) {
                 if ($a_user_data[$usr_id]) {
                     $a_user_data[$usr_id]['odf_' . $field_id] = $value;
                 }
             }
         }
         // add last edit date
         include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php';
         foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getParentObject()->object->getId()) as $usr_id => $edit_info) {
             if (!isset($a_user_data[$usr_id])) {
                 continue;
             }
             include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
             if ($usr_id == $edit_info['update_user']) {
                 $a_user_data[$usr_id]['odf_last_update'] = '';
                 $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self');
                 if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getParentObject()->object->getType())) {
                     $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX);
                     $a_user_data[$usr_id]['odf_info_txt'] .= ', ' . ilDatePresentation::formatDate($edit_info['editing_time']);
                 }
             } else {
                 $a_user_data[$usr_id]['odf_last_update'] = $edit_info['edit_user'];
                 $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX);
                 $name = ilObjUser::_lookupName($edit_info['update_user']);
                 $a_user_data[$usr_id]['odf_info_txt'] = $name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']);
             }
         }
     }
     foreach ($usr_data['set'] as $user) {
         // Check acceptance
         if (!$this->checkAcceptance($user['usr_id'])) {
             continue;
         }
         // DONE: accepted
         foreach ($usr_data_fields as $field) {
             $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
         }
     }
     // consultation hours
     if ($this->isColumnSelected('consultation_hour')) {
         include_once './Services/Booking/classes/class.ilBookingEntry.php';
         foreach (ilBookingEntry::lookupManagedBookingsForObject($this->getParentObject()->object->getId(), $GLOBALS['ilUser']->getId()) as $buser => $booking) {
             if (isset($a_user_data[$buser])) {
                 $a_user_data[$buser]['consultation_hour'] = $booking[0]['dt'];
                 $a_user_data[$buser]['consultation_hour_end'] = $booking[0]['dtend'];
                 $a_user_data[$buser]['consultation_hours'] = $booking;
             }
         }
     }
     return $this->setData($a_user_data);
 }
 /**
  * Read events (will be moved to another class, since only active and/or visible calendars are shown)
  *
  * @access protected
  */
 public function getEvents()
 {
     global $ilDB;
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     $cats = ilCalendarCategories::_getInstance($this->user->getId())->getCategories($this->enabledSubitemCalendars());
     if (!$this->filter_bookings) {
         $cats = $this->hidden_cat->filterHidden($cats, ilCalendarCategories::_getInstance($this->user->getId())->getCategoriesInfo());
     }
     if (!count($cats)) {
         return array();
     }
     // TODO: optimize
     $query = "SELECT ce.cal_id cal_id FROM cal_entries ce LEFT JOIN cal_recurrence_rules crr ON ce.cal_id = crr.cal_id " . "JOIN cal_cat_assignments ca ON ca.cal_id = ce.cal_id ";
     if ($this->type != self::TYPE_INBOX) {
         $query .= "WHERE ((starta <= " . $this->db->quote($this->end->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . " " . "AND enda >= " . $this->db->quote($this->start->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . ") " . "OR (starta <= " . $this->db->quote($this->end->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp') . " " . "AND NOT rule_id IS NULL)) ";
     } else {
         $date = new ilDateTime(mktime(0, 0, 0), IL_CAL_UNIX);
         $query .= "WHERE starta >= " . $this->db->quote($date->get(IL_CAL_DATETIME, '', 'UTC'), 'timestamp');
     }
     $query .= "AND " . $ilDB->in('ca.cat_id', $cats, false, 'integer') . " " . "ORDER BY starta";
     $res = $this->db->query($query);
     $events = array();
     include_once 'Services/Booking/classes/class.ilBookingEntry.php';
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!$this->hidden_cat->isAppointmentVisible($row->cal_id) || $this->filter_bookings) {
             $event = new ilCalendarEntry($row->cal_id);
             if (!$this->filter_bookings) {
                 $events[] = $event;
             } else {
                 $booking = new ilBookingEntry($event->getContextId());
                 if (!$booking->isBookedOut($row->cal_id, true)) {
                     $events[] = $event;
                 }
             }
         }
     }
     return $events;
 }
 /**
  * set appointments
  *
  * @access public
  * @return
  */
 public function setAppointments($a_apps)
 {
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     $cat = new ilCalendarCategory($this->cat_id);
     foreach ($a_apps as $cal_entry_id) {
         $entry = new ilCalendarEntry($cal_entry_id);
         $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
         // booking
         if ($cat->getType() == ilCalendarCategory::TYPE_CH) {
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $book = new ilBookingEntry($entry->getContextId());
             if ($book) {
                 $title = $entry->getTitle();
                 if ($book->isOwner()) {
                     $max = (int) $book->getNumberOfBookings();
                     $current = (int) $book->getCurrentNumberOfBookings($entry->getEntryId());
                     if ($max > 1) {
                         $title .= ' (' . $current . '/' . $max . ')';
                     } else {
                         if ($current == $max) {
                             $title .= ' (' . $this->lng->txt('cal_booked_out') . ')';
                         } else {
                             $title .= ' (' . $this->lng->txt('cal_book_free') . ')';
                         }
                     }
                 } else {
                     if ($book->hasBooked($entry->getEntryId())) {
                         $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
                     }
                 }
             }
         } else {
             $title = $entry->getPresentationTitle();
         }
         $tmp_arr['id'] = $entry->getEntryId();
         $tmp_arr['title'] = $title;
         $tmp_arr['description'] = $entry->getDescription();
         $tmp_arr['fullday'] = $entry->isFullday();
         $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
         $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
         $tmp_arr['dt_sort'] = $entry->getStart()->get(IL_CAL_UNIX);
         $tmp_arr['dt'] = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
         #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24;
         $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
         if ($tmp_arr['fullday']) {
             $tmp_arr['duration'] += 60 * 60 * 24;
         }
         if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) {
             $tmp_arr['duration'] = '';
         }
         $tmp_arr['frequence'] = $rec->getFrequenceType();
         $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable);
         $appointments[] = $tmp_arr;
     }
     $this->setData($appointments ? $appointments : array());
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBlock('app');
     } else {
         $this->tpl->setCurrentBlock('scrd_app');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
     $this->tpl->setVariable('APP_ROWSPAN', $a_app['rowspan']);
     $this->tpl->setVariable('APP_TITLE', $a_app['event']->getPresentationTitle(false));
     switch ($this->user_settings->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
             break;
         case ilCalendarSettings::TIME_FORMAT_12:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
             break;
     }
     // add end time for screen readers
     if ($ilUser->prefs["screen_reader_optimization"]) {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
     }
     // booking
     if ($a_app['category_type'] == ilCalendarCategory::TYPE_CH) {
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         $entry = new ilBookingEntry($a_app['event']->getContextId());
         if ($entry) {
             $title .= ' ' . $a_app['event']->getTitle();
             if ($entry->isOwner()) {
                 $max = (int) $entry->getNumberOfBookings();
                 $current = (int) $entry->getCurrentNumberOfBookings($a_app['event']->getEntryId());
                 if ($max > 1) {
                     $title .= ' (' . $current . '/' . $max . ')';
                 } else {
                     if ($current == $max) {
                         $title .= ' (' . $this->lng->txt('cal_booked_out') . ')';
                     } else {
                         $title .= ' (' . $this->lng->txt('cal_book_free') . ')';
                     }
                 }
             } else {
                 if ($entry->hasBooked($a_app['event']->getEntryId())) {
                     $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
                 }
             }
         }
     } else {
         $title .= ' ' . $a_app['event']->getPresentationTitle(false);
     }
     $this->tpl->setVariable('APP_TITLE', $title);
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_BGCOLOR', $color);
     $this->tpl->setVariable('APP_COLOR', ilCalendarUtil::calculateFontColor($color));
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $this->tpl->parseCurrentBlock();
     $this->num_appointments++;
 }
 protected function parseDynamicTitle($a_type)
 {
     global $lng;
     $title = $style = "";
     switch ($a_type) {
         case "consultationhour":
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $entry = new ilBookingEntry($this->getContextId());
             if ($entry) {
                 if ($entry->isOwner()) {
                     $max = (int) $entry->getNumberOfBookings();
                     $current = (int) $entry->getCurrentNumberOfBookings($this->getEntryId());
                     if (!$current) {
                         $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: green';
                         $title = $lng->txt('cal_book_free');
                     } elseif ($current >= $max) {
                         $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: red';
                         $title = $lng->txt('cal_booked_out');
                     } else {
                         $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: yellow';
                         $title = $current . '/' . $max;
                     }
                 } else {
                     /*
                      * if($entry->hasBooked($this->getEntryId()))
                      */
                     include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
                     $apps = ilConsultationHourAppointments::getAppointmentIds($entry->getObjId(), $this->getContextId(), $this->getStart());
                     $orig_event = $apps[0];
                     if ($entry->hasBooked($orig_event)) {
                         $style = ';border-left-width: 5px; border-left-style: solid; border-left-color: green';
                         $title = $lng->txt('cal_date_booked');
                     }
                 }
             }
             break;
     }
     if ($style) {
         $this->presentation_style = $style;
     }
     return $title;
 }
 /**
  * Get selectable fields
  * @return 
  */
 public function getSelectableFieldsInfo($a_obj_id)
 {
     global $lng;
     $fields = array();
     foreach ($this->getExportableFields() as $field) {
         switch ($field) {
             case 'lastname':
             case 'firstname':
                 break;
             case 'username':
                 $fields['login']['txt'] = $lng->txt('login');
                 $fields['login']['default'] = 1;
                 break;
             default:
                 $fields[$field]['txt'] = $lng->txt($field);
                 $fields[$field]['default'] = 0;
                 break;
         }
     }
     include_once './Services/Booking/classes/class.ilBookingEntry.php';
     if (ilBookingEntry::hasObjectBookingEntries($a_obj_id, $GLOBALS['ilUser']->getId())) {
         $GLOBALS['lng']->loadLanguageModule('dateplaner');
         $fields['consultation_hour']['txt'] = $GLOBALS['lng']->txt('cal_ch_field_ch');
         $fields['consultation_hour']['default'] = 0;
     }
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     if ($this->getType() == 'crs') {
         $udf = ilUserDefinedFields::_getInstance()->getCourseExportableFields();
     } elseif ($this->getType() == 'grp') {
         $udf = ilUserDefinedFields::_getInstance()->getGroupExportableFields();
     }
     if ($udf) {
         foreach ($udf as $field_id => $field) {
             $fields['udf_' . $field_id]['txt'] = $field['field_name'];
             $fields['udf_' . $field_id]['default'] = 0;
         }
     }
     include_once './Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     $cdf = ilCourseDefinedFieldDefinition::_getFields($a_obj_id);
     foreach ($cdf as $def) {
         $fields['odf_' . $def->getId()]['txt'] = $def->getName();
         $fields['odf_' . $def->getId()]['default'] = 0;
     }
     if (count($cdf)) {
         // add last edit
         $fields['odf_last_update']['txt'] = $GLOBALS['lng']->txt($this->getType() . '_cdf_tbl_last_edit');
         $fields['odf_last_update']['default'] = 0;
     }
     return $fields;
 }
 /**
  * Parse Groups
  * @param array $groups
  */
 public function parse(array $appointments)
 {
     global $ilCtrl;
     $rows = array();
     $counter = 0;
     foreach ($appointments as $app) {
         include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
         $cal_entry = new ilCalendarEntry($app);
         include_once './Services/Booking/classes/class.ilBookingEntry.php';
         foreach (ilBookingEntry::lookupBookingsForAppointment($app) as $user_id) {
             include_once './Services/User/classes/class.ilUserUtil.php';
             $rows[$counter]['name'] = ilUserUtil::getNamePresentation($user_id, true, true, $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd()), true, true);
             $message = ilBookingEntry::lookupBookingMessage($app, $user_id);
             if (strlen(trim($message))) {
                 $rows[$counter]['comment'] = '"' . $message . '"';
             }
             $rows[$counter]['title'] = $cal_entry->getTitle();
             $rows[$counter]['start'] = $cal_entry->getStart()->get(IL_CAL_UNIX);
             $rows[$counter]['start_str'] = ilDatePresentation::formatDate($cal_entry->getStart());
             $rows[$counter]['id'] = $app . '_' . $user_id;
             ++$counter;
         }
     }
     $this->setData($rows);
 }
 /**
  * Write data
  * @return 
  */
 protected function write()
 {
     // Add header line
     $row = 0;
     $col = 0;
     foreach ($all_fields = $this->getOrderedExportableFields() as $field) {
         switch ($field) {
             case 'role':
                 #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status'));
                 $this->addCol($this->lng->txt($this->getType() . '_role_status'), $row, $col++);
                 break;
             case 'agreement':
                 #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted'));
                 $this->addCol($this->lng->txt('ps_agreement_accepted'), $row, $col++);
                 break;
             case 'consultation_hour':
                 $this->lng->loadLanguageModule('dateplaner');
                 $this->addCol($this->lng->txt('cal_ch_field_ch'), $row, $col++);
                 break;
             default:
                 if (substr($field, 0, 4) == 'udf_') {
                     $field_id = explode('_', $field);
                     include_once 'Services/User/classes/class.ilUserDefinedFields.php';
                     $udf = ilUserDefinedFields::_getInstance();
                     $def = $udf->getDefinition($field_id[1]);
                     #$this->csv->addColumn($def['field_name']);
                     $this->addCol($def['field_name'], $row, $col++);
                 } elseif (substr($field, 0, 4) == 'cdf_') {
                     $field_id = explode('_', $field);
                     #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]));
                     $this->addCol(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]), $row, $col++);
                 } else {
                     #$this->csv->addColumn($this->lng->txt($field));
                     $this->addCol($this->lng->txt($field), $row, $col++);
                 }
                 break;
         }
     }
     #$this->csv->addRow();
     $this->addRow();
     // Add user data
     foreach ($this->user_ids as $usr_id) {
         $row++;
         $col = 0;
         $udf_data = new ilUserDefinedData($usr_id);
         foreach ($all_fields as $field) {
             // Handle course defined fields
             if ($this->addUserDefinedField($udf_data, $field, $row, $col)) {
                 $col++;
                 continue;
             }
             if ($this->addCourseField($usr_id, $field, $row, $col)) {
                 $col++;
                 continue;
             }
             switch ($field) {
                 case 'role':
                     switch ($this->user_course_data[$usr_id]['role']) {
                         case IL_CRS_ADMIN:
                             #$this->csv->addColumn($this->lng->txt('crs_admin'));
                             $this->addCol($this->lng->txt('crs_admin'), $row, $col++);
                             break;
                         case IL_CRS_TUTOR:
                             #$this->csv->addColumn($this->lng->txt('crs_tutor'));
                             $this->addCol($this->lng->txt('crs_tutor'), $row, $col++);
                             break;
                         case IL_CRS_MEMBER:
                             #$this->csv->addColumn($this->lng->txt('crs_member'));
                             $this->addCol($this->lng->txt('crs_member'), $row, $col++);
                             break;
                         case IL_GRP_ADMIN:
                             #$this->csv->addColumn($this->lng->txt('il_grp_admin'));
                             $this->addCol($this->lng->txt('il_grp_admin'), $row, $col++);
                             break;
                         case IL_GRP_MEMBER:
                             #$this->csv->addColumn($this->lng->txt('il_grp_member'));
                             $this->addCol($this->lng->txt('il_grp_member'), $row, $col++);
                             break;
                         case 'subscriber':
                             #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber'));
                             $this->addCol($this->lng->txt($this->getType() . '_subscriber'), $row, $col++);
                             break;
                         default:
                             #$this->csv->addColumn($this->lng->txt('crs_waiting_list'));
                             $this->addCol($this->lng->txt('crs_waiting_list'), $row, $col++);
                             break;
                     }
                     break;
                 case 'agreement':
                     if (isset($this->agreement[$usr_id])) {
                         if ($this->agreement[$usr_id]['accepted']) {
                             #$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true));
                             $this->addCol(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'], true), $row, $col++);
                         } else {
                             #$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
                             $this->addCol($this->lng->txt('ps_not_accepted'), $row, $col++);
                         }
                     } else {
                         #$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
                         $this->addCol($this->lng->txt('ps_not_accepted'), $row, $col++);
                     }
                     break;
                     // These fields are always enabled
                 // These fields are always enabled
                 case 'username':
                     #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']);
                     $this->addCol($this->user_profile_data[$usr_id]['login'], $row, $col++);
                     break;
                 case 'firstname':
                 case 'lastname':
                     #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
                     $this->addCol($this->user_profile_data[$usr_id][$field], $row, $col++);
                     break;
                 case 'consultation_hour':
                     include_once './Services/Booking/classes/class.ilBookingEntry.php';
                     $bookings = ilBookingEntry::lookupManagedBookingsForObject($this->obj_id, $GLOBALS['ilUser']->getId());
                     $uts = array();
                     foreach ((array) $bookings[$usr_id] as $ut) {
                         ilDatePresentation::setUseRelativeDates(false);
                         $tmp = ilDatePresentation::formatPeriod(new ilDateTime($ut['dt'], IL_CAL_UNIX), new ilDateTime($ut['dtend'], IL_CAL_UNIX));
                         if (strlen($ut['explanation'])) {
                             $tmp .= ' ' . $ut['explanation'];
                         }
                         $uts[] = $tmp;
                     }
                     $uts_str = implode(',', $uts);
                     $this->addCol($uts_str, $row, $col++);
                     break;
                 default:
                     // Check aggreement
                     if (!$this->privacy->courseConfirmationRequired() and !ilCourseDefinedFieldDefinition::_getFields($this->obj_id) or $this->agreement[$usr_id]['accepted']) {
                         #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
                         $this->addCol($this->user_profile_data[$usr_id][$field], $row, $col++);
                     } else {
                         #$this->csv->addColumn('');
                         $this->addCol('', $row, $col++);
                     }
                     break;
             }
         }
         #$this->csv->addRow();
         $this->addRow();
     }
 }
 /**
  * delete multiple entries
  */
 public function delete()
 {
     if (!isset($_POST['apps'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         return $this->appointmentList();
     }
     include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     foreach ($_POST['apps'] as $entry_id) {
         // cancel booking for users
         $booking = ilBookingEntry::getInstanceByCalendarEntryId($entry_id);
         if ($booking) {
             foreach ($booking->getCurrentBookings($entry_id) as $user_id) {
                 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
                 ilConsultationHourUtils::cancelBooking($user_id, $entry_id, false);
             }
         }
         // remove calendar entries
         include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
         $entry = new ilCalendarEntry($entry_id);
         $entry->delete();
         ilCalendarCategoryAssignments::_deleteByAppointmentId($entry_id);
     }
     ilBookingEntry::removeObsoleteEntries();
     ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
     $this->ctrl->redirect($this, 'appointmentList');
 }
 /**
  * Parse appointments
  * @return 
  */
 public function parse()
 {
     global $ilDB, $ilObjDataCache;
     include_once 'Services/Booking/classes/class.ilBookingEntry.php';
     $data = array();
     $counter = 0;
     foreach (ilConsultationHourAppointments::getAppointments($this->getUserId()) as $app) {
         $data[$counter]['id'] = $app->getEntryId();
         $data[$counter]['title'] = $app->getTitle();
         $data[$counter]['description'] = $app->getDescription();
         $data[$counter]['start'] = $app->getStart()->get(IL_CAL_UNIX);
         $data[$counter]['start_p'] = ilDatePresentation::formatDate($app->getStart());
         $booking = new ilBookingEntry($app->getContextId());
         $users = array();
         foreach ($booking->getCurrentBookings($app->getEntryId()) as $user_id) {
             $users[$user_id] = ilObjUser::_lookupFullname($user_id);
         }
         $data[$counter]['num_bookings'] = sizeof($users);
         $data[$counter]['bookings'] = $users;
         $target = $booking->getTargetObjId();
         if ($target) {
             $data[$counter]['target'] = $ilObjDataCache->lookupTitle($target);
         }
         $counter++;
     }
     $this->setData($data);
 }