Code merge from latest Ship-Simu code
[mailer.git] / inc / classes / main / user / class_User.php
index 53e8b46efec3e7910a5e9b1372b10835bac52a2c..280adec1600d86e43d65fc161b223fbe348da7eb 100644 (file)
@@ -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]