ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 
30 {
31  private int $cat_id = 0;
32  private bool $is_editable = false;
33  private ilObjUser $user;
34 
35  public function __construct(?object $a_parent_obj, string $a_parent_cmd)
36  {
37  global $DIC;
38 
39  $this->user = $DIC->user();
40  $this->lng = $DIC->language();
41  $this->lng->loadLanguageModule('dateplaner');
42  $this->ctrl = $DIC->ctrl();
43 
44  $this->setId('calinbox');
45 
46  parent::__construct($a_parent_obj, $a_parent_cmd);
47  $this->setFormName('appointments');
48  $this->addColumn($this->lng->txt('date'), 'begin', "30%");
49  $this->addColumn($this->lng->txt('title'), 'title', "40%");
50  #$this->addColumn($this->lng->txt('cal_duration'),'duration',"15%");
51  $this->addColumn($this->lng->txt('cal_recurrences'), 'frequence', "15%");
52  $this->addColumn($this->lng->txt('last_update'), 'last_update', "15%");
53 
54  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
55  $this->setRowTemplate("tpl.show_changed_appointment_row.html", "Services/Calendar");
56 
57  $this->setShowRowsSelector(true);
58  $this->enable('sort');
59  $this->enable('header');
60  $this->enable('numinfo');
61 
62  $this->setDefaultOrderField('begin');
63  $this->setDefaultOrderDirection('asc');
64  }
65 
66  protected function fillRow(array $a_set): void
67  {
68  $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']);
69 
70  $this->tpl->setVariable('VAL_TITLE_LINK', $a_set['title']);
71  $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_set['id']);
72  $this->tpl->setVariable('VAL_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
73 
74  switch ($a_set['frequence']) {
76  $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_daily'));
77  break;
78 
80  $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_weekly'));
81  break;
82 
84  $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_monthly'));
85  break;
86 
88  $this->tpl->setVariable('VAL_FREQUENCE', $this->lng->txt('cal_yearly'));
89  break;
90 
91  default:
92  #$this->tpl->setVariable('VAL_FREQUENCE',$this->lng->txt('cal_no_recurrence'));
93  break;
94  }
95  if ($a_set['fullday']) {
97  new ilDate($a_set['begin'], IL_CAL_UNIX),
98  new ilDate($a_set['end'], IL_CAL_UNIX)
99  );
100  } else {
102  new ilDateTime($a_set['begin'], IL_CAL_UNIX),
103  new ilDateTime($a_set['end'], IL_CAL_UNIX)
104  );
105  }
106  $this->tpl->setVariable('VAL_BEGIN', $date);
107  $update = new ilDateTime($a_set['last_update'], IL_CAL_UNIX, $this->user->getTimeZone());
108  $this->tpl->setVariable('VAL_LAST_UPDATE', ilDatePresentation::formatDate($update));
109  }
110 
111  public function setAppointments(array $a_apps): void
112  {
113  $appointments = [];
114  foreach ($a_apps as $event) {
115  $entry = $event['event'];
116 
117  $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
118 
119  $tmp_arr['id'] = $entry->getEntryId();
120  $tmp_arr['title'] = $entry->getPresentationTitle();
121  $tmp_arr['description'] = $entry->getDescription();
122  $tmp_arr['fullday'] = $entry->isFullday();
123 
124  $tmp_arr['begin'] = $event['dstart'];
125  $tmp_arr['end'] = $event['dend'];
126 
127  $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
128  if ($tmp_arr['fullday']) {
129  $tmp_arr['duration'] += (60 * 60 * 24);
130  }
131  if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) {
132  $tmp_arr['duration'] = '';
133  }
134 
135  $tmp_arr['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX);
136  $tmp_arr['frequence'] = $rec->getFrequenceType();
137 
138  $appointments[] = $tmp_arr;
139  }
140 
141  //cuts appointments array after Limit
142  $appointments = array_slice($appointments, 0, $this->getLimit());
143  $this->setData($appointments);
144  }
145 }
setData(array $a_data)
enable(string $a_module_name)
setFormAction(string $a_form_action, bool $a_multipart=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
setFormName(string $a_name="")
setId(string $a_val)
global $DIC
Definition: feed.php:28
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
__construct(?object $a_parent_obj, string $a_parent_cmd)
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)