Enumerations classes to enum: SignMeType, Layout and MessagePriority

This commit is contained in:
the-djmaze 2024-02-26 20:08:49 +01:00
parent 20daa1ce13
commit 45de60a7e1
8 changed files with 28 additions and 38 deletions

View file

@ -16,9 +16,14 @@ namespace MailSo\Mime\Enumerations;
* @package Mime
* @subpackage Enumerations
*/
abstract class MessagePriority
enum MessagePriority: int
{
const LOW = 5;
const NORMAL = 3;
const HIGH = 1;
case LOWEST = 5;
case NORMAL = 3;
case HIGHEST = 1;
public function toMIME() : string
{
return $this->value . ' (' . \ucfirst(\strtolower($this->name)) . ')';
}
}

View file

@ -11,6 +11,8 @@
namespace MailSo\Mime;
use MailSo\Mime\Enumerations\MessagePriority;
/**
* @category MailSo
* @package Mime
@ -196,26 +198,9 @@ class Message extends Part
return $this;
}
public function SetPriority(int $iValue) : self
public function SetPriority(MessagePriority $eValue) : self
{
$sResult = '';
switch ($iValue)
{
case Enumerations\MessagePriority::HIGH:
$sResult = Enumerations\MessagePriority::HIGH.' (Highest)';
break;
case Enumerations\MessagePriority::NORMAL:
$sResult = Enumerations\MessagePriority::NORMAL.' (Normal)';
break;
case Enumerations\MessagePriority::LOW:
$sResult = Enumerations\MessagePriority::LOW.' (Lowest)';
break;
}
if (\strlen($sResult)) {
$this->aHeadersValue[Enumerations\Header::X_PRIORITY] = $sResult;
}
$this->aHeadersValue[Enumerations\Header::X_PRIORITY] = $eValue->toMIME();
return $this;
}

View file

@ -702,7 +702,7 @@ class Actions
'SoundNotification' => true,
'NotificationSound' => 'new-mail',
'DesktopNotifications' => true,
'Layout' => (int) $oConfig->Get('defaults', 'view_layout', Enumerations\Layout::SIDE_PREVIEW),
'Layout' => (int) $oConfig->Get('defaults', 'view_layout', Enumerations\Layout::SIDE_PREVIEW->value),
'EditorDefaultType' => \str_replace('Forced', '', $oConfig->Get('defaults', 'view_editor_type', '')),
'editorWysiwyg' => 'Squire',
'UseCheckboxesInList' => (bool) $oConfig->Get('defaults', 'view_use_checkboxes', true),
@ -834,7 +834,7 @@ class Actions
$aResult['DevPassword'] = '';
}
$aResult['signMe'] = (string) $oConfig->Get('login', 'sign_me_auto', Enumerations\SignMeType::DEFAULT_OFF);
$aResult['signMe'] = (string) $oConfig->Get('login', 'sign_me_auto', Enumerations\SignMeType::DEFAULT_OFF->value);
}
}

View file

@ -903,7 +903,7 @@ trait Messages
}
if (!empty($this->GetActionParam('markAsImportant', 0))) {
$oMessage->SetPriority(\MailSo\Mime\Enumerations\MessagePriority::HIGH);
$oMessage->SetPriority(\MailSo\Mime\Enumerations\MessagePriority::HIGHEST);
}
$oMessage->SetSubject($this->GetActionParam('subject', ''));

View file

@ -170,9 +170,9 @@ trait User
});
$this->setSettingsFromParams($oSettings, 'Layout', 'int', function ($iValue) {
return (int) (\in_array((int) $iValue, array(\RainLoop\Enumerations\Layout::NO_PREVIEW,
\RainLoop\Enumerations\Layout::SIDE_PREVIEW, \RainLoop\Enumerations\Layout::BOTTOM_PREVIEW)) ?
$iValue : \RainLoop\Enumerations\Layout::SIDE_PREVIEW);
return (
\RainLoop\Enumerations\Layout::tryFrom((int) $iValue) ?? \RainLoop\Enumerations\Layout::SIDE_PREVIEW
)->value;
});
$this->setSettingsFromParams($oSettings, 'EditorDefaultType', 'string');

View file

@ -283,7 +283,7 @@ When this value is gethostname, the gethostname() value is used.
'login_lowercase' => array(true),
'sign_me_auto' => array(\RainLoop\Enumerations\SignMeType::DEFAULT_OFF,
'sign_me_auto' => array(\RainLoop\Enumerations\SignMeType::DEFAULT_OFF->value,
'This option allows webmail to remember the logged in user
once they closed the browser window.

View file

@ -2,9 +2,9 @@
namespace RainLoop\Enumerations;
abstract class Layout
enum Layout: int
{
const NO_PREVIEW = 0;
const SIDE_PREVIEW = 1;
const BOTTOM_PREVIEW = 2;
case NO_PREVIEW = 0;
case SIDE_PREVIEW = 1;
case BOTTOM_PREVIEW = 2;
}

View file

@ -2,9 +2,9 @@
namespace RainLoop\Enumerations;
abstract class SignMeType
enum SignMeType: string
{
const DEFAULT_OFF = 'DefaultOff';
const DEFAULT_ON = 'DefaultOn';
const UNUSED = 'Unused';
case DEFAULT_OFF = 'DefaultOff';
case DEFAULT_ON = 'DefaultOn';
case UNUSED = 'Unused';
}