User login (non-guest) basicly finished, news stubs added, registration and final...
authorRoland Häder <roland@mxchange.org>
Wed, 18 Jun 2008 15:19:34 +0000 (15:19 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 18 Jun 2008 15:19:34 +0000 (15:19 +0000)
37 files changed:
.gitattributes
application/ship-simu/class_ApplicationHelper.php
application/ship-simu/config.php
application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php [new file with mode: 0644]
application/ship-simu/main/login/class_ShipSimuUserLogin.php
application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php
application/ship-simu/templates/de/code/login_form.ctp [new file with mode: 0644]
application/ship-simu/templates/de/code/register.ctp [deleted file]
application/ship-simu/templates/de/code/register_form.ctp [new file with mode: 0644]
inc/classes/exceptions/result/.htaccess [new file with mode: 0644]
inc/classes/exceptions/result/class_InvalidDatabaseResultException.php [new file with mode: 0644]
inc/classes/interfaces/template/class_CompileableTemplate.php
inc/classes/main/commands/web/class_WebHomeCommand.php
inc/classes/main/commands/web/class_WebLoginAreaCommand.php
inc/classes/main/commands/web/class_WebLoginCommand.php [new file with mode: 0644]
inc/classes/main/commands/web/class_WebRegisterCommand.php
inc/classes/main/controller/default/class_WebDefaultController.php
inc/classes/main/controller/default/class_WebLoginController.php [new file with mode: 0644]
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php [new file with mode: 0644]
inc/classes/main/filter/news/class_NewsDownloadFilter.php
inc/classes/main/filter/verifier/.htaccess [new file with mode: 0644]
inc/classes/main/filter/verifier/class_EmailValidatorFilter.php [new file with mode: 0644]
inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php [new file with mode: 0644]
inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php [new file with mode: 0644]
inc/classes/main/helper/web/class_WebFormHelper.php
inc/classes/main/reader/class_DefaultNewsReader.php
inc/classes/main/registration/class_BaseRegistration.php
inc/classes/main/resolver/web/class_WebControllerResolver.php
inc/classes/main/response/class_HttpResponse.php
inc/classes/main/result/class_DatabaseResult.php
inc/classes/main/rng/class_RandomNumberGenerator.php
inc/classes/main/template/class_TemplateEngine.php
inc/classes/main/user/class_User.php
inc/config.php
inc/loader/class_ClassLoader.php
index.php

index 50e64d5ec2c2a8a02ae65f955c1c2d6035e58565..eb798ccbc18d683b1a11d3953ae4e1433166d55d 100644 (file)
@@ -62,6 +62,7 @@ application/ship-simu/main/class_WorksContract.php -text
 application/ship-simu/main/commands/.htaccess -text
 application/ship-simu/main/commands/web/.htaccess -text
 application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php -text
+application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php -text
 application/ship-simu/main/companies/.htaccess -text
 application/ship-simu/main/companies/class_ShippingCompany.php -text
 application/ship-simu/main/constructions/.htaccess -text
@@ -130,7 +131,8 @@ 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
 application/ship-simu/templates/de/code/login_failed.ctp -text
-application/ship-simu/templates/de/code/register.ctp -text
+application/ship-simu/templates/de/code/login_form.ctp -text
+application/ship-simu/templates/de/code/register_form.ctp -text
 application/ship-simu/templates/de/code/shipsimu_main.ctp -text
 application/ship-simu/templates/de/html/.htaccess -text
 application/ship-simu/templates/de/html/nav_advert.tpl -text
@@ -222,6 +224,8 @@ inc/classes/exceptions/main/class_NoObjectException.php -text
 inc/classes/exceptions/main/class_NullPointerException.php -text
 inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php -text
 inc/classes/exceptions/main/class_VariableIsNotSetException.php -text
+inc/classes/exceptions/result/.htaccess -text
+inc/classes/exceptions/result/class_InvalidDatabaseResultException.php -text
 inc/classes/exceptions/template/.htaccess -text
 inc/classes/exceptions/template/class_BasePathIsEmptyException.php -text
 inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php -text
@@ -321,6 +325,7 @@ inc/classes/main/commands/web/.htaccess -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
+inc/classes/main/commands/web/class_WebLoginCommand.php -text
 inc/classes/main/commands/web/class_WebLoginFailedCommand.php -text
 inc/classes/main/commands/web/class_WebRegisterCommand.php -text
 inc/classes/main/compressor/.htaccess -text
@@ -335,6 +340,7 @@ inc/classes/main/controller/class_BaseController.php -text
 inc/classes/main/controller/default/.htaccess -text
 inc/classes/main/controller/default/class_WebDefaultController.php -text
 inc/classes/main/controller/default/class_WebDefaultNewsController.php -text
+inc/classes/main/controller/default/class_WebLoginController.php -text
 inc/classes/main/controller/default/class_WebLoginFailedController.php -text
 inc/classes/main/controller/form/.htaccess -text
 inc/classes/main/controller/form/class_WebDoFormController.php -text
@@ -352,6 +358,7 @@ inc/classes/main/database/class_BaseDatabaseWrapper.php -text
 inc/classes/main/database/databases/.htaccess -text
 inc/classes/main/database/databases/class_LocalFileDatabase.php -text
 inc/classes/main/database/wrapper/.htaccess -text
+inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php -text
 inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php -text
 inc/classes/main/debug/.htaccess -text
 inc/classes/main/debug/class_DebugConsoleOutput.php -text
@@ -387,6 +394,10 @@ inc/classes/main/filter/validator/.htaccess -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_EmailValidatorFilter.php -text
+inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php -text
+inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php -text
 inc/classes/main/helper/.htaccess -text
 inc/classes/main/helper/class_ -text
 inc/classes/main/helper/class_BaseHelper.php -text
index c8057d44099809b2b8d7a9cef3a2290f51023be6..f499c4817cacc3493d79ee967f05a18229472fe4 100644 (file)
@@ -185,7 +185,11 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                $requestInstance = ObjectFactory::createObjectByName('HttpRequest');
 
                // ... and a new response object
-               $responseInstance = HttpResponse::createHttpResponse($this);
+               $responseInstance = ObjectFactory::createObjectByName('HttpResponse', array($this));
+
+               // Remember both in this application
+               $this->setRequestInstance($requestInstance);
+               $this->setResponseInstance($responseInstance);
 
                // Get the parameter from the request
                $commandName = $requestInstance->getRequestElement("page");
index 1e1604e66aa5922f141a76314352fcbc3ff2fad8..1abaffff152995cfd34b5195886110a9541eb9f4 100644 (file)
@@ -28,8 +28,8 @@ $cfg = FrameworkConfiguration::getInstance();
 // CFG: DEFAULT-COMMAND
 $cfg->setConfigEntry('default_command', "home");
 
-// CFG: HOME-WITH-NEWS
-$cfg->setConfigEntry('home_with_news', "Y");
+// CFG: PAGE-WITH-NEWS
+$cfg->setConfigEntry('page_with_news', "home");
 
 // CFG: FORM-ACTION
 $cfg->setConfigEntry('form_action', "index.php?app={?app_short_name?}&amp;page=do_form");
@@ -103,5 +103,29 @@ $cfg->setConfigEntry('news_process_class', "NewsProcessFilter");
 // CFG: USER-AUTH-FILTER
 $cfg->setConfigEntry('user_auth_class', "UserAuthFilter");
 
+// CFG: NEWS-HOME-LIMIT
+$cfg->setConfigEntry('news_home_limit', 10);
+
+// CFG: NEWS-LOGIN-AREA-LIMIT
+$cfg->setConfigEntry('news_login_area_limit', 15);
+
+// CFG: LOGIN-ENABLED
+$cfg->setConfigEntry('login_enabled', "Y");
+
+// CFG: LOGIN-DISABLED-REASON
+$cfg->setConfigEntry('login_disabled_reason', "Loginbereich befindet sich noch im Aufbau.");
+
+// CFG: LOGIN-TYPE
+$cfg->setConfigEntry('login_type', "username"); // username, email, both
+
+// CFG: GUEST-LOGIN-ALLOWED
+$cfg->setConfigEntry('guest_login_allowed', "Y");
+
+// CFG: GUEST-LOGIN-USERNAME
+$cfg->setConfigEntry('guest_login_username', "guest");
+
+// CFG: GUEST-LOGIN-PASSWORD
+$cfg->setConfigEntry('guest_login_password', "guest");
+
 // [EOF]
 ?>
diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php
new file mode 100644 (file)
index 0000000..afab446
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+/**
+ * A command for user login
+ *
+ * @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 WebShipsimuUserLoginCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("User login handling command for Ship-Simu");
+
+               // Create unique ID number
+               $this->generateUniqueId();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this command and sets the resolver instance
+        *
+        * @param       $resolverInstance       An instance of a command resolver
+        * @return      $commandInstance        The created command instance
+        */
+       public final static function createWebShipsimuUserLoginCommand (CommandResolver $resolverInstance) {
+               // Get a new instance
+               $commandInstance = new WebShipsimuUserLoginCommand();
+
+               // Set the resolver instance
+               $commandInstance->setResolverInstance($resolverInstance);
+
+               // Get the controller instance from the resolver (breaks MVC pattern again)
+               $controllerInstance = $resolverInstance->getControllerInstance();
+
+               switch ($commandInstance->getConfigInstance()->readConfig('login_type')) {
+                       case "username": // Login via username
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
+                               break;
+
+                       case "email": // Login via email
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_class'));
+                               break;
+
+                       default: // Wether username or email is set
+                               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class'));
+                               break;
+               }
+               // @TODO Add more filters
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class'));
+
+               // Return the prepared instance
+               return $commandInstance;
+       }
+
+       /**
+        * Executes the 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) {
+               // First get a UserLogin instance
+               $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class');
+
+               // First set request and response instance
+               $loginInstance->setRequestInstance($requestInstance);
+
+               // Encrypt the password
+               $loginInstance->encryptPassword('pass');
+
+               // Do the login here
+               $loginInstance->doLogin($requestInstance, $responseInstance);
+
+               // Was the login fine? Then redirect here
+               if ($loginInstance->ifLoginWasSuccessfull()) {
+                       // Try to redirect here
+                       try {
+                               $responseInstance->redirectToConfiguredUrl('app_login_url');
+                       } catch (FrameworkException $e) {
+                               // Something went wrong here!
+                               $responseInstance->addFatalMessage($e->getMessage());
+                       }
+               } else {
+                       // Attach error message to the response
+                       $responseInstance->addFatalMessage('failed_user_login');
+               }
+       }
+}
+
+// [EOF]
+?>
index 75bc8fa1384b8b8dc2edbd9c9860b362cc28b858..1f62ded44872b635a679bc03b8acde9156a65ce2 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
+       /**
+        * The hashed password
+        */
+       private $hashedPassword = "";
+
        /**
         * Protected constructor
         *
@@ -134,6 +139,33 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                // Return the result
                return $loginDone;
        }
+
+       /**
+        * Encrypt the given request key or throw an exception if the key was not
+        * found in the request
+        *
+        * @param       $requestKey             Key in request class
+        * @return      void
+        */
+       public function encryptPassword ($requestKey) {
+               // Check if the password is found in the request
+               if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
+                       // So encrypt the password and store it for later usage in
+                       // the request:
+
+                       // Get the plain password
+                       $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
+
+                       // Get user instance
+                       $userInstance = Registry::getRegistry()->getInstance('user');
+
+                       // Get a crypto helper and hash the password
+                       $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashPassword($plainPassword, $userInstance->getPasswordHash());
+
+                       // Store the hash back in the request
+                       $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
+               } // END - if
+       }
 }
 
 // [EOF]
