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 * @package Mime
* @subpackage Enumerations * @subpackage Enumerations
*/ */
abstract class MessagePriority enum MessagePriority: int
{ {
const LOW = 5; case LOWEST = 5;
const NORMAL = 3; case NORMAL = 3;
const HIGH = 1; case HIGHEST = 1;
public function toMIME() : string
{
return $this->value . ' (' . \ucfirst(\strtolower($this->name)) . ')';
}
} }

View file

@ -11,6 +11,8 @@
namespace MailSo\Mime; namespace MailSo\Mime;
use MailSo\Mime\Enumerations\MessagePriority;
/** /**
* @category MailSo * @category MailSo
* @package Mime * @package Mime
@ -196,26 +198,9 @@ class Message extends Part
return $this; return $this;
} }
public function SetPriority(int $iValue) : self public function SetPriority(MessagePriority $eValue) : self
{ {
$sResult = ''; $this->aHeadersValue[Enumerations\Header::X_PRIORITY] = $eValue->toMIME();
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;
}
return $this; return $this;
} }

View file

@ -702,7 +702,7 @@ class Actions
'SoundNotification' => true, 'SoundNotification' => true,
'NotificationSound' => 'new-mail', 'NotificationSound' => 'new-mail',
'DesktopNotifications' => true, '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', '')), 'EditorDefaultType' => \str_replace('Forced', '', $oConfig->Get('defaults', 'view_editor_type', '')),
'editorWysiwyg' => 'Squire', 'editorWysiwyg' => 'Squire',
'UseCheckboxesInList' => (bool) $oConfig->Get('defaults', 'view_use_checkboxes', true), 'UseCheckboxesInList' => (bool) $oConfig->Get('defaults', 'view_use_checkboxes', true),
@ -834,7 +834,7 @@ class Actions
$aResult['DevPassword'] = ''; $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))) { 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', '')); $oMessage->SetSubject($this->GetActionParam('subject', ''));

View file

@ -170,9 +170,9 @@ trait User
}); });
$this->setSettingsFromParams($oSettings, 'Layout', 'int', function ($iValue) { $this->setSettingsFromParams($oSettings, 'Layout', 'int', function ($iValue) {
return (int) (\in_array((int) $iValue, array(\RainLoop\Enumerations\Layout::NO_PREVIEW, return (
\RainLoop\Enumerations\Layout::SIDE_PREVIEW, \RainLoop\Enumerations\Layout::BOTTOM_PREVIEW)) ? \RainLoop\Enumerations\Layout::tryFrom((int) $iValue) ?? \RainLoop\Enumerations\Layout::SIDE_PREVIEW
$iValue : \RainLoop\Enumerations\Layout::SIDE_PREVIEW); )->value;
}); });
$this->setSettingsFromParams($oSettings, 'EditorDefaultType', 'string'); $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), '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 'This option allows webmail to remember the logged in user
once they closed the browser window. once they closed the browser window.

View file

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

View file

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