3 Commits

Author SHA1 Message Date
Jürgen Mummert 67442da17a Read external DB config from Dotenv environment 2026-04-01 12:13:44 +02:00
Jürgen Mummert f9df49b998 Allow evlks_access in editor field permissions 2026-04-01 12:02:50 +02:00
Jürgen Mummert 8a16de3477 Add EVLKS accessibility field and export mapping 2026-04-01 11:46:57 +02:00
6 changed files with 106 additions and 20 deletions
+1
View File
@@ -32,6 +32,7 @@ services:
Mummert\KsNossenerlandBundle\Service\SoapClientService: Mummert\KsNossenerlandBundle\Service\SoapClientService:
arguments: arguments:
$httpClient: '@GuzzleHttp\Client'
$wsdlUrl: '%env(default:ks_nossenerland.soap_wsdl_url_fallback:KS_NOSSENERLAND_SOAP_WSDL_URL)%' $wsdlUrl: '%env(default:ks_nossenerland.soap_wsdl_url_fallback:KS_NOSSENERLAND_SOAP_WSDL_URL)%'
$endpointUrl: '%env(default:ks_nossenerland.soap_endpoint_url_fallback:KS_NOSSENERLAND_SOAP_ENDPOINT_URL)%' $endpointUrl: '%env(default:ks_nossenerland.soap_endpoint_url_fallback:KS_NOSSENERLAND_SOAP_ENDPOINT_URL)%'
$apiKey: '%env(default:ks_nossenerland.soap_api_key_fallback:KS_NOSSENERLAND_SOAP_API_KEY)%' $apiKey: '%env(default:ks_nossenerland.soap_api_key_fallback:KS_NOSSENERLAND_SOAP_API_KEY)%'
+27 -1
View File
@@ -19,7 +19,7 @@ $fields = [
'alt', 'imageTitle', 'size', 'imageUrl', 'caption', 'floating', 'repeatEach', 'repeatEnd', 'recurrences', 'enclosure', 'alt', 'imageTitle', 'size', 'imageUrl', 'caption', 'floating', 'repeatEach', 'repeatEnd', 'recurrences', 'enclosure',
'source', 'linkText', 'jumpTo', 'articleId', 'url', 'cssClass', 'start', 'stop', 'languageMain', 'catalog_ort', 'source', 'linkText', 'jumpTo', 'articleId', 'url', 'cssClass', 'start', 'stop', 'languageMain', 'catalog_ort',
'catalog_kontakt', 'godi_options', 'catalog_pfarrbereiche', 'styleManager', 'export', 'catalog_kontakt', 'godi_options', 'catalog_pfarrbereiche', 'styleManager', 'export',
'external_location', 'evlkscalendar' 'external_location', 'evlkscalendar', 'evlks_access'
]; ];
foreach ($fields as $field) { foreach ($fields as $field) {
@@ -143,6 +143,31 @@ $dca['fields']['export'] = [
'sql' => "char(1) NOT NULL default ''", 'sql' => "char(1) NOT NULL default ''",
]; ];
$dca['fields']['evlks_access'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['evlks_access'],
'exclude' => true,
'inputType' => 'select',
'options' => [
1 => 'Veranstaltung in Gebaerdensprache bzw. Gebaerdendolmetscher ist anwesend',
2 => 'Predigt / Liturgie der Veranstaltung liegt in schriftlicher Form vor',
3 => 'Veranstaltung findet in Leichter Sprache statt',
4 => 'Gebaerdensprachdolmetscher kann bei Bedarf bestellt werden',
5 => 'Abholung oder Fahrdienst kann bei Bedarf organisiert werden',
6 => 'Induktive Hoeranlage',
7 => 'FM-Anlage (drahtlose Funkanlage)',
8 => 'Punktschrift / Grossdruck auf Anfrage',
9 => 'Begleitservice auf Anfrage',
],
'eval' => [
'multiple' => true,
'chosen' => true,
'csv' => ',',
'includeBlankOption' => true,
'tl_class' => 'w50 clr',
],
'sql' => "text NULL",
];
$dca['fields']['external_location'] = [ $dca['fields']['external_location'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['external_location'], 'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['external_location'],
'inputType' => 'select', 'inputType' => 'select',
@@ -182,6 +207,7 @@ PaletteManipulator::create()
->addField('subtitle', 'title_legend', PaletteManipulator::POSITION_APPEND) ->addField('subtitle', 'title_legend', PaletteManipulator::POSITION_APPEND)
->addField('evlkscalendar', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND) ->addField('evlkscalendar', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND)
->addField('export', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND) ->addField('export', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND)
->addField('evlks_access', 'nossenerland_legend', PaletteManipulator::POSITION_APPEND)
->addField('contributors', 'address') ->addField('contributors', 'address')
->addField('catalog_kontakt', 'address') ->addField('catalog_kontakt', 'address')
->addField('catalog_pfarrbereiche', 'address') ->addField('catalog_pfarrbereiche', 'address')
@@ -23,6 +23,9 @@ $lang['export'][1] = 'auswählen wenn die Veranstaltung auc
$lang['evlkscalendar'][0] = 'Veranstaltung nicht auf EVLKS Kaelnder zeigen'; $lang['evlkscalendar'][0] = 'Veranstaltung nicht auf EVLKS Kaelnder zeigen';
$lang['evlkscalendar'][1] = 'wenn ausgewählt, wird die Veranstaltung nicht zum EVLKS Kalender exportiert'; $lang['evlkscalendar'][1] = 'wenn ausgewählt, wird die Veranstaltung nicht zum EVLKS Kalender exportiert';
$lang['evlks_access'][0] = 'Angaben zur Barrierefreiheit (EVLKS)';
$lang['evlks_access'][1] = 'Auswahl wird als Feld "access" an die EVLKS SOAP API uebertragen.';
$lang['external_location'][0] = 'Veranstaltungsort aus nossener-land.de Datenbank'; $lang['external_location'][0] = 'Veranstaltungsort aus nossener-land.de Datenbank';
$lang['external_location'][1] = 'Export funktioniert nur mit Veranstaltungsort aus nossener-land.de Datenbank'; $lang['external_location'][1] = 'Export funktioniert nur mit Veranstaltungsort aus nossener-land.de Datenbank';
+23 -8
View File
@@ -12,6 +12,7 @@ class ExportEventsCommand extends Command
{ {
private $connection; private $connection;
private $soapClientService; private $soapClientService;
private const BATCH_SIZE = 200;
public function __construct(Connection $connection, SoapClientService $soapClientService) public function __construct(Connection $connection, SoapClientService $soapClientService)
{ {
@@ -29,22 +30,36 @@ class ExportEventsCommand extends Command
{ {
$today = (new \DateTimeImmutable('today'))->getTimestamp(); $today = (new \DateTimeImmutable('today'))->getTimestamp();
$stmt = $this->connection->executeQuery(
'SELECT * FROM tl_calendar_events WHERE pid IN (1, 2, 3) AND evlkscalendar != 1 AND (
(endDate IS NOT NULL AND endDate >= ?) OR (endDate IS NULL AND startDate >= ?)
)',
[$today, $today]
);
$exportedIds = []; $exportedIds = [];
$exportCount = 0; $exportCount = 0;
while ($event = $stmt->fetchAssociative()) { $lastId = 0;
while (true) {
$rows = $this->connection->executeQuery(
'SELECT * FROM tl_calendar_events
WHERE pid IN (1, 2, 3)
AND evlkscalendar != 1
AND ((endDate IS NOT NULL AND endDate >= ?) OR (endDate IS NULL AND startDate >= ?))
AND id > ?
ORDER BY id ASC
LIMIT ' . self::BATCH_SIZE,
[$today, $today, $lastId]
)->fetchAllAssociative();
if (empty($rows)) {
break;
}
foreach ($rows as $event) {
$response = $this->soapClientService->sendEventToSoapAPI($event); $response = $this->soapClientService->sendEventToSoapAPI($event);
if ($response) { if ($response) {
$exportedIds[] = (string) $event['id']; $exportedIds[] = (string) $event['id'];
$exportCount++; $exportCount++;
} }
$lastId = (int) $event['id'];
}
} }
$remoteExternalIds = $this->soapClientService->fetchRemoteExternalIds(); $remoteExternalIds = $this->soapClientService->fetchRemoteExternalIds();
+10 -3
View File
@@ -6,6 +6,13 @@ use PDO;
class ExternalLocationModel class ExternalLocationModel
{ {
private static function readEnv(string $key): string
{
$value = $_SERVER[$key] ?? $_ENV[$key] ?? getenv($key);
return is_string($value) ? trim($value) : '';
}
/** /**
* Erstellt die PDO-Verbindung zur externen Datenbank. * Erstellt die PDO-Verbindung zur externen Datenbank.
* *
@@ -13,9 +20,9 @@ class ExternalLocationModel
*/ */
private static function getConnection() private static function getConnection()
{ {
$dsn = getenv('KS_NOSSENERLAND_EXTERNAL_DB_DSN') ?: ''; $dsn = self::readEnv('KS_NOSSENERLAND_EXTERNAL_DB_DSN');
$user = getenv('KS_NOSSENERLAND_EXTERNAL_DB_USER') ?: ''; $user = self::readEnv('KS_NOSSENERLAND_EXTERNAL_DB_USER');
$password = getenv('KS_NOSSENERLAND_EXTERNAL_DB_PASSWORD') ?: ''; $password = self::readEnv('KS_NOSSENERLAND_EXTERNAL_DB_PASSWORD');
if ('' === $dsn || '' === $user) { if ('' === $dsn || '' === $user) {
throw new \PDOException('Missing external DB env vars for location lookup.'); throw new \PDOException('Missing external DB env vars for location lookup.');
+38 -4
View File
@@ -7,6 +7,7 @@ use SoapHeader;
use Exception; use Exception;
use StdClass; use StdClass;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use GuzzleHttp\Client;
class SoapClientService class SoapClientService
{ {
@@ -14,10 +15,12 @@ class SoapClientService
private string $apiKey; private string $apiKey;
private string $vid; private string $vid;
private Connection $connection; private Connection $connection;
private Client $httpClient;
public function __construct(Connection $connection, string $wsdlUrl, string $endpointUrl, string $apiKey, string $vid) public function __construct(Connection $connection, Client $httpClient, string $wsdlUrl, string $endpointUrl, string $apiKey, string $vid)
{ {
$this->connection = $connection; $this->connection = $connection;
$this->httpClient = $httpClient;
$this->apiKey = $apiKey; $this->apiKey = $apiKey;
$this->vid = $vid; $this->vid = $vid;
@@ -211,6 +214,7 @@ class SoapClientService
$link = 'https://kirchspiel-nossener-land.de/termine/' . $eventData['alias']; $link = 'https://kirchspiel-nossener-land.de/termine/' . $eventData['alias'];
$menue1 = (isset($eventData['godi_options']) && in_array('2', explode(',', $eventData['godi_options']))) ? 100 : null; $menue1 = (isset($eventData['godi_options']) && in_array('2', explode(',', $eventData['godi_options']))) ? 100 : null;
$access = $this->normalizeCsvSelection($eventData['evlks_access'] ?? null, range(1, 9));
$event = [ $event = [
'externalid' => strval($eventData['id']), 'externalid' => strval($eventData['id']),
@@ -233,6 +237,7 @@ class SoapClientService
'textline1' => $people, 'textline1' => $people,
'people' => null, 'people' => null,
'menue1' => $menue1, 'menue1' => $menue1,
'access' => $access,
'kollekte' => 0, 'kollekte' => 0,
]; ];
@@ -244,6 +249,19 @@ class SoapClientService
} }
} }
private function normalizeCsvSelection(?string $csv, array $allowedIds): ?string
{
if (null === $csv || '' === trim($csv)) {
return null;
}
$allowed = array_map('strval', $allowedIds);
$items = array_filter(array_map('trim', explode(',', $csv)), static fn ($v) => '' !== $v);
$items = array_values(array_unique(array_filter($items, static fn ($v) => in_array($v, $allowed, true))));
return empty($items) ? null : implode(',', $items);
}
public function deleteEventByExternalId(string $externalId): bool public function deleteEventByExternalId(string $externalId): bool
{ {
if (!$this->client instanceof SoapClient) { if (!$this->client instanceof SoapClient) {
@@ -272,9 +290,25 @@ class SoapClientService
{ {
$url = 'https://kalender.evlks.de/json?vid=' . $this->vid; $url = 'https://kalender.evlks.de/json?vid=' . $this->vid;
$json = @file_get_contents($url); try {
if (!$json) { $response = $this->httpClient->request('GET', $url, [
error_log("❌ Fehler beim Abrufen der JSON-Daten von $url"); 'timeout' => 3.0,
'connect_timeout' => 2.0,
'http_errors' => false,
]);
} catch (Exception $e) {
error_log("❌ Fehler beim Abrufen der JSON-Daten von $url: " . $e->getMessage());
return [];
}
if (200 !== $response->getStatusCode()) {
error_log("❌ EVLKS JSON antwortete mit HTTP " . $response->getStatusCode());
return [];
}
$json = (string) $response->getBody();
if ('' === $json) {
error_log("❌ Leere JSON-Antwort von $url");
return []; return [];
} }