ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCalendarSettingsGUI.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('./Services/Object/classes/class.ilObjectGUI.php');
24 
25 
36 {
37 
43  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
44  {
45  global $lng;
46 
47  $this->type = 'cals';
48  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
49 
50  $this->lng = $lng;
51  $this->lng->loadLanguageModule('dateplaner');
52  $this->lng->loadLanguageModule('jscalendar');
53  }
54 
61  public function executeCommand()
62  {
63  global $ilErr,$ilAccess;
64 
65  $next_class = $this->ctrl->getNextClass($this);
66  $cmd = $this->ctrl->getCmd();
67 
68  $this->prepareOutput();
69 
70  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
71  {
72  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
73  }
74 
75  switch($next_class)
76  {
77  case 'ilpermissiongui':
78  $this->tabs_gui->setTabActive('perm_settings');
79  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
80  $perm_gui =& new ilPermissionGUI($this);
81  $ret =& $this->ctrl->forwardCommand($perm_gui);
82  break;
83 
84  default:
85  $this->tabs_gui->setTabActive('settings');
86  $this->initCalendarSettings();
87  if(!$cmd || $cmd == 'view')
88  {
89  $cmd = "settings";
90  }
91 
92  $this->$cmd();
93  break;
94  }
95  return true;
96  }
97 
98 
105  public function getAdminTabs()
106  {
107  global $rbacsystem, $ilAccess;
108 
109  if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
110  {
111  $this->tabs_gui->addTarget("settings",
112  $this->ctrl->getLinkTarget($this, "settings"),
113  array("settings", "view"));
114  }
115 
116  if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
117  {
118  $this->tabs_gui->addTarget("perm_settings",
119  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
120  array(),'ilpermissiongui');
121  }
122  }
123 
127  public function settings()
128  {
129  include_once('./Services/Calendar/classes/class.ilDateTime.php');
130 
131  include_once('./Services/Calendar/classes/iCal/class.ilICalParser.php');
132 
133  include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php');
134  include_once('./Services/Calendar/classes/class.ilCalendarRecurrence.php');
135  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
136 
137 
138  #$parser = new ilICalParser('./extern/Feiertage.ics',ilICalParser::INPUT_FILE);
139  #$parser->setCategoryId(6);
140  #$parser->parse();
141  /*
142  $calc = new ilCalendarRecurrenceCalculator(
143  new ilCalendarEntry(273),
144  new ilCalendarRecurrence(43));
145 
146  $list = $calc->calculateDateList(
147  new ilDateTime('2008-04-01',IL_CAL_DATE),
148  new ilDateTime('2008-04-31',IL_CAL_DATE));
149  */
150  #echo "RESULT: ".$list;
151  /*
152  $zeit = microtime(true);
153 
154  for($i = 0;$i < 1;$i++)
155  {
156  $calc = new ilCalendarRecurrenceCalculator(
157  new ilCalendarEntry(1061),
158  new ilCalendarRecurrence(72));
159 
160  $list = $calc->calculateDateList(
161  new ilDateTime('2008-03-01',IL_CAL_DATE),
162  new ilDateTime('2008-03-31',IL_CAL_DATE));
163  }
164  echo "NEEDS: ".(microtime(true) - $zeit).' seconds.<br>';
165  foreach($list->get() as $event)
166  {
167  echo $event->get(IL_CAL_DATETIME,'',$this->settings->getDefaultTimeZone()).'<br />';
168  }
169  */
170  #$parser = new ilICalParser('./extern/fc.ics',ilICalParser::INPUT_FILE);
171  #$parser->setCategoryId(11);
172  #$parser = new ilICalParser('./Feiertage.ics',ilICalParser::INPUT_FILE);
173  #$parser->parse();
174  #$entry = new ilCalendarEntry(927);
175  /*
176  $timezone = "US/Alaska";
177  echo $entry->getTitle().'<br>';
178  echo $entry->getStart()->get(IL_CAL_DATE,'',$timezone).'<br>';
179  echo $entry->getStart()->get(IL_CAL_DATETIME,'',$timezone).'<br>';
180  echo $entry->getEnd()->get(IL_CAL_DATE,'',$timezone).'<br>';
181  echo $entry->getEnd()->get(IL_CAL_DATETIME,'',$timezone).'<br>';
182 
183  $entry = new ilCalendarEntry(928);
184  echo $entry->getTitle().'<br>';
185  echo $entry->getStart()->get(IL_CAL_DATE,'',$timezone).'<br>';
186  echo $entry->getStart()->get(IL_CAL_DATETIME,'',$timezone).'<br>';
187  echo $entry->getEnd()->get(IL_CAL_DATE,'',$timezone).'<br>';
188  echo $entry->getEnd()->get(IL_CAL_DATETIME,'',$timezone).'<br>';
189  */
190  $this->tabs_gui->setTabActive('settings');
191  $this->initFormSettings();
192  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.settings.html','Services/Calendar');
193  $this->tpl->setVariable('CAL_SETTINGS',$this->form->getHTML());
194  return true;
195  }
196 
202  protected function save()
203  {
204  $this->settings->setEnabled((int) $_POST['enable']);
205  $this->settings->setDefaultWeekStart((int) $_POST['default_week_start']);
206  $this->settings->setDefaultTimeZone(ilUtil::stripSlashes($_POST['default_timezone']));
207  $this->settings->setDefaultDateFormat((int) $_POST['default_date_format']);
208  $this->settings->setDefaultTimeFormat((int) $_POST['default_time_format']);
209  $this->settings->setEnableGroupMilestones((int) $_POST['enable_grp_milestones']);
210  $this->settings->enableCourseCalendar((int) $_POST['visible_crs']);
211  $this->settings->enableGroupCalendar((int) $_POST['visible_grp']);
212  $this->settings->setDefaultDayStart((int) $_POST['dst']);
213  $this->settings->setDefaultDayEnd((int) $_POST['den']);
214  $this->settings->enableSynchronisationCache((bool) $_POST['sync_cache']);
215  $this->settings->setSynchronisationCacheMinutes((int) $_POST['sync_cache_time']);
216  $this->settings->setCacheMinutes((int) $_POST['cache_time']);
217  $this->settings->useCache((bool) $_POST['cache']);
218  $this->settings->enableNotification((bool) $_POST['cn']);
219  $this->settings->enableUserNotification((bool) $_POST['cnu']);
220  $this->settings->enableConsultationHours((bool) $_POST['ch']);
221  $this->settings->enableCGRegistration((bool) $_POST['cgr']);
222  $this->settings->enableWebCalSync((bool) $_POST['webcal']);
223  $this->settings->setWebCalSyncHours((int) $_POST['webcal_hours']);
224 
225  if(((int) $_POST['den']) < (int) $_POST['dst'])
226  {
227  ilUtil::sendFailure($this->lng->txt('cal_dstart_dend_warn'));
228  $this->settings();
229  return false;
230  }
231 
232  $this->settings->save();
233 
234  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
235  $this->settings();
236  }
237 
243  protected function initCalendarSettings()
244  {
245  include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
247  }
248 
254  protected function initFormSettings()
255  {
256  if(is_object($this->form))
257  {
258  return true;
259  }
260  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
261  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
262 
263  $this->form = new ilPropertyFormGUI();
264  $this->form->setFormAction($this->ctrl->getFormAction($this));
265  $this->form->setTitle($this->lng->txt('cal_global_settings'));
266  $this->form->addCommandButton('save',$this->lng->txt('save'));
267  #$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
268 
269  $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'),'enable');
270  $check->setValue(1);
271  $check->setChecked($this->settings->isEnabled() ? true : false);
272  $this->form->addItem($check);
273 
274  $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
276  $this->form->addItem($server_tz);
277 
278  $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'),'default_timezone');
280  $select->setInfo($this->lng->txt('cal_def_timezone_info'));
281  $select->setValue($this->settings->getDefaultTimeZone());
282  $this->form->addItem($select);
283 
284  $year = date("Y");
285  $select = new ilSelectInputGUI($this->lng->txt('cal_def_date_format'),'default_date_format');
286  $select->setOptions(array(
287  ilCalendarSettings::DATE_FORMAT_DMY => '31.10.'.$year,
288  ilCalendarSettings::DATE_FORMAT_YMD => $year."-10-31",
289  ilCalendarSettings::DATE_FORMAT_MDY => "10/31/".$year));
290  $select->setInfo($this->lng->txt('cal_def_date_format_info'));
291  $select->setValue($this->settings->getDefaultDateFormat());
292  $this->form->addItem($select);
293 
294  $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'),'default_time_format');
295  $select->setOptions(array(
298  $select->setInfo($this->lng->txt('cal_def_time_format_info'));
299  $select->setValue($this->settings->getDefaultTimeFormat());
300  $this->form->addItem($select);
301 
302  // Weekstart
303  $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'),'default_week_start');
304  $radio->setValue($this->settings->getDefaultWeekStart());
305 
306  $option = new ilRadioOption($this->lng->txt('l_su'),0);
307  $radio->addOption($option);
308  $option = new ilRadioOption($this->lng->txt('l_mo'),1);
309  $radio->addOption($option);
310 
311  $this->form->addItem($radio);
312 
313  // Day start
314  $day_start = new ilSelectInputGUI($this->lng->txt('cal_day_start'),'dst');
315  $day_start->setOptions(
316  ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
317  );
318  $day_start->setValue($this->settings->getDefaultDayStart());
319  $this->form->addItem($day_start);
320 
321  $day_end = new ilSelectInputGUI($this->lng->txt('cal_day_end'),'den');
322  $day_end->setOptions(
323  ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat())
324  );
325  $day_end->setValue($this->settings->getDefaultDayEnd());
326  $this->form->addItem($day_end);
327 
328  $sync = new ilCheckboxInputGUI($this->lng->txt('cal_webcal_sync'),'webcal');
329  $sync->setValue(1);
330  $sync->setChecked($this->settings->isWebCalSyncEnabled());
331  $sync->setInfo($this->lng->txt('cal_webcal_sync_info'));
332 
333  $sync_min = new ilNumberInputGUI('','webcal_hours');
334  $sync_min->setSize(2);
335  $sync_min->setMaxLength(3);
336  $sync_min->setValue($this->settings->getWebCalSyncHours());
337  $sync_min->setSuffix($this->lng->txt('hours'));
338  $sync->addSubItem($sync_min);
339 
340  $this->form->addItem($sync);
341 
342 
343 
344  // enable milestone planning in groups
345  $mil = new ilFormSectionHeaderGUI();
346  $mil->setTitle($this->lng->txt('cal_milestone_settings'));
347  $this->form->addItem($mil);
348 
349  $checkm = new ilCheckboxInputGUI($this->lng->txt('cal_enable_group_milestones'),'enable_grp_milestones');
350  $checkm->setValue(1);
351  $checkm->setChecked($this->settings->getEnableGroupMilestones() ? true : false);
352  $checkm->setInfo($this->lng->txt('cal_enable_group_milestones_desc'));
353  $this->form->addItem($checkm);
354 
355  // Consultation hours
356  $con = new ilFormSectionHeaderGUI();
357  $con->setTitle($this->lng->txt('cal_ch_form_header'));
358  $this->form->addItem($con);
359 
360  $ch = new ilCheckboxInputGUI($this->lng->txt('cal_ch_form'),'ch');
361  $ch->setInfo($this->lng->txt('cal_ch_form_info'));
362  $ch->setValue(1);
363  $ch->setChecked($this->settings->areConsultationHoursEnabled());
364  $this->form->addItem($ch);
365 
366  // repository visibility default
367  $rep = new ilFormSectionHeaderGUI();
368  $rep->setTitle($GLOBALS['lng']->txt('cal_setting_global_vis_repos'));
369  $this->form->addItem($rep);
370 
371  $crs = new ilCheckboxInputGUI($GLOBALS['lng']->txt('cal_setting_global_crs_vis'),'visible_crs');
372  $crs->setInfo($GLOBALS['lng']->txt('cal_setting_global_crs_vis_info'));
373  $crs->setValue(1);
374  $crs->setInfo($GLOBALS['lng']->txt('cal_setting_global_crs_vis_info'));
375  $crs->setChecked($this->settings->isCourseCalendarEnabled());
376  $this->form->addItem($crs);
377 
378  $grp = new ilCheckboxInputGUI($GLOBALS['lng']->txt('cal_setting_global_grp_vis'),'visible_grp');
379  $grp->setInfo($GLOBALS['lng']->txt('cal_setting_global_grp_vis_info'));
380  $grp->setValue(1);
381  $grp->setInfo($GLOBALS['lng']->txt('cal_setting_global_grp_vis_info'));
382  $grp->setChecked($this->settings->isGroupCalendarEnabled());
383  $this->form->addItem($grp);
384 
385 
386 
387 
388  // Notifications
389  $not = new ilFormSectionHeaderGUI();
390  $not->setTitle($this->lng->txt('notifications'));
391  $this->form->addItem($not);
392 
393  $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_notification'),'cn');
394  $cgn->setOptionTitle($this->lng->txt('cal_notification_crsgrp'));
395  $cgn->setValue(1);
396  $cgn->setChecked($this->settings->isNotificationEnabled());
397  $cgn->setInfo($this->lng->txt('cal_adm_notification_info'));
398  $this->form->addItem($cgn);
399 
400  $cnu = new ilCheckboxInputGUI('','cnu');
401  $cnu->setOptionTitle($this->lng->txt('cal_notification_users'));
402  $cnu->setValue(1);
403  $cnu->setChecked($this->settings->isUserNotificationEnabled());
404  $cnu->setInfo($this->lng->txt('cal_adm_notification_user_info'));
405  $this->form->addItem($cnu);
406 
407 
408  // Registration
409  $book = new ilFormSectionHeaderGUI();
410  $book->setTitle($this->lng->txt('cal_registrations'));
411  $this->form->addItem($book);
412 
413  $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_cg_registrations'),'cgr');
414  $cgn->setValue(1);
415  $cgn->setChecked($this->settings->isCGRegistrationEnabled());
416  $cgn->setInfo($this->lng->txt('cal_cg_registration_info'));
417  $this->form->addItem($cgn);
418 
419  // Synchronisation cache
420  $sec = new ilFormSectionHeaderGUI();
421  $sec->setTitle($this->lng->txt('cal_cache_settings'));
422  $this->form->addItem($sec);
423 
424  $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_sync_cache'),'sync_cache');
425  $cache->setValue((int) $this->settings->isSynchronisationCacheEnabled());
426  $cache->setInfo($this->lng->txt('cal_sync_cache_info'));
427  $cache->setRequired(true);
428 
429  $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_disabled'),0);
430  $cache->addOption($sync_cache);
431 
432  $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_enabled'),1);
433  $cache->addOption($sync_cache);
434 
435  $cache_t = new ilNumberInputGUI('','sync_cache_time');
436  $cache_t->setValue($this->settings->getSynchronisationCacheMinutes());
437  $cache_t->setMinValue(0);
438  $cache_t->setSize(3);
439  $cache_t->setMaxLength(3);
440  $cache_t->setSuffix($this->lng->txt('form_minutes'));
441  $sync_cache->addSubItem($cache_t);
442 
443  $this->form->addItem($cache);
444 
445  // Calendar cache
446  $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_cache'),'cache');
447  $cache->setValue((int) $this->settings->isCacheUsed());
448  $cache->setInfo($this->lng->txt('cal_cache_info'));
449  $cache->setRequired(true);
450 
451  $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_disabled'),0);
452  $cache->addOption($sync_cache);
453 
454  $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_enabled'),1);
455  $cache->addOption($sync_cache);
456 
457  $cache_t = new ilNumberInputGUI('','cache_time');
458  $cache_t->setValue($this->settings->getCacheMinutes());
459  $cache_t->setMinValue(0);
460  $cache_t->setSize(3);
461  $cache_t->setMaxLength(3);
462  $cache_t->setSuffix($this->lng->txt('form_minutes'));
463  $sync_cache->addSubItem($cache_t);
464  $this->form->addItem($cache);
465  }
466 
467 
468 }
469 ?>