X-Git-Url: https://git.mxchange.org/?p=hub.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fuser%2Fclass_User.php;h=280adec1600d86e43d65fc161b223fbe348da7eb;hp=53e8b46efec3e7910a5e9b1372b10835bac52a2c;hb=1f1f351e726dae5d4cd25b46639c2fcaa9e38661;hpb=4505d1aba1901496e8034a8009fe635c05e70648 diff --git a/inc/classes/main/user/class_User.php b/inc/classes/main/user/class_User.php index 53e8b46ef..280adec16 100644 --- a/inc/classes/main/user/class_User.php +++ b/inc/classes/main/user/class_User.php @@ -92,11 +92,43 @@ class User extends BaseFrameworkSystem implements ManageableUser { /** * Getter for username * - * @return $userName The username to set + * @return $userName The username to get */ public final function getUsername () { return $this->userNane; } + + /** + * Determines wether the username exists or not + * + * @return $exists Wether the username exists + */ + protected function ifUsernameExists () { + // By default the username does exist + $exists = true; + + // Get a UserDatabaseWrapper instance + $wrapperInstance = UserDatabaseWrapper::createUserDatabaseWrapper(); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername()); + $criteriaInstance->setLimit(1); + + // Get a search result + $result = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Search for it + if ($result->next()) { + // Entry found, so all is fine + $exists = true; + } + + // Return the status + return $exists; + } } // [EOF]