diff --git a/CHANGELOG.md b/CHANGELOG.md index 42a8e92e..e55a5165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ Neueste Version oben. Jeder Abschnitt beginnt mit `## MAJOR.MINOR.PATCH` und enthält kurze Stichpunkte für Anwenderinnen und Anwender – keine Commit-Texte. Der Self-Updater zeigt diese Abschnitte bei neuen Versionen an. +## 0.6.0 + +- Formulare: Anträge, Anmeldungen, Umfragen und Meldungen im Baukasten zusammenstellen – Textfelder, Auswahllisten, Mehrfachauswahl, Datum, Zahlen, Datei-Upload, Zustimmung, Zwischenüberschriften und Hinweise +- Felder lassen sich abhängig von anderen Antworten ein- und ausblenden und aus dem Profil vorbelegen +- Einsendungen landen im Backend und per E-Mail bei festen Empfängern; auf Wunsch eine Kopie an die ausfüllende Person +- Zugriff auf die Ergebnisse je Formular und Rolle – ansehen und exportieren (CSV für Excel) bzw. löschen getrennt vergebbar +- Anonyme Formulare, „nur einmal ausfüllen“, Einsendeschluss, Sichtbarkeit und automatische Löschfrist +- Formulare lassen sich mit dem Pagebuilder in Seiten einbinden +- WordPress-Import: Beiträge mit Kategorien, Autorinnen und Autoren, Beitragsbildern und Bildern im Text übernehmen, auf Wunsch auch Seiten – wiederholbar, ohne Doppelungen +- E-Mail-Versand im Admin einrichten (SMTP), mit Test-Mail + ## 0.5.0 - Seiten: eigener Seitenbaum für Bereiche, Abteilungen und Gremien – mit Seitennavigation, Brotkrumen und optional in der Hauptnavigation diff --git a/app/Filament/Pages/MailSettingsPage.php b/app/Filament/Pages/MailSettingsPage.php new file mode 100644 index 00000000..05d6316a --- /dev/null +++ b/app/Filament/Pages/MailSettingsPage.php @@ -0,0 +1,109 @@ +|null */ + public ?array $data = []; + + public static function canAccess(): bool + { + return auth()->user()?->can('mail.manage') ?? false; + } + + public function mount(MailSettings $mail): void + { + $this->form->fill([...$mail->values(), 'password' => null]); + } + + public function form(Schema $schema): Schema + { + $smtp = fn (Get $get) => $get('mailer') === 'smtp'; + + return $schema + ->components([ + Section::make('Versand') + ->description('Die Zugangsdaten erhalten Sie von Ihrem Hoster oder Ihrer IT (z. B. Microsoft 365: smtp.office365.com, Port 587, TLS).') + ->columns(2) + ->schema([ + Select::make('mailer')->label('Versandart')->options(MailSettings::MAILERS)->required()->live()->native(false)->columnSpanFull(), + TextInput::make('host')->label('SMTP-Server')->required($smtp)->visible($smtp)->maxLength(255), + TextInput::make('port')->label('Port')->numeric()->required($smtp)->visible($smtp)->minValue(1)->maxValue(65535), + Select::make('encryption')->label('Verschlüsselung')->visible($smtp)->native(false) + ->options(['tls' => 'STARTTLS (meist Port 587)', 'ssl' => 'SSL/TLS (meist Port 465)', 'none' => 'Keine']), + TextInput::make('username')->label('Benutzername')->visible($smtp)->maxLength(255)->autocomplete('off'), + TextInput::make('password')->label('Passwort')->password()->revealable()->visible($smtp)->maxLength(255) + ->helperText('Leer lassen, um das gespeicherte Passwort zu behalten.')->autocomplete('new-password'), + ]), + Section::make('Absender') + ->columns(2) + ->schema([ + TextInput::make('from_address')->label('Absenderadresse')->email()->required()->maxLength(255)->placeholder('intranet@firma.de'), + TextInput::make('from_name')->label('Absendername')->maxLength(100)->placeholder('Name des Portals'), + ]), + ]) + ->statePath('data'); + } + + public function save(MailSettings $mail): void + { + $mail->save($this->form->getState()); + Audit::log('mail.settings_updated'); + + Notification::make()->success()->title('E-Mail-Versand gespeichert')->send(); + } + + protected function getHeaderActions(): array + { + return [ + Action::make('test') + ->label('Test-Mail senden') + ->icon(Heroicon::OutlinedPaperAirplane) + ->color('gray') + ->action(function () { + $to = auth()->user()->email; + + try { + Mail::raw('Diese Test-Mail bestätigt, dass der E-Mail-Versand des Portals funktioniert.', fn ($m) => $m->to($to)->subject('Test-Mail aus dem Portal')); + Notification::make()->success()->title('Test-Mail an '.$to.' gesendet')->send(); + } catch (Throwable $e) { + Notification::make()->danger()->title('Versand fehlgeschlagen')->body($e->getMessage())->persistent()->send(); + } + }), + ]; + } +} diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 11e570e7..7cb20982 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -42,6 +42,7 @@ class HandleInertiaRequests extends Middleware 'notifications' => fn () => $user ? ['unread' => $user->unreadNotifications()->count()] : null, 'flash' => [ 'status' => fn () => $request->session()->get('status'), + 'form_submitted' => fn () => $request->session()->get('form_submitted'), ], ]; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 254192fc..98d9b7d8 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -13,6 +13,7 @@ use App\Support\BackgroundTasks; use App\Support\Branding; use App\Support\Installation; use App\Support\License\LicenseStore; +use App\Support\MailSettings; use App\Support\Navigation; use App\Support\Permissions\PermissionResource; use App\Support\Permissions\Permissions; @@ -42,6 +43,7 @@ class AppServiceProvider extends ServiceProvider } $this->app->singleton(Settings::class); + $this->app->singleton(MailSettings::class); $this->app->singleton(Branding::class); $this->app->singleton(Avatars::class); $this->app->singleton(QuickLinks::class); @@ -84,5 +86,9 @@ class AppServiceProvider extends ServiceProvider }); Password::defaults(fn () => Password::min(10)->letters()->numbers()); + + if (Installation::isInstalled()) { + $this->app->make(MailSettings::class)->apply(); + } } } diff --git a/app/Support/Abilities.php b/app/Support/Abilities.php index d6685b32..665cd40d 100644 --- a/app/Support/Abilities.php +++ b/app/Support/Abilities.php @@ -25,6 +25,7 @@ class Abilities $this->define('plugins.manage', 'Plugins verwalten und installieren', 'System'); $this->define('appearance.manage', 'Erscheinungsbild und Schnellzugriffe', 'System'); $this->define('updates.manage', 'Aktualisierungen, Lizenz und Systemzustand', 'System'); + $this->define('mail.manage', 'E-Mail-Versand einrichten', 'System'); $this->define('feedback.send', 'Rückmeldungen an den Hersteller senden', 'System'); } diff --git a/app/Support/MailSettings.php b/app/Support/MailSettings.php new file mode 100644 index 00000000..9bc6d03d --- /dev/null +++ b/app/Support/MailSettings.php @@ -0,0 +1,100 @@ + 'SMTP-Server', + 'sendmail' => 'Sendmail des Servers', + 'log' => 'Nicht senden (nur ins Protokoll schreiben)', + ]; + + public function __construct(private readonly Settings $settings) {} + + public function configured(): bool + { + return $this->settings->get('mail.mailer') !== null; + } + + /** + * @return array + */ + public function values(): array + { + return [ + 'mailer' => $this->settings->get('mail.mailer', 'log'), + 'host' => $this->settings->get('mail.host'), + 'port' => $this->settings->get('mail.port', 587), + 'encryption' => $this->settings->get('mail.encryption', 'tls'), + 'username' => $this->settings->get('mail.username'), + 'from_address' => $this->settings->get('mail.from_address'), + 'from_name' => $this->settings->get('mail.from_name'), + ]; + } + + /** + * @param array $values + */ + public function save(array $values): void + { + $data = [ + 'mail.mailer' => $values['mailer'], + 'mail.host' => $values['host'] ?? null, + 'mail.port' => isset($values['port']) ? (int) $values['port'] : null, + 'mail.encryption' => $values['encryption'] ?? 'tls', + 'mail.username' => $values['username'] ?? null, + 'mail.from_address' => $values['from_address'] ?? null, + 'mail.from_name' => $values['from_name'] ?? null, + ]; + + // Leeres Passwortfeld = gespeichertes behalten. + if (filled($values['password'] ?? null)) { + $data['mail.password'] = Crypt::encryptString($values['password']); + } + + $this->settings->setMany($data); + $this->apply(); + } + + public function apply(): void + { + if (! $this->configured()) { + return; + } + + $values = $this->values(); + + try { + $password = $this->settings->get('mail.password') ? Crypt::decryptString($this->settings->get('mail.password')) : null; + } catch (Throwable) { + $password = null; // APP_KEY geändert – Passwort muss neu eingegeben werden + } + + config([ + 'mail.default' => $values['mailer'], + 'mail.mailers.smtp.host' => $values['host'], + 'mail.mailers.smtp.port' => (int) $values['port'], + 'mail.mailers.smtp.scheme' => $values['encryption'] === 'ssl' ? 'smtps' : 'smtp', + 'mail.mailers.smtp.username' => $values['username'], + 'mail.mailers.smtp.password' => $password, + 'mail.mailers.smtp.timeout' => 15, + 'mail.from.address' => $values['from_address'] ?: config('mail.from.address'), + 'mail.from.name' => $values['from_name'] ?: app(Branding::class)->portalName(), + ]); + + // Bereits erzeugte Mailer mit alter Konfiguration verwerfen. + app()->forgetInstance('mail.manager'); + app()->forgetInstance('mailer'); + Mail::clearResolvedInstance('mail.manager'); + } +} diff --git a/app/Version.php b/app/Version.php index c7787881..d6c05aee 100644 --- a/app/Version.php +++ b/app/Version.php @@ -9,5 +9,5 @@ namespace App; */ final class Version { - public const VERSION = '0.5.0'; + public const VERSION = '0.6.0'; } diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index f3921bab..a72c4c7e 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -81,6 +81,32 @@ Die Anmeldung mit Passwort bleibt für Notfälle erhalten (z. B. wenn Entra ID nicht erreichbar ist). Den geheimen Clientschlüssel vor Ablauf erneuern – er ist bei Microsoft befristet. +## E-Mail-Versand + +Unter **Administration → E-Mail-Versand** den SMTP-Zugang eintragen (vom +Hoster oder der IT, z. B. Microsoft 365: `smtp.office365.com`, Port 587, +STARTTLS) und mit **Test-Mail senden** prüfen. Das Passwort wird verschlüsselt +gespeichert. Gebraucht wird der Versand für „Passwort vergessen“ und +Formular-Benachrichtigungen. Mails werden über die Hintergrundaufgaben +verschickt – ohne Cron oder Web-Cron also mit etwas Verzögerung. + +## Umstieg von WordPress + +1. In WordPress unter **Werkzeuge → Daten exportieren** „Alle Inhalte“ wählen + und die XML-Datei herunterladen. +2. Im Portal unter **Administration → Inhalte → WordPress-Import** hochladen + und **Datei prüfen**. +3. Kategorien zuordnen (neu anlegen, vorhandene nutzen oder weglassen), + Autorinnen und Autoren prüfen (Zuordnung über die E-Mail-Adresse) und + entscheiden, ob Entwürfe und WordPress-Seiten mitkommen. +4. **Import starten** – die Seite geöffnet lassen, der Import läuft in Portionen. + +Bilder werden von der alten Website geladen, sie muss dafür noch erreichbar +sein. Ein erneuter Import legt nichts doppelt an; auf Wunsch aktualisiert er +bereits übernommene Einträge. Kommentare, Schlagwörter und Inhalte anderer +WordPress-Plugins werden nicht übernommen. Nach dem Umstieg kann das Plugin +„WordPress-Import“ deaktiviert werden. + ## Hintergrundaufgaben Rückmeldungen, geplante Inhalte und Aufräumarbeiten laufen im Hintergrund. Die diff --git a/docs/PLAN.md b/docs/PLAN.md index 819ac9ea..14c91719 100644 --- a/docs/PLAN.md +++ b/docs/PLAN.md @@ -452,8 +452,8 @@ Entwickler, ohne Build, direkt im Admin unter „Erscheinungsbild“. ## 13. Mitgelieferte Plugins -**Start:** Dashboard, News/Feed mit Kategorien, CMS-Seiten, Verzeichnis & -Organigramm, Dokumente, App-Launcher. +**Start:** Dashboard, News/Feed mit Kategorien, CMS-Seiten, Formulare, +WordPress-Import, Verzeichnis & Organigramm, Dokumente, App-Launcher. **Später:** Events, Umfragen, Geburtstage/Jubiläen, Onboarding, Raumbuchung, Kantinenplan, Ideenbox, Urlaubsanträge. @@ -482,6 +482,7 @@ Kantinenplan, Ideenbox, Urlaubsanträge. | **2 – Plugin-System & Rechte** ✅ | Plugin-Loader, Hooks/Filter, Registries, Recovery-Modus, Import-Map-Frontend; Rollen, Grants, Zielgruppen, Rechte-Cache, Rechte-Prüfer | | **3 – Entra ID** ✅ | OIDC-Login, JIT, Gruppen-/App-Rollen-Mapping (additiv), Graph-Profil- & Foto-Sync mit frei zuordenbaren Attributen (inkl. Erweiterungsattributen) und eigenen Profilfeldern, Delta-Sync | | **4 – CMS** ✅ | Seitenbaum, Pagebuilder (Layout-, Inhalts-, Medien- und dynamische Blöcke, Sichtbarkeit je Block), Entwürfe, Versionen, Zeitsteuerung, Bearbeitungssperre, Freigaben; News-Freigabe-Workflow und Redaktion im Portal; Benachrichtigungen. Offen: Vorlagen und wiederverwendbare Blöcke | +| **4b – Formulare & Umstieg** ✅ | Formular-Plugin (Baukasten, Bedingungen, Uploads, anonyme Formulare, Mail + Backend, Ergebnis-Rechte je Formular und Rolle, CSV, Löschfristen, Pagebuilder-Block); WordPress-Import (Beiträge, Kategorien, Bilder, Seiten); E-Mail-Versand im Admin | | **5 – Branding & Theming** | Vollständige Seite „Erscheinungsbild“: Logo-Varianten, Farben inkl. Farbtreue & Kontrastprüfung, Schriften, Form, Login-Seite, E-Mails, Live-Vorschau, Entwurf/Veröffentlichen, Export/Import | | **6 – Weitere Plugins & IdPs** | Verzeichnis/Organigramm, Dokumente, Events …; OIDC generisch, LDAP, SAML; Lasttests 5.000 User | | **7 – Plugin-SDK öffentlich** | Doku, Generator, Beispiel-Plugins (kein Plugin-Verzeichnis) | diff --git a/plugins-core/forms/database/migrations/2026_09_28_000002_create_forms_tables.php b/plugins-core/forms/database/migrations/2026_09_28_000002_create_forms_tables.php new file mode 100644 index 00000000..7ae396dc --- /dev/null +++ b/plugins-core/forms/database/migrations/2026_09_28_000002_create_forms_tables.php @@ -0,0 +1,57 @@ +id(); + $table->string('title'); + $table->string('slug', 120)->unique(); + $table->text('description')->nullable(); + $table->json('fields'); + $table->json('settings')->nullable(); + $table->boolean('is_open')->default(true); + $table->timestamp('closes_at')->nullable(); + $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamps(); + }); + + Schema::create('form_submissions', function (Blueprint $table) { + $table->id(); + $table->foreignId('form_id')->constrained('forms')->cascadeOnDelete(); + // Bei anonymen Formularen leer; „nur einmal ausfüllen“ prüft dann user_hash. + $table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete(); + $table->string('user_hash', 64)->nullable(); + $table->json('data'); + $table->timestamp('read_at')->nullable(); + $table->timestamps(); + + $table->index(['form_id', 'created_at']); + $table->index(['form_id', 'user_hash']); + $table->index(['form_id', 'user_id']); + }); + + Schema::create('form_files', function (Blueprint $table) { + $table->id(); + $table->foreignId('submission_id')->constrained('form_submissions')->cascadeOnDelete(); + $table->string('field', 80); + $table->string('name'); + $table->string('path'); + $table->string('mime', 150)->nullable(); + $table->unsignedBigInteger('size')->default(0); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('form_files'); + Schema::dropIfExists('form_submissions'); + Schema::dropIfExists('forms'); + } +}; diff --git a/plugins-core/forms/plugin.json b/plugins-core/forms/plugin.json new file mode 100644 index 00000000..0d1c1f80 --- /dev/null +++ b/plugins-core/forms/plugin.json @@ -0,0 +1,13 @@ +{ + "slug": "forms", + "name": "Formulare", + "version": "1.0.0", + "description": "Formulare zusammenstellen – Anträge, Anmeldungen, Umfragen, Meldungen. Ergebnisse per E-Mail und im Backend, Zugriff je Formular und Rolle.", + "author": "Inhaus", + "namespace": "Inhaus\\Plugins\\Forms\\", + "class": "Inhaus\\Plugins\\Forms\\FormsPlugin", + "requires": { + "core": ">=0.6.0", + "php": ">=8.3" + } +} diff --git a/plugins-core/forms/resources/js/blocks/FormBlock.vue b/plugins-core/forms/resources/js/blocks/FormBlock.vue new file mode 100644 index 00000000..4436a8ec --- /dev/null +++ b/plugins-core/forms/resources/js/blocks/FormBlock.vue @@ -0,0 +1,21 @@ + + + diff --git a/plugins-core/forms/resources/js/components/FormRenderer.vue b/plugins-core/forms/resources/js/components/FormRenderer.vue new file mode 100644 index 00000000..4ea8d058 --- /dev/null +++ b/plugins-core/forms/resources/js/components/FormRenderer.vue @@ -0,0 +1,199 @@ + + +