ILIAS  release_8 Revision v8.24
class.ilCalendarManageTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
29 protected ilObjUser $user;
30
31 public function __construct(object $a_parent_obj)
32 {
33 global $DIC;
34
35 $this->setId("calmng");
36 parent::__construct($a_parent_obj, 'manage');
37
38 $this->user = $DIC->user();
39
40 $this->actions = ilCalendarActions::getInstance();
41 $this->lng->loadLanguageModule('dateplaner');
42 $this->setFormName('categories');
43 $this->addColumn('', '', '1px', true);
44 $this->addColumn($this->lng->txt('type'), 'type_sortable', '1%');
45 $this->addColumn($this->lng->txt('title'), 'title', '79%');
46 $this->addColumn('', '', '20%');
47
48 $this->setRowTemplate("tpl.manage_row.html", "Services/Calendar");
49 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, "manage"));
50
51 $this->enable('select_all');
52 $this->enable('sort');
53 $this->enable('header');
54 $this->enable('num_info');
55
56 $this->setSelectAllCheckbox('selected_cat_ids');
57 $this->setShowRowsSelector(true);
58 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
59 $this->setDefaultOrderDirection('asc');
60 $this->setDefaultOrderField('type_sortable');
61 }
62
66 public function resetToDefaults(): void
67 {
68 $this->resetOffset();
69 $this->setOrderField('type_sortable');
70 $this->setOrderDirection('asc');
71 }
72
73 protected function fillRow(array $a_set): void
74 {
75 $current_selection_list = new ilAdvancedSelectionListGUI();
76 $current_selection_list->setListTitle($this->lng->txt("actions"));
77 $current_selection_list->setId("act_" . $a_set['id']);
78
79 $this->ctrl->setParameter($this->getParentObject(), 'category_id', $a_set['id']);
80
81 // edit
82 if ($this->actions->checkSettingsCal($a_set['id'])) {
83 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'edit');
84 $current_selection_list->addItem($this->lng->txt('settings'), '', $url);
85 }
86
87 // import (ics appointments)
88 if ($this->actions->checkAddEvent($a_set['id'])) {
89 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'importAppointments');
90 $current_selection_list->addItem($this->lng->txt('cal_import_appointments'), '', $url);
91 }
92
93 // unshare
94 if ($this->actions->checkUnshareCal($a_set['id'])) {
95 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'unshare');
96 $current_selection_list->addItem($this->lng->txt('cal_unshare'), '', $url);
97 }
98
99 // share
100 if ($this->actions->checkShareCal($a_set['id'])) {
101 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'shareSearch');
102 $current_selection_list->addItem($this->lng->txt('cal_share'), '', $url);
103 }
104
105 // synchronize
106 if ($this->actions->checkSynchronizeCal($a_set['id'])) {
107 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'synchroniseCalendar');
108 $current_selection_list->addItem($this->lng->txt('cal_cal_synchronize'), '', $url);
109 }
110
111 // delete
112 if ($this->actions->checkDeleteCal($a_set['id'])) {
113 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDelete');
114 $current_selection_list->addItem($this->lng->txt('delete'), '', $url);
115
116 $this->tpl->setCurrentBlock("checkbox");
117 $this->tpl->setVariable('VAL_ID', $a_set['id']);
118 $this->tpl->parseCurrentBlock();
119 }
120
121 $this->ctrl->setParameter($this->getParentObject(), 'category_id', '');
122
123 switch ($a_set['type']) {
125 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_calg.svg'));
126 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_system'));
127 break;
128
130 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_usr.svg'));
131 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_personal'));
132 break;
133
135 $type = ilObject::_lookupType($a_set['obj_id']);
136 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_' . $type . '.svg'));
137 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_' . $type));
138 break;
139
141 $type = ilObject::_lookupType($a_set['obj_id']);
142 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_book.svg'));
143 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_' . $type));
144 break;
145
147 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_calch.svg'));
148 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_ch_ch'));
149 break;
150
151 }
152
153 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
154 $this->ctrl->setParameterByClass(ilCalendarPresentationGUI::class, 'backvm', 1);
155 $this->ctrl->setParameterByClass(
156 "ilcalendarpresentationgui",
157 'category_id',
158 $a_set['id']
159 );
160 $this->tpl->setVariable(
161 'EDIT_LINK',
162 $this->ctrl->getLinkTargetByClass(
163 "ilcalendarpresentationgui",
164 ''
165 )
166 );
167 $this->tpl->setVariable('BGCOLOR', $a_set['color']);
168 $this->tpl->setVariable("ACTIONS", $current_selection_list->getHTML());
169 }
170
171 public function parse(): void
172 {
173 $cats = ilCalendarCategories::_getInstance($this->user->getId());
174
175 $tmp_title_counter = array();
176 $categories = array();
177 foreach ($cats->getCategoriesInfo() as $category) {
178 $tmp_arr['obj_id'] = $category['obj_id'];
179 $tmp_arr['id'] = $category['cat_id'];
180 $tmp_arr['title'] = $category['title'];
181 $tmp_arr['type'] = $category['type'];
182
183 // Append object type to make type sortable
184 $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
185 if ($category['type'] == ilCalendarCategory::TYPE_OBJ) {
186 $tmp_arr['type_sortable'] .= ('_' . ilObject::_lookupType($category['obj_id']));
187 }
188
189 $tmp_arr['color'] = $category['color'];
190 $tmp_arr['editable'] = $category['editable'];
191 $tmp_arr['accepted'] = $category['accepted'];
192 $tmp_arr['remote'] = $category['remote'];
193
194 $categories[] = $tmp_arr;
195
196 // count title for appending the parent container if there is more than one entry.
197 if ($tmp_title_counter[$category['type'] . '_' . $category['title']] ?? false) {
198 $tmp_title_counter[$category['type'] . '_' . $category['title']]++;
199 } else {
200 $tmp_title_counter[$category['type'] . '_' . $category['title']] = 1;
201 }
202 }
203
204 $path_categories = array();
205 foreach ($categories as $cat) {
206 if ($cat['type'] == ilCalendarCategory::TYPE_OBJ) {
207 if (($tmp_title_counter[$cat['type'] . '_' . $cat['title']] ?? 1) > 1) {
208 foreach (ilObject::_getAllReferences($cat['obj_id']) as $ref_id) {
209 $path = new ilPathGUI();
210 $path->setUseImages(false);
211 $path->enableTextOnly(false);
212 $cat['path'] = $path->getPath(ROOT_FOLDER_ID, $ref_id);
213 break;
214 }
215 }
216 }
217 $path_categories[] = $cat;
218 }
219 $this->setData($path_categories);
220 }
221}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance()
Get instance.
static _getInstance($a_usr_id=0)
get singleton instance
static lookupCategorySortIndex(int $a_type_id)
Lookup sort index of calendar type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
resetToDefaults()
reset table to defaults
fillRow(array $a_set)
Standard Version of Fill Row.
User class.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
Creates a path for a start and endnode.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setOrderField(string $a_order_field)
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
resetOffset(bool $a_in_determination=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
enable(string $a_module_name)
setOrderDirection(string $a_order_direction)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url