Properly handling profile preview for deleted users
authorAlexander Ebert <ebert@woltlab.com>
Mon, 8 Jul 2013 17:09:08 +0000 (19:09 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 8 Jul 2013 17:09:08 +0000 (19:09 +0200)
com.woltlab.wcf/templates/userProfilePreview.tpl
wcfsetup/install/files/lib/data/user/UserProfileAction.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index f3f3f27ae6d39305c3f82fc99dfc2d22f1350222..83e1929dac461f43e7312c6d8fc75d4543e72fca 100644 (file)
@@ -1,51 +1,55 @@
-<div class="box128 userProfilePreview">
-       <a href="{link controller='User' object=$user}{/link}" title="{$user->username}">{@$user->getAvatar()->getImageTag(128)}</a>
-       
-       {if $__wcf->getUser()->userID && $__wcf->getUser()->userID != $user->userID}
-               <script>
-                       //<![CDATA[
-                               $(function() {
-                                       WCF.Language.addObject({
-                                               'wcf.user.button.follow': '{lang}wcf.user.button.follow{/lang}',
-                                               'wcf.user.button.ignore': '{lang}wcf.user.button.ignore{/lang}',
-                                               'wcf.user.button.unfollow': '{lang}wcf.user.button.unfollow{/lang}',
-                                               'wcf.user.button.unignore': '{lang}wcf.user.button.unignore{/lang}'
-                                       });
-                                       
-                                       new WCF.User.Action.Follow($('.userInformation'));
-                                       
-                                       {if !$user->getPermission('user.profile.cannotBeIgnored')}
-                                               new WCF.User.Action.Ignore($('.userInformation'));
-                                       {/if}
-                               });
-                       //]]>
-               </script>
-       {/if}
-       
-       <div class="userInformation">
-               {include file='userInformation'}
+{if $unknownUser|isset}
+       <p>{lang}wcf.user.unknownUser{/lang}</p>
+{else}
+       <div class="box128 userProfilePreview">
+               <a href="{link controller='User' object=$user}{/link}" title="{$user->username}">{@$user->getAvatar()->getImageTag(128)}</a>
                
-               {if $user->canViewOnlineStatus() && $user->getLastActivityTime()}
-                       <dl class="plain inlineDataList userStats">
-                               <dt>{lang}wcf.user.usersOnline.lastActivity{/lang}</dt>
-                               <dd>{@$user->getLastActivityTime()|time}{if $user->getCurrentLocation()}, {@$user->getCurrentLocation()}{/if}</dd>
-                       </dl>
+               {if $__wcf->getUser()->userID && $__wcf->getUser()->userID != $user->userID}
+                       <script>
+                               //<![CDATA[
+                                       $(function() {
+                                               WCF.Language.addObject({
+                                                       'wcf.user.button.follow': '{lang}wcf.user.button.follow{/lang}',
+                                                       'wcf.user.button.ignore': '{lang}wcf.user.button.ignore{/lang}',
+                                                       'wcf.user.button.unfollow': '{lang}wcf.user.button.unfollow{/lang}',
+                                                       'wcf.user.button.unignore': '{lang}wcf.user.button.unignore{/lang}'
+                                               });
+                                               
+                                               new WCF.User.Action.Follow($('.userInformation'));
+                                               
+                                               {if !$user->getPermission('user.profile.cannotBeIgnored')}
+                                                       new WCF.User.Action.Ignore($('.userInformation'));
+                                               {/if}
+                                       });
+                               //]]>
+                       </script>
                {/if}
                
-               {hascontent}
-                       <dl class="plain inlineDataList userFields">
-                               {content}
-                                       {if $user->occupation}
-                                               <dt>{lang}wcf.user.option.occupation{/lang}</dt>
-                                               <dd>{$user->occupation}</dd>
-                                       {/if}
-                                       {if $user->hobbies}
-                                               <dt>{lang}wcf.user.option.hobbies{/lang}</dt>
-                                               <dd>{$user->hobbies}</dd>
-                                       {/if}
-                                       {event name='userFields'}
-                               {/content}
-                       </dl>
-               {/hascontent}
+               <div class="userInformation">
+                       {include file='userInformation'}
+                       
+                       {if $user->canViewOnlineStatus() && $user->getLastActivityTime()}
+                               <dl class="plain inlineDataList userStats">
+                                       <dt>{lang}wcf.user.usersOnline.lastActivity{/lang}</dt>
+                                       <dd>{@$user->getLastActivityTime()|time}{if $user->getCurrentLocation()}, {@$user->getCurrentLocation()}{/if}</dd>
+                               </dl>
+                       {/if}
+                       
+                       {hascontent}
+                               <dl class="plain inlineDataList userFields">
+                                       {content}
+                                               {if $user->occupation}
+                                                       <dt>{lang}wcf.user.option.occupation{/lang}</dt>
+                                                       <dd>{$user->occupation}</dd>
+                                               {/if}
+                                               {if $user->hobbies}
+                                                       <dt>{lang}wcf.user.option.hobbies{/lang}</dt>
+                                                       <dd>{$user->hobbies}</dd>
+                                               {/if}
+                                               {event name='userFields'}
+                                       {/content}
+                               </dl>
+                       {/hascontent}
+               </div>
        </div>
-</div>
\ No newline at end of file
+{/if}
index 4e44455c2c4ef670c8fc8bd8e490bf7d69dd42d6..8fd0de73253e6098b618d52887b661fa972ec16b 100644 (file)
@@ -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'),
index 7a11c1a0bcb3e41b2ae829b64e46a236879474e9..8ed2aa76807bd62fb6bfc2ca09307e496c3fe7eb 100644 (file)
@@ -1876,6 +1876,7 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getAllowedExtensions()
                <item name="wcf.user.registrationDate"><![CDATA[Registrierungsdatum]]></item>
                <item name="wcf.user.visibleLanguages"><![CDATA[Inhaltssprachen]]></item>
                <item name="wcf.user.visibleLanguages.description"><![CDATA[Zeigt Inhalte in den ausgewählten Sprachen an]]></item>
+               <item name="wcf.user.unknownUser"><![CDATA[Dieser Benutzer existiert nicht oder wurde gelöscht.]]></item>
                <item name="wcf.user.userID"><![CDATA[Benutzer-ID]]></item>
                <item name="wcf.user.username"><![CDATA[Benutzername]]></item>
                <item name="wcf.user.username.placeholder"><![CDATA[Geben Sie einen Benutzernamen ein]]></item>
index c01cc355b84a5d5a063543f746dc2cabaa0880d5..3738dd9a8f167821f0eb4ccf344dae79da7e5005 100644 (file)
@@ -1875,6 +1875,7 @@ Allowed extensions: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]>
                <item name="wcf.user.registrationDate"><![CDATA[Registration Date]]></item>
                <item name="wcf.user.visibleLanguages"><![CDATA[Multilingualism]]></item>
                <item name="wcf.user.visibleLanguages.description"><![CDATA[Limits visibility to content associated with the selected languages]]></item>
+               <item name="wcf.user.unknownUser"><![CDATA[This user does not exist or has been deleted.]]></item>
                <item name="wcf.user.userID"><![CDATA[User ID]]></item>
                <item name="wcf.user.username"><![CDATA[Username]]></item>
                <item name="wcf.user.username.placeholder"><![CDATA[Enter a username]]></item>