ILIAS  release_8 Revision v8.24
class.ilObjAwarenessAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected \ILIAS\Awareness\AdminManager $admin_manager;
28
32 public function __construct(
33 $a_data,
34 int $a_id,
35 bool $a_call_by_reference = true,
36 bool $a_prepare_output = true
37 ) {
38 global $DIC;
39
40 $this->rbacsystem = $DIC->rbac()->system();
41 $this->ctrl = $DIC->ctrl();
42 $this->lng = $DIC->language();
43 $this->type = "awra";
44 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
45
46 $this->lng->loadLanguageModule("awrn");
47 $this->lng->loadLanguageModule("pd");
48 $this->lng->loadLanguageModule("usr");
49 $this->admin_manager = $DIC->awareness()
50 ->internal()
51 ->domain()
52 ->admin($this->requested_ref_id);
53 }
54
55 public function executeCommand(): void
56 {
57 $next_class = $this->ctrl->getNextClass($this);
58 $cmd = $this->ctrl->getCmd();
59
60 $this->prepareOutput();
61
62 switch ($next_class) {
63 case 'iluseractionadmingui':
64 $gui = new ilUserActionAdminGUI($this->requested_ref_id);
65 $gui->setActionContext(new ilAwarenessUserActionContext());
66 $this->tabs_gui->setTabActive('settings');
67 $this->setSubTabs("actions");
68 $this->ctrl->forwardCommand($gui);
69 break;
70
71 case 'ilpermissiongui':
72 $this->tabs_gui->setTabActive('perm_settings');
73 $perm_gui = new ilPermissionGUI($this);
74 $this->ctrl->forwardCommand($perm_gui);
75 break;
76
77 default:
78 if (!$cmd || $cmd == 'view') {
79 $cmd = "editSettings";
80 }
81
82 $this->$cmd();
83 break;
84 }
85 }
86
87 public function getAdminTabs(): void
88 {
89 $rbacsystem = $this->rbacsystem;
90
91 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
92 $this->tabs_gui->addTab(
93 "settings",
94 $this->lng->txt("settings"),
95 $this->ctrl->getLinkTarget($this, "editSettings")
96 );
97 }
98
99 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
100 $this->tabs_gui->addTab(
101 "perm_settings",
102 $this->lng->txt("perm_settings"),
103 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
104 );
105 }
106 }
107
108 public function setSubTabs(string $a_id): void
109 {
110 $this->tabs_gui->addSubTab(
111 "settings",
112 $this->lng->txt("settings"),
113 $this->ctrl->getLinkTarget($this, "editSettings")
114 );
115
116 $this->tabs_gui->addSubTab(
117 "actions",
118 $this->lng->txt("user_actions"),
119 $this->ctrl->getLinkTargetByClass("iluseractionadmingui")
120 );
121
122 $this->tabs_gui->activateSubTab($a_id);
123 }
124
125
129 public function editSettings(?ilPropertyFormGUI $a_form = null): bool
130 {
131 $this->tabs_gui->setTabActive('settings');
132 $this->setSubTabs("settings");
133
134 if (!$a_form) {
135 $a_form = $this->initFormSettings();
136 }
137 $this->tpl->setContent($a_form->getHTML());
138 return true;
139 }
140
144 public function saveSettings(): void
145 {
146 $ilCtrl = $this->ctrl;
147
148 $this->checkPermission("write");
149
150 $form = $this->initFormSettings();
151 if ($form->checkInput()) {
152 $awrn_set = new ilSetting("awrn");
153 $awrn_set->set("awrn_enabled", (bool) $form->getInput("enable_awareness"));
154
155 $p = (int) $form->getInput("caching_period");
156 if ($p < 0) {
157 $p = 0;
158 }
159 $awrn_set->set("caching_period", $p);
160
161 $awrn_set->set("max_nr_entries", (int) $form->getInput("max_nr_entries"));
162 $awrn_set->set("use_osd", (int) $form->getInput("use_osd"));
163
164 $pd_set = new ilSetting("pd");
165 $pd_set->set("user_activity_time", (int) $form->getInput("time_removal"));
166
167 $prov = $this->admin_manager->getAllUserProviders();
168 foreach ($prov as $p) {
169 $this->admin_manager->setActivationMode(
170 $p->getProviderId(),
171 (int) $form->getInput("up_act_mode_" . $p->getProviderId())
172 );
173 }
174
175 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
176 $ilCtrl->redirect($this, "editSettings");
177 }
178
179 $form->setValuesByPost();
180 $this->editSettings($form);
181 }
182
186 public function cancel(): void
187 {
188 $ilCtrl = $this->ctrl;
189
190 $ilCtrl->redirect($this, "view");
191 }
192
194 {
196
197 $form = new ilPropertyFormGUI();
198 $form->setFormAction($this->ctrl->getFormAction($this));
199 $form->setTitle($this->lng->txt('awareness_settings'));
200
201 if ($this->checkPermissionBool("write")) {
202 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
203 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
204 }
205
206 $en = new ilCheckboxInputGUI($lng->txt("awrn_enable"), "enable_awareness");
207 $form->addItem($en);
208
209 $awrn_set = new ilSetting("awrn");
210 $en->setChecked($awrn_set->get("awrn_enabled", false));
211
212 // caching period
213 $ti = new ilNumberInputGUI($this->lng->txt("awrn_caching_period"), "caching_period");
214 $ti->setInfo($this->lng->txt("awrn_caching_period_info"));
215 $ti->setSuffix($this->lng->txt("awrn_seconds"));
216 $ti->setSize(6);
217 $ti->setMaxLength(6);
218 $ti->setValue($awrn_set->get("caching_period"));
219 $en->addSubItem($ti);
220
221 // limit number of entries
222 $ti = new ilNumberInputGUI($this->lng->txt("awrn_max_nr_entries"), "max_nr_entries");
223 $ti->setInfo($this->lng->txt("awrn_max_nr_entries_info"));
224 $ti->setSize(3);
225 $ti->setMaxLength(3);
226 $ti->setMinValue(5);
227 $ti->setMaxValue(200);
228 $ti->setValue($awrn_set->get("max_nr_entries"));
229 $en->addSubItem($ti);
230
231 // maximum inactivity time
232 $pd_set = new ilSetting("pd"); // under pd settings due to historical reasons
233 $ti_prop = new ilNumberInputGUI(
234 $lng->txt("awrn_max_inactivity"),
235 "time_removal"
236 );
237 $ti_prop->setSuffix($this->lng->txt("awrn_minutes"));
238 if ($pd_set->get("user_activity_time") > 0) {
239 $ti_prop->setValue($pd_set->get("user_activity_time"));
240 }
241 $ti_prop->setInfo($lng->txt("awrn_max_inactivity_info"));
242 $ti_prop->setMaxLength(3);
243 $ti_prop->setSize(3);
244 $en->addSubItem($ti_prop);
245
246 // activate osd
247 $osd = new ilCheckboxInputGUI($this->lng->txt("awrn_use_osd"), "use_osd");
248 $osd->setInfo($this->lng->txt("awrn_use_osd_info"));
249 $osd->setChecked($awrn_set->get("use_osd", true));
250 $en->addSubItem($osd);
251
252
253 $prov = $this->admin_manager->getAllUserProviders();
254 foreach ($prov as $p) {
255 // activation mode
256 $options = $this->admin_manager->getModeOptions();
257 $si = new ilSelectInputGUI($p->getTitle(), "up_act_mode_" . $p->getProviderId());
258 $si->setOptions($options);
259 $si->setInfo($p->getInfo());
260 $si->setValue($this->admin_manager->getActivationMode($p->getProviderId()));
261 $en->addSubItem($si);
262 }
263
264 return $form;
265 }
266}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=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 class represents a number property in a property form.
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
editSettings(?ilPropertyFormGUI $a_form=null)
Edit settings.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
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...
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc