/** * add photo data to VCard * * @param Addressbook_Model_Contact $record * @param \Sabre\VObject\Component $card */ protected function _fromTine20ModelAddPhoto(Addressbook_Model_Contact $record, \Sabre\VObject\Component $card) { if (!empty($record->jpegphoto)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__); try { $jpegData = $record->getSmallContactImage($this->_maxPhotoSize); $card->add('PHOTO', $jpegData, array('TYPE' => 'JPEG', 'ENCODING' => 'b')); } catch (Exception $e) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Image for contact {$record->getId()} not found or invalid: {$e->getMessage()}"); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString()); } } } }
/** * @see ActiveSync_Frontend_Abstract::toSyncrotonModel() * * @param Addressbook_Model_Contact $entry * @param array $options * @return Syncroton_Model_Contact */ public function toSyncrotonModel($entry, array $options = array()) { if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " contact data " . print_r($entry->toArray(), TRUE)); } $syncrotonContact = new Syncroton_Model_Contact(); foreach ($this->_mapping as $syncrotonProperty => $tine20Property) { // skip empty values if (empty($entry->{$tine20Property}) && $entry->{$tine20Property} != '0' || count($entry->{$tine20Property}) === 0) { continue; } switch ($tine20Property) { case 'adr_one_countryname': case 'adr_two_countryname': $syncrotonContact->{$syncrotonProperty} = Tinebase_Translation::getCountryNameByRegionCode($entry->{$tine20Property}); break; case 'bday': $syncrotonContact->{$syncrotonProperty} = $entry->{$tine20Property}; if ($this->_device->devicetype == Syncroton_Model_Device::TYPE_BLACKBERRY && version_compare($this->_device->getMajorVersion(), '10', '>=')) { // BB 10+ expects birthday to be at noon $syncrotonContact->{$syncrotonProperty}->addHour(12); } break; case 'note': $syncrotonContact->{$syncrotonProperty} = new Syncroton_Model_EmailBody(array('type' => Syncroton_Model_EmailBody::TYPE_PLAINTEXT, 'data' => $entry->{$tine20Property})); break; case 'jpegphoto': try { $syncrotonContact->{$syncrotonProperty} = $entry->getSmallContactImage(); } catch (Exception $e) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Image for contact {$entry->getId()} not found or invalid"); } break; // @todo validate tags are working // @todo validate tags are working case 'tags': $syncrotonContact->{$syncrotonProperty} = $entry->{$tine20Property}->name; break; default: $syncrotonContact->{$syncrotonProperty} = $entry->{$tine20Property}; break; } } return $syncrotonContact; }