1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-30 19:52:17 +01:00

Merge branch 'master' into share_api

Conflicts:
	apps/contacts/lib/vcard.php
	apps/files_sharing/sharedstorage.php
This commit is contained in:
Michael Gapczynski 2012-08-09 11:38:22 -04:00
commit a1ac3767ce
17 changed files with 148 additions and 82 deletions

View File

@ -49,4 +49,10 @@ if(!$id) {
exit(); exit();
} }
OCP\JSON::success(array('data' => array( 'id' => $id, 'aid' => $aid ))); OCP\JSON::success(array(
'data' => array(
'id' => $id,
'aid' => $aid,
'lastmodified' => OC_Contacts_VCard::lastModified($vcard)->format('U')
)
));

View File

@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
require_once 'loghandler.php'; require_once __DIR__.'/../loghandler.php';
$id = isset($_POST['id'])?$_POST['id']:null; $id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null; $name = isset($_POST['name'])?$_POST['name']:null;
@ -144,4 +144,9 @@ if(!OC_Contacts_VCard::edit($id, $vcard)) {
bailOut($l10n->t('Error adding contact property: '.$name)); bailOut($l10n->t('Error adding contact property: '.$name));
} }
OCP\JSON::success(array('data' => array( 'checksum' => $checksum ))); OCP\JSON::success(array(
'data' => array(
'checksum' => $checksum,
'lastmodified' => OC_Contacts_VCard::lastModified($vcard)->format('U'))
)
);

View File

@ -23,7 +23,8 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
require_once 'loghandler.php';
require_once __DIR__.'/../loghandler.php';
$id = isset($_POST['id'])?$_POST['id']:null; $id = isset($_POST['id'])?$_POST['id']:null;
if(!$id) { if(!$id) {

View File

@ -24,7 +24,8 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
require_once 'loghandler.php';
require_once __DIR__.'/../loghandler.php';
$id = $_POST['id']; $id = $_POST['id'];
$checksum = $_POST['checksum']; $checksum = $_POST['checksum'];
@ -43,4 +44,9 @@ if(!OC_Contacts_VCard::edit($id, $vcard)) {
bailOut($l10n->t('Error deleting contact property.')); bailOut($l10n->t('Error deleting contact property.'));
} }
OCP\JSON::success(array('data' => array( 'id' => $id ))); OCP\JSON::success(array(
'data' => array(
'id' => $id,
'lastmodified' => OC_Contacts_VCard::lastModified($vcard)->format('U'),
)
));

View File

@ -53,5 +53,6 @@ if(isset($details['PHOTO'])) {
$details['id'] = $id; $details['id'] = $id;
$details['displayname'] = $card['fullname']; $details['displayname'] = $card['fullname'];
$details['addressbookid'] = $card['addressbookid']; $details['addressbookid'] = $card['addressbookid'];
$details['lastmodified'] = OC_Contacts_App::lastModified($vcard)->format('U');
OC_Contacts_App::setLastModifiedHeader($vcard); OC_Contacts_App::setLastModifiedHeader($vcard);
OCP\JSON::success(array('data' => $details)); OCP\JSON::success(array('data' => $details));

View File

@ -19,7 +19,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
require_once 'loghandler.php';
require_once __DIR__.'/../loghandler.php';
// Check if we are a user // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
@ -146,5 +148,6 @@ if(!OC_Contacts_VCard::edit($id, $vcard)) {
OCP\JSON::success(array('data' => array( OCP\JSON::success(array('data' => array(
'line' => $line, 'line' => $line,
'checksum' => $checksum, 'checksum' => $checksum,
'oldchecksum' => $_POST['checksum'])) 'oldchecksum' => $_POST['checksum']
); 'lastmodified' => OC_Contacts_VCard::lastModified($vcard)->format('U')
));

View File

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

View File

@ -141,4 +141,7 @@ input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; }
.addressbooks-settings .actions * { float: left; } .addressbooks-settings .actions * { float: left; }
.addressbooks-settings .actions input.name { width: 5em; } .addressbooks-settings .actions input.name { width: 5em; }
.addressbooks-settings .actions input.name { width: 7em; } .addressbooks-settings .actions input.name { width: 7em; }
.addressbooks-settings a.action { opacity: 0.2; }
.addressbooks-settings a.action:hover { opacity: 1; }
.addressbooks-settings td.active, .addressbooks-settings td.action { width: 20px; }

View File

@ -835,7 +835,7 @@ OC.Contacts={
OC.Contacts.propertyContainerFor(obj).data('checksum', ''); OC.Contacts.propertyContainerFor(obj).data('checksum', '');
if(proptype == 'PHOTO') { if(proptype == 'PHOTO') {
OC.Contacts.Contacts.refreshThumbnail(OC.Contacts.Card.id); OC.Contacts.Contacts.refreshThumbnail(OC.Contacts.Card.id);
OC.Contacts.Card.loadPhoto(true); OC.Contacts.Card.loadPhoto();
} else if(proptype == 'NOTE') { } else if(proptype == 'NOTE') {
$('#note').find('textarea').val(''); $('#note').find('textarea').val('');
OC.Contacts.propertyContainerFor(obj).hide(); OC.Contacts.propertyContainerFor(obj).hide();
@ -1218,9 +1218,9 @@ OC.Contacts={
} }
}); });
}, },
loadPhoto:function(refresh){ loadPhoto:function(){
var self = this; var self = this;
var refreshstr = (refresh?'&refresh=1'+Math.random():'') var refreshstr = ''; //'&refresh='+Math.random();
$('#phototools li a').tipsy('hide'); $('#phototools li a').tipsy('hide');
var wrapper = $('#contacts_details_photo_wrapper'); var wrapper = $('#contacts_details_photo_wrapper');
wrapper.addClass('loading').addClass('wait'); wrapper.addClass('loading').addClass('wait');
@ -1278,7 +1278,7 @@ OC.Contacts={
var response=jQuery.parseJSON(target.contents().text()); var response=jQuery.parseJSON(target.contents().text());
if(response != undefined && response.status == 'success'){ if(response != undefined && response.status == 'success'){
// load cropped photo. // load cropped photo.
self.loadPhoto(true); self.loadPhoto();
OC.Contacts.Card.data.PHOTO = true; OC.Contacts.Card.data.PHOTO = true;
}else{ }else{
OC.dialogs.alert(response.data.message, t('contacts', 'Error')); OC.dialogs.alert(response.data.message, t('contacts', 'Error'));

View File

@ -90,8 +90,7 @@ OC.Contacts.Settings = OC.Contacts.Settings || {
+ '<td class="action"><a class="svg action globe" title="'+t('contacts', 'Show CardDav link')+'"></a></td>' + '<td class="action"><a class="svg action globe" title="'+t('contacts', 'Show CardDav link')+'"></a></td>'
+ '<td class="action"><a class="svg action cloud" title="'+t('contacts', 'Show read-only VCF link')+'"></a></td>' + '<td class="action"><a class="svg action cloud" title="'+t('contacts', 'Show read-only VCF link')+'"></a></td>'
+ '<td class="action"><a class="svg action download" title="'+t('contacts', 'Download')+'" ' + '<td class="action"><a class="svg action download" title="'+t('contacts', 'Download')+'" '
+ 'href="'+totalurl+'/'+encodeURIComponent(oc_current_user)+'/' + 'href="'+OC.linkTo('contacts', 'export.php')+'?bookid='+jsondata.data.addressbook.id+'"></a></td>'
+ encodeURIComponent(jsondata.data.addressbook.uri)+'?export"></a></td>'
+ '<td class="action"><a class="svg action edit" title="'+t('contacts', 'Edit')+'"></a></td>' + '<td class="action"><a class="svg action edit" title="'+t('contacts', 'Edit')+'"></a></td>'
+ '<td class="action"><a class="svg action delete" title="'+t('contacts', 'Delete')+'"></a></td>' + '<td class="action"><a class="svg action delete" title="'+t('contacts', 'Delete')+'"></a></td>'
+ '</tr>'); + '</tr>');
@ -107,17 +106,27 @@ OC.Contacts.Settings = OC.Contacts.Settings || {
} }
}); });
}, },
showLink:function(id, row, link) {
console.log('row:', row.length);
row.next('tr.link').remove();
var linkrow = $('<tr class="link"><td colspan="5"><input style="width: 95%;" type="text" value="'+link+'" /></td>'
+ '<td colspan="3"><button>'+t('contacts', 'Cancel')+'</button></td></tr>').insertAfter(row);
linkrow.find('input').focus().select();
linkrow.find('button').click(function() {
$(this).parents('tr').first().remove();
});
},
showCardDAV:function(id) { showCardDAV:function(id) {
console.log('showCardDAV: ', id); console.log('showCardDAV: ', id);
var row = this.adrsettings.find('tr[data-id="'+id+'"]'); var row = this.adrsettings.find('tr[data-id="'+id+'"]');
this.adractions.find('.link').val(totalurl+'/'+encodeURIComponent(oc_current_user)+'/'); this.showLink(id, row, totalurl+'/'+encodeURIComponent(oc_current_user));
this.showActions(['link','cancel']);
}, },
showVCF:function(id) { showVCF:function(id) {
console.log('showVCF: ', id); console.log('showVCF: ', id);
var row = this.adrsettings.find('tr[data-id="'+id+'"]'); var row = this.adrsettings.find('tr[data-id="'+id+'"]');
this.adractions.find('.link').val(totalurl+'/'+encodeURIComponent(oc_current_user)+'/'+encodeURIComponent(row.data('uri'))+'?export'); var link = totalurl+'/'+encodeURIComponent(oc_current_user)+'/'+encodeURIComponent(row.data('uri'))+'?export';
this.showActions(['link','cancel']); console.log(link);
this.showLink(id, row, link);
} }
} }
}; };

View File

@ -108,6 +108,8 @@
"Next contact in list" => "Nächster Kontakt aus der Liste", "Next contact in list" => "Nächster Kontakt aus der Liste",
"Previous contact in list" => "Vorheriger Kontakt aus der Liste", "Previous contact in list" => "Vorheriger Kontakt aus der Liste",
"Expand/collapse current addressbook" => "Ausklappen/Einklappen des Adressbuches", "Expand/collapse current addressbook" => "Ausklappen/Einklappen des Adressbuches",
"Next addressbook" => "Nächstes Adressbuch",
"Previous addressbook" => "Vorheriges Adressbuch",
"Actions" => "Aktionen", "Actions" => "Aktionen",
"Refresh contacts list" => "Kontaktliste neu laden", "Refresh contacts list" => "Kontaktliste neu laden",
"Add new contact" => "Neuen Kontakt hinzufügen", "Add new contact" => "Neuen Kontakt hinzufügen",

View File

@ -63,6 +63,8 @@
"Result: " => "Résultat :", "Result: " => "Résultat :",
" imported, " => "importé,", " imported, " => "importé,",
" failed." => "échoué.", " failed." => "échoué.",
"Displayname cannot be empty." => "Le nom d'affichage ne peut pas être vide.",
"Addressbook not found: " => "Carnet d'adresse introuvable : ",
"This is not your addressbook." => "Ce n'est pas votre carnet d'adresses.", "This is not your addressbook." => "Ce n'est pas votre carnet d'adresses.",
"Contact could not be found." => "Ce contact n'a pu être trouvé.", "Contact could not be found." => "Ce contact n'a pu être trouvé.",
"Address" => "Adresse", "Address" => "Adresse",
@ -97,6 +99,7 @@
"Contact" => "Contact", "Contact" => "Contact",
"Add Contact" => "Ajouter un Contact", "Add Contact" => "Ajouter un Contact",
"Import" => "Importer", "Import" => "Importer",
"Settings" => "Paramètres",
"Addressbooks" => "Carnets d'adresses", "Addressbooks" => "Carnets d'adresses",
"Close" => "Fermer", "Close" => "Fermer",
"Keyboard shortcuts" => "Raccourcis clavier", "Keyboard shortcuts" => "Raccourcis clavier",
@ -104,6 +107,8 @@
"Next contact in list" => "Contact suivant dans la liste", "Next contact in list" => "Contact suivant dans la liste",
"Previous contact in list" => "Contact précédent dans la liste", "Previous contact in list" => "Contact précédent dans la liste",
"Expand/collapse current addressbook" => "Dé/Replier le carnet d'adresses courant", "Expand/collapse current addressbook" => "Dé/Replier le carnet d'adresses courant",
"Next addressbook" => "Carnet d'adresses suivant",
"Previous addressbook" => "Carnet d'adresses précédent",
"Actions" => "Actions", "Actions" => "Actions",
"Refresh contacts list" => "Actualiser la liste des contacts", "Refresh contacts list" => "Actualiser la liste des contacts",
"Add new contact" => "Ajouter un nouveau contact", "Add new contact" => "Ajouter un nouveau contact",
@ -190,9 +195,13 @@
"more info" => "Plus d'infos", "more info" => "Plus d'infos",
"Primary address (Kontact et al)" => "Adresse principale", "Primary address (Kontact et al)" => "Adresse principale",
"iOS/OS X" => "iOS/OS X", "iOS/OS X" => "iOS/OS X",
"Show CardDav link" => "Afficher le lien CardDav",
"Download" => "Télécharger", "Download" => "Télécharger",
"Edit" => "Modifier", "Edit" => "Modifier",
"New Address Book" => "Nouveau Carnet d'adresses", "New Address Book" => "Nouveau Carnet d'adresses",
"Name" => "Nom",
"Description" => "Description",
"Save" => "Sauvegarder", "Save" => "Sauvegarder",
"Cancel" => "Annuler" "Cancel" => "Annuler",
"More..." => "Plus…"
); );

