Horde_SyncMl_Device_sync4j::sif2vtodo PHP Méthode

sif2vtodo() public méthode

public sif2vtodo ( $sif )
    public function sif2vtodo($sif)
    {
        $a = Horde_SyncMl_Device_sync4j::sif2array($sif);
        $iCal = new Horde_Icalendar();
        $iCal->setAttribute('PRODID', '-//The Horde Project//SyncML//EN');
        $iCal->setAttribute('METHOD', 'PUBLISH');
        $vtodo = Horde_Icalendar::newComponent('vtodo', $iCal);
        $vtodo->setAttribute('SUMMARY', $a['Subject']);
        $vtodo->setAttribute('DESCRIPTION', $a['Body']);
        if ($a['Importance'] == 0) {
            $vtodo->setAttribute('PRIORITY', 5);
        } elseif ($a['Importance'] == 2) {
            $vtodo->setAttribute('PRIORITY', 1);
        } else {
            $vtodo->setAttribute('PRIORITY', 3);
        }
        if (!empty($a['StartDate']) && $a['StartDate'] != '45001231T230000Z') {
            $vtodo->setAttribute('DTSTART', $iCal->_parseDateTime($a['StartDate']));
        }
        $dueSet = false;
        if (!empty($a['DueDate']) && $a['DueDate'] != '45001231T230000Z') {
            $vtodo->setAttribute('DUE', $iCal->_parseDateTime($a['DueDate']));
            $dueSet = true;
        }
        if (!empty($a['ReminderSet'])) {
            if (!$dueSet) {
                $vtodo->setAttribute('DUE', $iCal->_parseDateTime($a['ReminderTime']));
            }
            $vtodo->setAttribute('AALARM', $iCal->_parseDateTime($a['ReminderTime']));
        }
        if (!empty($a['Complete'])) {
            $vtodo->setAttribute('STATUS', 'COMPLETED');
        }
        $vtodo->setAttribute('CATEGORIES', isset($a['Categories']) ? $a['Categories'] : '');
        if (isset($a['Sensitivity'])) {
            switch ($a['Sensitivity']) {
                case 0:
                    /* olNormal */
                    $vtodo->setAttribute('CLASS', 'PUBLIC');
                    break;
                case 1:
                    /* olPersonal */
                /* olPersonal */
                case 2:
                    /* olPrivate */
                    $vtodo->setAttribute('CLASS', 'PRIVATE');
                    break;
                case 3:
                    /* olConfidential */
                    $vtodo->setAttribute('CLASS', 'CONFIDENTIAL');
                    break;
            }
        }
        return $vtodo->exportvCalendar();
    }

Usage Example

Exemple #1
0
 /**
  * Convert the content.
  */
 public function convertClient2Server($content, $contentType)
 {
     list($content, $contentType) = parent::convertClient2Server($content, $contentType);
     switch ($contentType) {
         case 'text/x-s4j-sifn':
         case 'text/x-sifn':
             $content = Horde_SyncMl_Device_sync4j::sif2vnote($content);
             $contentType = 'text/x-vnote';
             break;
         case 'text/x-s4j-sifc':
         case 'text/x-sifc':
             $content = Horde_SyncMl_Device_sync4j::sif2vcard($content);
             $contentType = 'text/x-vcard';
             break;
         case 'text/x-s4j-sife':
         case 'text/x-sife':
             $content = Horde_SyncMl_Device_sync4j::sif2vevent($content);
             $contentType = 'text/calendar';
             break;
         case 'text/x-s4j-sift':
         case 'text/x-sift':
             $content = Horde_SyncMl_Device_sync4j::sif2vtodo($content);
             $contentType = 'text/calendar';
             break;
         case 'text/calendar':
         case '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);
             }
             break;
     }
     $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, "\nInput converted for server ({$contentType}):\n{$content}\n");
     return array($content, $contentType);
 }
All Usage Examples Of Horde_SyncMl_Device_sync4j::sif2vtodo