From 5f0f873fb2111e990ade32f10eff5d202213ce0c Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Sat, 1 Feb 2025 21:14:28 +0100 Subject: [PATCH] Add configuration option to hide official templates Introduce a new environment variable and configuration option to allow users to hide official templates in the template gallery. This provides more flexibility for self-hosted instances of OpnForm. --- api/app/Http/Controllers/Forms/TemplateController.php | 2 +- api/config/opnform.php | 1 + docs/configuration/environment-variables.mdx | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/app/Http/Controllers/Forms/TemplateController.php b/api/app/Http/Controllers/Forms/TemplateController.php index 584a2f2f..804064dd 100644 --- a/api/app/Http/Controllers/Forms/TemplateController.php +++ b/api/app/Http/Controllers/Forms/TemplateController.php @@ -14,7 +14,7 @@ class TemplateController extends Controller { private function getProdTemplates($slug = false) { - if (!config('app.self_hosted')) { + if (!config('app.self_hosted') || !config('opnform.show_official_templates')) { return []; } diff --git a/api/config/opnform.php b/api/config/opnform.php index c47e97ba..78dc5fcb 100644 --- a/api/config/opnform.php +++ b/api/config/opnform.php @@ -5,4 +5,5 @@ return [ 'moderator_emails' => explode(',', env('MODERATOR_EMAILS') ?? ''), 'template_editor_emails' => explode(',', env('TEMPLATE_EDITOR_EMAILS') ?? ''), 'extra_pro_users_emails' => explode(',', env('EXTRA_PRO_USERS_EMAILS') ?? ''), + 'show_official_templates' => env('SHOW_OFFICIAL_TEMPLATES', true), ]; diff --git a/docs/configuration/environment-variables.mdx b/docs/configuration/environment-variables.mdx index 9c2a383c..6b82eb46 100644 --- a/docs/configuration/environment-variables.mdx +++ b/docs/configuration/environment-variables.mdx @@ -47,6 +47,7 @@ There are dedicated configuration pages available for more detailed setup instru | `TEMPLATE_EDITOR_EMAILS` | Comma-separated list of template editor emails. | | `EXTRA_PRO_USERS_EMAILS` | Comma-separated list of extra pro user emails. | | `MODERATOR_EMAILS` | Comma-separated list of moderator email addresses. | +| `SHOW_OFFICIAL_TEMPLATES` | Set to `false` to hide official templates from OpnForm's template gallery (defaults to `true`). | ## Front-end Environment Variables