]> git.mxchange.org Git - shipsimu.git/commitdiff
Email address confirmation now working (not in registration):
authorRoland Häder <roland@mxchange.org>
Mon, 30 Jun 2008 13:56:24 +0000 (13:56 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 30 Jun 2008 13:56:24 +0000 (13:56 +0000)
- 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

26 files changed:
.gitattributes
application/ship-simu/config.php
application/ship-simu/main/registration/class_ShipSimuRegistration.php
application/ship-simu/templates/de/code/block_persona_data.ctp
application/ship-simu/templates/de/code/confirm_link.ctp [new file with mode: 0644]
application/ship-simu/templates/de/code/login_main.ctp
application/ship-simu/templates/de/emails/text_resend_link.tpl
docs/COPYING
inc/classes/main/commands/web/class_WebConfirmCommand.php [new file with mode: 0644]
inc/classes/main/controller/web/class_WebConfirmController.php [new file with mode: 0644]
inc/classes/main/controller/web/class_WebLoginController.php
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
inc/classes/main/filter/change/class_EmailChangeFilter.php
inc/classes/main/filter/change/class_PasswordChangeFilter.php
inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php
inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php [new file with mode: 0644]
inc/classes/main/filter/update/class_UserUpdateFilter.php
inc/classes/main/filter/validator/class_ConfirmCodeValidatorFilter.php [new file with mode: 0644]
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php [new file with mode: 0644]
inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php
inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php
inc/classes/main/helper/class_BaseHelper.php
inc/classes/main/helper/web/blocks/class_WebBlockHelper.php
inc/classes/main/helper/web/class_BaseWebHelper.php
inc/classes/main/template/image/class_ImageTemplateEngine.php

index b34935c1bb488bc36cd5f40189e78b6269f74e38..b183acf6f110b9537586a708f52d62f2014f8e16 100644 (file)
@@ -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
index fcaa33c9dfaab29f189b4dc7c8d63bd1b7a2ea14..ef95a7c428defb530b9e5220896f5e078b8d6030 100644 (file)
@@ -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.");
 
index a4a0b355425e6ed9b1a792b709139031e4f261d0..60dc559df5002e4c0f723736ca871ed09f49ce0d 100644 (file)
@@ -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()));
index 6b01149e67631d67472fa6d29c5dfbcf62e3aea4..f51077b0c0500dae9fdf2fca6742b4f3c9db71e1 100644 (file)
@@ -13,6 +13,9 @@ $helperInstance->prefetchValueInstance('user');
 <div class="gamer_name_div">
        Spielername: <span class="gamer_name">{?block_username?}</span>
 </div>
