Allow admin to set default gravatar type
authorMarcel Werk <burntime@woltlab.com>
Tue, 24 Jun 2014 19:37:03 +0000 (21:37 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 24 Jun 2014 19:37:03 +0000 (21:37 +0200)
see #1332

com.woltlab.wcf/option.xml
com.woltlab.wcf/templates/avatarEdit.tpl
wcfsetup/install/files/acp/templates/userAdd.tpl
wcfsetup/install/files/lib/action/GravatarDownloadAction.class.php
wcfsetup/install/files/lib/data/user/avatar/Gravatar.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 28ce1007115960065202910a93bbc910f44a32f7..8bad41e5504256947233fb327939a445dbbfb8c6 100644 (file)
@@ -1014,6 +1014,17 @@ no:!cache_source_memcached_host]]></enableoptions>
                        <!-- /user.3rdPartyAuth -->
                        
                        <!-- user.avatar -->
+                       <option name="gravatar_default_type">
+                               <categoryname>user.avatar</categoryname>
+                               <optiontype>select</optiontype>
+                               <defaultvalue><![CDATA[404]]></defaultvalue>
+                               <selectoptions><![CDATA[404:wcf.acp.option.gravatar_default_type.404
+identicon:wcf.acp.option.gravatar_default_type.identicon
+wavatar:wcf.acp.option.gravatar_default_type.wavatar
+monsterid:wcf.acp.option.gravatar_default_type.monsterid
+retro:wcf.acp.option.gravatar_default_type.retro]]></selectoptions>
+                               <options>module_gravatar</options>
+                       </option>
                        <option name="max_avatar_width">
                                <categoryname>user.avatar</categoryname>
                                <optiontype>integer</optiontype>
index 7a76a46725f33569174c6b4bdc66fb9d1c0e93dd..606ee6fe2f97b0a926f1cdd9da391ef4de627327 100644 (file)
@@ -86,7 +86,7 @@
                        
                        {if MODULE_GRAVATAR}
                                <dl{if $errorField == 'gravatar'} class="formError"{/if}>
-                                       <dt class="framed"><img src="https://secure.gravatar.com/avatar/{@$__wcf->user->email|strtolower|md5}?s=96" alt="" class="icon96" /></dt>
+                                       <dt class="framed"><img src="https://secure.gravatar.com/avatar/{@$__wcf->user->email|strtolower|md5}?s=96{if GRAVATAR_DEFAULT_TYPE != '404'}&amp;d={@GRAVATAR_DEFAULT_TYPE}{/if}" alt="" class="icon96" /></dt>
                                        <dd>
                                                <label><input type="radio" name="avatarType" value="gravatar" {if $avatarType == 'gravatar'}checked="checked" {/if}/> {lang}wcf.user.avatar.type.gravatar{/lang}</label>
                                                {if $errorField == 'gravatar'}
index b8ced13f21456de6ea37bd1d81dc143ba76aa823..dfc319a6382aa7d10a0ded1cdfe9e7538e18fd29 100644 (file)
                                        
                                        {if MODULE_GRAVATAR}
                                                <dl{if $errorType[gravatar]|isset} class="formError"{/if}>
-                                                       <dt class="framed"><img src="https://secure.gravatar.com/avatar/{@$user->email|strtolower|md5}?s=96" alt="" class="icon96" /></dt>
+                                                       <dt class="framed"><img src="https://secure.gravatar.com/avatar/{@$user->email|strtolower|md5}?s=96{if GRAVATAR_DEFAULT_TYPE != '404'}&amp;d={@GRAVATAR_DEFAULT_TYPE}{/if}" alt="" class="icon96" /></dt>
                                                        <dd>
                                                                <label><input type="radio" name="avatarType" value="gravatar" {if $avatarType == 'gravatar'}checked="checked" {/if}/> {lang}wcf.user.avatar.type.gravatar{/lang}</label>
                                                                
