From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- demos/chat/protected/App_Code/ChatBufferRecord.php | 126 ++++++++-------- demos/chat/protected/App_Code/ChatUserManager.php | 168 ++++++++++----------- demos/chat/protected/App_Code/ChatUserRecord.php | 80 +++++----- 3 files changed, 187 insertions(+), 187 deletions(-) (limited to 'demos/chat/protected/App_Code') diff --git a/demos/chat/protected/App_Code/ChatBufferRecord.php b/demos/chat/protected/App_Code/ChatBufferRecord.php index f4d53db0..5a714de2 100644 --- a/demos/chat/protected/App_Code/ChatBufferRecord.php +++ b/demos/chat/protected/App_Code/ChatBufferRecord.php @@ -1,64 +1,64 @@ -_created_on === null) - $this->_created_on = time(); - return $this->_created_on; - } - - public function setCreated_On($value) - { - $this->_created_on = $value; - } - - public static function finder($className=__CLASS__) - { - return parent::finder($className); - } - - public function saveMessage() - { - foreach(ChatUserRecord::finder()->findAll() as $user) - { - $message = new self; - $message->for_user = $user->username; - $message->from_user = $this->from_user; - $message->message = $this->message; - $message->save(); - if($user->username == $this->from_user) - { - $user->last_activity = time(); //update the last activity; - $user->save(); - } - } - } - - public function getUserMessages($user) - { - $content = ''; - foreach($this->findAll('for_user = ?', $user) as $message) - $content .= $this->formatMessage($message); - $this->deleteAll('for_user = ? OR created_on < ?', $user, time() - 300); //5 min inactivity - return $content; - } - - protected function formatMessage($message) - { - $user = htmlspecialchars($message->from_user); - $content = htmlspecialchars($message->message); - return "
{$user}: {$content}
"; - } -} - +_created_on === null) + $this->_created_on = time(); + return $this->_created_on; + } + + public function setCreated_On($value) + { + $this->_created_on = $value; + } + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } + + public function saveMessage() + { + foreach(ChatUserRecord::finder()->findAll() as $user) + { + $message = new self; + $message->for_user = $user->username; + $message->from_user = $this->from_user; + $message->message = $this->message; + $message->save(); + if($user->username == $this->from_user) + { + $user->last_activity = time(); //update the last activity; + $user->save(); + } + } + } + + public function getUserMessages($user) + { + $content = ''; + foreach($this->findAll('for_user = ?', $user) as $message) + $content .= $this->formatMessage($message); + $this->deleteAll('for_user = ? OR created_on < ?', $user, time() - 300); //5 min inactivity + return $content; + } + + protected function formatMessage($message) + { + $user = htmlspecialchars($message->from_user); + $content = htmlspecialchars($message->message); + return "
{$user}: {$content}
"; + } +} + ?> \ No newline at end of file diff --git a/demos/chat/protected/App_Code/ChatUserManager.php b/demos/chat/protected/App_Code/ChatUserManager.php index f28ee362..d0f242fd 100644 --- a/demos/chat/protected/App_Code/ChatUserManager.php +++ b/demos/chat/protected/App_Code/ChatUserManager.php @@ -1,85 +1,85 @@ -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); - } - - /** - * Saves user auth data into a cookie. - * @param THttpCookie the cookie to receive the user auth data. - * @since 3.1.1 - */ - public function saveUserToCookie($cookie) - { - // do nothing since we don't support cookie-based auth in this example - } - - /** - * Returns a user instance according to auth data stored in a cookie. - * @param THttpCookie the cookie storing user authentication information - * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data. - * @since 3.1.1 - */ - public function getUserFromCookie($cookie) - { - // do nothing since we don't support cookie-based auth in this example - return null; - } -} - - +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); + } + + /** + * Saves user auth data into a cookie. + * @param THttpCookie the cookie to receive the user auth data. + * @since 3.1.1 + */ + public function saveUserToCookie($cookie) + { + // do nothing since we don't support cookie-based auth in this example + } + + /** + * Returns a user instance according to auth data stored in a cookie. + * @param THttpCookie the cookie storing user authentication information + * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data. + * @since 3.1.1 + */ + public function getUserFromCookie($cookie) + { + // do nothing since we don't support cookie-based auth in this example + return null; + } +} + + ?> \ No newline at end of file diff --git a/demos/chat/protected/App_Code/ChatUserRecord.php b/demos/chat/protected/App_Code/ChatUserRecord.php index b68fbd4d..ee45cf84 100644 --- a/demos/chat/protected/App_Code/ChatUserRecord.php +++ b/demos/chat/protected/App_Code/ChatUserRecord.php @@ -1,41 +1,41 @@ -_last_activity === null) - $this->_last_activity = time(); - return $this->_last_activity; - } - - public function setLast_Activity($value) - { - $this->_last_activity = $value; - } - - public static function finder($className=__CLASS__) - { - return parent::finder($className); - } - - public function getUserList() - { - $this->deleteAll('last_activity < ?', time()-300); //5 min inactivity - $content = ''; - - return $content; - } -} - +_last_activity === null) + $this->_last_activity = time(); + return $this->_last_activity; + } + + public function setLast_Activity($value) + { + $this->_last_activity = $value; + } + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } + + public function getUserList() + { + $this->deleteAll('last_activity < ?', time()-300); //5 min inactivity + $content = ''; + + return $content; + } +} + ?> \ No newline at end of file -- cgit v1.2.3