Fallback to all recent activities if there are no results
authorAlexander Ebert <ebert@woltlab.com>
Sat, 29 Apr 2017 23:15:09 +0000 (01:15 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 29 Apr 2017 23:15:09 +0000 (01:15 +0200)
See #2258

com.woltlab.wcf/templates/boxRecentActivity.tpl
wcfsetup/install/files/lib/system/box/RecentActivityListBoxController.class.php
wcfsetup/install/files/style/layout/containerList.scss
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index db1bc08e38a713c4be80e8e760d22ea913c20e72..eae61fc7983da2c1c90f8f86db02a2a39feffc85 100644 (file)
                                        <li><a href="#" class="button small{if !$filteredByFollowedUsers} active{/if}">{lang}wcf.user.recentActivity.scope.all{/lang}</a></li>
                                        <li><a href="#" class="button small{if $filteredByFollowedUsers} active{/if}">{lang}wcf.user.recentActivity.scope.followedUsers{/lang}</a></li>
                                </ul>
+                               
+                               {if $filteredByFollowedUsersOverride}
+                                       <p class="info recentActivityFollowedNoResults">{lang}wcf.user.recentActivity.scope.followedUsers.noResults{/lang}</p>
+                               {/if}
                        </li>
                {/if}
                
index 8ce405e17ea526b7bfe6638119210f9818743a23..7e109deb16531109b58a7dee489ac786374455cf 100644 (file)
@@ -38,6 +38,12 @@ class RecentActivityListBoxController extends AbstractDatabaseObjectListBoxContr
         */
        public $filteredByFollowedUsers = false;
        
+       /**
+        * is true if filtering by followed users yielded no results
+        * @var boolean
+        */
+       public $filteredByFollowedUsersOverride = false;
+       
        /**
         * @inheritDoc
         */
@@ -99,7 +105,8 @@ class RecentActivityListBoxController extends AbstractDatabaseObjectListBoxContr
                                'canFilterByFollowedUsers' => $this->canFilterByFollowedUsers,
                                'eventList' => $this->objectList,
                                'lastEventTime' => $this->objectList->getLastEventTime(),
-                               'filteredByFollowedUsers' => $this->filteredByFollowedUsers
+                               'filteredByFollowedUsers' => $this->filteredByFollowedUsers,
+                               'filteredByFollowedUsersOverride' => $this->filteredByFollowedUsersOverride
                        ], true);
                }
                else {
@@ -117,14 +124,35 @@ class RecentActivityListBoxController extends AbstractDatabaseObjectListBoxContr
                return true;
        }
        
+       /**
+        * @inheritDoc
+        */
+       public function hasContent() {
+               $hasContent = parent::hasContent();
+               
+               if (!$hasContent) {
+                       if (($this->getBox()->position == 'contentTop' || $this->getBox()->position == 'contentBottom') && $this->filteredByFollowedUsers) {
+                               $this->filteredByFollowedUsersOverride = true;
+                               
+                               $this->loadContent();
+                               
+                               return count($this->objectList) > 0;
+                       }
+               }
+               
+               return $hasContent;
+       }
+       
        /**
         * @inheritDoc
         */
        protected function readObjects() {
                // apply filter
                if (($this->getBox()->position == 'contentTop' || $this->getBox()->position == 'contentBottom') && $this->filteredByFollowedUsers) {
-                       /** @noinspection PhpUndefinedMethodInspection */
-                       $this->objectList->getConditionBuilder()->add('user_activity_event.userID IN (?)', [WCF::getUserProfileHandler()->getFollowingUsers()]);
+                       if (!$this->filteredByFollowedUsersOverride) {
+                               /** @noinspection PhpUndefinedMethodInspection */
+                               $this->objectList->getConditionBuilder()->add('user_activity_event.userID IN (?)', [WCF::getUserProfileHandler()->getFollowingUsers()]);
+                       }
                }
                
                // load more items than necessary to avoid empty list if some items are invisible for current user
index 152e5cab4c1f97168f7fc7ee19b53d5ccb08a894..91b74877c56e05427264e8367ef40f40f66fc61f 100644 (file)
                                margin-left: 5px;
                        }
                }
+               
+               > .recentActivityFollowedNoResults {
+                       text-align: left;
+               }
        }
        
        @include screen-md-down {
index 45b7f217653c560f4b974bcb365eee81e429cee4..d6e14ea3bc30aabe7a7a0dbb5ed44a978b37f44b 100644 (file)
@@ -3423,6 +3423,7 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email}
                <item name="wcf.user.recentActivity.condition.excludedObjectType"><![CDATA[Ausgeschlossene Aktivitäten]]></item>
                <item name="wcf.user.recentActivity.scope.all"><![CDATA[Aktivitäten aller Benutzer]]></item>
                <item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Aktivitäten von Benutzern, denen {if LANGUAGE_USE_INFORMAL_VARIANT}du folgst{else}Sie folgen{/if}]]></item>
+               <item name="wcf.user.recentActivity.scope.followedUsers.noResults"><![CDATA[Es gibt aktuell keine Aktivitäten von Benutzeren, denen {if LANGUAGE_USE_INFORMAL_VARIANT}du folgst{else}Sie folgen{/if}. Es werden alle Aktivitäten angezeigt.]]></item>
        </category>
        
        <category name="wcf.user.3rdparty">
index deee925028bdc6450b198ca48f1df8d10508a330..7378d63a7cd441214309685272f9a1c7b38f126e 100644 (file)
@@ -3410,6 +3410,7 @@ Open the link below to access the user profile:
                <item name="wcf.user.recentActivity.condition.excludedObjectType"><![CDATA[Excluded Activities]]></item>
                <item name="wcf.user.recentActivity.scope.all"><![CDATA[All Activities]]></item>
                <item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Filter by Followed Users]]></item>
+               <item name="wcf.user.recentActivity.scope.followedUsers.noResults"><![CDATA[There are no recent activities by followed users. Displaying activity for all users.]]></item>
        </category>
        
        <category name="wcf.user.3rdparty">