From 73487989c0a27deae38881379b052c5002b225ae Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Apr 2012 07:48:28 -0700 Subject: query to find un-grouped contacts --- include/Contact.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index ee434cb6d..8d893cf70 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -173,4 +173,15 @@ function random_profile() { if(count($r)) return dirname($r[0]['url']); return ''; -} \ No newline at end of file +} + + +function contacts_not_grouped($uid) { + $r = q("select * 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) + ); + + return $r; +} + -- cgit v1.2.3 From 3c4e6d34610ae4913d1d9ea090499c5d328a62e8 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Apr 2012 23:06:41 -0700 Subject: bug #369 - show contacts who are not in any groups --- include/Contact.php | 22 ++++++++++++++++++---- include/group.php | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 8d893cf70..657977801 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -176,12 +176,26 @@ function random_profile() { } -function contacts_not_grouped($uid) { - $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ", +function contacts_not_grouped($uid,$start = 0,$count = 0) { +dbg(1); + 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) + ); +dbg(0); + return $r; + + + } +dbg(1); + $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) limit %d, %d", + intval($uid), intval($uid), - intval($uid) + intval($start), + intval($count) ); - +dbg(0); return $r; } diff --git a/include/group.php b/include/group.php index 4a35912e5..edb547de6 100644 --- a/include/group.php +++ b/include/group.php @@ -212,6 +212,7 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0 '$title' => t('Groups'), '$edittext' => t('Edit group'), '$createtext' => t('Create a new group'), + '$ungrouped' => (($every === 'contacts') ? t('Contacts not in any group') : ''), '$groups' => $groups, '$add' => t('add'), )); -- cgit v1.2.3 From df1904b204a969780609cac64bbb1a03a8dd3fcb Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Apr 2012 23:14:41 -0700 Subject: stray debug statements, forgot to filter pending contacts --- include/Contact.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 657977801..388819b01 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -177,25 +177,25 @@ function random_profile() { function contacts_not_grouped($uid,$start = 0,$count = 0) { -dbg(1); + 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) ); -dbg(0); + return $r; } -dbg(1); - $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) limit %d, %d", + + $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) and blocked = 0 and pending = 0 limit %d, %d", intval($uid), intval($uid), intval($start), intval($count) ); -dbg(0); + return $r; } -- cgit v1.2.3