ILIAS  Release_3_10_x_branch Revision 61812
 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 
34 include_once('./classes/class.ilObjectGUI.php');
35 
37 {
38 
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 = 'cals';
49  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
50 
51  $this->lng = $lng;
52  $this->lng->loadLanguageModule('dateplaner');
53  $this->lng->loadLanguageModule('jscalendar');
54  }
55 
62  public function executeCommand()
63  {
64  global $ilErr,$ilAccess;
65 
66  $next_class = $this->ctrl->getNextClass($this);
67  $cmd = $this->ctrl->getCmd();
68 
69  $this->prepareOutput();
70 
71  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
72  {
73  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
74  }
75 
76  switch($next_class)
77  {
78  case 'ilpermissiongui':
79  $this->tabs_gui->setTabActive('perm_settings');
80  include_once("./classes/class.ilPermissionGUI.php");
81  $perm_gui =& new ilPermissionGUI($this);
82  $ret =& $this->ctrl->forwardCommand($perm_gui);
83  break;
84 
85  default:
86  $this->tabs_gui->setTabActive('settings');
87  $this->initCalendarSettings();
88  if(!$cmd || $cmd == 'view')
89  {
90  $cmd = "settings";
91  }
92 
93  $this->$cmd();
94  break;
95  }
96  return true;
97  }
98 
99 
106  public function getAdminTabs()
107  {
108  global $rbacsystem, $ilAccess;
109 
110  if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
111  {
112  $this->tabs_gui->addTarget("settings",
113  $this->ctrl->getLinkTarget($this, "settings"),
114  array("settings", "view"));
115  }
116 
117  if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
118  {
119  $this->tabs_gui->addTarget("perm_settings",
120  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
121  array(),'ilpermissiongui');
122  }
123  }
124 
128  public function settings()
129  {
130  include_once('./Services/Calendar/classes/class.ilDateTime.php');
131 
132  include_once('./Services/Calendar/classes/iCal/class.ilICalParser.php');
133 
134  include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php');
135  include_once('./Services/Calendar/classes/class.ilCalendarRecurrence.php');
136  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
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->setDefaultTimeFormat((int) $_POST['default_time_format']);
208  $this->settings->save();
209 
210  ilUtil::sendInfo($this->lng->txt('settings_saved'));
211  $this->settings();
212  }
213 
219  protected function initCalendarSettings()
220  {
221  include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
223  }
224 
230  protected function initFormSettings()
231  {
232  if(is_object($this->form))
233  {
234  return true;
235  }
236  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
237  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
238 
239  $this->form = new ilPropertyFormGUI();
240  $this->form->setFormAction($this->ctrl->getFormAction($this));
241  $this->form->setTitle($this->lng->txt('cal_global_settings'));
242  $this->form->addCommandButton('save',$this->lng->txt('save'));
243  #$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
244 
245  $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'),'enable');
246  $check->setValue(1);
247  $check->setChecked($this->settings->isEnabled() ? true : false);
248  $this->form->addItem($check);
249 
250  $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
252  $this->form->addItem($server_tz);
253 
254  $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'),'default_timezone');
256  $select->setInfo($this->lng->txt('cal_def_timezone_info'));
257  $select->setValue($this->settings->getDefaultTimeZone());
258  $this->form->addItem($select);
259 
260  $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'),'default_time_format');
261  $select->setOptions(array(
264  $select->setInfo($this->lng->txt('cal_def_time_format_info'));
265  $select->setValue($this->settings->getDefaultTimeFormat());
266  $this->form->addItem($select);
267 
268 
269  $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'),'default_week_start');
270  $radio->setValue($this->settings->getDefaultWeekStart());
271 
272  $option = new ilRadioOption($this->lng->txt('l_su'),0);
273  $radio->addOption($option);
274  $option = new ilRadioOption($this->lng->txt('l_mo'),1);
275  $radio->addOption($option);
276 
277 
278  $this->form->addItem($radio);
279  }
280 }
281 ?>