summaryrefslogtreecommitdiff
path: root/app/php/controls/RegistrationForm.php
blob: 0f24cea8153e7cb7ed39fc678914d5e7cc3dad6e (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
<?php

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

Prado::using('Application.model.User');

class RegistrationForm extends TemplateControl {

    public function checkUsername($sender, $param) {
        $param->IsValid = !User::finder()->countByLogin($this->Login->SafeText);
    }

    public function registerUser($sender, $param) {
        if ($this->Page->IsValid) {
            $newUser = new User();
            $newUser->Login = $this->Login->SafeText;
            $newUser->Password = DbUser::generatePassword($this->Password->Text);
            $newUser->IsAdmin = $this->Admin->Checked;
            $newUser->save();
            $this->Response->redirect(
                $this->Service->constructUrl(NULL)
            );
        }
    }

}

?>