ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarAppointmentsTableGUI.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');
33 {
34  private $cat_id = 0;
35  private $categories = null;
36  private $is_editable = false;
37 
45  public function __construct($a_parent_obj,$a_category_id)
46  {
47  global $lng,$ilCtrl;
48 
49 
50  $this->categories = ilCalendarCategories::_getInstance();
51  $this->cat_id = $a_category_id;
52  $this->is_editable = $this->categories->isEditable($this->cat_id);
53 
54  $this->lng = $lng;
55  $this->lng->loadLanguageModule('dateplaner');
56  $this->ctrl = $ilCtrl;
57 
58  parent::__construct($a_parent_obj,'edit');
59  $this->setFormName('appointments');
60  $this->addColumn('','f',"1");
61  $this->addColumn($this->lng->txt('title'),'title',"50%");
62  $this->addColumn($this->lng->txt('cal_start'),'begin',"20%");
63  $this->addColumn($this->lng->txt('cal_duration'),'duration',"20%");
64  $this->addColumn($this->lng->txt('cal_recurrences'),'frequence',"10%");
65 
66  if($this->is_editable)
67  {
68  $this->addMultiCommand('askDeleteAppointments',$this->lng->txt('delete'));
69  $this->enable('select_all');
70  }
71  else
72  {
73  $this->disable('select_all');
74  }
75 
76  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
77  $this->setRowTemplate("tpl.show_appointment_row.html","Services/Calendar");
78  $this->enable('sort');
79  $this->enable('header');
80  $this->enable('numinfo');
81 
82  $this->setDefaultOrderField('begin');
83 
84  $this->setSelectAllCheckbox('appointments');
85  $this->setPrefix('apps');
86  }
87 
88 
96  protected function fillRow($a_set)
97  {
98  global $ilUser;
99 
100 
101  if($a_set['deletable'])
102  {
103  $this->tpl->setVariable('VAL_ID',$a_set['id']);
104  }
105 
106  $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
107 
108  $this->tpl->setVariable('VAL_TITLE_LINK',$a_set['title']);
109  $this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_set['id']);
110  $this->tpl->setVariable('VAL_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
111 
112  switch($a_set['frequence'])
113  {
114  case IL_CAL_FREQ_DAILY:
115  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_daily'));
116  break;
117 
118  case IL_CAL_FREQ_WEEKLY:
119  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_weekly'));
120  break;
121 
122  case IL_CAL_FREQ_MONTHLY:
123  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_monthly'));
124  break;
125 
126  case IL_CAL_FREQ_YEARLY:
127  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_yearly'));
128  break;
129 
130  default:
131  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence'));
132  break; $this->addColumn($this->lng->txt('cal_duration'),'duration',"20%");
133  }
134  // TOD: Localization
135  if($a_set['fullday'])
136  {
137  $start = new ilDate($a_set['begin'],IL_CAL_UNIX);
138  $this->tpl->setVariable('VAL_BEGIN',ilDatePresentation::formatDate($start));
139  }
140  else
141  {
142  $start = new ilDateTime($a_set['begin'],IL_CAL_UNIX,'UTC');
143  $this->tpl->setVariable('VAL_BEGIN',ilDatePresentation::formatDate($start));
144  }
145  if($a_set['duration'])
146  {
147  $this->tpl->setVariable('VAL_DURATION',ilFormat::_secondsToString($a_set['duration']));
148  }
149  else
150  {
151  $this->tpl->setVariable('VAL_DURATION','');
152  }
153 
154 
155  }
156 
163  public function setAppointments($a_apps)
164  {
165  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
166  include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
167 
168 
169  foreach($a_apps as $cal_entry_id)
170  {
171  $entry = new ilCalendarEntry($cal_entry_id);
172  $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
173 
174  $tmp_arr['id'] = $entry->getEntryId();
175  $tmp_arr['title'] = $entry->getPresentationTitle();
176  $tmp_arr['description'] = $entry->getDescription();
177  $tmp_arr['fullday'] = $entry->isFullday();
178  $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
179  $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
180 
181  #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24;
182  $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
183  if($tmp_arr['fullday'])
184  {
185  $tmp_arr['duration'] += (60 * 60 * 24);
186  }
187 
188  if(!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin'])
189  {
190  $tmp_arr['duration'] = '';
191  }
192  $tmp_arr['frequence'] = $rec->getFrequenceType();
193  $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable);
194 
195  $appointments[] = $tmp_arr;
196  }
197  $this->setData($appointments ? $appointments : array());
198  }
199 
200 }
201 ?>