24 include_once(
'./Services/Calendar/classes/class.ilDate.php');
25 include_once
'./Services/Calendar/classes/class.ilCalendarRecurrenceExclusions.php';
26 include_once
'./Services/Calendar/interfaces/interface.ilCalendarRecurrenceCalculation.php';
38 define(
'IL_CAL_FREQ_DAILY',
'DAILY');
39 define(
'IL_CAL_FREQ_WEEKLY',
'WEEKLY');
40 define(
'IL_CAL_FREQ_MONTHLY',
'MONTHLY');
41 define(
'IL_CAL_FREQ_YEARLY',
'YEARLY');
90 $this->recurrence_id = $a_rec_id;
109 $query =
"DELETE FROM cal_recurrence_rules ".
110 "WHERE cal_id = ".$ilDB->quote($a_cal_id ,
'integer').
" ";
119 $ical .= (
'FREQ='.$this->getFrequenceType());
123 $ical .= (
';INTERVAL='.$this->getInterval());
127 $ical .= (
';COUNT='.$this->getFrequenceUntilCount());
131 $ical .= (
';UNTIL='.$this->getFrequenceUntilDate()->get(
IL_CAL_FKT_DATE,
'Ymd'));
135 $ical .= (
';BYMONTH='.$this->getBYMONTH());
139 $ical .= (
';BYWEEKNO='.$this->getBYWEEKNO());
143 $ical .= (
';BYYEARDAY='.$this->getBYYEARDAY());
147 $ical .= (
';BYMONTHDAY='.$this->getBYMONTHDAY());
151 $ical .= (
';BYDAY='.$this->getBYDAY());
155 $ical .= (
';BYSETPOS='.$this->getBYSETPOS());
203 $this->cal_id = $a_id;
215 $this->recurrence_type = $a_type;
239 $this->freq_type = $a_type;
261 return is_object($this->freq_until_date) ? $this->freq_until_date : null;
272 $this->freq_until_date = $a_date;
284 $this->freq_until_count = $a_count;
308 $this->interval = $a_interval;
319 return $this->interval ? $this->interval : 1;
331 $this->byday = $a_byday;
359 $bydays[] = trim($byday);
361 return $bydays ? $bydays : array();
373 $this->byweekno = $a_byweekno;
388 foreach(explode(
',',$this->
getBYWEEKNO()) as $week_num)
390 $weeks[] = (int) $week_num;
392 return $weeks ? $weeks : array();
416 $this->bymonth = $a_by;
442 foreach(explode(
',',$this->
getBYMONTH()) as $month_num)
444 $months[] = (int) $month_num;
446 return $months ? $months : array();
458 $this->bymonthday = $a_by;
485 $months[] = (int) $month_num;
487 return $months ? $months : array();
501 $this->byyearday = $a_by;
527 foreach(explode(
',',$this->
getBYYEARDAY()) as $year_day)
529 $days[] = (int) $year_day;
531 return $days ? $days : array();
543 $this->bysetpos = $a_by;
571 $positions[] = (int) $pos;
573 return $positions ? $positions : array();
586 $this->weekstart = $a_start;
620 $this->timezone = $a_tz;
670 $next_id = $ilDB->nextId(
'cal_recurrence_rules');
672 $query =
"INSERT INTO cal_recurrence_rules (rule_id,cal_id,cal_recurrence,freq_type,freq_until_date,freq_until_count,intervall, ".
673 "byday,byweekno,bymonth,bymonthday,byyearday,bysetpos,weekstart) ".
675 $ilDB->quote($next_id,
'integer').
", ".
676 $this->db->quote($this->cal_id ,
'integer').
", ".
677 $ilDB->quote(1,
'integer').
", ".
679 $this->db->quote($until_date,
'timestamp').
", ".
681 $this->db->quote($this->
getInterval() ,
'integer').
", ".
682 $this->db->quote($this->
getBYDAY() ,
'text').
", ".
683 $this->db->quote($this->
getBYWEEKNO() ,
'text').
", ".
684 $this->db->quote($this->
getBYMONTH() ,
'text').
", ".
687 $this->db->quote($this->
getBYSETPOS() ,
'text').
", ".
691 $this->recurrence_id = $next_id;
709 $query =
"UPDATE cal_recurrence_rules SET ".
710 "cal_id = ".$this->db->quote($this->cal_id ,
'integer').
", ".
711 "cal_recurrence = 1,".
713 "freq_until_date = ".$this->db->quote($until_date ,
'timestamp').
", ".
715 "intervall = ".$this->db->quote($this->
getInterval() ,
'integer').
", ".
716 "byday = ".$this->db->quote($this->
getBYDAY() ,
'text').
", ".
717 "byweekno = ".$this->db->quote($this->
getBYWEEKNO() ,
'text').
", ".
718 "bymonth = ".$this->db->quote($this->
getBYMONTH() ,
'text').
", ".
719 "bymonthday = ".$this->db->quote($this->
getBYMONTHDAY() ,
'text').
", ".
720 "byyearday = ".$this->db->quote($this->
getBYYEARDAY() ,
'text').
", ".
721 "bysetpos = ".$this->db->quote($this->
getBYSETPOS() ,
'text').
", ".
722 "weekstart = ".$this->db->quote($this->
getWeekstart() ,
'text').
" ".
723 "WHERE rule_id = ".$this->db->quote($this->recurrence_id ,
'integer').
" ";
734 public function delete()
738 $query =
"DELETE FROM cal_recurrence_rules ".
739 "WHERE rule_id = ".$this->db->quote($this->recurrence_id ,
'integer');
754 $query =
"SELECT * FROM cal_recurrence_rules ".
755 "WHERE rule_id = ".$this->db->quote($this->recurrence_id ,
'integer').
" ";
759 $this->cal_id =
$row->cal_id;
760 $this->recurrence_type =
$row->cal_recurrence;
761 $this->freq_type =
$row->freq_type;
763 if(
$row->freq_until_date != null)
767 $this->freq_until_count =
$row->freq_until_count;
768 $this->interval =
$row->intervall;
769 $this->byday =
$row->byday;
770 $this->byweekno =
$row->byweekno;
771 $this->bymonth =
$row->bymonth;
772 $this->bymonthday =
$row->bymonthday;
773 $this->byyearday =
$row->byyearday;
774 $this->bysetpos =
$row->bysetpos;
775 $this->weekstart =
$row->week_start;