} if (!extension_loaded('gd') || !function_exists('gd_info')) { OCP\Util::writeLog('contacts', 'photo.php. GD module not installed', OCP\Util::DEBUG); getStandardImage(); } $contact = OC_Contacts_App::getContactVCard($id); $image = new OC_Image(); if (!$image) { getStandardImage(); } // invalid vcard if (is_null($contact)) { OCP\Util::writeLog('contacts', 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible', OCP\Util::ERROR); } else { OCP\Response::enableCaching($caching); OC_Contacts_App::setLastModifiedHeader($contact); // Photo :-) if ($image->loadFromBase64($contact->getAsString('PHOTO'))) { // OK OCP\Response::setETagHeader(md5($contact->getAsString('PHOTO'))); } else { // Logo :-/ if ($image->loadFromBase64($contact->getAsString('LOGO'))) { // OK OCP\Response::setETagHeader(md5($contact->getAsString('LOGO'))); } } if ($image->valid()) { $max_size = 200; if ($image->width() > $max_size || $image->height() > $max_size) { $image->resize($max_size);
$vcard = OC_Contacts_App::getContactVCard($id); if (is_null($vcard)) { bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "' . $id . '"')); } $details = OC_Contacts_VCard::structureContact($vcard); // Some Google exported files have no FN field. /*if(!isset($details['FN'])) { $fn = ''; if(isset($details['N'])) { $details['FN'] = array(implode(' ', $details['N'][0]['value'])); } elseif(isset($details['EMAIL'])) { $details['FN'] = array('value' => $details['EMAIL'][0]['value']); } else { $details['FN'] = array('value' => OC_Contacts_App::$l10n->t('Unknown')); } }*/ // Make up for not supporting the 'N' field in earlier version. if (!isset($details['N'])) { $details['N'] = array(); $details['N'][0] = array($details['FN'][0]['value'], '', '', '', ''); } // Don't wanna transfer the photo in a json string. if (isset($details['PHOTO'])) { $details['PHOTO'] = true; //unset($details['PHOTO']); } else { $details['PHOTO'] = false; } $details['id'] = $id; OC_Contacts_App::setLastModifiedHeader($vcard); OCP\JSON::success(array('data' => $details));