]> git.mxchange.org Git - shipsimu.git/commitdiff
Comments fixed... ;) And pre/post filters for registrations now supported
authorRoland Häder <roland@mxchange.org>
Sun, 8 Jun 2008 17:43:32 +0000 (17:43 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 8 Jun 2008 17:43:32 +0000 (17:43 +0000)
12 files changed:
application/ship-simu/main/class_
application/ship-simu/main/registration/class_ShipSimuRegistration.php
inc/classes/main/class_
inc/classes/main/controller/class_
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php
inc/classes/main/filter/class_
inc/classes/main/filter/null/class_NullFilter.php
inc/classes/main/helper/class_
inc/classes/main/registration/class_BaseRegistration.php
inc/classes/main/rng/class_RandomNumberGenerator.php

index af4096f64df8b08521927573a48ac0c0f6ba584e..d8eb3efc4b68b6d10fe8b76a65da8681e08498f5 100644 (file)
@@ -23,7 +23,7 @@
  */
 class  extends BaseFrameworkSystem {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index a6639c5688f00013960e4a98054fc32b9c279b7c..252d05df20457e27e37311af7fe3ff711db0c5ea 100644 (file)
@@ -28,7 +28,7 @@ class ShipSimuRegistration extends BaseRegistration {
        private $hashedPassword = "";
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -52,6 +52,9 @@ class ShipSimuRegistration extends BaseRegistration {
                // Get a new instance
                $registrationInstance = new ShipSimuRegistration();
 
+               // Initialize the filter chains
+               $registrationInstance->initFilterChains();
+
                // And return it
                return $registrationInstance;
        }
@@ -84,7 +87,8 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function doPreRegistration () {
-               $this->partialStub();
+               // First run all pre filters
+               $this->executePreFilters();
        }
 
        /**
@@ -103,7 +107,8 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function doPostRegistration () {
-               $this->partialStub();
+               // First run all post filters
+               $this->executePostFilters();
        }
 
        /**
index 84434608897e137df38a865b9ffcf6d7fe0d5fe2..07d96db97ffc36d819e7ba60b2d41e66204b4a59 100644 (file)
@@ -23,7 +23,7 @@
  */
 class  extends BaseFrameworkSystem {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index 2c22f0647bacf5f31a627579b1bd94f60c5c26d7..0f9c56cf599c21a0108536056657d86009476079 100644 (file)
@@ -23,7 +23,7 @@
  */
 class Controller extends BaseController implements Controller {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index d23645272f79cdb47b41cf32ea342fec6f15864e..fc0cd39b806d64da5c7ba365e14d691e060b84bd 100644 (file)
@@ -38,7 +38,7 @@ class CryptoHelper extends BaseFrameworkSystem {
        private $salt = "";
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index e7227015a142ead96147ae9e6ed256d8dc5df6a1..1960794377b30c5dd218a16a5f14dfe3470631ee 100644 (file)
@@ -86,10 +86,10 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * Create an object of LocalFileDatabase and set the save path for local files.
         * This method also validates the given file path.
         *
-        * @param       $savePath               The local file path string
-        * @param       $ioInstance             The input/output handler. This
-        *                                                      should be FileIoHandler
-        * @return      $dbInstance             An instance of LocalFileDatabase
+        * @param               $savePath                                       The local file path string
+        * @param               $ioInstance                             The input/output handler. This
+        *                                                                      should be FileIoHandler
+        * @return      $dbInstance                             An instance of LocalFileDatabase
         */
        public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) {
                // Get an instance
@@ -151,7 +151,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * Saves a given object to the local file system by serializing and
         * transparently compressing it
         *
-        * @param       $object                                 The object we shall save to the local file system
+        * @param               $object                         The object we shall save to the local file system
         * @return      void
         * @throws      NullPointerException    If the object instance is null
         * @throws      NoObjectException               If the parameter $object is not
@@ -186,7 +186,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        /**
         * Get a serialized string from the given object
         *
-        * @param       $object         The object we want to serialize and transparently
+        * @param               $object         The object we want to serialize and transparently
         *                                              compress
         * @return      $serialized     A string containing the serialzed/compressed object
         * @see         ObjectLimits    An object holding limition information
@@ -218,12 +218,12 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * Analyses if a unique ID has already been used or not by search in the
         * local database folder.
         *
-        * @param       $uniqueID               A unique ID number which shall be checked
-        *                                                      before it will be used
-        * @param       $inConstructor  If we got called in a de/con-structor or
-        *                                                      from somewhere else
+        * @param               $uniqueID               A unique ID number which shall be checked
+        *                                              before it will be used
+        * @param               $inConstructor  If we got called in a de/con-structor or
+        *                                              from somewhere else
         * @return      $isUnused               true    = The unique ID was not found in the database,
-        *                                                      false = It is already in use by an other object
+        *                                              false = It is already in use by an other object
         * @throws      NoArrayCreatedException If explode() fails to create an array
         * @throws      InvalidArrayCountException      If the array contains less or
         *                                                                      more than two elements
@@ -274,7 +274,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
 
                // Initialize the search loop
                $isValid = false;
-               while ($dataFile = $dirInstance->readDirectoryExcept(array(".", ".."))) {
+               while ($dataFile = $dirInstance->readDirectoryExcept(array(".", "..", ".htaccess"))) {
                        // Generate FQFN for testing
                        $fqfn = sprintf("%s/%s", $pathName, $dataFile);
                        $this->setLastFile($fqfn);
index e3434890b7a17e2672459189b3d68cead0180346..006cc5e1d78b03644b3ff0f8aba9cd734b8f625f 100644 (file)
@@ -25,7 +25,7 @@
  */
 class RulesAcceptedFilter extends BaseFrameworkSystem implements Filterable {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index b79b83d21046e0abbd5bb3775cc7b2c845a570f5..a1feab9084816ea59e402130841281233142cb70 100644 (file)
@@ -23,7 +23,7 @@
  */
 class ???Filter extends BaseFrameworkSystem implements Filterable {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index 9a8a1ad6848f1a0e8c7803a53e085317e9d21ef0..a6cbe65387e82aadd6e083dc90f7f1204824265d 100644 (file)
@@ -24,7 +24,7 @@
  */
 class NullFilter extends BaseFrameworkSystem implements Filterable {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index 8a1892b8a0b6badcb43a2e6247ef9045befcbf8c..98d4a81bd9deb804e1756594a87ec9c4e598f4f1 100644 (file)
@@ -23,7 +23,7 @@
  */
 class  extends BaseHelper {
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
index e2cd7812635dec18f43aafa4ccf8f15f0413877c..3066d2989d8d369c6cd88fdccd73f54991a18d36 100644 (file)
@@ -33,7 +33,17 @@ abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegis
        private $responseInstance = null;
 
        /**
-        * Private constructor
+        * Pre-registration filter chain
+        */
+       private $preRegistrationFilter = null;
+
+       /**
+        * Pre-registration filter chain
+        */
+       private $postRegistrationFilter = null;
+
+       /**
+        * Protected constructor
         *
         * @param       $className      Name of the class
         * @return      void
@@ -47,6 +57,17 @@ abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegis
                $this->removeSystemArray();
        }
 
+       /**
+        * Initialize filters. This must be done before you can use them
+        *
+        * @return      void
+        */
+       protected function initFilterChains () {
+               // Pre/post-registration filters
+               $this->preRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain');
+               $this->postRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain');
+       }
+
        /**
         * Setter for request instance
         *
@@ -84,6 +105,48 @@ abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegis
        public final function getResponseInstance () {
                return $this->responseInstance;
        }
+
+       /**
+        * Adds a filter to the pre filter chain
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       public function addPreFilter (Filterable $filterInstance) {
+               // Add the pre filter
+               $this->preRegistrationFilter->addFilter($filterInstance);
+       }
+
+       /**
+        * Adds a filter to the post filter chain
+        *
+        * @param       $filterInstance         An instance of a filter
+        * @return      void
+        */
+       public function addPostFilter (Filterable $filterInstance) {
+               // Add the post filter
+               $this->postRegistrationFilter->addFilter($filterInstance);
+       }
+
+       /**
+        * Executes all pre filters
+        *
+        * @return      void
+        */
+       protected function executePreFilters () {
+               // Execute all pre filters
+               $this->preRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance());
+       }
+
+       /**
+        * Executes all post filters
+        *
+        * @return      void
+        */
+       protected function executePostFilters () {
+               // Execute all post filters
+               $this->postRegistrationFilter->processFilters($this->requestInstance, $this->responseInstance);
+       }
 }
 
 // [EOF]
index dded7e0b40613c6ec7851484bbb4aa2869d65fa4..c5c216d2a9e2f0397abcdcc8e0e799a343ac7ed9 100644 (file)
@@ -43,7 +43,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
        private $rndStrLen = 0;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @param       $className      Name of this class
         * @return      void