From 06a4c0f703d64cae1e72c2901742e3c101623a7b Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 27 Jun 2011 03:03:58 -0700 Subject: [PATCH] ignore current contact on friend suggestion picker --- include/acl_selectors.php | 19 +++++++++++++++---- mod/fsuggest.php | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index c19a0f5d3f..c3e26082e3 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -48,14 +48,22 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $mutual = false; $networks = null; $single = false; + $exclude = false; + $size = 4; + + if(is_array($options)) { + if(x($options,'size')) + $size = $options['size']; - if($is_array($options)) { if(x($options,'mutual_friends')) $mutual = true; if(x($options,'single')) $single = true; if(x($options,'multiple')) $single = false; + if(x($options,'exclude')) + $exclude = $options['exclude']; + if(x($options,'networks')) { switch($options['networks']) { case 'DFRN_ONLY': @@ -79,7 +87,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { } } - $x = array('options' => $options, 'single' => $single, 'mutual' => $mutual, 'networks' => $networks); + $x = array('options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks); call_hooks('contact_select_options', $x); @@ -91,6 +99,9 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD)); } + if(intval($x['exclude'])) + $sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude'])); + if(is_array($x['networks']) && count($x['networks'])) { for($y = 0; $y < count($x['networks']) ; $y ++) $x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'"; @@ -99,9 +110,9 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { } if($x['single']) - $o .= "\r\n"; else - $o .= "\r\n"; $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 29fb79cfb1..dc95fb8e16 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -103,8 +103,8 @@ function fsuggest_content(&$a) { $o .= '
'; - // TODO: selector should have an option to ignore the recipient - $o .= contact_select('suggest','suggest-select', $preselect, 4, true); + $o .= contact_selector('suggest','suggest-select', false, + array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true)); $o .= '';