ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
27 
28  $this->lng->loadLanguageModule("awrn");
29  $this->lng->loadLanguageModule("pd");
30  }
31 
38  public function executeCommand()
39  {
40  $next_class = $this->ctrl->getNextClass($this);
41  $cmd = $this->ctrl->getCmd();
42 
43  $this->prepareOutput();
44 
45  switch($next_class)
46  {
47  case 'ilpermissiongui':
48  $this->tabs_gui->setTabActive('perm_settings');
49  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
50  $perm_gui = new ilPermissionGUI($this);
51  $this->ctrl->forwardCommand($perm_gui);
52  break;
53 
54  default:
55  if(!$cmd || $cmd == 'view')
56  {
57  $cmd = "editSettings";
58  }
59 
60  $this->$cmd();
61  break;
62  }
63  return true;
64  }
65 
69  public function getAdminTabs()
70  {
71  global $rbacsystem;
72 
73  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
74  {
75  $this->tabs_gui->addTab("settings",
76  $this->lng->txt("settings"),
77  $this->ctrl->getLinkTarget($this, "editSettings"));
78  }
79 
80  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
81  {
82  $this->tabs_gui->addTab("perm_settings",
83  $this->lng->txt("perm_settings"),
84  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"));
85  }
86  }
87 
88 
92  public function editSettings($a_form = null)
93  {
94  $this->tabs_gui->setTabActive('settings');
95 
96  if(!$a_form)
97  {
98  $a_form = $this->initFormSettings();
99  }
100  $this->tpl->setContent($a_form->getHTML());
101  return true;
102  }
103 
107  public function saveSettings()
108  {
109  global $ilCtrl;
110 
111  $this->checkPermission("write");
112 
113  $form = $this->initFormSettings();
114  if($form->checkInput())
115  {
116  $awrn_set = new ilSetting("awrn");
117  $awrn_set->set("awrn_enabled", (bool) $form->getInput("enable_awareness"));
118 
119  $p = (int) $form->getInput("caching_period");
120  if ($p < 0)
121  {
122  $p = 0;
123  }
124  $awrn_set->set("caching_period", $p);
125 
126  $awrn_set->set("max_nr_entries", (int) $form->getInput("max_nr_entries"));
127 
128  $pd_set = new ilSetting("pd");
129  $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
130 
131  include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
133  foreach ($prov as $p)
134  {
135  $p->setActivationMode($form->getInput("up_act_mode_".$p->getProviderId()));
136  }
137 
138  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
139  $ilCtrl->redirect($this, "editSettings");
140  }
141 
142  $form->setValuesByPost();
143  $this->editSettings($form);
144  }
145 
149  public function cancel()
150  {
151  global $ilCtrl;
152 
153  $ilCtrl->redirect($this, "view");
154  }
155 
161  protected function initFormSettings()
162  {
163  global $lng;
164 
165  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
166  $form = new ilPropertyFormGUI();
167  $form->setFormAction($this->ctrl->getFormAction($this));
168  $form->setTitle($this->lng->txt('awareness_settings'));
169  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
170  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
171 
172  $en = new ilCheckboxInputGUI($lng->txt("awrn_enable"), "enable_awareness");
173  $form->addItem($en);
174 
175  $awrn_set = new ilSetting("awrn");
176  $en->setChecked($awrn_set->get("awrn_enabled", false));
177 
178  // caching period
179  $ti = new ilNumberInputGUI($this->lng->txt("awrn_caching_period"), "caching_period");
180  $ti->setInfo($this->lng->txt("awrn_caching_period_info"));
181  $ti->setSuffix($this->lng->txt("awrn_seconds"));
182  $ti->setSize(6);
183  $ti->setMaxLength(6);
184  $ti->setValue($awrn_set->get("caching_period"));
185  $en->addSubItem($ti);
186 
187  // limit number of entries
188  $ti = new ilNumberInputGUI($this->lng->txt("awrn_max_nr_entries"), "max_nr_entries");
189  $ti->setInfo($this->lng->txt("awrn_max_nr_entries_info"));
190  $ti->setSize(3);
191  $ti->setMaxLength(3);
192  $ti->setMinValue(5);
193  $ti->setMaxValue(200);
194  $ti->setValue($awrn_set->get("max_nr_entries"));
195  $en->addSubItem($ti);
196 
197  // maximum inactivity time
198  $pd_set = new ilSetting("pd"); // under pd settings due to historical reasons
199  $ti_prop = new ilNumberInputGUI($lng->txt("awrn_max_inactivity"),
200  "time_removal");
201  $ti_prop->setSuffix($this->lng->txt("awrn_minutes"));
202  if ($pd_set->get("user_activity_time") > 0)
203  {
204  $ti_prop->setValue($pd_set->get("user_activity_time"));
205  }
206  $ti_prop->setInfo($lng->txt("awrn_max_inactivity_info"));
207  $ti_prop->setMaxLength(3);
208  $ti_prop->setSize(3);
209  $en->addSubItem($ti_prop);
210 
211 
212  include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
214  foreach ($prov as $p)
215  {
216  // activation mode
217  $options = array(
218  ilAwarenessUserProvider::MODE_INACTIVE => $lng->txt("awrn_inactive"),
219  ilAwarenessUserProvider::MODE_ONLINE_ONLY => $lng->txt("awrn_online_only"),
220  ilAwarenessUserProvider::MODE_INCL_OFFLINE => $lng->txt("awrn_incl_offline")
221  );
222  $si = new ilSelectInputGUI($p->getTitle(), "up_act_mode_".$p->getProviderId());
223  $si->setOptions($options);
224  $si->setInfo($p->getInfo());
225  $si->setValue($p->getActivationMode());
226  $en->addSubItem($si);
227  }
228 
229  return $form;
230  }
231 }
232 ?>
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.
$_POST['username']
Definition: cron.php:12
This class represents a selection list property in a property form.
This class represents a property form user interface.
$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.
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.
prepareOutput()
prepare output
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.