From: Roland Häder Date: Wed, 4 Jun 2008 11:01:17 +0000 (+0000) Subject: Stub ifEmailAddressExists() finished X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2280e5443edd3296524eb56224b75b1888291a3f;p=shipsimu.git Stub ifEmailAddressExists() finished --- diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index a9f64d8..9dcb47d 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -33,6 +33,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { // Constants for database columns const DB_COLUMN_USERNAME = "username"; + const DB_COLUMN_EMAIL = "email"; // Constants for database table names const DB_TABLE_USER = "user"; diff --git a/inc/classes/main/user/class_User.php b/inc/classes/main/user/class_User.php index 564d0ec..d5a9f98 100644 --- a/inc/classes/main/user/class_User.php +++ b/inc/classes/main/user/class_User.php @@ -171,6 +171,38 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable { // Return the status return $exists; } + + /** + * Determines wether the email exists or not + * + * @return $exists Wether the email exists + */ + public function ifEmailAddressExists () { + // 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_EMAIL, $this->getEmail()); + $criteriaInstance->setLimit(1); + + // Get a search result + $result = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Search for it + if (!$result->next()) { + // Entry not found + $exists = false; + } // END - if + + // Return the status + return $exists; + } } // [EOF]