diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql index 77042b34..32bfacf3 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql @@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES (-100, 'DRAAF', '130007107'); INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES -(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}EHcsvjQ0ZSD0/jiRa6+mC4AtCXMZesgA +(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}Zk1FeGDztzYdA2Q2EhJOmEuDHs7uyXI2 ', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple'); @@ -19,6 +19,7 @@ INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `f (1010, 1000, 1010, 'Générale', 'cadoles_core_config_commun', 'fa-table', 'ROLE_ADMIN,ROLE_MODO', ''), (1020, 1000, 1020, 'Thème', 'cadoles_core_config_theme', 'fa-paint-brush', 'ROLE_ADMIN,ROLE_MODO', ''), (1030, 1000, 1030, 'Modération', 'cadoles_core_config_permmodo', 'fa-balance-scale', 'ROLE_ADMIN', ''), +(1040, 1000, 1040, 'Fiche Utilisateur', 'cadoles_core_config_datauser', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''), (1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''), (1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN,ROLE_MODO', ''), @@ -69,6 +70,7 @@ INSERT IGNORE INTO `config` (`order`, `visible`, `changeable`, `required`, `type ('003', 1, 1, 0, 'string', 'subappname', 'Portail', '', 'Le sous titre de votre site'), ('004', 1, 1, 1, 'logo', 'logo', 'uploads/logo/logo.png', '', 'Le logo de votre site'), ('005', 0, 1, 0, 'theme', 'theme', '', '', 'Le theme de votre site'), +('006', 0, 1, 0, 'datauser', 'datauser', '', '', 'Parametrage des champs utilisateurs : obligatoire / facultatif / caché'), ('010', 1, 1, 1, 'boolean', 'fgforceconnect', '0', '', 'Forcer la connection afin de rendre votre site privé'), @@ -90,12 +92,14 @@ INSERT IGNORE INTO `config` (`order`, `visible`, `changeable`, `required`, `type INSERT IGNORE permmodo (`route`, `visible`) VALUES ('cadoles_core_config_commun',0), ('cadoles_core_config_theme',0), +('cadoles_core_config_datauser',0), ('cadoles_core_config_whitelist',0), ('cadoles_core_config_niveau01',0), ('cadoles_core_config_niveau02',1), ('cadoles_core_config_group',1), ('cadoles_core_config_registration',1), ('cadoles_core_config_user',1), +('cadoles_core_config_importuser',0), ('cadoles_portal_config_page',1), ('cadoles_portal_config_item',1), ('cadoles_portal_config_alert',1), diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php index 3a3c99d5..57c89706 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php @@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Response; use Cadoles\CoreBundle\Entity\Config; use Cadoles\CoreBundle\Form\ConfigType; +use Cadoles\CoreBundle\Form\DatauserType; class ConfigController extends Controller { @@ -184,6 +185,91 @@ class ConfigController extends Controller return $response; } + public function datauserAction(Request $request) + { + $em = $this->getDoctrine()->getManager(); + $session=$this->get('session'); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + + if($fields=="") { + // Valeur par défaut 0=caché / 1=falcultatif / 2=obligatoire + $fields["firstname"]["perm"]=1; + $fields["firstname"]["label"]="Prénom"; + + $fields["visible"]["perm"]=2; + $fields["visible"]["label"]="Visible"; + + $fields["authlevel"]["perm"]=2; + $fields["authlevel"]["label"]="Niveau d'authentification"; + + $fields["belongingpopulation"]["perm"]=2; + $fields["belongingpopulation"]["label"]="Population d'appartenance"; + + $fields["job"]["perm"]=1; + $fields["job"]["label"]="Métier"; + + $fields["position"]["perm"]=1; + $fields["position"]["label"]="Fonction"; + + $fields["niveau02"]["perm"]=1; + $fields["niveau02"]["label"]="Niveau 02"; + + $fields["usualname"]["perm"]=1; + $fields["usualname"]["label"]="Nom d'Usage"; + + $fields["gender"]["perm"]=1; + $fields["gender"]["label"]="Sexe"; + + $fields["givensname"]["perm"]=1; + $fields["givensname"]["label"]="Autre Prénom"; + + $fields["telephonenumber"]["perm"]=1; + $fields["telephonenumber"]["label"]="Téléphone"; + + $fields["postaladress"]["perm"]=1; + $fields["postaladress"]["label"]="Adresse"; + + $fields["birthdate"]["perm"]=1; + $fields["birthdate"]["label"]="Date de Naissance"; + + $fields["birthcountry"]["perm"]=1; + $fields["birthcountry"]["label"]="Pays de Naissance"; + + $fields["birthplace"]["perm"]=1; + $fields["birthplace"]["label"]="Ville de Naissance"; + } + else { + $fields=json_decode($fields, true); + } + + $form = $this->createForm(DatauserType::class,$config,array("fields" => $fields)); + + // Récupération des data du formulaire + $form->handleRequest($request); + + if ($form->get('submit')->isClicked() && $form->isValid()) { + + foreach($fields as $key => $value) { + $perm = $form->get($key)->getData(); + $fields[$key]["perm"]=$perm; + } + + $json=json_encode($fields); + $config->setValue($json); + $em->persist($config); + $em->flush(); + } + + + return $this->render('CadolesCoreBundle:Config:datauser.html.twig',[ + 'useheader' => true, + 'usemenu' => false, + 'usesidebar' => true, + 'form' => $form->createView() + ]); + } + protected function getErrorForm($form,$request,$data) { if ($form->get('submit')->isClicked() && !$form->isValid()) { $this->get('session')->getFlashBag()->clear(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php index 413d522a..fcad3d7b 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php @@ -172,7 +172,7 @@ class RegistrationController extends Controller public function submitAction(Request $request) { - + $em = $this->getDoctrine()->getManager(); $moderegistration = $this->getParameter('moderegistration'); $masteridentity = $this->getParameter('masteridentity'); @@ -180,9 +180,14 @@ class RegistrationController extends Controller throw $this->createNotFoundException('Permission denied'); $data = new Registration(); + $data->setVisible(true); + + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); // Création du formulaire - $form = $this->createForm(RegistrationType::class,$data,array("mode"=>"submit")); + $form = $this->createForm(RegistrationType::class,$data,array("mode"=>"submit","fields"=>$fields)); // Récupération des data du formulaire $form->handleRequest($request); @@ -192,7 +197,7 @@ class RegistrationController extends Controller // Sur validation(z) if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $data = $form->getData(); $appname = $this->get('session')->get('appname'); @@ -354,6 +359,7 @@ class RegistrationController extends Controller public function sendAction($id,Request $request) { + $em = $this->getDoctrine()->getManager(); $moderegistration = $this->getParameter('moderegistration'); $masteridentity = $this->getParameter('masteridentity'); if($moderegistration=="none"||$masteridentity!="SQL") @@ -361,11 +367,14 @@ class RegistrationController extends Controller // Récupération de l'enregistrement courant $data=$this->getData($id); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); // Vérifier que cet enregistrement est modifiable // Création du formulaire - $form = $this->createForm(RegistrationType::class,$data,array("mode"=>"send")); + $form = $this->createForm(RegistrationType::class,$data,array("mode"=>"send","fields"=>$fields)); // Récupération des data du formulaire $form->handleRequest($request); @@ -512,6 +521,8 @@ class RegistrationController extends Controller public function deleteAction($id,Request $request) { + $em = $this->getDoctrine()->getManager(); + $moderegistration = $this->getParameter('moderegistration'); $masteridentity = $this->getParameter('masteridentity'); if($moderegistration=="none"||$masteridentity!="SQL") @@ -519,11 +530,14 @@ class RegistrationController extends Controller // Récupération de l'enregistrement courant $data=$this->getData($id); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); // Vérifier que cet enregistrement est supprimable // Création du formulaire - $form = $this->createForm(RegistrationType::class,$data,array("mode"=>"delete")); + $form = $this->createForm(RegistrationType::class,$data,array("mode"=>"delete","fields"=>$fields)); // Récupération des data du formulaire $form->handleRequest($request); @@ -533,7 +547,6 @@ class RegistrationController extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); $em->remove($data); $em->flush(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php index ede4a352..3b22c1cf 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -252,19 +252,29 @@ class UserController extends Controller public function submitAction(Request $request) { + $em = $this->getDoctrine()->getManager(); + // Vérifier que l'on puisse créer if($this->GetParameter("masteridentity")!="SQL") throw $this->createNotFoundException('Permission denied'); // Initialisation de l'enregistrement $data = new User(); - + $data->setVisible(true); + $data->setBelongingpopulation("authlevel"); + $data->setAuthlevel("simple"); + + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); + // Création du formulaire $form = $this->createForm(UserType::class,$data,array( "mode"=>"submit", "access"=>"config", "perm"=>$this->isGranted('ROLE_ADMIN'),"userid"=>$this->get('security.token_storage')->getToken()->getUser()->getId(), - "masteridentity"=>$this->GetParameter("masteridentity") + "masteridentity"=>$this->GetParameter("masteridentity"), + "fields"=>$fields )); // Récupération des data du formulaire @@ -276,7 +286,6 @@ class UserController extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { $data = $form->getData(); - $em = $this->getDoctrine()->getManager(); // On récupère le SIREN et le SIRET $data->setSiren($data->getNiveau01()->getSiren()); @@ -337,9 +346,14 @@ class UserController extends Controller public function updateAction($id,$access,Request $request) { + $em = $this->getDoctrine()->getManager(); + // Récupération de l'enregistrement courant $data=$this->getData($id); $oldpassword=$data->getPassword(); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); // Si un acces modo via console d'admin on s'assure qu'il a les droit dessus sinon retour à la liste if($this->isGranted('ROLE_MODO')&&$access=="config") { @@ -372,7 +386,8 @@ class UserController extends Controller "access"=>$access, "perm"=>($access=="config"?$this->isGranted('ROLE_ADMIN'):false), "userid"=>$this->get('security.token_storage')->getToken()->getUser()->getId(), - "masteridentity"=>$this->GetParameter("masteridentity") + "masteridentity"=>$this->GetParameter("masteridentity"), + "fields"=>$fields )); // Récupération des data du formulaire @@ -383,7 +398,6 @@ class UserController extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); $data = $form->getData(); // Si pas de changement de password on replace l'ancien @@ -494,8 +508,13 @@ class UserController extends Controller public function deleteAction($id,Request $request) { + $em = $this->getDoctrine()->getManager(); + // Récupération de l'enregistrement courant $data=$this->getData($id); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); // Si un acces modo via console d'admin on s'assure qu'il a les droit dessus sinon retour à la liste if($this->isGranted('ROLE_MODO')&&$access=="config") { @@ -518,7 +537,8 @@ class UserController extends Controller "access"=>"config", "perm"=>false, "userid"=>$this->get('security.token_storage')->getToken()->getUser()->getId(), - "masteridentity"=>$this->GetParameter("masteridentity") + "masteridentity"=>$this->GetParameter("masteridentity"), + "fields"=>$fields )); // Récupération des data du formulaire @@ -529,7 +549,6 @@ class UserController extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); $em->remove($data); $em->flush(); @@ -758,7 +777,6 @@ class UserController extends Controller $user->setBirthcountry($birthcountry); $user->setBirthplace($birthplace); $user->setVisible($visible); - $user->setVisible(true); $user->setRole($role); $user->setSiren($niveau01->getSiren()); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Config.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Config.php index 0dcd41cc..193d8a69 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Config.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Config.php @@ -16,7 +16,7 @@ class Config protected $id; /** - * @ORM\Column(type="string", length=250) + * @ORM\Column(type="text") */ protected $value; diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/DatauserType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/DatauserType.php new file mode 100644 index 00000000..a35d4134 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/DatauserType.php @@ -0,0 +1,70 @@ +getFlashBag()->clear(); + + $config = $session->get('configs'); + + $builder->add('submit', + SubmitType::class, + array("label" => "Valider", + "attr" => array("class" => "btn btn-success"))); + + + foreach($options["fields"] as $key => $field) { + if($key=="birthplace") + $choices=array( + "Falcultatif" => 1, + "Caché" => 0, + ); + else + $choices=array( + "Obligatoire" => 2, + "Falcultatif" => 1, + "Caché" => 0, + ); + + $builder->add($key, ChoiceType::class, + array("label" => $field["label"], + "label_attr" => array("style" => 'margin-top:15px;'), + "attr" => array("class" => "form-control"), + "data" => $field["perm"], + "mapped" => false, + 'required' => ($options["required"]==0?false:true), + "choices" => $choices)); + } + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Cadoles\CoreBundle\Entity\Config', + 'fields' => "array", + )); + } +} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php index 89e80cd5..7617f0f8 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php @@ -28,7 +28,9 @@ class RegistrationType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $session = new Session(); - + $fields=$options["fields"]; + if(!is_array($fields)) $fields=[]; + $builder->add('submit', SubmitType::class, array( "label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"), @@ -45,14 +47,6 @@ class RegistrationType extends AbstractType ) ); - $builder->add('firstname', - TextType::class, array( - "label" =>"Prénom", - "disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - $builder->add('lastname', TextType::class, array( "label" =>"Nom de Famille", @@ -69,17 +63,6 @@ class RegistrationType extends AbstractType ) ); - $choices=array("oui" => "1","non" => "0"); - $builder->add("visible", - ChoiceType::class,array( - "label" =>"Visible", - 'disabled' => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), - "choices" => $choices - ) - ); - - $builder->add('niveau01', EntityType::class, array("class" => "CadolesCoreBundle:Niveau01", @@ -108,149 +91,201 @@ class RegistrationType extends AbstractType ); } - # Optionnel - $builder->add('usualname', - TextType::class, array( - "label" => "Nom d'Usage", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - $builder->add('givensname', - TextType::class, array( - "label" => "Autre Prénom", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('telephonenumber', - TextType::class, array( - "label" => "Téléphone", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('postaladress', - TextareaType::class, array( - "label" => "Adresse", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 90px") - ) - ); - - $builder->add('birthdate', - DateType::class, array( - "label" => "Date de Naissance", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "widget" => 'single_text', - "format" => "dd/MM/yyyy", - "html5" => false, - "attr" => array("class" => "form-control js-datepicker", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false) + # En fonction de datauser + if(!array_key_exists("firstname",$fields)||$fields["firstname"]["perm"]!=0) { + $builder->add('firstname', + TextType::class, array( + "label" =>"Prénom", + "required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) - ) - ); - - $choices=array("" => "", "homme" => "male","femme" => "female"); - $builder->add("gender", - ChoiceType::class,array( - "label" =>"Sexe", - "required" => false, - 'disabled' => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), - "choices" => $choices - ) - ); + ); + } - $builder->add('job', - TextType::class, array( - "label" => "Métier", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); + if(!array_key_exists("visible",$fields)||$fields["visible"]["perm"]!=0) { + $choices=array("oui" => "1","non" => "0"); + $builder->add("visible", + ChoiceType::class,array( + "label" =>"Visible", + "required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)), + 'disabled' => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), + "choices" => $choices + ) + ); + } - $builder->add('position', - TextType::class, array( - "label" => "Fonction", - "required" => false, - "disabled" => ($options["mode"]=="submit"?false:true), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); + if(!array_key_exists("usualname",$fields)||$fields["usualname"]["perm"]!=0) { + $builder->add('usualname', + TextType::class, array( + "label" => "Nom d'Usage", + "required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + if(!array_key_exists("givensname",$fields)||$fields["givensname"]["perm"]!=0) { + $builder->add('givensname', + TextType::class, array( + "label" => "Autre Prénom", + "required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("telephonenumber",$fields)||$fields["telephonenumber"]["perm"]!=0) { + $builder->add('telephonenumber', + TextType::class, array( + "label" => "Téléphone", + "required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("postaladress",$fields)||$fields["postaladress"]["perm"]!=0) { + $builder->add('postaladress', + TextareaType::class, array( + "label" => "Adresse", + "required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 90px") + ) + ); + } + + if(!array_key_exists("birthdate",$fields)||$fields["birthdate"]["perm"]!=0) { + $builder->add('birthdate', + DateType::class, array( + "label" => "Date de Naissance", + "required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "widget" => 'single_text', + "format" => "dd/MM/yyyy", + "html5" => false, + "attr" => array("class" => "form-control js-datepicker", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false) + ) + ) + ); + } + + if(!array_key_exists("gender",$fields)||$fields["gender"]["perm"]!=0) { + $choices=array("" => "", "homme" => "male","femme" => "female"); + $builder->add("gender", + ChoiceType::class,array( + "label" =>"Sexe", + "required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)), + 'disabled' => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), + "choices" => $choices + ) + ); + } + + if(!array_key_exists("job",$fields)||$fields["job"]["perm"]!=0) { + $builder->add('job', + TextType::class, array( + "label" => "Métier", + "required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("position",$fields)||$fields["position"]["perm"]!=0) { + $builder->add('position', + TextType::class, array( + "label" => "Fonction", + "required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)), + "disabled" => ($options["mode"]=="submit"?false:true), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + + if(!array_key_exists("birthcountry",$fields)||$fields["birthcountry"]["perm"]!=0) { + $builder->add('birthcountry', + Select2EntityType::class, array( + 'label' => "Pays de Naissance", + 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)), + 'multiple' => false, + 'remote_route' => 'cadoles_core_ajax_country_list', + 'class' => 'Cadoles\coreBundle\Entity\Country', + 'primary_key' => 'id', + 'text_property' => 'label', + '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 pays', + 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("birthplace",$fields)||($fields["birthcountry"]["perm"]!=0&&$fields["birthplace"]["perm"]!=0)) { + $builder->add('birthplace', + Select2EntityType::class, array( + 'label' => "Ville de Naissance", + 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => false, + 'multiple' => false, + 'remote_route' => 'cadoles_core_ajax_city_list', + 'class' => 'Cadoles\coreBundle\Entity\City', + 'primary_key' => 'id', + 'text_property' => 'label', + '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 une ville', + 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } - $builder->add('birthcountry', - Select2EntityType::class, array( - 'label' => "Pays de Naissance", - 'disabled' => ($options["mode"]=="submit"?false:true), - 'multiple' => false, - 'remote_route' => 'cadoles_core_ajax_country_list', - 'class' => 'Cadoles\coreBundle\Entity\Country', - 'primary_key' => 'id', - 'text_property' => 'label', - '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 pays', - 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('birthplace', - Select2EntityType::class, array( - 'label' => "Ville de Naissance", - 'disabled' => ($options["mode"]=="submit"?false:true), - 'multiple' => false, - 'remote_route' => 'cadoles_core_ajax_city_list', - 'class' => 'Cadoles\coreBundle\Entity\City', - 'primary_key' => 'id', - 'text_property' => 'label', - '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 une ville', - 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('niveau02', - Select2EntityType::class, array( - 'label' => $session->get('labelniveau02'), - 'disabled' => ($options["mode"]=="submit"?false:true), - 'multiple' => false, - 'remote_route' => 'cadoles_core_ajax_niveau02_list', - 'class' => 'Cadoles\coreBundle\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, // if 'cache' is true - 'language' => 'fr', - 'placeholder' => 'Selectionner une Localisation', - 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); + if($session->get('viewniveau02')) { + if(!array_key_exists("niveau02",$fields)||$fields["niveau02"]["perm"]!=0) { + $builder->add('niveau02', + Select2EntityType::class, array( + 'label' => $session->get('labelniveau02'), + 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)), + 'multiple' => false, + 'remote_route' => 'cadoles_core_ajax_niveau02_list', + 'class' => 'Cadoles\coreBundle\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, // if 'cache' is true + 'language' => 'fr', + 'placeholder' => 'Selectionner '.$session->get('labelniveau02'), + 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + } } @@ -258,7 +293,8 @@ class RegistrationType extends AbstractType { $resolver->setDefaults(array( 'data_class' => 'Cadoles\CoreBundle\Entity\Registration', - 'mode' => "string" + 'mode' => "string", + 'fields' => "array" )); } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php index 124c7dbf..998a4702 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php @@ -27,6 +27,8 @@ class UserType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $session = new Session(); + $fields=$options["fields"]; + if(!is_array($fields)) $fields=[]; $builder->add('submit', SubmitType::class, array( @@ -44,15 +46,6 @@ class UserType extends AbstractType ) ); - $builder->add('firstname', - TextType::class, array( - "label" =>"Prénom", - "required" => false, - "disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - $builder->add('lastname', TextType::class, array( "label" =>"Nom", @@ -82,16 +75,6 @@ class UserType extends AbstractType "choices" => $choices)); } - $choices=array("oui" => "1","non" => "0"); - $builder->add("visible", - ChoiceType::class,array( - "label" =>"Visible", - 'disabled' => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), - "choices" => $choices - ) - ); - $perm=$options["perm"]; $userid=$options["userid"]; $access=$options["access"]; @@ -118,8 +101,6 @@ class UserType extends AbstractType "disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false)))); - - # Password if($options["mode"]!="delete"&&$options["masteridentity"]=="SQL") { $builder->add('password', RepeatedType::class, array( @@ -131,175 +112,230 @@ class UserType extends AbstractType ) ); } - - # Optionnel - $builder->add('usualname', - TextType::class, array( - "label" => "Nom d'Usage", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('givensname', - TextType::class, array( - "label" => "Autre Prénom", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('telephonenumber', - TextType::class, array( - "label" => "Téléphone", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - $builder->add('postaladress', - TextareaType::class, array( - "label" => "Adresse", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height:90px") - ) - ); - $builder->add('birthdate', - DateType::class, array( - "label" => "Date de Naissance", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "widget" => 'single_text', - "format" => "dd/MM/yyyy", - "html5" => false, - "attr" => array("class" => "form-control js-datepicker", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false) + + # En fonction de datauser + if(!array_key_exists("firstname",$fields)||$fields["firstname"]["perm"]!=0) { + $builder->add('firstname', + TextType::class, [ + "label" =>"Prénom", + "required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ]); + } + + if(!array_key_exists("visible",$fields)||$fields["visible"]["perm"]!=0) { + $choices=array("oui" => "1","non" => "0"); + $builder->add("visible", + ChoiceType::class,array( + "label" =>"Visible", + 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), + "choices" => $choices ) - ) - ); - - $choices=array("" => "", "homme" => "male","femme" => "female"); - $builder->add("gender", - ChoiceType::class,array( - "label" =>"Sexe", - "required" => false, - 'disabled' => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), - "choices" => $choices - ) - ); + ); + } - $builder->add('job', - TextType::class, array( - "label" => "Métier", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); + if(!array_key_exists("usualname",$fields)||$fields["usualname"]["perm"]!=0) { + $builder->add('usualname', + TextType::class, array( + "label" => "Nom d'Usage", + "required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } - $builder->add('position', - TextType::class, array( - "label" => "Fonction", - "required" => false, - "disabled" => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - - $builder->add('birthcountry', - Select2EntityType::class, array( - 'label' => "Pays de Naissance", - 'disabled' => ($options["mode"]=="delete"?true:false), - 'multiple' => false, - 'remote_route' => 'cadoles_core_ajax_country_list', - 'class' => 'Cadoles\coreBundle\Entity\Country', - 'primary_key' => 'id', - 'text_property' => 'label', - '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 pays', - 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - $builder->add('birthplace', - Select2EntityType::class, array( - 'label' => "Ville de Naissance", - 'disabled' => ($options["mode"]=="delete"?true:false), - 'multiple' => false, - 'remote_route' => 'cadoles_core_ajax_city_list', - 'class' => 'Cadoles\coreBundle\Entity\City', - 'primary_key' => 'id', - 'text_property' => 'label', - '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 une ville', - 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") - ) - ); - - if($session->get('viewniveau02')) { - $builder->add('niveau02', + if(!array_key_exists("gender",$fields)||$fields["gender"]["perm"]!=0) { + $choices=array("" => "", "homme" => "male","femme" => "female"); + $builder->add("gender", + ChoiceType::class,array( + "label" =>"Sexe", + "required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)), + 'disabled' => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), + "choices" => $choices + ) + ); + } + + if(!array_key_exists("givensname",$fields)||$fields["givensname"]["perm"]!=0) { + $builder->add('givensname', + TextType::class, array( + "label" => "Autre Prénom", + "required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("telephonenumber",$fields)||$fields["telephonenumber"]["perm"]!=0) { + $builder->add('telephonenumber', + TextType::class, array( + "label" => "Téléphone", + "required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("postaladress",$fields)||$fields["postaladress"]["perm"]!=0) { + $builder->add('postaladress', + TextareaType::class, array( + "label" => "Adresse", + "required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height:90px") + ) + ); + } + + if(!array_key_exists("birthdate",$fields)||$fields["birthdate"]["perm"]!=0) { + $builder->add('birthdate', + DateType::class, array( + "label" => "Date de Naissance", + "required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "widget" => 'single_text', + "format" => "dd/MM/yyyy", + "html5" => false, + "attr" => array("class" => "form-control js-datepicker", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false) + ) + ) + ); + } + + if(!array_key_exists("birthcountry",$fields)||$fields["birthcountry"]["perm"]!=0) { + $builder->add('birthcountry', Select2EntityType::class, array( - 'label' => $session->get('labelniveau02'), + 'label' => "Pays de Naissance", 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)), 'multiple' => false, - 'remote_route' => 'cadoles_core_ajax_niveau02_list', - 'class' => 'Cadoles\coreBundle\Entity\Niveau02', - 'req_params' => ['niveau01' => 'parent.children[niveau01]'], + 'remote_route' => 'cadoles_core_ajax_country_list', + 'class' => 'Cadoles\coreBundle\Entity\Country', 'primary_key' => 'id', 'text_property' => 'label', - 'minimum_input_length' => 0, + '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 '.$session->get('labelniveau02'), + 'placeholder' => 'Selectionner un pays', 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") ) - ); + ); + } + + if(!array_key_exists("birthplace",$fields)||($fields["birthcountry"]["perm"]!=0&&$fields["birthplace"]["perm"]!=0)) { + $builder->add('birthplace', + Select2EntityType::class, array( + 'label' => "Ville de Naissance", + 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => false, + 'multiple' => false, + 'remote_route' => 'cadoles_core_ajax_city_list', + 'class' => 'Cadoles\coreBundle\Entity\City', + 'primary_key' => 'id', + 'text_property' => 'label', + '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 une ville', + 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if(!array_key_exists("job",$fields)||$fields["job"]["perm"]!=0) { + $builder->add('job', + TextType::class, array( + "label" => "Métier", + "required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + + + if(!array_key_exists("position",$fields)||$fields["position"]["perm"]!=0) { + $builder->add('position', + TextType::class, array( + "label" => "Fonction", + "required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)), + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } + + if($session->get('viewniveau02')) { + if(!array_key_exists("niveau02",$fields)||$fields["niveau02"]["perm"]!=0) { + $builder->add('niveau02', + Select2EntityType::class, array( + 'label' => $session->get('labelniveau02'), + 'disabled' => ($options["mode"]=="delete"?true:false), + "required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)), + 'multiple' => false, + 'remote_route' => 'cadoles_core_ajax_niveau02_list', + 'class' => 'Cadoles\coreBundle\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, // if 'cache' is true + 'language' => 'fr', + 'placeholder' => 'Selectionner '.$session->get('labelniveau02'), + 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px") + ) + ); + } } if($options["access"]=="config") { - $choices=array("simple" => "simple","substantiel" => "substantiel","fort" => "fort"); - $builder->add("authlevel", - ChoiceType::class,array( - "label" =>"Niveau d'authentification", - "required" => true, - 'disabled' => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), - "choices" => $choices - ) - ); + if(!array_key_exists("authlevel",$fields)||$fields["authlevel"]["perm"]!=0) { + $choices=array("simple" => "simple","substantiel" => "substantiel","fort" => "fort"); + $builder->add("authlevel", + ChoiceType::class,array( + "label" =>"Niveau d'authentification", + "required" => (!array_key_exists("authlevel",$fields)?false:($fields["authlevel"]["perm"]==2)), + 'disabled' => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), + "choices" => $choices + ) + ); + } - $choices=array("agent" => "agent","prestataire" => "prestataire","partenaire" => "partenaire","stagiaire" => "stagiare"); - $builder->add("belongingpopulation", - ChoiceType::class,array( - "label" =>"Population d'appartenance", - "required" => true, - 'disabled' => ($options["mode"]=="delete"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), - "choices" => $choices - ) - ); + if(!array_key_exists("belongingpopulation",$fields)||$fields["belongingpopulation"]["perm"]!=0) { + $choices=array("agent" => "agent","prestataire" => "prestataire","partenaire" => "partenaire","stagiaire" => "stagiare"); + $builder->add("belongingpopulation", + ChoiceType::class,array( + "label" =>"Population d'appartenance", + "required" => (!array_key_exists("niveau02",$fields)?false:($fields["belongingpopulation"]["perm"]==2)), + 'disabled' => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), + "choices" => $choices + ) + ); + } } # Avatar @@ -321,7 +357,8 @@ class UserType extends AbstractType 'access' => "string", 'perm' => "boolean", 'userid' => "integer", - 'masteridentity' => "string" + 'masteridentity' => "string", + "fields" => "array" )); } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index de232008..3c1001e1 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -157,6 +157,9 @@ cadoles_core_config_permmodo_update: path: /config/commun/permmodo/update defaults: { _controller: CadolesCoreBundle:Config:permmodoupdate } +cadoles_core_config_datauser: + path: /config/commun/datauser + defaults: { _controller: CadolesCoreBundle:Config:datauser } #== Registration ========================================================================================================= #-- Access config diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/datauser.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/datauser.html.twig new file mode 100755 index 00000000..f7fc5327 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/datauser.html.twig @@ -0,0 +1,35 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +{{ form_start(form) }} +