X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FContact.php;h=0aeabc9725cc226074e37a37864cd56c936cf811;hb=0cd9db9cb7f4c96f597e37590a536eaae123238d;hp=ee5ec0cfceb0c681dbba76487b9f0af3b9e84505;hpb=18d23ca443a3a2df77b78ad28cc151199d70a8d8;p=friendica.git diff --git a/include/Contact.php b/include/Contact.php index ee5ec0cfce..0aeabc9725 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,5 +1,8 @@ '0001-01-01') { $bd_timestamp = strtotime($profile["birthday"]); $month = date("m", $bd_timestamp); $day = date("d", $bd_timestamp); @@ -271,43 +256,43 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { $profile["bd"] = (++$current_year)."-".$month."-".$day; } } else { - $profile["bd"] = "0000-00-00"; + $profile["bd"] = '0001-01-01'; } } else { $profile = $default; } - if (($profile["photo"] == "") AND isset($default["photo"])) { + if (($profile["photo"] == "") && isset($default["photo"])) { $profile["photo"] = $default["photo"]; } - if (($profile["name"] == "") AND isset($default["name"])) { + if (($profile["name"] == "") && isset($default["name"])) { $profile["name"] = $default["name"]; } - if (($profile["network"] == "") AND isset($default["network"])) { + if (($profile["network"] == "") && isset($default["network"])) { $profile["network"] = $default["network"]; } - if (($profile["thumb"] == "") AND isset($profile["photo"])) { + if (($profile["thumb"] == "") && isset($profile["photo"])) { $profile["thumb"] = $profile["photo"]; } - if (($profile["micro"] == "") AND isset($profile["thumb"])) { + if (($profile["micro"] == "") && isset($profile["thumb"])) { $profile["micro"] = $profile["thumb"]; } - if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND + if ((($profile["addr"] == "") || ($profile["name"] == "")) && ($profile["gid"] != 0) && in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { proc_run(PRIORITY_LOW, "include/update_gcontact.php", $profile["gid"]); } // Show contact details of Diaspora contacts only if connected - if (($profile["cid"] == 0) AND ($profile["network"] == NETWORK_DIASPORA)) { + if (($profile["cid"] == 0) && ($profile["network"] == NETWORK_DIASPORA)) { $profile["location"] = ""; $profile["about"] = ""; $profile["gender"] = ""; - $profile["birthday"] = "0000-00-00"; + $profile["birthday"] = '0001-01-01'; } $cache[$url][$uid] = $profile; @@ -328,6 +313,10 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { function get_contact_details_by_addr($addr, $uid = -1) { static $cache = array(); + if ($addr == '') { + return array(); + } + if ($uid == -1) { $uid = local_user(); } @@ -353,7 +342,6 @@ function get_contact_details_by_addr($addr, $uid = -1) { dbesc($addr)); if (!dbm::is_result($r)) { - require_once('include/Probe.php'); $data = Probe::uri($addr); $profile = get_contact_details_by_url($data['url'], $uid); @@ -534,6 +522,10 @@ function get_contact($url, $uid = 0, $no_update = false) { $data = array(); $contact_id = 0; + if ($url == '') { + return 0; + } + // We first try the nurl (http://server.tld/nick), most common case $contacts = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `nurl` = '%s' @@ -567,7 +559,7 @@ function get_contact($url, $uid = 0, $no_update = false) { // Update the contact every 7 days $update_photo = ($contacts[0]['avatar-date'] < datetime_convert('','','now -7 days')); - if (!$update_photo OR $no_update) { + if (!$update_photo || $no_update) { return $contact_id; } } elseif ($uid != 0) { @@ -575,7 +567,6 @@ function get_contact($url, $uid = 0, $no_update = false) { return 0; } - require_once('include/Probe.php'); $data = Probe::uri($url); // Last try in gcontact for unsupported networks @@ -645,7 +636,7 @@ function get_contact($url, $uid = 0, $no_update = false) { } } - if (count($contacts) > 1 AND $uid == 0 AND $contact_id != 0 AND $url != "") { + if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $url != "") { q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d AND NOT `self`", dbesc(normalise_link($url)), intval($contact_id)); @@ -663,9 +654,9 @@ function get_contact($url, $uid = 0, $no_update = false) { } // Only update if there had something been changed - if ($data["addr"] != $contacts[0]["addr"] OR - $data["alias"] != $contacts[0]["alias"] OR - $data["name"] != $contacts[0]["name"] OR + if ($data["addr"] != $contacts[0]["addr"] || + $data["alias"] != $contacts[0]["alias"] || + $data["name"] != $contacts[0]["name"] || $data["nick"] != $contacts[0]["nick"]) { q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s', `name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d", @@ -692,7 +683,7 @@ function get_contact($url, $uid = 0, $no_update = false) { */ function posts_from_gcontact(App $a, $gcontact_id) { - require_once('include/conversation.php'); + require_once 'include/conversation.php'; // There are no posts with "uid = 0" with connector networks // This speeds up the query a lot @@ -702,15 +693,6 @@ function posts_from_gcontact(App $a, $gcontact_id) { else $sql = "`item`.`uid` = %d"; - if(get_config('system', 'old_pager')) { - $r = q("SELECT COUNT(*) AS `total` FROM `item` - WHERE `gcontact-id` = %d and $sql", - intval($gcontact_id), - intval(local_user())); - - $a->set_pager_total($r[0]['total']); - } - $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, `author-name` AS `name`, `owner-avatar` AS `photo`, `owner-link` AS `url`, `owner-avatar` AS `thumb` @@ -724,13 +706,9 @@ function posts_from_gcontact(App $a, $gcontact_id) { intval($a->pager['itemspage']) ); - $o = conversation($a,$r,'community',false); + $o = conversation($a, $r, 'community', false); - if(!get_config('system', 'old_pager')) { - $o .= alt_pager($a,count($r)); - } else { - $o .= paginate($a); - } + $o .= alt_pager($a, count($r)); return $o; } @@ -744,7 +722,7 @@ function posts_from_gcontact(App $a, $gcontact_id) { */ function posts_from_contact_url(App $a, $contact_url) { - require_once('include/conversation.php'); + require_once 'include/conversation.php'; // There are no posts with "uid = 0" with connector networks // This speeds up the query a lot @@ -763,15 +741,6 @@ function posts_from_contact_url(App $a, $contact_url) { $author_id = intval($r[0]["author-id"]); - if (get_config('system', 'old_pager')) { - $r = q("SELECT COUNT(*) AS `total` FROM `item` - WHERE `author-id` = %d and $sql", - intval($author_id), - intval(local_user())); - - $a->set_pager_total($r[0]['total']); - } - $r = q(item_query()." AND `item`.`author-id` = %d AND ".$sql. " ORDER BY `item`.`created` DESC LIMIT %d, %d", intval($author_id), @@ -780,13 +749,9 @@ function posts_from_contact_url(App $a, $contact_url) { intval($a->pager['itemspage']) ); - $o = conversation($a,$r,'community',false); + $o = conversation($a, $r, 'community', false); - if (!get_config('system', 'old_pager')) { - $o .= alt_pager($a,count($r)); - } else { - $o .= paginate($a); - } + $o .= alt_pager($a, count($r)); return $o; } @@ -804,7 +769,7 @@ function formatted_location($profile) { if($profile['locality']) $location .= $profile['locality']; - if($profile['region'] AND ($profile['locality'] != $profile['region'])) { + if($profile['region'] && ($profile['locality'] != $profile['region'])) { if($location) $location .= ', '; @@ -866,4 +831,3 @@ function account_type($contact) { return $account_type; } -?>