index 169f18fbdd5242973893e947282bd412eef26170..0e9aee1fedb768cc73a6d420f951875a2ca4e2c5 100644 (file)
@@ -35,11 +35,6 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
         */
        private $authMethod = "";
 
-       /**
-        * Instance for a request class
-        */
-       private $requestInstance = null;
-
        // Exception constants
        const EXCEPTION_INVALID_USER_INSTANCE = 0x080;
 
@@ -99,26 +94,6 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
                $this->authMethod = $this->getConfigInstance()->readConfig('auth_method_class');
        }
 
-       /**
-        * Setter for request instance
-        *
-        * @param       $requestInstance        A Requestable class instance
-        * @return      void
-        */
-       public final function setRequestInstance (Requestable $requestInstance) {
-               $this->requestInstance = $requestInstance;
-       }
-
-       /**
-        * Getter for request instance
-        *
-        * @param       
-        * @return      $requestInstance        A Requestable class instance
-        */
-       public final function getRequestInstance () {
-               return $this->requestInstance;
-       }
-
        /**
         * Execute the login request by given response instance. This instance can
         * be used for sending cookies or at least the session id out.
@@ -131,10 +106,10 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
                $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance));
 
                // Set user cookie
-               $loginInstance->setUserAuth($this->requestInstance->getRequestElement('username'));
+               $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username'));
 
                // Set password cookie
-               $loginInstance->setPasswordAuth($this->requestInstance->getRequestElement('pass_hash'));
+               $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash'));
 
                // Remember this login instance for later usage
                Registry::getRegistry()->addInstance('login', $loginInstance);
diff --git a/application/ship-simu/templates/de/code/login_form.ctp b/application/ship-simu/templates/de/code/login_form.ctp
new file mode 100644 (file)
index 0000000..afd2941
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+// Get helper instance for web forms. This will add the opening form-tag to
+// the helper's render cache which is simply a small variable in the class
+// BaseHelper.
+$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_user_login");
+
+// Formular deaktiviert?
+if ($helper->ifLoginIsEnabled()) {
+       // Formular ist aktiv
+       $helper->addFormGroup("login", "Gebe hier deine Logindaten ein:");
+
+       // Welches Loginverfahren wurde konfiguriert?
+       if ($helper->ifLoginWithUsername()) {
+               // Login mit Username
+               $helper->addFormSubGroup("username", "Bitte mit deinem Nickname einloggen.");
+               $helper->addFieldText("username", "Dein Nickname:");
+               $helper->addInputTextField("username");
+       } elseif ($helper->ifLoginWithEmail()) {
+               // Login mit Email
+               $helper->addFormSubGroup("email", "Bitte mit deiner Email-Adresse einloggen.");
+               $helper->addFieldText("email", "Deine Email-Addresse:");
+               $helper->addInputTextField("email");
+       } else {
+               // Login mit Email/Username
+               $helper->addFormSubGroup("user_email", "Bitte mit deinem Nickname oder Email-Adresse einloggen.");
+               $helper->addFieldText("user_email", "Dein Nickname/Email:");
+               $helper->addInputTextField("user_email");
+       }
+
+       $helper->addFormSubGroup("pass", "Gebe dein Passwort von der Anmeldung ein.");
+       $helper->addFieldText("pass", "Dein Passwort:");
+       $helper->addInputPasswordField("pass");
+       $helper->addFormGroup("buttons", "Alles richtig eingegeben?");
+       $helper->addInputResetButton("Formular leeren");
+       $helper->addInputSubmitButton("Zum Spiel einloggen");
+} else {
+       // Formular deaktiviert
+       $helper->addFormNote("Einloggen in&#39;s Spiel ist derzeit administrativ deaktiviert worden. Bitte komme sp&auml;ter noch mal wieder.");
+       $helper->addFormNote("Nachricht vom Admin: <span id=\"disabled_reason\">".$this->getConfigInstance()->readConfig('login_disabled_reason')."</span>");
+}
+
+// Formular schliessen
+$helper->addFormTag();
+$helper->flushContent();
+
+// Ist Gastlogin erlaubt?
+if ($helper->ifGuestLoginAllowed()) {
+       // Neue Helper-Instanz holen
+       $helper = WebFormHelper::createWebFormHelper($this, "shipsimu_guest_login");
+       $helper->addInputHiddenField("username", $this->getConfigInstance()->readConfig('guest_login_username'));
+       $helper->addInputHiddenField("password", $this->getConfigInstance()->readConfig('guest_login_password'));
+       $helper->addFormGroup("buttons", "Gastlogins sind in der Funkionsweise eingeschr&auml;nkt. Mehr dazu unter &quot;Gastlogin&quot;.");
+       $helper->addInputSubmitButton("Als Gast einloggen");
+       $helper->addFormTag();
+       $helper->flushContent();
+}
+
+?>
+<div id="content_header">
+       Einloggen zu <span class="app_name">{?app_full_name?}</span>
+</div>
+
+<div id="login_box">
+       {?shipsimu_user_login?}
+</div>
+
+<div id="guest_login">
+       {?shipsimu_guest_login?}
+</div>
diff --git a/application/ship-simu/templates/de/code/register.ctp b/application/ship-simu/templates/de/code/register.ctp
deleted file mode 100644 (file)
index f579b1b..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-// Get helper instance for web forms. This will add the opening form-tag to
-// the helper's render cache which is simply a small variable in the class
-// BaseHelper.
-$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_register");
-
-// Nickname und Passwort sollten immer abgefragt werden, die Email als Loginname
-// wuerde aber auch gehen.
-$helper->addFormGroup("login", "Bitte gebe hier gew&uuml;nschten Nickname und dein Zugangspasswort ein.");
-$helper->addFormSubGroup("username", "Dein Nickname wird erst nach Absenden des Formulares gepr&uuml;ft. Sp&auml;ter bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist.");
-$helper->addFieldText("username", "Nickname im Spiel:");
-$helper->addInputTextField("username");
-$helper->addFormSubGroup("password", "Dein Passwort sollte nicht zu leicht erratbar sein. Sp&auml;ter bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortst&auml;rke anzeigt.");
-$helper->addFieldText("pass1", "Passwort:");
-$helper->addInputPasswordField("pass1");
-$helper->addFieldText("pass2", "Passwortwiederholung:");
-$helper->addInputPasswordField("pass2");
-
-if ($helper->ifRegisterRequiresEmailVerification()) {
-       $helper->addFormGroup("email", "Bitte gebe deine Email zweimal (ein zweites Mal zur Best&auml;tigung) ein, damit wir dir deinen Freischaltlink zusenden k&ouml;nnen.");
-       $helper->addFieldText("email1", "Email-Adresse:");
-       $helper->addInputTextField("email1");
-       $helper->addFieldText("email2", "Wiederholung Email-Adresse:");
-       $helper->addInputTextField("email2");
-       if ($helper->ifEmailMustBeUnique()) {
-               $helper->addFormNote("Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein.");
-       } // END - Unique email addresses
-} // END - email verification
-
-if ($helper->ifRegisterIncludesProfile()) {
-       $helper->addFormGroup("profile", "Hier kannst du zus&auml;tzlich deine Profildaten vorweg eingeben, du kannst sie aber auch nach dem Login vervollst&auml;ndigen!");
-       if (!$helper->ifRegisterRequiresEmailVerification()) {
-               $helper->addFormSubGroup("email", "Die Angabe deiner Email-Adresse ist nur dann n&ouml;tig, wenn du auch Email-Benachrichtigungen (<span id=\"add_note\">*1</span>) haben m&ouml;chtest.");
-               $helper->addFieldText("email1", "Email-Adresse:");
-               $helper->addInputTextField("email1");
-       } // END - No email verification
-
-       // Persoenliche Daten mit in der Anmeldung abfragen?
-       if ($helper->ifRegisterIncludesPersonaData()) {
-               $helper->addFormSubGroup("persona", "Wenn du magst, dann vervollst&auml;ndige deine komplette Adresse mit deinem Namen.");
-               $helper->addFieldText("surname", "Dein Vorname:");
-               $helper->addInputTextField("surname");
-               $helper->addFieldText("family", "Dein Nachname:");
-               $helper->addInputTextField("family");
-               $helper->addFieldText("street", "Strasse und Hausnummer:");
-               $helper->addInputTextField("street");
-               $helper->addFieldText("city", "Wohnort:");
-               $helper->addInputTextField("city");
-       } // END - Persona data
-
-       $helper->addFormSubGroup("zip", "Magst du uns auch deine Postleitzahl verraten?");
-       $helper->addFieldText("zip", "Postleitzahl:");
-       $helper->addInputTextField("zip");
-
-       $helper->addFormSubGroup("chat", "Gebe hier deine Nicknames bzw. Nummern an:");
-       if ($helper->ifChatEnabled("icq")) {
-               $helper->addFieldText("icq", "ICQ-Nummer:");
-               $helper->addInputTextField("icq");
-       }
-       if ($helper->ifChatEnabled("jabber")) {
-               $helper->addFieldText("jabber", "Jabber:");
-               $helper->addInputTextField("jabber");
-       }
-       if ($helper->ifChatEnabled("yahoo")) {
-               $helper->addFieldText("yahoo", "Yahoo!:");
-               $helper->addInputTextField("yahoo");
-       }
-       if ($helper->ifChatEnabled("aol")) {
-               $helper->addFieldText("aol", "AOL-Screenname:");
-               $helper->addInputTextField("aol");
-       }
-       if ($helper->ifChatEnabled("msn")) {
-               $helper->addFieldText("msn", "MSN:");
-               $helper->addInputTextField("msn");
-       }
-
-       if (!$helper->ifRegisterRequiresEmailVerification()) {
-               $helper->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst.");
-       } // END - Extra note
-} // END - ask profile data
-
-// Spielregeln abfragen
-$helper->addFormGroup("rules", "Bitte lese dir die Spieleregeln gut durch und kreuze dann &quot;Ja, ich akzeptiere die aktuellen Spielregeln&quot; an.");
-$helper->addFieldText("rules", "Ja, ich akzeptiere die aktuellen Spielregeln:");
-$helper->addInputCheckboxField("rules", false);
-
-// Abschliessender Hinweis und Abschluss des Formulars
-$helper->addFormGroup("buttons", "Wenn du alle ben&ouml;tigten Felder korrekt ausgef&uuml;t hast, kannst du die Anmeldung abschliessen.");
-$helper->addInputResetButton("Alles nochmal eingeben");
-$helper->addInputSubmitButton("Anmeldung zum Spiel abschliessen");
-$helper->addFormNote("Deine Daten werden nach den g&uuml;ltigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link &quot;Datenschutz&quot;.");
-$helper->addFormTag();
-$helper->flushContent();
-?>
-<div id="content_header">
-       Anmeldung bei <span class="app_name">{?app_full_name?}</span>
-</div>
-
-<div id="register_box">
-       {?shipsimu_register?}
-</div>
diff --git a/application/ship-simu/templates/de/code/register_form.ctp b/application/ship-simu/templates/de/code/register_form.ctp
new file mode 100644 (file)
index 0000000..f579b1b
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+// Get helper instance for web forms. This will add the opening form-tag to
+// the helper's render cache which is simply a small variable in the class
+// BaseHelper.
+$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_register");
+
+// Nickname und Passwort sollten immer abgefragt werden, die Email als Loginname
+// wuerde aber auch gehen.
+$helper->addFormGroup("login", "Bitte gebe hier gew&uuml;nschten Nickname und dein Zugangspasswort ein.");
+$helper->addFormSubGroup("username", "Dein Nickname wird erst nach Absenden des Formulares gepr&uuml;ft. Sp&auml;ter bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist.");
+$helper->addFieldText("username", "Nickname im Spiel:");
+$helper->addInputTextField("username");
+$helper->addFormSubGroup("password", "Dein Passwort sollte nicht zu leicht erratbar sein. Sp&auml;ter bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortst&auml;rke anzeigt.");
+$helper->addFieldText("pass1", "Passwort:");
+$helper->addInputPasswordField("pass1");
+$helper->addFieldText("pass2", "Passwortwiederholung:");
+$helper->addInputPasswordField("pass2");
+
+if ($helper->ifRegisterRequiresEmailVerification()) {
+       $helper->addFormGroup("email", "Bitte gebe deine Email zweimal (ein zweites Mal zur Best&auml;tigung) ein, damit wir dir deinen Freischaltlink zusenden k&ouml;nnen.");
+       $helper->addFieldText("email1", "Email-Adresse:");
+       $helper->addInputTextField("email1");
+       $helper->addFieldText("email2", "Wiederholung Email-Adresse:");
+       $helper->addInputTextField("email2");
+       if ($helper->ifEmailMustBeUnique()) {
+               $helper->addFormNote("Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein.");
+       } // END - Unique email addresses
+} // END - email verification
+
+if ($helper->ifRegisterIncludesProfile()) {
+       $helper->addFormGroup("profile", "Hier kannst du zus&auml;tzlich deine Profildaten vorweg eingeben, du kannst sie aber auch nach dem Login vervollst&auml;ndigen!");
+       if (!$helper->ifRegisterRequiresEmailVerification()) {
+               $helper->addFormSubGroup("email", "Die Angabe deiner Email-Adresse ist nur dann n&ouml;tig, wenn du auch Email-Benachrichtigungen (<span id=\"add_note\">*1</span>) haben m&ouml;chtest.");
+               $helper->addFieldText("email1", "Email-Adresse:");
+               $helper->addInputTextField("email1");
+       } // END - No email verification
+
+       // Persoenliche Daten mit in der Anmeldung abfragen?
+       if ($helper->ifRegisterIncludesPersonaData()) {
+               $helper->addFormSubGroup("persona", "Wenn du magst, dann vervollst&auml;ndige deine komplette Adresse mit deinem Namen.");
+               $helper->addFieldText("surname", "Dein Vorname:");
+               $helper->addInputTextField("surname");
+               $helper->addFieldText("family", "Dein Nachname:");
+               $helper->addInputTextField("family");
+               $helper->addFieldText("street", "Strasse und Hausnummer:");
+               $helper->addInputTextField("street");
+               $helper->addFieldText("city", "Wohnort:");
+               $helper->addInputTextField("city");
+       } // END - Persona data
+
+       $helper->addFormSubGroup("zip", "Magst du uns auch deine Postleitzahl verraten?");
+       $helper->addFieldText("zip", "Postleitzahl:");
+       $helper->addInputTextField("zip");
+
+       $helper->addFormSubGroup("chat", "Gebe hier deine Nicknames bzw. Nummern an:");
+       if ($helper->ifChatEnabled("icq")) {
+               $helper->addFieldText("icq", "ICQ-Nummer:");
+               $helper->addInputTextField("icq");
+       }
+       if ($helper->ifChatEnabled("jabber")) {
+               $helper->addFieldText("jabber", "Jabber:");
+               $helper->addInputTextField("jabber");
+       }
+       if ($helper->ifChatEnabled("yahoo")) {
+               $helper->addFieldText("yahoo", "Yahoo!:");
+               $helper->addInputTextField("yahoo");
+       }
+       if ($helper->ifChatEnabled("aol")) {
+               $helper->addFieldText("aol", "AOL-Screenname:");
+               $helper->addInputTextField("aol");
+       }
+       if ($helper->ifChatEnabled("msn")) {
+               $helper->addFieldText("msn", "MSN:");
+               $helper->addInputTextField("msn");
+       }
+
+       if (!$helper->ifRegisterRequiresEmailVerification()) {
+               $helper->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst.");
+       } // END - Extra note
+} // END - ask profile data
+
+// Spielregeln abfragen
+$helper->addFormGroup("rules", "Bitte lese dir die Spieleregeln gut durch und kreuze dann &quot;Ja, ich akzeptiere die aktuellen Spielregeln&quot; an.");
+$helper->addFieldText("rules", "Ja, ich akzeptiere die aktuellen Spielregeln:");
+$helper->addInputCheckboxField("rules", false);
+
+// Abschliessender Hinweis und Abschluss des Formulars
+$helper->addFormGroup("buttons", "Wenn du alle ben&ouml;tigten Felder korrekt ausgef&uuml;t hast, kannst du die Anmeldung abschliessen.");
+$helper->addInputResetButton("Alles nochmal eingeben");
+$helper->addInputSubmitButton("Anmeldung zum Spiel abschliessen");
+$helper->addFormNote("Deine Daten werden nach den g&uuml;ltigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link &quot;Datenschutz&quot;.");
+$helper->addFormTag();
+$helper->flushContent();
+?>
+<div id="content_header">
+       Anmeldung bei <span class="app_name">{?app_full_name?}</span>
+</div>
+
+<div id="register_box">
+       {?shipsimu_register?}
+</div>
diff --git a/inc/classes/exceptions/result/.htaccess b/inc/classes/exceptions/result/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php b/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php
new file mode 100644 (file)
index 0000000..bd10459
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * An exception thrown if a database result does not contain expected entries
+ *
+ * @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 InvalidDatabaseResultException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param               $msgArray       Error message array
+        * @param               $code           Error code
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code) {
+               // Construct the message
+               $message = sprintf("[%s:%d] Database instance <u>%s</u> contains invalid entries.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1]->__toString()
+               );
+
+               // Call parent exception constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index c0ec28b7d369529c43e0bcda43b4ae78f350298e..2b3499e67ece6ed16e8792c3791a6bf45470125d 100644 (file)
@@ -31,20 +31,11 @@ interface CompileableTemplate extends FrameworkInterface {
         */
        function assignVariable ($var, $value);
 
