ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjAwarenessAdministrationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3include_once("./Services/Object/classes/class.ilObjectGUI.php");
4
17{
21 protected $rbacsystem;
22
28 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
29 {
30 global $DIC;
31
32 $this->rbacsystem = $DIC->rbac()->system();
33 $this->ctrl = $DIC->ctrl();
34 $this->lng = $DIC->language();
35 $this->type = "awra";
36 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
37
38 $this->lng->loadLanguageModule("awrn");
39 $this->lng->loadLanguageModule("pd");
40 $this->lng->loadLanguageModule("usr");
41 }
42
49 public function executeCommand()
50 {
51 $next_class = $this->ctrl->getNextClass($this);
52 $cmd = $this->ctrl->getCmd();
53
54 $this->prepareOutput();
55
56 switch ($next_class) {
57 case 'iluseractionadmingui':
58 include_once("./Services/User/Actions/classes/class.ilUserActionAdminGUI.php");
59 include_once("./Services/Awareness/classes/class.ilAwarenessUserActionContext.php");
60 $gui = new ilUserActionAdminGUI();
61 $gui->setActionContext(new ilAwarenessUserActionContext());
62 $this->tabs_gui->setTabActive('settings');
63 $this->setSubTabs("actions");
64 $this->ctrl->forwardCommand($gui);
65 break;
66
67 case 'ilpermissiongui':
68 $this->tabs_gui->setTabActive('perm_settings');
69 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
70 $perm_gui = new ilPermissionGUI($this);
71 $this->ctrl->forwardCommand($perm_gui);
72 break;
73
74 default:
75 if (!$cmd || $cmd == 'view') {
76 $cmd = "editSettings";
77 }
78
79 $this->$cmd();
80 break;
81 }
82 return true;
83 }
84
88 public function getAdminTabs()
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
115 public function setSubTabs($a_id)
116 {
117 $this->tabs_gui->addSubTab(
118 "settings",
119 $this->lng->txt("settings"),
120 $this->ctrl->getLinkTarget($this, "editSettings")
121 );
122
123 $this->tabs_gui->addSubTab(
124 "actions",
125 $this->lng->txt("user_actions"),
126 $this->ctrl->getLinkTargetByClass("iluseractionadmingui")
127 );
128
129 $this->tabs_gui->activateSubTab($a_id);
130 }
131
132
136 public function editSettings($a_form = null)
137 {
138 $this->tabs_gui->setTabActive('settings');
139 $this->setSubTabs("settings");
140
141 if (!$a_form) {
142 $a_form = $this->initFormSettings();
143 }
144 $this->tpl->setContent($a_form->getHTML());
145 return true;
146 }
147
151 public function saveSettings()
152 {
153 $ilCtrl = $this->ctrl;
154
155 $this->checkPermission("write");
156
157 $form = $this->initFormSettings();
158 if ($form->checkInput()) {
159 $awrn_set = new ilSetting("awrn");
160 $awrn_set->set("awrn_enabled", (bool) $form->getInput("enable_awareness"));
161
162 $p = (int) $form->getInput("caching_period");
163 if ($p < 0) {
164 $p = 0;
165 }
166 $awrn_set->set("caching_period", $p);
167
168 $awrn_set->set("max_nr_entries", (int) $form->getInput("max_nr_entries"));
169 $awrn_set->set("use_osd", (int) $form->getInput("use_osd"));
170
171 $pd_set = new ilSetting("pd");
172 $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
173
174 include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
176 foreach ($prov as $p) {
177 $p->setActivationMode($form->getInput("up_act_mode_" . $p->getProviderId()));
178 }
179
180 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
181 $ilCtrl->redirect($this, "editSettings");
182 }
183
184 $form->setValuesByPost();
185 $this->editSettings($form);
186 }
187
191 public function cancel()
192 {
193 $ilCtrl = $this->ctrl;
194
195 $ilCtrl->redirect($this, "view");
196 }
197
203 protected function initFormSettings()
204 {
206
207 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
208 $form = new ilPropertyFormGUI();
209 $form->setFormAction($this->ctrl->getFormAction($this));
210 $form->setTitle($this->lng->txt('awareness_settings'));
211
212 if ($this->checkPermissionBool("write")) {
213 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
214 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
215 }
216
217 $en = new ilCheckboxInputGUI($lng->txt("awrn_enable"), "enable_awareness");
218 $form->addItem($en);
219
220 $awrn_set = new ilSetting("awrn");
221 $en->setChecked($awrn_set->get("awrn_enabled", false));
222
223 // caching period
224 $ti = new ilNumberInputGUI($this->lng->txt("awrn_caching_period"), "caching_period");
225 $ti->setInfo($this->lng->txt("awrn_caching_period_info"));
226 $ti->setSuffix($this->lng->txt("awrn_seconds"));
227 $ti->setSize(6);
228 $ti->setMaxLength(6);
229 $ti->setValue($awrn_set->get("caching_period"));
230 $en->addSubItem($ti);
231
232 // limit number of entries
233 $ti = new ilNumberInputGUI($this->lng->txt("awrn_max_nr_entries"), "max_nr_entries");
234 $ti->setInfo($this->lng->txt("awrn_max_nr_entries_info"));
235 $ti->setSize(3);
236 $ti->setMaxLength(3);
237 $ti->setMinValue(5);
238 $ti->setMaxValue(200);
239 $ti->setValue($awrn_set->get("max_nr_entries"));
240 $en->addSubItem($ti);
241
242 // maximum inactivity time
243 $pd_set = new ilSetting("pd"); // under pd settings due to historical reasons
244 $ti_prop = new ilNumberInputGUI(
245 $lng->txt("awrn_max_inactivity"),
246 "time_removal"
247 );
248 $ti_prop->setSuffix($this->lng->txt("awrn_minutes"));
249 if ($pd_set->get("user_activity_time") > 0) {
250 $ti_prop->setValue($pd_set->get("user_activity_time"));
251 }
252 $ti_prop->setInfo($lng->txt("awrn_max_inactivity_info"));
253 $ti_prop->setMaxLength(3);
254 $ti_prop->setSize(3);
255 $en->addSubItem($ti_prop);
256
257 // activate osd
258 $osd = new ilCheckboxInputGUI($this->lng->txt("awrn_use_osd"), "use_osd");
259 $osd->setInfo($this->lng->txt("awrn_use_osd_info"));
260 $osd->setChecked($awrn_set->get("use_osd", true));
261 $en->addSubItem($osd);
262
263
264 include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
266 foreach ($prov as $p) {
267 // activation mode
268 $options = array(
269 ilAwarenessUserProvider::MODE_INACTIVE => $lng->txt("awrn_inactive"),
270 ilAwarenessUserProvider::MODE_ONLINE_ONLY => $lng->txt("awrn_online_only"),
271 ilAwarenessUserProvider::MODE_INCL_OFFLINE => $lng->txt("awrn_incl_offline")
272 );
273 $si = new ilSelectInputGUI($p->getTitle(), "up_act_mode_" . $p->getProviderId());
274 $si->setOptions($options);
275 $si->setInfo($p->getInfo());
276 $si->setValue($p->getActivationMode());
277 $en->addSubItem($si);
278 }
279
280 return $form;
281 }
282}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Awareness context for user actions.
static getAllProviders()
Get all awareness providers.
This class represents a checkbox property in a property form.
This class represents a number property in a property form.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
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.
ILIAS Setting Class.
User action administration GUI class.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc