summaryrefslogtreecommitdiffstats
path: root/apps/contacts/photo.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contacts/photo.php')
-rw-r--r--apps/contacts/photo.php28
1 files changed, 19 insertions, 9 deletions
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index efdf157cd95..f5c8e6fe4bd 100644
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -20,14 +20,15 @@ function getStandardImage() {
}
$id = isset($_GET['id']) ? $_GET['id'] : null;
-$caching = isset($_GET['refresh']) ? 0 : null;
+$etag = null;
+$caching = null;
if(is_null($id)) {
getStandardImage();
}
if(!extension_loaded('gd') || !function_exists('gd_info')) {
- OCP\Util::writeLog('contacts',
+ OCP\Util::writeLog('contacts',
'photo.php. GD module not installed', OCP\Util::DEBUG);
getStandardImage();
}
@@ -39,25 +40,34 @@ if (!$image) {
}
// invalid vcard
if (is_null($contact)) {
- OCP\Util::writeLog('contacts',
- 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible',
+ 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')));
+ $etag = md5($contact->getAsString('PHOTO'));
}
else
// Logo :-/
if ($image->loadFromBase64($contact->getAsString('LOGO'))) {
// OK
- OCP\Response::setETagHeader(md5($contact->getAsString('LOGO')));
+ $etag = md5($contact->getAsString('LOGO'));
}
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;
if ($image->width() > $max_size || $image->height() > $max_size) {
$image->resize($max_size);