-       /**
-        * Assign a configuration variables for templates
-        *
-        * @param               $var            The configuration "variable" we want to assign
-        * @param               $value  The value we want to store in the variable
-        * @return      void
-        */
-       function assignConfigVariable ($var, $value);
-
        /**
         * Load a specified web template into the engine
         *
-        * @param               $template               The web template we shall load which is
-        *                                              located in "html" by default
+        * @param       $template       The web template we shall load which is located in
+        *                                              "html" by default
         * @return      void
         */
        function loadWebTemplate ($template);
index 3cc3592cf40c022d46a85f709c1c0dbad2ef774a..1deddf282779cd1d6ce362f2a8c524c57ebf9a97 100644 (file)
@@ -99,9 +99,7 @@ class WebHomeCommand extends BaseCommand implements Commandable {
                $templateInstance->loadCodeTemplate($masterTemplate);
 
                // Set title
-               $title = ucfirst($requestInstance->getRequestElement("page"));
-               if (empty($title)) $title = "Home";
-               $templateInstance->assignVariable('title', $title);
+               $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_home_title'));
 
                // ... and all variables. This should be merged together in a pattern
                // to make things easier. A cache mechanism should be added between
index d5f45ec598d9ab404eb4048ad41e4896bf862a03..8b73b2ba1367bcc14cd744d528110c331d8e2fff 100644 (file)
@@ -101,7 +101,7 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable {
                        $action = sprintf("login_%s", $actReq);
                } // END - if
 
-               // TODO Do the action somewhere here
+               // @TODO Do the action somewhere here
 
                // Load the matching template
                $templateInstance->loadCodeTemplate($action);
diff --git a/inc/classes/main/commands/web/class_WebLoginCommand.php b/inc/classes/main/commands/web/class_WebLoginCommand.php
new file mode 100644 (file)
index 0000000..3f56321
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+/**
+ * A command for the login form
+ *
+ * @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 WebLoginCommand extends BaseCommand implements Commandable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set special description
+               $this->setObjectDescription("Command for the &quot;home&quot; page");
+
+               // 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 createWebLoginCommand (CommandResolver $resolverInstance) {
+               // Get new instance
+               $commandInstance = new WebLoginCommand();
+
+               // 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->prepareTemplateEngine($appInstance);
+
+               // Assign application data with template engine
+               $templateInstance->assignApplicationData($appInstance);
+
+               // 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("login_form");
+
+               // Assign the home template with the master template as a content ... ;)
+               $templateInstance->assignTemplateWithVariable("login_form", "content");
+
+               // Load the master template
+               $templateInstance->loadCodeTemplate($masterTemplate);
+
+               // Set title
+               $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_login_title'));
+
+               // ... 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);
+       }
+}
+
+// [EOF]
+?>
index df504999875b2368fce140f38b2f4c102f80e3e5..f073baa8f73f5e038f4fa03febd114ebc1044606 100644 (file)
@@ -93,19 +93,17 @@ class WebRegisterCommand extends BaseCommand implements Commandable {
                $templateInstance->assignTemplateWithVariable("footer", "footer");
 
                // Load the register template
-               $templateInstance->loadCodeTemplate("register");
+               $templateInstance->loadCodeTemplate("register_form");
 
                // Assign the register template with the master template as a content ... ;)
                $templateInstance->compileTemplate();
-               $templateInstance->assignTemplateWithVariable("register", "content");
+               $templateInstance->assignTemplateWithVariable("register_form", "content");
 
                // Load the master template
                $templateInstance->loadCodeTemplate($masterTemplate);
 
                // Set title
-               $title = ucfirst($requestInstance->getRequestElement("page"));
-               if (empty($title)) $title = "Register";
-               $templateInstance->assignVariable('title', $title);
+               $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_register_title'));
 
                // ... and all variables. This should be merged together in a pattern
                // to make things easier. A cache mechanism should be added between
index 60ddfedcf0ea4c273d5fafe45504b89c71e9fccc..59c51c3134964bb31c848b2dc500fb7a286e43a1 100644 (file)
@@ -7,6 +7,7 @@
  * @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
+ * @todo               This controller shall still provide some headlines for sidebars
  *
  * 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
diff --git a/inc/classes/main/controller/default/class_WebLoginController.php b/inc/classes/main/controller/default/class_WebLoginController.php
new file mode 100644 (file)
index 0000000..1758c8a
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * Controller for login form with password reminder and maybe enabled
+ * "guest-login" button
+ *
+ * @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 WebLoginController extends BaseController implements Controller {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Controller for login form");
+
+               // 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
+        */
+       public final static function createWebLoginController (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new WebLoginController();
+
+               // Set the command resolver
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // @TODO Add some filters to this controller
+
+               // 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) {
+               // Run the pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // Get the command instance from the resolver by sending a request instance to the resolver
+               $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance);
+
+               // 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 4ec02ad9171256c275b26311527851df3b475cc7..93502cbce1e3b4fd2c487d349a6012125415b639 100644 (file)
@@ -142,6 +142,7 @@ class CryptoHelper extends BaseFrameworkSystem {
                }
 
                // Hash the password with salt
+               //* DEBUG: */ echo $salt."/".$plainPassword."/".$this->rngInstance->getExtraSalt()."<br />\n";
                $hashed = $salt . md5(sprintf($this->getConfigInstance()->readConfig('hash_mask'),
                        $salt,
                        $this->rngInstance->getExtraSalt(),
diff --git a/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..c8c43dc
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+/**
+ * A database wrapper for news classes
+ *
+ * @see                        DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
+ * @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 NewsDatabaseWrapper extends BaseDatabaseWrapper {
+       /**
+        * Cache instance
+        */
+       private $cacheInstance = null;
+
+       // Constants for exceptions
+       const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x070;
+
+       // Constants for database columns
+
+       // Constants for database table names
+       const DB_TABLE_NEWS = "news";
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct() {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Database wrapper for user objects");
+
+               // Create unique ID number
+               $this->generateUniqueId();
+       }
+
+       /**
+        * Creates an instance of this database wrapper by a provided user class
+        *
+        * @return      $wrapperInstance        An instance of the created wrapper class
+        */
+       public final static function createNewsDatabaseWrapper () {
+               // Get a new instance
+               $wrapperInstance = new NewsDatabaseWrapper();
+
+               // Initialize the cache instance
+               $wrapperInstance->initCacheInstance();
+
+               // Return the instance
+               return $wrapperInstance;
+       }
+
+       /**
+        * Initializes the cache instance with a new object
+        *
+        * @return      void
+        */
+       protected function initCacheInstance () {
+               // Set the new instance
+               $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+       }
+
+       /**
+        * Do a "select" query on the user table with the given search criteria and
+        * store it in cache for later usage
+        *
+        * @param       $criteriaInstance       An instance of a Criteria class
+        * @return      $resultInstance         An instance of a database result class
+        */
+       public function doSelectByCriteria (Criteria $criteriaInstance) {
+               // First get a key suitable for our cache and extend it with this class name
+               $cacheKey = sprintf("%s@%s",
+                       $this->__toString(),
+                       $criteriaInstance->getCacheKey()
+               );
+
+               // Does this key exists in cache?
+               if ($this->cacheInstance->offsetExists($cacheKey)) {
+                       // Then use this result
+                       $result = $cacheInstance->offsetGet($cacheKey);
+               } else {
+                       // Now it's time to ask the database layer for this select statement
+                       $result = $this->getDatabaseInstance()->doSelectByTableCriteria(self::DB_TABLE_NEWS, $criteriaInstance);
+
+                       // Cache the result if not null
+                       if (!is_null($result)) {
+                               // A valid result has returned from the database layer
+                               $this->cacheInstance->offsetSet($cacheKey, $result);
+                       } else {
+                               // This invalid result must be wrapped
+                               $result = array(
+                                       'status'                => "invalid",
+                                       'exception'             => $this->getDatabaseInstance()->getLastException()
+                               );
+                       }
+               }
+
+               // Create an instance of a DatabaseResult class with the given result
+               $resultInstance = DatabaseResult::createDatabaseResult($result);
+
+               // And return the instance
+               return $resultInstance;
+       }
+}
+
+// [EOF]
+?>
index e3a1881c2aad10d4f18d733efd9b1c0296beea9f..a85937de2b9ea6da099bf6f638f892eb69ae1461 100644 (file)
@@ -64,8 +64,8 @@ class NewsDownloadFilter extends BaseFilter implements Filterable {
                // Get a news instance
                $newsInstance = WebNewsFactory::createFactoryByRequest($requestInstance);
 
-               // TODO Need to extend/rewrite this
-               $this->partialStub("Unfinished work.");
+               // Store the news instance in registry
+               Registry::getRegistry()->addInstance('news', $newsInstance);
        }
 }
 
diff --git a/inc/classes/main/filter/verifier/.htaccess b/inc/classes/main/filter/verifier/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/filter/verifier/class_EmailValidatorFilter.php b/inc/classes/main/filter/verifier/class_EmailValidatorFilter.php
new file mode 100644 (file)
index 0000000..4785a96
--- /dev/null
@@ -0,0 +1,174 @@
+<?php
+/**
+ * A concrete filter for validating the email address. This filter may intercept
+ * the filter chain if no email address is given or if the supplied email has an
+ * invalid form. It could also intercept the filter chain if the email address
+ * is already used by some one if configuration requires this.
+ *
+ * @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 EmailValidatorFilter 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 Email 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 createEmailValidatorFilter () {
+               // Get a new instance
+               $filterInstance = new EmailValidatorFilter();
+
+               // 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 Email from request
+               $email = $requestInstance->getRequestElement('email');
+
+               // Is the Email set?
+               if ((is_null($email)) || ($this->getConfigInstance()->readConfig('register_email_unique') == "Y")) {
+                       // Try it again
+                       $email1 = $requestInstance->getRequestElement('email1');
+                       $email2 = $requestInstance->getRequestElement('email2');
+
+                       // Is the email still not set?
+                       if ((is_null($email1)) || (is_null($email2))) {
+                               // Not found in form so stop the filtering process
+                               $requestInstance->requestIsValid(false);
+
+                               // Add a message to the response
+                               $responseInstance->addFatalMessage('email_unset');
+
+                               // Abort here
+                               return false;
+                       } elseif ((empty($email1)) || (empty($email2))) {
+                               // Email is empty
+                               $requestInstance->requestIsValid(false);
+
+                               // Is the email empty?
+                               if (empty($email1)) {
+                                       // Add a message to the response
+                                       $responseInstance->addFatalMessage('email1_empty');
+                               } // END - if
+
+                               // Is the confirmation empty?
+                               if (empty($email2)) {
+                                       // Add a message to the response
+                                       $responseInstance->addFatalMessage('email2_empty');
+                               } // END - if
+
+                               // Abort here
+                               return false;
+                       } elseif ($this->ifEmailIsTaken($email1)) {
+                               // Email is already taken
+                               $requestInstance->requestIsValid(false);
+
+                               // Add a message to the response
+                               $responseInstance->addFatalMessage('email_taken');
+
+                               // Abort here
+                               return false;
+                       } elseif ($email1 != $email2) {
+                               // Emails didn't match
+                               $requestInstance->requestIsValid(false);
+
+                               // Add a message to the response
+                               $responseInstance->addFatalMessage('emails_mismatch');
+
+                               // Abort here
+                               return false;
+                       } // END - elseif
+               } elseif (empty($email)) {
+                       // Empty field!
+                       $requestInstance->requestIsValid(false);
+
+                       // Add a message to the response
+                       $responseInstance->addFatalMessage('email_empty');
+
+                       // Abort here
+                       return false;
+               } // END - elseif
+       }
+
+       /**
+        * Check wether the email as already been taken
+        *
+        * @param       $email                  Email to check for existence
+        * @return      $alreadyTaken   Wether the email has been taken
+        */
+       private function ifEmailIsTaken ($email) {
+               // Default is already taken
+               $alreadyTaken = true;
+
+               // Initialize instance
+               $userInstance = null;
+
+               // Get a registry instance
+               $registry = Registry::getRegistry();
+
+               // Is the user already there?
+               if ($registry->instanceExists('user')) {
+                       // Use the instance for checking for the email
+                       $userInstance = $registry->getInstance('user');
+                       $userInstance->setEmailAddress($email);
+               } else {
+                       // If this instance is created then the username *does* exist
+                       $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), "createUserByEmail"), array($email));
+
+                       // Remember this user instance in our registry for later usage
+                       $registry->addInstance('user', $userInstance);
+               }
+
+               // Does the email exist?
+               if (!$userInstance->ifEmailAddressExists()) {
+                       // This email has not being used yet
+                       $alreadyTaken = false;
+               }
+
+               // Return the result
+               return $alreadyTaken;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php
new file mode 100644 (file)
index 0000000..002c0a5
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * A concrete filter for validating the password. This filter may intercept
+ * the filter chain if no password is given or the password is invalid
+ *
+ * @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 PasswordVerifierFilter 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 password 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 createPasswordVerifierFilter () {
+               // Get a new instance
+               $filterInstance = new PasswordVerifierFilter();
+
+               // 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 password
+               $password = $requestInstance->getRequestElement('pass');
+
+               // Is the password still not set?
+               if (is_null($password)) {
+                       // Not found in form so stop the filtering process
+                       $requestInstance->requestIsValid(false);
+
+                       // Add a message to the response
+                       $responseInstance->addFatalMessage('password_unset');
+
+                       // Abort here
+                       return false;
+               } elseif (empty($password)) {
+                       // Password is empty
+                       $requestInstance->requestIsValid(false);
+
+                       // Add a message to the response
+                       $responseInstance->addFatalMessage('password_empty');
+
+                       // Abort here
+                       return false;
+               }
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php
new file mode 100644 (file)
index 0000000..756a311
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+/**
+ * A concrete filter for verfying the username. This filter may intercept the
+ * filter chain if no username is given or if the supplied username has an
+ * invalid form. It could also intercept the filter chain if the username was
+ * not found.
+ *
+ * @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 UserNameVerifierFilter 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 username 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 createUserNameVerifierFilter () {
+               // Get a new instance
+               $filterInstance = new UserNameVerifierFilter();
+
+               // 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 username from request
+               $userName = $requestInstance->getRequestElement('username');
+
+               // Is the username set?
+               if (is_null($userName)) {
+                       // Not found in form so stop the filtering process
+                       $requestInstance->requestIsValid(false);
+
+                       // Add a message to the response
+                       $responseInstance->addFatalMessage('username_unset');
+
+                       // Abort here
+                       return false;
+               } elseif (empty($userName)) {
+                       // Empty field!
+                       $requestInstance->requestIsValid(false);
+
+                       // Add a message to the response
+                       $responseInstance->addFatalMessage('username_empty');
+
+                       // Abort here
+                       return false;
+               } elseif (!$this->ifUserNameIsTaken($userName)) {
+                       // Username is already taken
+                       $requestInstance->requestIsValid(false);
+
+                       // Add a message to the response
+                       $responseInstance->addFatalMessage('username_not_found');
+
+                       // Abort here
+                       return false;
+               }
+       }
+
+       /**
+        * Check wether the username as already been taken
+        *
+        * @param       $userName               Username to check for existence
+        * @return      $alreadyTaken   Wether the username has been taken
+        */
+       private function ifUserNameIsTaken ($userName) {
+               // Default is already taken
+               $alreadyTaken = true;
+
+               // Initialize instance
+               $userInstance = null;
+
+               // Get a registry instance
+               $registry = Registry::getRegistry();
+
+               // Is the user already there?
+               if ($registry->instanceExists('user')) {
+                       // Use the instance for checking for the email
+                       $userInstance = $registry->getInstance('user');
+                       $userInstance->setUserName($userName);
+               } else {
+                       // If this instance is created then the username *does* exist
+                       try {
+                               // Get a new instance
+                               $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), "createUserByUsername"), array($userName));
+
+                               // Remember this user instance in our registry for later usage
+                               $registry->addInstance('user', $userInstance);
+                       } catch (UsernameMissingException $e) {
+                               // User was not found
+                       }
+               }
+
+               // Does the username exist?
+               if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+                       // This username is still available
+                       $alreadyTaken = false;
+               }
+
+               // Return the result
+               return $alreadyTaken;
+       }
+}
+
+// [EOF]
+?>
index 7daa441eb1a4b61f02d0446cf01f7b3fcd0b7a8e..6dbffb5c01a33ed1c02b32856b2140420e875b68 100644 (file)
@@ -567,6 +567,46 @@ class WebFormHelper extends BaseHelper {
                return $required;
        }
 
