| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 /** 4 * Model representing the users in our application. Provides the methods such as 5 * authentication and querying for users. 6 * 7 * \ingroup DAO 8 */ 9 class Users 10 { 11 var $_provider; 12 13 /** 14 * Initializes the model 15 */ 16 function Users() 17 { 18 $this->_loadUserDataProvider(); 19 } 20 21 /** 22 * @private 23 * loads the user data provider specified in the config file 24 */ 25 function _loadUserDataProvider() 26 { 27 // load the config file 28 lt_include( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" ); 29 $config = new ConfigFileStorage( Array( "file" => PLOG_CLASS_PATH."config/userdata.properties.php" )); 30 31 // see which class has been configured as the user data provider 32 $providerClass = $config->getValue( "provider" ); 33 if( !$providerClass ) { 34 die( "ERROR: No provider class was specified in userdata.properties.php!" ); 35 } 36 37 // try to load the class 38 lt_include( PLOG_CLASS_PATH."class/dao/userdata/".strtolower( $providerClass ).".class.php" ); 39 40 // try to check if the class has been defined at all... 41 if( !class_exists( $providerClass )) { 42 die( "ERROR: Provider class $providerClass has not been defined!" ); 43 } 44 45 // and if so, we can create an instance of it 46 $this->_provider = new $providerClass( $config ); 47 48 // all is well... 49 return( true ); 50 } 51 52 /** 53 * Returns true if the user is in the database and the username 54 * and password match 55 * 56 * @param user Username of the user who we'd like to authenticate 57 * @param pass Password of the user 58 * @return true if user and password correct or false otherwise. 59 */ 60 function authenticateUser( $user, $pass ) 61 { 62 return( $this->_provider->authenticateUser( $user, $pass )); 63 } 64 65 /** 66 * Retrieves the user information but given only a username 67 * 68 * @param username The username of the user 69 * @return Returns a UserInfo object with the requested information, or false otherwise. 70 */ 71 function getUserInfoFromUsername( $username ) 72 { 73 return( $this->_provider->getUserInfoFromUsername( $username )); 74 } 75 76 /** 77 * Returns all the information associated to the user given 78 * 79 * @param user Username of the user from who we'd like to get the information 80 * @param pass Password of the user we'd like to get the information 81 * @return Returns a UserInfo object with the requested information, or false otherwise. 82 */ 83 function getUserInfo( $user, $pass ) 84 { 85 return( $this->_provider->getUserInfo( $user, $pass )); 86 } 87 88 /** 89 * Retrieves the user infromation but given only a userid 90 * 91 * @param userId User ID of the user from whom we'd like to get the information 92 * @return Returns a UserInfo object with the requested information, or false otherwise. 93 */ 94 function getUserInfoFromId( $userid, $extendedInfo = false ) 95 { 96 return( $this->_provider->getUserInfoFromId( $userid, $extendedInfo )); 97 } 98 99 /** 100 * Returns an array of BlogInfo objects with the information of all the blogs to which 101 * a user belongs 102 * 103 * @param userId Identifier of the user 104 * @return An array of BlogInfo objects to whom the user belongs. 105 */ 106 function getUsersBlogs( $userid, $status = BLOG_STATUS_ALL ) 107 { 108 return( $this->_provider->getUsersBlogs( $userid, $status )); 109 } 110 111 /** 112 * Returns an array with all the users available in the database 113 * 114 * @param status 115 * @param searchTerms 116 * @param orderBy 117 * @param page 118 * @param itemsPerPage 119 * @return An array containing all the users. 120 */ 121 function getAllUsers( $status = USER_STATUS_ALL, $searchTerms = "", $orderBy = "", $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE ) 122 { 123 return( $this->_provider->getAllUsers( $status, $searchTerms, $orderBy, $page, $itemsPerPage )); 124 } 125 126 /** 127 * Updates the information related to a user 128 * 129 * @param userInfo An UserInfo object containing the <b>already udpated</b> information of the 130 * user we would like to update. 131 * @return Returns true if ok or false otherwise. 132 */ 133 function updateUser( $userInfo ) 134 { 135 return( $this->_provider->updateUser( $userInfo )); 136 } 137 138 /** 139 * Adds a user to the database. 140 * 141 * @param user An UserInfo object with the necessary information 142 * @return Returns the identifier assigned to the user, or false if there was any error. It will also modify the 143 * UserInfo object passed by parameter and set its database id. 144 */ 145 function addUser( &$user ) 146 { 147 return( $this->_provider->addUser( $user )); 148 } 149 150 /** 151 * Returns an array with all the users that belong to the given 152 * blog. 153 * 154 * @param blogId The blog identifier. 155 * @param includeOwner Wether to include the owner of the blog or not. 156 * @return An array with the information about the users who belong in 157 * one way or another to that blog. 158 */ 159 function getBlogUsers( $blogId, $includeOwner = true, $status = USER_STATUS_ALL ) 160 { 161 return( $this->_provider->getBlogUsers( $blogId, $includeOwner, $status )); 162 } 163 164 /** 165 * Removes users from the database 166 * 167 * @param userId The identifier of the user we are trying to remove 168 */ 169 function deleteUser( $userId ) 170 { 171 return( $this->_provider->deleteUser( $userId )); 172 } 173 174 /** 175 * returns the total number of users 176 * 177 * @param status 178 * @param searchTerms 179 * 180 * @return total number of users 181 */ 182 function getNumUsers( $status = USER_STATUS_ALL, $searchTerms = "" ) 183 { 184 return( $this->_provider->getNumUsers( $status, $searchTerms )); 185 } 186 187 /** 188 * check if the email account has been registered 189 * @return true if the email account has been registered 190 */ 191 function emailExists($email) 192 { 193 return( $this->_provider->emailExists( $email )); 194 } 195 196 /** 197 * @see BaseUserDataProvider::mapRow() 198 */ 199 function mapRow( $row ) 200 { 201 return( $this->_provider->mapRow( $row )); 202 } 203 204 } 205 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
|