143 lines
4.8 KiB
PHP
143 lines
4.8 KiB
PHP
<?php
|
|
namespace App\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
class GroupType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder->add('submit',
|
|
SubmitType::class,[
|
|
"label" => "Valider",
|
|
"attr" => ["class" => "btn btn-success"],
|
|
]
|
|
);
|
|
|
|
if($options["access"]=="admin") {
|
|
$builder->add('isworkgroup',
|
|
ChoiceType::class,[
|
|
"label" =>"Groupe de Travail",
|
|
"choices" => ["non" => "0","oui" => "1"],
|
|
]
|
|
);
|
|
}
|
|
|
|
if($options["access"]=="admin" || $options["mode"] == "update") {
|
|
$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" => 'username',
|
|
"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($options["access"]=="admin") {
|
|
$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,array(
|
|
"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($options["appMasteridentity"]=="LDAP"&&$options["access"]=="admin")
|
|
{
|
|
$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($options["appMasteridentity"]=="SSO"&&$options["access"]=="admin")
|
|
{
|
|
$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(array(
|
|
'data_class' => 'App\Entity\Group',
|
|
'mode' => "string",
|
|
'access' => "string",
|
|
'appMasteridentity' => "string",
|
|
));
|
|
}
|
|
}
|