* @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;
+ }
- if (WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
- 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();
- }
+ // 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
if (isset($responses[$event->objectID])) {
$response = $responses[$event->objectID];
$comment = $comments[$response->commentID];
- if (isset($users[$comment->objectID]) && isset($users[$comment->userID]) && !$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());
+ 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;
}
}
* @see \wcf\system\user\activity\event\IUserActivityEvent::prepare()
*/
public function prepare(array $events) {
+ if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
+ return;
+ }
+
$comments = $commentIDs = array();
+ foreach ($events as $event) {
+ $commentIDs[] = $event->objectID;
+ }
- if (WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
- foreach ($events as $event) {
- $commentIDs[] = $event->objectID;
- }
-
- // fetch comments
- $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;
- }
- if (!empty($userIDs)) {
- $userList = new UserProfileList();
- $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs));
- $userList->readObjects();
- $users = $userList->getObjects();
- }
+ // fetch comments
+ $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;
+ }
+ if (!empty($userIDs)) {
+ $userList = new UserProfileList();
+ $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs));
+ $userList->readObjects();
+ $users = $userList->getObjects();
}
// set message
if (isset($comments[$event->objectID])) {
// short output
$comment = $comments[$event->objectID];
- if (isset($users[$comment->objectID]) && !$users[$comment->objectID]->isProtected()) {
- $event->setIsAccessible();
-
- $user = $users[$comment->objectID];
- $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileComment', array('user' => $user));
- $event->setTitle($text);
-
- // output
- $event->setDescription($comment->getExcerpt());
+ if (isset($users[$comment->objectID])) {
+ if (!$users[$comment->objectID]->isProtected()) {
+ $event->setIsAccessible();
+
+ $user = $users[$comment->objectID];
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileComment', array('user' => $user));
+ $event->setTitle($text);
+
+ // output
+ $event->setDescription($comment->getExcerpt());
+ }
continue;
}
}