Пример #1
0
 public function __toString() {
   $line = '';
   $upper_case = Vpdi::getConfig('always_encode_in_upper_case');
   if ($this->group !== null) {
     $line.= $this->group.'.';
   }
   $line.= ($upper_case) ? strtoupper($this->name) : $this->name;
   foreach ($this->params as $name => $values) {
     if (!is_array($values)) {
       $values = array($values);
     }
     if (count($values) === 0) {
       continue;
     }
     if (strtoupper($name) == 'TYPE' && Vpdi::getConfig('type_values_as_a_parameter_list') == true) {
       $list = array();
       foreach ($values as $v) {
         $list[] = 'TYPE='.$v;
       }
       $line.= ';'.implode(';', $list);
     } else {
       $line.= ';'.$name.'='.implode(',', $values);
     }
   }
   $line.= ':'.$this->value;
   
   return $line;
 }
Пример #2
0
 protected function getDateTime($propName) {
   $prop = $this->getProperty($propName);
   if (is_null($prop)) {
     return null;
   }
   $dt = Vpdi::decodeDateTime($prop->value());
   if (($tzid = $prop->getParam('TZID')) !== false) {
     $dt->setTimezone(Vpdi::decodeTimezone($tzid));
   }
   return $dt;
 }
Пример #3
0
 public function encode() {
   return new Vpdi_Property('n', Vpdi::encodeTextList(array($this->family, $this->given, 
     $this->additional, $this->prefixes, $this->suffixes), ';'));
 }
Пример #4
0
 /**
  * Returns the value for a property
  * 
  * @param Vpdi_Property $property
  * @access private
  * @return mixed
  */
 protected function decodeProperty($property) {
   return Vpdi::decodeText($property->value());
 }
Пример #5
0
 public function encode() {
   $parts = array();
   foreach (self::$addr_parts as $part) {
     $parts[] = $this->{$part};
   }
   $value = Vpdi::encodeTextList($parts, ';');
   
   $params = array();
   $params = array_merge($params, $this->location, $this->delivery);
   if ($this->preferred) {
     $params[] = 'pref';
   }
   return new Vpdi_Property('ADR', $value, array('TYPE' => $params));
 }
Пример #6
0
  public function getRrule() {
    if (($rrule = $this->getProperty('RRULE')) === null) {
      return null;
    }
    $data = Vpdi::decodeTextList($rrule->value(), ';');
    foreach($data as $d) {
      list($name, $value) = explode('=', $d);
      $name = strtolower($name);
      $property[$name]=$value;
    }
    $freq = strtolower($property['freq']);
    if (!in_array($freq, $this->frequency)) return null;

    $return = array();

    switch ($freq)  {
      case 'weekly':
        $days = '0000000';
        if(!is_null($property['byday'])) {
          $byday = Vpdi::decodeTextList($property['byday']);
          foreach($byday as $day) {
            $index = date('w', strtotime($this->weekDays[strtolower($day)]));
            $days[$index] = '1';
          }
        }
        $return['repeat_days'] = $days;
        break;
      case 'monthly' :
        if(!is_null($property['byday'])) {
          $freq = 'monthlybyday';
        } else {
          $freq = 'monthlybydate';
        }
        break;
    }

    $return['freq'] = $freq;
    if(is_numeric($property['interval'])) {
      $return['interval'] = $property['interval'];
    } else {
      $return['interval'] = 1;
    }

    if(!is_null($property['count'])) {
      $return['count'] = $property['count'];
    } elseif(!is_null($property['until'])) {
      $return['until'] = Vpdi::decodeDate($property['until']);
    }

    // Exceptions
    $return['exdates'] = null;
    if (($exdates = $this->getPropertiesByName('EXDATE')) != null) {
      foreach($exdates as $exdate) {
        $return['exdates'][] = new Of_Date($exdate->value());
      } 
    }
    return $return;
  }
Пример #7
0
 /**
  * Returns a DateTime object set to the value of the BDAY property
  * 
  * @access public
  * @return DateTime
  */
 public function getBday() {
   if (($bday = $this->getValue('BDAY')) === null) {
     return null;
   }
   return Vpdi::decodeDate($bday);
 }
Пример #8
0
 public function encode() {
   return new Vpdi_Property('FREEBUSY', Vpdi::encodePeriod($this->start, $this->end), array('FBTYPE' => $this->type));
 }
Пример #9
0
  private function get_freebusy_from_obmsync($obmsyncserver, $email){
      $obmSyncRootPath = "http://".$obmsyncserver.":8080";
      $freebusyUrl = $obmSyncRootPath."/obm-sync/freebusy/".rawurlencode($email)."?dataSource=remote";
      $ret = @file_get_contents($freebusyUrl);
      if (!$ret) {
	return false;
      }
      $calendar = reset(Vpdi::decode($ret));
      $periods = $calendar->getBusyPeriods();
      return $periods;
  }