]> git.mxchange.org Git - friendica.git/commitdiff
Display pending contacts in the contact list
authorMichael <heluecht@pirati.ca>
Sun, 8 Sep 2019 19:18:56 +0000 (19:18 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 8 Sep 2019 19:18:56 +0000 (19:18 +0000)
src/App/Router.php
src/Module/Contact.php

index 50b208792b76a08d55a4734f8c31edabd861f4ea..b3df8a14d294c8477e1ed92859ad900b2f5b83f8 100644 (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);
index 198496a0eb61f6bf055f4e765eed30743d52b419..7f31527a2b30efff4766d6b41b02983cd3cab6eb 100644 (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');