Fixed a couple oversights.

This commit is contained in:
flash 2020-06-07 20:55:43 +00:00
parent 44fc436134
commit e99625c2ad
3 changed files with 10 additions and 13 deletions

View file

@ -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']));
}
}
}

View file

@ -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;
}

View file

@ -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;
}