90 lines
1.9 KiB
PHP
90 lines
1.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Civi\Mailinglistsync;
|
|
|
|
use Civi\Mailinglistsync\Exceptions\ContactSyncException;
|
|
use CRM_Mailinglistsync_ExtensionUtil as E;
|
|
|
|
class MailingListManager {
|
|
use Singleton;
|
|
|
|
/**
|
|
* Is the mailing list enabled?
|
|
*
|
|
* @var bool
|
|
*/
|
|
private bool $enabled;
|
|
|
|
/**
|
|
* Is logging enabled?
|
|
*
|
|
* @var bool
|
|
*/
|
|
private mixed $logging;
|
|
|
|
/**
|
|
* Host of the mlmmj server
|
|
*
|
|
* @var string
|
|
*/
|
|
private string $mlmmjHost;
|
|
|
|
/**
|
|
* Token for the mlmmj server
|
|
*
|
|
* @var string
|
|
*/
|
|
private string $mlmmjToken;
|
|
|
|
/**
|
|
* Port of the mlmmj server
|
|
*
|
|
* @var int
|
|
*/
|
|
private int $mlmmjPort;
|
|
|
|
/**
|
|
* Host of the dovecot server
|
|
*
|
|
* @var string|mixed
|
|
*/
|
|
private string $dovecotHost;
|
|
|
|
/**
|
|
* Token for the dovecot server
|
|
*
|
|
* @var string|mixed
|
|
*/
|
|
private string $dovecotToken;
|
|
|
|
/**
|
|
* Port of the dovecot server
|
|
*
|
|
* @var int
|
|
*/
|
|
private int $dovecotPort;
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @throws \Exception
|
|
*/
|
|
protected function __construct() {
|
|
// Load settings
|
|
$settings = MailingListSettings::get();
|
|
$this->enabled = $settings[E::SHORT_NAME . '_enable'] ?? FALSE;
|
|
$this->logging = $settings[E::SHORT_NAME . '_logging'] ?? FALSE;
|
|
$this->mlmmjHost = $settings[E::SHORT_NAME . '_mlmmj_host'] ??
|
|
throw new \Exception('No mlmmj host set');
|
|
$this->mlmmjToken = $settings[E::SHORT_NAME . '_mlmmj_token'] ??
|
|
throw new \Exception('No mlmmj token set');
|
|
$this->mlmmjPort = $settings[E::SHORT_NAME . '_mlmmj_port'] ?? 443;
|
|
$this->dovecotHost = $settings[E::SHORT_NAME . '_dovecot_host'] ??
|
|
throw new \Exception('No dovecot host set');
|
|
$this->dovecotToken = $settings[E::SHORT_NAME . '_dovecot_token'] ??
|
|
throw new \Exception('No dovecot token set');
|
|
$this->dovecotPort = $settings[E::SHORT_NAME . '_dovecot_port'] ?? 443;
|
|
$this->mlmmjApi = MailingListApi::getInstance();
|
|
}
|
|
}
|