Support for 3rd party avatars
authorAlexander Ebert <ebert@woltlab.com>
Fri, 22 Dec 2017 10:20:25 +0000 (11:20 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 22 Dec 2017 10:20:33 +0000 (11:20 +0100)
wcfsetup/install/files/lib/data/user/UserProfile.class.php

index a56ea4fb9722b738d9af8ba82673aff93566ad2c..a4724595deef98fdd3f60686af7f93c7ff1729c5 100644 (file)
@@ -270,6 +270,18 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
                                        else if (MODULE_GRAVATAR && $this->enableGravatar) {
                                                $this->avatar = new Gravatar($this->userID, $this->email, ($this->gravatarFileExtension ?: 'png'));
                                        }
+                                       else {
+                                               $parameters = ['avatar' => null];
+                                               EventHandler::getInstance()->fireAction($this, 'getAvatar', $parameters);
+                                               
+                                               if ($parameters['avatar'] !== null) {
+                                                       if (!($parameters['avatar'] instanceof IUserAvatar)) {
+                                                               throw new \RuntimeException("Object '".get_class($parameters['avatar'])."' does not implement '".IUserAvatar::class."'.");
+                                                       }
+                                                       
+                                                       $this->avatar = $parameters['avatar'];
+                                               }
+                                       }
                                }
                        }