ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $lng->txt("note_enable_comments_del_user_info")
144 )
145 ->withValue((bool) $setting->get("comments_del_user", '0'));
146 $subfields["comm_del_tutor"] = $f->input()->field()->checkbox(
147 $lng->txt("note_enable_comments_del_tutor"),
148 $lng->txt("note_enable_comments_del_tutor_info")
149 )
150 ->withValue((bool) $setting->get("comments_del_tutor", '1'));
151 $subfields["comments_noti_recip"] = $f->input()->field()->text(
152 $lng->txt("note_comments_notification"),
153 $lng->txt("note_comments_notification_info")
154 )
155 ->withValue((string) $setting->get("comments_noti_recip"));
156
158 $subfields["enable_comments_export"] = $f->input()->field()->checkbox(
159 $lng->txt("enable_comments_export"),
160 $lng->txt("note_enable_comments_export_info")
161 )
162 ->withValue($privacy->enabledCommentsExport());
163
164
165 $fields["enable_comments"] = $f->input()->field()->optionalGroup(
166 $subfields,
167 $lng->txt("note_enable_comments"),
168 $lng->txt("")
169 );
170 if ($setting->get("disable_comments")) {
171 $fields["enable_comments"] = $fields["enable_comments"]->withValue(null);
172 }
173
174 // section
175 $section1 = $f->input()->field()->section($fields, $lng->txt("settings"));
176
177 $form_action = $ctrl->getLinkTarget($this, "saveSettings");
178 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
179 }
180
181 public function saveSettings(): void
182 {
184 $form = $this->initForm();
187 $setting = $this->setting;
188
189 if ($request->getMethod() === "POST") {
190 $form = $form->withRequest($request);
191 $data = $form->getData();
192 if (isset($data["sec"])) {
193 $data = $data["sec"]["enable_comments"];
194 $disable_comments = (bool) (is_array($data) ? 0 : 1);
195 $setting->set("disable_comments", (is_array($data) ? 0 : 1));
196 if (!$disable_comments) {
197 $setting->set("comments_del_user", ($data["comm_del_user"] ? 1 : 0));
198 $setting->set("comments_del_tutor", ($data["comm_del_tutor"] ? 1 : 0));
199 $setting->set("comments_noti_recip", $data["comments_noti_recip"]);
200
202 $privacy->enableCommentsExport((bool) $data['enable_comments_export']);
203 $privacy->save();
204 }
205 $this->main_tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
206 }
207 }
208 $ctrl->redirect($this, "editSettings");
209 }
210
211 public function addToExternalSettingsForm(int $a_form_id): ?array
212 {
213 switch ($a_form_id) {
215
217
218 $fields = array('enable_comments_export' => array($privacy->enabledCommentsExport(), ilAdministrationSettingsFormHandler::VALUE_BOOL));
219
220 return array(array("editSettings", $fields));
221 }
222 return null;
223 }
224}
getLinkTarget(object $a_gui_obj, ?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
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@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
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 ...
ILIAS Setting Class.
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)
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26