Results are now searchable and iterateable, insertDataSet renamed to queryInsertDataS...
authorRoland Häder <roland@mxchange.org>
Thu, 12 Jun 2008 22:51:28 +0000 (22:51 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 12 Jun 2008 22:51:28 +0000 (22:51 +0000)
38 files changed:
.gitattributes
application/selector/loader.php
application/ship-simu/config.php
application/ship-simu/loader.php
application/ship-simu/main/login/class_ShipSimuUserLogin.php
application/ship-simu/main/login/helper/.htaccess [new file with mode: 0644]
application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php [new file with mode: 0644]
inc/classes/exceptions/helper/class_UserInstanceMissingException.php [new file with mode: 0644]
inc/classes/exceptions/user/class_UserPasswordMismatchException.php [new file with mode: 0644]
inc/classes/interfaces/cache/class_Cacheable.php
inc/classes/interfaces/class_
inc/classes/interfaces/criteria/class_Criteria.php
inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php
inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php
inc/classes/interfaces/login/class_LoginableUser.php
inc/classes/interfaces/registration/class_UserRegister.php
inc/classes/interfaces/registry/class_Register.php
inc/classes/interfaces/registry/class_Registerable.php
inc/classes/interfaces/result/.htaccess [new file with mode: 0644]
inc/classes/interfaces/result/class_SearchableResult.php [new file with mode: 0644]
inc/classes/interfaces/user/class_ManageableUser.php
inc/classes/main/actions/class_BaseAction.php
inc/classes/main/cache/class_MemoryCache.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/class_
inc/classes/main/criteria/class_SearchCriteria.php
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
inc/classes/main/debug/class_DebugConsoleOutput.php
inc/classes/main/helper/login/.htaccess [new file with mode: 0644]
inc/classes/main/helper/login/class_BaseLoginHelper.php [new file with mode: 0644]
inc/classes/main/registration/class_BaseRegistration.php
inc/classes/main/registry/class_Registry.php
inc/classes/main/result/class_DatabaseResult.php
inc/classes/main/rng/class_RandomNumberGenerator.php
inc/classes/main/user/class_User.php
inc/classes/middleware/database/class_DatabaseConnection.php

index 343d112be1cb558694c82a8a2f79490af0f5781d..e2ffacadf95cb017ec7642278bf56bfa26fd4325 100644 (file)
@@ -84,6 +84,8 @@ application/ship-simu/main/factories/.htaccess -text
 application/ship-simu/main/factories/class_ShipSimuWebNewsFactory.php -text
 application/ship-simu/main/login/.htaccess -text
 application/ship-simu/main/login/class_ShipSimuUserLogin.php -text
+application/ship-simu/main/login/helper/.htaccess -text
+application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php -text
 application/ship-simu/main/parts/.htaccess -text
 application/ship-simu/main/parts/class_BaseShipPart.php -text
 application/ship-simu/main/parts/maschineroom/.htaccess -text
@@ -173,6 +175,7 @@ inc/classes/exceptions/helper/class_FormClosedException.php -text
 inc/classes/exceptions/helper/class_FormGroupClosedException.php -text
 inc/classes/exceptions/helper/class_FormOpenedException.php -text
 inc/classes/exceptions/helper/class_InvalidFormNameException.php -text
+inc/classes/exceptions/helper/class_UserInstanceMissingException.php -text
 inc/classes/exceptions/io/.htaccess -text
 inc/classes/exceptions/io/class_DirPointerNotOpenedException.php -text
 inc/classes/exceptions/io/class_FilePointerNotOpenedException.php -text
@@ -224,6 +227,7 @@ inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php -te
 inc/classes/exceptions/template/class_ViewHelperNotFoundException.php -text
 inc/classes/exceptions/user/.htaccess -text
 inc/classes/exceptions/user/class_UserEmailMissingException.php -text
+inc/classes/exceptions/user/class_UserPasswordMismatchException.php -text
 inc/classes/exceptions/user/class_UsernameMissingException.php -text
 inc/classes/interfaces/.htaccess -text
 inc/classes/interfaces/application/.htaccess -text
@@ -278,6 +282,8 @@ inc/classes/interfaces/resolver/class_CommandResolver.php -text
 inc/classes/interfaces/resolver/class_ControllerResolver.php -text
 inc/classes/interfaces/response/.htaccess -text
 inc/classes/interfaces/response/class_Responseable.php -text
+inc/classes/interfaces/result/.htaccess -text
+inc/classes/interfaces/result/class_SearchableResult.php -text
 inc/classes/interfaces/template/.htaccess -text
 inc/classes/interfaces/template/class_CompileableTemplate.php -text
 inc/classes/interfaces/template/view/class_ViewHelper.php -text
@@ -359,6 +365,8 @@ inc/classes/main/filter/validator/class_UserNameValidatorFilter.php -text
 inc/classes/main/helper/.htaccess -text
 inc/classes/main/helper/class_ -text
 inc/classes/main/helper/class_BaseHelper.php -text
+inc/classes/main/helper/login/.htaccess -text
+inc/classes/main/helper/login/class_BaseLoginHelper.php -text
 inc/classes/main/helper/web/.htaccess -text
 inc/classes/main/helper/web/class_WebFormHelper.php -text
 inc/classes/main/io/.htaccess -text
index ace39f5aeea890c36acd349785e38028137a283e..9869069912397671d015e08b20fc733807d1f7b0 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// Is the application instance set?
-if (!isset($application)) {
-       // We need this!
-       ApplicationEntryPoint::app_die("[Main:] Interne Variable <strong>application</strong> nicht gefunden!");
-}
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
 
 // Load all classes
-ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/", FrameworkConfiguration::getInstance()->readConfig('application_path'), $application));
+ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/", $cfg->readConfig('application_path'), $cfg->readConfig('app_name')));
 
 // Clean up the global namespace
 unset($lowerClasses);
index 2d5cd1f45ee3ea2aba4cb46adedbb618ec10b3fa..87c01c45a80e1daadf752f30abd1466f7d3df3d7 100644 (file)
@@ -79,5 +79,8 @@ $cfg->setConfigEntry('login_user', "ShipSimuUserLogin");
 // CFG: USER-STATUS-REGISTER
 $cfg->setConfigEntry('user_status_register', "UNCONFIRMED");
 
+// CFG: LOGIN-HELPER
+$cfg->setConfigEntry('login_helper', "ShipSimuLoginHelper");
+
 // [EOF]
 ?>
index 0ffd93f30c6340c2aff1538a11df0616abda7dd8..d60af4c88814987d00756f599962fa3021f8ef0e 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// Is the application instance set?
-if (!isset($application)) {
-       // We need this!
-       ApplicationEntryPoint::app_die("[Main:] Interne Variable <strong>application</strong> nicht gefunden!");
-}
+// Get config instance
+$cfg = FrameworkConfiguration::getInstance();
 
 // Load all classes for the application
 foreach ($lowerClasses as $class) {
        // Try to load the application classes
        try {
-               ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", FrameworkConfiguration::getInstance()->readConfig('application_path'), $application, $class));
+               ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", $cfg->readConfig('application_path'), $cfg->readConfig('app_name'), $class));
        } catch (PathIsNoDirectoryException $e) {
                ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
                        $application,
index 7caea517ce48879a22e73c06fc8020e6aceceacb..a043de8ba74c0ed28cedc5ab4621ebdcd608ab6c 100644 (file)
@@ -66,8 +66,8 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
         *                                                                              was detected
         * @throws      MissingMethodException          If a method was not found in the
         *                                                                              User class
-        * @throws      UserEmailMissingException       If user with given email address was
-        *                                                                              not found in database
+        * @throws      UserPasswordMismatchException   If the supplied password did not
+        *                                                                              match with the stored password
         */
        public function doLogin (Requestable $requestInstance) {
                // By default no method is selected
@@ -101,16 +101,24 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                if (is_null($userInstance)) {
                        // Get a user instance
                        $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), $method), array($data));
+
+                       // Remember this new instance in registry
+                       Registry::getRegistry()->addInstance($userInstance);
                } // END - if
 
-               // If we have email login then check if a user account with that email exists!
-               if (($method == "createUserByEmail") && (!$userInstance->ifEmailAddressExists())) {
-                       // The user account is missing!
-                       throw new UserEmailMissingException(array($this, $data), User::EXCEPTION_USER_EMAIL_NOT_FOUND);
+               // Is the password correct?
+               if (!$userInstance->ifPasswordHashMatches($requestInstance)) {
+                       // Mismatching password
+                       throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
                } // END - if
 
-               // Partially finished!
-               $this->partialStub("userInstance set, continue with password verification");
+               // Now do the real login. This can be cookie- or session-based login
+               // which depends on the admins setting then on the user's taste.
+               // 1) Get a login helper instance
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper', array($requestInstance));
+
+               // 2) Execute the login. This will now login...
+               $helperInstance->executeLogin();
        }
 }
 
