From a550aa5e5aea2ecddfe0166e96bea62b01c7450e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 30 Jun 2008 13:56:24 +0000 Subject: [PATCH] Email address confirmation now working (not in registration): - Confirmation link extended with username to make looking the user account up much more easier - Confirmation of email address now working but still no email is send in registration procedure - Current user's status now displayed in login area - Some minor code rewrites --- .gitattributes | 6 + application/ship-simu/config.php | 12 ++ .../class_ShipSimuRegistration.php | 10 +- .../templates/de/code/block_persona_data.ctp | 3 + .../templates/de/code/confirm_link.ctp | 13 ++ .../templates/de/code/login_main.ctp | 1 + .../templates/de/emails/text_resend_link.tpl | 4 +- docs/COPYING | 5 +- .../commands/web/class_WebConfirmCommand.php | 138 ++++++++++++++++++ .../web/class_WebConfirmController.php | 94 ++++++++++++ .../web/class_WebLoginController.php | 1 - .../wrapper/class_UserDatabaseWrapper.php | 1 + .../filter/change/class_EmailChangeFilter.php | 4 - .../change/class_PasswordChangeFilter.php | 4 - .../crypto/class_CaptchaEncryptFilter.php | 4 - .../class_UserStatusConfimedUpdateFilter.php | 80 ++++++++++ .../filter/update/class_UserUpdateFilter.php | 4 - .../class_ConfirmCodeValidatorFilter.php | 89 +++++++++++ .../class_UserNameValidatorFilter.php | 2 +- .../class_ConfirmCodeVerifierFilter.php | 114 +++++++++++++++ .../class_UserStatusVerifierFilter.php | 6 +- .../class_UserUnconfirmedVerifierFilter.php | 6 +- inc/classes/main/helper/class_BaseHelper.php | 2 +- .../web/blocks/class_WebBlockHelper.php | 17 +++ .../main/helper/web/class_BaseWebHelper.php | 6 +- .../image/class_ImageTemplateEngine.php | 27 ++++ 26 files changed, 614 insertions(+), 39 deletions(-) create mode 100644 application/ship-simu/templates/de/code/confirm_link.ctp create mode 100644 inc/classes/main/commands/web/class_WebConfirmCommand.php create mode 100644 inc/classes/main/controller/web/class_WebConfirmController.php create mode 100644 inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php create mode 100644 inc/classes/main/filter/validator/class_ConfirmCodeValidatorFilter.php create mode 100644 inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php diff --git a/.gitattributes b/.gitattributes index b34935c..b183acf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -147,6 +147,7 @@ application/ship-simu/templates/de/code/action_login_welcome.ctp -text application/ship-simu/templates/de/code/block_company_data.ctp -text application/ship-simu/templates/de/code/block_persona_data.ctp -text application/ship-simu/templates/de/code/captch_graphic_code.ctp -text +application/ship-simu/templates/de/code/confirm_link.ctp -text application/ship-simu/templates/de/code/footer.ctp -text application/ship-simu/templates/de/code/header.ctp -text application/ship-simu/templates/de/code/home.ctp -text @@ -398,6 +399,7 @@ inc/classes/main/commands/class_BaseCommand.php -text inc/classes/main/commands/image/.htaccess -text inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php -text inc/classes/main/commands/web/.htaccess -text +inc/classes/main/commands/web/class_WebConfirmCommand.php -text inc/classes/main/commands/web/class_WebDoFormCommand.php -text inc/classes/main/commands/web/class_WebHomeCommand.php -text inc/classes/main/commands/web/class_WebLoginAreaCommand.php -text @@ -425,6 +427,7 @@ inc/classes/main/controller/image/class_ImageDefaultController.php -text inc/classes/main/controller/login/.htaccess -text inc/classes/main/controller/login/class_WebLoginAreaController.php -text inc/classes/main/controller/web/.htaccess -text +inc/classes/main/controller/web/class_WebConfirmController.php -text inc/classes/main/controller/web/class_WebDefaultController.php -text inc/classes/main/controller/web/class_WebDefaultNewsController.php -text inc/classes/main/controller/web/class_WebLoginController.php -text @@ -481,13 +484,16 @@ inc/classes/main/filter/news/class_NewsProcessFilter.php -text inc/classes/main/filter/null/.htaccess -text inc/classes/main/filter/null/class_NullFilter.php -text inc/classes/main/filter/update/.htaccess -text +inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php -text inc/classes/main/filter/update/class_UserUpdateFilter.php -text inc/classes/main/filter/validator/.htaccess -text +inc/classes/main/filter/validator/class_ConfirmCodeValidatorFilter.php -text inc/classes/main/filter/validator/class_EmailValidatorFilter.php -text inc/classes/main/filter/validator/class_PasswordValidatorFilter.php -text inc/classes/main/filter/validator/class_UserNameValidatorFilter.php -text inc/classes/main/filter/verifier/.htaccess -text inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php -text +inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php -text inc/classes/main/filter/verifier/class_EmailValidatorFilter.php -text inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php -text inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php -text diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index fcaa33c..ef95a7c 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -112,6 +112,9 @@ $cfg->setConfigEntry('user_not_unconfirmed_url', "index.php?app=ship-simu&page=s // CFG: USER-UNCONFIRMED-EMAIL-MISSING-URL $cfg->setConfigEntry('user_unconfirmed_email_missing_url', "index.php?app=ship-simu&page=status&status=unconfirmed_email_missing"); +// CFG: CONFIRM-CODE-INVALID-URL +$cfg->setConfigEntry('confirm_code_invalid_url', "index.php?app=ship-simu&page=status&status=confirm_code_invalid"); + // CFG: LOGIN-DEFAULT-ACTION $cfg->setConfigEntry('login_default_action', "welcome"); @@ -130,6 +133,9 @@ $cfg->setConfigEntry('user_auth_class', "UserAuthFilter"); // CFG: USER-UPDATE-CLASS $cfg->setConfigEntry('user_update_class', "UserUpdateFilter"); +// CFG: USER-STATUS-CONFIRMED-CLASS +$cfg->setConfigEntry('user_status_confirmed_class', "UserStatusConfimedUpdateFilter"); + // CFG: CAPTCHA-ENCRYPT-VALIDATOR-CLASS $cfg->setConfigEntry('captcha_encrypt_validator_class', "CaptchaEncryptFilter"); @@ -142,6 +148,9 @@ $cfg->setConfigEntry('captcha_user_verifier_class', "GraphicalCodeCaptchaVerifie // CFG: CAPTCHA-REGISTER-VERIFIER-CLASS $cfg->setConfigEntry('captcha_register_verifier_class', "GraphicalCodeCaptchaVerifierFilter"); +// CFG: CONFIRM-CODE-VALIDATOR-CLASS +$cfg->setConfigEntry('confirm_code_verifier_class', "ConfirmCodeVerifierFilter"); + // CFG: NEWS-HOME-LIMIT $cfg->setConfigEntry('news_home_limit', 10); @@ -151,6 +160,9 @@ $cfg->setConfigEntry('news_login_area_limit', 15); // CFG: LOGIN-ENABLED $cfg->setConfigEntry('login_enabled', "Y"); +// CFG: CONFIRM-EMAIL-ENABLED +$cfg->setConfigEntry('confirm_email_enabled', "Y"); + // CFG: LOGIN-DISABLED-REASON $cfg->setConfigEntry('login_disabled_reason', "Loginbereich befindet sich noch im Aufbau."); diff --git a/application/ship-simu/main/registration/class_ShipSimuRegistration.php b/application/ship-simu/main/registration/class_ShipSimuRegistration.php index a4a0b35..60dc559 100644 --- a/application/ship-simu/main/registration/class_ShipSimuRegistration.php +++ b/application/ship-simu/main/registration/class_ShipSimuRegistration.php @@ -159,9 +159,15 @@ class ShipSimuRegistration extends BaseRegistration { * @return void */ public function addElementsToDataSet (StoreableCriteria $criteriaInstance) { - // Default is user account! + // Default is unconfirmed! $configEntry = 'user_status_unconfirmed'; + // Is the confirmation process entirely disabled? + if ($this->getConfigInstance()->readConfig('confirm_email_enabled') === "N") { + // No confirmation of email needed + $configEntry = 'user_status_confirmed'; + } // END - if + // Add a lot elements to the dataset criteria foreach ($this->criteriaElements as $alias=>$element) { // Do we have an alias? @@ -184,7 +190,7 @@ class ShipSimuRegistration extends BaseRegistration { $criteriaInstance->setUniqueKey('username'); // Add account status as configured - $criteriaInstance->addConfiguredCriteria('user_status', $configEntry); + $criteriaInstance->addConfiguredCriteria(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $configEntry); // Include registration timestamp $criteriaInstance->addCriteria('registered', date("Y-m-d H:i:s", time())); diff --git a/application/ship-simu/templates/de/code/block_persona_data.ctp b/application/ship-simu/templates/de/code/block_persona_data.ctp index 6b01149..f51077b 100644 --- a/application/ship-simu/templates/de/code/block_persona_data.ctp +++ b/application/ship-simu/templates/de/code/block_persona_data.ctp @@ -13,6 +13,9 @@ $helperInstance->prefetchValueInstance('user');
Spielername: {?block_username?}
+
+ Spielerstatus: {?block_user_status?} +
{?profile_link?}
diff --git a/application/ship-simu/templates/de/code/confirm_link.ctp b/application/ship-simu/templates/de/code/confirm_link.ctp new file mode 100644 index 0000000..75a1885 --- /dev/null +++ b/application/ship-simu/templates/de/code/confirm_link.ctp @@ -0,0 +1,13 @@ +
+ Bestätigung Deiner Email-Adresse: +
+ +
+ Hallo {?username?}! Du hast heute deine + Email-Addresse bestätigt, wodurch alle Spielefunktionen entsperrt + worden sind. Viel Spass beim Spielen! +
+ + diff --git a/application/ship-simu/templates/de/code/login_main.ctp b/application/ship-simu/templates/de/code/login_main.ctp index 3f66e9a..81d3c0a 100644 --- a/application/ship-simu/templates/de/code/login_main.ctp +++ b/application/ship-simu/templates/de/code/login_main.ctp @@ -11,6 +11,7 @@ $blockInstance->prefetchValueInstance('user'); // Assign fields with template variables $blockInstance->assignField('username'); +$blockInstance->assignFieldWithFilter('user_status', "user_status_translator"); // Shall we include registration date? if ($blockInstance->ifIncludeRegistrationStamp()) { diff --git a/application/ship-simu/templates/de/emails/text_resend_link.tpl b/application/ship-simu/templates/de/emails/text_resend_link.tpl index 4451ec1..e5b7a59 100644 --- a/application/ship-simu/templates/de/emails/text_resend_link.tpl +++ b/application/ship-simu/templates/de/emails/text_resend_link.tpl @@ -11,11 +11,11 @@ Du (oder ein anderer) hattest soeben deinen Bestätigungslink erneut angefor Hier ist nun dein Bestätigungslink. Der alte aus der Anmeldemail ist somit nicht mehr gültig! -$config[base_url]/index.php?app=ship-simu&page=confirm&confirm={?confirm_hash?} +$config[base_url]/index.php?app=ship-simu&page=confirm&username={?username?}&confirm={?confirm_hash?} Solltest du die URL nicht anklicken können, versuche diese in die Adresszeile deines Browsers zu kopieren. -Alternativ kannst du im Spielebereich oder im Gastbereich unter Bestätigungscode den folgenden Code reinkopieren oder eingeben: +Alternativ kannst du im Spielebereich unter Bestätigungscode den folgenden Code reinkopieren oder eingeben: {?confirm_hash?} diff --git a/docs/COPYING b/docs/COPYING index 8d3092e..23d0d15 100644 --- a/docs/COPYING +++ b/docs/COPYING @@ -1,7 +1,6 @@ -For scripts, except shell scripts, templates and compileable templates see -COPYING.software. +For PHP scripts except templates and compileable templates see COPYING.software. For documents see COPYING.documents. -The rest of the scripts (shell, templates, code templates) are given away +The rest of the software (shell scripts, templates, code templates) are given away "AS IS" and "WITHOUT ANY WARRANTY". So it shall be public domain. diff --git a/inc/classes/main/commands/web/class_WebConfirmCommand.php b/inc/classes/main/commands/web/class_WebConfirmCommand.php new file mode 100644 index 0000000..5bfa866 --- /dev/null +++ b/inc/classes/main/commands/web/class_WebConfirmCommand.php @@ -0,0 +1,138 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebConfirmCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set special description + $this->setObjectDescription("Command for confirmation link handling"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createWebConfirmCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new WebConfirmCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($appInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($appInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $appInstance->getMasterTemplate(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('confirm_link'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('confirm_link', 'content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title')); + + // Get user instance + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Set username + $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME)); + + // ... and all variables. This should be merged together in a pattern + // to make things easier. A cache mechanism should be added between + // these two calls to cache compiled templates. + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in the response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * 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 + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebConfirmController.php b/inc/classes/main/controller/web/class_WebConfirmController.php new file mode 100644 index 0000000..975d518 --- /dev/null +++ b/inc/classes/main/controller/web/class_WebConfirmController.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebConfirmController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("Controller for confirmation link handling"); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createWebConfirmController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebConfirmController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filters for handling confirmation code and username + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_class')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/web/class_WebLoginController.php b/inc/classes/main/controller/web/class_WebLoginController.php index 6a673e7..4b10387 100644 --- a/inc/classes/main/controller/web/class_WebLoginController.php +++ b/inc/classes/main/controller/web/class_WebLoginController.php @@ -53,7 +53,6 @@ class WebLoginController extends BaseController implements Controller { // Set the command resolver $controllerInstance->setResolverInstance($resolverInstance); - // Return the prepared instance return $controllerInstance; } diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index 62c7d88..0669cb8 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -29,6 +29,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { const DB_COLUMN_USERNAME = "username"; const DB_COLUMN_EMAIL = "email"; const DB_COLUMN_CONFIRM_HASH = "confirm_hash"; + const DB_COLUMN_USER_STATUS = "user_status"; // Constants for database table names const DB_TABLE_USER = "user"; diff --git a/inc/classes/main/filter/change/class_EmailChangeFilter.php b/inc/classes/main/filter/change/class_EmailChangeFilter.php index 07b2a21..c427fd6 100644 --- a/inc/classes/main/filter/change/class_EmailChangeFilter.php +++ b/inc/classes/main/filter/change/class_EmailChangeFilter.php @@ -36,10 +36,6 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable { // Create unique ID number $this->generateUniqueId(); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** diff --git a/inc/classes/main/filter/change/class_PasswordChangeFilter.php b/inc/classes/main/filter/change/class_PasswordChangeFilter.php index eab6ace..fd39880 100644 --- a/inc/classes/main/filter/change/class_PasswordChangeFilter.php +++ b/inc/classes/main/filter/change/class_PasswordChangeFilter.php @@ -36,10 +36,6 @@ class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable { // Create unique ID number $this->generateUniqueId(); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** diff --git a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php index de0b779..8ddbd16 100644 --- a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php +++ b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php @@ -36,10 +36,6 @@ class CaptchaEncryptFilter extends BaseFrameworkSystem implements Filterable { // Create unique ID number $this->generateUniqueId(); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** diff --git a/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php b/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php new file mode 100644 index 0000000..c6da66e --- /dev/null +++ b/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php @@ -0,0 +1,80 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserStatusConfimedUpdateFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("User status 'confirmed' update filter"); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createUserStatusConfimedUpdateFilter () { + // Get a new instance + $filterInstance = new UserStatusConfimedUpdateFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get "confirmed" status from config + $confirmed = $this->getConfigInstance()->readConfig('user_status_confirmed'); + + // Update the user status to "confirmed" here + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $confirmed); + + // Wipe out the confirm hash for extra security + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, ""); + + // Write all updates to the database + $userInstance->flushPendingUpdates(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/update/class_UserUpdateFilter.php b/inc/classes/main/filter/update/class_UserUpdateFilter.php index babc67c..e154928 100644 --- a/inc/classes/main/filter/update/class_UserUpdateFilter.php +++ b/inc/classes/main/filter/update/class_UserUpdateFilter.php @@ -37,10 +37,6 @@ class UserUpdateFilter extends BaseFrameworkSystem implements Filterable { // Create unique ID number $this->generateUniqueId(); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** diff --git a/inc/classes/main/filter/validator/class_ConfirmCodeValidatorFilter.php b/inc/classes/main/filter/validator/class_ConfirmCodeValidatorFilter.php new file mode 100644 index 0000000..d29a053 --- /dev/null +++ b/inc/classes/main/filter/validator/class_ConfirmCodeValidatorFilter.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfirmCodeValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("A filter for ConfirmCode validation"); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createConfirmCodeValidatorFilter () { + // Get a new instance + $filterInstance = new ConfirmCodeValidatorFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get confirmation code from request + $confirmCode = $requestInstance->getRequestElement('confirm'); + + // Is this code set? + if (is_null($confirmCode)) { + // Is not in request + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_unset'); + + // Abort here + return false; + } elseif (empty($confirmCode)) { + // Email is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_empty'); + + // Abort here + return false; + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php index 8fbb3c3..43927a7 100644 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -134,7 +134,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable { if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) { // This username is still available $alreadyTaken = false; - } + } // END - if // Return the result return $alreadyTaken; diff --git a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php new file mode 100644 index 0000000..e681df4 --- /dev/null +++ b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @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 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("A filter for confirmation code verification"); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createConfirmCodeVerifierFilter () { + // Get a new instance + $filterInstance = new ConfirmCodeVerifierFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws NullPointerException If the user instance from registry is null + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get confirmation code from request + $confirmCode = $requestInstance->getRequestElement('confirm'); + + // Is this code set? + if (is_null($confirmCode)) { + // Is not in request + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_unset'); + + // Abort here + return false; + } elseif (empty($confirmCode)) { + // Email is empty + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_empty'); + + // Abort here + return false; + } + + // Get a user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Is the instance there? + if (is_null($userInstance)) { + // Throw an exception here + throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the confirm code from user for comparison + $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH); + + // Do we have the same code or different? + if ($userCode != $confirmCode) { + // Email is empty + $requestInstance->requestIsValid(false); + + // Redirect to error page + $responseInstance->redirectToConfiguredUrl('confirm_code_invalid_url'); + + // Stop processing here + exit; + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php index e4cfdfb..3b8fe72 100644 --- a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php @@ -36,10 +36,6 @@ class UserStatusVerifierFilter extends BaseFrameworkSystem implements Filterable // Create unique ID number $this->generateUniqueId(); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -67,7 +63,7 @@ class UserStatusVerifierFilter extends BaseFrameworkSystem implements Filterable $userInstance = Registry::getRegistry()->getInstance('user'); // Is the user account confirmed? - if (($userInstance->getField('user_status') != $this->getConfigInstance()->readConfig('user_status_confirmed')) && ($userInstance->getField('user_status') != $this->getConfigInstance()->readConfig('user_status_guest'))) { + if (($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->readConfig('user_status_confirmed')) && ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->readConfig('user_status_guest'))) { // Request is invalid! $requestInstance->requestIsValid(false); diff --git a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php index f5ab58d..d65ca74 100644 --- a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -36,10 +36,6 @@ class UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filte // Create unique ID number $this->generateUniqueId(); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -79,7 +75,7 @@ class UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filte } // END - if // Is the user account confirmed? - if ($userInstance->getField('user_status') != $this->getConfigInstance()->readConfig('user_status_unconfirmed')) { + if ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->readConfig('user_status_unconfirmed')) { // Request is invalid! $requestInstance->requestIsValid(false); diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index cc829fd..94f48fb 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -99,7 +99,7 @@ class BaseHelper extends BaseFrameworkSystem { $fieldValue = $this->getValueField($fieldName); // Now filter it through the value through the filter method - $filteredValue = call_user_func_array(array($this, "doFilter" . ucfirst($filterMethod)), array($fieldValue)); + $filteredValue = call_user_func_array(array($this, "doFilter" . $this->convertToClassName($filterMethod)), array($fieldValue)); // Assign it with a template variable $this->getTemplateInstance()->assignVariable("block_" . $fieldName, $filteredValue); diff --git a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php index d8a33eb..5f1c43b 100644 --- a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php +++ b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php @@ -116,6 +116,23 @@ class WebBlockHelper extends BaseWebHelper implements HelpableTemplate { $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); } + /** + * "Filter" method for translating the raw user status into something human-readable + * + * @param $userStatus Raw user status from database layer + * @return $translated Translated user status + */ + protected function doFilterUserStatusTranslator ($userStatus) { + // Generate message id + $messageId = 'user_status_' . strtolower($userStatus); + + // Get that message + $translated = $this->getLanguageInstance()->getMessage($messageId); + + // Return it + return $translated; + } + /** * Flush the content out,e g. to a template variable * diff --git a/inc/classes/main/helper/web/class_BaseWebHelper.php b/inc/classes/main/helper/web/class_BaseWebHelper.php index e1d5638..e3030f7 100644 --- a/inc/classes/main/helper/web/class_BaseWebHelper.php +++ b/inc/classes/main/helper/web/class_BaseWebHelper.php @@ -160,7 +160,7 @@ class BaseWebHelper extends BaseHelper { * @return $isUnconfirmed Wether the user account is unconfirmed */ public function ifUserAccountUnconfirmed () { - $isUnconfirmed = ($this->getValueField('user_status') === $this->getConfigInstance()->readConfig('user_status_unconfirmed')); + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_unconfirmed')); return $isUnconfirmed; } @@ -170,7 +170,7 @@ class BaseWebHelper extends BaseHelper { * @return $isUnconfirmed Wether the user account is locked */ public function ifUserAccountLocked () { - $isUnconfirmed = ($this->getValueField('user_status') === $this->getConfigInstance()->readConfig('user_status_locked')); + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_locked')); return $isUnconfirmed; } @@ -180,7 +180,7 @@ class BaseWebHelper extends BaseHelper { * @return $isUnconfirmed Wether the user account is a guest */ public function ifUserAccountGuest () { - $isUnconfirmed = ($this->getValueField('user_status') === $this->getConfigInstance()->readConfig('user_status_guest')); + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_guest')); return $isUnconfirmed; } } diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php index d60f102..eeb62ed 100644 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -112,6 +112,33 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl return $tplInstance; } + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->currMainNode; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + /** * Handles the start element of an XML resource * -- 2.39.5