19 declare(strict_types=1);
67 $this->db = $DIC->database();
68 $this->recurrence_id = $a_rec_id;
74 public static function _delete(
int $a_cal_id): void
79 $query =
"DELETE FROM cal_recurrence_rules " .
80 "WHERE cal_id = " .
$ilDB->quote($a_cal_id,
'integer') .
" ";
89 public function toICal(
int $a_user_id): string
106 if ($entry->isFullday()) {
126 $ical .= (
';BYDAY=' . $this->
getBYDAY());
136 $ical .= (
';WKST=MO');
138 $ical .= (
';WKST=SU');
168 $this->cal_id = $a_id;
183 $this->recurrence_type = $a_type;
188 return $this->recurrence_type == self::REC_RECURRENCE;
193 $this->freq_type = $a_type;
203 return is_object($this->freq_until_date) ? $this->freq_until_date :
null;
208 $this->freq_until_date = $a_date;
213 $this->freq_until_count = $a_count;
223 $this->interval = $a_interval;
237 $this->byday = $a_byday;
254 foreach (explode(
',', $this->
getBYDAY()) as $byday) {
255 $bydays[] = trim($byday);
262 $this->byweekno = $a_byweekno;
271 foreach (explode(
',', $this->
getBYWEEKNO()) as $week_num) {
272 $weeks[] = (
int) $week_num;
284 $this->bymonth = $a_by;
298 foreach (explode(
',', $this->
getBYMONTH()) as $month_num) {
299 $months[] = (
int) $month_num;
306 $this->bymonthday = $a_by;
320 foreach (explode(
',', $this->
getBYMONTHDAY()) as $month_num) {
321 $month[] = (
int) $month_num;
328 $this->byyearday = $a_by;
342 foreach (explode(
',', $this->
getBYYEARDAY()) as $year_day) {
343 $days[] = (
int) $year_day;
350 $this->bysetpos = $a_by;
364 foreach (explode(
',', $this->
getBYSETPOS()) as $pos) {
365 $positions[] = (
int) $pos;
372 $this->weekstart = $a_start;
387 $this->timezone = $a_tz;
403 $valid_frequences = array(self::FREQ_DAILY,
425 $next_id = $this->db->nextId(
'cal_recurrence_rules');
427 $query =
"INSERT INTO cal_recurrence_rules (rule_id,cal_id,cal_recurrence,freq_type,freq_until_date,freq_until_count,intervall, " .
428 "byday,byweekno,bymonth,bymonthday,byyearday,bysetpos,weekstart) " .
430 $this->db->quote($next_id,
'integer') .
", " .
431 $this->db->quote($this->cal_id,
'integer') .
", " .
432 $this->db->quote(1,
'integer') .
", " .
434 $this->db->quote($until_date,
'timestamp') .
", " .
436 $this->db->quote($this->
getInterval(),
'integer') .
", " .
437 $this->db->quote($this->
getBYDAY(),
'text') .
", " .
438 $this->db->quote($this->
getBYWEEKNO(),
'text') .
", " .
439 $this->db->quote($this->
getBYMONTH(),
'text') .
", " .
441 $this->db->quote($this->
getBYYEARDAY(),
'text') .
", " .
442 $this->db->quote($this->
getBYSETPOS(),
'text') .
", " .
445 $res = $this->db->manipulate($query);
446 $this->recurrence_id = $next_id;
455 $query =
"UPDATE cal_recurrence_rules SET " .
456 "cal_id = " . $this->db->quote($this->cal_id,
'integer') .
", " .
457 "cal_recurrence = 1," .
458 "freq_type = " . $this->db->quote($this->
getFrequenceType(),
'text') .
", " .
459 "freq_until_date = " . $this->db->quote($until_date,
'timestamp') .
", " .
461 "intervall = " . $this->db->quote($this->
getInterval(),
'integer') .
", " .
462 "byday = " . $this->db->quote($this->
getBYDAY(),
'text') .
", " .
463 "byweekno = " . $this->db->quote($this->
getBYWEEKNO(),
'text') .
", " .
464 "bymonth = " . $this->db->quote($this->
getBYMONTH(),
'text') .
", " .
465 "bymonthday = " . $this->db->quote($this->
getBYMONTHDAY(),
'text') .
", " .
466 "byyearday = " . $this->db->quote($this->
getBYYEARDAY(),
'text') .
", " .
467 "bysetpos = " . $this->db->quote($this->
getBYSETPOS(),
'text') .
", " .
468 "weekstart = " . $this->db->quote($this->
getWeekstart(),
'text') .
" " .
469 "WHERE rule_id = " . $this->db->quote($this->recurrence_id,
'integer') .
" ";
470 $res = $this->db->manipulate($query);
473 public function delete():
void 475 $query =
"DELETE FROM cal_recurrence_rules " .
476 "WHERE rule_id = " . $this->db->quote($this->recurrence_id,
'integer');
477 $res = $this->db->manipulate($query);
482 $query =
"SELECT * FROM cal_recurrence_rules " .
483 "WHERE rule_id = " . $this->db->quote($this->recurrence_id,
'integer') .
" ";
484 $res = $this->db->query($query);
486 $this->cal_id = (
int) $row->cal_id;
487 $this->recurrence_type = (
int) $row->cal_recurrence;
488 $this->freq_type = (string) $row->freq_type;
490 if ($row->freq_until_date !=
null) {
493 $this->freq_until_count = (
int) $row->freq_until_count;
494 $this->interval = (
int) $row->intervall;
495 $this->byday = (string) $row->byday;
496 $this->byweekno = (
string) $row->byweekno;
497 $this->bymonth = (string) $row->bymonth;
498 $this->bymonthday = (
string) $row->bymonthday;
499 $this->byyearday = (string) $row->byyearday;
500 $this->bysetpos = (
string) $row->bysetpos;
501 $this->weekstart = (string) $row->weekstart;
static delete(int $a_cal_id)
Delete exclusion dates of calendar entry.
setBYDAY(string $a_byday)
3.8.5.3.
setFrequenceUntilDate(?ilDateTime $a_date=null)
Model of calendar entry recurrcences based on iCalendar-RFC-5545.
if(!file_exists('../ilias.ini.php'))
getBYMONTHList()
Get BYMONTHList.
__construct(int $a_rec_id=0)
setInterval(int $a_interval)
getBYYEARDAYList()
Get BYYEARDAYLIST.
getBYMONTHDAYList()
Get BYMONTHDAY List.
setFrequenceType(string $a_type)
setRecurrence(int $a_type)
set type of recurrence public
static _getInstanceByUserId(int $a_user_id)
getFrequenceType()
Get Frequence type of recurrence.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getTimeZone()
Get timezone of recurrence.
setBYWEEKNO(string $a_byweekno)
setTimeZone(string $a_tz)
setFrequenceUntilCount(int $a_count)
getBYSETPOSList()
Get BYSETPOS List.
getBYWEEKNOList()
Get BYWEEKNOList.
setBYYEARDAY(string $a_by)
setBYMONTHDAY(string $a_by)
toICal(int $a_user_id)
Get ical presentation for calendar recurrence.
getFrequenceUntilDate()
Get end data of recurrence.
setWeekstart(string $a_start)
static getExclusionDates($a_cal_id)
Read exclusion dates.
getInterval()
Get interval of recurrence.
getFrequenceUntilCount()
Get number of recurrences.
static _delete(int $a_cal_id)
setBYSETPOS(string $a_by)
reset()
reset all settings