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');
92 $this->recurrence_id = $a_rec_id;
110 $ilDB = $DIC[
'ilDB'];
112 $query =
"DELETE FROM cal_recurrence_rules " .
113 "WHERE cal_id = " .
$ilDB->quote($a_cal_id,
'integer') .
" ";
126 include_once
'./Services/Calendar/classes/class.ilCalendarEntry.php';
138 if ($entry->isFullday()) {
158 $ical .= (
';BYDAY=' . $this->
getBYDAY());
166 include_once
'./Services/Calendar/classes/class.ilCalendarUserSettings.php';
167 include_once
'./Services/Calendar/classes/class.ilCalendarSettings.php';
170 $ical .= (
';WKST=MO');
172 $ical .= (
';WKST=SU');
222 $this->cal_id = $a_id;
243 $this->recurrence_type =
$a_type;
255 return $this->recurrence_type == self::REC_RECURRENCE;
289 return is_object($this->freq_until_date) ? $this->freq_until_date : null;
300 $this->freq_until_date = $a_date;
312 $this->freq_until_count = $a_count;
336 $this->interval = $a_interval;
347 return $this->interval ? $this->interval : 1;
359 $this->byday = $a_byday;
385 $bydays[] = trim($byday);
387 return $bydays ? $bydays : array();
399 $this->byweekno = $a_byweekno;
413 foreach (explode(
',', $this->
getBYWEEKNO()) as $week_num) {
414 $weeks[] = (int) $week_num;
416 return $weeks ? $weeks : array();
440 $this->bymonth = $a_by;
465 foreach (explode(
',', $this->
getBYMONTH()) as $month_num) {
466 $months[] = (int) $month_num;
468 return $months ? $months : array();
480 $this->bymonthday = $a_by;
504 foreach (explode(
',', $this->
getBYMONTHDAY()) as $month_num) {
505 $months[] = (int) $month_num;
507 return $months ? $months : array();
520 $this->byyearday = $a_by;
545 foreach (explode(
',', $this->
getBYYEARDAY()) as $year_day) {
546 $days[] = (int) $year_day;
548 return $days ? $days : array();
560 $this->bysetpos = $a_by;
585 foreach (explode(
',', $this->
getBYSETPOS()) as $pos) {
586 $positions[] = (int) $pos;
588 return $positions ? $positions : array();
601 $this->weekstart = $a_start;
635 $this->timezone = $a_tz;
679 $ilDB = $DIC[
'ilDB'];
684 $next_id =
$ilDB->nextId(
'cal_recurrence_rules');
686 $query =
"INSERT INTO cal_recurrence_rules (rule_id,cal_id,cal_recurrence,freq_type,freq_until_date,freq_until_count,intervall, " .
687 "byday,byweekno,bymonth,bymonthday,byyearday,bysetpos,weekstart) " .
689 $ilDB->quote($next_id,
'integer') .
", " .
690 $this->db->quote($this->cal_id,
'integer') .
", " .
691 $ilDB->quote(1,
'integer') .
", " .
693 $this->db->quote($until_date,
'timestamp') .
", " .
695 $this->db->quote((
int) $this->
getInterval(),
'integer') .
", " .
696 $this->db->quote((
string) $this->
getBYDAY(),
'text') .
", " .
697 $this->db->quote((
string) $this->
getBYWEEKNO(),
'text') .
", " .
698 $this->db->quote((
string) $this->
getBYMONTH(),
'text') .
", " .
699 $this->db->quote((
string) $this->
getBYMONTHDAY(),
'text') .
", " .
700 $this->db->quote((
string) $this->
getBYYEARDAY(),
'text') .
", " .
701 $this->db->quote((
string) $this->
getBYSETPOS(),
'text') .
", " .
702 $this->db->quote((
string) $this->
getWeekstart(),
'text') .
" " .
705 $this->recurrence_id = $next_id;
719 $ilDB = $DIC[
'ilDB'];
725 $query =
"UPDATE cal_recurrence_rules SET " .
726 "cal_id = " . $this->db->quote($this->cal_id,
'integer') .
", " .
727 "cal_recurrence = 1," .
728 "freq_type = " . $this->db->quote($this->
getFrequenceType(),
'text') .
", " .
729 "freq_until_date = " . $this->db->quote($until_date,
'timestamp') .
", " .
731 "intervall = " . $this->db->quote($this->
getInterval(),
'integer') .
", " .
732 "byday = " . $this->db->quote($this->
getBYDAY(),
'text') .
", " .
733 "byweekno = " . $this->db->quote($this->
getBYWEEKNO(),
'text') .
", " .
734 "bymonth = " . $this->db->quote($this->
getBYMONTH(),
'text') .
", " .
735 "bymonthday = " . $this->db->quote($this->
getBYMONTHDAY(),
'text') .
", " .
736 "byyearday = " . $this->db->quote($this->
getBYYEARDAY(),
'text') .
", " .
737 "bysetpos = " . $this->db->quote($this->
getBYSETPOS(),
'text') .
", " .
738 "weekstart = " . $this->db->quote($this->
getWeekstart(),
'text') .
" " .
739 "WHERE rule_id = " . $this->db->quote($this->recurrence_id,
'integer') .
" ";
750 public function delete()
754 $ilDB = $DIC[
'ilDB'];
756 $query =
"DELETE FROM cal_recurrence_rules " .
757 "WHERE rule_id = " . $this->db->quote($this->recurrence_id,
'integer');
772 $ilDB = $DIC[
'ilDB'];
774 $query =
"SELECT * FROM cal_recurrence_rules " .
775 "WHERE rule_id = " . $this->db->quote($this->recurrence_id,
'integer') .
" ";
778 $this->cal_id =
$row->cal_id;
779 $this->recurrence_type =
$row->cal_recurrence;
780 $this->freq_type =
$row->freq_type;
782 if (
$row->freq_until_date != null) {
785 $this->freq_until_count =
$row->freq_until_count;
786 $this->interval =
$row->intervall;
787 $this->byday =
$row->byday;
788 $this->byweekno =
$row->byweekno;
789 $this->bymonth =
$row->bymonth;
790 $this->bymonthday =
$row->bymonthday;
791 $this->byyearday =
$row->byyearday;
792 $this->bysetpos =
$row->bysetpos;
793 $this->weekstart =
$row->week_start;
getBYDAYList()
get BYDAY list
const IL_CAL_FREQ_MONTHLY
Model for a calendar entry.
getEntryId()
Get calendar entry id.
setBYWEEKNO($a_byweekno)
set by day
setFrequenceUntilCount($a_count)
set frequence count
static _getInstanceByUserId($a_user_id)
get singleton instance
getBYMONTHList()
get bymonth list
setFrequenceUntilDate(ilDateTime $a_date=null)
set freq until date
setBYMONTHDAY($a_by)
set by day
getBYYEARDAYList()
get BYYEARDAY list
setFrequenceType($a_type)
set frequence type
setWeekstart($a_start)
set weekstart
getBYMONTHDAYList()
get BYMONTHDAY list
getExclusionDates()
Get exclusion dates.
getFrequenceType()
get freq type
isRecurrence()
is recurrence
setEntryId($a_id)
set cal id
getTimeZone()
get timezone
toICal($a_user_id)
Get ical presentation for calendar recurrence.
foreach($_POST as $key=> $value) $res
static delete($a_cal_id)
Delete exclusion dates of calendar entry.
setInterval($a_interval)
set interval
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
getBYSETPOSList()
get bysetpos list
getBYWEEKNOList()
get byweekno list
__construct($a_rec_id=0)
Constructor.
getWeekstart()
get weekstart
setBYMONTH($a_by)
set by day
static _delete($a_cal_id)
delete
getFrequenceUntilDate()
get until date
getRecurrenceId()
get recurrence id
static getExclusionDates($a_cal_id)
Read exclusion dates.
setRecurrence($a_type)
set type of recurrence
setBYSETPOS($a_by)
set by day
getInterval()
get interval
getFrequenceUntilCount()
get frequence until count
setBYDAY($a_byday)
set by day
setBYYEARDAY($a_by)
set by day
setTimeZone($a_tz)
set timezone
reset()
reset all settings