diff --git a/config/config.default.php b/config/config.default.php index e39e10c9..00b8c92d 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -35,12 +35,15 @@ return [ // Footer links 'footer_items' => [ // URL to the angel faq and job description - 'FAQ' => env('FAQ_URL', 'https://events.ccc.de/congress/2013/wiki/Static:Volunteers'), + 'FAQ' => env('FAQ_URL', '/faq'), // Contact email address, linked on every page 'Contact' => env('CONTACT_EMAIL', 'mailto:ticket@c3heaven.de'), ], + // Text displayed on the FAQ page, rendered as markdown + 'faq_text' => env('FAQ_TEXT', null), + // Link to documentation/help 'documentation_url' => 'https://engelsystem.de/doc/', diff --git a/config/routes.php b/config/routes.php index 14a5e1a9..c0a562ab 100644 --- a/config/routes.php +++ b/config/routes.php @@ -40,6 +40,9 @@ $route->get('/meetings', 'NewsController@meetings'); $route->get('/news/{id:\d+}', 'NewsController@show'); $route->post('/news/{id:\d+}', 'NewsController@comment'); +// FAQ +$route->get('/faq', 'FaqController@index'); + // API $route->get('/api[/{resource:.+}]', 'ApiController@index'); @@ -50,6 +53,15 @@ $route->get('/design', 'DesignController@index'); $route->addGroup( '/admin', function (RouteCollector $route) { + // FAQ + $route->addGroup( + '/faq', + function (RouteCollector $route) { + $route->get('[/{id:\d+}]', 'Admin\\FaqController@edit'); + $route->post('[/{id:\d+}]', 'Admin\\FaqController@save'); + } + ); + // Log $route->get('/logs', 'Admin\\LogsController@index'); $route->post('/logs', 'Admin\\LogsController@index'); diff --git a/db/migrations/2020_09_28_000000_create_faq_table_and_permissions.php b/db/migrations/2020_09_28_000000_create_faq_table_and_permissions.php new file mode 100644 index 00000000..730ea2dd --- /dev/null +++ b/db/migrations/2020_09_28_000000_create_faq_table_and_permissions.php @@ -0,0 +1,69 @@ +schema->create('faq', function (Blueprint $table) { + $table->increments('id'); + $table->string('question'); + $table->text('text'); + $table->timestamps(); + }); + + if ($this->schema->hasTable('Privileges')) { + $db = $this->schema->getConnection(); + $db->table('Privileges')->insert([ + ['name' => 'faq.view', 'desc' => 'View FAQ entries'], + ['name' => 'faq.edit', 'desc' => 'Edit FAQ entries'], + ]); + + $guestGroup = -10; + $angelGroup = -20; + $shiftCoordinatorGroup = -40; + $viewId = $db->table('Privileges')->where('name', 'faq.view')->first()->id; + $editId = $db->table('Privileges')->where('name', 'faq.edit')->first()->id; + $db->table('GroupPrivileges')->insert([ + ['group_id' => $guestGroup, 'privilege_id' => $viewId], + ['group_id' => $angelGroup, 'privilege_id' => $viewId], + ['group_id' => $shiftCoordinatorGroup, 'privilege_id' => $editId], + ]); + + $db->table('Privileges') + ->whereIn('name', ['admin_faq']) + ->delete(); + } + } + + /** + * Reverse the migration + */ + public function down() + { + $this->schema->drop('faq'); + + if ($this->schema->hasTable('Privileges')) { + $db = $this->schema->getConnection(); + $db->table('Privileges') + ->whereIn('name', ['faq.view', 'faq.edit']) + ->delete(); + + $db->table('Privileges')->insert([ + ['name' => 'admin_faq', 'desc' => 'Edit FAQs'], + ]); + $bureaucratGroup = -60; + $adminFaqId = $db->table('Privileges')->where('name', 'admin_faq')->first()->id; + $db->table('GroupPrivileges')->insert([ + ['group_id' => $bureaucratGroup, 'privilege_id' => $adminFaqId], + ]); + } + } +} diff --git a/resources/lang/de_DE/additional.po b/resources/lang/de_DE/additional.po index 35b10119..ece9a9d3 100644 --- a/resources/lang/de_DE/additional.po +++ b/resources/lang/de_DE/additional.po @@ -108,3 +108,9 @@ msgstr "OAuth-Provider nicht gefunden" msgid "settings.profile" msgstr "Profil" + +msgid "faq.delete.success" +msgstr "FAQ Eintrag erfolgreich gelöscht." + +msgid "faq.edit.success" +msgstr "FAQ Eintrag erfolgreich aktualisiert." diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index d6dd2136..a9ab1342 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2776,6 +2776,15 @@ msgstr "Bearbeiten" msgid "form.save" msgstr "Speichern" +msgid "form.preview" +msgstr "Vorschau" + +msgid "form.delete" +msgstr "Löschen" + +msgid "form.updated" +msgstr "Aktualisiert" + msgid "schedule.import" msgstr "Programm importieren" @@ -2879,9 +2888,6 @@ msgstr "Treffen" msgid "news.edit.message" msgstr "Nachricht" -msgid "news.preview" -msgstr "Vorschau" - msgid "form.search" msgstr "Suchen" @@ -2936,3 +2942,18 @@ msgstr "Verbinden" msgid "form.disconnect" msgstr "Trennen" + +msgid "faq.faq" +msgstr "FAQ" + +msgid "faq.edit" +msgstr "FAQ Eintrag bearbeiten" + +msgid "faq.add" +msgstr "FAQ Eintrag erstellen" + +msgid "faq.question" +msgstr "Frage" + +msgid "faq.message" +msgstr "Antwort" diff --git a/resources/lang/en_US/additional.po b/resources/lang/en_US/additional.po index c5500f84..bcf08ef7 100644 --- a/resources/lang/en_US/additional.po +++ b/resources/lang/en_US/additional.po @@ -104,3 +104,9 @@ msgstr "Unable to find OAuth provider" msgid "settings.profile" msgstr "Profile" + +msgid "faq.delete.success" +msgstr "FAQ entry successfully deleted." + +msgid "faq.edit.success" +msgstr "FAQ entry successfully updated." diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index 3999d8ea..4d54671e 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -60,6 +60,15 @@ msgstr "Save" msgid "form.edit" msgstr "Bearbeiten" +msgid "form.preview" +msgstr "Preview" + +msgid "form.delete" +msgstr "Delete" + +msgid "form.updated" +msgstr "Updated" + msgid "schedule.import" msgstr "Import schedule" @@ -165,9 +174,6 @@ msgstr "Meeting" msgid "news.edit.message" msgstr "Message" -msgid "news.preview" -msgstr "Preview" - msgid "form.search" msgstr "Search" @@ -221,3 +227,18 @@ msgstr "Connect" msgid "form.disconnect" msgstr "Disconnect" + +msgid "faq.faq" +msgstr "FAQ" + +msgid "faq.edit" +msgstr "Edit FAQ entry" + +msgid "faq.add" +msgstr "Add FAQ entry" + +msgid "faq.question" +msgstr "Question" + +msgid "faq.message" +msgstr "Answer" diff --git a/resources/views/layouts/parts/footer.twig b/resources/views/layouts/parts/footer.twig index 01fd5c1a..d848764c 100644 --- a/resources/views/layouts/parts/footer.twig +++ b/resources/views/layouts/parts/footer.twig @@ -26,7 +26,7 @@ {% endblock %} {% for name,url in config('footer_items') %} - + {% if '@' in url %}{% endif %} {{ __(name) }} · diff --git a/resources/views/macros/form.twig b/resources/views/macros/form.twig index 4d78707d..7ea7f822 100644 --- a/resources/views/macros/form.twig +++ b/resources/views/macros/form.twig @@ -69,6 +69,7 @@