Code merged from ship-simu repository
[mailer.git] / inc / classes / main / filter / change / class_EmailChangeFilter.php
index 4e75421e1832f566291a11263478f47440a832b4..bc481dd709fa8af868cdc17017f58f4e535b882b 100644 (file)
@@ -21,7 +21,7 @@
  * 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 EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
+class EmailChangeFilter extends BaseFilter implements Filterable {
        /**
         * Protected constructor
         *
@@ -35,12 +35,16 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
        /**
         * Creates an instance of this filter class
         *
-        * @return      $filterInstance         An instance of this filter class
+        * @param       $controllerInstance             An instance of a Controller class
+        * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createEmailChangeFilter () {
+       public final static function createEmailChangeFilter (Controller $controllerInstance) {
                // Get a new instance
                $filterInstance = new EmailChangeFilter();
 
+               // Set the controller
+               $filterInstance->setControllerInstance($controllerInstance);
+
                // Return the instance
                return $filterInstance;
        }
@@ -94,6 +98,12 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
                        return false;
                } // END - if
 
+               // Are email and confirmation empty?
+               if ((empty($email1)) && (empty($email2))) {
+                       // No email change required!
+                       return true;
+               } // END - if
+
                // Now, get a user instance for comparison
                $userInstance = Registry::getRegistry()->getInstance('user');
 
@@ -101,10 +111,13 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
                $userEmail = $userInstance->getField('email');
 
                // Are they different?
-               if ($userEmail != $email1) {
-                       // Update the "new_email" field
-                       $this->partialStub("Unfinished part.");
+               if ($userEmail == $email1) {
+                       // Nothing has been changed is fine...
+                       return true;
                } // END - if
+
+               // Update the "new_email" field
+               $this->partialStub("Unfinished part.");
        }
 }