first commit symfony 6
This commit is contained in:
189
src/Form/ConfigType.php
Normal file
189
src/Form/ConfigType.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?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\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
class ConfigType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('id',
|
||||
TextType::class,
|
||||
array("label" =>"Clé",
|
||||
'disabled' => true));
|
||||
|
||||
switch($options["type"]) {
|
||||
case "string":
|
||||
$builder->add('value',
|
||||
TextType::class,
|
||||
array("label" => "Valeur",
|
||||
'required' => ($options["required"]==0?false:true)));
|
||||
break;
|
||||
|
||||
case "boolean":
|
||||
$choices=["oui" => "1","non" => "0"];
|
||||
$builder->add("value", ChoiceType::class,
|
||||
array("label" =>"Valeur",
|
||||
'required' => ($options["required"]==0?false:true),
|
||||
"choices" => $choices));
|
||||
break;
|
||||
|
||||
case "integer":
|
||||
$builder->add("value",
|
||||
IntegerType::class, [
|
||||
"label" =>"Valeur",
|
||||
"attr" => ["min" => "0"],
|
||||
"required" => ($options["required"]==0?false:true),
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case "pourcentage":
|
||||
$builder->add("value",
|
||||
IntegerType::class, [
|
||||
"label" =>"Valeur",
|
||||
"attr" => ["min" => "0", "max"=>"100"],
|
||||
"required" => ($options["required"]==0?false:true),
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case "font":
|
||||
$choices=[
|
||||
"ABeeZee-Regular" => "ABeeZee-Regular",
|
||||
"Acme-Regular" => "Acme-Regular",
|
||||
"AlfaSlabOne-Regular" => "AlfaSlabOne-Regular",
|
||||
"Anton-Regular" => "Anton-Regular",
|
||||
"Baloo-Regular" => "Baloo-Regular",
|
||||
"CarterOne-Regular" => "CarterOne-Regular",
|
||||
"Chewy-Regular" => "Chewy-Regular",
|
||||
"Courgette-Regular" => "Courgette-Regular",
|
||||
"FredokaOne-Regular" => "FredokaOne-Regular",
|
||||
"Grandstander" => "Grandstander",
|
||||
"Helvetica" => "Helvetica",
|
||||
"Justanotherhand-Regular" => "Justanotherhand-Regular",
|
||||
"Lato-Regular" => "Lato-Regular",
|
||||
"LexendDeca-Regular" => "LexendDeca-Regular",
|
||||
"LuckiestGuy-Regular" => "LuckiestGuy-Regular",
|
||||
"Overpass-Black" => "Overpass-Black",
|
||||
"PassionOne" => "PassionOne",
|
||||
"Peacesans" => "Peacesans",
|
||||
"Redressed" => "Redressed",
|
||||
"Righteous-Regular" => "Righteous-Regular",
|
||||
"Roboto-Regular" => "Roboto-Regular",
|
||||
"RubikMonoOne-Regular" => "RubikMonoOne-Regular",
|
||||
"SigmarOne-Regular" => "SigmarOne-Regular",
|
||||
"Signika-Regular" => "Signika-Regular",
|
||||
"Teko-Bold" => "Teko-Bold",
|
||||
"Theboldfont" => "Theboldfont",
|
||||
"Viga-Regular" => "Viga-Regular",
|
||||
];
|
||||
|
||||
$builder->add("value", ChoiceType::class,
|
||||
array("label" =>"Valeur",
|
||||
'required' => ($options["required"]==0?false:true),
|
||||
"choices" => $choices));
|
||||
break;
|
||||
|
||||
case "editor":
|
||||
$builder->add('value',
|
||||
CKEditorType::class,[
|
||||
"required" => ($options["required"]==0?false:true),
|
||||
"config_name" => "full_config",
|
||||
"config" => [
|
||||
'height' => 600,
|
||||
'filebrowserUploadRoute' => 'app_ckeditor_upload',
|
||||
]
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
|
||||
case "role":
|
||||
$choices=array(
|
||||
"NO_BODY" => "NO_BODY",
|
||||
"ROLE_USER" => "ROLE_USER",
|
||||
"ROLE_MASTER" => "ROLE_MASTER",
|
||||
"ROLE_MODO" => "ROLE_MODO",
|
||||
);
|
||||
|
||||
$builder->add("value", ChoiceType::class,
|
||||
array("label" =>"Valeur",
|
||||
"label_attr" => array("style" => 'margin-top:15px;'),
|
||||
"attr" => array("class" => "form-control"),
|
||||
'required' => ($options["required"]==0?false:true),
|
||||
"choices" => $choices));
|
||||
break;
|
||||
|
||||
|
||||
case "scopeannu":
|
||||
$choices=array(
|
||||
"ALL" => "ALL",
|
||||
"SAME_NIVEAU01" => "SAME_NIVEAU01",
|
||||
"SAME_NIVEAU02" => "SAME_NIVEAU02",
|
||||
);
|
||||
|
||||
$builder->add("value", ChoiceType::class,
|
||||
array("label" =>"Valeur",
|
||||
"label_attr" => array("style" => 'margin-top:15px;'),
|
||||
"attr" => array("class" => "form-control"),
|
||||
'required' => ($options["required"]==0?false:true),
|
||||
"choices" => $choices));
|
||||
break;
|
||||
|
||||
case "logo":
|
||||
$builder->add('value',HiddenType::class);
|
||||
break;
|
||||
|
||||
case "header":
|
||||
$builder->add('value',HiddenType::class);
|
||||
break;
|
||||
|
||||
case "image":
|
||||
$builder->add('value',HiddenType::class);
|
||||
break;
|
||||
|
||||
case "color":
|
||||
$builder->add('value',
|
||||
TextType::class,
|
||||
array("label" => "Valeur",
|
||||
"attr" => ["class" => "pick-a-color"],
|
||||
'required' => ($options["required"]==0?false:true)));
|
||||
break;
|
||||
}
|
||||
|
||||
$builder->add('help',
|
||||
TextareaType::class,
|
||||
array("label" =>"Aide",
|
||||
"attr" => ["style" => "height: 200px;"],
|
||||
'required' => false,
|
||||
'disabled' => true));
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Config',
|
||||
'mode' => "string",
|
||||
'id' => "string",
|
||||
'type' => "string",
|
||||
'required' => "string",
|
||||
));
|
||||
}
|
||||
}
|
66
src/Form/CronType.php
Normal file
66
src/Form/CronType.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
|
||||
class CronType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit', SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => array("class" => "btn btn-success")
|
||||
])
|
||||
|
||||
->add('command', TextType::class, [
|
||||
'label' => 'Commande',
|
||||
"disabled" => true,
|
||||
])
|
||||
|
||||
->add('jsonargument', TextType::class, [
|
||||
'label' => 'Argument Commande au format json',
|
||||
"disabled" => true,
|
||||
])
|
||||
|
||||
->add('statut', ChoiceType::class, [
|
||||
'label' => "Statut",
|
||||
'choices' => array("Désactivé" => -1,"KO" => "0","OK" => "1")
|
||||
])
|
||||
|
||||
->add('repeatinterval', IntegerType::class, [
|
||||
'label' => "Interval en seconde entre deux éxécution"
|
||||
])
|
||||
|
||||
->add('nextexecdate', DatetimeType::class, [
|
||||
'label' => "Prochaine exécution",
|
||||
'widget' => 'single_text',
|
||||
"html5"=>true,
|
||||
'input_format' => "d/m/Y H:i"
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OptionsResolver $resolver
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'App\Entity\Cron',
|
||||
'mode' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
142
src/Form/GroupType.php
Normal file
142
src/Form/GroupType.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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",
|
||||
));
|
||||
}
|
||||
}
|
37
src/Form/LoginType.php
Normal file
37
src/Form/LoginType.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
|
||||
class LoginType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success mt-4 float-end"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('username',
|
||||
TextType::class,[
|
||||
"label" =>"Login",
|
||||
"attr" => ["autocomplete" => "new-password"]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('password',
|
||||
PasswordType::class, [
|
||||
"always_empty" => true,
|
||||
"label" => "Mot de Passe",
|
||||
"attr" => ["autocomplete" => "new-password"]
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
}
|
81
src/Form/Niveau01Type.php
Normal file
81
src/Form/Niveau01Type.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class Niveau01Type extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('label',
|
||||
TextType::class, [
|
||||
"label" =>"Label",
|
||||
]
|
||||
);
|
||||
|
||||
// Si masteridentity = LDAP alors on demande le filtre des utilisateurs qui appartiennent à ce groupe
|
||||
if($options["appMasteridentity"]=="LDAP"||$options["appSynchro"]=="LDAP2NINE")
|
||||
{
|
||||
$builder->add("fgassocldap",
|
||||
ChoiceType::class,[
|
||||
"mapped" => false,
|
||||
"label" => $options["appNiveau01label"]." associé à l'annuaire ?",
|
||||
"choices" => ["non" => "0","oui" => "1"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('ldapfilter',
|
||||
TextType::class, [
|
||||
"label" => "Filtre LDAP du ".$options["appNiveau01label"],
|
||||
"label_attr" => ["id" => "label_group_ldapfilter"],
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if($options["appMasteridentity"]=="SSO")
|
||||
{
|
||||
$builder->add("fgassocsso",
|
||||
ChoiceType::class,[
|
||||
"mapped" => false,
|
||||
"label" => $options["appNiveau01label"]." associé à des attributs SSO ?",
|
||||
"choices" => ["non" => "0","oui" => "1"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('attributes',
|
||||
TextareaType::class, [
|
||||
"label" => "Attributs SSO du ".$options["appNiveau01label"],
|
||||
"label_attr" => ["id" => "label_group_attributes"],
|
||||
"required" => false,
|
||||
"attr" => ["rows" => 10]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Niveau01',
|
||||
'mode' => "string",
|
||||
'appMasteridentity' => "string",
|
||||
"appSynchro" => "string",
|
||||
'appNiveau01label' => "string"
|
||||
));
|
||||
}
|
||||
}
|
70
src/Form/Niveau02Type.php
Normal file
70
src/Form/Niveau02Type.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
class Niveau02Type extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$access=$options["access"];
|
||||
$userid=$options["userid"];
|
||||
$builder->add('niveau01',
|
||||
EntityType::class, [
|
||||
"class" => "App\Entity\Niveau01",
|
||||
"label" => $options["appNiveau01label"],
|
||||
"placeholder" => "== Choisir ".$options["appNiveau01label"]." ==",
|
||||
"choice_label" => "label",
|
||||
"disabled" => ($options["mode"]!="submit"),
|
||||
"query_builder"=> function (EntityRepository $er) use($access,$userid) {
|
||||
switch($access) {
|
||||
case "admin":
|
||||
return $er->createQueryBuilder('niveau01')->orderBy('niveau01.label','ASC');
|
||||
break;
|
||||
|
||||
case "modo":
|
||||
$result=$er->createQueryBuilder("table")->innerJoin("App:UserModo", "usermodo", Join::WITH, "table.id = usermodo.niveau01")->orderBy('table.label','ASC');
|
||||
$result->andWhere("usermodo.user = :user");
|
||||
$result->setParameter('user', $userid);
|
||||
return $result;
|
||||
break;
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('label',
|
||||
TextType::class, [
|
||||
"label" =>"Label",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Niveau02',
|
||||
'mode' => "string",
|
||||
'access' => "string",
|
||||
'userid' => "string",
|
||||
'appMasteridentity' => "string",
|
||||
'appNiveau01label' => "string",
|
||||
'appNiveau02label' => "string"
|
||||
));
|
||||
}
|
||||
}
|
212
src/Form/RegistrationType.php
Normal file
212
src/Form/RegistrationType.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?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\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Gregwar\CaptchaBundle\Type\CaptchaType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
|
||||
class RegistrationType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => ($options["mode"]=="submit"?"Confirmer":"Enregistrer et envoyer le mail de confirmation"),
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
if($options["mode"]=="update") {
|
||||
$builder->add('save',
|
||||
SubmitType::class, array(
|
||||
"label" => "Enregistrer sans envoyer le mail de confirmation",
|
||||
"attr" => array("class" => "btn btn-success")
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('note',
|
||||
TextareaType::class, array(
|
||||
"label" => "Notes Administrateur",
|
||||
"required" => false,
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 130px")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$builder->add('username',
|
||||
TextType::class,[
|
||||
"label" =>"Login",
|
||||
"disabled" => ($options["mode"]!="submit"),
|
||||
"attr" => ["autocomplete" => "new-password"]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('lastname',
|
||||
TextType::class, [
|
||||
"label" =>"Nom",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL"&&$options["mode"]!="submit"),
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('firstname',
|
||||
TextType::class, [
|
||||
"label" =>"Prénom",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL"&&$options["mode"]!="submit"),
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('email',
|
||||
EmailType::class, array(
|
||||
"label" =>"Mail",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL")&&$options["mode"]!="submit",
|
||||
)
|
||||
);
|
||||
|
||||
$access=$options["access"];
|
||||
$userid=$options["userid"];
|
||||
$builder->add('niveau01',
|
||||
EntityType::class, [
|
||||
"class" => "App\Entity\Niveau01",
|
||||
"label" => $options["appNiveau01label"],
|
||||
"placeholder" => "== Choisir ".$options["appNiveau01label"]." ==",
|
||||
"choice_label" => "label",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL"&&$options["mode"]!="submit"),
|
||||
"query_builder"=> function (EntityRepository $er) use($access,$userid) {
|
||||
switch($access) {
|
||||
case "admin":
|
||||
return $er->createQueryBuilder('niveau01')->orderBy('niveau01.label','ASC');
|
||||
break;
|
||||
|
||||
case "modo":
|
||||
$result=$er->createQueryBuilder("table")->innerJoin("App:UserModo", "usermodo", Join::WITH, "table.id = usermodo.niveau01")->orderBy('table.label','ASC');
|
||||
$result->andWhere("usermodo.user = :user");
|
||||
$result->setParameter('user', $userid);
|
||||
return $result;
|
||||
break;
|
||||
|
||||
default:
|
||||
return $er->createQueryBuilder('niveau01')->orderBy('niveau01.label','ASC');
|
||||
break;
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('niveau02',
|
||||
Select2EntityType::class, [
|
||||
"label" => $options["appNiveau02label"],
|
||||
"required" => false,
|
||||
"remote_route" => "app_niveau02_selectlist",
|
||||
"class" => "App\Entity\Niveau02",
|
||||
//"req_params" => ["niveau01" => "parent.children[niveau01]"],
|
||||
"primary_key" => "id",
|
||||
"text_property" => "label",
|
||||
"minimum_input_length" => 0,
|
||||
"page_limit" => 10,
|
||||
"allow_clear" => true,
|
||||
"delay" => 250,
|
||||
"cache" => false,
|
||||
"cache_timeout" => 60000,
|
||||
"language" => "fr",
|
||||
"placeholder" => "== Choisir ".$options["appNiveau02label"]." ==",
|
||||
]
|
||||
);
|
||||
|
||||
# Password
|
||||
if($options["mode"]=="submit") {
|
||||
$builder->add('password',
|
||||
RepeatedType::class, array(
|
||||
"type" => PasswordType::class,
|
||||
"required" => ($options["mode"]=="submit"?true:false),
|
||||
"first_options" => array("label" => "Mot de Passe","attr" => array("class" => "form-control", "style" => "margin-bottom:15px", "autocomplete" => "new-password")),
|
||||
"second_options" => array('label' => 'Confirmer Mot de Passe',"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")),
|
||||
"invalid_message" => "Mot de passe non valide"
|
||||
)
|
||||
);
|
||||
$builder->add('passwordplain',PasswordType::class,["mapped"=>false,"required"=>false]);
|
||||
|
||||
$builder->add('captcha',
|
||||
CaptchaType::class,array(
|
||||
"width" => 200,
|
||||
"height" => 50,
|
||||
"length" => 6,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$choices=array("oui" => "1","non" => "0");
|
||||
$builder->add("isvisible",
|
||||
ChoiceType::class,array(
|
||||
"label" =>"Visible",
|
||||
"choices" => $choices
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('postaladress',
|
||||
TextareaType::class, [
|
||||
"label" => "Adresse",
|
||||
"required" => false,
|
||||
"attr" => ["style" => "height:90px"]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('telephonenumber',
|
||||
TextType::class, [
|
||||
"label" => "Téléphone",
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('job',
|
||||
TextType::class, [
|
||||
"label" => "Métier",
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('position',
|
||||
TextType::class, [
|
||||
"label" => "Fonction",
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('motivation',
|
||||
TextareaType::class, [
|
||||
"label" => "Motivation",
|
||||
"required" => false,
|
||||
"attr" => ["style" => "height: 90px"],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Registration',
|
||||
'mode' => "string",
|
||||
'access' => "string",
|
||||
'userid' => "string",
|
||||
'appMasteridentity' => "string",
|
||||
'appNiveau01label' => "string",
|
||||
'appNiveau02label' => "string",
|
||||
));
|
||||
}
|
||||
}
|
55
src/Form/ResetpwdType.php
Normal file
55
src/Form/ResetpwdType.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
|
||||
class ResetpwdType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
if($options["mode"]=="resetpwd01") {
|
||||
$builder->add('email',
|
||||
TextType::class, array(
|
||||
"label" =>"Votre Mail",
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$builder->add('password',
|
||||
RepeatedType::class, array(
|
||||
"type" => PasswordType::class,
|
||||
"required" => ($options["mode"]=="submit"?true:false),
|
||||
"options" => array("always_empty" => true),
|
||||
"first_options" => array("label" => "Votre nouveau Mot de Passe","attr" => array("class" => "form-control", "style" => "margin-bottom:15px")),
|
||||
"second_options" => array('label' => 'Confirmer votre nouveau Mot de Passe',"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")),
|
||||
"invalid_message" => "Mot de passe non valide"
|
||||
)
|
||||
);
|
||||
$builder->add('passwordplain',PasswordType::class,["mapped"=>false,"required"=>false]);
|
||||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\User',
|
||||
'mode' => "string"
|
||||
));
|
||||
}
|
||||
}
|
232
src/Form/UserType.php
Normal file
232
src/Form/UserType.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?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\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
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 Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
|
||||
class UserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('username',
|
||||
TextType::class,[
|
||||
"label" =>"Login",
|
||||
"disabled" => ($options["mode"]!="submit"),
|
||||
"attr" => ["autocomplete" => "new-password"]
|
||||
]
|
||||
);
|
||||
|
||||
if($options["appMasteridentity"]=="SQL"||$options["mode"]=="submit") {
|
||||
$builder->add('password',
|
||||
RepeatedType::class, [
|
||||
"type" => PasswordType::class,
|
||||
"required" => ($options["mode"]=="submit"),
|
||||
"options" => ["always_empty" => true],
|
||||
"first_options" => ["label" => "Mot de Passe","attr" => ["autocomplete" => "new-password"]],
|
||||
"second_options" => ["label" => 'Confirmer Mot de Passe'],
|
||||
"invalid_message" => "Mot de passe non valide"
|
||||
]
|
||||
);
|
||||
$builder->add('passwordplain',PasswordType::class,["mapped"=>false,"required"=>false]);
|
||||
}
|
||||
|
||||
$builder->add('lastname',
|
||||
TextType::class, [
|
||||
"label" =>"Nom",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL"&&$options["mode"]!="submit"),
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('firstname',
|
||||
TextType::class, [
|
||||
"label" =>"Prénom",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL"&&$options["mode"]!="submit"),
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('email',
|
||||
EmailType::class, array(
|
||||
"label" =>"Mail",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL")&&$options["mode"]!="submit",
|
||||
)
|
||||
);
|
||||
|
||||
$access=$options["access"];
|
||||
$userid=$options["userid"];
|
||||
$builder->add('niveau01',
|
||||
EntityType::class, [
|
||||
"class" => "App\Entity\Niveau01",
|
||||
"label" => $options["appNiveau01label"],
|
||||
"placeholder" => "== Choisir ".$options["appNiveau01label"]." ==",
|
||||
"choice_label" => "label",
|
||||
"disabled" => ($options["appMasteridentity"]!="SQL"&&$options["mode"]!="submit"),
|
||||
"query_builder"=> function (EntityRepository $er) use($access,$userid) {
|
||||
switch($access) {
|
||||
case "admin":
|
||||
return $er->createQueryBuilder('niveau01')->orderBy('niveau01.label','ASC');
|
||||
break;
|
||||
|
||||
case "modo":
|
||||
$result=$er->createQueryBuilder("table")->innerJoin("App:UserModo", "usermodo", Join::WITH, "table.id = usermodo.niveau01")->orderBy('table.label','ASC');
|
||||
$result->andWhere("usermodo.user = :user");
|
||||
$result->setParameter('user', $userid);
|
||||
return $result;
|
||||
break;
|
||||
|
||||
default:
|
||||
return $er->createQueryBuilder('niveau01')->orderBy('niveau01.label','ASC');
|
||||
break;
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('niveau02',
|
||||
Select2EntityType::class, [
|
||||
"label" => $options["appNiveau02label"],
|
||||
"required" => false,
|
||||
"remote_route" => "app_niveau02_selectlist",
|
||||
"class" => "App\Entity\Niveau02",
|
||||
//"req_params" => ["niveau01" => "parent.children[niveau01]"],
|
||||
"primary_key" => "id",
|
||||
"text_property" => "label",
|
||||
"minimum_input_length" => 0,
|
||||
"page_limit" => 10,
|
||||
"allow_clear" => true,
|
||||
"delay" => 250,
|
||||
"cache" => false,
|
||||
"cache_timeout" => 60000,
|
||||
"language" => "fr",
|
||||
"placeholder" => "== Choisir ".$options["appNiveau02label"]." ==",
|
||||
]
|
||||
);
|
||||
|
||||
$choices=array("oui" => "1","non" => "0");
|
||||
$builder->add("isvisible",
|
||||
ChoiceType::class,array(
|
||||
"label" =>"Visible",
|
||||
"choices" => $choices
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('postaladress',
|
||||
TextareaType::class, [
|
||||
"label" => "Adresse",
|
||||
"required" => false,
|
||||
"attr" => ["style" => "height:90px"]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('telephonenumber',
|
||||
TextType::class, [
|
||||
"label" => "Téléphone",
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('job',
|
||||
TextType::class, [
|
||||
"label" => "Métier",
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('position',
|
||||
TextType::class, [
|
||||
"label" => "Fonction",
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$builder->add('visitedate',
|
||||
DateTimeType::class, [
|
||||
"label" => "Date de dernière visite",
|
||||
"disabled" => true,
|
||||
"required" => false,
|
||||
"widget" => 'single_text',
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('visitecpt',
|
||||
IntegerType::class, [
|
||||
"label" => "Nombre de visites",
|
||||
"disabled" => true,
|
||||
"required" => false,
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('motivation',
|
||||
TextareaType::class, [
|
||||
"label" => "Motivation",
|
||||
"required" => false,
|
||||
"attr" => ["style" => "height: 90px"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('avatar',HiddenType::class);
|
||||
$builder->add('linkgroups',HiddenType::class, array("mapped" => false));
|
||||
$builder->add('linkmodos',HiddenType::class, array("mapped" => false));
|
||||
|
||||
if($options["access"]=="admin" || $options["access"]=="modo") {
|
||||
$choices=array("ROLE_ADMIN" => "ROLE_ADMIN","ROLE_MODO" => "ROLE_MODO","ROLE_MASTER" => "ROLE_MASTER","ROLE_USER" => "ROLE_USER");
|
||||
$builder->add("roles",
|
||||
ChoiceType::class,[
|
||||
"label" =>"Rôle",
|
||||
"required" => true,
|
||||
"multiple" => true,
|
||||
"expanded" => true,
|
||||
"choices" => $choices
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('note',
|
||||
TextareaType::class, [
|
||||
"label" => "Notes Administrateur",
|
||||
"required" => false,
|
||||
"attr" => ["style" => "height: 130px"]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\User',
|
||||
'mode' => "string",
|
||||
'access' => "string",
|
||||
'userid' => "string",
|
||||
'appMasteridentity' => "string",
|
||||
'appNiveau01label' => "string",
|
||||
'appNiveau02label' => "string",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
35
src/Form/WhitelistType.php
Normal file
35
src/Form/WhitelistType.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class WhitelistType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('submit',
|
||||
SubmitType::class,[
|
||||
"label" => "Valider",
|
||||
"attr" => ["class" => "btn btn-success"],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('label',
|
||||
TextType::class, [
|
||||
"label" =>"Label",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Whitelist',
|
||||
'mode' => "string"
|
||||
));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user