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