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