136 lines
4.5 KiB
PHP
136 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
|
|
|
class GroupType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder->add('submit',
|
|
SubmitType::class, [
|
|
'label' => 'Valider',
|
|
'attr' => ['class' => 'btn btn-success'],
|
|
]
|
|
);
|
|
|
|
if ('admin' == $options['access']) {
|
|
$builder->add('isworkgroup',
|
|
ChoiceType::class, [
|
|
'label' => 'Groupe de Travail',
|
|
'choices' => ['non' => '0', 'oui' => '1'],
|
|
]
|
|
);
|
|
}
|
|
|
|
if ('admin' == $options['access'] || 'update' == $options['mode']) {
|
|
$builder->add('owner',
|
|
Select2EntityType::class, [
|
|
'label' => 'Propriétaire',
|
|
'required' => false,
|
|
'multiple' => false,
|
|
'remote_route' => 'app_'.$options['access'].'_user_selectlist',
|
|
'class' => 'App\Entity\User',
|
|
'primary_key' => 'id',
|
|
'text_property' => 'fullname',
|
|
'minimum_input_length' => 2,
|
|
'page_limit' => 10,
|
|
'allow_clear' => true,
|
|
'delay' => 250,
|
|
'cache' => false,
|
|
'cache_timeout' => 60000, // if 'cache' is true
|
|
'language' => 'fr',
|
|
'placeholder' => 'Selectionner un propriétaire',
|
|
]
|
|
);
|
|
}
|
|
|
|
if ('admin' == $options['access']) {
|
|
$builder->add('email',
|
|
EmailType::class, [
|
|
'label' => 'Mail',
|
|
'required' => false,
|
|
]
|
|
);
|
|
}
|
|
|
|
$builder->add('description',
|
|
TextareaType::class, [
|
|
'label' => 'Description',
|
|
'required' => false,
|
|
'attr' => ['rows' => '4'],
|
|
]
|
|
);
|
|
|
|
$builder->add('label',
|
|
TextType::class, [
|
|
'label' => 'Label',
|
|
]
|
|
);
|
|
|
|
$builder->add('isopen',
|
|
ChoiceType::class, [
|
|
'label' => 'Groupe Ouvert (inscription possible par les utilisateurs)',
|
|
'choices' => ['non' => '0', 'oui' => '1'],
|
|
]
|
|
);
|
|
|
|
// Si masteridentity = LDAP alors on demande le filtre des utilisateurs qui appartiennent à ce groupe
|
|
if ('LDAP' == $options['appMasteridentity'] && 'admin' == $options['access']) {
|
|
$builder->add('fgassoc',
|
|
ChoiceType::class, [
|
|
'mapped' => false,
|
|
'label' => "Groupe associé à l'annuaire ?",
|
|
'choices' => ['non' => '0', 'oui' => '1'],
|
|
]
|
|
);
|
|
|
|
$builder->add('ldapfilter',
|
|
TextType::class, [
|
|
'label' => 'Filtre LDAP des utilisateurs',
|
|
'label_attr' => ['id' => 'label_group_ldapfilter'],
|
|
'required' => false,
|
|
]
|
|
);
|
|
}
|
|
|
|
if ('SSO' == $options['appMasteridentity'] && 'admin' == $options['access']) {
|
|
$builder->add('fgassoc',
|
|
ChoiceType::class, [
|
|
'mapped' => false,
|
|
'label' => 'Groupe associé à des attributs SSO ?',
|
|
'choices' => ['non' => '0', 'oui' => '1'],
|
|
]
|
|
);
|
|
|
|
$builder->add('attributes',
|
|
TextareaType::class, [
|
|
'label' => 'Attributs SSO des utilisateurs',
|
|
'label_attr' => ['id' => 'label_group_attributes'],
|
|
'required' => false,
|
|
'attr' => ['rows' => 10],
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => 'App\Entity\Group',
|
|
'mode' => 'string',
|
|
'access' => 'string',
|
|
'appMasteridentity' => 'string',
|
|
]);
|
|
}
|
|
}
|