diff options
author | wei <> | 2007-01-04 11:23:26 +0000 |
---|---|---|
committer | wei <> | 2007-01-04 11:23:26 +0000 |
commit | dd028bec3822d1d9c28c35d599d687e038c7705f (patch) | |
tree | f3d2fb7f95073ea481a4dec86f0f0d30c7fe3588 /demos/chat/protected/pages/Login.php | |
parent | cac90ea6547fe194ab6ab101dfe11a0b751823ca (diff) |
Add chat demo and tutorial.
Diffstat (limited to 'demos/chat/protected/pages/Login.php')
-rw-r--r-- | demos/chat/protected/pages/Login.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/demos/chat/protected/pages/Login.php b/demos/chat/protected/pages/Login.php new file mode 100644 index 00000000..831ab925 --- /dev/null +++ b/demos/chat/protected/pages/Login.php @@ -0,0 +1,40 @@ +<?php
+
+class Login extends TPage
+{
+ /**
+ * Check that the username is not already taken.
+ * @param TControl custom validator that created the event.
+ * @param TServerValidateEventParameter validation parameters.
+ */
+ function checkUsername($sender, $param)
+ {
+ $manager = $this->Application->Modules['users'];
+ if($manager->usernameExists($this->username->Text))
+ $param->IsValid = false;
+ }
+
+ /**
+ * Create and login a new user, then redirect to the requested page.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ function createNewUser($sender, $param)
+ {
+ if($this->Page->IsValid)
+ {
+ $manager = $this->Application->Modules['users'];
+ $manager->addNewUser($this->username->Text);
+
+ //do manual login
+ $user = $manager->getUser($this->username->Text);
+ $auth = $this->Application->Modules['auth'];
+ $auth->updateSessionUser($user);
+ $this->Application->User = $user;
+
+ $this->Response->redirect($auth->ReturnUrl);
+ }
+ }
+}
+
+?>
\ No newline at end of file |