+<div class="gamer_status_div">
+       Spielerstatus: <span class="gamer_status">{?block_user_status?}</span>
+</div>
 <div class="gamer_profile_div">
        {?profile_link?}
 </div>
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 (file)
index 0000000..75a1885
--- /dev/null
@@ -0,0 +1,13 @@
+<div id="content_header">
+       Best&auml;tigung Deiner Email-Adresse:
+</div>
+
+<div id="content_body">
+       Hallo <span class="data_username">{?username?}</span>! Du hast heute deine
+       Email-Addresse best&auml;tigt, wodurch alle Spielefunktionen entsperrt
+       worden sind. Viel Spass beim Spielen!
+</div>
+
+<div id="content_footer">
+       <a href="$config[base_url]/index.php?app=ship-simu&amp;page=login" title="Direkt zum Login-Formular">Hier geht es direkt zum Login!</a>
+</div>
index 3f66e9a5d713e20f723745817d164dba0b35f2e2..81d3c0abbc945b511cc28ba1b709ca7c4079bf5c 100644 (file)
@@ -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()) {
index 4451ec1c794c2dcb65e1e5df9b645057d28c0817..e5b7a597f738edfb146074ad3b07b0b2febdb8f1 100644 (file)
@@ -11,11 +11,11 @@ Du (oder ein anderer) hattest soeben deinen Best&auml;tigungslink erneut angefor
 
 Hier ist nun dein Best&auml;tigungslink. Der alte aus der Anmeldemail ist somit nicht mehr g&uuml;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&ouml;nnen, versuche diese in die Adresszeile deines Browsers zu kopieren.
 
-Alternativ kannst du im Spielebereich oder im Gastbereich unter Best&auml;tigungscode den folgenden Code reinkopieren oder eingeben:
+Alternativ kannst du im Spielebereich unter Best&auml;tigungscode den folgenden Code reinkopieren oder eingeben:
 
 {?confirm_hash?}
 
index 8d3092e86c6024f0eb7971667ed36d24460ad8cd..23d0d152571c2ce27b579f86b7c80b49e0b04cdc 100644 (file)
@@ -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 (file)
index 0000000..5bfa866
--- /dev/null
@@ -0,0 +1,138 @@
+<?php
+/**
+ * A command for the confirmation link handling
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..975d518
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+/**
+ * Controller for confirmation link
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 6a673e7270eab2698fb46fa361adf1d026df1246..4b10387b1d2bd61d9ed93e18802d569d3f84f79b 100644 (file)
@@ -53,7 +53,6 @@ class WebLoginController extends BaseController implements Controller {
                // Set the command resolver
                $controllerInstance->setResolverInstance($resolverInstance);
 
-
                // Return the prepared instance
                return $controllerInstance;
        }
index 62c7d883f8b7f0d5528c514cc03123e1d4caec87..0669cb8caf3c5186e1f403a66b4c042a71f2d67d 100644 (file)
@@ -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";
index 07b2a21c8768861320f3764ffa3c685e6f057d0e..c427fd69633bc195978385f53697802ce3baeedc 100644 (file)
@@ -36,10 +36,6 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
 
                // Create unique ID number
                $this->generateUniqueId();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
index eab6ace0253411a8ae74607dfd5430f971665f0d..fd3988062f25f6f038f06e52f7e707850a4cde6b 100644 (file)
@@ -36,10 +36,6 @@ class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable {
 
                // Create unique ID number
                $this->generateUniqueId();
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
index de0b77927306b4a05f968caaa54005563f20fd13..8ddbd163a1d04e1734bdc4611085069e0215073a 100644 (file)
@@ -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 (file)
index 0000000..c6da66e
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * A filter for updating the user account status to confirmed
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index babc67c731c93ff831210cef8aa1a0ed061c7515..e1549281d4d3df4c05746c0aca1e309fc79edf2e 100644 (file)
@@ -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 (file)
index 0000000..d29a053
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * A filter for checking if the the supplied confirmation code is valid
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 8fbb3c316cad8e0d9bc2b35d28f795a1061288aa..43927a7d01917e5e5683b5dfb3c359ab4a7a6066 100644 (file)
@@ -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 (file)
index 0000000..e681df4
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * A filter for checking if the the supplied confirmation code is valid
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index e4cfdfb596f8e7f0d9ce1a423aff704eca5bc03a..3b8fe727770c98143c0ec21f2a6ebf96a4a674d0 100644 (file)
@@ -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);
 
index f5ab58d248da507a95c6570b04cf72bf3f549427..d65ca746a291af381828fbf458bdac943c368bc6 100644 (file)
@@ -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);
 
index cc829fd0ea053d00dab82c363d9deee3f77f9c6d..94f48fbbc3a4171d2dd0bf878ca84b165237110e 100644 (file)
@@ -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);
index d8a33eb79960fa66a21c467816764d35650cd426..5f1c43bfd19c71564782177db203f36b26b85fa7 100644 (file)
@@ -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
         *
index e1d5638a063ee3ac2088fa0d4b3c7405d671506c..e3030f7612a156e4fc47fb4c1fcf61772c1e06fe 100644 (file)
@@ -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;
        }
 }
index d60f102359ae04cd55c101a3008181c1d15f17f8..eeb62edd5a5a65e5ce156fb88297d06b8fb4abe0 100644 (file)
@@ -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
         *