Browse Source

Add captch in registration form.

jmontoya 9 years ago
parent
commit
8bd553eccc

+ 1 - 1
app/config/config.yml

@@ -279,7 +279,7 @@ knp_menu:
 #            client_id:           <client_id>
 #            client_secret:       <client_secret>
 
-gregwar_captcha: ~
+gregwar_captcha:
 
 # Doctrine audit
 sonata_doctrine_orm_admin:

+ 0 - 10
app/config/fos/fos_user.yml

@@ -12,13 +12,3 @@ fos_user:
     service:
         user_manager: sonata.user.orm.user_manager
 
-    profile:  # Authentication Form
-        form:
-            type:               chamilo_fos_user_profile
-            handler:            fos_user.profile.form.handler.default
-            name:               fos_user_profile_form
-            validation_groups:  [Authentication]
-
-#    registration:
-#        form:
-#            type: chamilo_sonata_registration_profile

+ 3 - 2
app/config/sonata/sonata_user.yml

@@ -55,8 +55,9 @@ sonata_user:
 
         register:
             form:
-                type:                 sonata_user_registration
+                type:                 chamilo_sonata_user_registration
                 handler:              sonata.user.registration.form.handler.default
-                name:                 chamilo_sonata_registration_profile_form
+                name:                 chamilo_sonata_user_registration
                 validation_groups:
                   - Registration
+                  - Default

+ 1 - 6
src/Chamilo/CoreBundle/Resources/config/services.yml

@@ -387,7 +387,7 @@ services:
 
     # Form types
     chamilo_user.registration.form.type:
-        class: Chamilo\UserBundle\Form\RegistrationType
+        class: Chamilo\UserBundle\Form\Type\RegistrationFormType
         arguments: [%fos_user.model.user.class%]
         tags:
             - { name: form.type, alias: chamilo_sonata_user_registration }
@@ -398,9 +398,4 @@ services:
         tags:
             - { name: form.type, alias: chamilo_sonata_user_profile }
 
-    chamilo_user.fos_profile.form.type:
-        class: Chamilo\UserBundle\Form\ProfileFosUserType
-        arguments: [%fos_user.model.user.class%]
-        tags:
-            - { name: form.type, alias: chamilo_fos_user_profile }
 

+ 1 - 0
src/Chamilo/UserBundle/Form/ProfileFosUserType.php

@@ -16,6 +16,7 @@ use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
 
 /**
  * Class ProfileType
+ * @deprecated is not being used
  * @package Chamilo\UserBundle\Form
  */
 class ProfileFosUserType extends AbstractType

+ 1 - 7
src/Chamilo/UserBundle/Form/ProfileType.php

@@ -3,20 +3,14 @@
 
 namespace Chamilo\UserBundle\Form;
 
-use Chamilo\UserBundle\Entity\User;
-use Sonata\AdminBundle\Form\Type\CollectionType;
 use Symfony\Component\Form\AbstractType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolverInterface;
-use Symfony\Component\Security\Core\SecurityContext;
 use Symfony\Component\OptionsResolver\OptionsResolver;
-use Sonata\UserBundle\Model\UserInterface;
-
-use Symfony\Component\Form\FormEvent;
-use Symfony\Component\Form\FormEvents;
 
 /**
  * Class ProfileType
+ * Located in web/app_dev.php/profile/edit-profile
  * @package Chamilo\UserBundle\Form
  */
 class ProfileType extends AbstractType

+ 19 - 12
src/Chamilo/UserBundle/Form/RegistrationType.php → src/Chamilo/UserBundle/Form/Type/RegistrationFormType.php

@@ -1,7 +1,7 @@
 <?php
 /* For licensing terms, see /license.txt */
 
-namespace Chamilo\UserBundle\Form;
+namespace Chamilo\UserBundle\Form\Type;
 
 use Chamilo\UserBundle\Entity\User;
 use Symfony\Component\Form\AbstractType;
@@ -13,10 +13,11 @@ use Symfony\Component\Form\FormEvents;
 use Symfony\Component\OptionsResolver\OptionsResolver;
 
 /**
- * Class RegistrationType
- * @package Chamilo\UserBundle\Form
+ * Class RegistrationFormType
+ * Form located in web/app_dev.php/register/
+ * @package Chamilo\UserBundle\Form\Type
  */
-class RegistrationType extends AbstractType
+class RegistrationFormType extends AbstractType
 {
     /**
      * @inheritdoc
@@ -32,6 +33,8 @@ class RegistrationType extends AbstractType
                     'translation_domain' => 'FOSUserBundle',
                 )
             )
+            ->add('firstname', 'text')
+            ->add('lastname', 'text')
             ->add(
                 'email',
                 'email',
@@ -39,11 +42,11 @@ class RegistrationType extends AbstractType
                     'label' => 'form.email',
                     'translation_domain' => 'FOSUserBundle',
                 )
-            );
+            )
+            ->add('captcha', 'Gregwar\CaptchaBundle\Type\CaptchaType');
+        ;
 
         //$builder
-        //->add('firstname', 'text')
-        //->add('lastname', 'text')
         /*->add('official_code', 'text')
         ->add('email', 'email')
         ->add('username', 'text')
@@ -103,7 +106,6 @@ class RegistrationType extends AbstractType
         $this->configureOptions($resolver);
     }
 
-
     /**
      * {@inheritdoc}
      */
@@ -116,12 +118,17 @@ class RegistrationType extends AbstractType
         );
     }
 
-    /*public function getParent()
+    /**
+     * @return string
+     */
+    public function getParent()
     {
-        return 'sonata.user.registration.form';
-    }*/
-
+        return 'fos_user_registration';
+    }
 
+    /**
+     * @return string
+     */
     public function getName()
     {
         return 'chamilo_sonata_user_registration';

+ 1 - 0
src/Chamilo/UserBundle/Form/UserType.php

@@ -13,6 +13,7 @@ use Symfony\Component\Form\FormEvents;
 
 /**
  * Class UserType
+ * @deprecated
  * @package Chamilo\UserBundle\Form
  */
 class UserType extends AbstractType