Untitled
By: a guest | Feb 9th, 2010 | Syntax:
None | Size: 1.83 KB | Hits: 30 | Expires: Never
<validator class="string" name="email_specification" provides="email_specification">
<arguments>
<argument>email</argument>
</arguments>
<errors>
<error for="required">You must provide your e-mail address.</error>
<error for="max">Your e-mail address may not exceed 255 characters in length.</error>
</errors>
<ae:parameters>
<ae:parameter name="min">1</ae:parameter>
<ae:parameter name="max">255</ae:parameter>
<ae:parameter name="trim">true</ae:parameter>
<ae:parameter name="export">email</ae:parameter>
</ae:parameters>
</validator>
<validator class="email" name="email_validation" depends="email_specification">
<arguments>
<argument>email</argument>
</arguments>
<errors>
<error>You must provide a valid e-mail address.</error>
</errors>
</validator>
<validator class="not" name="email_usage" depends="email_validation">
<validator class="UserAuthenticationEmailValidator">
<arguments>
<argument>email</argument>
</arguments>
</validator>
<errors>
<error>That e-mail address is already in use.</error>
</errors>
</validator>
<?php
/**
* Validates an account given an e-mail address.
*/
class UserAuthenticationEmailValidator extends AgaviValidator
{
/**
* Performs the validation.
*
* @return bool True if the validation succeeds; false otherwise.
*/
public function validate()
{
$email = $this->getData($this->getArgument());
$loginsys = $this->getContext()->getModel('LoginSystem', 'UserAuthentication');
$account = null;
try {
$account = $loginsys->retrieveAccountByEmail($email);
}
catch(AgaviException $pare) {
$this->throwError();
return false;
}
$this->export($account);
return true;
}
}
?>