ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarPresentationGUI.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 
24 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
25 
39 {
40  protected $ctrl;
41  protected $lng;
42  protected $tpl;
43  protected $tabs_gui;
44 
52  public function __construct()
53  {
54  global $ilCtrl,$lng,$tpl,$ilTabs,$ilUser;
55 
56  $this->ctrl = $ilCtrl;
57  $this->lng = $lng;
58  $this->lng->loadLanguageModule('dateplaner');
59 
60  $this->tpl = $tpl;
61  $this->tabs_gui = $ilTabs;
62 
63 
64  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
65  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
66 
67  include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
69  {
71  }
72  else
73  {
75  }
76  }
77 
78 
86  public function executeCommand()
87  {
88  global $ilUser, $ilSetting,$tpl;
89 
90  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
91  if(!ilCalendarSettings::_getInstance()->isEnabled())
92  {
93  ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
94  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
95  }
96 
97  $this->initSeed();
98  $this->prepareOutput();
99 
100  $next_class = $this->getNextClass();
101  switch($next_class)
102  {
103  case 'ilcalendarinboxgui':
104  $this->tabs_gui->setSubTabActive('app_inbox');
105  $this->forwardToClass('ilcalendarinboxgui');
106  break;
107 
108  case 'ilconsultationhoursgui':
109  $this->tabs_gui->setSubTabActive('app_consultation_hours');
110  $this->tabs_gui->clearTargets();
111 
112  // No side blocks
113  $this->tabs_gui->setBackTarget(
114  $this->lng->txt('cal_back_to_cal'),
115  $this->ctrl->getLinkTargetByClass($this->readLastClass())
116  );
117 
118  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php';
119  $gui = new ilConsultationHoursGUI();
120  $this->ctrl->forwardCommand($gui);
121  return true;
122 
123  case 'ilcalendarmonthgui':
124  $this->tabs_gui->setSubTabActive('app_month');
125  $this->forwardToClass('ilcalendarmonthgui');
126  break;
127 
128  case 'ilcalendarweekgui':
129  $this->tabs_gui->setSubTabActive('app_week');
130  $this->forwardToClass('ilcalendarweekgui');
131  break;
132 
133  case 'ilcalendardaygui':
134  $this->tabs_gui->setSubTabActive('app_day');
135  $this->forwardToClass('ilcalendardaygui');
136  break;
137 
138  case 'ilcalendarusersettingsgui':
139  $this->ctrl->setReturn($this,'');
140  $this->tabs_gui->setSubTabActive('properties');
141  $this->setCmdClass('ilcalendarusersettingsgui');
142 
143  include_once('./Services/Calendar/classes/class.ilCalendarUserSettingsGUI.php');
144  $user_settings = new ilCalendarUserSettingsGUI();
145  $this->ctrl->forwardCommand($user_settings);
146  // No side blocks
147  return true;
148 
149  case 'ilcalendarappointmentgui':
150  $this->ctrl->setReturn($this,'');
151  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
152 
153  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
154  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed,(int) $_GET['app_id']);
155  $this->ctrl->forwardCommand($app);
156  break;
157 
158  case 'ilcalendarcategorygui':
159  $this->ctrl->setReturn($this,'');
160 
161  include_once('Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
162  $category = new ilCalendarCategoryGUI($ilUser->getId(),$this->seed);
163  if($this->ctrl->forwardCommand($category))
164  {
165  $this->tabs_gui->setSubTabActive("cal_manage");
166 
167  // no side blocks
168  return;
169  }
170  else
171  {
172  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
173  break;
174  }
175 
176  default:
177  $cmd = $this->ctrl->getCmd("show");
178 
179  $this->$cmd();
180  break;
181  }
182 
183  $this->showSideBlocks();
184 
185  return true;
186  }
187 
193  public function getNextClass()
194  {
195  global $ilUser;
196 
197  if(strlen($next_class = $this->ctrl->getNextClass()))
198  {
199  return $next_class;
200  }
201  if($this->ctrl->getCmdClass() == strtolower(get_class($this)) or $this->ctrl->getCmdClass() == '')
202  {
203  return $this->readLastClass();
204  }
205  }
206 
211  public function readLastClass()
212  {
213  global $ilUser;
214 
215  return $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarinboxgui';
216 
217  }
218 
219  public function setCmdClass($a_class)
220  {
221  // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
222  // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
223 
224  if($this->ctrl->getCmdClass() == strtolower(get_class($this)))
225  {
226  $this->ctrl->setCmdClass(strtolower($a_class));
227  }
228  return true;
229  }
230 
236  protected function forwardToClass($a_class)
237  {
238  global $ilUser;
239 
240  switch($a_class)
241  {
242  case 'ilcalendarmonthgui':
243  $ilUser->writePref('cal_last_class',$a_class);
244  $_SESSION['cal_last_tab'] = 'app_month';
245  $this->setCmdClass('ilcalendarmonthgui');
246  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
247  $month_gui = new ilCalendarMonthGUI($this->seed);
248  $this->ctrl->forwardCommand($month_gui);
249  break;
250 
251  case 'ilcalendarweekgui':
252  $ilUser->writePref('cal_last_class',$a_class);
253  $_SESSION['cal_last_tab'] = 'app_week';
254  $this->setCmdClass('ilcalendarweekgui');
255  include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
256  $week_gui = new ilCalendarWeekGUI($this->seed);
257  $this->ctrl->forwardCommand($week_gui);
258  break;
259 
260  case 'ilcalendardaygui':
261  $ilUser->writePref('cal_last_class',$a_class);
262  $_SESSION['cal_last_tab'] = 'app_day';
263  $this->setCmdClass('ilcalendardaygui');
264  include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
265  $day_gui = new ilCalendarDayGUI($this->seed);
266  $this->ctrl->forwardCommand($day_gui);
267  break;
268 
269  case 'ilcalendarinboxgui':
270  $ilUser->writePref('cal_last_class',$a_class);
271  $_SESSION['cal_last_tab'] = 'app_inbox';
272  $this->setCmdClass('ilcalendarinboxgui');
273  include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
274  $inbox_gui = new ilCalendarinboxGUI($this->seed);
275  $this->ctrl->forwardCommand($inbox_gui);
276  break;
277 
278  }
279  }
280 
288  protected function loadHistory()
289  {
290  global $ilUser;
291 
292  $this->ctrl->setCmd('');
293  $history = $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarmonthgui';
294  $this->forwardToClass($history);
295  }
296 
304  protected function showSideBlocks()
305  {
306  global $ilUser;
307 
308  $tpl = new ilTemplate('tpl.cal_side_block.html',true,true,'Services/Calendar');
309 
310  include_once('./Services/Calendar/classes/class.ilMiniCalendarGUI.php');
311  $mini = new ilMiniCalendarGUI($this->seed, $this);
312 // $mini->setPresentationMode(ilMiniCalendarGUI::PRESENTATION_CALENDAR);
313  $tpl->setVariable('MINICAL',$mini->getHTML());
314 
315  include_once('./Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
316  $cat = new ilCalendarCategoryGUI($ilUser->getId(),$this->seed);
317  $tpl->setVariable('CATEGORIES',$cat->getHTML());
318 
319  $this->tpl->setLeftContent($tpl->get());
320  }
321 
322 
330  public function show()
331  {
332  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
333  }
334 
335 
341  protected function prepareOutput()
342  {
343  global $rbacsystem;
344 
345  $this->tabs_gui->addSubTabTarget('app_inbox',$this->ctrl->getLinkTargetByClass('ilCalendarInboxGUI',''));
346 
347  if(
348  $rbacsystem->checkAccess('add_consultation_hours', ilCalendarSettings::_getInstance()->getCalendarSettingsId()) and
349  ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
350  )
351  {
352  $this->tabs_gui->addSubTabTarget('app_consultation_hours',$this->ctrl->getLinkTargetByClass('ilConsultationHoursGUI',''));
353  }
354  $this->tabs_gui->addSubTabTarget('app_day',$this->ctrl->getLinkTargetByClass('ilCalendarDayGUI',''));
355  $this->tabs_gui->addSubTabTarget('app_week',$this->ctrl->getLinkTargetByClass('ilCalendarWeekGUI',''));
356  $this->tabs_gui->addSubTabTarget('app_month',$this->ctrl->getLinkTargetByClass('ilCalendarMonthGUI',''));
357  $this->tabs_gui->addSubTabTarget('cal_manage',$this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI','manage'));
358  $this->tabs_gui->addSubTabTarget('properties',$this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI',''));
359  }
360 
366  public function initSeed()
367  {
368  include_once('Services/Calendar/classes/class.ilDate.php');
369  $this->seed = $_REQUEST['seed'] ? new ilDate($_REQUEST['seed'],IL_CAL_DATE) : new ilDate(date('Y-m-d',time()),IL_CAL_DATE);
370  $_GET['seed'] = $this->seed->get(IL_CAL_DATE,'');
371  $this->ctrl->saveParameter($this,array('seed'));
372  }
373 
374 }
375 ?>