From 5684ba4442b3db9ea0c135f1013a70f515d98e1f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 6 Jan 2015 08:16:15 +0100 Subject: [PATCH] Now the glink table is written as well in the poco_check function. --- include/socgraph.php | 77 +++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/include/socgraph.php b/include/socgraph.php index 8b8eb915cc..623cf88cea 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -95,45 +95,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if(isset($entry->updated)) $updated = date("Y-m-d H:i:s", strtotime($entry->updated)); - if((! $name) || (! $profile_url) || (! $profile_photo)) - continue; - - $gcid = poco_check($profile_url, $name, $profile_photo, $connect_url, $updated); - - if(! $gcid) - return; - - $r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1", - intval($cid), - intval($uid), - intval($gcid), - intval($zcid) - ); - if(! count($r)) { - q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", - intval($cid), - intval($uid), - intval($gcid), - intval($zcid), - dbesc(datetime_convert()) - ); - } - else { - q("UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", - dbesc(datetime_convert()), - intval($cid), - intval($uid), - intval($gcid), - intval($zcid) - ); - } - - // For unknown reasons there are sometimes duplicates - q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d AND - NOT EXISTS (SELECT `gcid` FROM `glink` WHERE `gcid` = `gcontact`.`id`)", - dbesc(normalise_link($profile_url)), - intval($gcid) - ); + poco_check($profile_url, $name, $profile_photo, $connect_url, $updated, $cid, $uid, $zcid); } logger("poco_load: loaded $total entries",LOGGER_DEBUG); @@ -146,7 +108,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { } -function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated) { +function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated, $cid = 0, $uid = 0, $zcid = 0) { $gcid = ""; if (($profile_url == "") OR ($name == "") OR ($profile_photo == "")) @@ -188,6 +150,41 @@ function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated) if(count($x)) $gcid = $x[0]['id']; } + + if(! $gcid) + return $gcid; + + $r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1", + intval($cid), + intval($uid), + intval($gcid), + intval($zcid) + ); + if(! count($r)) { + q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", + intval($cid), + intval($uid), + intval($gcid), + intval($zcid), + dbesc(datetime_convert()) + ); + } else { + q("UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", + dbesc(datetime_convert()), + intval($cid), + intval($uid), + intval($gcid), + intval($zcid) + ); + } + + // For unknown reasons there are sometimes duplicates + q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d AND + NOT EXISTS (SELECT `gcid` FROM `glink` WHERE `gcid` = `gcontact`.`id`)", + dbesc(normalise_link($profile_url)), + intval($gcid) + ); + return $gcid; }