Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6750 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Auth;
6
 
7
use Laminas\Form\Form;
8
use LeadersLinked\Model\UserType;
4398 efrain 9
use LeadersLinked\Model\User;
1 www 10
 
11
class SignupForm extends Form
12
{
13
    /**
14
     *
15
     * @param array $config
16
     */
17
    public function __construct($config)
18
    {
19
 
20
        parent::__construct();
21
        $this->setInputFilter(new SignupFilter());
22
 
23
        $this->add([
24
            'name' => 'first_name',
25
            'type' => \Laminas\Form\Element\Text::class,
26
             'attributes' => [
27
                'maxlength' 	=> 64,
28
                'id' 			=> 'first_name',
29
            ]
30
         ]);
31
         $this->add([
32
            'name' => 'last_name',
33
            'type' => \Laminas\Form\Element\Text::class,
34
            'attributes' => [
35
                'maxlength' 	=> 64,
36
                'id' 			=> 'last_name',
37
            ]
38
        ]);
39
         $this->add([
40
            'name' => 'email',
41
            'type' => \Laminas\Form\Element\Text::class,
42
            'attributes' => [
43
                'maxlength' 	=> 64,
44
                'id' 			=> 'email',
45
            ]
46
        ]);
47
         $this->add([
48
             'name' => 'password',
49
             'type' => \Laminas\Form\Element\Text::class,
50
             'attributes' => [
51
                 'maxlength' 	=> 16,
52
                 'id' 			=> 'password',
53
             ]
54
         ]);
55
         $this->add([
56
             'name' => 'confirmation',
57
             'type' => \Laminas\Form\Element\Text::class,
58
             'attributes' => [
59
                 'maxlength' 	=> 16,
60
                 'id' 			=> 'confirmation',
61
             ]
62
         ]);
63
 
64
        $this->add([
65
            'name' => 'terms_and_conditions',
66
            'type' => \Laminas\Form\Element\Checkbox::class,
67
            'attributes' => [
68
                'id' => 'terms_and_conditions',
69
            ],
70
            'options' => [
6752 efrain 71
                'use_hidden_element' => false,
72
                'unchecked_value' => '0',
73
                'checked_value' => '1',
1 www 74
            ]
75
        ]);
76
 
4398 efrain 77
 
78
        $this->add([
79
            'name' => 'terms_and_conditions',
80
            'type' => \Laminas\Form\Element\Checkbox::class,
81
            'attributes' => [
82
                'id' => 'terms_and_conditions',
83
            ],
84
            'options' => [
6752 efrain 85
                'use_hidden_element' => false,
86
                'unchecked_value' => '0',
87
                'checked_value' => '1',
4398 efrain 88
            ]
89
        ]);
90
 
91
        $this->add([
92
            'name' => 'is_adult',
93
            'type' => \Laminas\Form\Element\Checkbox::class,
94
            'attributes' => [
95
                'id' => 'is_adult',
96
            ],
97
            'options' => [
6752 efrain 98
                'use_hidden_element' => false,
4398 efrain 99
                'unchecked_value' => User::IS_ADULT_NO,
100
                'checked_value' => User::IS_ADULT_YES,
101
            ]
102
        ]);
103
 
1 www 104
        if($config['leaderslinked.runmode.sandbox']) {
105
            $site_key      = $config['leaderslinked.google_captcha.sandbox_site_key'];
106
            $secret_key    = $config['leaderslinked.google_captcha.sandbox_secret_key'];
107
        } else {
108
            $site_key      = $config['leaderslinked.google_captcha.production_site_key'];
109
            $secret_key    = $config['leaderslinked.google_captcha.production_secret_key'];
110
        }
111
 
112
        $curl = new \Laminas\Http\Client\Adapter\Curl();
113
        $curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST,false);
114
        $curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER,false);
115
 
116
        $httpClient = new \Laminas\Http\Client();
117
        $httpClient->setAdapter($curl);
118
 
119
 
120
        $captcha = new \Laminas\Captcha\ReCaptcha();
121
        $captcha->setService(new \Laminas\ReCaptcha\ReCaptcha($site_key, $secret_key, $params = null, $options = ['callback' => 'enableBtn'], $ip = null, $httpClient));
122
 
123
 
124
        // Add the CAPTCHA field
125
        $this->add([
126
            'type' => 'captcha',
127
            'name' => 'captcha',
128
            'attributes' => [
129
                'data-role' => 'none',
130
            ],
131
            'options' => [
132
                'captcha' => $captcha,
133
            ],
134
        ]);
135
    }
136
 
137
 
138
}