From a821cb93dac0ac38dd60fdbd859dd97418798331 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 8 Jul 2013 19:09:08 +0200 Subject: [PATCH] Properly handling profile preview for deleted users --- .../templates/userProfilePreview.tpl | 98 ++++++++++--------- .../lib/data/user/UserProfileAction.class.php | 24 +++-- wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 4 files changed, 69 insertions(+), 55 deletions(-) diff --git a/com.woltlab.wcf/templates/userProfilePreview.tpl b/com.woltlab.wcf/templates/userProfilePreview.tpl index f3f3f27ae6..83e1929dac 100644 --- a/com.woltlab.wcf/templates/userProfilePreview.tpl +++ b/com.woltlab.wcf/templates/userProfilePreview.tpl @@ -1,51 +1,55 @@ -
- {@$user->getAvatar()->getImageTag(128)} - - {if $__wcf->getUser()->userID && $__wcf->getUser()->userID != $user->userID} - - {/if} - -
- {include file='userInformation'} +{if $unknownUser|isset} +

{lang}wcf.user.unknownUser{/lang}

+{else} +
+ {@$user->getAvatar()->getImageTag(128)} - {if $user->canViewOnlineStatus() && $user->getLastActivityTime()} -
-
{lang}wcf.user.usersOnline.lastActivity{/lang}
-
{@$user->getLastActivityTime()|time}{if $user->getCurrentLocation()}, {@$user->getCurrentLocation()}{/if}
-
+ {if $__wcf->getUser()->userID && $__wcf->getUser()->userID != $user->userID} + {/if} - {hascontent} -
- {content} - {if $user->occupation} -
{lang}wcf.user.option.occupation{/lang}
-
{$user->occupation}
- {/if} - {if $user->hobbies} -
{lang}wcf.user.option.hobbies{/lang}
-
{$user->hobbies}
- {/if} - {event name='userFields'} - {/content} -
- {/hascontent} +
+ {include file='userInformation'} + + {if $user->canViewOnlineStatus() && $user->getLastActivityTime()} +
+
{lang}wcf.user.usersOnline.lastActivity{/lang}
+
{@$user->getLastActivityTime()|time}{if $user->getCurrentLocation()}, {@$user->getCurrentLocation()}{/if}
+
+ {/if} + + {hascontent} +
+ {content} + {if $user->occupation} +
{lang}wcf.user.option.occupation{/lang}
+
{$user->occupation}
+ {/if} + {if $user->hobbies} +
{lang}wcf.user.option.hobbies{/lang}
+
{$user->hobbies}
+ {/if} + {event name='userFields'} + {/content} +
+ {/hascontent} +
-
\ No newline at end of file +{/if} diff --git a/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php b/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php index 4e44455c2c..8fd0de7325 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php @@ -95,14 +95,22 @@ class UserProfileAction extends UserAction { public function getUserProfile() { $userID = reset($this->objectIDs); - $userProfileList = new UserProfileList(); - $userProfileList->getConditionBuilder()->add("user_table.userID = ?", array($userID)); - $userProfileList->readObjects(); - $userProfiles = $userProfileList->getObjects(); - - WCF::getTPL()->assign(array( - 'user' => reset($userProfiles) - )); + 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'), diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 7a11c1a0bc..8ed2aa7680 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1876,6 +1876,7 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getAllowedExtensions() + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index c01cc355b8..3738dd9a8f 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1875,6 +1875,7 @@ Allowed extensions: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]> + -- 2.20.1