diff --git a/application/ship-simu/main/login/helper/.htaccess b/application/ship-simu/main/login/helper/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php b/application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php
new file mode 100644 (file)
index 0000000..13bed29
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+/**
+ * A helper for Ship-Simu to login. This login helper first checks what setting
+ * (cookie or session) the admin has choosen then overwrites it with the setting
+ * from current user. The registry instance should hold an instance of this user
+ * class at key 'user' else an exception will be thrown. After this the setting
+ * from a login form will be taken as login method and be stored in database
+ * for later usage.
+ *
+ * The user shall be able to choose "Default login method" or similar to use his
+ * own login method.
+ *
+ * @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
+ * @todo               Find an interface name for login helper
+ *
+ * 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 ShipSimuLoginHelper extends BaseLoginHelper {
+       // Exception constants
+       const EXCEPTION_INVALID_USER_INSTANCE = 0xf00;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Login helper for Ship-Simu");
+
+               // Create unique ID number
+               $this->generateUniqueId();
+       }
+
+       /**
+        * Creates an instance of this class by given request instance
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      $helperInstance         An instance of this helper class
+        * @throws      UserInstanceMissingException    If the user instance in registry
+        *                                                                                      is missing or invalid
+        */
+       public final static function createShipSimuLoginHelper (Requestable $requestInstance) {
+               // Get a new instance first
+               $helperInstance = new ShipSimuLoginHelper();
+
+               // Get a user instance from registry
+               $userInstance = Registry::getRegistry()->getInstance('user');
+
+               // Is this instance valid?
+               if (!$userInstance instanceof ManageableUser) {
+                       // Thrown an exception here
+                       throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE);
+               } // END - if
+
+               // Get the login method from request
+               $methodRequest = $requestInstance->getRequestElement('login_method');
+
+               // Now, if that wents fine we can check if the request includes a login method entry
+               if ((!is_null($methodRequest)) && ($methodRequest != "default") && ($methodRequest != $userInstance->getLoginMethod())) {
+                       // Okay, the login method has been choosen by user so remember it
+                       $helperInstance->setLoginMethod($methodRequest);
+
+                       // Remeber that we need to update the user account as well
+                       $userInstance->addUpdateData('login_method', $methodRequest);
+               } elseif (($methodRequest == "default") && (is_string($userInstance->getLoginMethod()))) {
+                       // Choose default method from user
+                       $helperInstance->setLoginMethod($userInstance->getLoginMethod());
+               } else {
+                       // Set default login method from config
+                       $helperInstance->setDefaultLoginMethod();
+               }
+               
+               // Return the prepared instance
+               return $helperInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/helper/class_UserInstanceMissingException.php b/inc/classes/exceptions/helper/class_UserInstanceMissingException.php
new file mode 100644 (file)
index 0000000..ecdf3c7
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * An exception thrown when a user instance 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 UserInstanceMissingException extends FrameworkException {
+       /**
+        * The constructor
+        *
+        * @param               $classArray             Array with class instance and registry key
+        * @param               $code                   Code number for the exception
+        * @return      void
+        */
+       public function __construct (array $classArray, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:%d] Registry key <u>%s</u> does not include a class with implemented interface <u>ManageableUser</u>.",
+                       $classArray[0]->__toString(),
+                       $this->getLine(),
+                       $classArray[1]
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php
new file mode 100644 (file)
index 0000000..032437c
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * A class for mismatching passwords
+ *
+ * @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 UserPasswordMismatchException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param               $msgArray               The non-optional message for the exception
+        * @param               $code           An optional code for better debugging
+        * @return      void
+        */
+       public function __construct(array $msgArray, $code = 0) {
+               // Create the message
+               $message = sprintf("[%s:%d] Supplied password for user <u>%s</u> did not match with stored password.",
+                       $msgArray[0]->__toString(),
+                       $this->getLine(),
+                       $msgArray[1]->getUserName()
+               );
+
+               // Make sure everything is assigned properly
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index c6fa237371afa603691258bc89db61477f3d003b..23e4f0f490c1c03f2bb7d11e7fab2384af683e58 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * An interface for classes which are "able" to cache
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index 055ad90d6a932b175f3021455b1c663194036758..264d3d903c2321da8c998f3120c74792a419061c 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * 
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index 35b51f35b5a74c775607be64e2c6066073ea69e5..b4bfec60573e2442e708d9c86288ff08c070547c 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * An interface for criterias
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index 2ac9efda9497b2265742d1e7274bf5a97e2ba2a7..785c3c6a9d4b42f9dff449761598e76887fb17f5 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * An interface for local criterias
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface LocalCriteria extends Criteria {
+interface LocalSearchCriteria extends Criteria {
 }
 
 //
index f61df0713e040f6e7026a6b2dd62cefc08d40181..0bdf820adfffe262929e4368be80cc9aeccf3016 100644 (file)
@@ -56,7 +56,7 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface {
         * @throws      UnsupportedCriteriaException    If the criteria is unsupported
         * @throws      SqlException                                    If an SQL error occurs
         */
-       function querySelect ($resultType, $tableName, Criteria $criteriaInstance);
+       function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance);
 
        /**
         * "Inserts" a data set instance into a local file database folder
@@ -65,7 +65,7 @@ interface DatabaseFrontendInterface extends FrameworkDatabaseInterface {
         * @return      void
         * @throws      SqlException    If an SQL error occurs
         */
-       function insertDataSet (StoreableCriteria $dataSetInstance);
+       function queryInsertDataSet (StoreableCriteria $dataSetInstance);
 }
 
 // [EOF]
index c7abf2d8d05004c86668f487103db3336b2daf7e..c9a842a969f0b550b4986cd7f1418ca0cc5457b8 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * An interface for user login classes
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index 9fbf2ff4f152857e2781680cd2f5bcbe188e4e2b..3f04623ca4be215da6e975d9b103d54f78b453d9 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * A class for user registration
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index a750ac1b3740bb44e1772b92d0aae4bf800a8bdd..083679ff897897798e2bb223827b313d1039fc0c 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * An interface for registries
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index 0616d002adfa3bba9d058e5b0a6bec3401152607..5a9105e1b2ccdad5ac9a2c0bb59b7a8129c3064e 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * A class for registerable classes
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
diff --git a/inc/classes/interfaces/result/.htaccess b/inc/classes/interfaces/result/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/result/class_SearchableResult.php b/inc/classes/interfaces/result/class_SearchableResult.php
new file mode 100644 (file)
index 0000000..5afb8f8
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * An interface for searchable results
+ *
+ * @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/>.
+ */
+interface SearchableResult extends FrameworkInterface {
+       /**
+        * Searches for an entry in the data result and returns it
+        *
+        * @param       $criteriaInstance       The criteria to look inside the data set
+        * @return      $result                         Found result entry
+        */
+       function searchEntry (LocalSearchCriteria $criteriaInstance);
+}
+
+// [EOF]
+?>
index 768df477908345a52bb6a547137fe3bc8369e9b3..40c4b73348f030ec7ee8679e132d8e961b7d067f 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface ManageableUser extends FrameworkInterface {
+       /**
+        * Determines wether the username exists or not
+        *
+        * @return      $exists         Wether the username exists
+        */
+       function ifUsernameExists ();
+
+       /**
+        * Determines wether the email exists or not
+        *
+        * @return      $exists         Wether the email exists
+        */
+       function ifEmailAddressExists ();
+
+       /**
+        * Checks if the supplied password hash in request matches with the stored
+        * in database.
+        *
+        * @param       $requestInstance        A requestable class instance
+        * @return      $matches                        Wether the supplied password hash matches
+        */
+       function ifPasswordHashMatches (Requestable $requestInstance);
+
+       /**
+        * Adds data for later complete update
+        *
+        * @param       $column         Column we want to update
+        * @param       $value          New value to store in database
+        * @return      void
+        */
+       function addUpdateData ($column, $value);
 }
 
 //
index 9b2df36d50d7fe562c80e54e3718a37908f2f786..15ba51ef0d5c8eca17639646801af360ef5d07a6 100644 (file)
@@ -3,10 +3,10 @@
  * A general action class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index 01d2a367819df645c6f0251e726154a6537546b4..4cb7459b6d72a47d19a4e5e00beb12455bc44fd7 100644 (file)
@@ -3,10 +3,10 @@
  * A simple memory cache (similar to a registry)
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index 2a0c80768b2b2c7fd2928af4a88e30716f82d640..d8d095f06ac7e9957055aa95d0dfc0e199485559 100644 (file)
@@ -61,7 +61,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * The file I/O instance for the template loader
         */
-       private $fileIOInstance = null;
+       private $fileIoInstance = null;
 
        /***********************
         * Exception codes.... *
@@ -758,20 +758,20 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Private getter for file IO instance
         *
-        * @return      $fileIOInstance An instance to the file I/O sub-system
+        * @return      $fileIoInstance An instance to the file I/O sub-system
         */
        protected final function getFileIoInstance () {
-               return $this->fileIOInstance;
+               return $this->fileIoInstance;
        }
 
        /**
         * Setter for file I/O instance
         *
-        * @param       $fileIOInstance An instance to the file I/O sub-system
+        * @param       $fileIoInstance An instance to the file I/O sub-system
         * @return      void
         */
-       public final function setFileIoInstance (FileIoHandler $fileIOInstance) {
-               $this->fileIOInstance = $fileIOInstance;
+       public final function setFileIoInstance (FileIoHandler $fileIoInstance) {
+               $this->fileIoInstance = $fileIoInstance;
        }
 
        /**
index 628cd0f8eb59cd66aa6b278a8393b48317675fcd..df557367a86f78f29cab9234d9270fc9d090e517 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * 
  *
- * @author             Roland Haeder <webmaster@mxchange.org>
+ * @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
index f948909671be7412d9fa19ac8e744c3847167b3a..fc5b1addd3757b37530196a67e8393841b05a966 100644 (file)
@@ -5,10 +5,10 @@
  * for looking in storages like the database.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index cdde42113806c1e70aa1fbdda9f7a7c68bfbad16..4ec02ad9171256c275b26311527851df3b475cc7 100644 (file)
@@ -3,10 +3,10 @@
  * A helper class for cryptographical things like hashing passwords and so on
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index 151698c7f28b9410837921a480688c516dc4cf62..bf19a67ecdddba1c3c2b8c0c490ce3358ee9a247 100644 (file)
@@ -535,16 +535,10 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @throws      UnsupportedCriteriaException    If the criteria is unsupported
         * @throws      SqlException                                    If an "SQL error" occurs
         */
-       public function querySelect ($resultType, $tableName, Criteria $criteriaInstance) {
+       public function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance) {
                // The result is null by any errors
                $resultData = null;
 
-               // Is this criteria supported?
-               if (!$criteriaInstance instanceof LocalSearchCriteria) {
-                       // Not supported by this database layer
-                       throw new UnsupportedCriteriaException(array($this, $criteriaInstance), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
-               }
-
                // Create full path name
                $pathName = $this->getSavePath() . $tableName . '/';
 
@@ -640,7 +634,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @return      void
         * @throws      SqlException    If an SQL error occurs
         */
-       public function insertDataSet (StoreableCriteria $dataSetInstance) {
+       public function queryInsertDataSet (StoreableCriteria $dataSetInstance) {
                // Create full path name
                $fqfn = sprintf("%s%s/%s.%s",
                        $this->getSavePath(),
index 88bc13fbb24e1ee3b91782005888fb2431f26b4f..1edd236d8d3befd386fb2f288e04a8561280139c 100644 (file)
@@ -139,7 +139,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper {
                $registrationInstance->addElementsToDataSet($dataSetInstance);
 
                // "Insert" this request instance completely into the database
-               $this->getDatabaseInstance()->insertDataSet($dataSetInstance);
+               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
        }
 }
 
index f7dbea7589d2dc47f7e9b81f99a32e747b4442c8..77b28b4bebf6a6982af80f8b6df183d065ffc462 100644 (file)
@@ -21,7 +21,7 @@
  * 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 DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer {
+class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, OutputStreamer, Registerable {
        /**
         * Protected constructor
         *
diff --git a/inc/classes/main/helper/login/.htaccess b/inc/classes/main/helper/login/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/helper/login/class_BaseLoginHelper.php b/inc/classes/main/helper/login/class_BaseLoginHelper.php
new file mode 100644 (file)
index 0000000..25be6a9
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general login helper class
+ *
+ * @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 BaseLoginHelper extends BaseHelper {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Real name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
index 3066d2989d8d369c6cd88fdccd73f54991a18d36..aec7e5ab8a4b59dadec8acaad89f433ab357f983 100644 (file)
@@ -3,10 +3,10 @@
  * A general registration class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index a8abb509266f09293349f4562f675c380566f6d5..308e89c72ba8ca44ad33c7a4d4c5a41144eeaef5 100644 (file)
@@ -3,10 +3,10 @@
  * A registry for several data types
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index 3d48861ba6fd259debbccf177bef32f3a4441e03..c6a0b1149a9d3e1907e019f51711ab0c68e5c74e 100644 (file)
@@ -3,10 +3,10 @@
  * A database result class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
@@ -21,7 +21,7 @@
  * 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 DatabaseResult extends BaseFrameworkSystem {
+class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, SeekableIterator {
        /**
         * Current position in array
         */
@@ -97,7 +97,7 @@ class DatabaseResult extends BaseFrameworkSystem {
                // Is the result valid?
                if ($this->resultArray['status'] === "ok") {
                        // The status is fine so let's have a look for the next entry
-                       if (isset($this->resultArray['rows'][($this->currentPos + 1)])) {
+                       if ($this->valid()) {
                                // Next entry found, so count one up and cache it
                                $this->currentPos++;
                                $this->currentRow = $this->resultArray['rows'][$this->currentPos];
@@ -108,6 +108,89 @@ class DatabaseResult extends BaseFrameworkSystem {
                // Return the result
                return $nextValid;
        }
+
+       /**
+        * Seeks for to a specified position
+        *
+        * @param       $index  Index to seek for
+        * @return      void
+        */
+       public function seek ($index) {
+               // Rewind to beginning
+               $this->rewind();
+
+               // Search for the entry
+               while ($this->currentPos < $index && ($this->valid())) {
+                       // Continue on
+                       $this->next();
+               } // END - while
+       }
+
+       /**
+        * Gives back the current position or null if not found
+        *
+        * @return      $current        Current element to give back
+        */
+       public function current () {
+               // Default is not found
+               $current = null;
+
+               // Does the current enty exist?
+               if (isset($this->resultArray['rows'][$this->currentPos])) {
+                       // Then get it
+                       $current = $this->resultArray['rows'][$this->currentPos];
+               } // END - if
+
+               // Return the result
+               return $current;
+       }
+
+       /**
+        * Checks if next() and rewind will give a valid result
+        *
+        * @return      $isValid Wether the next/rewind entry is valid
+        */
+       public function valid () {
+               // By default nothing is valid
+               $isValid = false;
+
+               // Check if 
+               if ((isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) {
+                       // All fine!
+                       $isValid = true;
+               } // END - if
+
+               // Return the result
+               return $isValid;
+       }
+
+       /**
+        * Gets the current key of iteration
+        *
+        * @return      $currentPos     Key from iterator
+        */
+       public function key () {
+               return $this->currentPos;
+       }
+
+       /**
+        * Rewind to the beginning
+        *
+        * @return      void
+        */
+       public function rewind () {
+               $this->currentPos = 0;
+       }
+
+       /**
+        * Searches for an entry in the data result and returns it
+        *
+        * @param       $criteriaInstance       The criteria to look inside the data set
+        * @return      $result                         Found result entry
+        */
+       public function searchEntry (LocalSearchCriteria $criteriaInstance) {
+               die("OK");
+       }
 }
 
 // [EOF]
index b50af11d865a3f3b051be397b5ff13b96d441ecd..8875a4ca06ba2b8d4076973cf39558c8351ff9ed 100644 (file)
@@ -3,10 +3,10 @@
  * A standard random number generator
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @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.mxchange.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
index 25e2cc3ffd1e5cdd2745da5d444425878062355e..302c117d73d475c0fdb4d6129b2fbd7bdc60a5d2 100644 (file)
@@ -35,6 +35,7 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
        // Exceptions
        const EXCEPTION_USERNAME_NOT_FOUND   = 0xd00;
        const EXCEPTION_USER_EMAIL_NOT_FOUND = 0xd01;
+       const EXCEPTION_USER_PASS_MISMATCH   = 0xd02;
 
        /**
         * Protected constructor
@@ -147,8 +148,8 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
         * @return      $exists         Wether the username exists
         */
        public function ifUsernameExists () {
-               // By default the username does exist
-               $exists = true;
+               // By default the username does not exist
+               $exists = false;
 
                // Get a UserDatabaseWrapper instance
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
@@ -164,9 +165,9 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
                $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
 
                // Search for it
-               if (!$result->next()) {
-                       // Entry not found
-                       $exists = false;
+               if ($result->next()) {
+                       // Entry found
+                       $exists = true;
                } // END - if
 
                // Return the status
@@ -179,8 +180,8 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
         * @return      $exists         Wether the email exists
         */
        public function ifEmailAddressExists () {
-               // By default the username does exist
-               $exists = true;
+               // By default the email does not exist
+               $exists = false;
 
                // Get a UserDatabaseWrapper instance
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
@@ -196,14 +197,62 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
                $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
 
                // Search for it
-               if (!$result->next()) {
-                       // Entry not found
-                       $exists = false;
+               if ($result->next()) {
+                       // Entry found
+                       $exists = true;
                } // END - if
 
                // Return the status
                return $exists;
        }
+
+       /**
+        * Checks if the supplied password hash in request matches with the stored
+        * in database.
+        *
+        * @param       $requestInstance        A requestable class instance
+        * @return      $matches                        Wether the supplied password hash matches
+        */
+       public function ifPasswordHashMatches (Requestable $requestInstance) {
+               // By default nothing matches... ;)
+               $matches = false;
+
+               // Get a UserDatabaseWrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
+
+               // Create a search criteria
+               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria');
+
+               // 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);
+
+               // Search for it
+               if ($result->next()) {
+                       // Get the current entry (can only be one!)
+                       $entry = $result->current();
+
+                       // So does the hashes match?
+                       $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
+               } // END - if
+
+               // Return the status
+               return $matches;
+       }
+
+       /**
+        * Adds data for later complete update
+        *
+        * @param       $column         Column we want to update
+        * @param       $value          New value to store in database
+        * @return      void
+        */
+       public function addUpdateData ($column, $value) {
+               $this->partialStub("Column={$column}, value={$value}");
+       }
 }
 
 // [EOF]
index 0c428075180f97e19c36f1dfa42e1cb5718ddac9..d5661d20ddb88e5c1a1027cab0462004fdecf81d 100644 (file)
@@ -158,12 +158,12 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
         * @param       $dataSetInstance        A storeable data set
         * @return      void
         */
-       public function insertDataSet (StoreableCriteria $dataSetInstance) {
+       public function queryInsertDataSet (StoreableCriteria $dataSetInstance) {
                // Connect to the database
                $this->dbLayer->connectToDatabase();
 
                // Ask the database layer
-               $this->dbLayer->insertDataSet($dataSetInstance);
+               $this->dbLayer->queryInsertDataSet($dataSetInstance);
        }
 }