aboutsummaryrefslogtreecommitdiffstats
path: root/include/poller.php
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-08-08 21:03:08 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-08-08 21:03:08 -0700
commitd11c1c63c02e88b3c73336741a2240ccc18d3b02 (patch)
treeaf32bf9355c99c578f696aec91f66374acd82208 /include/poller.php
parent0bcd5522315649c8d4652b8bfaa9bec328b9d548 (diff)
downloadvolse-hubzilla-d11c1c63c02e88b3c73336741a2240ccc18d3b02.tar.gz
volse-hubzilla-d11c1c63c02e88b3c73336741a2240ccc18d3b02.tar.bz2
volse-hubzilla-d11c1c63c02e88b3c73336741a2240ccc18d3b02.zip
lots of fixes - most recent photo updates for contacts
Diffstat (limited to 'include/poller.php')
-rw-r--r--include/poller.php51
1 files changed, 49 insertions, 2 deletions
diff --git a/include/poller.php b/include/poller.php
index be073b93b..0ef4d126a 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -123,6 +123,51 @@ echo "Length:" . strlen($xml) . "\r\n";
$feed->enable_order_by_date(false);
$feed->init();
+ $photo_rawupdate = $feed->get_feed_tags(NAMESPACE_DFRN,'icon-updated');
+ if($photo_rawupdate) {
+ $photo_timestamp = datetime_convert('UTC','UTC',$photo_rawupdate[0]['data']);
+ $photo_url = $feed->get_image_url();
+ if(strlen($photo_url) && $photo_timestamp > $contact['avatar-date']) {
+
+ require_once("Photo.php");
+
+ $photo_failure = false;
+
+ $r = q("SELECT `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d LIMIT 1",
+ intval($contact['id']),
+ intval($contact['uid'])
+ );
+ if(count($r)) {
+ $resource_id = $r[0]['resource-id'];
+ $img_str = fetch_url($photo_url,true);
+ $img = new Photo($img_str);
+ if($img) {
+ q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND contact-id` = %d AND `uid` = %d",
+ dbesc($resource_id),
+ intval($contact['id']),
+ intval($contact['uid'])
+ );
+
+ $img->scaleImageSquare(175);
+
+ $hash = $resource_id;
+
+ $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 4);
+
+ $img->scaleImage(80);
+ $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 5);
+ if($r)
+ q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
+ intval($contact['uid']),
+ intval($contact['id'])
+ );
+ }
+ }
+ }
+ }
+
+
foreach($feed->get_items() as $item) {
$deleted = false;
@@ -145,14 +190,16 @@ echo "Length:" . strlen($xml) . "\r\n";
);
if(count($r)) {
if($r[0]['uri'] == $r[0]['parent-uri']) {
- $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s'
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s',
+ `body` = '', `title` = ''
WHERE `parent-uri` = '%s'",
dbesc($when),
dbesc($r[0]['uri'])
);
}
else {
- $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s'
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s',
+ `body` = '', `title` = ''
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($when),
dbesc($uri),