mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-29 05:26:13 +00:00
[admin] show/hide the user permissions group depending on config
This commit is contained in:
parent
a4210dd2c7
commit
da2c88c026
@ -109,6 +109,7 @@ class UserController extends CRUDController
|
|||||||
|
|
||||||
return $this->render('@ChillMain/User/edit.html.twig', [
|
return $this->render('@ChillMain/User/edit.html.twig', [
|
||||||
'entity' => $user,
|
'entity' => $user,
|
||||||
|
'access_permissions_group_list' => $this->parameterBag->get('chill_main.access_permissions_group_list'),
|
||||||
'edit_form' => $this->createEditForm($user)->createView(),
|
'edit_form' => $this->createEditForm($user)->createView(),
|
||||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user, $request)->createView(),
|
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user, $request)->createView(),
|
||||||
'delete_groupcenter_form' => array_map(
|
'delete_groupcenter_form' => array_map(
|
||||||
@ -158,6 +159,74 @@ class UserController extends CRUDController
|
|||||||
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', ['id' => $uid]));
|
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', ['id' => $uid]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit(Request $request, $id): Response
|
||||||
|
{
|
||||||
|
$action = 'edit';
|
||||||
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
|
|
||||||
|
if (null === $entity) {
|
||||||
|
throw $this->createNotFoundException(
|
||||||
|
sprintf(
|
||||||
|
'The %s with id %s is not found',
|
||||||
|
$this->getCrudName(),
|
||||||
|
$id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->checkACL($action, $entity);
|
||||||
|
|
||||||
|
if ($response instanceof Response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->onPostCheckACL($action, $request, $entity);
|
||||||
|
|
||||||
|
if ($response instanceof Response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = $this->createFormFor($action, $entity);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->onFormValid($action, $entity, $form, $request);
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$this->onPreFlush($action, $entity, $form, $request);
|
||||||
|
$em->flush();
|
||||||
|
$this->onPostFlush($action, $entity, $form, $request);
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->generateFormSuccessMessage($action, $entity));
|
||||||
|
|
||||||
|
$result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request);
|
||||||
|
|
||||||
|
if ($result instanceof Response) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($form->isSubmitted()) {
|
||||||
|
$this->addFlash('error', $this->generateFormErrorMessage($action, $form));
|
||||||
|
}
|
||||||
|
|
||||||
|
$defaultTemplateParameters = [
|
||||||
|
'form' => $form->createView(),
|
||||||
|
'entity' => $entity,
|
||||||
|
'crud_name' => $this->getCrudName(),
|
||||||
|
'access_permissions_group_list' => $this->parameterBag->get('chill_main.access_permissions_group_list'),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
$this->getTemplateFor($action, $entity, $request),
|
||||||
|
$this->generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit the user current location.
|
* Displays a form to edit the user current location.
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
{% block admin_content -%}
|
{% block admin_content -%}
|
||||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||||
{% block crud_content_after_form %}
|
{% block crud_content_after_form %}
|
||||||
|
{% if access_permissions_group_list %}
|
||||||
<h2>{{ 'Permissions granted'|trans }}</h2>
|
<h2>{{ 'Permissions granted'|trans }}</h2>
|
||||||
|
|
||||||
{% if entity.groupcenters|length > 0 %}
|
{% if entity.groupcenters|length > 0 %}
|
||||||
@ -49,8 +50,9 @@
|
|||||||
{{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }}
|
{{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }}
|
||||||
|
|
||||||
{{ form_end(add_groupcenter_form) }}
|
{{ form_end(add_groupcenter_form) }}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user