Display pending contacts in the contact list

This commit is contained in:
Michael 2019-09-08 19:18:56 +00:00
parent 2dcb9926bc
commit 591ba9c68e
2 changed files with 32 additions and 3 deletions

View file

@ -108,6 +108,7 @@ class Router
$collector->addRoute(['GET'], '/{id:\d+}/updateprofile', Module\Contact::class);
$collector->addRoute(['GET'], '/archived', Module\Contact::class);
$collector->addRoute(['GET', 'POST'], '/batch', Module\Contact::class);
$collector->addRoute(['GET'], '/pending', Module\Contact::class);
$collector->addRoute(['GET'], '/blocked', Module\Contact::class);
$collector->addRoute(['GET'], '/hidden', Module\Contact::class);
$collector->addRoute(['GET'], '/ignored', Module\Contact::class);

View file

@ -641,8 +641,11 @@ class Contact extends BaseModule
case 'archived':
$sql_extra = " AND `archive` AND NOT `blocked`";
break;
case 'pending':
$sql_extra = " AND `pending` AND NOT `archive`";
break;
default:
$sql_extra = " AND NOT `archive` AND NOT `blocked`";
$sql_extra = " AND NOT `archive` AND NOT `blocked` AND NOT `pending`";
}
$sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
@ -660,6 +663,14 @@ class Contact extends BaseModule
'id' => 'showall-tab',
'accesskey' => 'l',
],
[
'label' => L10n::t('Pending'),
'url' => 'contact/pending',
'sel' => $type == 'pending' ? 'active' : '',
'title' => L10n::t('Only show pending contacts'),
'id' => 'showpending-tab',
'accesskey' => 'p',
],
[
'label' => L10n::t('Blocked'),
'url' => 'contact/blocked',
@ -730,7 +741,7 @@ class Contact extends BaseModule
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= Model\Contact::FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '');
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
WHERE `uid` = %d AND `self` = 0 $sql_extra $sql_extra2 ",
intval($_SESSION['uid'])
);
if (DBA::isResult($r)) {
@ -742,7 +753,7 @@ class Contact extends BaseModule
$contacts = [];
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT %d , %d ",
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT %d , %d ",
intval($_SESSION['uid']),
$pager->getStart(),
$pager->getItemsPerPage()
@ -763,6 +774,7 @@ class Contact extends BaseModule
}
switch ($type) {
case 'pending': $header .= ' - ' . L10n::t('Pending'); break;
case 'blocked': $header .= ' - ' . L10n::t('Blocked'); break;
case 'hidden': $header .= ' - ' . L10n::t('Hidden'); break;
case 'ignored': $header .= ' - ' . L10n::t('Ignored'); break;
@ -976,6 +988,22 @@ class Contact extends BaseModule
$sparkle = '';
}
if ($rr['pending']) {
if (in_array($rr['rel'], [Model\Contact::FRIEND, Model\Contact::SHARING])) {
$alt_text = L10n::t('Pending outgoing contact request');
} else {
$alt_text = L10n::t('Pending incoming contact request');
$intro = DBA::selectFirst('intro', ['blocked', 'ignore'], ['contact-id' => $rr['id']]);
if (DBA::isResult($intro)) {
if ($intro['blocked']) {
$alt_text = L10n::t('Blocked incoming contact request');
} elseif ($intro['ignore']) {
$alt_text = L10n::t('Ignored incoming contact request');
}
}
}
}
if ($rr['self']) {
$dir_icon = 'images/larrow.gif';
$alt_text = L10n::t('This is you');