index ef6883b31beb330f21c318ed2838f49ea886ae5d..e5dd1700f290e4f7504d6c8b4c5fc283910b7521 100644 (file)
@@ -67,7 +67,7 @@ class GravatarDownloadAction extends AbstractAction {
                        }
                        
                        // try to download new version
-                       $gravatarURL = sprintf(Gravatar::GRAVATAR_BASE, md5(mb_strtolower($this->user->email)), $this->size, '404');
+                       $gravatarURL = sprintf(Gravatar::GRAVATAR_BASE, md5(mb_strtolower($this->user->email)), $this->size, GRAVATAR_DEFAULT_TYPE);
                        try {
                                $tmpFile = FileUtil::downloadFileFromHttp($gravatarURL, 'gravatar');
                                copy($tmpFile, WCF_DIR.$cachedFilename);
index 7de3a61172629aabaafe570dfab85e01b2de1410..5c4d5badafa3555ce9f49711da9c568583cc47da 100644 (file)
@@ -93,7 +93,7 @@ class Gravatar extends DefaultAvatar {
         * @return      boolean
         */
        public static function test($email) {
-               $gravatarURL = sprintf(self::GRAVATAR_BASE, md5(mb_strtolower($email)), 80, '404');
+               $gravatarURL = sprintf(self::GRAVATAR_BASE, md5(mb_strtolower($email)), 80, GRAVATAR_DEFAULT_TYPE);
                try {
                        $tmpFile = FileUtil::downloadFileFromHttp($gravatarURL, 'gravatar');
                        @unlink($tmpFile);
index 279a0bbbd4005e701d6b2d215ecb7f37a4a0a436..6d9210ce40f98838e7f8bad866d4d707fc47010f 100644 (file)
@@ -1008,6 +1008,13 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.option.user_authentication_failure_user_captcha.description"><![CDATA[TODO]]></item>
                <item name="wcf.acp.option.user_authentication_failure_expiration"><![CDATA[Löschung von alten Protokolleinträgen]]></item>
                <item name="wcf.acp.option.user_authentication_failure_expiration.description"><![CDATA[TODO]]></item>
+               <item name="wcf.acp.option.gravatar_default_type"><![CDATA[Standard Gravatar-Typ]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.description"><![CDATA[Der <a class="externalURL" href="{@$__wcf->getPath()}acp/dereferrer.php?url=https://de.gravatar.com/site/implement/images/#default-image">Standard-Gravatar-Typ</a>, wenn einer E-Mail kein Gravatar zugeordnet werden kann.]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.404"><![CDATA[Kein Standard-Gravatar]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.identicon"><![CDATA[Identicon]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.wavatar"><![CDATA[Wavatar]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.monsterid"><![CDATA[Monster-ID]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.retro"><![CDATA[Retro]]></item>
        </category>
        
        <category name="wcf.acp.package">
index 83b06e1859b2bd28f3a21cce9ce8544b3e52dce5..83ccb68afe3ce60e93eba51c7660afe9e2a5d544 100644 (file)
@@ -1008,6 +1008,13 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.option.user_authentication_failure_user_captcha.description"><![CDATA[TODO]]></item>
                <item name="wcf.acp.option.user_authentication_failure_expiration"><![CDATA[TODO: Löschung von alten Protokolleinträgen]]></item>
                <item name="wcf.acp.option.user_authentication_failure_expiration.description"><![CDATA[TODO]]></item>
+               <item name="wcf.acp.option.gravatar_default_type"><![CDATA[Default Gravatar Type]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.description"><![CDATA[The <a class="externalURL" href="{@$__wcf->getPath()}acp/dereferrer.php?url=https://de.gravatar.com/site/implement/images/#default-image">default Gravatar type</a> used if no matching Gravatar was found.]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.404"><![CDATA[No default Gravatar]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.identicon"><![CDATA[Identicon]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.wavatar"><![CDATA[Wavatar]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.monsterid"><![CDATA[Monster id]]></item>
+               <item name="wcf.acp.option.gravatar_default_type.retro"><![CDATA[Retro]]></item>
        </category>
        
        <category name="wcf.acp.package">