Code merged from ship-simu repository
[mailer.git] / inc / classes / main / filter / validator / class_UserNameValidatorFilter.php
index 522e77a82b426052be9ebf3f55ed3433edcede99..8d0445feb4696d5fe43ea9b68edeb3729a358104 100644 (file)
@@ -1,9 +1,8 @@
 <?php
 /**
  * A concrete filter for validating the username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username is
- * already taken.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username is already taken.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -38,12 +37,16 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createUserNameValidatorFilter () {
+       public final static function createUserNameValidatorFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new UserNameValidatorFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -125,7 +128,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                }
 
                // Does the username exist?
-               if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+               if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
                        // This username is still available
                        $alreadyTaken = false;
                } // END - if