3 declare(strict_types=1);
61 $this->log = $DIC->logger()->cal();
62 $this->
lng = $DIC->language();
63 $this->db = $DIC->database();
64 $this->error = $DIC[
'ilErr'];
65 $this->entry_id = $a_id;
66 if ($this->entry_id > 0) {
79 public static function _delete(
int $a_entry_id): void
86 $query =
"DELETE FROM cal_entries " .
87 "WHERE cal_id = " .
$ilDB->quote($a_entry_id,
'integer') .
" ";
93 $this->context_info = $a_info;
113 $this->last_update = $a_date;
123 $this->start = $a_start;
138 $this->title = $a_title;
152 if (preg_match(
"/#([a-z]+)#/", $this->
getSubtitle(), $matches)) {
159 ?
' (' . $subtitle .
')' 173 $title = $style =
"";
175 case "consultationhour":
178 if ($entry->isOwner()) {
179 $max = $entry->getNumberOfBookings();
180 $current = $entry->getCurrentNumberOfBookings($this->
getEntryId());
182 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: green';
183 $title = $this->
lng->txt(
'cal_book_free');
184 } elseif ($current >= $max) {
185 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: red';
186 $title = $this->
lng->txt(
'cal_booked_out');
188 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: yellow';
189 $title = $current .
'/' . $max;
198 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: red';
199 $title = $this->
lng->txt(
'cal_booked_out');
201 $orig_event = $apps[0];
202 $max = $entry->getNumberOfBookings();
203 $current = $entry->getCurrentNumberOfBookings($this->
getEntryId());
204 if ($entry->hasBooked($orig_event)) {
205 $title = $this->
lng->txt(
'cal_date_booked');
206 } elseif ($current >= $max) {
207 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: red';
208 $title = $this->
lng->txt(
'cal_booked_out');
210 $style =
';border-left-width: 5px; border-left-style: solid; border-left-color: green';
211 $title = $this->
lng->txt(
'cal_book_free');
218 if (strlen($style)) {
219 $this->presentation_style = $style;
237 $this->subtitle = $a_subtitle;
247 $this->description = $a_description;
257 $this->location = $a_location;
267 $this->further_informations = $a_informations;
282 $this->fullday = $a_fullday;
297 $this->is_auto_generated = $a_status;
307 $this->is_milestone = $a_status;
312 $this->completion = $a_completion;
322 $this->context_id = $a_context_id;
332 $this->translation_type = $a_type;
354 $query =
"UPDATE cal_entries " .
355 "SET title = " . $this->db->quote($this->
getTitle(),
'text') .
", " .
356 "last_update = " . $this->db->quote($utc_timestamp,
'timestamp') .
", " .
357 "subtitle = " . $this->db->quote($this->
getSubtitle(),
'text') .
", " .
358 "description = " . $this->db->quote($this->
getDescription(),
'text') .
", " .
359 "location = " . $this->db->quote($this->
getLocation(),
'text') .
", " .
360 "fullday = " . $this->db->quote($this->
isFullday() ? 1 : 0,
'integer') .
", " .
364 "auto_generated = " . $this->db->quote($this->
isAutoGenerated(),
'integer') .
", " .
365 "translation_type = " . $this->db->quote($this->
getTranslationType(),
'integer') .
", " .
366 "context_id = " . $this->db->quote($this->
getContextId(),
'integer') .
", " .
367 'context_info = ' . $this->db->quote($this->
getContextInfo(),
'text') .
', ' .
368 "completion = " . $this->db->quote($this->
getCompletion(),
'integer') .
", " .
369 "is_milestone = " . $this->db->quote($this->
isMilestone() ? 1 : 0,
'integer') .
", " .
371 "WHERE cal_id = " . $this->db->quote($this->
getEntryId(),
'integer') .
" ";
377 $next_id = $this->db->nextId(
'cal_entries');
381 $query =
"INSERT INTO cal_entries (cal_id,title,last_update,subtitle,description,location,fullday,starta,enda, " .
382 "informations,auto_generated,context_id,context_info,translation_type, completion, is_milestone, notification) " .
384 $this->db->quote($next_id,
'integer') .
", " .
385 $this->db->quote($this->
getTitle(),
'text') .
", " .
386 $this->db->quote($utc_timestamp,
'timestamp') .
", " .
387 $this->db->quote($this->
getSubtitle(),
'text') .
", " .
389 $this->db->quote($this->
getLocation(),
'text') .
", " .
390 $this->db->quote($this->
isFullday() ? 1 : 0,
'integer') .
", " .
395 $this->db->quote($this->
getContextId(),
'integer') .
", " .
399 $this->db->quote($this->
isMilestone() ? 1 : 0,
'integer') .
", " .
404 $this->entry_id = $next_id;
407 public function delete():
void 411 $query =
"DELETE FROM cal_entries " .
412 "WHERE cal_id = " . $this->db->quote($this->
getEntryId(),
'integer') .
" ";
421 $this->error->setMessage(
'');
424 $this->error->appendMessage($this->
lng->txt(
'err_missing_title'));
430 $this->error->appendMessage($this->
lng->txt(
'err_end_before_start'));
435 protected function read(): void
437 $query =
"SELECT * FROM cal_entries WHERE cal_id = " . $this->db->quote($this->
getEntryId(),
'integer') .
" ";
441 $this->
setTitle((
string) $row->title);
467 $body = $lng->
txt(
'cal_details');
469 $body .= $lng->
txt(
'title') .
': ' . $this->
getTitle() .
"\n";
476 $body .= $lng->
txt(
'cal_where') .
': ' . $this->
getLocation() .
"\n";
487 $this->db->manipulateF(
488 "DELETE FROM cal_entry_responsible WHERE cal_id = %s",
493 if (is_array($a_users)) {
494 foreach ($a_users as $user_id) {
495 $this->db->manipulateF(
496 "INSERT INTO cal_entry_responsible (cal_id, user_id) " .
498 array(
"integer",
"integer"),
504 $this->responsible_users = $a_users;
509 $set = $this->db->queryF(
510 "SELECT * FROM cal_entry_responsible WHERE cal_id = %s",
516 while ($rec = $this->db->fetchAssoc($set)) {
518 $return[] = array_merge(
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...
static _lookupName(int $a_user_id)
lookup user name
setContextId(int $a_context_id)
setCompletion(int $a_completion)
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)
writeResponsibleUsers(array $a_users)
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 uses PEAR error class.
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
setMilestone(bool $a_status)
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.
static _lookupLogin(int $a_user_id)