diff --git a/public/profile.php b/public/profile.php index 710b366d..149f3cc8 100644 --- a/public/profile.php +++ b/public/profile.php @@ -242,14 +242,12 @@ if($isEditing) { } catch(UserImageAssetException $ex) { $notices[] = 'Unable to save your background, contact an administator!'; } - - try { - $backgroundInfo->setAttachmentString($_POST['background']['attach'] ?? '') - ->setBlend(!empty($_POST['background']['attr']['blend'])) - ->setSlide(!empty($_POST['background']['attr']['slide'])); - } catch(InvalidArgumentException $ex) {} } } + + $backgroundInfo->setAttachment((int)($_POST['background']['attach'] ?? 0)) + ->setBlend(!empty($_POST['background']['attr']['blend'])) + ->setSlide(!empty($_POST['background']['attr']['slide'])); } } } diff --git a/src/Users/Assets/UserBackgroundAsset.php b/src/Users/Assets/UserBackgroundAsset.php index f41e9c9f..a45fa714 100644 --- a/src/Users/Assets/UserBackgroundAsset.php +++ b/src/Users/Assets/UserBackgroundAsset.php @@ -27,7 +27,6 @@ class UserBackgroundAsset extends UserImageAsset { public const ATTRIB_SLIDE = 0x20; public const ATTACHMENT_STRINGS = [ - self::ATTACH_NONE => '', self::ATTACH_COVER => 'cover', self::ATTACH_STRETCH => 'stretch', self::ATTACH_TILE => 'tile', @@ -88,7 +87,7 @@ class UserBackgroundAsset extends UserImageAsset { } public function getAttributes(): int { - return $this->getUser()->getBackgroundSettings(); + return $this->getUser()->getBackgroundSettings() & 0xF0; } public function setAttributes(int $attrib): self { $this->getUser()->setBackgroundSettings($this->getAttachment() | ($attrib & 0xF0)); @@ -100,8 +99,8 @@ class UserBackgroundAsset extends UserImageAsset { public function setBlend(bool $blend): self { $this->getUser()->setBackgroundSettings( $blend - ? ($this->getAttributes() | self::ATTRIB_BLEND) - : ($this->getAttributes() & ~self::ATTRIB_BLEND) + ? ($this->getUser()->getBackgroundSettings() | self::ATTRIB_BLEND) + : ($this->getUser()->getBackgroundSettings() & ~self::ATTRIB_BLEND) ); return $this; } @@ -111,8 +110,8 @@ class UserBackgroundAsset extends UserImageAsset { public function setSlide(bool $slide): self { $this->getUser()->setBackgroundSettings( $slide - ? ($this->getAttributes() | self::ATTRIB_SLIDE) - : ($this->getAttributes() & ~self::ATTRIB_SLIDE) + ? ($this->getUser()->getBackgroundSettings() | self::ATTRIB_SLIDE) + : ($this->getUser()->getBackgroundSettings() & ~self::ATTRIB_SLIDE) ); return $this; } diff --git a/src/Users/Assets/UserImageAsset.php b/src/Users/Assets/UserImageAsset.php index 72ba6777..83947c15 100644 --- a/src/Users/Assets/UserImageAsset.php +++ b/src/Users/Assets/UserImageAsset.php @@ -114,7 +114,7 @@ abstract class UserImageAsset implements JsonSerializable, UserImageAssetInterfa if(!is_dir($targetDir)) mkdir($targetDir, 0775, true); - if(is_uploaded_file($path) ? move_uploaded_file($path, $targetPath) : copy($path, $targetPath)) + if(is_uploaded_file($path) ? !move_uploaded_file($path, $targetPath) : !copy($path, $targetPath)) throw new UserImageAssetMoveFailedException; }