ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjNotificationSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $lng;
18
22 protected $ctrl;
23
27 protected $tpl;
28
32 protected $obj_id;
33
37 public function __construct($a_ref_id)
38 {
39 global $DIC;
40
41 $this->ctrl = $DIC->ctrl();
42 $this->lng = $DIC->language();
43 $this->tpl = $DIC["tpl"];
44 $this->ref_id = $a_ref_id;
45 $this->obj_id = ilObject::_lookupObjId($a_ref_id);
46 include_once("./Services/Notification/classes/class.ilObjNotificationSettings.php");
47 $this->settings = new ilObjNotificationSettings($this->obj_id);
48 }
49
53 public function executeCommand()
54 {
56
57 $next_class = $ctrl->getNextClass($this);
58 $cmd = $ctrl->getCmd("show");
59
60 switch ($next_class) {
61 default:
62 if (in_array($cmd, array("show", "save"))) {
63 $this->$cmd();
64 }
65 }
66 }
67
71 protected function show()
72 {
74
75 $form = $this->initForm();
76 $tpl->setContent($form->getHTML());
77 }
78
79
84 protected function initForm()
85 {
88
89 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
91
92 $form->setFormAction($ctrl->getFormAction($this, 'save'));
93 $form->setTitle($lng->txt('obj_notification_settings'));
94
95 $radio_grp = new ilRadioGroupInputGUI($lng->txt("obj_activation"), 'notification_type');
96 $radio_grp->setValue('0');
97
98 $opt_default = new ilRadioOption($lng->txt("obj_user_decides_notification"), '0');
99 $opt_0 = new ilRadioOption($lng->txt("obj_settings_for_all_members"), '1');
100
101 $radio_grp->addOption($opt_default);
102 $radio_grp->addOption($opt_0);
103
104 $chb_2 = new ilCheckboxInputGUI($lng->txt('obj_user_not_disable_not'), 'no_opt_out');
105 $chb_2->setValue(1);
106
107 $opt_0->addSubItem($chb_2);
108 $form->addItem($radio_grp);
109
111 $radio_grp->setValue('1');
112 }
114 $radio_grp->setValue('1');
115 $chb_2->setChecked(true);
116 }
117
118 $form->addCommandButton("save", $lng->txt("save"));
119
120 $form->setTitle($this->lng->txt("notifications"));
121
122 return $form;
123 }
124
128 protected function save()
129 {
131
132 $form = $this->initForm();
133 if ($form->checkInput()) {
135 if ($_POST['notification_type'] == "1") {
136 if ((int) $form->getInput('no_opt_out')) {
138 } else {
140 }
141 }
142 $this->settings->save();
143 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
144 $ctrl->redirect($this, "show");
145 }
146
147 $form->setValuesByPost();
148 $this->show();
149 }
150}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
Handles general notification settings, see e.g.
Handles general object notification settings, see e.g.
static _lookupObjId($a_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.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2