3 declare(strict_types=1);
58 $this->log = $DIC->logger()->cal();
59 $this->
lng = $DIC->language();
60 $this->db = $DIC->database();
61 $this->error = $DIC[
'ilErr'];
62 $this->entry_id = $a_id;
63 if ($this->entry_id > 0) {
76 public static function _delete(
int $a_entry_id): void
83 $query =
"DELETE FROM cal_entries " .
84 "WHERE cal_id = " .
$ilDB->quote($a_entry_id,
'integer') .
" ";
90 $this->context_info = $a_info;
110 $this->last_update = $a_date;
120 $this->start = $a_start;
135 $this->title = $a_title;
149 if (preg_match(
"/#([a-z]+)#/", $this->
getSubtitle(), $matches)) {
156 ?
' (' . $subtitle .
')' 170 $title = $style =
"";
172 case "consultationhour":
175 if ($entry->isOwner()) {
176 $max = $entry->getNumberOfBookings();
177 $current = $entry->getCurrentNumberOfBookings($this->
getEntryId());
179 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: green';
180 $title = $this->
lng->txt(
'cal_book_free');
181 } elseif ($current >= $max) {
182 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: red';
183 $title = $this->
lng->txt(
'cal_booked_out');
185 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: yellow';
186 $title = $current .
'/' . $max;
195 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: red';
196 $title = $this->
lng->txt(
'cal_booked_out');
198 $orig_event = $apps[0];
199 $max = $entry->getNumberOfBookings();
200 $current = $entry->getCurrentNumberOfBookings($this->
getEntryId());
201 if ($entry->hasBooked($orig_event)) {
202 $title = $this->
lng->txt(
'cal_date_booked');
203 } elseif ($current >= $max) {
204 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: red';
205 $title = $this->
lng->txt(
'cal_booked_out');
207 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: green';
208 $title = $this->
lng->txt(
'cal_book_free');
215 if (strlen($style)) {
216 $this->presentation_style = $style;
234 $this->subtitle = $a_subtitle;
244 $this->description = $a_description;
254 $this->location = $a_location;
264 $this->further_informations = $a_informations;
279 $this->fullday = $a_fullday;
294 $this->is_auto_generated = $a_status;
299 $this->context_id = $a_context_id;
309 $this->translation_type = $a_type;
331 $query =
"UPDATE cal_entries " .
336 "SET title = " . $this->db->quote(mb_substr($this->
getTitle(), 0, 128),
'text') .
", " .
337 "last_update = " . $this->db->quote($utc_timestamp,
'timestamp') .
", " .
338 "subtitle = " . $this->db->quote($this->
getSubtitle(),
'text') .
", " .
339 "description = " . $this->db->quote($this->
getDescription(),
'text') .
", " .
340 "location = " . $this->db->quote($this->
getLocation(),
'text') .
", " .
341 "fullday = " . $this->db->quote($this->
isFullday() ? 1 : 0,
'integer') .
", " .
345 "auto_generated = " . $this->db->quote($this->
isAutoGenerated(),
'integer') .
", " .
346 "translation_type = " . $this->db->quote($this->
getTranslationType(),
'integer') .
", " .
347 "context_id = " . $this->db->quote($this->
getContextId(),
'integer') .
", " .
348 'context_info = ' . $this->db->quote($this->
getContextInfo(),
'text') .
', ' .
350 "WHERE cal_id = " . $this->db->quote($this->
getEntryId(),
'integer') .
" ";
351 $res = $this->db->manipulate($query);
356 $next_id = $this->db->nextId(
'cal_entries');
360 $query =
"INSERT INTO cal_entries (cal_id,title,last_update,subtitle,description,location,fullday,starta,enda, " .
361 "informations,auto_generated,context_id,context_info,translation_type, notification) " .
363 $this->db->quote($next_id,
'integer') .
", " .
368 $this->db->quote(mb_substr($this->
getTitle(), 0, 128),
'text') .
", " .
369 $this->db->quote($utc_timestamp,
'timestamp') .
", " .
370 $this->db->quote($this->
getSubtitle(),
'text') .
", " .
372 $this->db->quote($this->
getLocation(),
'text') .
", " .
373 $this->db->quote($this->
isFullday() ? 1 : 0,
'integer') .
", " .
378 $this->db->quote($this->
getContextId(),
'integer') .
", " .
383 $res = $this->db->manipulate($query);
385 $this->entry_id = $next_id;
388 public function delete():
void 392 $query =
"DELETE FROM cal_entries " .
393 "WHERE cal_id = " . $this->db->quote($this->
getEntryId(),
'integer') .
" ";
394 $res = $this->db->manipulate($query);
402 $this->error->setMessage(
'');
405 $this->error->appendMessage($this->
lng->txt(
'err_missing_title'));
411 $this->error->appendMessage($this->
lng->txt(
'err_end_before_start'));
416 protected function read(): void
418 $query =
"SELECT * FROM cal_entries WHERE cal_id = " . $this->db->quote($this->
getEntryId(),
'integer') .
" ";
419 $res = $this->db->query($query);
422 $this->
setTitle((
string) $row->title);
446 $body = $lng->
txt(
'cal_details');
448 $body .= $lng->
txt(
'title') .
': ' . $this->
getTitle() .
"\n";
455 $body .= $lng->
txt(
'cal_where') .
': ' . $this->
getLocation() .
"\n";
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title)
appointmentToMailString(ilLanguage $lng)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
setAutoGenerated(bool $a_status)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContextId(int $a_context_id)
setStart(?ilDateTime $a_start)
setSubtitle(string $a_subtitle)
set subtitle Used for automatic generated appointments.
getPresentationTitle(bool $a_shorten=true)
setLocation(string $a_location)
static _delete(int $a_entry_id)
setFullday(bool $a_fullday)
set fullday event Fullday events do not change their time in different timezones. ...
static getAppointmentIds(int $a_user_id, int $a_context_id=null, ?ilDateTime $a_start=null, ?int $a_type=null, bool $a_check_owner=true)
getEnd()
Get end of period.
static _deleteByAppointmentId(int $a_app_id)
Delete appointment assignment.
setFurtherInformations(string $a_informations)
isFullday()
is event a fullday period
string $presentation_style
setTranslationType(int $a_type)
setContextInfo(string $a_info)
parseDynamicTitle(string $a_type)
setEnd(?ilDateTime $a_end)
getStart()
Get start of date period.
Error Handling & global info handling.
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
enableNotification(bool $a_status)
setLastUpdate(ilDateTime $a_date)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
setDescription(string $a_description)
static _delete(int $a_cal_id)
static setUseRelativeDates(bool $a_status)
set use relative dates
string $further_informations
static shortenWords(string $a_str, int $a_len=30, bool $a_dots=true)
Ensure that the maximum word lenght within a text is not longer than $a_len.