ILIAS  release_8 Revision v8.24
class.ilObjNotificationSettingsGUI.php
Go to the documentation of this file.
1<?php
2
22{
24 protected int $ref_id;
25 protected ilLanguage $lng;
26 protected ilCtrl $ctrl;
28 protected int $obj_id;
29
30 public function __construct(int $a_ref_id)
31 {
32 global $DIC;
33
34 $this->ctrl = $DIC->ctrl();
35 $this->lng = $DIC->language();
36 $this->tpl = $DIC["tpl"];
37 $this->ref_id = $a_ref_id;
38 $this->obj_id = ilObject::_lookupObjId($a_ref_id);
39 $this->settings = new ilObjNotificationSettings($this->obj_id);
40 }
41
42 public function executeCommand(): void
43 {
45
46 $next_class = $ctrl->getNextClass($this);
47 $cmd = $ctrl->getCmd("show");
48
49 switch ($next_class) {
50 default:
51 if (in_array($cmd, array("show", "save"))) {
52 $this->$cmd();
53 }
54 }
55 }
56
57 protected function show(): void
58 {
60
61 $form = $this->initForm();
62 $tpl->setContent($form->getHTML());
63 }
64
65 protected function initForm(): ilPropertyFormGUI
66 {
69
70 $form = new ilPropertyFormGUI();
71
72 $form->setFormAction($ctrl->getFormAction($this, 'save'));
73 $form->setTitle($lng->txt('obj_notification_settings'));
74
75 $radio_grp = new ilRadioGroupInputGUI($lng->txt("obj_activation"), 'notification_type');
76 $radio_grp->setValue('0');
77
78 $opt_default = new ilRadioOption($lng->txt("obj_user_decides_notification"), '0');
79 $opt_0 = new ilRadioOption($lng->txt("obj_settings_for_all_members"), '1');
80
81 $radio_grp->addOption($opt_default);
82 $radio_grp->addOption($opt_0);
83
84 $chb_2 = new ilCheckboxInputGUI($lng->txt('obj_user_not_disable_not'), 'no_opt_out');
85 $chb_2->setValue(1);
86
87 $opt_0->addSubItem($chb_2);
88 $form->addItem($radio_grp);
89
91 $radio_grp->setValue('1');
92 }
94 $radio_grp->setValue('1');
95 $chb_2->setChecked(true);
96 }
97
98 $form->addCommandButton("save", $lng->txt("save"));
99
100 $form->setTitle($this->lng->txt("notifications"));
101
102 return $form;
103 }
104
105 protected function save(): void
106 {
108
109 $form = $this->initForm();
110 if ($form->checkInput()) {
112 if ($form->getInput('notification_type') === "1") {
113 if ((int) $form->getInput('no_opt_out')) {
115 } else {
117 }
118 }
119 $this->settings->save();
120 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
121 $ctrl->redirect($this, "show");
122 }
123
124 $form->setValuesByPost();
125 $this->show();
126 }
127}
This class represents a checkbox property in a property form.
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
getCmd(string $fallback_command=null)
@inheritDoc
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
language handling
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...
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 _lookupObjId(int $ref_id)
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.