ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPersonalDesktopSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 include_once("./classes/class.ilObjectGUI.php");
24 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
25 
37 {
38  private static $ERROR_MESSAGE;
44  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
45  {
46  global $lng;
47 
48  $this->type = 'pdts';
49  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
50 
51  $lng->loadLanguageModule("pd");
52  }
53 
60  public function executeCommand()
61  {
62  global $rbacsystem,$ilErr,$ilAccess;
63 
64  $next_class = $this->ctrl->getNextClass($this);
65  $cmd = $this->ctrl->getCmd();
66 
67  $this->prepareOutput();
68 
69  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
70  {
71  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
72  }
73 
74  switch($next_class)
75  {
76  case 'ilpermissiongui':
77  $this->tabs_gui->setTabActive('perm_settings');
78  include_once("./classes/class.ilPermissionGUI.php");
79  $perm_gui =& new ilPermissionGUI($this);
80  $ret =& $this->ctrl->forwardCommand($perm_gui);
81  break;
82 
83  default:
84  if(!$cmd || $cmd == 'view')
85  {
86  $cmd = "editSettings";
87  }
88 
89  $this->$cmd();
90  break;
91  }
92  return true;
93  }
94 
101  public function getAdminTabs()
102  {
103  global $rbacsystem, $ilAccess;
104 
105  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
106  {
107  $this->tabs_gui->addTarget("pd_settings",
108  $this->ctrl->getLinkTarget($this, "editSettings"),
109  array("editSettings", "view"));
110  }
111 
112  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
113  {
114  $this->tabs_gui->addTarget("perm_settings",
115  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
116  array(),'ilpermissiongui');
117  }
118  }
119 
123  public function editSettings()
124  {
125  global $ilCtrl, $lng, $ilSetting;
126 
127  $pd_set = new ilSetting("pd");
128 
129  $enable_calendar = ilCalendarSettings::_getInstance()->isEnabled();
130  #$enable_calendar = $ilSetting->get("enable_calendar");
131  $enable_block_moving = $pd_set->get("enable_block_moving");
132  $enable_active_users = $ilSetting->get("block_activated_pdusers");
133 
134  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
135  $form = new ilPropertyFormGUI();
136  $form->setFormAction($ilCtrl->getFormAction($this));
137  $form->setTitle($lng->txt("pd_settings"));
138 
139  // Enable calendar
140  $cb_prop = new ilCheckboxInputGUI($lng->txt("enable_calendar"), "enable_calendar");
141  $cb_prop->setValue("1");
142  //$cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
143  $cb_prop->setChecked($enable_calendar);
144  $form->addItem($cb_prop);
145 
146  // Enable bookmarks
147  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_bookmarks"), "enable_bookmarks");
148  $cb_prop->setValue("1");
149  $cb_prop->setChecked(($ilSetting->get("disable_bookmarks") ? "0" : "1"));
150  $form->addItem($cb_prop);
151 
152  // Enable notes
153  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_notes"), "enable_notes");
154  $cb_prop->setValue("1");
155  $cb_prop->setChecked(($ilSetting->get("disable_notes") ? "0" : "1"));
156  $form->addItem($cb_prop);
157 
158  // Enable block moving
159  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_block_moving"),
160  "enable_block_moving");
161  $cb_prop->setValue("1");
162  $cb_prop->setInfo($lng->txt("pd_enable_block_moving_info"));
163  $cb_prop->setChecked($enable_block_moving);
164  $form->addItem($cb_prop);
165 
166  // Enable active users block
167  $cb_prop = new ilCheckboxInputGUI($lng->txt("pd_enable_active_users"),
168  "block_activated_pdusers");
169  $cb_prop->setValue("1");
170  $cb_prop->setChecked($enable_active_users);
171 
172  // maximum inactivity time
173  $ti_prop = new ilTextInputGUI($lng->txt("pd_time_before_removal"),
174  "time_removal");
175  $ti_prop->setValue($pd_set->get("user_activity_time"));
176  $ti_prop->setInfo($lng->txt("pd_time_before_removal_info"));
177  $ti_prop->setMaxLength(3);
178  $ti_prop->setSize(3);
179  $cb_prop->addSubItem($ti_prop);
180 
181  // osi host
182  // see http://www.onlinestatus.org
183  $ti_prop = new ilTextInputGUI($lng->txt("pd_osi_host"),
184  "osi_host");
185  $ti_prop->setValue($pd_set->get("osi_host"));
186  $ti_prop->setInfo($lng->txt("pd_osi_host_info").
187  ' <a href="http://www.onlinestatus.org" target="_blank">http://www.onlinestatus.org</a>');
188  $cb_prop->addSubItem($ti_prop);
189 
190  $form->addItem($cb_prop);
191 
192  // Enable 'My Offers' (default personal items)
193  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_offers'), 'enable_my_offers');
194  $cb_prop->setValue('1');
195  $cb_prop->setInfo($lng->txt('pd_enable_my_offers_info'));
196  $cb_prop->setChecked(($ilSetting->get('disable_my_offers') ? '0' : '1'));
197  $form->addItem($cb_prop);
198 
199  // Enable 'My Memberships'
200  $cb_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_my_memberships'), 'enable_my_memberships');
201  $cb_prop->setValue('1');
202  $cb_prop->setInfo($lng->txt('pd_enable_my_memberships_info'));
203  $cb_prop->setChecked(($ilSetting->get('disable_my_memberships') ? '0' : '1'));
204  $form->addItem($cb_prop);
205 
206  if($ilSetting->get('disable_my_offers') == 0 &&
207  $ilSetting->get('disable_my_memberships') == 0)
208  {
209  // Default view of personal items
210  $sb_prop = new ilSelectInputGUI($lng->txt('pd_personal_items_default_view'), 'personal_items_default_view');
211  $sb_prop->setInfo($lng->txt('pd_personal_items_default_view_info'));
212  $option = array();
213  $option[0] = $lng->txt('pd_my_offers');
214  $option[1] = $lng->txt('pd_my_memberships');
215  $sb_prop->setOptions($option);
216  $sb_prop->setValue((int)$ilSetting->get('personal_items_default_view'));
217  $form->addItem($sb_prop);
218  }
219 
220  // command buttons
221  $form->addCommandButton("saveSettings", $lng->txt("save"));
222  $form->addCommandButton("view", $lng->txt("cancel"));
223 
224  $this->tpl->setContent($form->getHTML());
225  }
226 
230  public function saveSettings()
231  {
232  global $ilCtrl, $ilSetting;
233 
234  $pd_set = new ilSetting("pd");
235 
236  ilCalendarSettings::_getInstance()->setEnabled( $_POST["enable_calendar"]);
238 
239  #$ilSetting->set("enable_calendar", $_POST["enable_calendar"]);
240  $ilSetting->set("disable_bookmarks", (int) ($_POST["enable_bookmarks"] ? 0 : 1));
241  $ilSetting->set("disable_notes", (int) ($_POST["enable_notes"] ? 0 : 1));
242 
243  $ilSetting->set("block_activated_pdusers", $_POST["block_activated_pdusers"]);
244  $pd_set->set("enable_block_moving", $_POST["enable_block_moving"]);
245  $pd_set->set("user_activity_time", (int) $_POST["time_removal"]);
246  $pd_set->set("osi_host", $_POST["osi_host"]);
247 
248  // Validate personal desktop view
249  if(!(int)$_POST['enable_my_offers'] && !(int)$_POST['enable_my_memberships'])
250  {
251  ilUtil::sendInfo($this->lng->txt('pd_view_select_at_least_one'), true);
252  $ilCtrl->redirect($this, 'view');
253  }
254 
255  // Enable 'My Offers' (default personal items)
256  $ilSetting->set('disable_my_offers', (int)($_POST['enable_my_offers'] ? 0 : 1));
257 
258  // Enable 'My Memberships'
259  $ilSetting->set('disable_my_memberships', (int)($_POST['enable_my_memberships'] ? 0 : 1));
260 
261  if((int)$_POST['enable_my_offers'] && !(int)$_POST['enable_my_memberships'])
262  $_POST['personal_items_default_view'] = 0;
263  else if(!(int)$_POST['enable_my_offers'] && (int)$_POST['enable_my_memberships'])
264  $_POST['personal_items_default_view'] = 1;
265  else if(!isset($_POST['personal_items_default_view']))
266  $_POST['personal_items_default_view'] = $ilSetting->get('personal_items_default_view');
267 
268  // Default view of personal items
269  $ilSetting->set('personal_items_default_view', (int)$_POST['personal_items_default_view']);
270 
271  ilUtil::sendInfo($this->lng->txt("settings_saved"), true);
272 
273  $ilCtrl->redirect($this, "view");
274  }
275 }
276 ?>