ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarInboxGUI.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.ilDate.php');
25 include_once('Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php');
26 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
27 include_once('Services/Calendar/classes/class.ilCalendarAppointmentColors.php');
28 include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
29 
30 
31 
42 {
43  protected $seed = null;
44  protected $user_settings = null;
45 
46  protected $lng;
47  protected $ctrl;
48  protected $tabs_gui;
49  protected $tpl;
50 
51  protected $timezone = 'UTC';
52 
60  public function __construct(ilDate $seed_date)
61  {
62  global $ilCtrl, $lng, $ilUser,$ilTabs,$tpl;
63 
64  $this->seed = $seed_date;
65 
66  $this->tpl = $tpl;
67  $this->lng = $lng;
68  $this->ctrl = $ilCtrl;
69  $this->tabs_gui = $ilTabs;
70 
71  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
72  $this->app_colors = new ilCalendarAppointmentColors($ilUser->getId());
73 
74  $this->timezone = $ilUser->getTimeZone();
75  }
76 
83  public function executeCommand()
84  {
85  global $ilCtrl,$tpl;
86 
87  $next_class = $ilCtrl->getNextClass();
88  switch($next_class)
89  {
90  case 'ilcalendarappointmentgui':
91  $this->ctrl->setReturn($this,'');
92  $this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
93 
94  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
95  $app = new ilCalendarAppointmentGUI($this->seed,(int) $_GET['app_id']);
96  $this->ctrl->forwardCommand($app);
97  break;
98 
99  default:
100  $cmd = $this->ctrl->getCmd("inbox");
101  $this->$cmd();
102  $tpl->setContent($this->tpl->get());
103  break;
104  }
105 
106  return true;
107  }
108 
115  protected function inbox()
116  {
117  $this->tpl = new ilTemplate('tpl.inbox.html',true,true,'Services/Calendar');
118 
119  include_once('./Services/Calendar/classes/class.ilCalendarInboxSharedTableGUI.php');
120  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
121 
122  $table = new ilCalendarInboxSharedTableGUI($this,'inbox');
123  $table->setCalendars(ilCalendarShared::getSharedCalendarsForUser());
124 
125  if($table->parse())
126  {
127  $this->tpl->setVariable('SHARED_CAL_TABLE',$table->getHTML());
128  }
129 
130  $schedule = new ilCalendarSchedule($this->seed,ilCalendarSchedule::TYPE_INBOX);
131  $events = $schedule->getChangedEvents(true);
132 
133  include_once('./Services/Calendar/classes/class.ilCalendarChangedAppointmentsTableGUI.php');
134 
135  $table_gui = new ilCalendarChangedAppointmentsTableGUI($this,'inbox');
136  $table_gui->setTitle($this->lng->txt('cal_changed_events_header'));
137  $table_gui->setAppointments($events);
138 
139  $this->tpl->setVariable('CHANGED_TABLE',$table_gui->getHTML());
140 
141  }
142 
149  protected function acceptShared()
150  {
151  global $ilUser;
152 
153  if(!$_POST['cal_ids'] or !is_array($_POST['cal_ids']))
154  {
155  ilUtil::sendInfo($this->lng->txt('select_one'));
156  $this->inbox();
157  return false;
158  }
159 
160  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
161  $status = new ilCalendarSharedStatus($ilUser->getId());
162 
163  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
164  foreach($_POST['cal_ids'] as $calendar_id)
165  {
166  if(!ilCalendarShared::isSharedWithUser($ilUser->getId(),$calendar_id))
167  {
168  ilUtil::sendInfo($this->lng->txt('permission_denied'));
169  $this->inbox();
170  return false;
171  }
172  $status->accept($calendar_id);
173  }
174 
175  ilUtil::sendInfo($this->lng->txt('settings_saved'),true);
176  // redfirect for loading new calendar+
177  $this->ctrl->redirect($this,'inbox');
178  return true;
179  }
180 
187  protected function declineShared()
188  {
189  global $ilUser;
190 
191  if(!$_POST['cal_ids'] or !is_array($_POST['cal_ids']))
192  {
193  ilUtil::sendInfo($this->lng->txt('select_one'));
194  $this->inbox();
195  return false;
196  }
197 
198  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
199  $status = new ilCalendarSharedStatus($ilUser->getId());
200 
201  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
202  foreach($_POST['cal_ids'] as $calendar_id)
203  {
204  if(!ilCalendarShared::isSharedWithUser($ilUser->getId(),$calendar_id))
205  {
206  ilUtil::sendInfo($this->lng->txt('permission_denied'));
207  $this->inbox();
208  return false;
209  }
210  $status->decline($calendar_id);
211  }
212 
213  ilUtil::sendInfo($this->lng->txt('settings_saved'));
214  $this->inbox();
215  return true;
216  }
217 
218 }
219 ?>