From 5ae64989ebf307ad0bfff64fe5a8529fd1ecb341 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 25 Apr 2016 17:45:57 +0300 Subject: [PATCH] system avatar color --- application/Espo/EntryPoints/Avatar.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/application/Espo/EntryPoints/Avatar.php b/application/Espo/EntryPoints/Avatar.php index 50429b5ca4..1ac18f6a34 100644 --- a/application/Espo/EntryPoints/Avatar.php +++ b/application/Espo/EntryPoints/Avatar.php @@ -40,7 +40,9 @@ class Avatar extends Image public static $notStrictAuth = true; - private $colorList = [ + protected $systemColor = [212,114,155]; + + protected $colorList = [ [111,168,214], [237,197,85], [212,114,155], @@ -73,7 +75,6 @@ class Avatar extends Image $userId = $_GET['id']; - $user = $this->getEntityManager()->getEntity('User', $userId); if (!$user) { throw new NotFound(); @@ -103,12 +104,20 @@ class Avatar extends Image if (!empty($this->imageSizes[$size])) { $width = $this->imageSizes[$size][0]; + ob_clean(); + flush(); + header('Cache-Control: max-age=360000, must-revalidate'); header('Content-Type: image/png'); - ob_clean(); - flush(); - echo $identicon->getImageData($userId, $width, $this->getColor($userId)); + $hash = $userId; + $color = $this->getColor($userId); + if ($hash === 'system') { + $color = $this->systemColor; + } + + $imgContent = $identicon->getImageData($hash, $width, $color); + echo $imgContent; exit; } }