]> git.mxchange.org Git - shipsimu.git/commitdiff
Stub ifEmailAddressExists() finished
authorRoland Häder <roland@mxchange.org>
Wed, 4 Jun 2008 11:01:17 +0000 (11:01 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 4 Jun 2008 11:01:17 +0000 (11:01 +0000)
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
inc/classes/main/user/class_User.php

index a9f64d8c0b54c40ad49e6d5225785485fffab231..9dcb47da0b5c9a678d6d25dfd2b2f872aceb4d6b 100644 (file)
@@ -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";
index 564d0ecf21e652ccf63c3ed54fbf4d1a5631d212..d5a9f98aa8878150901b03abd35e2b6ca8e155c9 100644 (file)
@@ -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]