ignore current contact on friend suggestion picker
This commit is contained in:
parent
c410c9013c
commit
06a4c0f703
2 changed files with 17 additions and 6 deletions
|
@ -48,14 +48,22 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
||||||
$mutual = false;
|
$mutual = false;
|
||||||
$networks = null;
|
$networks = null;
|
||||||
$single = false;
|
$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'))
|
if(x($options,'mutual_friends'))
|
||||||
$mutual = true;
|
$mutual = true;
|
||||||
if(x($options,'single'))
|
if(x($options,'single'))
|
||||||
$single = true;
|
$single = true;
|
||||||
if(x($options,'multiple'))
|
if(x($options,'multiple'))
|
||||||
$single = false;
|
$single = false;
|
||||||
|
if(x($options,'exclude'))
|
||||||
|
$exclude = $options['exclude'];
|
||||||
|
|
||||||
if(x($options,'networks')) {
|
if(x($options,'networks')) {
|
||||||
switch($options['networks']) {
|
switch($options['networks']) {
|
||||||
case 'DFRN_ONLY':
|
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);
|
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));
|
$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'])) {
|
if(is_array($x['networks']) && count($x['networks'])) {
|
||||||
for($y = 0; $y < count($x['networks']) ; $y ++)
|
for($y = 0; $y < count($x['networks']) ; $y ++)
|
||||||
$x['networks'][$y] = "'" . dbesc($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'])
|
if($x['single'])
|
||||||
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
|
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" >\r\n";
|
||||||
else
|
else
|
||||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
|
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" >\r\n";
|
||||||
|
|
||||||
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
|
||||||
WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
|
WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
|
||||||
|
|
|
@ -103,8 +103,8 @@ function fsuggest_content(&$a) {
|
||||||
|
|
||||||
$o .= '<form action="fsuggest/' . $contact_id . '" method="post" >';
|
$o .= '<form action="fsuggest/' . $contact_id . '" method="post" >';
|
||||||
|
|
||||||
// TODO: selector should have an option to ignore the recipient
|
$o .= contact_selector('suggest','suggest-select', false,
|
||||||
$o .= contact_select('suggest','suggest-select', $preselect, 4, true);
|
array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true));
|
||||||
|
|
||||||
|
|
||||||
$o .= '<input type="submit" name="submit" value="' . t('Submit') . '" />';
|
$o .= '<input type="submit" name="submit" value="' . t('Submit') . '" />';
|
||||||
|
|
Loading…
Reference in a new issue