X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FContact.php;h=bb6d8c198178a9002ee0ade07daff13c0ba94d49;hb=71a5de40f105234aa8082844d7839c3e0e49e905;hp=de76789e8c68020b826fe388f235c9153faf01db;hpb=41a36606c6ee92c914acbb7f6d9ea79c0a149088;p=friendica.git diff --git a/include/Contact.php b/include/Contact.php index de76789e8c..bb6d8c1981 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,11 +1,14 @@ datetime_convert('UTC','UTC',$expiry)) { + if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) { // relationship is really truly dead. // archive them rather than delete @@ -185,13 +166,13 @@ function unmark_for_death($contact) { // It's a miracle. Our dead contact has inexplicably come back to life. q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d", - dbesc('0000-00-00 00:00:00'), + dbesc(NULL_DATE), intval($contact['id']) ); if ($contact['url'] != '') { q("UPDATE `contact` SET `term-date` = '%s' WHERE `nurl` = '%s'", - dbesc('0000-00-00 00:00:00'), + dbesc(NULL_DATE), dbesc(normalise_link($contact['url'])) ); } @@ -212,6 +193,10 @@ function unmark_for_death($contact) { function get_contact_details_by_url($url, $uid = -1, $default = array()) { static $cache = array(); + if ($url == '') { + return $default; + } + if ($uid == -1) { $uid = local_user(); } @@ -254,7 +239,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { // "bd" always contains the upcoming birthday of a contact. // "birthday" might contain the birthday including the year of birth. - if ($profile["birthday"] != "0000-00-00") { + if ($profile["birthday"] > '0001-01-01') { $bd_timestamp = strtotime($profile["birthday"]); $month = date("m", $bd_timestamp); $day = date("d", $bd_timestamp); @@ -271,7 +256,7 @@ 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; @@ -307,7 +292,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { $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); @@ -483,7 +471,7 @@ function random_profile() { function contacts_not_grouped($uid,$start = 0,$count = 0) { - if (! $count) { + if(! $count) { $r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ", intval($uid), intval($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' @@ -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 @@ -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 @@ -731,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 @@ -775,18 +766,18 @@ function posts_from_contact_url(App $a, $contact_url) { function formatted_location($profile) { $location = ''; - if ($profile['locality']) + if($profile['locality']) $location .= $profile['locality']; - if ($profile['region'] AND ($profile['locality'] != $profile['region'])) { - if ($location) + if($profile['region'] AND ($profile['locality'] != $profile['region'])) { + if($location) $location .= ', '; $location .= $profile['region']; } - if ($profile['country-name']) { - if ($location) + if($profile['country-name']) { + if($location) $location .= ', '; $location .= $profile['country-name']; @@ -808,7 +799,7 @@ function account_type($contact) { // "page-flags" is a field in the user table, // "forum" and "prv" are used in the contact table. They stand for PAGE_COMMUNITY and PAGE_PRVGROUP. // "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP. - if ((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY)) + if((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY)) || (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP)) || (isset($contact['forum']) && intval($contact['forum'])) || (isset($contact['prv']) && intval($contact['prv'])) @@ -840,4 +831,3 @@ function account_type($contact) { return $account_type; } -?>