]> git.mxchange.org Git - friendica.git/commitdiff
Remove Widget::accounts in favor of Widget::accounttypes
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 14 Oct 2020 02:30:40 +0000 (22:30 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 14 Oct 2020 02:30:40 +0000 (22:30 -0400)
src/Content/Widget.php
src/Module/Conversation/Community.php
src/Module/Conversation/Network.php
static/routes.config.php

index 90373e8c3b490cc3fd5d964f52bcf397fc71b2bd..e18f70631dc826b1913f851e075940a8dca90c54 100644 (file)
@@ -542,26 +542,4 @@ class Widget
                return self::filter('accounttype', DI::l10n()->t('Account Types'), '',
                        DI::l10n()->t('All'), $base, $accounts, $accounttype);
        }
-
-       /**
-        * Display the accounts sidebar
-        * The account type is added to the path
-        *
-        * @param string $base        Basepath
-        * @param string $accounttype Acount type (person, organisation, news, community)
-        * @return string
-        */
-       public static function accounts(string $base, string $accounttype)
-       {
-               return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/accounts.tpl'), [
-                       '$title'        => DI::l10n()->t('Account Types'),
-                       '$content'      => $base,
-                       '$accounttype'  => ($accounttype ?? ''),
-                       '$all'          => DI::l10n()->t('All'),
-                       '$person'       => DI::l10n()->t('Persons'),
-                       '$organisation' => DI::l10n()->t('Organisations'),
-                       '$news'         => DI::l10n()->t('News'),
-                       '$community'    => DI::l10n()->t('Forums'),
-               ]);     
-       }
 }
