From b5c2dd7bd23ab8a529ef641137066268ca7e87f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 22 Sep 2021 18:18:49 +0200 Subject: [PATCH 1/4] fix-admin and crudify user admin --- .../Controller/AdminController.php | 32 +++------ .../Controller/UserController.php | 62 ++++++----------- .../ChillMainExtension.php | 25 ++++++- .../layout_crud_permission_index.html.twig | 8 +++ .../Resources/views/Admin/index.html.twig | 22 +++--- .../Admin/layoutWithVerticalMenu.html.twig | 31 ++------- .../views/Admin/layout_permissions.html.twig | 6 +- .../views/Admin/menu_admin_index.html.twig | 18 +++++ .../menu_admin_permissions.html.twig} | 0 .../menu_admin_section.html.twig} | 0 .../views/Menu/verticalMenu.html.twig | 16 ++--- .../Resources/views/User/index.html.twig | 67 +++++++++++++++++-- .../MenuBuilder/AdminSectionMenuBuilder.php | 13 ++-- .../MenuBuilder/PermissionMenuBuilder.php | 47 +++++++++++++ src/Bundle/ChillMainBundle/config/routes.yaml | 18 ++--- .../ChillMainBundle/config/routes/center.yaml | 10 --- .../config/routes/permissionsgroup.yaml | 14 +--- .../ChillMainBundle/config/routes/scope.yaml | 10 --- .../ChillMainBundle/config/routes/user.yaml | 18 ++--- .../config/services/controller.yaml | 6 +- .../ChillMainBundle/config/services/menu.yaml | 9 ++- 21 files changed, 247 insertions(+), 185 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig rename src/Bundle/ChillMainBundle/Resources/views/{Menu/admin_permissions.html.twig => Admin/menu_admin_permissions.html.twig} (100%) rename src/Bundle/ChillMainBundle/Resources/views/{Menu/adminSection.html.twig => Admin/menu_admin_section.html.twig} (100%) create mode 100644 src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php diff --git a/src/Bundle/ChillMainBundle/Controller/AdminController.php b/src/Bundle/ChillMainBundle/Controller/AdminController.php index cdb7796a3..1c6569eea 100644 --- a/src/Bundle/ChillMainBundle/Controller/AdminController.php +++ b/src/Bundle/ChillMainBundle/Controller/AdminController.php @@ -23,32 +23,22 @@ namespace Chill\MainBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -/** - * Class AdminController - * - * @package Chill\MainBundle\Controller - * @author julien.fastre@champs-libres.coop - * @author marc@champs-libres.coop - */ +use Symfony\Component\Routing\Annotation\Route; + class AdminController extends AbstractController { - - public function indexAction($menu = 'admin', - $header_title = 'views.Main.admin.index.header_title', - $page_title = 'views.Main.admin.index.page_title') { - return $this->render('@ChillMain/Admin/layout.html.twig'); + + /** + * @Route("/{_locale}/admin", name="chill_main_admin_central") + */ + public function indexAction() + { + return $this->render('@ChillMain/Admin/index.html.twig'); } - + public function indexPermissionsAction() { return $this->render('@ChillMain/Admin/layout_permissions.html.twig'); } - - public function configurationWarningsAction() - { - $alertManager = $this->get('chill_main.configuration_alert_manager'); - - - } - + } diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 7de280d1d..62a28b8d6 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -2,6 +2,8 @@ namespace Chill\MainBundle\Controller; +use Chill\MainBundle\CRUD\Controller\AbstractCRUDController; +use Chill\MainBundle\CRUD\Controller\CRUDController; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +13,9 @@ use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Form\Type\ComposedGroupCenterType; use Chill\MainBundle\Form\UserPasswordType; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; +use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -19,69 +24,61 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; * * @package Chill\MainBundle\Controller */ -class UserController extends AbstractController +class UserController extends CRUDController { const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter'; - + /** * @var \Psr\Log\LoggerInterface */ private $logger; - + /** * @var ValidatorInterface */ private $validator; - + + private UserPasswordEncoderInterface $passwordEncoder; + /** * UserController constructor. * * @param LoggerInterface $logger * @param ValidatorInterface $validator */ - public function __construct(LoggerInterface $logger, ValidatorInterface $validator) - { + public function __construct( + LoggerInterface $logger, + ValidatorInterface $validator, + UserPasswordEncoderInterface $passwordEncoder + ) { $this->logger = $logger; $this->validator = $validator; + $this->passwordEncoder = $passwordEncoder; } - - /** - * Lists all User entities. - * - */ - public function indexAction() - { - $em = $this->getDoctrine()->getManager(); - $entities = $em->createQuery('SELECT u FROM ChillMainBundle:User u ' - . 'ORDER BY u.username') - ->getResult(); - - return $this->render('@ChillMain/User/index.html.twig', array( - 'entities' => $entities, - )); - } /** * Creates a new User entity. * */ - public function createAction(Request $request) + public function new(Request $request): Response { $user = new User(); $form = $this->createCreateForm($user); $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); - $user->setPassword($this->get('security.password_encoder') + $user->setPassword($this->passwordEncoder ->encodePassword($user, $form['plainPassword']->getData())); $em->persist($user); $em->flush(); return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId()))); + } elseif ($form->isSubmitted() && !$form->isValid()){ + } return $this->render('@ChillMain/User/new.html.twig', array( @@ -110,21 +107,6 @@ class UserController extends AbstractController return $form; } - /** - * Displays a form to create a new User entity. - * - */ - public function newAction() - { - $user = new User(); - $form = $this->createCreateForm($user); - - return $this->render('@ChillMain/User/new.html.twig', array( - 'entity' => $user, - 'form' => $form->createView(), - )); - } - /** * Finds and displays a User entity. * diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index d0aada689..65b8ffdf6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -19,10 +19,13 @@ namespace Chill\MainBundle\DependencyInjection; +use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Doctrine\DQL\STContains; use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Form\UserJobType; +use Chill\MainBundle\Form\UserType; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -283,13 +286,33 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'template' => '@ChillMain/UserJob/index.html.twig', ], 'new' => [ - 'role' => 'ROLE_ADMIN' + 'role' => 'ROLE_ADMIN' ], 'edit' => [ 'role' => 'ROLE_ADMIN' ] ], ], + [ + 'class' => User::class, + 'controller' => UserController::class, + 'name' => 'admin_user', + 'base_path' => '/admin/main/user2', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => UserType::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/User/index.html.twig' + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + ] + ] + ] ], 'apis' => [ [ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig new file mode 100644 index 000000000..76c1e2338 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig @@ -0,0 +1,8 @@ +{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} + +{% block title %}{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}{% endblock %} + +{% block content %} +{% embed '@ChillMain/CRUD/_index.html.twig' %} +{% endembed %} +{% endblock content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig index 7c922f333..11d5cc3c9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig @@ -1,17 +1,15 @@ {% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} +{% block vertical_menu_content %} +{% endblock %} + {% block admin_content %}

{{ 'Administration interface'|trans }}

- - {{ 'welcome_message_raw'|trans|raw }} -
-

{{ 'Configuration alerts'|trans }}

- -

{{ 'Here you can check the configuration of your instance.'|trans }}

- - {{ chill_widget('configuration_warnings', {}) }} - -
- -{% endblock %} \ No newline at end of file +

{{ 'Welcome to the admin section !'|trans }}

+ + {{ chill_menu('admin_index', { + 'layout': '@ChillMain/Admin/menu_admin_index.html.twig' + }) }} + +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig index eb9ad8451..9a57b9067 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig @@ -1,37 +1,14 @@ -{# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, - / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} - -{# - The layout of the admin section. All the page / template of the admin section must use this - layout. -#} - {% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} {% block navigation_search_bar %}{% endblock %} {% block navigation_section_menu %} {{ chill_menu('admin_section', { - 'layout': '@ChillMain/Menu/adminSection.html.twig', + 'layout': '@ChillMain/Admin/menu_admin_section.html.twig', }) }} {% endblock %} {% block layout_wvm_content %} - {% block admin_content %} -

{{ 'Welcome to the admin section !'|trans }}

+ {% block admin_content %} + {% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig index 3195ffdb9..dfb5139d3 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ {% block vertical_menu_content %} {{ chill_menu('admin_permissions', { - 'layout': '@ChillMain/Menu/admin_permissions.html.twig', + 'layout': '@ChillMain/Admin/menu_admin_permissions.html.twig', }) }} {% endblock %} @@ -28,4 +28,4 @@ {% block admin_content %}

{{ 'Permissions management of your chill installation' |trans }}

{% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig new file mode 100644 index 000000000..b766b6440 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig @@ -0,0 +1,18 @@ + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/admin_permissions.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_permissions.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Menu/admin_permissions.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_permissions.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/adminSection.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_section.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Menu/adminSection.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_section.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig index 398f84c31..56b2f31ee 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ #} {# - Layout for a vertical menu (like admin, export) to use with the + Layout for a vertical menu (like admin, export) to use with the layout ../layoutWithVerticalMenu.html.twig. #} @@ -25,13 +25,9 @@
  • {% block v_menu_title %}{% endblock %}
  • - {% for route in routes %} -
  • - {{ route.label|trans }} + {% for menu in menus %} +
  • {% endfor %} - \ No newline at end of file + diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index c97a658bb..be8a02d87 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -1,9 +1,66 @@ -{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} - -{% block title %}{{ 'user list'|trans|capitalize }}{% endblock %} +{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block admin_content -%} -

    {{ 'user list'|trans|capitalize }}

    + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entites_thead_tr %} + {{ 'crud.admin_user.index.is_active'|trans }} + {{ 'crud.admin_user.index.usernames'|trans }} + {{ 'crud.admin_user.index.mains'|trans }} +   + {% endblock %} + {% block table_entities_tbody %} + {% for entity in entities %} + + + {% if entity.isEnabled %} + + {% else %} + + {% endif %} + + + {{ entity.username }} +
    + {{ entity.label }} +
    + {{ entity.email }} + + + {% if entity.userJob %} + {{ entity.userJob.label|localize_translatable_string }} +
    + {% endif %} + {% if entity.mainScope %} + {{ entity.mainScope.name|localize_translatable_string }} +
    + {% endif %} + {% if entity.mainCenter %} + {{ entity.mainCenter.name }} + {% endif %} + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} + +{# @@ -51,3 +108,5 @@ {% endblock admin_content %} + +#} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php index 96a63ff75..b943ce8da 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php @@ -23,7 +23,7 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Chill\MainBundle\Security\Authorization\ChillExportVoter; /** - * + * * */ class AdminSectionMenuBuilder implements LocalMenuBuilderInterface @@ -33,30 +33,31 @@ class AdminSectionMenuBuilder implements LocalMenuBuilderInterface * @var AuthorizationCheckerInterface */ protected $authorizationChecker; - + public function __construct(AuthorizationCheckerInterface $authorizationChecker) { $this->authorizationChecker = $authorizationChecker; } - + public function buildMenu($menuId, MenuItem $menu, array $parameters) { // all the entries below must have ROLE_ADMIN permissions if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) { return; } - + $menu->addChild('Users and permissions', [ 'route' => 'chill_main_admin_permissions' ]) ->setExtras([ 'icons' => ['key'], - 'order' => 200 + 'order' => 200, + 'explain' => "Configure permissions for users" ]); } public static function getMenuIds(): array { - return [ 'admin_section' ]; + return [ 'admin_section', 'admin_index' ]; } } diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php new file mode 100644 index 000000000..76cae45f5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php @@ -0,0 +1,47 @@ +addChild('Permissions group list', [ + 'route' => 'admin_permissionsgroup' + ])->setExtras([ + 'order' => 300 + ]); + + $menu->addChild('List users', [ + 'route' => 'admin_user' + ])->setExtras(['order' => 400]); + + $menu->addChild('List users CRUD', [ + 'route' => 'chill_crud_admin_user_index' + ])->setExtras(['order' => 400]); + + $menu->addChild('List circles', [ + 'route' => 'admin_scope' + ])->setExtras(['order' => 200]); + + $menu->addChild('Center list', [ + 'route' => 'admin_center' + ])->setExtras(['order' => 100]); + + $menu->addChild('User jobs', [ + 'route' => 'chill_crud_admin_user_job_index' + ])->setExtras(['order' => 150]); + + } +} diff --git a/src/Bundle/ChillMainBundle/config/routes.yaml b/src/Bundle/ChillMainBundle/config/routes.yaml index 697ec8ec0..d75e91363 100644 --- a/src/Bundle/ChillMainBundle/config/routes.yaml +++ b/src/Bundle/ChillMainBundle/config/routes.yaml @@ -57,15 +57,15 @@ chill_main_homepage: path: /{_locale}/homepage controller: Chill\MainBundle\Controller\DefaultController::indexAction -chill_main_admin_central: - path: /{_locale}/admin - controller: Chill\MainBundle\Controller\AdminController::indexAction - options: - menus: - admin_permissions: - order: 0 - label: Main admin menu - +# chill_main_admin_central: +# path: /{_locale}/admin +# controller: Chill\MainBundle\Controller\AdminController::indexAction +# options: +# menus: +# admin_permissions: +# order: 0 +# label: Main admin menu +# chill_main_admin_permissions: path: /{_locale}/admin/permissions controller: Chill\MainBundle\Controller\AdminController::indexPermissionsAction diff --git a/src/Bundle/ChillMainBundle/config/routes/center.yaml b/src/Bundle/ChillMainBundle/config/routes/center.yaml index 69b635cad..9dc322bc1 100644 --- a/src/Bundle/ChillMainBundle/config/routes/center.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/center.yaml @@ -1,11 +1,6 @@ admin_center: path: / controller: Chill\MainBundle\Controller\CenterController::indexAction - options: - menus: - admin_permissions: - order: 100 - label: Center list admin_center_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_center_show: admin_center_new: path: /new controller: Chill\MainBundle\Controller\CenterController::newAction - options: - menus: - admin_permissions: - order: 101 - label: New center admin_center_create: path: /create diff --git a/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml b/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml index 42e3ea3c2..56f3a7569 100644 --- a/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml @@ -1,11 +1,6 @@ admin_permissionsgroup: path: / controller: Chill\MainBundle\Controller\PermissionsGroupController::indexAction - options: - menus: - admin_permissions: - order: 300 - label: Permissions group list admin_permissionsgroup_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_permissionsgroup_show: admin_permissionsgroup_new: path: /new controller: Chill\MainBundle\Controller\PermissionsGroupController::newAction - options: - menus: - admin_permissions: - order: 301 - label: New permission group admin_permissionsgroup_create: path: /create @@ -33,12 +23,12 @@ admin_permissionsgroup_update: path: /{id}/update controller: Chill\MainBundle\Controller\PermissionsGroupController::updateAction methods: [POST, PUT] - + admin_permissionsgroup_delete_role_scope: path: /{pgid}/delete_link_role_scope/{rsid} controller: Chill\MainBundle\Controller\PermissionsGroupController::deleteLinkRoleScopeAction methods: [DELETE] - + admin_permissionsgroup_add_role_scope: path: /{id}/add_link_role_scope controller: Chill\MainBundle\Controller\PermissionsGroupController::addLinkRoleScopeAction diff --git a/src/Bundle/ChillMainBundle/config/routes/scope.yaml b/src/Bundle/ChillMainBundle/config/routes/scope.yaml index cb27ec93b..c7ea32718 100644 --- a/src/Bundle/ChillMainBundle/config/routes/scope.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/scope.yaml @@ -1,11 +1,6 @@ admin_scope: path: / controller: Chill\MainBundle\Controller\ScopeController::indexAction - options: - menus: - admin_permissions: - order: 200 - label: List circles admin_scope_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_scope_show: admin_scope_new: path: /new controller: Chill\MainBundle\Controller\ScopeController::newAction - options: - menus: - admin_permissions: - order: 201 - label: New circle admin_scope_create: path: /create diff --git a/src/Bundle/ChillMainBundle/config/routes/user.yaml b/src/Bundle/ChillMainBundle/config/routes/user.yaml index 545496138..de62a570e 100644 --- a/src/Bundle/ChillMainBundle/config/routes/user.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/user.yaml @@ -1,11 +1,6 @@ admin_user: path: / controller: Chill\MainBundle\Controller\UserController::indexAction - options: - menus: - admin_permissions: - order: 400 - label: List users admin_user_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_user_show: admin_user_new: path: /new controller: Chill\MainBundle\Controller\UserController::newAction - options: - menus: - admin_permissions: - order: 401 - label: Add a new user admin_user_create: path: /create @@ -28,7 +18,7 @@ admin_user_create: admin_user_edit: path: /{id}/edit controller: Chill\MainBundle\Controller\UserController::editAction - + admin_user_edit_password: path: /{id}/edit_password controller: Chill\MainBundle\Controller\UserController::editPasswordAction @@ -37,17 +27,17 @@ admin_user_update: path: /{id}/update controller: Chill\MainBundle\Controller\UserController::updateAction methods: [POST, PUT] - + admin_user_update_password: path: /{id}/update_password controller: Chill\MainBundle\Controller\UserController::updatePasswordAction methods: [POST, PUT] - + admin_user_delete_group_center: path: /{uid}/delete_link_groupcenter/{gcid} controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction methods: [DELETE] - + admin_user_add_group_center: path: /{uid}/add_link_groupcenter controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml index 11a9bc274..a74755ffd 100644 --- a/src/Bundle/ChillMainBundle/config/services/controller.yaml +++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml @@ -29,10 +29,8 @@ services: tags: ['controller.service_arguments'] Chill\MainBundle\Controller\UserController: - arguments: - $logger: '@Psr\Log\LoggerInterface' - $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface' - tags: ['controller.service_arguments'] + autowire: true + autoconfigure: true Chill\MainBundle\Controller\NotificationController: arguments: diff --git a/src/Bundle/ChillMainBundle/config/services/menu.yaml b/src/Bundle/ChillMainBundle/config/services/menu.yaml index 91b481b51..cf31dccf1 100644 --- a/src/Bundle/ChillMainBundle/config/services/menu.yaml +++ b/src/Bundle/ChillMainBundle/config/services/menu.yaml @@ -1,17 +1,22 @@ services: + Chill\MainBundle\Routing\MenuBuilder\: + resource: '../../Routing/MenuBuilder' + autowire: true + autoconfigure: true + Chill\MainBundle\Routing\MenuBuilder\UserMenuBuilder: arguments: $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' tags: - { name: 'chill.menu_builder' } - + Chill\MainBundle\Routing\MenuBuilder\SectionMenuBuilder: arguments: $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface' tags: - { name: 'chill.menu_builder' } - + Chill\MainBundle\Routing\MenuBuilder\AdminSectionMenuBuilder: arguments: $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' From 72b1916da84eca6953e22476fd076854ac4e29bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Sep 2021 13:30:04 +0200 Subject: [PATCH 2/4] continue CRUD user --- .../CRUD/Controller/CRUDController.php | 15 +- .../Controller/UserController.php | 290 ++++++------------ .../ChillMainExtension.php | 2 + src/Bundle/ChillMainBundle/Form/UserType.php | 10 +- .../views/CRUD/_edit_content.html.twig | 18 +- .../views/CRUD/_new_content.html.twig | 8 +- .../Resources/views/User/edit.html.twig | 111 +++---- .../views/User/edit_password.html.twig | 28 +- .../Resources/views/User/index.html.twig | 57 +--- .../Resources/views/User/new.html.twig | 23 +- .../MenuBuilder/PermissionMenuBuilder.php | 4 - .../ChillMainBundle/config/routes/user.yaml | 88 +++--- 12 files changed, 231 insertions(+), 423 deletions(-) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index adc0c071d..d135cda39 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -118,7 +118,7 @@ class CRUDController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->onFormValid($entity, $form, $request); + $this->onFormValid($action, $entity, $form, $request); $em = $this->getDoctrine()->getManager(); $this->onPreRemove($action, $entity, $form, $request); @@ -607,7 +607,7 @@ class CRUDController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->onFormValid($entity, $form, $request); + $this->onFormValid($action, $entity, $form, $request); $em = $this->getDoctrine()->getManager(); $this->onPreFlush($action, $entity, $form, $request); @@ -706,7 +706,7 @@ class CRUDController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->onFormValid($entity, $form, $request); + $this->onFormValid($action, $entity, $form, $request); $em = $this->getDoctrine()->getManager(); $this->onPrePersist($action, $entity, $form, $request); @@ -716,7 +716,7 @@ class CRUDController extends AbstractController $this->onPreFlush($action, $entity, $form, $request); $em->flush(); $this->onPostFlush($action, $entity, $form, $request); - $this->getPaginatorFactory(); + $this->addFlash('success', $this->generateFormSuccessMessage($action, $entity)); $result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request); @@ -1084,12 +1084,7 @@ class CRUDController extends AbstractController return null; } - /** - * @param object $entity - * @param FormInterface $form - * @param Request $request - */ - protected function onFormValid(object $entity, FormInterface $form, Request $request) + protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request) { } diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 62a28b8d6..99de70747 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -4,8 +4,10 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\AbstractCRUDController; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Chill\MainBundle\Entity\User; @@ -13,10 +15,10 @@ use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Form\Type\ComposedGroupCenterType; use Chill\MainBundle\Form\UserPasswordType; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; +use Symfony\Component\Routing\Annotation\Route; +use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter; /** @@ -48,63 +50,38 @@ class UserController extends CRUDController * @param ValidatorInterface $validator */ public function __construct( - LoggerInterface $logger, + LoggerInterface $chillLogger, ValidatorInterface $validator, UserPasswordEncoderInterface $passwordEncoder ) { - $this->logger = $logger; + $this->logger = $chillLogger; $this->validator = $validator; $this->passwordEncoder = $passwordEncoder; } - /** - * Creates a new User entity. - * - */ - public function new(Request $request): Response + protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface { - $user = new User(); - $form = $this->createCreateForm($user); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); - - $user->setPassword($this->passwordEncoder - ->encodePassword($user, $form['plainPassword']->getData())); - - $em->persist($user); - $em->flush(); - - return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId()))); - } elseif ($form->isSubmitted() && !$form->isValid()){ - + // for "new", add special config + if ('new' === $action) { + return $this->createForm(UserType::class, $entity, array( + 'is_creation' => true + )); } - return $this->render('@ChillMain/User/new.html.twig', array( - 'entity' => $user, - 'form' => $form->createView(), - )); + // default behaviour + return parent::createFormFor($action, $entity, $formClass, $formOptions); } - /** - * Creates a form to create a User entity. - * - * @param User $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(User $entity) + protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request) { - $form = $this->createForm(UserType::class, $entity, array( - 'action' => $this->generateUrl('admin_user_create'), - 'method' => 'POST', - 'is_creation' => true - )); + // for "new", encode the password + if ('new' === $action) { + $entity->setPassword($this->passwordEncoder + ->encodePassword($entity, $form['plainPassword']->getData())); + } - $form->add('submit', SubmitType::class, array('label' => 'Create')); - - return $form; + // default behaviour + parent::onPrePersist($action, $entity, $form, $request); } /** @@ -126,55 +103,63 @@ class UserController extends CRUDController )); } - /** - * Displays a form to edit an existing User entity. - * - */ - public function editAction($id) + + protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []) { - $em = $this->getDoctrine()->getManager(); - - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); + // add mini-forms for edit action + if ("edit" === $action) { + return array_merge( + $defaultTemplateParameters, + [ + 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), + 'delete_groupcenter_form' => array_map( + function(\Symfony\Component\Form\Form $form) { + return $form->createView(); + }, + iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) + ) + ] + ); } - $editForm = $this->createEditForm($user); - - return $this->render('@ChillMain/User/edit.html.twig', array( - 'entity' => $user, - 'edit_form' => $editForm->createView(), - 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), - 'delete_groupcenter_form' => array_map( - function(\Symfony\Component\Form\Form $form) { - return $form->createView(); - - }, - iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) - )); + // default behaviour + return parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters); } /** * Displays a form to edit the user password. * + * @Route("/{_locale}/admin/user/{id}/edit_password", name="admin_user_edit_password") */ - public function editPasswordAction($id) + public function editPasswordAction(User $user, Request $request) { - $em = $this->getDoctrine()->getManager(); + $editForm = $this->createEditPasswordForm($user, $request); + $editForm->handleRequest($request); - $user = $em->getRepository('ChillMainBundle:User')->find($id); + if ($editForm->isSubmitted() && $editForm->isValid()) { + $password = $editForm->get('new_password')->getData(); - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); + // logging for prod + $this->logger->info('update password for an user', [ + 'by' => $this->getUser()->getUsername(), + 'user' => $user->getUsername() + ]); + + $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + + $this->getDoctrine()->getManager()->flush(); + $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!')); + + return $this->redirect( + $request->query->has('returnPath') ? $request->query->get('returnPath') : + $this->generateUrl('chill_crud_admin_user_edit', ['id' => $user->getId()]) + ); } - $editForm = $this->createEditPasswordForm($user); - - return $this->render('@ChillMain/User/edit_password.html.twig', array( + return $this->render('@ChillMain/User/edit_password.html.twig', [ 'entity' => $user, 'edit_form' => $editForm->createView() - )); + ]); } /** @@ -186,9 +171,6 @@ class UserController extends CRUDController private function createEditPasswordForm(User $user) { return $this->createForm(UserPasswordType::class, null, array( - 'action' => - $this->generateUrl('admin_user_update_password', array('id' => $user->getId())), - 'method' => 'PUT', 'user' => $user )) ->add('submit', SubmitType::class, array('label' => 'Change password')) @@ -196,7 +178,11 @@ class UserController extends CRUDController ; } - public function deleteLinkGroupCenterAction($uid, $gcid) + /** + * @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}", + * name="admin_user_delete_groupcenter") + */ + public function deleteLinkGroupCenterAction($uid, $gcid, Request $request): RedirectResponse { $em = $this->getDoctrine()->getManager(); @@ -218,7 +204,7 @@ class UserController extends CRUDController } catch (\RuntimeException $ex) { $this->addFlash('error', $this->get('translator')->trans($ex->getMessage())); - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid))); + return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', array('id' => $uid))); } $em->flush(); @@ -226,11 +212,15 @@ class UserController extends CRUDController $this->addFlash('success', $this->get('translator') ->trans('The permissions where removed.')); - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid))); + return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', array('id' => $uid))); } - public function addLinkGroupCenterAction(Request $request, $uid) + /** + * @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter", + * name="admin_user_add_groupcenter") + */ + public function addLinkGroupCenterAction(Request $request, $uid): RedirectResponse { $em = $this->getDoctrine()->getManager(); @@ -240,7 +230,7 @@ class UserController extends CRUDController throw $this->createNotFoundException('Unable to find User entity.'); } - $form = $this->createAddLinkGroupCenterForm($user); + $form = $this->createAddLinkGroupCenterForm($user, $request); $form->handleRequest($request); if ($form->isValid()) { @@ -254,8 +244,12 @@ class UserController extends CRUDController $this->addFlash('success', $this->get('translator')->trans('The ' . 'permissions have been successfully added to the user')); - return $this->redirect($this->generateUrl('admin_user_edit', - array('id' => $uid))); + $returnPathParams = $request->query->has('returnPath') ? + ['returnPath' => $request->query->get('returnPath')] : []; + + return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', + \array_merge(['id' => $uid], $returnPathParams))); + } else { foreach($this->validator->validate($user) as $error) $this->addFlash('error', $error->getMessage()); @@ -293,104 +287,6 @@ class UserController extends CRUDController return $groupCenterManaged; } - /** - * Creates a form to edit a User entity. - * - * @param User $user The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createEditForm(User $user) - { - $form = $this->createForm(UserType::class, $user, array( - 'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())), - 'method' => 'PUT', - )); - - $form->add('submit', SubmitType::class, array('label' => 'Update')); - - return $form; - } - - /** - * Edits an existing User entity. - * - */ - public function updateAction(Request $request, $id) - { - $em = $this->getDoctrine()->getManager(); - - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); - } - - $editForm = $this->createEditForm($user); - $editForm->handleRequest($request); - - if ($editForm->isValid()) { - $em->flush(); - - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); - } - - return $this->render('@ChillMain/User/edit.html.twig', array( - 'entity' => $user, - 'edit_form' => $editForm->createView(), - 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), - 'delete_groupcenter_form' => array_map( - function(\Symfony\Component\Form\Form $form) { - return $form->createView(); - - }, - iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) - )); - } - - /** - * Edits the user password - * - */ - public function updatePasswordAction(Request $request, $id) - { - $em = $this->getDoctrine()->getManager(); - - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); - } - - $editForm = $this->createEditPasswordForm($user); - $editForm->handleRequest($request); - - if ($editForm->isValid()) { - $password = $editForm->get('new_password')->getData(); - - // logging for prod - $this->logger->info('update password for an user', [ - 'by' => $this->getUser()->getUsername(), - 'user' => $user->getUsername() - ]); - - $user->setPassword($this->get('security.password_encoder') - ->encodePassword($user, $password)); - - $em->flush(); - - $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!')); - - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); - } - - return $this->render('@ChillMain/User/edit_password.html.twig', array( - 'entity' => $user, - 'edit_form' => $editForm->createView(), - )); - } - - /** * Creates a form to delete a link to a GroupCenter * @@ -398,11 +294,13 @@ class UserController extends CRUDController * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter) + private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request) { + $returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : []; + return $this->createFormBuilder() - ->setAction($this->generateUrl('admin_user_delete_group_center', - array('uid' => $user->getId(), 'gcid' => $groupCenter->getId()))) + ->setAction($this->generateUrl('admin_user_delete_groupcenter', + array_merge($returnPathParams, ['uid' => $user->getId(), 'gcid' => $groupCenter->getId()]))) ->setMethod('DELETE') ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() @@ -415,11 +313,13 @@ class UserController extends CRUDController * @param User $user * @return \Symfony\Component\Form\Form */ - private function createAddLinkGroupCenterForm(User $user) + private function createAddLinkGroupCenterForm(User $user, Request $request) { + $returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : []; + return $this->createFormBuilder() - ->setAction($this->generateUrl('admin_user_add_group_center', - array('uid' => $user->getId()))) + ->setAction($this->generateUrl('admin_user_add_groupcenter', + array_merge($returnPathParams, ['uid' => $user->getId()]))) ->setMethod('POST') ->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class) ->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter')) @@ -431,11 +331,11 @@ class UserController extends CRUDController * * @param User $user */ - private function getDeleteLinkGroupCenterByUser(User $user) + private function getDeleteLinkGroupCenterByUser(User $user, Request $request) { foreach ($user->getGroupCenters() as $groupCenter) { yield $groupCenter->getId() => $this - ->createDeleteLinkGroupCenterForm($user, $groupCenter); + ->createDeleteLinkGroupCenterForm($user, $groupCenter, $request); } } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 65b8ffdf6..e8c43e02d 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -307,9 +307,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, ], 'new' => [ 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/User/new.html.twig' ], 'edit' => [ 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/User/edit.html.twig' ] ] ] diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 09e2d1391..bf056cec5 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -47,9 +47,9 @@ class UserType extends AbstractType ]) ->add('label', TextType::class) ->add('mainCenter', EntityType::class, [ - 'label' => 'main center', + 'label' => 'Main center', 'required' => false, - 'placeholder' => 'choose a main center', + 'placeholder' => 'Choose a main center', 'class' => Center::class, 'query_builder' => function (EntityRepository $er) { $qb = $er->createQueryBuilder('c'); @@ -59,16 +59,16 @@ class UserType extends AbstractType } ]) ->add('mainScope', EntityType::class, [ - 'label' => 'Choose a main scope', + 'label' => 'Main scope', 'required' => false, - 'placeholder' => 'choose a main scope', + 'placeholder' => 'Choose a main scope', 'class' => Scope::class, 'choice_label' => function (Scope $c) { return $this->translatableStringHelper->localize($c->getName()); }, ]) ->add('userJob', EntityType::class, [ - 'label' => 'Choose a job', + 'label' => 'user job', 'required' => false, 'placeholder' => 'choose a job', 'class' => UserJob::class, diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig index cc2673960..5e338d5fd 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig @@ -1,17 +1,22 @@ +{% set formId = crudMainFormId|default('crud_main_form') %}
    {% block crud_content_header %}

    {{ ('crud.'~crud_name~'.title_edit')|trans }}

    {% endblock crud_content_header %} {% block crud_content_form %} - {{ form_start(form) }} - + {{ form_start(form, { 'attr' : { 'id': formId } } ) }} + {% block crud_content_form_rows %} {% for f in form %} {{ form_row(f) }} {% endfor %} {% endblock crud_content_form_rows %} + {{ form_end(form) }} + + {% block crud_content_after_form %}{% endblock %} + {% block crud_content_form_actions %}
      {% block content_form_actions_back %} @@ -30,7 +35,7 @@ {% endif %} {% endif %} - {% endblock content_form_actions_delete %} + {% endblock content_form_actions_delete %} {% block content_form_actions_view %} {% if chill_crud_action_exists(crud_name, 'view') %} {% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %} @@ -39,17 +44,17 @@ {% endif %} {% endif %} - {% endblock content_form_actions_view %} + {% endblock content_form_actions_view %} {% block content_form_actions_save_and_close %}
    • -
    • {% endblock %} {% block content_form_actions_save_and_show %}
    • -
    • @@ -58,6 +63,5 @@
    {% endblock %} - {{ form_end(form) }} {% endblock %}
    diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig index ff5fe7263..4c2003617 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig @@ -5,14 +5,16 @@ {% block crud_content_form %} {{ form_start(form) }} - + {% block crud_content_form_rows %} {% for f in form %}{% if f.vars.name != 'submit' %} {{ form_row(f) }} {% endif %}{% endfor %} {% endblock crud_content_form_rows %} - {% block crud_content_form_actions %} + {% block crud_content_after_form %}{% endblock %} + + {% block crud_content_form_actions %}
      {% block content_form_actions_back %}
    • @@ -20,7 +22,7 @@ {{ 'Cancel'|trans }}
    • - {% endblock %} + {% endblock %} {% block content_form_actions_save_and_close %}
    - - - - - - - - - {% for groupcenter in entity.groupcenters %} - - + + + {% endfor %} + +
    {{ 'Permission group'|trans }}{{ 'Center'|trans }} 
    + {% if entity.groupcenters|length > 0 %} + + + + + + + + + + {% for groupcenter in entity.groupcenters %} + + - + - - - {% endfor %} - -
    {{ 'Permission group'|trans }}{{ 'Center'|trans }} 
    {{ groupcenter.permissionsgroup.name }} - + {{ groupcenter.center.name }} - - {{ form_start(delete_groupcenter_form[groupcenter.id]) }} - {{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }} - {{ form_rest(delete_groupcenter_form[groupcenter.id]) }} - {{ form_end(delete_groupcenter_form[groupcenter.id]) }} -
    - {% else %} -

    {{ 'Any permissions granted to this user'|trans }}.

    - {% endif %} - -

    {{ 'Grant new permissions'|trans }}

    - - {{ form_start(add_groupcenter_form) }} - {{ form_row(add_groupcenter_form.composed_groupcenter.center) }} - {{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }} - {{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }} +
    + {{ form_start(delete_groupcenter_form[groupcenter.id]) }} + {{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }} + {{ form_rest(delete_groupcenter_form[groupcenter.id]) }} + {{ form_end(delete_groupcenter_form[groupcenter.id]) }} +
    + {% else %} +

    {{ 'Any permissions granted to this user'|trans }}.

    + {% endif %} - {{ form_end(add_groupcenter_form) }} - - +

    {{ 'Grant new permissions'|trans }}

    + + {{ form_start(add_groupcenter_form) }} + {{ form_row(add_groupcenter_form.composed_groupcenter.center) }} + {{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }} + {{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }} + + {{ form_end(add_groupcenter_form) }} + + {% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig index 3280b3679..c26f6cf24 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig @@ -1,4 +1,4 @@ -{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} +{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block title %}{{ 'Edit password for %username%'|trans( { '%username%': entity.username } ) }}{% endblock %} @@ -7,19 +7,17 @@ {{ form_start(edit_form) }} {{ form_row(edit_form.new_password) }} - {{ form_widget(edit_form.submit, { 'attr': { 'class': 'btn btn-chill-orange' } } ) }} + + + {{ form_end(edit_form) }} - - {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index be8a02d87..1f96cf4cb 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -41,14 +41,14 @@ @@ -59,54 +59,3 @@ {% endblock %} {% endembed %} {% endblock %} - -{# - - - - - - - - - - {% for entity in entities %} - - - - - {% endfor %} - -
    {{ 'Username'|trans|capitalize }}{{ 'Actions'|trans|capitalize }}
    {{ entity.username }} - -
    - - - -{% endblock admin_content %} - -#} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig index b2234ef30..f0757b25d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig @@ -1,22 +1,7 @@ -{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} - -{% block title %}{{ 'User creation'|trans }}{% endblock %} +{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block admin_content -%} -

    {{ 'User creation'|trans }}

    - - {{ form_start(form) }} - {{ form_row(form.username) }} - {{ form_row(form.email) }} - {{ form_row(form.plainPassword) }} - {{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-chill-blue' } }) }} - {{ form_end(form) }} - - + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php index 76cae45f5..64c9f857a 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php @@ -24,10 +24,6 @@ class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilde ]); $menu->addChild('List users', [ - 'route' => 'admin_user' - ])->setExtras(['order' => 400]); - - $menu->addChild('List users CRUD', [ 'route' => 'chill_crud_admin_user_index' ])->setExtras(['order' => 400]); diff --git a/src/Bundle/ChillMainBundle/config/routes/user.yaml b/src/Bundle/ChillMainBundle/config/routes/user.yaml index de62a570e..aee1393f5 100644 --- a/src/Bundle/ChillMainBundle/config/routes/user.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/user.yaml @@ -1,44 +1,44 @@ -admin_user: - path: / - controller: Chill\MainBundle\Controller\UserController::indexAction - -admin_user_show: - path: /{id}/show - controller: Chill\MainBundle\Controller\UserController::showAction - -admin_user_new: - path: /new - controller: Chill\MainBundle\Controller\UserController::newAction - -admin_user_create: - path: /create - controller: Chill\MainBundle\Controller\UserController::createAction - methods: POST - -admin_user_edit: - path: /{id}/edit - controller: Chill\MainBundle\Controller\UserController::editAction - -admin_user_edit_password: - path: /{id}/edit_password - controller: Chill\MainBundle\Controller\UserController::editPasswordAction - -admin_user_update: - path: /{id}/update - controller: Chill\MainBundle\Controller\UserController::updateAction - methods: [POST, PUT] - -admin_user_update_password: - path: /{id}/update_password - controller: Chill\MainBundle\Controller\UserController::updatePasswordAction - methods: [POST, PUT] - -admin_user_delete_group_center: - path: /{uid}/delete_link_groupcenter/{gcid} - controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction - methods: [DELETE] - -admin_user_add_group_center: - path: /{uid}/add_link_groupcenter - controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction - methods: [POST] +#admin_user: +# path: / +# controller: Chill\MainBundle\Controller\UserController::indexAction +# +#admin_user_show: +# path: /{id}/show +# controller: Chill\MainBundle\Controller\UserController::showAction +# +#admin_user_new: +# path: /new +# controller: Chill\MainBundle\Controller\UserController::newAction +# +#admin_user_create: +# path: /create +# controller: Chill\MainBundle\Controller\UserController::createAction +# methods: POST +# +#admin_user_edit: +# path: /{id}/edit +# controller: Chill\MainBundle\Controller\UserController::editAction +# +#admin_user_edit_password: +# path: /{id}/edit_password +# controller: Chill\MainBundle\Controller\UserController::editPasswordAction +# +#admin_user_update: +# path: /{id}/update +# controller: Chill\MainBundle\Controller\UserController::updateAction +# methods: [POST, PUT] +# +#admin_user_update_password: +# path: /{id}/update_password +# controller: Chill\MainBundle\Controller\UserController::updatePasswordAction +# methods: [POST, PUT] +# +#admin_user_delete_group_center: +# path: /{uid}/delete_link_groupcenter/{gcid} +# controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction +# methods: [DELETE] +# +#admin_user_add_group_center: +# path: /{uid}/add_link_groupcenter +# controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction +# methods: [POST] From 430177f0c754f0f4d691959090ec6988bf5cc178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Sep 2021 14:09:51 +0200 Subject: [PATCH 3/4] some finalisation for admin user --- .../Controller/UserController.php | 20 ++------- .../ChillMainExtension.php | 2 +- .../Resources/views/User/edit.html.twig | 1 + .../Resources/views/User/index.html.twig | 5 +-- .../MenuBuilder/PermissionMenuBuilder.php | 2 +- src/Bundle/ChillMainBundle/config/routes.yaml | 4 -- .../ChillMainBundle/config/routes/user.yaml | 44 ------------------- .../translations/messages.fr.yml | 12 ++++- 8 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/config/routes/user.yaml diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 99de70747..735546eba 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -4,6 +4,7 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\AbstractCRUDController; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Pagination\PaginatorInterface; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Form\FormInterface; @@ -84,26 +85,13 @@ class UserController extends CRUDController parent::onPrePersist($action, $entity, $form, $request); } - /** - * Finds and displays a User entity. - * - */ - public function showAction($id) + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - $em = $this->getDoctrine()->getManager(); + $query->addOrderBy('e.usernameCanonical', 'ASC'); - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); - } - - return $this->render('@ChillMain/User/show.html.twig', array( - 'entity' => $user, - )); + return parent::orderQuery($action, $query, $request, $paginator); } - protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []) { // add mini-forms for edit action diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index e8c43e02d..f196b8a2b 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -297,7 +297,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'class' => User::class, 'controller' => UserController::class, 'name' => 'admin_user', - 'base_path' => '/admin/main/user2', + 'base_path' => '/admin/main/user', 'base_role' => 'ROLE_ADMIN', 'form_class' => UserType::class, 'actions' => [ diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig index 38889cf72..0ea1d529c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig @@ -51,5 +51,6 @@ {{ form_end(add_groupcenter_form) }} {% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index 1f96cf4cb..c57d9ed5f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -2,7 +2,7 @@ {% block admin_content -%} {% embed '@ChillMain/CRUD/_index.html.twig' %} - {% block table_entites_thead_tr %} + {% block table_entities_thead_tr %} {{ 'crud.admin_user.index.is_active'|trans }} {{ 'crud.admin_user.index.usernames'|trans }} {{ 'crud.admin_user.index.mains'|trans }} @@ -44,7 +44,7 @@
  • - +
  • {% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
  • @@ -53,7 +53,6 @@ {% endif %} - {% endfor %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php index 64c9f857a..470930820 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php @@ -23,7 +23,7 @@ class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilde 'order' => 300 ]); - $menu->addChild('List users', [ + $menu->addChild('crud.admin_user.index.title', [ 'route' => 'chill_crud_admin_user_index' ])->setExtras(['order' => 400]); diff --git a/src/Bundle/ChillMainBundle/config/routes.yaml b/src/Bundle/ChillMainBundle/config/routes.yaml index d75e91363..9a155f6e6 100644 --- a/src/Bundle/ChillMainBundle/config/routes.yaml +++ b/src/Bundle/ChillMainBundle/config/routes.yaml @@ -6,10 +6,6 @@ chill_main_admin_permissionsgroup: resource: "@ChillMainBundle/config/routes/permissionsgroup.yaml" prefix: "{_locale}/admin/permissionsgroup" -chill_main_admin_user: - resource: "@ChillMainBundle/config/routes/user.yaml" - prefix: "{_locale}/admin/user" - chill_main_admin_scope: resource: "@ChillMainBundle/config/routes/scope.yaml" prefix: "{_locale}/admin/scope" diff --git a/src/Bundle/ChillMainBundle/config/routes/user.yaml b/src/Bundle/ChillMainBundle/config/routes/user.yaml deleted file mode 100644 index aee1393f5..000000000 --- a/src/Bundle/ChillMainBundle/config/routes/user.yaml +++ /dev/null @@ -1,44 +0,0 @@ -#admin_user: -# path: / -# controller: Chill\MainBundle\Controller\UserController::indexAction -# -#admin_user_show: -# path: /{id}/show -# controller: Chill\MainBundle\Controller\UserController::showAction -# -#admin_user_new: -# path: /new -# controller: Chill\MainBundle\Controller\UserController::newAction -# -#admin_user_create: -# path: /create -# controller: Chill\MainBundle\Controller\UserController::createAction -# methods: POST -# -#admin_user_edit: -# path: /{id}/edit -# controller: Chill\MainBundle\Controller\UserController::editAction -# -#admin_user_edit_password: -# path: /{id}/edit_password -# controller: Chill\MainBundle\Controller\UserController::editPasswordAction -# -#admin_user_update: -# path: /{id}/update -# controller: Chill\MainBundle\Controller\UserController::updateAction -# methods: [POST, PUT] -# -#admin_user_update_password: -# path: /{id}/update_password -# controller: Chill\MainBundle\Controller\UserController::updatePasswordAction -# methods: [POST, PUT] -# -#admin_user_delete_group_center: -# path: /{uid}/delete_link_groupcenter/{gcid} -# controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction -# methods: [DELETE] -# -#admin_user_add_group_center: -# path: /{uid}/add_link_groupcenter -# controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction -# methods: [POST] diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index f799f20b6..d99a565c1 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -143,10 +143,8 @@ The role '%role%' has been removed: Le rôle "%role%" a été enlevé de ce grou The role '%role%' on circle '%scope%' has been removed: Le rôle "%role%" sur le cercle "%scope%" a été enlevé de ce groupe de permission #admin section for users -List users: Liste des utilisateurs user list: Liste des utilisateurs User edit: Modification d'un utilisateur -User creation: Créer un utilisateur User'status: Statut de l'utilisateur Disabled, the user is not allowed to login: Désactivé, l'utilisateur n'est pas autorisé à se connecter Enabled, the user is active: Actif, l'utilisateur peut se connecter @@ -281,6 +279,16 @@ crud: success: Les données ont été enregistrées view: link_duplicate: Dupliquer + ## admin for users + admin_user: + index: + title: Utilisateurs + add_new: "Créer" + is_active: "Actif ?" + usernames: "Identifiants" + mains: "Champs principaux" + title_new: "Nouvel utilisateur" + title_edit: Modifier un utilisateur No entities: Aucun élément CHILL_FOO_SEE: Voir un élément From 1d4b1d852f5404cf3d87c813163866f18db30c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Sep 2021 10:35:28 +0200 Subject: [PATCH 4/4] improve layout for admin --- .../Repository/UserJobRepository.php | 49 +++++++++++++++++++ .../Resources/views/Admin/layout.html.twig | 25 +--------- .../Resources/views/Layout/_header.html.twig | 43 +++++----------- .../Resources/views/layout.html.twig | 22 --------- .../views/layoutWithVerticalMenu.html.twig | 23 --------- 5 files changed, 63 insertions(+), 99 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Repository/UserJobRepository.php diff --git a/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php b/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php new file mode 100644 index 000000000..f19952c31 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php @@ -0,0 +1,49 @@ +repository = $em->getRepository(UserJob::class); + } + + public function find($id): ?UserJob + { + return $this->repository->find($id); + } + + /** + * @return array|UserJob[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return array|UserJob[]|object[] + */ + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria) + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName() + { + return UserJob::class; + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig index c3331b08b..6efca3256 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig @@ -1,26 +1,3 @@ -{# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, - / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} - -{# - The layout of the admin section. All the page / template of the admin section must use this - layout. -#} - {% extends "@ChillMain/layout.html.twig" %} {% block navigation_search_bar %}{% endblock %} @@ -38,4 +15,4 @@ {% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig index 605be2da6..ab823ff2e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig @@ -1,20 +1,3 @@ -{# - * Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, - * / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#}
  • {% else %}