[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * BlogUserManager class file 4 * 5 * @author Qiang Xue <qiang.xue@gmail.com> 6 * @link http://www.pradosoft.com/ 7 * @copyright Copyright © 2006 PradoSoft 8 * @license http://www.pradosoft.com/license/ 9 * @version $Id: BlogUserManager.php 1397 2006-09-07 07:55:53Z wei $ 10 */ 11 12 Prado::using('System.Security.IUserManager'); 13 Prado::using('Application.Common.BlogUser'); 14 15 /** 16 * BlogUserManager class 17 * 18 * @author Qiang Xue <qiang.xue@gmail.com> 19 * @link http://www.pradosoft.com/ 20 * @copyright Copyright © 2006 PradoSoft 21 * @license http://www.pradosoft.com/license/ 22 */ 23 class BlogUserManager extends TModule implements IUserManager 24 { 25 public function getGuestName() 26 { 27 return 'Guest'; 28 } 29 30 /** 31 * Returns a user instance given the user name. 32 * @param string user name, null if it is a guest. 33 * @return TUser the user instance, null if the specified username is not in the user database. 34 */ 35 public function getUser($username=null) 36 { 37 if($username===null) 38 return new BlogUser($this); 39 else 40 { 41 $username=strtolower($username); 42 $db=$this->Application->getModule('data'); 43 if(($userRecord=$db->queryUserByName($username))!==null) 44 { 45 $user=new BlogUser($this); 46 $user->setID($userRecord->ID); 47 $user->setName($username); 48 $user->setIsGuest(false); 49 $user->setRoles($userRecord->Role===UserRecord::ROLE_USER?'user':'admin'); 50 return $user; 51 } 52 else 53 return null; 54 } 55 } 56 57 /** 58 * Validates if the username and password are correct. 59 * @param string user name 60 * @param string password 61 * @return boolean true if validation is successful, false otherwise. 62 */ 63 public function validateUser($username,$password) 64 { 65 $db=$this->Application->getModule('data'); 66 if(($userRecord=$db->queryUserByName($username))!==null) 67 return $userRecord->Password===md5($password) && $userRecord->Status===UserRecord::STATUS_NORMAL; 68 else 69 return false; 70 } 71 } 72 73 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |