From dd028bec3822d1d9c28c35d599d687e038c7705f Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 4 Jan 2007 11:23:26 +0000 Subject: Add chat demo and tutorial. --- demos/chat/protected/App_Code/ChatUserManager.php | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 demos/chat/protected/App_Code/ChatUserManager.php (limited to 'demos/chat/protected/App_Code/ChatUserManager.php') diff --git a/demos/chat/protected/App_Code/ChatUserManager.php b/demos/chat/protected/App_Code/ChatUserManager.php new file mode 100644 index 00000000..f8fe09cc --- /dev/null +++ b/demos/chat/protected/App_Code/ChatUserManager.php @@ -0,0 +1,63 @@ +setIsGuest(true); + if($username !== null) + { + $user->setIsGuest(false); + $user->setName($username); + $user->setRoles(array('normal')); + } + return $user; + } + + /** + * Add a new user to the database. + * @param string username. + */ + public function addNewUser($username) + { + $user = new ChatUserRecord(); + $user->username = $username; + $user->save(); + } + + /** + * @return boolean true if username already exists, false otherwise. + */ + public function usernameExists($username) + { + return ChatUserRecord::finder()->findByUsername($username) instanceof ChatUserRecord; + } + + /** + * Validates if the username exists. + * @param string user name + * @param string password + * @return boolean true if validation is successful, false otherwise. + */ + public function validateUser($username,$password) + { + return $this->usernameExists($username); + } +} + + +?> \ No newline at end of file -- cgit v1.2.3