/** * @see \wcf\data\IGroupedUserListAction::getGroupedUserList() */ public function getGroupedUserList() { $year = $month = $day = 0; $value = explode('-', $this->parameters['date']); if (isset($value[0])) { $year = intval($value[0]); } if (isset($value[1])) { $month = intval($value[1]); } if (isset($value[2])) { $day = intval($value[2]); } // get users $users = array(); $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options'); if (isset($userOptions['birthday'])) { $birthdayUserOption = $userOptions['birthday']; $userIDs = UserBirthdayCache::getInstance()->getBirthdays($month, $day); $userList = new UserProfileList(); $userList->setObjectIDs($userIDs); $userList->readObjects(); foreach ($userList->getObjects() as $user) { $birthdayUserOption->setUser($user->getDecoratedObject()); if (!$user->isProtected() && $birthdayUserOption->isVisible() && $user->getAge($year) >= 0) { $users[] = $user; } } } WCF::getTPL()->assign(array('users' => $users, 'year' => $year)); return array('pageCount' => 1, 'template' => WCF::getTPL()->fetch('userBirthdayList')); }
/** * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare() */ public function prepare(array $events) { if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) { return; } $responses = $responseIDs = array(); foreach ($events as $event) { $responseIDs[] = $event->objectID; } // fetch responses $responseList = new CommentResponseList(); $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs)); $responseList->readObjects(); $responses = $responseList->getObjects(); // fetch comments $commentIDs = $comments = array(); foreach ($responses as $response) { $commentIDs[] = $response->commentID; } if (!empty($commentIDs)) { $commentList = new CommentList(); $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs)); $commentList->readObjects(); $comments = $commentList->getObjects(); } // fetch users $userIDs = $users = array(); foreach ($comments as $comment) { $userIDs[] = $comment->objectID; $userIDs[] = $comment->userID; } if (!empty($userIDs)) { $userList = new UserProfileList(); $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs)); $userList->readObjects(); $users = $userList->getObjects(); } // set message foreach ($events as $event) { if (isset($responses[$event->objectID])) { $response = $responses[$event->objectID]; $comment = $comments[$response->commentID]; if (isset($users[$comment->objectID]) && isset($users[$comment->userID])) { if (!$users[$comment->objectID]->isProtected()) { $event->setIsAccessible(); // title $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', array('commentAuthor' => $users[$comment->userID], 'user' => $users[$comment->objectID])); $event->setTitle($text); // description $event->setDescription($response->getExcerpt()); } continue; } } $event->setIsOrphaned(); } }
/** * Returns user profile preview. * * @return array */ public function getUserProfile() { $userID = reset($this->objectIDs); if ($userID) { $userProfileList = new UserProfileList(); $userProfileList->getConditionBuilder()->add("user_table.userID = ?", array($userID)); $userProfileList->readObjects(); $userProfiles = $userProfileList->getObjects(); if (empty($userProfiles)) { WCF::getTPL()->assign('unknownUser', true); } else { WCF::getTPL()->assign('user', reset($userProfiles)); } } else { WCF::getTPL()->assign('unknownUser', true); } return array('template' => WCF::getTPL()->fetch('userProfilePreview'), 'userID' => $userID); }