vtodo2sif() public method

public vtodo2sif ( $vcard )
Example #1
0
 /**
  * Converts the content from the backend to a format suitable for the
  * client device.
  *
  * Strips the uid (primary key) information as client and server might use
  * different ones.
  *
  * @param string $content      The content to convert
  * @param string $contentType  The content type of content as returned
  *                             from the backend
  * @param string $database     The server database URI.
  *
  * @return array  Three-element array with the converted content, the
  *                (possibly changed) new content type, and encoding type
  *                (like b64 as used by Funambol).
  */
 public function convertServer2Client($content, $contentType, $database)
 {
     $database = $GLOBALS['backend']->normalize($database);
     list($content, $contentType, $encodingType) = parent::convertServer2Client($content, $contentType, $database);
     if ($this->requestedContentType == $contentType) {
         if ($contentType == 'text/calendar' || $contentType == 'text/x-vcalendar') {
             $si = $GLOBALS['backend']->state->sourceURI;
             if (stristr($si, 'fol-') !== false) {
                 // The Funambol Outlook connector uses invalid STATUS
                 // values. Actually it maps MeetingStatus values of the
                 // Outlook event to the STATUS property, which is
                 // completely useless. So drop the STATUS altogether.
                 $content = preg_replace('/^STATUS:.*\\r?\\n/im', '', $content);
             }
         }
         return array($content, $contentType, $encodingType);
     }
     switch ($contentType) {
         case 'text/calendar':
         case 'text/x-vcalendar':
             switch ($database) {
                 case 'calendar':
                     $content = Horde_SyncMl_Device_sync4j::vevent2sif($content);
                     $content = base64_encode($content);
                     $contentType = 'text/x-s4j-sife';
                     break 2;
                 case 'tasks':
                     $content = Horde_SyncMl_Device_sync4j::vtodo2sif($content);
                     $content = base64_encode($content);
                     $contentType = 'text/x-s4j-sift';
                     break 2;
             }
             break;
         case 'text/x-vcard':
             $content = Horde_SyncMl_Device_sync4j::vcard2sif($content);
             $content = base64_encode($content);
             $contentType = 'text/x-s4j-sifc';
             break;
         case 'text/x-vnote':
         case 'text/plain':
             $content = Horde_SyncMl_Device_sync4j::vnote2sif($content);
             $content = base64_encode($content);
             $contentType = 'text/x-s4j-sifn';
             break;
     }
     $l = "\nOutput converted for client ({$contentType}):\n" . base64_decode($content) . "\n";
     $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, $l);
     return array($content, $contentType, 'b64');
 }