Exemple #1
0
 /**
  * setRrule
  *
  * @param mixed $value
  * @param mixed $options
  * @access public
  * @return void
  */
 function parseRrule($value,$options) {
   $value = Vcalendar_Reader_ICS::parseAttributeValues(explode(';',$value));
   $rrule = array();
   $kind = strtolower($value['freq']);
   if(!in_array($kind,$this->frequency))  {
     //TODO Unsupported item. Error handler!
     return NULL;
   }
   $rrule['kind'] = $kind;
   if(is_numeric($value['interval'])) {
     $interval = $value['interval'];
   } else {
     $interval = 1;
   }
   $rrule['interval'] = $interval;
   foreach($value as $name => $repeat) {
     $repeat = strtolower($repeat);
     if(in_array($name,$this->repeat)) {
       $keys = explode(',',$repeat);
       foreach($keys as $key) {
         $rrule[$name][] = $this->weekDays[$key];
       }
     }
   }
   if(!is_null($value['count'])) {
     $rrule['count'] = $value['count'];
   } elseif(!is_null($value['until'])) {
     $rrule['until'] = $this->parseDate($value['until']);
   }
   return $rrule;
 }
Exemple #2
0
 /**
  * Perform the import of the vcalendar
  */
 private function user_vcalendar_import($fd, $user_id)
 {
     include_once 'php/calendar/calendar_query.inc';
     include_once 'php/calendar/event_observer.php';
     include_once 'obminclude/lib/Solr/Document.php';
     include_once 'obminclude/of/of_indexingService.inc';
     include_once 'obminclude/of/vcalendar/Utils.php';
     include_once 'obminclude/of/vcalendar/writer/OBM.php';
     include_once 'obminclude/of/vcalendar/reader/ICS.php';
     $remember_uid = $GLOBALS['obm']['uid'];
     $GLOBALS['obm']['uid'] = $user_id;
     // some kind of sudo $user_id
     //reset calendar
     run_query_calendar_reset($user_id, array('delete_meeting' => true));
     //restore calendar
     $reader = new Vcalendar_Reader_ICS($fd);
     $document = $reader->getDocument();
     $writer = new Vcalendar_Writer_OBM(true);
     $writer->writeDocument($document);
     $document->destroy();
     $GLOBALS['obm']['uid'] = $remember_uid;
 }