ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarChangedAppointmentsTableGUI.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.ilCalendarCategories.php');
25 include_once('./Services/Table/classes/class.ilTable2GUI.php');
26 
35 {
36  private $cat_id = 0;
37  private $categories = null;
38  private $is_editable = false;
39 
47  public function __construct($a_parent_obj,$a_parent_cmd)
48  {
49  global $lng,$ilCtrl;
50 
51 
52  $this->categories = ilCalendarCategories::_getInstance();
53 
54  $this->lng = $lng;
55  $this->lng->loadLanguageModule('dateplaner');
56  $this->ctrl = $ilCtrl;
57 
58  $this->setId('calinbox');
59 
60  parent::__construct($a_parent_obj,$a_parent_cmd);
61  $this->setFormName('appointments');
62  $this->addColumn($this->lng->txt('date'),'begin',"30%");
63  $this->addColumn($this->lng->txt('title'),'title',"40%");
64  #$this->addColumn($this->lng->txt('cal_duration'),'duration',"15%");
65  $this->addColumn($this->lng->txt('cal_recurrences'),'frequence',"15%");
66  $this->addColumn($this->lng->txt('last_update'),'last_update',"15%");
67 
68 
69  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
70  $this->setRowTemplate("tpl.show_changed_appointment_row.html","Services/Calendar");
71 
72  $this->setShowRowsSelector(true);
73  $this->enable('sort');
74  $this->enable('header');
75  $this->enable('numinfo');
76 
77  $this->setDefaultOrderField('begin');
78  $this->setDefaultOrderDirection('asc');
79  }
80 
81 
89  protected function fillRow($a_set)
90  {
91  global $ilUser, $lng;
92 
93  if ($a_set["milestone"])
94  {
95  $this->tpl->setCurrentBlock("img_ms");
96  $this->tpl->setVariable("IMG_MS", ilUtil::getImagePath("icon_ms_s.png"));
97  $this->tpl->setVariable("ALT_MS", $lng->txt("cal_milestone"));
98  $this->tpl->parseCurrentBlock();
99  }
100 
101  $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
102 
103  $this->tpl->setVariable('VAL_TITLE_LINK',$a_set['title']);
104  $this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_set['id']);
105  $this->tpl->setVariable('VAL_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
106 
107  switch($a_set['frequence'])
108  {
109  case IL_CAL_FREQ_DAILY:
110  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_daily'));
111  break;
112 
113  case IL_CAL_FREQ_WEEKLY:
114  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_weekly'));
115  break;
116 
117  case IL_CAL_FREQ_MONTHLY:
118  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_monthly'));
119  break;
120 
121  case IL_CAL_FREQ_YEARLY:
122  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_yearly'));
123  break;
124 
125  default:
126  #$this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence'));
127  break;
128  }
129  if($a_set['fullday'])
130  {
132  new ilDate($a_set['begin'],IL_CAL_UNIX),
133  new ilDate($a_set['end'],IL_CAL_UNIX)
134  );
135  }
136  else
137  {
139  new ilDateTime($a_set['begin'],IL_CAL_UNIX),
140  new ilDateTime($a_set['end'],IL_CAL_UNIX)
141  );
142  }
143  $this->tpl->setVariable('VAL_BEGIN',$date);
144  /*
145  if($a_set['duration'])
146  {
147  if($a_set['milestone'])
148  {
149  $this->tpl->setVariable('VAL_DURATION','-');
150  }
151  else
152  {
153  $this->tpl->setVariable('VAL_DURATION',ilFormat::_secondsToString($a_set['duration']));
154  }
155  }
156  else
157  {
158  $this->tpl->setVariable('VAL_DURATION','');
159  }
160  */
161  $update = new ilDateTime($a_set['last_update'],IL_CAL_UNIX,$ilUser->getTimeZone());
162  $this->tpl->setVariable('VAL_LAST_UPDATE',ilDatePresentation::formatDate($update));
163 
164 
165  }
166 
173  public function setAppointments($a_apps)
174  {
175  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
176  include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
177  $appointments = array();
178 
179  foreach($a_apps as $event)
180  {
181  $entry = $event['event'];
182 
183  $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
184 
185  $tmp_arr['id'] = $entry->getEntryId();
186  $tmp_arr['milestone'] = $entry->isMilestone();
187  $tmp_arr['title'] = $entry->getPresentationTitle();
188  $tmp_arr['description'] = $entry->getDescription();
189  $tmp_arr['fullday'] = $entry->isFullday();
190  #$tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
191  #$tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
192 
193  $tmp_arr['begin'] = $event['dstart'];
194  $tmp_arr['end'] = $event['dend'];
195 
196  $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
197  if($tmp_arr['fullday'])
198  {
199  $tmp_arr['duration'] += (60 * 60 * 24);
200  }
201  if(!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin'])
202  {
203  $tmp_arr['duration'] = '';
204  }
205 
206  $tmp_arr['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX);
207  $tmp_arr['frequence'] = $rec->getFrequenceType();
208 
209  $appointments[] = $tmp_arr;
210  }
211 
212  //cuts appointments array after Limit
213  $appointments = array_slice($appointments, 0, $this->getLimit());
214 
215  $this->setData($appointments ? $appointments : array());
216  }
217 
218 }
219 ?>