From 2e81d0a2b3cd2b76495472c8ee2ef04524c2447a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 5 Nov 2015 10:55:00 +0100 Subject: [PATCH 1/3] Fetch the "addr" value whenever it is empty --- include/socgraph.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/socgraph.php b/include/socgraph.php index 5c8da3cc2a..c5aa08d086 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -235,7 +235,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca $addr = ""; } - if ((($network == "") OR ($name == "") OR ($profile_photo == "") OR ($server_url == "") OR $alternate) + if ((($network == "") OR ($name == "") OR ($addr == "") OR ($profile_photo == "") OR ($server_url == "") OR $alternate) AND poco_reachable($profile_url, $server_url, $network, false)) { $data = probe_url($profile_url); From 0f41f35041bb4f240d359a1ffed91f8bc4eb89a4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 6 Nov 2015 00:47:54 +0100 Subject: [PATCH 2/3] The contact template now displays the address if available --- include/Contact.php | 10 +- include/update_gcontact.php | 114 ++++++++++++++++++ mod/allfriends.php | 2 +- mod/common.php | 4 +- mod/contacts.php | 2 +- mod/dirfind.php | 10 +- mod/match.php | 7 +- mod/nogroup.php | 6 +- mod/suggest.php | 8 +- mod/viewcontacts.php | 9 +- view/theme/vier/mobile.css | 2 + view/theme/vier/style.css | 2 +- .../theme/vier/templates/contact_template.tpl | 6 +- 13 files changed, 164 insertions(+), 18 deletions(-) create mode 100644 include/update_gcontact.php diff --git a/include/Contact.php b/include/Contact.php index 04cf3b4395..5138f276be 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -198,12 +198,16 @@ function get_contact_details_by_url($url, $uid = -1) { if ($uid == -1) $uid = local_user(); - $r = q("SELECT `url`, `name`, `nick`, `addr`. `photo`, `location`, `about`, `keywords`, `gender`, `community`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", + $r = q("SELECT `id` AS `gid`, `url`, `name`, `nick`, `addr`, `photo`, `location`, `about`, `keywords`, `gender`, `community`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link($url))); - if ($r) + if ($r) { $profile = $r[0]; - else { + + if ($profile["addr"] == "") + proc_run('php',"include/update_gcontact.php", $profile["gid"]); + + } else { $r = q("SELECT `url`, `name`, `nick`, `avatar` AS `photo`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", dbesc(normalise_link($url))); diff --git a/include/update_gcontact.php b/include/update_gcontact.php new file mode 100644 index 0000000000..05cfba96c1 --- /dev/null +++ b/include/update_gcontact.php @@ -0,0 +1,114 @@ +set_baseurl(get_config('system','url')); + + load_hooks(); + + logger('update_gcontact: start'); + + $manual_id = 0; + $generation = 0; + $hub_update = false; + $force = false; + $restart = false; + + if(($argc > 1) && (intval($argv[1]))) + $contact_id = intval($argv[1]); + + if(($argc > 2) && ($argv[2] == "force")) + $force = true; + + if(!$contact_id) { + logger('update_gcontact: no contact'); + return; + } + + $lockpath = get_lockpath(); + if ($lockpath != '') { + $pidfile = new pidfile($lockpath, 'update_gcontact'.$contact_id); + if ($pidfile->is_already_running()) { + logger("update_gcontact: Already running for contact ".$contact_id); + if ($pidfile->running_time() > 9*60) { + $pidfile->kill(); + logger("killed stale process"); + } + exit; + } + } + + $r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id)); + + if (!$r) + return; + + $data = probe_url($r[0]["url"]); + + if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) + return; + + if (($data["name"] == "") AND ($r[0]['name'] != "")) + $data["name"] = $r[0]['name']; + + if (($data["nick"] == "") AND ($r[0]['nick'] != "")) + $data["nick"] = $r[0]['nick']; + + if (($data["addr"] == "") AND ($r[0]['addr'] != "")) + $data["addr"] = $r[0]['addr']; + + if (($data["photo"] == "") AND ($r[0]['photo'] != "")) + $data["photo"] = $r[0]['photo']; + + + q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s' + WHERE `id` = %d", + dbesc($data["name"]), + dbesc($data["nick"]), + dbesc($data["addr"]), + dbesc($data["photo"]), + intval($contact_id) + ); + + q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s' + WHERE `uid` = 0 AND `nurl` = '%s'", + dbesc($data["name"]), + dbesc($data["nick"]), + dbesc($data["addr"]), + dbesc($data["photo"]), + dbesc(normalise_link($data["url"])) + ); +} + +if (array_search(__file__,get_included_files())===0){ + update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]); + killme(); +} diff --git a/mod/allfriends.php b/mod/allfriends.php index 8396efdd2d..1be9550b10 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -69,7 +69,7 @@ function allfriends_content(&$a) { $entry = array( 'url' => $rr['url'], - 'itemurl' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'name' => htmlentities($rr['name']), 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), diff --git a/mod/common.php b/mod/common.php index 560865b154..0860922297 100644 --- a/mod/common.php +++ b/mod/common.php @@ -70,7 +70,7 @@ function common_content(&$a) { if($cid == 0 && $zcid == 0) - return; + return; if($cid) @@ -112,7 +112,7 @@ function common_content(&$a) { $entry = array( 'url' => $rr['url'], - 'itemurl' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), diff --git a/mod/contacts.php b/mod/contacts.php index 934472b39f..017b1d6435 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -867,7 +867,7 @@ function _contact_detail_for_template($rr){ 'name' => htmlentities($rr['name']), 'username' => htmlentities($rr['name']), 'sparkle' => $sparkle, - 'itemurl' => $rr['url'], + 'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']), 'url' => $url, 'network' => network_to_name($rr['network'], $rr['url']), ); diff --git a/mod/dirfind.php b/mod/dirfind.php index 4213ec4b60..3df27e5fb7 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -69,7 +69,7 @@ function dirfind_content(&$a, $prefix = "") { dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search))); - $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network` , `gcontact`.`keywords` + $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr` FROM `gcontact` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d AND NOT `contact`.`blocked` @@ -101,6 +101,7 @@ function dirfind_content(&$a, $prefix = "") { $objresult = new stdClass(); $objresult->cid = $result["cid"]; $objresult->name = $result["name"]; + $objresult->addr = $result["addr"]; $objresult->url = $result["url"]; $objresult->photo = $result["photo"]; $objresult->tags = $result["keywords"]; @@ -134,7 +135,9 @@ function dirfind_content(&$a, $prefix = "") { $alt_text = ""; - $itemurl = $jj->url; + $contact_details = get_contact_details_by_url($jj->url, local_user()); + + $itemurl = (($contact_details["addr"] != "") ? $contact_details["addr"] : $jj->url); // If We already know this contact then don't show the "connect" button if ($jj->cid > 0) { @@ -167,6 +170,9 @@ function dirfind_content(&$a, $prefix = "") { 'conntxt' => $conntxt, 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], 'network' => network_to_name($jj->network, $jj->url), 'id' => ++$id, ); diff --git a/mod/match.php b/mod/match.php index bbf1a6c634..db1cac0f78 100644 --- a/mod/match.php +++ b/mod/match.php @@ -70,10 +70,15 @@ function match_content(&$a) { $photo_menu = array(array(t("View Profile"), zrl($jj->url))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); + $contact_details = get_contact_details_by_url($jj->url, local_user()); + $entry = array( 'url' => zrl($jj->url), - 'itemurl' => $jj->url, + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url), 'name' => $jj->name, + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), diff --git a/mod/nogroup.php b/mod/nogroup.php index adbcfcb515..06fa730e0d 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -35,6 +35,7 @@ function nogroup_content(&$a) { if(count($r)) { foreach($r as $rr) { + $contact_details = get_contact_details_by_url($rr['url'], local_user()); $contacts[] = array( 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']), @@ -46,8 +47,11 @@ function nogroup_content(&$a) { 'thumb' => $rr['thumb'], 'name' => $rr['name'], 'username' => $rr['name'], + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], 'sparkle' => $sparkle, - 'itemurl' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'url' => $url, 'network' => network_to_name($rr['network'], $url), ); diff --git a/mod/suggest.php b/mod/suggest.php index 8870c65df8..578338b505 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -78,16 +78,20 @@ function suggest_content(&$a) { $connlnk = $a->get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']); $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id']; - $photo_menu = array(array(t("View Profile"), zrl($jj->url))); + $photo_menu = array(array(t("View Profile"), zrl($rr["url"]))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); $photo_menu[] = array(t('Ignore/Hide'), $ignlnk); + $contact_details = get_contact_details_by_url($rr["url"], local_user()); $entry = array( 'url' => zrl($rr['url']), - 'itemurl' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'img_hover' => $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], 'ignlnk' => $ignlnk, 'ignid' => $rr['id'], 'conntxt' => t('Connect'), diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 927a597524..f199574c69 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -1,4 +1,5 @@ profile['uid']); + $contacts[] = array( 'id' => $rr['id'], 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB), 'name' => htmlentities(substr($rr['name'],0,20)), 'username' => htmlentities($rr['name']), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], 'url' => $url, 'sparkle' => '', - 'itemurl' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'network' => network_to_name($rr['network'], $rr['url']), ); } diff --git a/view/theme/vier/mobile.css b/view/theme/vier/mobile.css index ba8254d7fe..90e8e64d77 100644 --- a/view/theme/vier/mobile.css +++ b/view/theme/vier/mobile.css @@ -29,6 +29,8 @@ nav { .wall-item-container .wall-item-content { max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; /* margin-left: -70px; padding-top: 25px; */ } diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 15e42e79a6..c48801d829 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -2294,7 +2294,7 @@ aside #id_password { .contact-entry-wrapper { float: left; width: 363px; - height: 90px; + height: 100px; padding-right: 10px; margin: 0 10px 10px 0px; } diff --git a/view/theme/vier/templates/contact_template.tpl b/view/theme/vier/templates/contact_template.tpl index 60e05610f6..c4ed99caa4 100644 --- a/view/theme/vier/templates/contact_template.tpl +++ b/view/theme/vier/templates/contact_template.tpl @@ -36,10 +36,12 @@ {{if $contact.account_type}} ({{$contact.account_type}}){{/if}} {{if $contact.alt_text}}
{{$contact.alt_text}}
{{/if}} - {{if $contact.itemurl}}
{{$contact.itemurl}}
{{/if}} +
+ {{if $contact.itemurl}}{{$contact.itemurl}}{{/if}} + {{if $contact.network}} ({{$contact.network}}){{/if}} +
{{if $contact.tags}}
{{$contact.tags}}
{{/if}} {{if $contact.details}}
{{$contact.details}}
{{/if}} - {{if $contact.network}}
{{$contact.network}}
{{/if}} From f42a3c9bc60c403fa361df9dcd772be956c16ce4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 6 Nov 2015 01:19:37 +0100 Subject: [PATCH 3/3] Update the contact table as well. --- include/onepoll.php | 12 ++++++------ include/update_gcontact.php | 39 +++++++++++++------------------------ 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/include/onepoll.php b/include/onepoll.php index 0e58a776ca..6ff7eae422 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -18,10 +18,10 @@ function onepoll_run(&$argv, &$argc){ } if(is_null($db)) { - @include(".htconfig.php"); - require_once("include/dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); + @include(".htconfig.php"); + require_once("include/dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); }; @@ -679,6 +679,6 @@ function onepoll_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - onepoll_run($_SERVER["argv"],$_SERVER["argc"]); - killme(); + onepoll_run($_SERVER["argv"],$_SERVER["argc"]); + killme(); } diff --git a/include/update_gcontact.php b/include/update_gcontact.php index 05cfba96c1..ce2323f187 100644 --- a/include/update_gcontact.php +++ b/include/update_gcontact.php @@ -10,22 +10,14 @@ function update_gcontact_run(&$argv, &$argc){ } if(is_null($db)) { - @include(".htconfig.php"); - require_once("include/dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); + @include(".htconfig.php"); + require_once("include/dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); }; - - require_once('include/session.php'); - require_once('include/datetime.php'); - require_once('library/simplepie/simplepie.inc'); - require_once('include/items.php'); - require_once('include/Contact.php'); - require_once('include/email.php'); - require_once('include/socgraph.php'); require_once('include/pidfile.php'); - require_once('include/queue_fn.php'); + require_once('include/Scrape.php'); load_config('config'); load_config('system'); @@ -36,18 +28,9 @@ function update_gcontact_run(&$argv, &$argc){ logger('update_gcontact: start'); - $manual_id = 0; - $generation = 0; - $hub_update = false; - $force = false; - $restart = false; - if(($argc > 1) && (intval($argv[1]))) $contact_id = intval($argv[1]); - if(($argc > 2) && ($argv[2] == "force")) - $force = true; - if(!$contact_id) { logger('update_gcontact: no contact'); return; @@ -99,16 +82,22 @@ function update_gcontact_run(&$argv, &$argc){ ); q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s' - WHERE `uid` = 0 AND `nurl` = '%s'", + WHERE `uid` = 0 AND `addr` = '' AND `nurl` = '%s'", dbesc($data["name"]), dbesc($data["nick"]), dbesc($data["addr"]), dbesc($data["photo"]), dbesc(normalise_link($data["url"])) ); + + q("UPDATE `contact` SET `addr` = '%s' + WHERE `uid` != 0 AND `addr` = '' AND `nurl` = '%s'", + dbesc($data["addr"]), + dbesc(normalise_link($data["url"])) + ); } if (array_search(__file__,get_included_files())===0){ - update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]); - killme(); + update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]); + killme(); }