示例#1
0
 function __construct($url, $uid = '', $pwd = '', $cal = '')
 {
     //file_put_contents('/tmp/dump', "$url\n$uid\n$pwd\n$cal\n", FILE_APPEND);
     if (empty($url)) {
         throw new Exception("Missing URL");
     }
     parent::__construct($url, $uid, $pwd, $cal);
 }
示例#2
0
 function isActive($start, $end)
 {
     $res = FALSE;
     if (!($start && $end)) {
         return TRUE;
     }
     if (!CaldavRessource::isDateTime($start) || !CaldavRessource::isDateTime($end)) {
         throw new Exception("[{$start},{$end}] Invalid CalDAV DateTime format");
     }
     $event = $this->getBaseComponent();
     if ($start && !$end) {
         if (CaldavRessource::datecmp($start, $event->GetPValue('DTSTART')) < 0) {
             $res = TRUE;
         }
     } else {
         if (CaldavRessource::datecmp($start, $event->GetPValue('DTSTART')) < 0 && CaldavRessource::datecmp($end, $event->GetPValue('DTEND')) > 0) {
             $res = TRUE;
         }
     }
     return $res;
 }
 function getEventDates($startDate = NULL, $endDate = NULL)
 {
     $dates = array();
     $freq = $this->getFreq();
     //print "$freq\n";
     if (!in_array($freq, $this->freq)) {
         return $dates;
     }
     if ($startDate && $endDate) {
         $this->range_start = CaldavRessource::iCal2Timestamp($startDate);
         $this->range_end = CaldavRessource::iCal2Timestamp($endDate);
         if ($this->start > $this->range_end) {
             return $dates;
         }
     } else {
         if ($startDate) {
             $this->range_start = CaldavRessource::iCal2Timestamp($startDate);
             $this->range_end = NULL;
         } else {
             $this->range_start = NULL;
             $this->range_end = NULL;
         }
     }
     switch ($freq) {
         case 'HOURLY':
             $dates = $this->hourly();
             break;
         case 'DAILY':
             $dates = $this->daily();
             break;
         case 'WEEKLY':
             $dates = $this->weekly();
             break;
         case 'MONTHLY':
             $dates = $this->monthly();
             break;
         case 'YEARLY':
             $dates = $this->yearly();
             break;
         default:
             break;
     }
     //print_r($dates);
     return count($dates) > 0 ? $this->limitRange($dates) : $dates;
 }