diff --git a/app/Models/User.php b/app/Models/User.php index e61df3ee..5235aac2 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -234,8 +234,8 @@ class User public function getAvatar($size) { // output image directly - if (!is_null($this->eloquent_model) && $this->eloquent_model->avatar) { - $png = \Minecraft::generateAvatarFromSkin(BASE_DIR."/textures/".Texture::find($this->eloquent_model->avatar)->hash, $size); + if (!is_null($this->eloquent_model) && $this->getAvatarId()) { + $png = \Minecraft::generateAvatarFromSkin(BASE_DIR."/textures/".Texture::find($this->getAvatarId())->hash, $size); header('Content-Type: image/png'); imagepng($png); imagedestroy($png); @@ -249,6 +249,11 @@ class User } } + public function getAvatarId() + { + return $this->eloquent_model->avatar; + } + public function setAvatar($tid) { $this->eloquent_model->avatar = $tid; diff --git a/app/Services/Utils.php b/app/Services/Utils.php index 1f35e7b7..d805f0fa 100644 --- a/app/Services/Utils.php +++ b/app/Services/Utils.php @@ -52,4 +52,18 @@ class Utils return ($timestamp == 0) ? date('Y-m-d H:i:s') : date('Y-m-d H:i:s', $timestamp); } + public static function getNameOrEmail(\App\Models\User $user) + { + return ($user->getNickName() == '') ? $_SESSION['email'] : $user->getNickName(); + } + + public static function getAvatarFname(\App\Models\User $user) + { + $fname = base64_encode($user->email).".png"; + if (Option::get('avatar_query_string')) { + $fname .= '?v='.$user->getAvatarId(); + } + return $fname; + } + } diff --git a/resources/views/admin/master.tpl b/resources/views/admin/master.tpl index 8de44631..bdd4ce9c 100644 --- a/resources/views/admin/master.tpl +++ b/resources/views/admin/master.tpl @@ -50,12 +50,12 @@ - +