ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjCommentsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
18 protected $rbacsystem;
19
23 protected $error;
24
28 protected $request;
29
33 protected $tabs;
34
38 protected $ui;
39
40
44 protected $setting;
45
49 protected $main_tpl;
50
51
57 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
58 {
59 global $DIC;
60
61 $this->lng = $DIC->language();
62 $this->rbacsystem = $DIC->rbac()->system();
63 $this->error = $DIC["ilErr"];
64 $this->ctrl = $DIC->ctrl();
65 $this->request = $DIC->http()->request();
66 $this->tabs = $DIC->tabs();
67 $this->ui = $DIC->ui();
68 $this->setting = $DIC->settings();
69 $this->main_tpl = $DIC->ui()->mainTemplate();
70
71 $this->type = 'coms';
72
73 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
74
75 $this->lng->loadLanguageModule("note");
76 }
77
82 public function executeCommand()
83 {
87
88 $next_class = $ctrl->getNextClass($this);
89 $cmd = $ctrl->getCmd("editSettings");
90
91 if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
92 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
93 }
94
95 $this->prepareOutput();
96
97 switch ($next_class) {
98 case 'ilpermissiongui':
99 $tabs->activateTab('perm_settings');
100 $perm_gui = new ilPermissionGUI($this);
101 $ctrl->forwardCommand($perm_gui);
102 break;
103
104 default:
105 if ($cmd == "view") {
106 $cmd = "editSettings";
107 }
108 if (in_array($cmd, ["editSettings", "saveSettings"])) {
109 $this->$cmd();
110 }
111 break;
112 }
113 }
114
118 public function getAdminTabs()
119 {
124
125 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
126 $tabs->addTab(
127 "settings",
128 $lng->txt("settings"),
129 $ctrl->getLinkTarget($this, "editSettings")
130 );
131 }
132
133 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
134 $tabs->addTab(
135 "perm_settings",
136 $lng->txt("perm_settings"),
137 $ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
138 );
139 }
140 }
141
145 public function editSettings()
146 {
148 $ui = $this->ui;
150
151 $tabs->activateTab("settings");
152
153 $form = $this->initForm();
154 $main_tpl->setContent($ui->renderer()->render($form));
155 }
156
161 public function initForm()
162 {
163 $ui = $this->ui;
164 $f = $ui->factory();
168
169 $subfields["comm_del_user"] = $f->input()->field()->checkbox(
170 $lng->txt("note_enable_comments_del_user")
171 )
172 ->withValue((bool) $setting->get("comments_del_user", 0));
173 $subfields["comm_del_tutor"] = $f->input()->field()->checkbox(
174 $lng->txt("note_enable_comments_del_tutor"),
175 $lng->txt("note_enable_comments_del_tutor_info")
176 )
177 ->withValue((bool) $setting->get("comments_del_tutor", 1));
178 $subfields["comments_noti_recip"] = $f->input()->field()->text(
179 $lng->txt("note_comments_notification"),
180 $lng->txt("note_comments_notification_info")
181 )
182 ->withValue((string) $setting->get("comments_noti_recip"));
183
184 $fields["enable_comments"] = $f->input()->field()->optionalGroup(
185 $subfields,
186 $lng->txt("note_enable_comments"),
187 $lng->txt("")
188 );
189 if ($setting->get("disable_comments")) {
190 $fields["enable_comments"] = $fields["enable_comments"]->withValue(null);
191 }
192
193 // section
194 $section1 = $f->input()->field()->section($fields, $lng->txt("settings"));
195
196 $form_action = $ctrl->getLinkTarget($this, "saveSettings");
197 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
198 }
199
203 public function saveSettings()
204 {
206 $form = $this->initForm();
210
211 if ($request->getMethod() == "POST") {
212 $form = $form->withRequest($request);
213 $data = $form->getData();
214 if (is_array($data["sec"])) {
215 $data = $data["sec"]["enable_comments"];
216 $setting->set("disable_comments", (is_array($data) ? 0 : 1));
217 $setting->set("comments_del_user", ($data["comm_del_user"] ? 1 : 0));
218 $setting->set("comments_del_tutor", ($data["comm_del_tutor"] ? 1 : 0));
219 $setting->set("comments_noti_recip", $data["comments_noti_recip"]);
220
221 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
222 }
223 }
224 $ctrl->redirect($this, "editSettings");
225 }
226}
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46