ILIAS  release_8 Revision v8.24
class.ilObjectServiceSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
31{
32 // unfortunately the following constants are not stored
33 // in a non-GUI class, other classes are currently directly
34 // accessing these, see ilObjectDataSet (changes should be
35 // made there accordingly)
36
37 public const CALENDAR_CONFIGURATION = 'cont_cal_configuration';
38 public const CALENDAR_VISIBILITY = 'cont_show_calendar';
39 public const CALENDAR_ACTIVATION = 'cont_activation_calendar';
40
41 public const NEWS_VISIBILITY = 'cont_show_news';
42 public const USE_NEWS = 'cont_use_news';
43 public const AUTO_RATING_NEW_OBJECTS = 'cont_auto_rate_new_obj';
44 public const INFO_TAB_VISIBILITY = 'cont_show_info_tab';
45 public const TAXONOMIES = 'cont_taxonomies';
46 public const TAG_CLOUD = 'cont_tag_cloud';
47 public const CUSTOM_METADATA = 'cont_custom_md';
48 public const BADGES = 'cont_badges';
49 public const ORGU_POSITION_ACCESS = 'obj_orgunit_positions';
50 public const SKILLS = 'cont_skills';
51 public const FILTER = 'filter';
52 public const BOOKING = 'cont_bookings';
53 public const EXTERNAL_MAIL_PREFIX = 'mail_external_prefix';
54
55 protected ilCtrl $ctrl;
57 protected ilLanguage $lng;
58
59 protected ?ilObjectGUI $gui = null;
60 protected array $modes = [];
61 protected int $obj_id = 0;
62
66 public function __construct(ilObjectGUI $parent_gui, int $obj_id, array $modes)
67 {
68 global $DIC;
69 $this->main_tpl = $DIC->ui()->mainTemplate();
70 $this->ctrl = $DIC->ctrl();
71 $this->lng = $DIC["lng"];
72
73 $this->gui = $parent_gui;
74 $this->modes = $DIC->refinery()->to()->listOf(
75 $DIC->refinery()->kindlyTo()->string()
76 )->transform($modes);
77
78 $this->obj_id = $obj_id;
79 }
80
81 public function executeCommand(): void
82 {
83 $this->ctrl->getNextClass($this);
84 $cmd = $this->ctrl->getCmd('editSettings');
85 $this->$cmd();
86 }
87
88 public static function initServiceSettingsForm(
89 int $obj_id,
91 array $services
93 global $DIC;
94
95 $ilSetting = $DIC->settings();
96 $ilCtrl = $DIC->ctrl();
97 $lng = $DIC->language();
98
100
101 // info tab
102 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
103 $info = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_info_tab'), self::INFO_TAB_VISIBILITY);
104 $info->setValue("1");
105 $info->setChecked((bool) ilContainer::_lookupContainerSetting(
106 $obj_id,
107 self::INFO_TAB_VISIBILITY
108 ));
109 //$info->setOptionTitle($lng->txt('obj_tool_setting_info_tab'));
110 $info->setInfo($lng->txt('obj_tool_setting_info_tab_info'));
111 $form->addItem($info);
112 }
113
114 // calendar
115 if (in_array(self::CALENDAR_CONFIGURATION, $services)) {
117 if ($settings->isEnabled()) {
118 $active = new ilCheckboxInputGUI(
119 $lng->txt('obj_tool_setting_calendar_active'),
120 self::CALENDAR_ACTIVATION
121 );
122 $active->setValue("1");
124 $active->setInfo($lng->txt('obj_tool_setting_calendar_active_info'));
125
126 $visible = new ilCheckboxInputGUI(
127 $lng->txt('obj_tool_setting_calendar'),
128 self::CALENDAR_VISIBILITY
129 );
130 $visible->setValue("1");
132 $visible->setInfo($lng->txt('obj_tool_setting_calendar_info'));
133 $active->addSubItem($visible);
134
135 $form->addItem($active);
136 }
137 }
138
139 // news
140 if (in_array(self::USE_NEWS, $services)) {
141 $news = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_use_news'), self::USE_NEWS);
142 $news->setValue("1");
143 $checked = (bool) ilContainer::_lookupContainerSetting(
144 $obj_id,
145 self::USE_NEWS
146 );
147 $news->setChecked($checked);
148 $info = $lng->txt('obj_tool_setting_use_news_info');
149 if ($checked) {
150 $info .= " <a href='" . $ilCtrl->getLinkTargetByClass("ilcontainernewssettingsgui", "") .
151 "'>ยป " . $lng->txt('obj_tool_setting_use_news_open_settings') . "</a>";
152 }
153 $news->setInfo($info);
154 $form->addItem($news);
155 }
156 if (in_array(self::NEWS_VISIBILITY, $services)) {
157 if ($ilSetting->get('block_activated_news')) {
158 // Container tools (calendar, news, ... activation)
159 $news = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_news'), self::NEWS_VISIBILITY);
160 $news->setValue("1");
161 $news->setChecked((bool) ilContainer::_lookupContainerSetting(
162 $obj_id,
163 self::NEWS_VISIBILITY,
164 $ilSetting->get('block_activated_news')
165 ));
166 //$news->setOptionTitle($lng->txt('obj_tool_setting_news'));
167 $news->setInfo($lng->txt('obj_tool_setting_news_info'));
168 $form->addItem($news);
169
170 if (in_array(ilObject::_lookupType($obj_id), array('crs', 'grp'))) {
172 $ref_id = array_pop($refs);
173
175 }
176 }
177 }
178
179 // (local) custom metadata
180 if (in_array(self::CUSTOM_METADATA, $services)) {
181 $md = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_custom_metadata'), self::CUSTOM_METADATA);
182 $md->setInfo($lng->txt('obj_tool_setting_custom_metadata_info'));
183 $md->setValue("1");
184 $md->setChecked((bool) ilContainer::_lookupContainerSetting(
185 $obj_id,
186 self::CUSTOM_METADATA
187 ));
188 $form->addItem($md);
189 }
190
191 // tag cloud
192 if (in_array(self::TAG_CLOUD, $services)) {
193 $tags_active = new ilSetting("tags");
194 if ($tags_active->get("enable")) {
195 $tag = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_tag_cloud'), self::TAG_CLOUD);
196 $tag->setInfo($lng->txt('obj_tool_setting_tag_cloud_info'));
197 $tag->setValue("1");
198 $tag->setChecked((bool) ilContainer::_lookupContainerSetting(
199 $obj_id,
200 self::TAG_CLOUD
201 ));
202 $form->addItem($tag);
203 }
204 }
205
206 // taxonomies
207 if (in_array(self::TAXONOMIES, $services)) {
208 $tax = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_taxonomies'), self::TAXONOMIES);
209 $tax->setInfo($lng->txt('obj_tool_setting_taxonomies_info'));
210 $tax->setValue("1");
211 $tax->setChecked((bool) ilContainer::_lookupContainerSetting(
212 $obj_id,
213 self::TAXONOMIES
214 ));
215 $form->addItem($tax);
216 }
217
218 // auto rating
219 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
220 $lng->loadLanguageModule("rating");
221
222 // auto rating for new objects
223 $rate = new ilCheckboxInputGUI($lng->txt('rating_new_objects_auto'), self::AUTO_RATING_NEW_OBJECTS);
224 $rate->setValue("1");
225 //$rate->setOptionTitle($lng->txt('rating_new_objects_auto'));
226 $rate->setInfo($lng->txt('rating_new_objects_auto_info'));
227 $rate->setChecked((bool) ilContainer::_lookupContainerSetting(
228 $obj_id,
229 self::AUTO_RATING_NEW_OBJECTS
230 ));
231 $form->addItem($rate);
232 }
233
234 // badges
235 if (in_array(self::BADGES, $services)) {
236 if (ilBadgeHandler::getInstance()->isActive()) {
237 $bdg = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_badges'), self::BADGES);
238 $bdg->setInfo($lng->txt('obj_tool_setting_badges_info'));
239 $bdg->setValue("1");
240 $bdg->setChecked((bool) ilContainer::_lookupContainerSetting(
241 $obj_id,
242 self::BADGES
243 ));
244 $form->addItem($bdg);
245 }
246 }
247 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
248 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
250 );
251 if (
252 $position_settings->isActive()
253 ) {
254 $lia = new ilCheckboxInputGUI(
255 $GLOBALS['DIC']->language()->txt('obj_orgunit_positions'),
256 self::ORGU_POSITION_ACCESS
257 );
258 $lia->setInfo($GLOBALS['DIC']->language()->txt('obj_orgunit_positions_info'));
259 $lia->setValue("1");
260 $lia->setChecked(
261 ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($obj_id)
262 );
263 if (!$position_settings->isChangeableForObject()) {
264 $lia->setDisabled(true);
265 }
266 $form->addItem($lia);
267 }
268 }
269
270 // skills
271 if (in_array(self::SKILLS, $services)) {
272 $skmg_set = new ilSetting("skmg");
273 if ($skmg_set->get("enable_skmg")) {
274 $skill = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_skills'), self::SKILLS);
275 $skill->setInfo($lng->txt('obj_tool_setting_skills_info'));
276 $skill->setValue("1");
277 $skill->setChecked((bool) ilContainer::_lookupContainerSetting(
278 $obj_id,
279 self::SKILLS
280 ));
281 $form->addItem($skill);
282 }
283 }
284
285 // filter
286 if (in_array(self::FILTER, $services)) {
287 $filter = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_filter'), self::FILTER);
288 $filter->setInfo($lng->txt('obj_tool_setting_filter_info'));
289 $filter->setValue("1");
290 $filter->setChecked((bool) ilContainer::_lookupContainerSetting(
291 $obj_id,
292 self::FILTER
293 ));
294 $form->addItem($filter);
295
296 $filter_show_empty = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_filter_empty'), "filter_show_empty");
297 $filter_show_empty->setInfo($lng->txt('obj_tool_setting_filter_empty_info'));
298 $filter_show_empty->setValue("1");
299 $filter_show_empty->setChecked((bool) ilContainer::_lookupContainerSetting(
300 $obj_id,
301 "filter_show_empty"
302 ));
303 $filter->addSubItem($filter_show_empty);
304 }
305 // booking tool
306 if (in_array(self::BOOKING, $services)) {
307 $book = new ilCheckboxInputGUI($lng->txt('obj_tool_booking'), self::BOOKING);
308 $book->setInfo($lng->txt('obj_tool_booking_info'));
309 $book->setValue("1");
310 $book->setChecked((bool) ilContainer::_lookupContainerSetting(
311 $obj_id,
312 self::BOOKING
313 ));
314 $form->addItem($book);
315 }
316
317 if (in_array(self::EXTERNAL_MAIL_PREFIX, $services)) {
318 $externalMailPrefix = new ilTextInputGUI($lng->txt('obj_tool_ext_mail_subject_prefix'), self::EXTERNAL_MAIL_PREFIX);
319 $externalMailPrefix->setMaxLength(255);
320 $externalMailPrefix->setInfo($lng->txt('obj_tool_ext_mail_subject_prefix_info'));
321 $externalMailPrefix->setValue(ilContainer::_lookupContainerSetting($obj_id, self::EXTERNAL_MAIL_PREFIX, ''));
322 $form->addItem($externalMailPrefix);
323 }
324
325 return $form;
326 }
327
331 public static function updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services): bool
332 {
333 // info
334 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
336 $obj_id,
337 self::INFO_TAB_VISIBILITY,
338 $form->getInput(self::INFO_TAB_VISIBILITY)
339 );
340 }
341
342 // calendar
343 if (in_array(self::CALENDAR_CONFIGURATION, $services)) {
344 if (ilCalendarSettings::_getInstance()->isEnabled()) {
345 $active = $form->getInput(self::CALENDAR_ACTIVATION);
346 $visible = $form->getInput(self::CALENDAR_VISIBILITY);
348 $obj_id,
349 self::CALENDAR_ACTIVATION,
350 $active
351 );
353 $obj_id,
354 self::CALENDAR_VISIBILITY,
355 $active ? $visible : ""
356 );
357 }
358 }
359 // news
360 if (in_array(self::USE_NEWS, $services)) {
361 ilContainer::_writeContainerSetting($obj_id, self::USE_NEWS, $form->getInput(self::USE_NEWS));
362 }
363 if (in_array(self::NEWS_VISIBILITY, $services)) {
364 ilContainer::_writeContainerSetting($obj_id, self::NEWS_VISIBILITY, $form->getInput(self::NEWS_VISIBILITY));
365
366 if (in_array(ilObject::_lookupType($obj_id), array('crs', 'grp'))) {
367 $refs = ilObject::_getAllReferences($obj_id);
368 $ref_id = array_pop($refs);
369
371 }
372 }
373
374 // rating
375 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
377 $obj_id,
378 self::AUTO_RATING_NEW_OBJECTS,
379 $form->getInput(self::AUTO_RATING_NEW_OBJECTS)
380 );
381 }
382
383 // taxonomies
384 if (in_array(self::TAXONOMIES, $services)) {
385 ilContainer::_writeContainerSetting($obj_id, self::TAXONOMIES, $form->getInput(self::TAXONOMIES));
386 }
387
388 // tag cloud
389 if (in_array(self::TAG_CLOUD, $services)) {
390 ilContainer::_writeContainerSetting($obj_id, self::TAG_CLOUD, $form->getInput(self::TAG_CLOUD));
391 }
392
393 // (local) custom metadata
394 if (in_array(self::CUSTOM_METADATA, $services)) {
395 ilContainer::_writeContainerSetting($obj_id, self::CUSTOM_METADATA, $form->getInput(self::CUSTOM_METADATA));
396 }
397
398 // badges
399 if (in_array(self::BADGES, $services)) {
400 if (ilBadgeHandler::getInstance()->isActive()) {
401 ilContainer::_writeContainerSetting($obj_id, self::BADGES, $form->getInput(self::BADGES));
402 }
403 }
404
405 // booking
406 if (in_array(self::BOOKING, $services)) {
407 ilContainer::_writeContainerSetting($obj_id, self::BOOKING, $form->getInput(self::BOOKING));
408 }
409
410 // extended user access
411 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
412 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
413 ilObject::_lookupType($obj_id)
414 );
415
416 if ($position_settings->isActive() && $position_settings->isChangeableForObject()) {
417 $orgu_object_settings = new ilOrgUnitObjectPositionSetting($obj_id);
418 $orgu_object_settings->setActive(
419 (bool) $form->getInput(self::ORGU_POSITION_ACCESS)
420 );
421 $orgu_object_settings->update();
422 }
423 }
424
425 // skills
426 if (in_array(self::SKILLS, $services)) {
427 $skmg_set = new ilSetting("skmg");
428 if ($skmg_set->get("enable_skmg")) {
429 ilContainer::_writeContainerSetting($obj_id, self::SKILLS, $form->getInput(self::SKILLS));
430 }
431 }
432
433 // filter
434 if (in_array(self::FILTER, $services)) {
435 ilContainer::_writeContainerSetting($obj_id, self::FILTER, $form->getInput(self::FILTER));
436 ilContainer::_writeContainerSetting($obj_id, "filter_show_empty", $form->getInput("filter_show_empty"));
437 }
438
439 if (in_array(self::EXTERNAL_MAIL_PREFIX, $services)) {
440 ilContainer::_writeContainerSetting($obj_id, self::EXTERNAL_MAIL_PREFIX, $form->getInput(self::EXTERNAL_MAIL_PREFIX));
441 }
442
443 return true;
444 }
445
446
451 public function getModes(): array
452 {
453 return $this->modes;
454 }
455
459 public function getObjId(): int
460 {
461 return $this->obj_id;
462 }
463
464 protected function cancel(): void
465 {
466 $this->ctrl->returnToParent($this);
467 }
468
473 protected function editSettings(ilPropertyFormGUI $form = null): void
474 {
475 if (!$form instanceof ilPropertyFormGUI) {
476 // TODO: cant find initSettingsForm, is editSettings ever called?
477 $form = $this->initSettingsForm();
478 }
479 $this->main_tpl->setContent($form->getHTML());
480 }
481
482
486 protected function updateToolSettings(): void
487 {
488 // TODO: cant find initSettingsForm, is updateToolSettings ever called?
489 $form = $this->initSettingsForm();
490 if ($form->checkInput()) {
491 if (ilCalendarSettings::_getInstance()->isEnabled()) {
492 if ($this->isModeActive(self::CALENDAR_VISIBILITY)) {
493 ilContainer::_writeContainerSetting($this->getObjId(), 'show_calendar', $form->getInput('calendar'));
494 }
495 }
496 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
497 $this->ctrl->redirect($this);
498 }
499
500 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
501 $form->setValuesByPost();
502 $this->editSettings($form);
503 }
504
508 protected function isModeActive(string $mode): bool
509 {
510 return in_array($mode, $this->getModes(), true);
511 }
512}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static lookupCalendarContentPresentationEnabled(int $obj_id)
static lookupCalendarActivated(int $a_obj_id)
This class represents a checkbox property in a property form.
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
Class ilCtrl provides processing control methods.
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static importFromForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null)
static addToSettingsForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null, ?ilFormPropertyGUI $a_input=null)
Add notification settings to form.
Class ilObjectGUI Basic methods of all Output classes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
isModeActive(string $mode)
Check if specific mode is active.
__construct(ilObjectGUI $parent_gui, int $obj_id, array $modes)
Constructor.
editSettings(ilPropertyFormGUI $form=null)
Edit tool settings (calendar, news, comments, ...)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $ilSetting
Definition: privfeed.php:17