aboutsummaryrefslogtreecommitdiffstats
path: root/include
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
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')
-rw-r--r--include/items.php8
-rw-r--r--include/poller.php51
2 files changed, 56 insertions, 3 deletions
diff --git a/include/items.php b/include/items.php
index e74132c6a..876f92330 100644
--- a/include/items.php
+++ b/include/items.php
@@ -61,6 +61,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`,
+ `contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@@ -91,7 +92,12 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
'$name' => xmlify($owner['name']),
'$profile_page' => xmlify($owner['url']),
- '$photo' => xmlify($owner['photo'])
+ '$photo' => xmlify($owner['photo']),
+ '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+ '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+ '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+
+
));
foreach($items as $item) {
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),