View File

@ -243,6 +243,18 @@ class OC_Contacts_App {
self::getVCategories()->loadFromVObject($contact, true); self::getVCategories()->loadFromVObject($contact, true);
} }
/**
* @brief Get the last modification time.
* @param $vcard OC_VObject
* $return DateTime | null
*/
public static function lastModified($vcard) {
$rev = $vcard->getAsString('REV');
if ($rev) {
return DateTime::createFromFormat(DateTime::W3C, $rev);
}
}
public static function setLastModifiedHeader($contact) { public static function setLastModifiedHeader($contact) {
$rev = $contact->getAsString('REV'); $rev = $contact->getAsString('REV');
if ($rev) { if ($rev) {

View File

@ -282,12 +282,13 @@ class OC_Contacts_VCard{
/** /**
* @brief Adds a card * @brief Adds a card
* @param integer $aid Addressbook id * @param $aid integer Addressbook id
* @param OC_VObject $card vCard file * @param $card OC_VObject vCard file
* @param string $uri the uri of the card, default based on the UID * @param $uri string the uri of the card, default based on the UID
* @param $isChecked boolean If the vCard should be checked for validity and version.
* @return insertid on success or false. * @return insertid on success or false.
*/ */
public static function add($aid, OC_VObject $card, $uri=null, $isnew=false){ public static function add($aid, OC_VObject $card, $uri=null, $isChecked=false){
if(is_null($card)) { if(is_null($card)) {
OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR); OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
return null; return null;
@ -295,22 +296,13 @@ class OC_Contacts_VCard{
$addressbook = OC_Contacts_Addressbook::find($aid); $addressbook = OC_Contacts_Addressbook::find($aid);
if ($addressbook['userid'] != OCP\User::getUser()) { if ($addressbook['userid'] != OCP\User::getUser()) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid);
if (!$sharedAddressbook) { if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_CREATE)) {
return false; return false;
} }
} else {
$sharedAddressbook = false;
}
if(!$isnew) {
if ($sharedAddressbook && !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_UPDATE)) {
return false;
} }
if(!$isChecked) {
OC_Contacts_App::loadCategoriesFromVCard($card); OC_Contacts_App::loadCategoriesFromVCard($card);
self::updateValuesFromAdd($aid, $card); self::updateValuesFromAdd($aid, $card);
} else {
if ($sharedAddressbook && !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_CREATE)) {
return false;
}
} }
$card->setString('VERSION', '3.0'); $card->setString('VERSION', '3.0');
// Add product ID is missing. // Add product ID is missing.

View File

@ -20,7 +20,8 @@ function getStandardImage() {
} }
$id = isset($_GET['id']) ? $_GET['id'] : null; $id = isset($_GET['id']) ? $_GET['id'] : null;
$caching = isset($_GET['refresh']) ? 0 : null; $etag = null;
$caching = null;
if(is_null($id)) { if(is_null($id)) {
getStandardImage(); getStandardImage();
@ -43,21 +44,30 @@ if (is_null($contact)) {
'photo.php. The VCard for ID ' . $id . ' is not RFC compatible', 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible',
OCP\Util::ERROR); OCP\Util::ERROR);
} else { } else {
OCP\Response::enableCaching($caching);
OC_Contacts_App::setLastModifiedHeader($contact);
// Photo :-) // Photo :-)
if ($image->loadFromBase64($contact->getAsString('PHOTO'))) { if ($image->loadFromBase64($contact->getAsString('PHOTO'))) {
// OK // OK
OCP\Response::setETagHeader(md5($contact->getAsString('PHOTO'))); $etag = md5($contact->getAsString('PHOTO'));
} }
else else
// Logo :-/ // Logo :-/
if ($image->loadFromBase64($contact->getAsString('LOGO'))) { if ($image->loadFromBase64($contact->getAsString('LOGO'))) {
// OK // OK
OCP\Response::setETagHeader(md5($contact->getAsString('LOGO'))); $etag = md5($contact->getAsString('LOGO'));
} }
if ($image->valid()) { if ($image->valid()) {
$modified = OC_Contacts_App::lastModified($contact);
// Force refresh if modified within the last minute.
if(!is_null($modified)) {
$caching = (time() - $modified->format('U') > 60) ? null : 0;
}
OCP\Response::enableCaching($caching);
if(!is_null($modified)) {
OCP\Response::setLastModifiedHeader($modified);
}
if($etag) {
OCP\Response::setETagHeader($etag);
}
$max_size = 200; $max_size = 200;
if ($image->width() > $max_size || $image->height() > $max_size) { if ($image->width() > $max_size || $image->height() > $max_size) {
$image->resize($max_size); $image->resize($max_size);

View File

@ -27,8 +27,7 @@
</td> </td>
<td class="action"> <td class="action">
<a class="svg action download" title="<?php echo $l->t('Download'); ?>" <a class="svg action download" title="<?php echo $l->t('Download'); ?>"
href="<?php echo OCP\Util::linkToRemote('carddav').'addressbooks/'.OCP\USER::getUser().'/' href="<?php echo OCP\Util::linkToAbsolute('contacts', 'export.php'); ?>?bookid=<?php echo $addressbook['id'] ?>"></a>
.rawurlencode($addressbook['uri']) ?>?export"></a>
</td> </td>
<td class="action"> <td class="action">
<a class="svg action edit" title="<?php echo $l->t("Edit"); ?>"></a> <a class="svg action edit" title="<?php echo $l->t("Edit"); ?>"></a>
@ -44,7 +43,6 @@
<button class="new"><?php echo $l->t('New Address Book') ?></button> <button class="new"><?php echo $l->t('New Address Book') ?></button>
<input class="name hidden" type="text" autofocus="autofocus" placeholder="<?php echo $l->t('Name'); ?>" /> <input class="name hidden" type="text" autofocus="autofocus" placeholder="<?php echo $l->t('Name'); ?>" />
<input class="description hidden" type="text" placeholder="<?php echo $l->t('Description'); ?>" /> <input class="description hidden" type="text" placeholder="<?php echo $l->t('Description'); ?>" />
<input class="link hidden" style="width: 80%" type="text" autofocus="autofocus" />
<button class="save hidden"><?php echo $l->t('Save') ?></button> <button class="save hidden"><?php echo $l->t('Save') ?></button>
<button class="cancel hidden"><?php echo $l->t('Cancel') ?></button> <button class="cancel hidden"><?php echo $l->t('Cancel') ?></button>
</div> </div>

View File

@ -26,7 +26,6 @@ OCP\App::checkAppEnabled('contacts');
session_write_close(); session_write_close();
function getStandardImage() { function getStandardImage() {
//OCP\Response::setExpiresHeader('P10D');
OCP\Response::enableCaching(); OCP\Response::enableCaching();
OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person.png')); OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person.png'));
} }
@ -39,7 +38,7 @@ if(!extension_loaded('gd') || !function_exists('gd_info')) {
} }
$id = $_GET['id']; $id = $_GET['id'];
$caching = isset($_GET['refresh']) ? 0 : null; $caching = null;
$contact = OC_Contacts_App::getContactVCard($id); $contact = OC_Contacts_App::getContactVCard($id);
@ -60,10 +59,19 @@ $thumbnail_size = 23;
$image = new OC_Image(); $image = new OC_Image();
$photo = $contact->getAsString('PHOTO'); $photo = $contact->getAsString('PHOTO');
if($photo) { if($photo) {
OCP\Response::setETagHeader(md5($photo));
if($image->loadFromBase64($photo)) { if($image->loadFromBase64($photo)) {
if($image->centerCrop()) { if($image->centerCrop()) {
if($image->resize($thumbnail_size)) { if($image->resize($thumbnail_size)) {
$modified = OC_Contacts_App::lastModified($contact);
// Force refresh if modified within the last minute.
if(!is_null($modified)) {
$caching = (time() - $modified->format('U') > 60) ? null : 0;
}
OCP\Response::enableCaching($caching);
if(!is_null($modified)) {
OCP\Response::setLastModifiedHeader($modified);
}
OCP\Response::setETagHeader(md5($photo));
if($image->show()) { if($image->show()) {
exit(); exit();
} else { } else {