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