ILIAS  release_8 Revision v8.24
class.ilObjCommentsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
26{
31 protected ilTabsGUI $tabs;
32 protected \ILIAS\DI\UIServices $ui;
35
36 public function __construct(
37 $a_data,
38 int $a_id,
39 bool $a_call_by_reference = true,
40 bool $a_prepare_output = true
41 ) {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 $this->rbacsystem = $DIC->rbac()->system();
46 $this->ctrl = $DIC->ctrl();
47 $this->request = $DIC->http()->request();
48 $this->tabs = $DIC->tabs();
49 $this->ui = $DIC->ui();
50 $this->setting = $DIC->settings();
51 $this->main_tpl = $DIC->ui()->mainTemplate();
52
53 $this->type = 'coms';
54
55 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
56
57 $this->lng->loadLanguageModule("note");
58 }
59
64 public function executeCommand(): void
65 {
69
70 $next_class = $ctrl->getNextClass($this);
71 $cmd = $ctrl->getCmd("editSettings");
72
73 if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
74 throw new ilPermissionException($this->lng->txt('no_permission'));
75 }
76
77 $this->prepareOutput();
78
79 switch ($next_class) {
80 case 'ilpermissiongui':
81 $tabs->activateTab('perm_settings');
82 $perm_gui = new ilPermissionGUI($this);
83 $ctrl->forwardCommand($perm_gui);
84 break;
85
86 default:
87 if ($cmd === "view") {
88 $cmd = "editSettings";
89 }
90 if (in_array($cmd, ["editSettings", "saveSettings"])) {
91 $this->$cmd();
92 }
93 break;
94 }
95 }
96
97 public function getAdminTabs(): void
98 {
103
104 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
105 $tabs->addTab(
106 "settings",
107 $lng->txt("settings"),
108 $ctrl->getLinkTarget($this, "editSettings")
109 );
110 }
111
112 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
113 $tabs->addTab(
114 "perm_settings",
115 $lng->txt("perm_settings"),
116 $ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
117 );
118 }
119 }
120
121 public function editSettings(): void
122 {
124 $ui = $this->ui;
126
127 $tabs->activateTab("settings");
128
129 $form = $this->initForm();
130 $main_tpl->setContent($ui->renderer()->render($form));
131 }
132
133 public function initForm(): \ILIAS\UI\Component\Input\Container\Form\Standard
134 {
135 $ui = $this->ui;
136 $f = $ui->factory();
140
141 $subfields["comm_del_user"] = $f->input()->field()->checkbox(
142 $lng->txt("note_enable_comments_del_user")
143 )
144 ->withValue((bool) $setting->get("comments_del_user", '0'));
145 $subfields["comm_del_tutor"] = $f->input()->field()->checkbox(
146 $lng->txt("note_enable_comments_del_tutor"),
147 $lng->txt("note_enable_comments_del_tutor_info")
148 )
149 ->withValue((bool) $setting->get("comments_del_tutor", '1'));
150 $subfields["comments_noti_recip"] = $f->input()->field()->text(
151 $lng->txt("note_comments_notification"),
152 $lng->txt("note_comments_notification_info")
153 )
154 ->withValue((string) $setting->get("comments_noti_recip"));
155
157 $subfields["enable_comments_export"] = $f->input()->field()->checkbox(
158 $lng->txt("enable_comments_export"),
159 $lng->txt("note_enable_comments_export_info")
160 )
161 ->withValue($privacy->enabledCommentsExport());
162
163
164 $fields["enable_comments"] = $f->input()->field()->optionalGroup(
165 $subfields,
166 $lng->txt("note_enable_comments"),
167 $lng->txt("")
168 );
169 if ($setting->get("disable_comments")) {
170 $fields["enable_comments"] = $fields["enable_comments"]->withValue(null);
171 }
172
173 // section
174 $section1 = $f->input()->field()->section($fields, $lng->txt("settings"));
175
176 $form_action = $ctrl->getLinkTarget($this, "saveSettings");
177 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
178 }
179
180 public function saveSettings(): void
181 {
183 $form = $this->initForm();
186 $setting = $this->setting;
187
188 if ($request->getMethod() === "POST") {
189 $form = $form->withRequest($request);
190 $data = $form->getData();
191 if (isset($data["sec"])) {
192 $data = $data["sec"]["enable_comments"];
193 $disable_comments = (bool) (is_array($data) ? 0 : 1);
194 $setting->set("disable_comments", (is_array($data) ? 0 : 1));
195 if (!$disable_comments) {
196 $setting->set("comments_del_user", ($data["comm_del_user"] ? 1 : 0));
197 $setting->set("comments_del_tutor", ($data["comm_del_tutor"] ? 1 : 0));
198 $setting->set("comments_noti_recip", $data["comments_noti_recip"]);
199
201 $privacy->enableCommentsExport((bool) $data['enable_comments_export']);
202 $privacy->save();
203 }
204 $this->main_tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
205 }
206 }
207 $ctrl->redirect($this, "editSettings");
208 }
209
210 public function addToExternalSettingsForm(int $a_form_id): ?array
211 {
212 switch ($a_form_id) {
214
216
217 $fields = array('enable_comments_export' => array($privacy->enabledCommentsExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
218
219 return array(array("editSettings", $fields));
220 }
221 return null;
222 }
223}
getLinkTargetByClass( $a_class, string $a_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
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
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...
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
ServerRequestInterface $request
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
set(string $a_key, string $a_val)
get(string $a_keyword, ?string $a_default_value=null)
get setting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
activateTab(string $a_id)
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.