+       /**
+        * Checks wether login is enabled or disabled
+        *
+        * @return      $isEnabled      Wether the login is enabled or disabled
+        */
+       public function ifLoginIsEnabled () {
+               $isEnabled = ($this->getConfigInstance()->readConfig('login_enabled') == "Y");
+               return $isEnabled;
+       }
+
+       /**
+        * Checks wether login shall be done by username
+        *
+        * @return      $isEnabled      Wether the login shall be done by username
+        */
+       public function ifLoginWithUsername () {
+               $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "username");
+               return $isEnabled;
+       }
+
+       /**
+        * Checks wether login shall be done by email
+        *
+        * @return      $isEnabled      Wether the login shall be done by email
+        */
+       public function ifLoginWithEmail () {
+               $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "email");
+               return $isEnabled;
+       }
+
+       /**
+        * Checks wether guest login is allowed
+        *
+        * @return      $isAllowed      Wether guest login is allowed
+        */
+       public function ifGuestLoginAllowed () {
+               $isAllowed = ($this->getConfigInstance()->readConfig('guest_login_allowed') == "Y");
+               return $isAllowed;
+       }
+
        /**
         * Flushs the content out (not yet secured against open forms, etc.!) or
         * throw an exception if it is not yet closed
index 7fa8ff2e6b813e0f20f17ab1f7a55c88f8e82f5a..599761d84e518c19ad6d2fee73bf4d19cb2e085c 100644 (file)
  * 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 DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews {
+class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable {
+       /**
+        * Result set with news
+        */
+       private $resultInstance = null;
+
        /**
         * Protected constructor
         *
@@ -66,7 +71,26 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews {
         * @return      void
         */
        public function initializeReader () {
-               // TODO Need to implement this method
+               // Get "page" for saving some calls
+               $page = $this->getRequestInstance()->getRequestElement('page');
+
+               // First get a wrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('news_db_wrapper_class');
+
+               // Next create a searchable criteria instance
+               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add the page as criteria to it at lease
+               $criteriaInstance->addCriteria('page', $page);
+
+               // Add limitation from config
+               $criteriaInstance->setLimit($this->getConfigInstance()->readConfig("news_{$page}_limit"));
+
+               // Get a resultInstance back from the database
+               $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+               // Save that resultInstance in this class
+               $this->resultInstance = $resultInstance;
        }
 }
 
