ILIAS  Release_3_10_x_branch Revision 61812
 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 
36 {
37  protected $ctrl;
38  protected $lng;
39  protected $tpl;
40  protected $tabs_gui;
41 
49  public function __construct()
50  {
51  global $ilCtrl,$lng,$tpl,$ilTabs,$ilUser;
52 
53  $this->ctrl = $ilCtrl;
54  $this->lng = $lng;
55  $this->lng->loadLanguageModule('dateplaner');
56 
57  $this->tpl = $tpl;
58  $this->tabs_gui = $ilTabs;
59 
60 
61  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
62  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
64 
65  }
66 
67 
75  public function executeCommand()
76  {
77  global $ilUser, $ilSetting,$tpl;
78 
79  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
80  if(!ilCalendarSettings::_getInstance()->isEnabled())
81  {
82  ilUtil::sendInfo($this->lng->txt('permission_denied'),true);
83  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
84  }
85 
86  $this->initSeed();
87  $this->prepareOutput();
88 
89  $next_class = $this->getNextClass();
90  switch($next_class)
91  {
92  case 'ilcalendarinboxgui':
93  $this->tabs_gui->setSubTabActive('app_inbox');
94  $this->forwardToClass('ilcalendarinboxgui');
95  break;
96 
97  case 'ilcalendarmonthgui':
98  $this->tabs_gui->setSubTabActive('app_month');
99  $this->forwardToClass('ilcalendarmonthgui');
100  break;
101 
102  case 'ilcalendarweekgui':
103  $this->tabs_gui->setSubTabActive('app_week');
104  $this->forwardToClass('ilcalendarweekgui');
105  break;
106 
107  case 'ilcalendardaygui':
108  $this->tabs_gui->setSubTabActive('app_day');
109  $this->forwardToClass('ilcalendardaygui');
110  break;
111 
112  case 'ilcalendarusersettingsgui':
113  $this->ctrl->setReturn($this,'');
114  $this->tabs_gui->setSubTabActive('properties');
115  $this->setCmdClass('ilcalendarusersettingsgui');
116 
117  include_once('./Services/Calendar/classes/class.ilCalendarUserSettingsGUI.php');
118  $user_settings = new ilCalendarUserSettingsGUI();
119  $this->ctrl->forwardCommand($user_settings);
120  break;
121 
122  case 'ilcalendarappointmentgui':
123  $this->ctrl->setReturn($this,'');
124  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
125 
126  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
127  $app = new ilCalendarAppointmentGUI($this->seed,(int) $_GET['app_id']);
128  $this->ctrl->forwardCommand($app);
129  break;
130 
131  case 'ilcalendarcategorygui':
132  $this->ctrl->setReturn($this,'');
133  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
134 
135  include_once('Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
136  $category = new ilCalendarCategoryGUI($ilUser->getId(),$this->seed);
137  $this->ctrl->forwardCommand($category);
138  break;
139 
140  default:
141  $cmd = $this->ctrl->getCmd("show");
142  $this->$cmd();
143  break;
144  }
145 
146  $this->showSideBlocks();
147 
148  return true;
149  }
150 
156  public function getNextClass()
157  {
158  global $ilUser;
159 
160  if(strlen($next_class = $this->ctrl->getNextClass()))
161  {
162  return $next_class;
163  }
164  if($this->ctrl->getCmdClass() == strtolower(get_class($this)) or $this->ctrl->getCmdClass() == '')
165  {
166  return $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarinboxgui';
167  }
168  }
169 
170  public function setCmdClass($a_class)
171  {
172  // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
173  // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
174 
175  if($this->ctrl->getCmdClass() == strtolower(get_class($this)))
176  {
177  $this->ctrl->setCmdClass(strtolower($a_class));
178  }
179  return true;
180  }
181 
187  protected function forwardToClass($a_class)
188  {
189  global $ilUser;
190 
191  $ilUser->writePref('cal_last_class',$a_class);
192  switch($a_class)
193  {
194  case 'ilcalendarmonthgui':
195  $_SESSION['cal_last_tab'] = 'app_month';
196  $this->setCmdClass('ilcalendarmonthgui');
197  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
198  $month_gui = new ilCalendarMonthGUI($this->seed);
199  $this->ctrl->forwardCommand($month_gui);
200  break;
201 
202  case 'ilcalendarweekgui':
203  $_SESSION['cal_last_tab'] = 'app_week';
204  $this->setCmdClass('ilcalendarweekgui');
205  include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
206  $week_gui = new ilCalendarWeekGUI($this->seed);
207  $this->ctrl->forwardCommand($week_gui);
208  break;
209 
210  case 'ilcalendardaygui':
211  $_SESSION['cal_last_tab'] = 'app_day';
212  $this->setCmdClass('ilcalendardaygui');
213  include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
214  $day_gui = new ilCalendarDayGUI($this->seed);
215  $this->ctrl->forwardCommand($day_gui);
216  break;
217 
218  case 'ilcalendarinboxgui':
219  $_SESSION['cal_last_tab'] = 'app_inbox';
220  $this->setCmdClass('ilcalendarinboxgui');
221  include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
222  $inbox_gui = new ilCalendarinboxGUI($this->seed);
223  $this->ctrl->forwardCommand($inbox_gui);
224  break;
225 
226  }
227  }
228 
236  protected function loadHistory()
237  {
238  global $ilUser;
239 
240  $this->ctrl->setCmd('');
241  $history = $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarmonthgui';
242  $this->forwardToClass($history);
243  }
244 
252  protected function showSideBlocks()
253  {
254  global $ilUser;
255 
256  $tpl = new ilTemplate('tpl.cal_side_block.html',true,true,'Services/Calendar');
257 
258  include_once('./Services/Calendar/classes/class.ilMiniCalendarGUI.php');
259  $mini = new ilMiniCalendarGUI($this->seed, $this);
260 // $mini->setPresentationMode(ilMiniCalendarGUI::PRESENTATION_CALENDAR);
261  $tpl->setVariable('MINICAL',$mini->getHTML());
262 
263  include_once('./Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
264  $cat = new ilCalendarCategoryGUI($ilUser->getId(),$this->seed);
265  $tpl->setVariable('CATEGORIES',$cat->getHTML());
266 
267  $this->tpl->setLeftContent($tpl->get());
268  }
269 
270 
278  public function show()
279  {
280  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
281  }
282 
283 
289  protected function prepareOutput()
290  {
291  $this->tabs_gui->addSubTabTarget('app_inbox',$this->ctrl->getLinkTargetByClass('ilCalendarInboxGUI',''));
292  $this->tabs_gui->addSubTabTarget('app_day',$this->ctrl->getLinkTargetByClass('ilCalendarDayGUI',''));
293  $this->tabs_gui->addSubTabTarget('app_week',$this->ctrl->getLinkTargetByClass('ilCalendarWeekGUI',''));
294  $this->tabs_gui->addSubTabTarget('app_month',$this->ctrl->getLinkTargetByClass('ilCalendarMonthGUI',''));
295  $this->tabs_gui->addSubTabTarget('properties',$this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI',''));
296  }
297 
303  public function initSeed()
304  {
305  include_once('Services/Calendar/classes/class.ilDate.php');
306  $this->seed = $_REQUEST['seed'] ? new ilDate($_REQUEST['seed'],IL_CAL_DATE) : new ilDate(date('Y-m-d',time()),IL_CAL_DATE);
307  $_GET['seed'] = $this->seed->get(IL_CAL_DATE,'');
308  $this->ctrl->saveParameter($this,array('seed'));
309  }
310 
311 }
312 ?>