ILIAS  Release_4_0_x_branch Revision 61816
 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 
37 {
38  protected $ctrl;
39  protected $lng;
40  protected $tpl;
41  protected $tabs_gui;
42 
50  public function __construct()
51  {
52  global $ilCtrl,$lng,$tpl,$ilTabs,$ilUser;
53 
54  $this->ctrl = $ilCtrl;
55  $this->lng = $lng;
56  $this->lng->loadLanguageModule('dateplaner');
57 
58  $this->tpl = $tpl;
59  $this->tabs_gui = $ilTabs;
60 
61 
62  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
63  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
64 
65  include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
67  {
69  }
70  else
71  {
73  }
74  }
75 
76 
84  public function executeCommand()
85  {
86  global $ilUser, $ilSetting,$tpl;
87 
88  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
89  if(!ilCalendarSettings::_getInstance()->isEnabled())
90  {
91  ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
92  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
93  }
94 
95  $this->initSeed();
96  $this->prepareOutput();
97 
98  $next_class = $this->getNextClass();
99  switch($next_class)
100  {
101  case 'ilcalendarinboxgui':
102  $this->tabs_gui->setSubTabActive('app_inbox');
103  $this->forwardToClass('ilcalendarinboxgui');
104  break;
105 
106  case 'ilcalendarmonthgui':
107  $this->tabs_gui->setSubTabActive('app_month');
108  $this->forwardToClass('ilcalendarmonthgui');
109  break;
110 
111  case 'ilcalendarweekgui':
112  $this->tabs_gui->setSubTabActive('app_week');
113  $this->forwardToClass('ilcalendarweekgui');
114  break;
115 
116  case 'ilcalendardaygui':
117  $this->tabs_gui->setSubTabActive('app_day');
118  $this->forwardToClass('ilcalendardaygui');
119  break;
120 
121  case 'ilcalendarusersettingsgui':
122  $this->ctrl->setReturn($this,'');
123  $this->tabs_gui->setSubTabActive('properties');
124  $this->setCmdClass('ilcalendarusersettingsgui');
125 
126  include_once('./Services/Calendar/classes/class.ilCalendarUserSettingsGUI.php');
127  $user_settings = new ilCalendarUserSettingsGUI();
128  $this->ctrl->forwardCommand($user_settings);
129  break;
130 
131  case 'ilcalendarappointmentgui':
132  $this->ctrl->setReturn($this,'');
133  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
134 
135  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
136  $app = new ilCalendarAppointmentGUI($this->seed,(int) $_GET['app_id']);
137  $this->ctrl->forwardCommand($app);
138  break;
139 
140  case 'ilcalendarcategorygui':
141  $this->ctrl->setReturn($this,'');
142  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
143 
144  include_once('Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
145  $category = new ilCalendarCategoryGUI($ilUser->getId(),$this->seed);
146  $this->ctrl->forwardCommand($category);
147  break;
148 
149  default:
150  $cmd = $this->ctrl->getCmd("show");
151  $this->$cmd();
152  break;
153  }
154 
155  $this->showSideBlocks();
156 
157  return true;
158  }
159 
165  public function getNextClass()
166  {
167  global $ilUser;
168 
169  if(strlen($next_class = $this->ctrl->getNextClass()))
170  {
171  return $next_class;
172  }
173  if($this->ctrl->getCmdClass() == strtolower(get_class($this)) or $this->ctrl->getCmdClass() == '')
174  {
175  return $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarinboxgui';
176  }
177  }
178 
179  public function setCmdClass($a_class)
180  {
181  // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
182  // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
183 
184  if($this->ctrl->getCmdClass() == strtolower(get_class($this)))
185  {
186  $this->ctrl->setCmdClass(strtolower($a_class));
187  }
188  return true;
189  }
190 
196  protected function forwardToClass($a_class)
197  {
198  global $ilUser;
199 
200  $ilUser->writePref('cal_last_class',$a_class);
201  switch($a_class)
202  {
203  case 'ilcalendarmonthgui':
204  $_SESSION['cal_last_tab'] = 'app_month';
205  $this->setCmdClass('ilcalendarmonthgui');
206  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
207  $month_gui = new ilCalendarMonthGUI($this->seed);
208  $this->ctrl->forwardCommand($month_gui);
209  break;
210 
211  case 'ilcalendarweekgui':
212  $_SESSION['cal_last_tab'] = 'app_week';
213  $this->setCmdClass('ilcalendarweekgui');
214  include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
215  $week_gui = new ilCalendarWeekGUI($this->seed);
216  $this->ctrl->forwardCommand($week_gui);
217  break;
218 
219  case 'ilcalendardaygui':
220  $_SESSION['cal_last_tab'] = 'app_day';
221  $this->setCmdClass('ilcalendardaygui');
222  include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
223  $day_gui = new ilCalendarDayGUI($this->seed);
224  $this->ctrl->forwardCommand($day_gui);
225  break;
226 
227  case 'ilcalendarinboxgui':
228  $_SESSION['cal_last_tab'] = 'app_inbox';
229  $this->setCmdClass('ilcalendarinboxgui');
230  include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
231  $inbox_gui = new ilCalendarinboxGUI($this->seed);
232  $this->ctrl->forwardCommand($inbox_gui);
233  break;
234 
235  }
236  }
237 
245  protected function loadHistory()
246  {
247  global $ilUser;
248 
249  $this->ctrl->setCmd('');
250  $history = $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarmonthgui';
251  $this->forwardToClass($history);
252  }
253 
261  protected function showSideBlocks()
262  {
263  global $ilUser;
264 
265  $tpl = new ilTemplate('tpl.cal_side_block.html',true,true,'Services/Calendar');
266 
267  include_once('./Services/Calendar/classes/class.ilMiniCalendarGUI.php');
268  $mini = new ilMiniCalendarGUI($this->seed, $this);
269 // $mini->setPresentationMode(ilMiniCalendarGUI::PRESENTATION_CALENDAR);
270  $tpl->setVariable('MINICAL',$mini->getHTML());
271 
272  include_once('./Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
273  $cat = new ilCalendarCategoryGUI($ilUser->getId(),$this->seed);
274  $tpl->setVariable('CATEGORIES',$cat->getHTML());
275 
276  $this->tpl->setLeftContent($tpl->get());
277  }
278 
279 
287  public function show()
288  {
289  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
290  }
291 
292 
298  protected function prepareOutput()
299  {
300  $this->tabs_gui->addSubTabTarget('app_inbox',$this->ctrl->getLinkTargetByClass('ilCalendarInboxGUI',''));
301  $this->tabs_gui->addSubTabTarget('app_day',$this->ctrl->getLinkTargetByClass('ilCalendarDayGUI',''));
302  $this->tabs_gui->addSubTabTarget('app_week',$this->ctrl->getLinkTargetByClass('ilCalendarWeekGUI',''));
303  $this->tabs_gui->addSubTabTarget('app_month',$this->ctrl->getLinkTargetByClass('ilCalendarMonthGUI',''));
304  $this->tabs_gui->addSubTabTarget('properties',$this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI',''));
305  }
306 
312  public function initSeed()
313  {
314  include_once('Services/Calendar/classes/class.ilDate.php');
315  $this->seed = $_REQUEST['seed'] ? new ilDate($_REQUEST['seed'],IL_CAL_DATE) : new ilDate(date('Y-m-d',time()),IL_CAL_DATE);
316  $_GET['seed'] = $this->seed->get(IL_CAL_DATE,'');
317  $this->ctrl->saveParameter($this,array('seed'));
318  }
319 
320 }
321 ?>