Only show valid contacts on the group side

This commit is contained in:
Michael Vogel 2015-11-08 16:41:00 +01:00
parent d9e56e0450
commit 1c5eaa646c
2 changed files with 16 additions and 15 deletions

View File

@ -156,9 +156,11 @@ function group_add_member($uid,$name,$member,$gid = 0) {
function group_get_members($gid) { function group_get_members($gid) {
$ret = array(); $ret = array();
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member`
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ", 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($gid),
intval(local_user()) intval(local_user())
); );
@ -171,14 +173,14 @@ function group_get_members($gid) {
function group_public_members($gid) { function group_public_members($gid) {
$ret = 0; $ret = 0;
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d WHERE `gid` = %d AND `group_member`.`uid` = %d
AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ", AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ",
intval($gid), intval($gid),
intval(local_user()), intval(local_user()),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
if(count($r)) if(count($r))
$ret = count($r); $ret = count($r);
} }
@ -187,7 +189,7 @@ function group_public_members($gid) {
function mini_group_select($uid,$gid = 0) { function mini_group_select($uid,$gid = 0) {
$grps = array(); $grps = array();
$o = ''; $o = '';
@ -205,7 +207,7 @@ function mini_group_select($uid,$gid = 0) {
$o = replace_macros(get_markup_template('group_selection.tpl'), array( $o = replace_macros(get_markup_template('group_selection.tpl'), array(
'$label' => t('Default privacy group for new contacts'), '$label' => t('Default privacy group for new contacts'),
'$groups' => $grps '$groups' => $grps
)); ));
return $o; return $o;
} }

View File

@ -62,12 +62,12 @@ function group_post(&$a) {
$a->page['aside'] = group_side(); $a->page['aside'] = group_side();
} }
return; return;
} }
function group_content(&$a) { function group_content(&$a) {
$change = false; $change = false;
if(! local_user()) { if(! local_user()) {
notice( t('Permission denied') . EOL); notice( t('Permission denied') . EOL);
return; return;
@ -172,7 +172,7 @@ function group_content(&$a) {
'$form_security_token' => get_form_security_token("group_drop"), '$form_security_token' => get_form_security_token("group_drop"),
)); ));
$context = $context + array( $context = $context + array(
'$title' => t('Group Editor'), '$title' => t('Group Editor'),
'$gname' => array('groupname',t('Group Name: '),$group['name'], ''), '$gname' => array('groupname',t('Group Name: '),$group['name'], ''),
@ -192,7 +192,7 @@ function group_content(&$a) {
'label_contacts' => t('All Contacts'), 'label_contacts' => t('All Contacts'),
'contacts' => array(), 'contacts' => array(),
); );
$sec_token = addslashes(get_form_security_token('group_member_change')); $sec_token = addslashes(get_form_security_token('group_member_change'));
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
foreach($members as $member) { foreach($members as $member) {
@ -226,8 +226,7 @@ function group_content(&$a) {
echo replace_macros($tpl, $context); echo replace_macros($tpl, $context);
killme(); killme();
} }
return replace_macros($tpl, $context); return replace_macros($tpl, $context);
} }