More improvements and fixes:
[shipsimu.git] / application / ship-simu / main / commands / web / class_WebShipsimuProfileCommand.php
index 18adfa07126ac6df9f36aceda90d65854fbab076..e8aff7d0e414ee3527f558763b068205d04bf5e1 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -55,12 +55,6 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Registration handling command for Ship-Simu");
-
-               // Create unique ID number
-               $this->generateUniqueId();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
@@ -79,14 +73,6 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
                // Set the resolver instance
                $commandInstance->setResolverInstance($resolverInstance);
 
-               // Get the controller instance from the resolver (breaks MVC pattern again)
-               $controllerInstance = $resolverInstance->getControllerInstance();
-
-               /* @TODO Add some more pre/post filters to the controller */
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_change_class'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_change_class'));
-
                // Return the prepared instance
                return $commandInstance;
        }
@@ -97,17 +83,24 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
+        * @todo        Add functionality here
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Make sure only allowed values are comming through
-               foreach ($this->allowedData as $alias=>$element) {
+               foreach ($this->allowedData as $alias => $element) {
+                       // Get data
+                       $data = $requestInstance->getRequestElement($element);
+
+                       // Silently skip empty fields
+                       if (empty($data)) continue;
+
                        // Do we have an alias?
                        if (is_string($alias)) {
                                // Yes, so use it
-                               $this->requestData[$alias]   = $requestInstance->getRequestElement($element);
+                               $this->requestData[$alias]   = $data;
                        } else {
                                // No, default entry
-                               $this->requestData[$element] = $requestInstance->getRequestElement($element);
+                               $this->requestData[$element] = $data;
                        }
                } // END - foreach
 
@@ -115,21 +108,41 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable {
                unset($this->allowedData);
 
                // Unfinished!
-               $this->debugInstance();
+               $this->partialStub("Unfinished work.");
+               $this->debugBackTrace();
        }
 
        /**
         * Adds extra filters to the given controller instance
         *
         * @param       $controllerInstance             A controller instance
+        * @param       $requestInstance                An instance of a class with an Requestable interface
         * @return      void
+        * @todo        Add some more pre/post filters to the controller
         */
-       function addExtraFilters (Controller $controllerInstance) {
+       public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Add user auth filter (we don't need an update of the user here because it will be redirected)
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
+
+               // User status filter
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
+
+               // Updated rules accepted
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_filter'));
+
+               // Account password validation
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('account_password_filter'));
+
+               // Validate CAPTCHA input
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_profile_verifier_filter'));
+
+               // Email changed
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_change_filter'));
+
+               // Password changed
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_change_filter'));
        }
 }
 
 // [EOF]
 ?>
-