From fe76c3626828df10434f15c67a613d8f5d27ff20 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 8 Jun 2008 17:43:32 +0000 Subject: [PATCH] Comments fixed... ;) And pre/post filters for registrations now supported --- application/ship-simu/main/class_ | 2 +- .../class_ShipSimuRegistration.php | 11 +++- inc/classes/main/class_ | 2 +- inc/classes/main/controller/class_ | 2 +- .../main/crypto/class_CryptoHelper.php | 2 +- .../databases/class_LocalFileDatabase.php | 24 +++---- .../checkboxes/class_RulesAcceptedFilter.php | 2 +- inc/classes/main/filter/class_ | 2 +- .../main/filter/null/class_NullFilter.php | 2 +- inc/classes/main/helper/class_ | 2 +- .../registration/class_BaseRegistration.php | 65 ++++++++++++++++++- .../main/rng/class_RandomNumberGenerator.php | 2 +- 12 files changed, 93 insertions(+), 25 deletions(-) diff --git a/application/ship-simu/main/class_ b/application/ship-simu/main/class_ index af4096f..d8eb3ef 100644 --- a/application/ship-simu/main/class_ +++ b/application/ship-simu/main/class_ @@ -23,7 +23,7 @@ */ class extends BaseFrameworkSystem { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/application/ship-simu/main/registration/class_ShipSimuRegistration.php b/application/ship-simu/main/registration/class_ShipSimuRegistration.php index a6639c5..252d05d 100644 --- a/application/ship-simu/main/registration/class_ShipSimuRegistration.php +++ b/application/ship-simu/main/registration/class_ShipSimuRegistration.php @@ -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(); } /** diff --git a/inc/classes/main/class_ b/inc/classes/main/class_ index 8443460..07d96db 100644 --- a/inc/classes/main/class_ +++ b/inc/classes/main/class_ @@ -23,7 +23,7 @@ */ class extends BaseFrameworkSystem { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/controller/class_ b/inc/classes/main/controller/class_ index 2c22f06..0f9c56c 100644 --- a/inc/classes/main/controller/class_ +++ b/inc/classes/main/controller/class_ @@ -23,7 +23,7 @@ */ class Controller extends BaseController implements Controller { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index d236452..fc0cd39 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -38,7 +38,7 @@ class CryptoHelper extends BaseFrameworkSystem { private $salt = ""; /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index e722701..1960794 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -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); diff --git a/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php index e343489..006cc5e 100644 --- a/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php +++ b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php @@ -25,7 +25,7 @@ */ class RulesAcceptedFilter extends BaseFrameworkSystem implements Filterable { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/filter/class_ b/inc/classes/main/filter/class_ index b79b83d..a1feab9 100644 --- a/inc/classes/main/filter/class_ +++ b/inc/classes/main/filter/class_ @@ -23,7 +23,7 @@ */ class ???Filter extends BaseFrameworkSystem implements Filterable { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/filter/null/class_NullFilter.php b/inc/classes/main/filter/null/class_NullFilter.php index 9a8a1ad..a6cbe65 100644 --- a/inc/classes/main/filter/null/class_NullFilter.php +++ b/inc/classes/main/filter/null/class_NullFilter.php @@ -24,7 +24,7 @@ */ class NullFilter extends BaseFrameworkSystem implements Filterable { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/helper/class_ b/inc/classes/main/helper/class_ index 8a1892b..98d4a81 100644 --- a/inc/classes/main/helper/class_ +++ b/inc/classes/main/helper/class_ @@ -23,7 +23,7 @@ */ class extends BaseHelper { /** - * Private constructor + * Protected constructor * * @return void */ diff --git a/inc/classes/main/registration/class_BaseRegistration.php b/inc/classes/main/registration/class_BaseRegistration.php index e2cd781..3066d29 100644 --- a/inc/classes/main/registration/class_BaseRegistration.php +++ b/inc/classes/main/registration/class_BaseRegistration.php @@ -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] diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php index dded7e0..c5c216d 100644 --- a/inc/classes/main/rng/class_RandomNumberGenerator.php +++ b/inc/classes/main/rng/class_RandomNumberGenerator.php @@ -43,7 +43,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { private $rndStrLen = 0; /** - * Private constructor + * Protected constructor * * @param $className Name of this class * @return void -- 2.39.5