diff options
Diffstat (limited to 'apps/contacts/ajax/savecrop.php')
-rw-r--r-- | apps/contacts/ajax/savecrop.php | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php index 1df5299c7a6..2483d0f7128 100644 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -62,17 +62,17 @@ if($data) { if($image->crop($x1, $y1, $w, $h)) { if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) { - $card = OC_Contacts_App::getContactVCard($id); - if(!$card) { + $vcard = OC_Contacts_App::getContactVCard($id); + if(!$vcard) { OC_Cache::remove($tmpkey); bailOut(OC_Contacts_App::$l10n ->t('Error getting contact object.')); } - if($card->__isset('PHOTO')) { + if($vcard->__isset('PHOTO')) { OCP\Util::writeLog('contacts', 'savecrop.php: PHOTO property exists.', OCP\Util::DEBUG); - $property = $card->__get('PHOTO'); + $property = $vcard->__get('PHOTO'); if(!$property) { OC_Cache::remove($tmpkey); bailOut(OC_Contacts_App::$l10n @@ -83,27 +83,28 @@ if($data) { = new Sabre_VObject_Parameter('ENCODING', 'b'); $property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType()); - $card->__set('PHOTO', $property); + $vcard->__set('PHOTO', $property); } else { OCP\Util::writeLog('contacts', 'savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG); - $card->addProperty('PHOTO', + $vcard->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType())); } $now = new DateTime; - $card->setString('REV', $now->format(DateTime::W3C)); - if(!OC_Contacts_VCard::edit($id, $card)) { + $vcard->setString('REV', $now->format(DateTime::W3C)); + if(!OC_Contacts_VCard::edit($id, $vcard)) { bailOut(OC_Contacts_App::$l10n->t('Error saving contact.')); } - $tmpl = new OCP\Template("contacts", "part.contactphoto"); - $tmpl->assign('id', $id); - $tmpl->assign('refresh', true); - $tmpl->assign('width', $image->width()); - $tmpl->assign('height', $image->height()); - $page = $tmpl->fetchPage(); - OCP\JSON::success(array('data' => array('page'=>$page))); + OCP\JSON::success(array( + 'data' => array( + 'id' => $id, + 'width' => $image->width(), + 'height' => $image->height(), + 'lastmodified' => OC_Contacts_App::lastModified($vcard)->format('U') + ) + )); } else { bailOut(OC_Contacts_App::$l10n->t('Error resizing image')); } |