00001 <?php 00024 class PasswordChangeFilter extends BaseFilter implements Filterable { 00030 protected function __construct () { 00031 // Call parent constructor 00032 parent::__construct(__CLASS__); 00033 } 00034 00041 public final static function createPasswordChangeFilter () { 00042 // Get a new instance 00043 $filterInstance = new PasswordChangeFilter(); 00044 00045 // Return the instance 00046 return $filterInstance; 00047 } 00048 00057 public function execute (Requestable $requestInstance, Responseable $responseInstance) { 00058 // Get both passwords 00059 $pass1 = $requestInstance->getRequestElement('pass1'); 00060 $pass2 = $requestInstance->getRequestElement('pass2'); 00061 00062 // Is only first email set? 00063 if ((!empty($pass1)) && (empty($pass2))) { 00064 // Request is invalid! 00065 $requestInstance->requestIsValid(false); 00066 00067 // Email 2 is empty 00068 $responseInstance->addFatalMessage('pass2_empty'); 00069 00070 // Stop processing here 00071 return false; 00072 } // END - if 00073 00074 // Is only second pass set? 00075 if ((empty($pass1)) && (!empty($pass2))) { 00076 // Request is invalid! 00077 $requestInstance->requestIsValid(false); 00078 00079 // Email 1 is empty 00080 $responseInstance->addFatalMessage('pass1_empty'); 00081 00082 // Stop processing here 00083 return false; 00084 } // END - if 00085 00086 // Are password and confirmation empty? 00087 if ((empty($pass1)) && (empty($pass2))) { 00088 // Don't change password here 00089 return true; 00090 } // END - if 00091 00092 // Do both match? 00093 if ($pass1 != $pass2) { 00094 // Request is invalid! 00095 $requestInstance->requestIsValid(false); 00096 00097 // Emails are mismatching 00098 $responseInstance->addFatalMessage('pass_mismatch'); 00099 00100 // Stop processing here 00101 return false; 00102 } // END - if 00103 00104 // Now, get a user instance for comparison 00105 $userInstance = Registry::getRegistry()->getInstance('user'); 00106 00107 // Update the "password" field 00108 $this->partialStub("Unfinished part."); 00109 } 00110 } 00111 00112 // [EOF] 00113 ?>
1.5.6