ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPersonalDesktopSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./Services/Object/classes/class.ilObjectGUI.php");
4 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
5 
17 {
18  private static $ERROR_MESSAGE;
24  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
25  {
26  global $lng;
27 
28  $this->type = 'pdts';
29  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
30 
31  $lng->loadLanguageModule("pd");
32  }
33 
40  public function executeCommand()
41  {
42  global $rbacsystem,$ilErr,$ilAccess;
43 
44  $next_class = $this->ctrl->getNextClass($this);
45  $cmd = $this->ctrl->getCmd();
46 
47  $this->prepareOutput();
48 
49  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
50  {
51  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
52  }
53 
54  switch($next_class)
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  $ret =& $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 
81  public function getAdminTabs()
82  {
83  global $rbacsystem, $ilAccess;
84 
85  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
86  {
87  $this->tabs_gui->addTarget("pd_settings",
88  $this->ctrl->getLinkTarget($this, "editSettings"),
89  array("editSettings", "view"));
90  }
91 
92  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
93  {
94  $this->tabs_gui->addTarget("perm_settings",
95  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
96  array(),'ilpermissiongui');
97  }
98  }
99 
103  public function editSettings()
104  {
105  global $ilCtrl, $lng, $ilSetting;
106 
107  $pd_set = new ilSetting("pd");
108 
109  $enable_calendar = ilCalendarSettings::_getInstance()->isEnabled();
110  #$enable_calendar = $ilSetting->get("enable_calendar");
111  $enable_block_moving = $pd_set->get("enable_block_moving");
112  $enable_active_users = $ilSetting->get("block_activated_pdusers");
113 
114  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
115  $form = new ilPropertyFormGUI();
116  $form->setFormAction($ilCtrl->getFormAction($this));
117  $form->setTitle($lng->txt("pd_settings"));
118 
119  // Enable calendar
120  $cb_prop = new ilCheckboxInputGUI($lng->txt("enable_calendar"), "enable_calendar");
121  $cb_prop->setValue("1");
122  //$cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
123  $cb_prop->setChecked($enable_calendar);
124  $form->addItem($cb_prop);
125 
126  // Enable bookmarks
127  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_bookmarks"), "enable_bookmarks");
128  $cb_prop->setValue("1");
129  $cb_prop->setChecked(($ilSetting->get("disable_bookmarks") ? "0" : "1"));
130  $form->addItem($cb_prop);
131 
132  // Enable contacts
133  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_contacts"), "enable_contacts");
134  $cb_prop->setValue("1");
135  $cb_prop->setChecked(($ilSetting->get("disable_contacts") ? "0" : "1"));
136 
137  $cb_prop_requires_mail = new ilCheckboxInputGUI($lng->txt('pd_enable_contacts_requires_mail'), 'enable_contacts_require_mail');
138  $cb_prop_requires_mail->setValue("1");
139  $cb_prop_requires_mail->setChecked(($ilSetting->get("disable_contacts_require_mail") ? "0" : "1"));
140  $cb_prop->addSubItem($cb_prop_requires_mail);
141 
142  $form->addItem($cb_prop);
143 
144  // Enable notes
145  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_notes"), "enable_notes");
146  $cb_prop->setValue("1");
147  $cb_prop->setChecked(($ilSetting->get("disable_notes") ? "0" : "1"));
148  $form->addItem($cb_prop);
149 
150  // Enable notes
151  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_comments"), "enable_comments");
152  $cb_prop->setValue("1");
153  $cb_prop->setChecked(($ilSetting->get("disable_comments") ? "0" : "1"));
154  $form->addItem($cb_prop);
155 
156  // Enable Chatviewer
157  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_chatviewer"), "block_activated_chatviewer");
158  $cb_prop->setValue("1");
159  $cb_prop->setChecked(($ilSetting->get("block_activated_chatviewer")));
160  $form->addItem($cb_prop);
161 
162  // Enable block moving
163  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_block_moving"),
164  "enable_block_moving");
165  $cb_prop->setValue("1");
166  $cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
167  $cb_prop->setChecked($enable_block_moving);
168  $form->addItem($cb_prop);
169 
170  // Enable active users block
171  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_active_users"),
172  "block_activated_pdusers");
173  $cb_prop->setValue("1");
174  $cb_prop->setChecked($enable_active_users);
175 
176  // maximum inactivity time
177  $ti_prop = new ilTextInputGUI($lng->txt("pd_time_before_removal"),
178  "time_removal");
179  $ti_prop->setValue($pd_set->get("user_activity_time"));
180  $ti_prop->setInfo($lng->txt("pd_time_before_removal_info"));
181  $ti_prop->setMaxLength(3);
182  $ti_prop->setSize(3);
183  $cb_prop->addSubItem($ti_prop);
184 
185  // osi host
186  // see http://www.onlinestatus.org
187  $ti_prop = new ilTextInputGUI($lng->txt("pd_osi_host"),
188  "osi_host");
189  $ti_prop->setValue($pd_set->get("osi_host"));
190  $ti_prop->setInfo($lng->txt("pd_osi_host_info").
191  ' <a href="http://www.onlinestatus.org" target="_blank">http://www.onlinestatus.org</a>');
192  $cb_prop->addSubItem($ti_prop);
193 
194  $form->addItem($cb_prop);
195 
196  // Enable 'My Offers' (default personal items)
197  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_offers'), 'enable_my_offers');
198  $cb_prop->setValue('1');
199  $cb_prop->setInfo($lng->txt('pd_enable_my_offers_info'));
200  $cb_prop->setChecked(($ilSetting->get('disable_my_offers') ? '0' : '1'));
201  $form->addItem($cb_prop);
202 
203  // Enable 'My Memberships'
204  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_memberships'), 'enable_my_memberships');
205  $cb_prop->setValue('1');
206  $cb_prop->setInfo($lng->txt('pd_enable_my_memberships_info'));
207  $cb_prop->setChecked(($ilSetting->get('disable_my_memberships') ? '0' : '1'));
208  $form->addItem($cb_prop);
209 
210  if($ilSetting->get('disable_my_offers') == 0 &&
211  $ilSetting->get('disable_my_memberships') == 0)
212  {
213  // Default view of personal items
214  $sb_prop = new ilSelectInputGUI($lng->txt('pd_personal_items_default_view'), 'personal_items_default_view');
215  $sb_prop->setInfo($lng->txt('pd_personal_items_default_view_info'));
216  $option = array();
217  $option[0] = $lng->txt('pd_my_offers');
218  $option[1] = $lng->txt('my_courses_groups');
219  $sb_prop->setOptions($option);
220  $sb_prop->setValue((int)$ilSetting->get('personal_items_default_view'));
221  $form->addItem($sb_prop);
222  }
223 
224  // Enable 'Personal Workspace'
225  $wsp_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_personal_workspace'), 'wsp');
226  $wsp_prop->setValue('1');
227  $wsp_prop->setChecked(($ilSetting->get('disable_personal_workspace') ? '0' : '1'));
228  $form->addItem($wsp_prop);
229 
230  // Enable 'Blogs'
231  $blog_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_blogs'), 'blog');
232  $blog_prop->setValue('1');
233  $blog_prop->setChecked(($ilSetting->get('disable_wsp_blogs') ? '0' : '1'));
234  $wsp_prop->addSubItem($blog_prop);
235 
236  // Enable 'Files'
237  $file_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_files'), 'file');
238  $file_prop->setValue('1');
239  $file_prop->setChecked(($ilSetting->get('disable_wsp_files') ? '0' : '1'));
240  $wsp_prop->addSubItem($file_prop);
241 
242  // Enable 'Certificates'
243  $cert_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_certificates'), 'cert');
244  $cert_prop->setValue('1');
245  $cert_prop->setChecked(($ilSetting->get('disable_wsp_certificates') ? '0' : '1'));
246  $wsp_prop->addSubItem($cert_prop);
247 
248  // Enable 'Links'
249  $link_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_wsp_links'), 'link');
250  $link_prop->setValue('1');
251  $link_prop->setChecked(($ilSetting->get('disable_wsp_links') ? '0' : '1'));
252  $wsp_prop->addSubItem($link_prop);
253 
254  // Enable 'Portfolios'
255  $lng->loadLanguageModule('user');
256  $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
257  $prtf_prop->setValue('1');
258  $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
259  $prtf_prop->setChecked(($ilSetting->get('user_portfolios') ? '1' : '0'));
260  $form->addItem($prtf_prop);
261 
262  // command buttons
263  $form->addCommandButton("saveSettings", $lng->txt("save"));
264  $form->addCommandButton("view", $lng->txt("cancel"));
265 
266  $this->tpl->setContent($form->getHTML());
267  }
268 
272  public function saveSettings()
273  {
274  global $ilCtrl, $ilSetting;
275 
276  $pd_set = new ilSetting("pd");
277 
278  ilCalendarSettings::_getInstance()->setEnabled( $_POST["enable_calendar"]);
280 
281  #$ilSetting->set("enable_calendar", $_POST["enable_calendar"]);
282  $ilSetting->set("disable_bookmarks", (int) ($_POST["enable_bookmarks"] ? 0 : 1));
283 
284  $ilSetting->set("disable_contacts", (int) ($_POST["enable_contacts"] ? 0 : 1));
285  $ilSetting->set("disable_contacts_require_mail", (int) ($_POST["enable_contacts_require_mail"] ? 0 : 1));
286 
287  $ilSetting->set("disable_notes", (int) ($_POST["enable_notes"] ? 0 : 1));
288  $ilSetting->set("disable_comments", (int) ($_POST["enable_comments"] ? 0 : 1));
289  $ilSetting->set("block_activated_chatviewer", (int) ($_POST["block_activated_chatviewer"]));
290 
291  $ilSetting->set("block_activated_pdusers", $_POST["block_activated_pdusers"]);
292  $pd_set->set("enable_block_moving", $_POST["enable_block_moving"]);
293  $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
294  $pd_set->set("osi_host", $_POST["osi_host"]);
295 
296  // Validate personal desktop view
297  if(!(int)$_POST['enable_my_offers'] && !(int)$_POST['enable_my_memberships'])
298  {
299  ilUtil::sendFailure($this->lng->txt('pd_view_select_at_least_one'), true);
300  $ilCtrl->redirect($this, 'view');
301  }
302 
303  // Enable 'My Offers' (default personal items)
304  $ilSetting->set('disable_my_offers', (int)($_POST['enable_my_offers'] ? 0 : 1));
305 
306  // Enable 'My Memberships'
307  $ilSetting->set('disable_my_memberships', (int)($_POST['enable_my_memberships'] ? 0 : 1));
308 
309  if((int)$_POST['enable_my_offers'] && !(int)$_POST['enable_my_memberships'])
310  $_POST['personal_items_default_view'] = 0;
311  else if(!(int)$_POST['enable_my_offers'] && (int)$_POST['enable_my_memberships'])
312  $_POST['personal_items_default_view'] = 1;
313  else if(!isset($_POST['personal_items_default_view']))
314  $_POST['personal_items_default_view'] = $ilSetting->get('personal_items_default_view');
315 
316  // Default view of personal items
317  $ilSetting->set('personal_items_default_view', (int)$_POST['personal_items_default_view']);
318 
319  // without personal workspace we have to disable to sub-items
320  if(!$_POST["wsp"])
321  {
322  $_POST["blog"] = 0;
323  $_POST["file"] = 0;
324  $_POST["cert"] = 0;
325  $_POST["link"] = 0;
326  }
327 
328  $ilSetting->set('disable_personal_workspace', (int)($_POST['wsp'] ? 0 : 1));
329  $ilSetting->set('disable_wsp_blogs', (int)($_POST['blog'] ? 0 : 1));
330  $ilSetting->set('disable_wsp_files', (int)($_POST['file'] ? 0 : 1));
331  $ilSetting->set('disable_wsp_certificates', (int)($_POST['cert'] ? 0 : 1));
332  $ilSetting->set('disable_wsp_links', (int)($_POST['link'] ? 0 : 1));
333  $ilSetting->set('user_portfolios', (int)($_POST['prtf'] ? 1 : 0));
334 
335  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
336 
337  $ilCtrl->redirect($this, "view");
338  }
339 }
340 ?>