<?php
/**
* A concrete filter for validating the email address. This filter may intercept
- * the filter chain if no email address is given or if the supplied username has
- * an invalid form. It could also intercept the filter chain if the email
- * address is already used by some one if configuration requires this.
+ * the filter chain if no email address is given or if the supplied email has an
+ * invalid form. It could also intercept the filter chain if the email address
+ * is already used by some one if configuration requires this.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class EmailValidatorFilter extends BaseFrameworkSystem implements Filterable {
+class EmailValidatorFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
$this->setObjectDescription("A filter for Email validation");
// Create unique ID number
- $this->createUniqueID();
-
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
+ $this->generateUniqueId();
}
/**
// Add a message to the response
$responseInstance->addFatalMessage('email_taken');
+ // Abort here
+ return false;
+ } elseif ($email1 != $email2) {
+ // Emails didn't match
+ $requestInstance->requestIsValid(false);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('emails_mismatch');
+
// Abort here
return false;
} // END - elseif
// Default is already taken
$alreadyTaken = true;
+ // Initialize instance
+ $userInstance = null;
+
// Get a registry instance
- $registry = Registry::getInstance();
+ $registry = Registry::getRegistry();
// Is the user already there?
- if ($registry->keyExists('userInstance')) {
+ if ($registry->instanceExists('user')) {
// Use the instance for checking for the email
- $userInstance = $registry->getInstance('userInstance');
+ $userInstance = $registry->getInstance('user');
$userInstance->setEmailAddress($email);
} else {
// If this instance is created then the username *does* exist
- $userInstance = User::createUserByEmail($userName);
+ $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), "createUserByEmail"), array($email));
// Remember this user instance in our registry for later usage
- $registry->addInstance('userInstance', $userInstance);
+ $registry->addInstance('user', $userInstance);
}
// Does the email exist?