415b390a61d460f794672612a282ec24551790f2
[GitHub/WoltLab/WCF.git] /
1 <?php
2 declare(strict_types=1);
3 namespace wcf\system\menu\user\profile\content;
4 use wcf\data\user\activity\event\ViewableUserActivityEventList;
5 use wcf\system\user\activity\event\UserActivityEventHandler;
6 use wcf\system\SingletonFactory;
7 use wcf\system\WCF;
8
9 /**
10 * Handles user activity events.
11 *
12 * @author Alexander Ebert
13 * @copyright 2001-2018 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\Menu\User\Profile\Content
16 */
17 class RecentActivityUserProfileMenuContent extends SingletonFactory implements IUserProfileMenuContent {
18 /**
19 * @inheritDoc
20 */
21 public function getContent($userID) {
22 $eventList = new ViewableUserActivityEventList();
23
24 // load more items than necessary to avoid empty list if some items are invisible for current user
25 $eventList->sqlLimit = 60;
26
27 $eventList->getConditionBuilder()->add("user_activity_event.userID = ?", [$userID]);
28 $eventList->readObjects();
29
30 UserActivityEventHandler::validateEvents($eventList);
31
32 // remove unused items
33 $eventList->truncate(20);
34
35 WCF::getTPL()->assign([
36 'eventList' => $eventList,
37 'lastEventTime' => $eventList->getLastEventTime(),
38 'placeholder' => WCF::getLanguage()->get('wcf.user.profile.content.recentActivity.noEntries'),
39 'userID' => $userID
40 ]);
41
42 return WCF::getTPL()->fetch('recentActivities');
43 }
44
45 /**
46 * @inheritDoc
47 */
48 public function isVisible($userID) {
49 return true;
50 }
51 }