index 79225300e10d1f8eccfaf9d8b2e9529b0b5686d8..92f9ff6b99959acd571db54b0cd2e4d217bc034e 100644 (file)
@@ -97,7 +97,7 @@ abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegis
         */
        protected function executePostFilters () {
                // Execute all post filters
-               $this->postRegistrationFilter->processFilters($this->requestInstance, $this->responseInstance);
+               $this->postRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance());
        }
 }
 
index 0585196bc06c999fcaa3fe3adb7afd2a2424763a..6dd5a39fe25a8c54d0782c7f75c91fed272098a3 100644 (file)
@@ -158,11 +158,11 @@ class WebControllerResolver extends BaseResolver implements ControllerResolver {
                        $class = sprintf("Web%sController",
                                $this->convertToClassName($commandName)
                        );
-               } elseif ($this->getConfigInstance()->readConfig('home_with_news') == "Y") {
+               } elseif ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) {
                        // Yes, display news in home then set default controller with news
                        $class = "WebDefaultNewsController";
                } else {
-                       // No nes at "home" page
+                       // No news at "home" page or non-news page
                        $class = "WebDefaultController";
                }
                //* DEBUG: */ echo ", controller=".$class."<br />\n";
index 3fc5d2db1943c62b56ad4a209604804ab03cefd5..b3cbd0bdc3b92fff5e4c306bcab1eba5b58f16f6 100644 (file)
@@ -271,15 +271,15 @@ class HttpResponse extends BaseFrameworkSystem implements Responseable {
                $domain = $this->getConfigInstance()->readConfig('cookie_domain');
 
                setcookie($cookieName, $cookieValue, $expires);
-               // TODO Why are these parameters conflicting?
+               // @TODO Why are these parameters conflicting?
                //, $path, $domain, (isset($_SERVER['HTTPS']))
                return;
-               // TODO This will send only one cookie out, the first one.
+               // @TODO This will send only one cookie out, the first one.
 
                // Now construct the full header
                $cookieString = $cookieName . "=" . $cookieValue . "; ";
                $cookieString .= "expires=" . date("D, d-F-Y H:i:s", $expires) . " GMT";
-               // TODO Why are these parameters conflicting?
+               // @TODO Why are these parameters conflicting?
                // $cookieString .= "; path=".$path."; domain=".$domain;
 
                // Set the cookie as a header
index c6a0b1149a9d3e1907e019f51711ab0c68e5c74e..017547259c44b709e34d0c3920e322c1ef76683d 100644 (file)
@@ -22,6 +22,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, SeekableIterator {
+       // Exception constants
+       const EXCEPTION_INVALID_DATABASE_RESULT = 0x0b0;
+
        /**
         * Current position in array
         */
@@ -179,7 +182,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se
         * @return      void
         */
        public function rewind () {
-               $this->currentPos = 0;
+               $this->currentPos = -1;
        }
 
        /**
index 8875a4ca06ba2b8d4076973cf39558c8351ff9ed..a72e13a9e03fa74f023750b3c1be27fd15b9a57f 100644 (file)
@@ -97,6 +97,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
 
                // Set the server IP to cluster
                $serverIp = "cluster";
+
                // Do we have a single server?
                if ($this->getConfigInstance()->readConfig('is_single_server') == "Y") {
                        // Then use that IP for extra security
@@ -104,7 +105,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
                }
 
                // One-way data we need for "extra-salting" the random number
-               // @TODO Add site for stronger salt!
+               // @TODO Add site key for stronger salt!
                $this->extraSalt = sha1($serverIp . ":" . getenv('SERVER_SOFTWARE') . ":" . $this->getConfigInstance()->readConfig('date_key') . ":" . serialize($this->getDatabaseInstance()->getConnectionData()));
 
                // Get config entry for max salt length
index fad4cf4a3f5a956a63092319b477076d58f0586b..7fada106d4501510690254e537f3d9fb6742a4ef 100644 (file)
@@ -283,6 +283,53 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                }
        }
 
+       /**
+        * Setter for template type. Only "html", "emails" and "compiled" should
+        * be sent here
+        *
+        * @param       $templateType   The current template's type
+        * @return      void
+        */
+       private final function setTemplateType ($templateType) {
+               // Cast it
+               $templateType = (string) $templateType;
+
+               // And set it (only 2 letters)
+               $this->templateType = $templateType;
+       }
+
+       /**
+        * Setter for the last loaded template's FQFN
+        *
+        * @param       $template       The last loaded template
+        * @return      void
+        */
+       private final function setLastTemplate ($template) {
+               // Cast it to string
+               $template = (string) $template;
+               $this->lastTemplate = $template;
+       }
+
+       /**
+        * Getter for the last loaded template's FQFN
+        *
+        * @return      $template       The last loaded template
+        */
+       private final function getLastTemplate () {
+               return $this->lastTemplate;
+       }
+
+       /**
+        * Assign a given congfiguration variable with a value
+        *
+        * @param       $var    The configuration variable we want to assign
+        * @return      void
+        */
+       private final function assignConfigVariable ($var) {
+               // Sweet and simple...
+               $this->configVariables[$var] = $this->getConfigInstance()->readConfig($var);
+       }
+
        /**
         * Initialize the variable stack. This holds all variables for later
         * compilation.
@@ -372,8 +419,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        /**
         * Setter for path of compiled templates
         *
-        * @param               $compileOutputPath              The local base path for all
-        *                                                              compiled templates
+        * @param       $compileOutputPath      The local base path for all compiled
+        *                                                              templates
         * @return      void
         */
        public final function setCompileOutputPath ($compileOutputPath) {
@@ -384,21 +431,6 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                $this->compileOutputPath = $compileOutputPath;
        }
 
-       /**
-        * Setter for template type. Only "html", "emails" and "compiled" should
-        * be sent here
-        *
-        * @param               $templateType   The current template's type
-        * @return      void
-        */
-       private final function setTemplateType ($templateType) {
-               // Cast it
-               $templateType = (string) $templateType;
-
-               // And set it (only 2 letters)
-               $this->templateType = $templateType;
-       }
-
        /**
         * Getter for template type
         *
@@ -408,32 +440,11 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                return $this->templateType;
        }
 
-       /**
-        * Setter for the last loaded template's FQFN
-        *
-        * @param               $template               The last loaded template
-        * @return      void
-        */
-       private final function setLastTemplate ($template) {
-               // Cast it to string
-               $template = (string) $template;
-               $this->lastTemplate = $template;
-       }
-
-       /**
-        * Getter for the last loaded template's FQFN
-        *
-        * @return      $template               The last loaded template
-        */
-       private final function getLastTemplate () {
-               return $this->lastTemplate;
-       }
-
        /**
         * Assign (add) a given variable with a value
         *
-        * @param               $var            The variable we are looking for
-        * @param               $value  The value we want to store in the variable
+        * @param       $var    The variable we are looking for
+        * @param       $value  The value we want to store in the variable
         * @return      void
         */
        public final function assignVariable ($var, $value) {
@@ -450,22 +461,10 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                }
        }
 
-       /**
-        * Assign a given congfiguration variable with a value
-        *
-        * @param               $var            The configuration variable we are looking for
-        * @param               $value  The value we want to store in the variable
-        * @return      void
-        */
-       public final function assignConfigVariable ($var, $value) {
-               // Sweet and simple...
-               $this->configVariables[$var] = $value;
-       }
-
        /**
         * Removes a given variable
         *
-        * @param               $var            The variable we are looking for
+        * @param       $var    The variable we are looking for
         * @return      void
         */
        public final function removeVariable ($var) {
@@ -482,7 +481,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        /**
         * Private setter for raw template data
         *
-        * @param               $rawTemplateData        The raw data from the template
+        * @param       $rawTemplateData        The raw data from the template
         * @return      void
         */
        private final function setRawTemplateData ($rawTemplateData) {
@@ -495,6 +494,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
 
        /**
         * Private setter for compiled templates
+        *
+        * @return      void
         */
        private final function setCompiledData ($compiledData) {
                // Cast it to string
@@ -507,7 +508,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        /**
         * Private loader for all template types
         *
-        * @param               $template               The template we shall load
+        * @param       $template       The template we shall load
         * @return      void
         */
        private final function loadTemplate ($template) {
@@ -539,12 +540,12 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        /**
         * A private loader for raw template names
         *
-        * @param               $fqfn   The full-qualified file name for a template
+        * @param       $fqfn   The full-qualified file name for a template
         * @return      void
         * @throws      NullPointerException    If $inputInstance is null
         * @throws      NoObjectException               If $inputInstance is not an object
         * @throws      MissingMethodException  If $inputInstance is missing a
-        *                                                              required method
+        *                                                                      required method
         */
        private function loadRawTemplateData ($fqfn) {
                // Get a input/output instance from the middleware
@@ -576,9 +577,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         * Try to assign an extracted template variable as a "content" or "config"
         * variable.
         *
-        * @param               $varName                The variable's name (shall be content or
-        *                                              config) by default
-        * @param               $var                    The variable we want to assign
+        * @param       $varName        The variable's name (shall be content orconfig) by
+        *                                              default
+        * @param       $var            The variable we want to assign
         */
        private function assignTemplateVariable ($varName, $var) {
                // Is it not a config variable?
@@ -587,7 +588,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        $this->assignVariable($var, "");
                } else {
                        // Configuration variables
-                       $this->assignConfigVariable($var, $this->getConfigInstance()->readConfig($var));
+                       $this->assignConfigVariable($var);
                }
        }
 
@@ -617,7 +618,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        /**
         * Main analysis of the loaded template
         *
-        * @param               $templateMatches        Found template place-holders, see below
+        * @param       $templateMatches        Found template place-holders, see below
         * @return      void
         *
         *---------------------------------
@@ -676,8 +677,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
        /**
         * Compile a given raw template code and remember it for later usage
         *
-        * @param               $code           The raw template code
-        * @param               $template               The template's name
+        * @param       $code           The raw template code
+        * @param       $template       The template's name
         * @return      void
         */
        private function compileCode ($code, $template) {
@@ -712,7 +713,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
         * Insert all given and loaded templates by running through all loaded
         * codes and searching for their place-holder in the main template
         *
-        * @param               $templateMatches        See method analyzeTemplate()
+        * @param       $templateMatches        See method analyzeTemplate()
         * @return      void
         */
        private function insertAllTemplates (array $templateMatches) {
index cc9c44348058bd2e9645030a5d2950a22554955e..2221111eabda84589ede9bfc3e360934065fd4a9 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
+       /**
+        * Instance of the database result
+        */
+       private $resultInstance = null;
+
        /**
         * Username of current user
         */
@@ -104,6 +109,38 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
                return $userInstance;
        }
 
+       /**
+        * "Getter" for databse entry
+        *
+        * @return      $entry  An array with database entries
+        * @throws      NullPointerException    If the database result is not found
+        * @throws      InvalidDatabaseResultException  If the database result is invalid
+        */
+       private function getDatabaseEntry () {
+               // Is there an instance?
+               if (is_null($this->resultInstance)) {
+                       // Throw new exception
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } // END - if
+
+               // Rewind it
+               $this->resultInstance->rewind();
+
+               // Do we have an entry?
+               if (!$this->resultInstance->valid()) {
+                       throw new InvalidDatabaseResultException(array($this, $this->resultInstance), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
+               } // END - if
+
+               // Get next entry
+               $this->resultInstance->next();
+
+               // Fetch it
+               $entry = $this->resultInstance->current();
+
+               // And return it
+               return $entry;
+       }
+
        /**
         * Setter for username
         *
@@ -151,21 +188,27 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
                // By default the username does not exist
                $exists = false;
 
-               // Get a UserDatabaseWrapper instance
-               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+               // Is a previous result there?
+               if (is_null($this->resultInstance)) {
+                       // Get a UserDatabaseWrapper instance
+                       $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
-               // Create a search criteria
-               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+                       // Create a search criteria
+                       $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
-               // Add the username as a criteria and set limit to one entry
-               $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
-               $criteriaInstance->setLimit(1);
+                       // Add the username as a criteria and set limit to one entry
+                       $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
+                       $criteriaInstance->setLimit(1);
 
-               // Get a search result
-               $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+                       // Get a search result
+                       $this->resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+               } else {
+                       // Rewind it
+                       $this->resultInstance->rewind();
+               }
 
                // Search for it
-               if ($result->next()) {
+               if ($this->resultInstance->next()) {
                        // Entry found
                        $exists = true;
                } // END - if
@@ -183,21 +226,27 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
                // By default the email does not exist
                $exists = false;
 
-               // Get a UserDatabaseWrapper instance
-               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+               // Is a previous result there?
+               if (is_null($this->resultInstance)) {
+                       // Get a UserDatabaseWrapper instance
+                       $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
-               // Create a search criteria
-               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+                       // Create a search criteria
+                       $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
-               // Add the username as a criteria and set limit to one entry
-               $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
-               $criteriaInstance->setLimit(1);
+                       // Add the username as a criteria and set limit to one entry
+                       $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
+                       $criteriaInstance->setLimit(1);
 
-               // Get a search result
-               $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+                       // Get a search resultInstance
+                       $this->resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+               } else {
+                       // Rewind it
+                       $this->resultInstance->rewind();
+               }
 
                // Search for it
-               if ($result->next()) {
+               if ($this->resultInstance->next()) {
                        // Entry found
                        $exists = true;
                } // END - if
@@ -227,13 +276,13 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
                $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
                $criteriaInstance->setLimit(1);
 
-               // Get a search result
-               $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+               // Get a search resultInstance
+               $this->resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
 
                // Search for it
-               if ($result->next()) {
+               if ($this->resultInstance->next()) {
                        // Get the current entry (can only be one!)
-                       $entry = $result->current();
+                       $entry = $this->resultInstance->current();
 
                        // So does the hashes match?
                        $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
@@ -253,6 +302,28 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
        public function addUpdateData ($column, $value) {
                $this->partialStub("Column={$column}, value={$value}");
        }
+
+       /**
+        * "Getter" for user's password hash
+        *
+        * @return      $passHash       User's password hash from database result
+        */
+       public function getPasswordHash () {
+               // Default is missing password hash
+               $passHash = null;
+
+               // Get a database entry
+               $entry = $this->getDatabaseEntry();
+
+               // Is the password hash there?
+               if (isset($entry['pass_hash'])) {
+                       // Get it
+                       $passHash = $entry['pass_hash'];
+               }
+
+               // And return the hash
+               return $passHash;
+       }
 }
 
 // [EOF]
index 50571624abfeeac3611f4ad9f0c39c3eaf7ae363..5e611b4b3b820aac236ea702f64269cbaf1a1385 100644 (file)
@@ -182,6 +182,15 @@ $cfg->setConfigEntry('password_validator_class', "PasswordValidatorFilter");
 // CFG: RULES-ACCEPTED-FILTER
 $cfg->setConfigEntry('rules_accepted_class', "RulesAcceptedFilter");
 
+// CFG: USERNAME-VERIFIER
+$cfg->setConfigEntry('username_verifier_class', "UserNameVerifierFilter");
+
+// CFG: EMAIL-VERIFIER
+$cfg->setConfigEntry('email_verifier_class', "EmailVerifierFilter");
+
+// CFG: PASSWORD-VERIFIER
+$cfg->setConfigEntry('password_verifier_class', "PasswordVerifierFilter");
+
 // CFG: CRYPTO-HELPER
 $cfg->setConfigEntry('crypto_class', "CryptoHelper");
 
@@ -191,6 +200,9 @@ $cfg->setConfigEntry('rng_class', "RandomNumberGenerator");
 // CFG: USER-DB-WRAPPER
 $cfg->setConfigEntry('user_db_wrapper_class', "UserDatabaseWrapper");
 
+// CFG: NEWS-DB-WRAPPER
+$cfg->setConfigEntry('news_db_wrapper_class', "NewsDatabaseWrapper");
+
 // CFG: WEB-CMD-RESOLVER
 $cfg->setConfigEntry('web_cmd_resolver_class', "WebCommandResolver");
 
@@ -210,7 +222,7 @@ $cfg->setConfigEntry('rnd_str_length', 128);
 $cfg->setConfigEntry('hash_mask', "%1s:%2s:%3s"); // 1=salt, 2=extra salt, 3=plain password
 
 // CFG: IS-SINGLE-SERVER
-$cfg->setConfigEntry('is_single_server', "Y");
+$cfg->setConfigEntry('is_single_server', "N");
 
 // CFG: POST-REGISTRATION-ACTION
 $cfg->setConfigEntry('post_registration_class', "LoginAfterRegistrationAction");
index fa9c771d9f23912c58b003725cf68f51d0917c5a..5e9ac7ba6b968b06ec60e0d250c545e6a717eac1 100644 (file)
@@ -240,7 +240,7 @@ class ClassLoader {
 
                // If the basePath is false it is invalid
                if ($basePath2 === false) {
-                       // TODO: Do not die here.
+                       // @TODO: Do not die here.
                        die("Cannot read {$basePath} !");
                } else {
                        // Set base path
index 48976ab9738d0d5034fd46860f766b190a987402..857b1561ba6e88ae5e09a3c20ef388835583df1a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
 <?php
 // Developer mode active? Comment out if no dev!
-//define('DEVELOPER', true);
+define('DEVELOPER', true);
 //xdebug_start_trace();
 /**
  * The main class with the entry point to the whole application. This class
@@ -14,7 +14,7 @@
  * @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
+ * @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
@@ -69,7 +69,7 @@ class ApplicationEntryPoint {
                }
 
                // Get some instances
-               $tpl = FrameworkConfiguration::getInstance()->readConfig('tpl_engine');
+               $tpl = FrameworkConfiguration::getInstance()->readConfig('template_class');
                $lang = LanguageSystem::getInstance();
                $io = FileIoHandler::getInstance();
 
@@ -78,7 +78,7 @@ class ApplicationEntryPoint {
                        // Use the template engine for putting out (nicer look) the message
                        try {
                                // Get the template instance from our object factory
-                               $tplEngine = ObjectFactory::createObjectByConfiguredName('tpl_engine', array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io));
+                               $tplEngine = ObjectFactory::createObjectByConfiguredName('template_class', array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io));
                        } catch (BasePathIsEmptyException $e) {
                                die(sprintf("[Main:] Could not initialize template engine for this reason: <strong>%s</strong>",
                                        $e->getMessage()
@@ -110,6 +110,7 @@ class ApplicationEntryPoint {
                        // Assign variables
                        $tplEngine->assignVariable('message', $message);
                        $tplEngine->assignVariable('backtrace', $backtrace);
+                       $tplEngine->assignVariable('total_includes', ClassLoader::getInstance()->getTotal());
                        $tplEngine->assignVariable('total_objects', ObjectFactory::getTotal());
 
                        // Load the template