summaryrefslogtreecommitdiff
path: root/demos/chat/protected/pages
diff options
context:
space:
mode:
Diffstat (limited to 'demos/chat/protected/pages')
-rw-r--r--demos/chat/protected/pages/Home.php110
-rw-r--r--demos/chat/protected/pages/Login.php78
2 files changed, 94 insertions, 94 deletions
diff --git a/demos/chat/protected/pages/Home.php b/demos/chat/protected/pages/Home.php
index 65cb22dc..bdcb2d3b 100644
--- a/demos/chat/protected/pages/Home.php
+++ b/demos/chat/protected/pages/Home.php
@@ -1,56 +1,56 @@
-<?php
-
-class Home extends TPage
-{
- public function onLoad($param)
- {
- $username = $this->Application->User->Name;
- if(!$this->Application->Modules['users']->usernameExists($username))
- {
- $auth = $this->Application->Modules['auth'];
- $auth->logout();
-
- //redirect to login page.
- $this->Response->Redirect($this->Service->ConstructUrl($auth->LoginPage));
- }
- }
-
- function processMessage($sender, $param)
- {
- if(strlen($this->userinput->Text) > 0)
- {
- $record = new ChatBufferRecord();
- $record->message = $this->userinput->Text;
- $record->from_user = $this->Application->User->Name;
- $record->saveMessage();
- $this->userinput->Text = '';
- $this->refresh($sender, $param);
- $this->CallbackClient->focus($this->userinput);
- }
- }
-
- function refresh($sender, $param)
- {
- //refresh the message list
- $content = ChatBufferRecord::finder()->getUserMessages($this->Application->User->Name);
- if(strlen($content) > 0)
- {
- $client = $this->Page->CallbackClient;
- $anchor = (string)time();
- $content .= "<a href=\"#\" id=\"{$anchor}\"> </a>";
- $client->appendContent("messages", $content);
- $client->focus($anchor);
- }
-
- //refresh the user list
- $lastUpdate = $this->getViewState('userList','');
- $users = ChatUserRecord::finder()->getUserList();
- if($lastUpdate != $users)
- {
- $this->Page->CallbackClient->update('users', $users);
- $this->setViewstate('userList', $users);
- }
- }
-}
-
+<?php
+
+class Home extends TPage
+{
+ public function onLoad($param)
+ {
+ $username = $this->Application->User->Name;
+ if(!$this->Application->Modules['users']->usernameExists($username))
+ {
+ $auth = $this->Application->Modules['auth'];
+ $auth->logout();
+
+ //redirect to login page.
+ $this->Response->Redirect($this->Service->ConstructUrl($auth->LoginPage));
+ }
+ }
+
+ function processMessage($sender, $param)
+ {
+ if(strlen($this->userinput->Text) > 0)
+ {
+ $record = new ChatBufferRecord();
+ $record->message = $this->userinput->Text;
+ $record->from_user = $this->Application->User->Name;
+ $record->saveMessage();
+ $this->userinput->Text = '';
+ $this->refresh($sender, $param);
+ $this->CallbackClient->focus($this->userinput);
+ }
+ }
+
+ function refresh($sender, $param)
+ {
+ //refresh the message list
+ $content = ChatBufferRecord::finder()->getUserMessages($this->Application->User->Name);
+ if(strlen($content) > 0)
+ {
+ $client = $this->Page->CallbackClient;
+ $anchor = (string)time();
+ $content .= "<a href=\"#\" id=\"{$anchor}\"> </a>";
+ $client->appendContent("messages", $content);
+ $client->focus($anchor);
+ }
+
+ //refresh the user list
+ $lastUpdate = $this->getViewState('userList','');
+ $users = ChatUserRecord::finder()->getUserList();
+ if($lastUpdate != $users)
+ {
+ $this->Page->CallbackClient->update('users', $users);
+ $this->setViewstate('userList', $users);
+ }
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/chat/protected/pages/Login.php b/demos/chat/protected/pages/Login.php
index 831ab925..ec39f1f0 100644
--- a/demos/chat/protected/pages/Login.php
+++ b/demos/chat/protected/pages/Login.php
@@ -1,40 +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);
- }
- }
-}
-
+<?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