From 1c5eaa646c2129c2244bb38ca64e369ebfd080b6 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 8 Nov 2015 16:41:00 +0100 Subject: [PATCH] Only show valid contacts on the group side --- include/group.php | 20 +++++++++++--------- mod/group.php | 11 +++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/group.php b/include/group.php index b7e1963bf3..fe29d39f1a 100644 --- a/include/group.php +++ b/include/group.php @@ -156,9 +156,11 @@ function group_add_member($uid,$name,$member,$gid = 0) { function group_get_members($gid) { $ret = array(); if(intval($gid)) { - $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ", + $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` + INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d AND + NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + ORDER BY `contact`.`name` ASC ", intval($gid), intval(local_user()) ); @@ -171,14 +173,14 @@ function group_get_members($gid) { function group_public_members($gid) { $ret = 0; if(intval($gid)) { - $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d + $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` + INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ", intval($gid), intval(local_user()), dbesc(NETWORK_OSTATUS) - ); + ); if(count($r)) $ret = count($r); } @@ -187,7 +189,7 @@ function group_public_members($gid) { function mini_group_select($uid,$gid = 0) { - + $grps = array(); $o = ''; @@ -205,7 +207,7 @@ function mini_group_select($uid,$gid = 0) { $o = replace_macros(get_markup_template('group_selection.tpl'), array( '$label' => t('Default privacy group for new contacts'), - '$groups' => $grps + '$groups' => $grps )); return $o; } diff --git a/mod/group.php b/mod/group.php index 4a447713dc..263586e2e9 100644 --- a/mod/group.php +++ b/mod/group.php @@ -62,12 +62,12 @@ function group_post(&$a) { $a->page['aside'] = group_side(); } - return; + return; } function group_content(&$a) { $change = false; - + if(! local_user()) { notice( t('Permission denied') . EOL); return; @@ -172,7 +172,7 @@ function group_content(&$a) { '$form_security_token' => get_form_security_token("group_drop"), )); - + $context = $context + array( '$title' => t('Group Editor'), '$gname' => array('groupname',t('Group Name: '),$group['name'], ''), @@ -192,7 +192,7 @@ function group_content(&$a) { 'label_contacts' => t('All Contacts'), 'contacts' => array(), ); - + $sec_token = addslashes(get_form_security_token('group_member_change')); $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { @@ -226,8 +226,7 @@ function group_content(&$a) { echo replace_macros($tpl, $context); killme(); } - + return replace_macros($tpl, $context); } -