index b37ab69848cdde1ea64377ff2a8814373f104823..a960bf5e0ecc4692785127b7ed371de430d8d9fc 100644 (file)
@@ -42,7 +42,8 @@ class Community extends BaseModule
 {
        protected static $page_style;
        protected static $content;
-       protected static $accounttype;
+       protected static $accountTypeString;
+       protected static $accountType;
        protected static $itemsPerPage;
        protected static $min_id;
        protected static $max_id;
@@ -89,7 +90,7 @@ class Community extends BaseModule
 
                        Nav::setSelected('community');
 
-                       DI::page()['aside'] .= Widget::accounts('community/' . self::$content, $parameters['accounttype'] ?? '');
+                       DI::page()['aside'] .= Widget::accounttypes('community/' . self::$content, self::$accountTypeString);
        
                        if (local_user() && DI::config()->get('system', 'community_no_sharer')) {
                                $path = self::$content;
@@ -192,7 +193,8 @@ class Community extends BaseModule
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
                }
 
-               self::$accounttype = User::getAccountTypeByString($parameters['accounttype'] ?? '');
+               self::$accountTypeString = $_GET['accounttype'] ?? $parameters['accounttype'] ?? '';
+               self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
 
                self::$content = $parameters['content'] ?? '';
                if (!self::$content) {
@@ -311,14 +313,14 @@ class Community extends BaseModule
        private static function selectItems($min_id, $max_id, $item_id, $itemspage)
        {
                if (self::$content == 'local') {
-                       if (!is_null(self::$accounttype)) {
-                               $condition = ["`wall` AND `origin` AND `private` = ? AND `owner`.`contact-type` = ?", Item::PUBLIC, self::$accounttype];
+                       if (!is_null(self::$accountType)) {
+                               $condition = ["`wall` AND `origin` AND `private` = ? AND `owner`.`contact-type` = ?", Item::PUBLIC, self::$accountType];
                        } else {
                                $condition = ["`wall` AND `origin` AND `private` = ?", Item::PUBLIC];
                        }
                } elseif (self::$content == 'global') {
-                       if (!is_null(self::$accounttype)) {
-                               $condition = ["`uid` = ? AND `private` = ? AND `owner`.`contact-type` = ?", 0, Item::PUBLIC, self::$accounttype];
+                       if (!is_null(self::$accountType)) {
+                               $condition = ["`uid` = ? AND `private` = ? AND `owner`.`contact-type` = ?", 0, Item::PUBLIC, self::$accountType];
                        } else {
                                $condition = ["`uid` = ? AND `private` = ?", 0, Item::PUBLIC];
                        }
index ab3e917ee5a8ec5dbe44d796df0e22fbd0df3602..f21b3816a6848cf5111824816331a251a3fd59e0 100644 (file)
@@ -34,6 +34,8 @@ class Network extends BaseModule
        private static $min_id;
        /** @var mixed */
        private static $max_id;
+       /** @var string */
+       private static $accountTypeString;
        /** @var int */
        private static $accountType;
        /** @var string */
@@ -61,7 +63,7 @@ class Network extends BaseModule
 
                $module = 'network';
 
-               DI::page()['aside'] .= Widget::accounts($module . '/accounttype', self::$accountType);
+               DI::page()['aside'] .= Widget::accounttypes($module, self::$accountTypeString);
                DI::page()['aside'] .= Group::sidebarWidget($module, $module . '/group', 'standard', self::$groupId);
                DI::page()['aside'] .= ForumManager::widget($module . '/forum', local_user(), self::$forumContactId);
                DI::page()['aside'] .= Widget::postedByYear($module . '/archive', local_user(), false);
@@ -300,7 +302,8 @@ class Network extends BaseModule
                self::$mention = intval($_GET['mention']      ?? 0);
                self::$order   = in_array(self::$selectedTab, ['received', 'commented', 'created', 'uriid']) ? self::$selectedTab : 'commented';
 
-               self::$accountType = User::getAccountTypeByString($parameters['accounttype'] ?? '') ?? '';
+               self::$accountTypeString = $_GET['accounttype'] ?? $parameters['accounttype'] ?? '';
+               self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
 
                self::$network = $get['nets'] ?? '';
 
@@ -339,7 +342,7 @@ class Network extends BaseModule
                $conditionFields['uid'] = local_user();
                $conditionStrings = [];
 
-               if (self::$accountType) {
+               if (!is_null(self::$accountType)) {
                        $conditionFields['contact-type'] = self::$accountType;
                }
 
index 13025d5426a270fbf343a05e09feafc2f24850e4..8ddd7250cd274f106b40a71d76c25fa755023d32 100644 (file)
@@ -117,7 +117,7 @@ return [
        '/debug/ap'            => [Module\Debug\ActivityPubConversion::class,  [R::GET, R::POST]],
        '/bookmarklet'         => [Module\Bookmarklet::class,  [R::GET]],
 
-       '/community[/{content}[/{accounttype}]]' => [Module\Conversation\Community::class, [R::GET]],
+       '/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]],
 
        '/compose[/{type}]'    => [Module\Item\Compose::class, [R::GET, R::POST]],
 
@@ -304,7 +304,6 @@ return [
                '/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d-\d\d-\d\d}]' => [Module\Conversation\Network::class, [R::GET]],
                '/forum/{contact_id:\d+}'     => [Module\Conversation\Network::class, [R::GET]],
                '/group/{group_id:\d+}'       => [Module\Conversation\Network::class, [R::GET]],
-               '/accounttype/{accounttype}'  => [Module\Conversation\Network::class, [R::GET]],
        ],
 
        '/randprof'                      => [Module\RandomProfile::class,         [R::GET]],
@@ -318,7 +317,7 @@ return [
        '/toggle_mobile'                 => [Module\ToggleMobile::class,          [R::GET]],
        '/tos'                           => [Module\Tos::class,                   [R::GET]],
 
-       '/update_community[/{content}[/{accounttype}]]' => [Module\Update\Community::class, [R::GET]],
+       '/update_community[/{content}]'  => [Module\Update\Community::class,      [R::GET]],
        '/update_network'                => [Module\Update\Network::class,        [R::GET]],
        '/update_profile'                => [Module\Update\Profile::class,        [R::GET]],