From 3a76a6766f644b4970cd11702b660ba049d49391 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Nov 2016 22:11:13 +0000 Subject: [PATCH] Issue 2772: Pending contacts should now be displayed --- include/api.php | 22 +++++++++++----------- include/conversation.php | 2 +- include/dfrn.php | 4 ++-- include/identity.php | 2 +- include/text.php | 4 ++-- mod/network.php | 8 ++++---- mod/viewcontacts.php | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/api.php b/include/api.php index 7518d4c0c4..9892fef26a 100644 --- a/include/api.php +++ b/include/api.php @@ -623,7 +623,7 @@ // count friends $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND `blocked`=0 AND `hidden`=0", + AND `self`=0 AND (NOT `blocked` OR `pending`) AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND) @@ -632,7 +632,7 @@ $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND `blocked`=0 AND `hidden`=0", + AND `self`=0 AND (NOT `blocked` OR `pending`) AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND) @@ -1399,7 +1399,7 @@ `contact`.`id` AS `cid` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` $sql_extra @@ -1476,7 +1476,7 @@ `user`.`nickname`, `user`.`hidewall` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid` AND NOT `user`.`hidewall` WHERE `verb` = '%s' AND `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` @@ -1543,7 +1543,7 @@ `contact`.`id` AS `cid` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND `item`.`uid` = %d AND `item`.`verb` = '%s' $sql_extra", @@ -1619,7 +1619,7 @@ `contact`.`id` AS `cid` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`parent` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND `item`.`uid` = %d AND `item`.`verb` = '%s' @@ -1673,7 +1673,7 @@ `contact`.`id` AS `cid` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND NOT `item`.`private` AND `item`.`allow_cid` = '' AND `item`.`allow`.`gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' @@ -1792,7 +1792,7 @@ `contact`.`id` AS `cid` FROM `item` FORCE INDEX (`uid_id`) STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s')) AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` @@ -1866,7 +1866,7 @@ `contact`.`id` AS `cid` FROM `item` FORCE INDEX (`uid_contactid_id`) STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`contact-id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` @@ -2002,7 +2002,7 @@ AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 AND `item`.`starred` = 1 AND `contact`.`id` = `item`.`contact-id` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) $sql_extra AND `item`.`id`>%d ORDER BY `item`.`id` DESC LIMIT %d ,%d ", @@ -2648,7 +2648,7 @@ if ($user_info['self'] == 0) $sql_extra = " AND false "; - $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` $sql_extra", + $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) $sql_extra", intval(api_user()) ); diff --git a/include/conversation.php b/include/conversation.php index 434a2eb858..c073117efd 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -439,7 +439,7 @@ These Fields are not added below (yet). They are here to for bug search. function item_joins() { return "STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND - NOT `contact`.`blocked` + (NOT `contact`.`blocked` OR `contact`.`pending`) LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`"; } diff --git a/include/dfrn.php b/include/dfrn.php index 67cef59d95..8c03b65822 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -134,7 +134,7 @@ class dfrn { break; // NOTREACHED } - $r = q("SELECT * FROM `contact` WHERE NOT `blocked` AND `contact`.`uid` = %d $sql_extra LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE (NOT `blocked` OR `pending`) AND `contact`.`uid` = %d $sql_extra LIMIT 1", intval($owner_id) ); @@ -193,7 +193,7 @@ class dfrn { `sign`.`signed_text`, `sign`.`signature`, `sign`.`signer` FROM `item` USE INDEX (`uid_wall_changed`, `uid_type_changed`) $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0 AND `item`.`wall` AND `item`.`changed` > '%s' diff --git a/include/identity.php b/include/identity.php index 288f93aaf9..133a12a13f 100644 --- a/include/identity.php +++ b/include/identity.php @@ -371,7 +371,7 @@ function profile_sidebar($profile, $block = 0) { if(count($r)) $updated = date("c", strtotime($r[0]['updated'])); - $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive` + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s', '')", intval($profile['uid']), dbesc(NETWORK_DFRN), diff --git a/include/text.php b/include/text.php index 63e583d69f..154e4e235f 100644 --- a/include/text.php +++ b/include/text.php @@ -874,7 +874,7 @@ function contact_block() { if((! is_array($a->profile)) || ($a->profile['hide-friends'])) return $o; $r = q("SELECT COUNT(*) AS `total` FROM `contact` - WHERE `uid` = %d AND NOT `self` AND NOT `blocked` + WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), @@ -892,7 +892,7 @@ function contact_block() { } else { // Splitting the query in two parts makes it much faster $r = q("SELECT `id` FROM `contact` - WHERE `uid` = %d AND NOT `self` AND NOT `blocked` + WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d", intval($a->profile['uid']), diff --git a/mod/network.php b/mod/network.php index d522598f5a..94a6e81b8c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -504,7 +504,7 @@ function network_content(&$a, $update = 0) { elseif($cid) { $r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d - AND NOT `blocked` LIMIT 1", + AND (NOT `blocked` OR `pending`) LIMIT 1", intval($cid) ); if(count($r)) { @@ -603,7 +603,7 @@ function network_content(&$a, $update = 0) { if(get_config('system', 'old_pager')) { $r = qu("SELECT COUNT(*) AS `total` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted` $sql_extra2 $sql_extra3 $sql_extra $sql_nets ", @@ -681,7 +681,7 @@ function network_content(&$a, $update = 0) { $r = qu("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` $sql_extra4 AND NOT `item`.`moderated` AND `item`.`unseen` $sql_extra3 $sql_extra $sql_nets @@ -691,7 +691,7 @@ function network_content(&$a, $update = 0) { } else { $r = qu("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` - AND NOT `contact`.`blocked` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `thread`.`uid` = %d AND `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated` $sql_extra2 $sql_extra3 $sql_extra $sql_nets diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 6fb3b37fd5..6be1f16de0 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -47,7 +47,7 @@ function viewcontacts_content(&$a) { } $r = q("SELECT COUNT(*) AS `total` FROM `contact` - WHERE `uid` = %d AND NOT `blocked` AND NOT `hidden` AND NOT `archive` + WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), @@ -58,7 +58,7 @@ function viewcontacts_content(&$a) { $a->set_pager_total($r[0]['total']); $r = q("SELECT * FROM `contact` - WHERE `uid` = %d AND NOT `blocked` AND NOT `hidden` AND NOT `archive` + WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive` AND `network` IN ('%s', '%s', '%s') ORDER BY `name` ASC LIMIT %d, %d", intval($a->profile['uid']), -- 2.39.5