diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarAppointmentsTableGUI.php b/components/ILIAS/Calendar/classes/class.ilCalendarAppointmentsTableGUI.php deleted file mode 100755 index e2ef2468024e..000000000000 --- a/components/ILIAS/Calendar/classes/class.ilCalendarAppointmentsTableGUI.php +++ /dev/null @@ -1,176 +0,0 @@ - - * @ingroup ServicesCalendar - */ -class ilCalendarAppointmentsTableGUI extends ilTable2GUI -{ - private int $cat_id = 0; - private ilCalendarCategories $categories; - private bool $is_editable = false; - - public function __construct(object $a_parent_obj, string $a_parent_cmd, int $a_category_id) - { - global $DIC; - - $this->categories = ilCalendarCategories::_getInstance(); - $this->cat_id = $a_category_id; - $this->is_editable = $this->categories->isEditable($this->cat_id); - - $this->setId('calcalapps'); - parent::__construct($a_parent_obj, $a_parent_cmd); - - $this->lng->loadLanguageModule('dateplaner'); - - $this->setFormName('appointments'); - $this->addColumn('', 'f', "1"); - $this->addColumn($this->lng->txt('cal_start'), 'dt_sort', "30%"); - $this->addColumn($this->lng->txt('title'), 'title', "60%"); - $this->addColumn($this->lng->txt('cal_duration'), 'duration', "20%"); - $this->addColumn($this->lng->txt('cal_recurrences'), 'frequence', "10%"); - - if ($this->is_editable) { - $this->addMultiCommand('askDeleteAppointments', $this->lng->txt('delete')); - $this->enable('select_all'); - } else { - $this->disable('select_all'); - } - - $this->setFormAction($this->ctrl->getFormAction($a_parent_obj)); - $this->setRowTemplate("tpl.show_appointment_row.html", "components/ILIAS/Calendar"); - - $this->setShowRowsSelector(true); - $this->enable('sort'); - $this->enable('header'); - $this->enable('numinfo'); - - $this->setDefaultOrderField('dt_sort'); - $this->setSelectAllCheckbox('appointments'); - } - - protected function fillRow(array $a_set): void - { - if ($a_set['deletable']) { - $this->tpl->setVariable('VAL_ID', $a_set['id']); - } - - $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']); - - $this->tpl->setVariable('VAL_TITLE_LINK', $a_set['title']); - $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_set['id']); - $this->tpl->setVariable('VAL_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit')); - - switch ($a_set['frequence']) { - case ilCalendarRecurrence::FREQ_DAILY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_daily')); - break; - - case ilCalendarRecurrence::FREQ_WEEKLY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_weekly')); - break; - - case ilCalendarRecurrence::FREQ_MONTHLY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_monthly')); - break; - - case ilCalendarRecurrence::FREQ_YEARLY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_yearly')); - break; - - default: - //$this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence')); - $this->tpl->setVariable('VAL_FREQUENCE', ''); - break; - } - $this->tpl->setVariable('VAL_BEGIN', $a_set['dt']); - if ($a_set['duration']) { - $this->tpl->setVariable('VAL_DURATION', ilDatePresentation::secondsToString($a_set['duration'])); - } else { - $this->tpl->setVariable('VAL_DURATION', ''); - } - } - - /** - * set appointments - * @param int[] - */ - public function setAppointments(array $a_apps): void - { - $cat = new ilCalendarCategory($this->cat_id); - - $appointments = []; - foreach ($a_apps as $cal_entry_id) { - $entry = new ilCalendarEntry($cal_entry_id); - $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId()); - - // booking - $title = ''; - if ($cat->getType() == ilCalendarCategory::TYPE_CH) { - $book = new ilBookingEntry($entry->getContextId()); - if ($book) { - $title = $entry->getTitle(); - if ($book->isOwner()) { - $max = $book->getNumberOfBookings(); - $current = $book->getCurrentNumberOfBookings($entry->getEntryId()); - if ($max > 1) { - $title .= ' (' . $current . '/' . $max . ')'; - } elseif ($current == $max) { - $title .= ' (' . $this->lng->txt('cal_booked_out') . ')'; - } else { - $title .= ' (' . $this->lng->txt('cal_book_free') . ')'; - } - } elseif ($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'] = $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); - } -} diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php b/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php index 111c76eb3dc1..c7079a3d36d1 100755 --- a/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php +++ b/components/ILIAS/Calendar/classes/class.ilCalendarCategoryGUI.php @@ -161,8 +161,6 @@ public function executeCommand(): void } switch ($next_class) { case 'ilcalendarappointmentgui': - $this->ctrl->setReturn($this, 'details'); - $app_id = 0; if ($this->http->wrapper()->query()->has('app_id')) { $app_id = $this->http->wrapper()->query()->retrieve( @@ -177,9 +175,6 @@ public function executeCommand(): void default: $cmd = $this->ctrl->getCmd("show"); $this->$cmd(); - if (!in_array($cmd, array("details", "askDeleteAppointments", "deleteAppointments"))) { - return; - } } } @@ -346,25 +341,6 @@ protected function edit(?ilPropertyFormGUI $form = null): void $this->tpl->setContent($form->getHTML()); } - protected function details(): void - { - if (!$this->category_id) { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true); - $this->ctrl->returnToParent($this); - } - - $this->readPermissions(); - $this->checkVisible(); - - // Non editable category - $info = new ilInfoScreenGUI($this); - $info->setFormAction($this->ctrl->getFormAction($this)); - - $info->addSection($this->lng->txt('cal_cal_details')); - - $this->tpl->setContent($info->getHTML() . $this->showAssignedAppointments()); - } - protected function synchroniseCalendar(): void { if (!$this->category_id) { @@ -941,84 +917,6 @@ protected function unshare(): void $this->ctrl->redirect($this, 'manage'); } - protected function showAssignedAppointments(): string - { - $table_gui = new ilCalendarAppointmentsTableGUI($this, 'details', $this->category_id); - $table_gui->setTitle($this->lng->txt('cal_assigned_appointments')); - $table_gui->setAppointments( - ilCalendarCategoryAssignments::_getAssignedAppointments( - ilCalendarCategories::_getInstance()->getSubitemCategories($this->category_id) - ) - ); - return $table_gui->getHTML(); - } - - protected function askDeleteAppointments(): void - { - $appointments = []; - if ($this->http->wrapper()->post()->has('appointments')) { - $appointments = $this->http->wrapper()->post()->retrieve( - 'appointments', - $this->refinery->kindlyTo()->dictOf( - $this->refinery->kindlyTo()->int() - ) - ); - } - if (!count($appointments)) { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one')); - $this->details(); - return; - } - $this->readPermissions(); - if (!$this->isEditable() || !$this->areAppointmentsEditable($appointments)) { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true); - $this->ctrl->returnToParent($this); - } - - $confirmation_gui = new ilConfirmationGUI(); - $this->ctrl->setParameter($this, 'category_id', $this->category_id); - $confirmation_gui->setFormAction($this->ctrl->getFormAction($this)); - $confirmation_gui->setHeaderText($this->lng->txt('cal_del_app_sure')); - $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteAppointments'); - $confirmation_gui->setCancel($this->lng->txt('cancel'), 'details'); - - foreach ($appointments as $app_id) { - $app = new ilCalendarEntry($app_id); - $confirmation_gui->addItem('appointments[]', (string) $app_id, $app->getTitle()); - } - $this->tpl->setContent($confirmation_gui->getHTML()); - } - - protected function deleteAppointments(): void - { - $appointments = []; - if ($this->http->wrapper()->post()->has('appointments')) { - $appointments = $this->http->wrapper()->post()->retrieve( - 'appointments', - $this->refinery->kindlyTo()->dictOf( - $this->refinery->kindlyTo()->int() - ) - ); - } - if (!count($appointments)) { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one')); - $this->details(); - return; - } - $this->readPermissions(); - if (!$this->isEditable() || !$this->areAppointmentsEditable($appointments)) { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true); - $this->ctrl->returnToParent($this); - } - foreach ($appointments as $app_id) { - $app = new ilCalendarEntry($app_id); - $app->delete(); - ilCalendarCategoryAssignments::_deleteByAppointmentId($app_id); - } - $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved')); - $this->details(); - } - public function getHTML(): string { $block_gui = new ilCalendarSelectionBlockGUI($this->seed, $this->ref_id); diff --git a/components/ILIAS/Calendar/classes/class.ilCalendarChangedAppointmentsTableGUI.php b/components/ILIAS/Calendar/classes/class.ilCalendarChangedAppointmentsTableGUI.php deleted file mode 100755 index a7ddcf8217a0..000000000000 --- a/components/ILIAS/Calendar/classes/class.ilCalendarChangedAppointmentsTableGUI.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @version $Id$ - * @ingroup ServicesCalendar - */ -class ilCalendarChangedAppointmentsTableGUI extends ilTable2GUI -{ - private int $cat_id = 0; - private bool $is_editable = false; - private ilObjUser $user; - - public function __construct(?object $a_parent_obj, string $a_parent_cmd) - { - global $DIC; - - $this->user = $DIC->user(); - $this->lng = $DIC->language(); - $this->lng->loadLanguageModule('dateplaner'); - $this->ctrl = $DIC->ctrl(); - - $this->setId('calinbox'); - - parent::__construct($a_parent_obj, $a_parent_cmd); - $this->setFormName('appointments'); - $this->addColumn($this->lng->txt('date'), 'begin', "30%"); - $this->addColumn($this->lng->txt('title'), 'title', "40%"); - #$this->addColumn($this->lng->txt('cal_duration'),'duration',"15%"); - $this->addColumn($this->lng->txt('cal_recurrences'), 'frequence', "15%"); - $this->addColumn($this->lng->txt('last_update'), 'last_update', "15%"); - - $this->setFormAction($this->ctrl->getFormAction($a_parent_obj)); - $this->setRowTemplate("tpl.show_changed_appointment_row.html", "components/ILIAS/Calendar"); - - $this->setShowRowsSelector(true); - $this->enable('sort'); - $this->enable('header'); - $this->enable('numinfo'); - - $this->setDefaultOrderField('begin'); - $this->setDefaultOrderDirection('asc'); - } - - protected function fillRow(array $a_set): void - { - $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']); - - $this->tpl->setVariable('VAL_TITLE_LINK', $a_set['title']); - $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_set['id']); - $this->tpl->setVariable('VAL_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit')); - - switch ($a_set['frequence']) { - case ilCalendarRecurrence::FREQ_DAILY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_daily')); - break; - - case ilCalendarRecurrence::FREQ_WEEKLY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_weekly')); - break; - - case ilCalendarRecurrence::FREQ_MONTHLY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_monthly')); - break; - - case ilCalendarRecurrence::FREQ_YEARLY: - $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_yearly')); - break; - - default: - #$this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence')); - break; - } - if ($a_set['fullday']) { - $date = ilDatePresentation::formatPeriod( - new ilDate($a_set['begin'], IL_CAL_UNIX), - new ilDate($a_set['end'], IL_CAL_UNIX) - ); - } else { - $date = ilDatePresentation::formatPeriod( - new ilDateTime($a_set['begin'], IL_CAL_UNIX), - new ilDateTime($a_set['end'], IL_CAL_UNIX) - ); - } - $this->tpl->setVariable('VAL_BEGIN', $date); - $update = new ilDateTime($a_set['last_update'], IL_CAL_UNIX, $this->user->getTimeZone()); - $this->tpl->setVariable('VAL_LAST_UPDATE', ilDatePresentation::formatDate($update)); - } - - public function setAppointments(array $a_apps): void - { - $appointments = []; - foreach ($a_apps as $event) { - $entry = $event['event']; - - $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId()); - - $tmp_arr['id'] = $entry->getEntryId(); - $tmp_arr['title'] = $entry->getPresentationTitle(); - $tmp_arr['description'] = $entry->getDescription(); - $tmp_arr['fullday'] = $entry->isFullday(); - - $tmp_arr['begin'] = $event['dstart']; - $tmp_arr['end'] = $event['dend']; - - $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['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX); - $tmp_arr['frequence'] = $rec->getFrequenceType(); - - $appointments[] = $tmp_arr; - } - - //cuts appointments array after Limit - $appointments = array_slice($appointments, 0, $this->getLimit()); - $this->setData($appointments); - } -} diff --git a/components/ILIAS/Calendar/templates/default/tpl.show_appointment_row.html b/components/ILIAS/Calendar/templates/default/tpl.show_appointment_row.html deleted file mode 100755 index a2fe934fca86..000000000000 --- a/components/ILIAS/Calendar/templates/default/tpl.show_appointment_row.html +++ /dev/null @@ -1,29 +0,0 @@ -