]> git.mxchange.org Git - friendica.git/blobdiff - src/BaseModule.php
Merge pull request #10179 from nupplaphil/fix/transifex_script
[friendica.git] / src / BaseModule.php
index 0e0fedb80c35925b4809595287c88254ae2a4c12..19b58ad06683f8413ae6a2385b69d42909a81c24 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -140,7 +140,7 @@ abstract class BaseModule
                        return false;
                }
 
-               $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename);
+               $sec_hash = hash('whirlpool', ($a->user['guid'] ?? '') . ($a->user['prvkey'] ?? '') . session_id() . $x[0] . $typename);
 
                return ($sec_hash == $x[1]);
        }
@@ -171,4 +171,40 @@ abstract class BaseModule
                        throw new \Friendica\Network\HTTPException\ForbiddenException();
                }
        }
+
+       protected static function getContactFilterTabs(string $baseUrl, string $current, bool $displayCommonTab)
+       {
+               $tabs = [
+                       [
+                               'label' => DI::l10n()->t('All contacts'),
+                               'url'   => $baseUrl . '/contacts',
+                               'sel'   => !$current || $current == 'all' ? 'active' : '',
+                       ],
+                       [
+                               'label' => DI::l10n()->t('Followers'),
+                               'url'   => $baseUrl . '/contacts/followers',
+                               'sel'   => $current == 'followers' ? 'active' : '',
+                       ],
+                       [
+                               'label' => DI::l10n()->t('Following'),
+                               'url'   => $baseUrl . '/contacts/following',
+                               'sel'   => $current == 'following' ? 'active' : '',
+                       ],
+                       [
+                               'label' => DI::l10n()->t('Mutual friends'),
+                               'url'   => $baseUrl . '/contacts/mutuals',
+                               'sel'   => $current == 'mutuals' ? 'active' : '',
+                       ],
+               ];
+
+               if ($displayCommonTab) {
+                       $tabs[] = [
+                               'label' => DI::l10n()->t('Common'),
+                               'url'   => $baseUrl . '/contacts/common',
+                               'sel'   => $current == 'common' ? 'active' : '',
+                       ];
+               }
+
+               return $tabs;
+       }
 }