ILIAS  Release_4_0_x_branch Revision 61816
 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');
33 {
34  private $cat_id = 0;
35  private $categories = null;
36  private $is_editable = false;
37 
45  public function __construct($a_parent_obj,$a_parent_cmd)
46  {
47  global $lng,$ilCtrl;
48 
49 
50  $this->categories = ilCalendarCategories::_getInstance();
51 
52  $this->lng = $lng;
53  $this->lng->loadLanguageModule('dateplaner');
54  $this->ctrl = $ilCtrl;
55 
56  parent::__construct($a_parent_obj,$a_parent_cmd);
57  $this->setFormName('appointments');
58  $this->addColumn($this->lng->txt('title'),'title',"40%");
59  $this->addColumn($this->lng->txt('cal_start'),'begin',"15%");
60  $this->addColumn($this->lng->txt('cal_duration'),'duration',"20%");
61  $this->addColumn($this->lng->txt('cal_recurrences'),'frequence',"10%");
62  $this->addColumn($this->lng->txt('last_update'),'last_update',"15%");
63 
64 
65  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
66  $this->setRowTemplate("tpl.show_changed_appointment_row.html","Services/Calendar");
67  $this->enable('sort');
68  $this->enable('header');
69  $this->enable('numinfo');
70 
71  $this->setDefaultOrderField('last_update');
72  $this->setDefaultOrderDirection('desc');
73 
74  $this->setPrefix('apps');
75  }
76 
77 
85  protected function fillRow($a_set)
86  {
87  global $ilUser, $lng;
88 
89  if ($a_set["milestone"])
90  {
91  $this->tpl->setCurrentBlock("img_ms");
92  $this->tpl->setVariable("IMG_MS", ilUtil::getImagePath("icon_ms_s.gif"));
93  $this->tpl->setVariable("ALT_MS", $lng->txt("cal_milestone"));
94  $this->tpl->parseCurrentBlock();
95  }
96 
97  $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
98 
99  $this->tpl->setVariable('VAL_TITLE_LINK',$a_set['title']);
100  $this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_set['id']);
101  $this->tpl->setVariable('VAL_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
102 
103  switch($a_set['frequence'])
104  {
105  case IL_CAL_FREQ_DAILY:
106  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_daily'));
107  break;
108 
109  case IL_CAL_FREQ_WEEKLY:
110  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_weekly'));
111  break;
112 
113  case IL_CAL_FREQ_MONTHLY:
114  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_monthly'));
115  break;
116 
117  case IL_CAL_FREQ_YEARLY:
118  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_yearly'));
119  break;
120 
121  default:
122  $this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence'));
123  break; $this->addColumn($this->lng->txt('cal_duration'),'duration',"20%");
124  }
125  // TOD: Localization
126  if($a_set['fullday'])
127  {
128  $start = new ilDate($a_set['begin'],IL_CAL_UNIX);
129  $this->tpl->setVariable('VAL_BEGIN',ilDatePresentation::formatDate($start));
130  }
131  else
132  {
133  $start = new ilDateTime($a_set['begin'],IL_CAL_UNIX,'UTC');
134  $this->tpl->setVariable('VAL_BEGIN',ilDatePresentation::formatDate($start));
135  }
136  if($a_set['duration'])
137  {
138  if($a_set['milestone'])
139  {
140  $this->tpl->setVariable('VAL_DURATION','-');
141  }
142  else
143  {
144  $this->tpl->setVariable('VAL_DURATION',ilFormat::_secondsToString($a_set['duration']));
145  }
146  }
147  else
148  {
149  $this->tpl->setVariable('VAL_DURATION','');
150  }
151  $update = new ilDateTime($a_set['last_update'],IL_CAL_UNIX,$ilUser->getTimeZone());
152  $this->tpl->setVariable('VAL_LAST_UPDATE',ilDatePresentation::formatDate($update));
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 $entry)
170  {
171  $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
172 
173  $tmp_arr['id'] = $entry->getEntryId();
174  $tmp_arr['milestone'] = $entry->isMilestone();
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  if(!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin'])
188  {
189  $tmp_arr['duration'] = '';
190  }
191 
192  $tmp_arr['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX);
193  $tmp_arr['frequence'] = $rec->getFrequenceType();
194 
195  $appointments[] = $tmp_arr;
196  }
197 
198  $this->setData($appointments ? $appointments : array());
199  }
200 
201 }
202 ?>