EmailChangeFilter.execute ( Requestable requestInstance,
Responseable responseInstance 
)

Executes the filter with given request and response objects.

Parameters:
$requestInstance An instance of a class with an Requestable interface
$responseInstance An instance of a class with an Responseable interface
Returns:
void
Todo:
Implement email change of the user here. HINT: Use the User class!

Implements Filterable.

Definition at line 56 of file class_EmailChangeFilter.php.

References BaseFrameworkSystem.$userInstance, Responseable.addFatalMessage(), Registry.getRegistry(), Requestable.getRequestElement(), BaseFrameworkSystem.partialStub(), and Requestable.requestIsValid().

00056                                                                                                {
00057                 // Get both emails
00058                 $email1 = $requestInstance->getRequestElement('email1');
00059                 $email2 = $requestInstance->getRequestElement('email2');
00060 
00061                 // Is only first email set?
00062                 if ((!empty($email1)) && (empty($email2))) {
00063                         // Request is invalid!
00064                         $requestInstance->requestIsValid(false);
00065 
00066                         // Email 2 is empty
00067                         $responseInstance->addFatalMessage('email2_empty');
00068 
00069                         // Stop processing here
00070                         return false;
00071                 } // END - if
00072 
00073                 // Is only second email set?
00074                 if ((empty($email1)) && (!empty($email2))) {
00075                         // Request is invalid!
00076                         $requestInstance->requestIsValid(false);
00077 
00078                         // Email 1 is empty
00079                         $responseInstance->addFatalMessage('email1_empty');
00080 
00081                         // Stop processing here
00082                         return false;
00083                 } // END - if
00084 
00085                 // Do both match?
00086                 if ($email1 != $email2) {
00087                         // Request is invalid!
00088                         $requestInstance->requestIsValid(false);
00089 
00090                         // Emails are mismatching
00091                         $responseInstance->addFatalMessage('emails_mismatch');
00092 
00093                         // Stop processing here
00094                         return false;
00095                 } // END - if
00096 
00097                 // Are email and confirmation empty?
00098                 if ((empty($email1)) && (empty($email2))) {
00099                         // No email change required!
00100                         return true;
00101                 } // END - if
00102 
00103                 // Now, get a user instance for comparison
00104                 $userInstance = Registry::getRegistry()->getInstance('user');
00105 
00106                 // Get the email field
00107                 $userEmail = $userInstance->getField('email');
00108 
00109                 // Are they different?
00110                 if ($userEmail == $email1) {
00111                         // Nothing has been changed is fine...
00112                         return true;
00113                 } // END - if
00114 
00115                 // Update the "new_email" field
00116                 $this->partialStub("Unfinished part.");
00117         }

Here is the call graph for this function:


Generated on Mon Dec 8 01:11:47 2008 for Ship-Simulator by  doxygen 1.5.6