Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev Autor Línea Nro. Línea
1 efrain 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;
9
use LeadersLinked\Model\User;
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' => [
283 www 43
                'maxlength' 	=> 250,
1 efrain 44
                'id' 			=> 'email',
45
            ]
46
        ]);
47
         $this->add([
48
             'name' => 'password',
49
             'type' => \Laminas\Form\Element\Text::class,
50
             'attributes' => [
283 www 51
                 'maxlength' 	=> 25,
1 efrain 52
                 'id' 			=> 'password',
53
             ]
54
         ]);
55
         $this->add([
56
             'name' => 'confirmation',
57
             'type' => \Laminas\Form\Element\Text::class,
58
             'attributes' => [
283 www 59
                 'maxlength' 	=> 25,
1 efrain 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' => [
71
                'use_hidden_element' => false,
72
                'unchecked_value' => '0',
73
                'checked_value' => '1',
74
            ]
75
        ]);
76
 
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' => [
85
                'use_hidden_element' => false,
86
                'unchecked_value' => '0',
87
                'checked_value' => '1',
88
            ]
89
        ]);
385 www 90
 
91
 
92
        $records = \LeadersLinked\Library\Functions::getAllTimeZones();
93
        foreach($records as $record)
94
        {
95
            $items[ $record ] = $record;
96
        }
1 efrain 97
 
385 www 98
 
1 efrain 99
        $this->add([
385 www 100
            'name' => 'timezone',
101
            'type' => \Laminas\Form\Element\Select::class,
102
            'attributes' => [
103
                'multiple' => 'no',
104
                'id' => 'timezone'
105
            ],
106
            'options' => [
107
                'disable_inarray_validator' => false,
108
                'value_options' =>  $items
109
            ]
110
        ]);
111
 
112
        $this->add([
1 efrain 113
            'name' => 'is_adult',
114
            'type' => \Laminas\Form\Element\Checkbox::class,
115
            'attributes' => [
116
                'id' => 'is_adult',
117
            ],
118
            'options' => [
119
                'use_hidden_element' => false,
120
                'unchecked_value' => User::IS_ADULT_NO,
121
                'checked_value' => User::IS_ADULT_YES,
122
            ]
123
        ]);
124
 
125
        if($config['leaderslinked.runmode.sandbox']) {
126
            $site_key      = $config['leaderslinked.google_captcha.sandbox_site_key'];
127
            $secret_key    = $config['leaderslinked.google_captcha.sandbox_secret_key'];
128
        } else {
129
            $site_key      = $config['leaderslinked.google_captcha.production_site_key'];
130
            $secret_key    = $config['leaderslinked.google_captcha.production_secret_key'];
131
        }
132
 
133
        $curl = new \Laminas\Http\Client\Adapter\Curl();
134
        $curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST,false);
135
        $curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER,false);
136
 
137
        $httpClient = new \Laminas\Http\Client();
138
        $httpClient->setAdapter($curl);
139
 
140
 
141
        $captcha = new \Laminas\Captcha\ReCaptcha();
142
        $captcha->setService(new \Laminas\ReCaptcha\ReCaptcha($site_key, $secret_key, $params = null, $options = ['callback' => 'enableBtn'], $ip = null, $httpClient));
143
 
144
 
145
        // Add the CAPTCHA field
146
        $this->add([
147
            'type' => 'captcha',
148
            'name' => 'captcha',
149
            'attributes' => [
150
                'data-role' => 'none',
151
            ],
152
            'options' => [
153
                'captcha' => $captcha,
154
            ],
155
        ]);
156
    }
157
 
158
 
159
}