ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 */
3 include_once("./Services/Object/classes/class.ilObjectGUI.php");
4 
17 {
23  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
24  {
25  $this->type = "awra";
26  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
27 
28  $this->lng->loadLanguageModule("awrn");
29  $this->lng->loadLanguageModule("pd");
30  $this->lng->loadLanguageModule("usr");
31  }
32 
39  public function executeCommand()
40  {
41  $next_class = $this->ctrl->getNextClass($this);
42  $cmd = $this->ctrl->getCmd();
43 
44  $this->prepareOutput();
45 
46  switch($next_class)
47  {
48  case 'iluseractionadmingui':
49  include_once("./Services/User/Actions/classes/class.ilUserActionAdminGUI.php");
50  $gui = new ilUserActionAdminGUI();
51  $this->tabs_gui->setTabActive('settings');
52  $this->setSubTabs("actions");
53  $this->ctrl->forwardCommand($gui);
54  break;
55 
56  case 'ilpermissiongui':
57  $this->tabs_gui->setTabActive('perm_settings');
58  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
59  $perm_gui = new ilPermissionGUI($this);
60  $this->ctrl->forwardCommand($perm_gui);
61  break;
62 
63  default:
64  if(!$cmd || $cmd == 'view')
65  {
66  $cmd = "editSettings";
67  }
68 
69  $this->$cmd();
70  break;
71  }
72  return true;
73  }
74 
78  public function getAdminTabs()
79  {
80  global $rbacsystem;
81 
82  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
83  {
84  $this->tabs_gui->addTab("settings",
85  $this->lng->txt("settings"),
86  $this->ctrl->getLinkTarget($this, "editSettings"));
87  }
88 
89  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
90  {
91  $this->tabs_gui->addTab("perm_settings",
92  $this->lng->txt("perm_settings"),
93  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"));
94  }
95  }
96 
103  function setSubTabs($a_id)
104  {
105  $this->tabs_gui->addSubTab("settings",
106  $this->lng->txt("settings"),
107  $this->ctrl->getLinkTarget($this, "editSettings"));
108 
109  $this->tabs_gui->addSubTab("actions",
110  $this->lng->txt("user_actions"),
111  $this->ctrl->getLinkTargetByClass("iluseractionadmingui"));
112 
113  $this->tabs_gui->activateSubTab($a_id);
114  }
115 
116 
120  public function editSettings($a_form = null)
121  {
122  $this->tabs_gui->setTabActive('settings');
123  $this->setSubTabs("settings");
124 
125  if(!$a_form)
126  {
127  $a_form = $this->initFormSettings();
128  }
129  $this->tpl->setContent($a_form->getHTML());
130  return true;
131  }
132 
136  public function saveSettings()
137  {
138  global $ilCtrl;
139 
140  $this->checkPermission("write");
141 
142  $form = $this->initFormSettings();
143  if($form->checkInput())
144  {
145  $awrn_set = new ilSetting("awrn");
146  $awrn_set->set("awrn_enabled", (bool) $form->getInput("enable_awareness"));
147 
148  $p = (int) $form->getInput("caching_period");
149  if ($p < 0)
150  {
151  $p = 0;
152  }
153  $awrn_set->set("caching_period", $p);
154 
155  $awrn_set->set("max_nr_entries", (int) $form->getInput("max_nr_entries"));
156  $awrn_set->set("use_osd", (int) $form->getInput("use_osd"));
157 
158  $pd_set = new ilSetting("pd");
159  $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
160 
161  include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
163  foreach ($prov as $p)
164  {
165  $p->setActivationMode($form->getInput("up_act_mode_".$p->getProviderId()));
166  }
167 
168  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
169  $ilCtrl->redirect($this, "editSettings");
170  }
171 
172  $form->setValuesByPost();
173  $this->editSettings($form);
174  }
175 
179  public function cancel()
180  {
181  global $ilCtrl;
182 
183  $ilCtrl->redirect($this, "view");
184  }
185 
191  protected function initFormSettings()
192  {
193  global $lng;
194 
195  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
196  $form = new ilPropertyFormGUI();
197  $form->setFormAction($this->ctrl->getFormAction($this));
198  $form->setTitle($this->lng->txt('awareness_settings'));
199  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
200  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
201 
202  $en = new ilCheckboxInputGUI($lng->txt("awrn_enable"), "enable_awareness");
203  $form->addItem($en);
204 
205  $awrn_set = new ilSetting("awrn");
206  $en->setChecked($awrn_set->get("awrn_enabled", false));
207 
208  // caching period
209  $ti = new ilNumberInputGUI($this->lng->txt("awrn_caching_period"), "caching_period");
210  $ti->setInfo($this->lng->txt("awrn_caching_period_info"));
211  $ti->setSuffix($this->lng->txt("awrn_seconds"));
212  $ti->setSize(6);
213  $ti->setMaxLength(6);
214  $ti->setValue($awrn_set->get("caching_period"));
215  $en->addSubItem($ti);
216 
217  // limit number of entries
218  $ti = new ilNumberInputGUI($this->lng->txt("awrn_max_nr_entries"), "max_nr_entries");
219  $ti->setInfo($this->lng->txt("awrn_max_nr_entries_info"));
220  $ti->setSize(3);
221  $ti->setMaxLength(3);
222  $ti->setMinValue(5);
223  $ti->setMaxValue(200);
224  $ti->setValue($awrn_set->get("max_nr_entries"));
225  $en->addSubItem($ti);
226 
227  // maximum inactivity time
228  $pd_set = new ilSetting("pd"); // under pd settings due to historical reasons
229  $ti_prop = new ilNumberInputGUI($lng->txt("awrn_max_inactivity"),
230  "time_removal");
231  $ti_prop->setSuffix($this->lng->txt("awrn_minutes"));
232  if ($pd_set->get("user_activity_time") > 0)
233  {
234  $ti_prop->setValue($pd_set->get("user_activity_time"));
235  }
236  $ti_prop->setInfo($lng->txt("awrn_max_inactivity_info"));
237  $ti_prop->setMaxLength(3);
238  $ti_prop->setSize(3);
239  $en->addSubItem($ti_prop);
240 
241  // activate osd
242  $osd = new ilCheckboxInputGUI($this->lng->txt("awrn_use_osd"), "use_osd");
243  $osd->setInfo($this->lng->txt("awrn_use_osd_info"));
244  $osd->setChecked($awrn_set->get("use_osd", true));
245  $en->addSubItem($osd);
246 
247 
248  include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
250  foreach ($prov as $p)
251  {
252  // activation mode
253  $options = array(
254  ilAwarenessUserProvider::MODE_INACTIVE => $lng->txt("awrn_inactive"),
255  ilAwarenessUserProvider::MODE_ONLINE_ONLY => $lng->txt("awrn_online_only"),
256  ilAwarenessUserProvider::MODE_INCL_OFFLINE => $lng->txt("awrn_incl_offline")
257  );
258  $si = new ilSelectInputGUI($p->getTitle(), "up_act_mode_".$p->getProviderId());
259  $si->setOptions($options);
260  $si->setInfo($p->getInfo());
261  $si->setValue($p->getActivationMode());
262  $en->addSubItem($si);
263  }
264 
265  return $form;
266  }
267 }
268 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
ILIAS Setting Class.
This class represents a selection list property in a property form.
This class represents a property form user interface.
User action administration GUI class.
$cmd
Definition: sahs_server.php:35
This class represents a checkbox property in a property form.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
prepareOutput($a_show_subobjects=true)
prepare output
setSuffix($a_value)
Set suffix.
if(!is_array($argv)) $options
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
static getAllProviders()
Get all awareness providers.
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
$_POST["username"]