Added usergroup setting for avatar visibility
authorSascha Greuel <sascha@softcreatr.de>
Fri, 4 Oct 2013 17:36:22 +0000 (19:36 +0200)
committerSascha Greuel <sascha@softcreatr.de>
Fri, 4 Oct 2013 17:36:22 +0000 (19:36 +0200)
See
http://beta.woltlab.com/index.php/Thread/4081-Avatar-ausblenden-f%C3%BCr-G%C3%A4ste

com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 202e88a5944231d9bc8700ddd188a4ec47fc98ac..507b2e39776076f0c9ba3f08ad3e22093905d267 100644 (file)
@@ -489,6 +489,11 @@ pdf]]></defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                        </option>
                        
+                       <option name="user.profile.avatar.canSeeAvatars">
+                               <categoryname>user.profile.avatar</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>1</defaultvalue>
+                       </option>
                        <option name="user.profile.avatar.canUploadAvatar">
                                <categoryname>user.profile.avatar</categoryname>
                                <optiontype>boolean</optiontype>
index 5346f098ace9a68e20394404b6dbbb23d39bde81..dcc8e9da825db1969e01a9d397a5ce24ccb2fde8 100644 (file)
@@ -258,27 +258,29 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider
        public function getAvatar() {
                if ($this->avatar === null) {
                        if (!$this->disableAvatar) {
-                               if ($this->avatarID) {
-                                       if (!$this->fileHash) {
-                                               // load storage data
-                                               UserStorageHandler::getInstance()->loadStorage(array($this->userID));
-                                               $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'avatar');
-                                               
-                                               if ($data[$this->userID] === null) {
-                                                       $this->avatar = new UserAvatar($this->avatarID);
-                                                       UserStorageHandler::getInstance()->update($this->userID, 'avatar', serialize($this->avatar));
+                               if ($this->canSeeAvatar()) {
+                                       if ($this->avatarID) {
+                                               if (!$this->fileHash) {
+                                                       // load storage data
+                                                       UserStorageHandler::getInstance()->loadStorage(array($this->userID));
+                                                       $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'avatar');
+                                                       
+                                                       if ($data[$this->userID] === null) {
+                                                               $this->avatar = new UserAvatar($this->avatarID);
+                                                               UserStorageHandler::getInstance()->update($this->userID, 'avatar', serialize($this->avatar));
+                                                       }
+                                                       else {
+                                                               $this->avatar = unserialize($data[$this->userID]);
+                                                       }
                                                }
                                                else {
-                                                       $this->avatar = unserialize($data[$this->userID]);
+                                                       $this->avatar = new UserAvatar(null, $this->getDecoratedObject()->data);
                                                }
                                        }
-                                       else {
-                                               $this->avatar = new UserAvatar(null, $this->getDecoratedObject()->data);
+                                       else if (MODULE_GRAVATAR && $this->enableGravatar) {
+                                               $this->avatar = new Gravatar($this->userID, $this->email);
                                        }
                                }
-                               else if (MODULE_GRAVATAR && $this->enableGravatar) {
-                                       $this->avatar = new Gravatar($this->userID, $this->email);
-                               }
                        }
                        
                        // use default avatar
@@ -290,6 +292,15 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider
                return $this->avatar;
        }
        
+       /**
+        * Returns true if the active user can view the avatar of this user.
+        * 
+        * @return      boolean
+        */
+       public function canSeeAvatar() {
+               return (WCF::getUser()->userID == $this->userID || WCF::getSession()->getPermission('user.profile.avatar.canSeeAvatars'));
+       }
+       
        /**
         * Returns true if this user is currently online.
         * 
index fdbb0411496e4b0c6ad3c7e0046379728530f6a4..0a83c01108a6f49952b6b77ca64bbc094495285f 100644 (file)
                <item name="wcf.acp.group.option.category.admin.user.rank"><![CDATA[Benutzerränge]]></item>
                <item name="wcf.acp.group.option.category.user.signature"><![CDATA[Signaturen]]></item>
                <item name="wcf.acp.group.option.user.profile.avatar.allowedFileExtensions"><![CDATA[Erlaubte Dateiendungen]]></item>
+               <item name="wcf.acp.group.option.user.profile.avatar.canSeeAvatars"><![CDATA[Kann Avatare anderer Benutzer sehen]]></item>
                <item name="wcf.acp.group.option.user.profile.avatar.canUploadAvatar"><![CDATA[Kann eigenen Avatar hochladen]]></item>
                <item name="wcf.acp.group.option.user.profile.avatar.maxSize"><![CDATA[Maximale Dateigröße]]></item>
                <item name="wcf.acp.group.option.user.profile.canChangeEmail"><![CDATA[Kann E-Mail-Adresse ändern]]></item>
index 0ec8559f8b23e9cb96325f6c9f97005d04f285e9..a71574177d988aab0d379e254d130cf3b09c9960 100644 (file)
@@ -322,6 +322,7 @@ Examples for medium ID detection:
                <item name="wcf.acp.group.option.category.admin.user.rank"><![CDATA[User Ranks]]></item>
                <item name="wcf.acp.group.option.category.user.signature"><![CDATA[Signatures]]></item>
                <item name="wcf.acp.group.option.user.profile.avatar.allowedFileExtensions"><![CDATA[Allowed File Extensions]]></item>
+               <item name="wcf.acp.group.option.user.profile.avatar.canUploadAvatar"><![CDATA[Can see avatars of other users]]></item>
                <item name="wcf.acp.group.option.user.profile.avatar.canUploadAvatar"><![CDATA[Can upload own avatar]]></item>
                <item name="wcf.acp.group.option.user.profile.avatar.maxSize"><![CDATA[Maximimum File Size]]></item>
                <item name="wcf.acp.group.option.user.profile.canChangeEmail"><![CDATA[Can change email address]]></item>