diff options
Diffstat (limited to 'app/frontend/controls')
-rw-r--r-- | app/frontend/controls/RegistrationForm.php | 26 | ||||
-rw-r--r-- | app/frontend/controls/RegistrationForm.tpl | 185 |
2 files changed, 142 insertions, 69 deletions
diff --git a/app/frontend/controls/RegistrationForm.php b/app/frontend/controls/RegistrationForm.php index 46494e3..0e6f740 100644 --- a/app/frontend/controls/RegistrationForm.php +++ b/app/frontend/controls/RegistrationForm.php @@ -6,8 +6,25 @@ 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); + $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) { @@ -15,10 +32,13 @@ class RegistrationForm extends FacadeTemplateControl { $this->getFacade()->registerUser( $this->Login->SafeText, $this->Password->Text, - $this->Admin->Checked + $this->EMail->Text ); $this->Response->redirect( - $this->Service->constructUrl(NULL) + $this->Service->constructUrl( + $this->Request->ServiceParameter, + ['success' => 'success'] + ) ); } } diff --git a/app/frontend/controls/RegistrationForm.tpl b/app/frontend/controls/RegistrationForm.tpl index 9defe54..0c7e146 100644 --- a/app/frontend/controls/RegistrationForm.tpl +++ b/app/frontend/controls/RegistrationForm.tpl @@ -1,66 +1,119 @@ -<%[ Username: ]%> -<com:TTextBox ID="Login" - ValidationGroup="SignupGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Login" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Username cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TRegularExpressionValidator - ControlToValidate="Login" - RegularExpression="[a-zA-Z0-9_]{6,255}" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Username must contain 6-255 characters, all Latin alphanumeric or underscore ]%></prop:ErrorMessage> -</com:TRegularExpressionValidator> -<com:TCustomValidator - ControlToValidate="Login" - OnServerValidate="checkUsername" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Username already exists ]%></prop:ErrorMessage> -</com:TCustomValidator> -<br /> -<%[ Password: ]%> -<com:TTextBox ID="Password" - TextMode="Password" - ValidationGroup="SignupGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Password" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<br /> -<%[ Repeat password: ]%> -<com:TTextBox ID="RePassword" - TextMode="Password" - ValidationGroup="SignupGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="RePassword" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TCompareValidator - ControlToValidate="RePassword" - ControlToCompare="Password" - DataType="String" - Operator="Equal" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Passwords don't match ]%></prop:ErrorMessage> -</com:TCompareValidator> -<br /> -<%[ Admin: ]%> -<com:TCheckBox ID="Admin" - ValidationGroup="SignupGroup" /> -<br /> -<com:TButton - OnCommand="registerUser" - ValidationGroup="SignupGroup"> - <prop:Text><%[ Create ]%></prop:Text> -</com:TButton> -<com:TValidationSummary - ValidationGroup="SignupGroup" /> +<com:TMultiView ID="MV"> + <com:TView ID="FormPanel"> + <%[ Username: ]%> + <com:TTextBox ID="Login" + ValidationGroup="SignupGroup" /> + <com:TRequiredFieldValidator + ControlToValidate="Login" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ Username cannot be empty ]%></prop:ErrorMessage> + </com:TRequiredFieldValidator> + <com:TRegularExpressionValidator + ControlToValidate="Login" + RegularExpression="[a-zA-Z0-9_]{6,255}" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ Username must contain 6-255 characters, all Latin alphanumeric or underscore ]%></prop:ErrorMessage> + </com:TRegularExpressionValidator> + <com:TCustomValidator + ControlToValidate="Login" + OnServerValidate="checkUsername" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ Username already exists ]%></prop:ErrorMessage> + </com:TCustomValidator> + <br /> + <%[ Password: ]%> + <com:TTextBox ID="Password" + TextMode="Password" + ValidationGroup="SignupGroup" /> + <com:TRequiredFieldValidator + ControlToValidate="Password" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> + </com:TRequiredFieldValidator> + <br /> + <%[ Repeat password: ]%> + <com:TTextBox ID="RePassword" + TextMode="Password" + ValidationGroup="SignupGroup" /> + <com:TRequiredFieldValidator + ControlToValidate="RePassword" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> + </com:TRequiredFieldValidator> + <com:TCompareValidator + ControlToValidate="RePassword" + ControlToCompare="Password" + DataType="String" + Operator="Equal" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ Passwords don't match ]%></prop:ErrorMessage> + </com:TCompareValidator> + <br /> + <%[ E-mail: ]%> + <com:TTextBox ID="EMail" + ValidationGroup="SignupGroup" /> + <com:TRequiredFieldValidator + ControlToValidate="EMail" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ E-mail address cannot be empty ]%></prop:ErrorMessage> + </com:TRequiredFieldValidator> + <com:TEmailAddressValidator + ControlToValidate="EMail" + Display="Dynamic" + ValidationGroup="SignupGroup" + CheckMXRecord="false"> + <prop:ErrorMessage><%[ E-mail address is invalid ]%></prop:ErrorMessage> + </com:TEmailAddressValidator> + <com:TCustomValidator + ControlToValidate="EMail" + OnServerValidate="checkEMail" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ E-mail already registered ]%></prop:ErrorMessage> + </com:TCustomValidator> + <br /> + <%[ Repeat e-mail: ]%> + <com:TTextBox ID="ReEMail" + ValidationGroup="SignupGroup" /> + <com:TRequiredFieldValidator + ControlToValidate="ReEMail" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ E-mail address cannot be empty ]%></prop:ErrorMessage> + </com:TRequiredFieldValidator> + <com:TEmailAddressValidator + ControlToValidate="ReEMail" + Display="Dynamic" + ValidationGroup="SignupGroup" + CheckMXRecord="false"> + <prop:ErrorMessage><%[ E-mail address is invalid ]%></prop:ErrorMessage> + </com:TEmailAddressValidator> + <com:TCompareValidator + ControlToValidate="ReEMail" + ControlToCompare="EMail" + DataType="String" + Operator="Equal" + Display="Dynamic" + ValidationGroup="SignupGroup"> + <prop:ErrorMessage><%[ E-mails don't match ]%></prop:ErrorMessage> + </com:TCompareValidator> + <br /> + <com:TButton + OnCommand="registerUser" + ValidationGroup="SignupGroup"> + <prop:Text><%[ Create ]%></prop:Text> + </com:TButton> + <com:TValidationSummary + ValidationGroup="SignupGroup" /> + </com:TView> + <com:TView ID="SuccessPanel"> + <%[ Registration finished without problems. Please activate your account with the link we've sent you. ]%> + </com:TView> +</com:TMultiView> |