Skip to content

Commit

Permalink
Fix displaying .gif avatars on user profile pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tadhgboyle committed Dec 25, 2021
1 parent 7d8647a commit 28e15d6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/classes/Core/User.php
Expand Up @@ -481,7 +481,7 @@ public function getAvatar(int $size = 128, bool $full = false): string {
if ($this->data()->has_avatar) {
$exts = ['png', 'jpg', 'jpeg'];

if ($this->hasPermission('usercp.gif_avatar')) {
if ($this->hasPermission('usercp.gif_avatar', false)) {
$exts[] = 'gif';
}

Expand Down Expand Up @@ -518,12 +518,18 @@ public function getAvatar(int $size = 128, bool $full = false): string {
* Does the user have a given permission in any of their groups?
*
* @param string $permission Permission node to check recursively for.
* @param bool $login_check Whether to check if this user instance is logged in or not, "false" for avatar permission checking.
*
* @return bool Whether they inherit this permission or not.
*/
public function hasPermission(string $permission): bool {
public function hasPermission(string $permission, bool $login_check = true): bool {
$groups = $this->_groups;
if ($this->isLoggedIn() && $groups) {

if (!$groups) {
return false;
}

if (!$login_check || $this->isLoggedIn()) {
foreach ($groups as $group) {
$permissions = json_decode($group->permissions, true);

Expand Down

0 comments on commit 28e15d6

Please sign in to comment.