class_ConfirmCodeVerifierFilter.php

Go to the documentation of this file.
00001 <?php
00024 class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
00030         protected function __construct () {
00031                 // Call parent constructor
00032                 parent::__construct(__CLASS__);
00033         }
00034 
00040         public final static function createConfirmCodeVerifierFilter () {
00041                 // Get a new instance
00042                 $filterInstance = new ConfirmCodeVerifierFilter();
00043 
00044                 // Return the instance
00045                 return $filterInstance;
00046         }
00047 
00056         public function execute (Requestable $requestInstance, Responseable $responseInstance) {
00057                 // Get confirmation code from request
00058                 $confirmCode = $requestInstance->getRequestElement('confirm');
00059 
00060                 // Is this code set?
00061                 if (is_null($confirmCode)) {
00062                         // Is not in request
00063                         $requestInstance->requestIsValid(false);
00064 
00065                         // Add a message to the response
00066                         $responseInstance->addFatalMessage('confirm_code_unset');
00067 
00068                         // Abort here
00069                         return false;
00070                 } elseif (empty($confirmCode)) {
00071                         // Email is empty
00072                         $requestInstance->requestIsValid(false);
00073 
00074                         // Add a message to the response
00075                         $responseInstance->addFatalMessage('confirm_code_empty');
00076 
00077                         // Abort here
00078                         return false;
00079                 }
00080 
00081                 // Get a user instance from registry
00082                 $userInstance = Registry::getRegistry()->getInstance('user');
00083 
00084                 // Is the instance there?
00085                 if (is_null($userInstance)) {
00086                         // Throw an exception here
00087                         throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
00088                 } // END - if
00089 
00090                 // Get the confirm code from user for comparison
00091                 $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH);
00092 
00093                 // Do we have the same code or different?
00094                 if ($userCode != $confirmCode) {
00095                         // Email is empty
00096                         $requestInstance->requestIsValid(false);
00097 
00098                         // Redirect to error page
00099                         $responseInstance->redirectToConfiguredUrl('confirm_code_invalid_url');
00100 
00101                         // Stop processing here
00102                         exit();
00103                 } // END - if
00104         }
00105 }
00106 
00107 // [EOF]
00108 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6