summaryrefslogtreecommitdiff
path: root/app/frontend/controls/RegistrationForm.php
blob: 0e6f740ed73a1eef06555875a9793f46436ff7ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

Prado::using('Application.web.FacadeTemplateControl');

Prado::using('Application.facades.UserFacade');

class RegistrationForm extends FacadeTemplateControl {

    public function onLoad($param) {
        parent::onLoad($param);
        if ($this->Request['success'] === 'success') {
            $this->MV->setActiveView($this->SuccessPanel);
        } else {
            $this->MV->setActiveView($this->FormPanel);
        }
    }

    public function checkUsername($sender, $param) {
        $param->IsValid = $this->getFacade()->checkForUsername(
            $this->Login->SafeText
        );
    }

    public function checkEMail($sender, $param) {
        $param->IsValid = $this->getFacade()->checkForEMail(
            $this->EMail->SafeText
        );
    }

    public function registerUser($sender, $param) {
        if ($this->Page->IsValid) {
            $this->getFacade()->registerUser(
                $this->Login->SafeText,
                $this->Password->Text,
                $this->EMail->Text
            );
            $this->Response->redirect(
                $this->Service->constructUrl(
                    $this->Request->ServiceParameter,
                    ['success' => 'success']
                )
            );
        }
    }

}

?>