Ship-Simu now has its own member/guest implementations
authorRoland Häder <roland@mxchange.org>
Tue, 1 Jul 2008 11:08:21 +0000 (11:08 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 1 Jul 2008 11:08:21 +0000 (11:08 +0000)
17 files changed:
.gitattributes
application/ship-simu/config.php
application/ship-simu/main/login/class_ShipSimuGuestLogin.php
application/ship-simu/main/login/class_ShipSimuUserLogin.php
application/ship-simu/main/user/.htaccess [new file with mode: 0644]
application/ship-simu/main/user/class_ShipSimuGuest.php [new file with mode: 0644]
application/ship-simu/main/user/class_ShipSimuMember.php [new file with mode: 0644]
db/company_user/.htaccess [new file with mode: 0644]
inc/classes/main/filter/auth/class_UserAuthFilter.php
inc/classes/main/filter/validator/class_EmailValidatorFilter.php
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
inc/classes/main/filter/verifier/class_EmailValidatorFilter.php
inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php
inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php
inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php
inc/classes/main/user/class_BaseUser.php
inc/classes/main/user/member/class_Member.php

index 2084758942c71ba1673686d533a13e1ac997616c..4efc684fd25dc03e2cd3318d43804c6f45408e7c 100644 (file)
@@ -176,6 +176,9 @@ application/ship-simu/main/structures/extended/decks/class_BaseDeck.php -text
 application/ship-simu/main/structures/extended/lower/.htaccess -text
 application/ship-simu/main/structures/extended/upper/.htaccess -text
 application/ship-simu/main/structures/extended/upper/class_Bridge.php -text
+application/ship-simu/main/user/.htaccess -text
+application/ship-simu/main/user/class_ShipSimuGuest.php -text
+application/ship-simu/main/user/class_ShipSimuMember.php -text
 application/ship-simu/main/wrapper/.htaccess -text
 application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php -text
 application/ship-simu/starter.php -text
@@ -213,6 +216,7 @@ application/ship-simu/templates/images/de/image/base_code.itp -text
 application/ship-simu/templates/images/de/image/code_captcha.itp -text
 /clear-cache.sh -text
 db/.htaccess -text
+db/company_user/.htaccess -text
 db/news/.htaccess -text
 db/user/.htaccess -text
 devel/.htaccess -text
index ef95a7c428defb530b9e5220896f5e078b8d6030..242de41c0b7c12d07dfd5eea84388197dbca6806 100644 (file)
@@ -244,5 +244,11 @@ $cfg->setConfigEntry('image_template_class', "ImageTemplateEngine");
 // CFG: ADMIN-EMAIL
 $cfg->setConfigEntry('admin_email', "you@some-hoster.invalid");
 
+// CFG: USER-CLASS
+$cfg->setConfigEntry('user_class', "ShipSimuMember");
+
+// CFG: GUEST-CLASS
+$cfg->setConfigEntry('guest_class', "ShipSimuGuest");
+
 // [EOF]
 ?>
index b59eb2b9d6ecf722a17d19a012d00a4d210b2f94..24c44f65c270cfd6a0ddf03cfd0c4d8fdda750e6 100644 (file)
@@ -83,9 +83,9 @@ class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser {
                // Detect login method (username or email) and try to get a userinstance
                if (!is_null($requestInstance->getRequestElement('user'))) {
                        // Username found!
-                       $method = "createGuestByUsername";
+                       $method = 'createGuestByUsername';
                        $data = $requestInstance->getRequestElement('user');
-               }
+               } // END - if
 
                // Is a method detected?
                if (is_null($method)) {
index 367103ca2021995e23bedf871ac2aa4524da2b27..7ca65d2da16f8c757511972b76eaf339f29f9565 100644 (file)
@@ -85,7 +85,7 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                // Is there an instance?
                if (is_null($userInstance)) {
                        // Get a user instance
-                       $userInstance = Member::createUserByRequest($requestInstance);
+                       $userInstance = Member::createMemberByRequest($requestInstance);
 
                        // Remember this new instance in registry
                        Registry::getRegistry()->addInstance($userInstance);
diff --git a/application/ship-simu/main/user/.htaccess b/application/ship-simu/main/user/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/ship-simu/main/user/class_ShipSimuGuest.php b/application/ship-simu/main/user/class_ShipSimuGuest.php
new file mode 100644 (file)
index 0000000..1f6edc3
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/**
+ * A special guest class for Ship-Simu!
+ *
+ * @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 ShipSimuGuest extends Guest {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Special guest class for Ship-Simu");
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/ship-simu/main/user/class_ShipSimuMember.php b/application/ship-simu/main/user/class_ShipSimuMember.php
new file mode 100644 (file)
index 0000000..b62c7d3
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/**
+ * A special member class for Ship-Simu!
+ *
+ * @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 ShipSimuMember extends Member {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("Special member class for Ship-Simu");
+       }
+}
+
+// [EOF]
+?>
diff --git a/db/company_user/.htaccess b/db/company_user/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
index 25641dc3b90b6debc00e26d57d685d303c021857..572d2b0f2eb1df4ac542af6baec01ae071c122d4 100644 (file)
@@ -79,6 +79,7 @@ class UserAuthFilter extends BaseFilter implements Filterable {
         * @return      void
         * @throws      UserAuthorizationException      If the auth login was not found or if it was invalid
         * @throws      UserPasswordMismatchException   If the supplied password hash does not match
+        * @throws      ClassNotFoundException  If the user (guest/member) class was not found
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Then get an auth instance for checking and updating the auth cookies
@@ -108,13 +109,24 @@ class UserAuthFilter extends BaseFilter implements Filterable {
 
                // Now, try to get a user or guest instance
                if ($authLogin == $this->getConfigInstance()->readConfig('guest_login_user')) {
-                       // Guest login!
-                       $userInstance = Guest::createGuestByUserName($authLogin);
+                       // Set class
+                       $className = $this->getConfigInstance()->readConfig('guest_class');
+                       $methodName = 'createGuestByUserName';
                } else {
                        // Regular user account
-                       $userInstance = Member::createUserByUserName($authLogin);
+                       $className = $this->getConfigInstance()->readConfig('user_class');
+                       $methodName = 'createMemberByUserName';
                }
 
+               // Does the guest class exist?
+               if (!class_exists($className)) {
+                       // Then abort here
+                       throw new ClassNotFoundException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND);
+               } // END - if
+
+               // Now try the dynamic login
+               $userInstance = call_user_func_array(array($className, $methodName), array($authLogin));
+
                // Is the password correct?
                if ($userInstance->getPasswordHash() !== $authHash) {
                        // Mismatching password
index b1307128fa9852a0e8d95c9b2d897cba1fffb60d..23dff14121a7c6401cd874283094a503cd575e55 100644 (file)
@@ -153,7 +153,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                        $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));
+                       $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByEmail'), array($email));
 
                        // Remember this user instance in our registry for later usage
                        $registry->addInstance('user', $userInstance);
index 43927a7d01917e5e5683b5dfb3c359ab4a7a6066..4150d2ceed5d19499729fcfae3390195c5da2ce6 100644 (file)
@@ -121,7 +121,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                        // 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));
+                               $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByUsername'), array($userName));
 
                                // Remember this user instance in our registry for later usage
                                $registry->addInstance('user', $userInstance);
index b1307128fa9852a0e8d95c9b2d897cba1fffb60d..23dff14121a7c6401cd874283094a503cd575e55 100644 (file)
@@ -153,7 +153,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                        $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));
+                       $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByEmail'), array($email));
 
                        // Remember this user instance in our registry for later usage
                        $registry->addInstance('user', $userInstance);
index e4f180ae9ad81ec451f394332109ee8590249eb8..c223af9a81c4281d81b1977dd46d1a038660de12 100644 (file)
@@ -124,7 +124,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                        // If this instance is created then the username *does* exist
                        try {
                                // Get a new instance
-                               $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('guest_class'), "createGuestByUsername"), array($userName));
+                               $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('guest_class'), 'createGuestByUsername'), array($userName));
 
                                // Remember this user instance in our registry for later usage
                                $registry->addInstance('user', $userInstance);
index 5ca8c8bbca6aba17ffb204900344bd6af7334b29..da4791c7ea217d2099ee37a4ee8e93fc87768ef4 100644 (file)
@@ -121,7 +121,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
                        // 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));
+                               $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), 'createMemberByUsername'), array($userName));
 
                                // Remember this user instance in our registry for later usage
                                $registry->addInstance('user', $userInstance);
@@ -134,7 +134,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
                if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
                        // This username is still available
                        $alreadyTaken = false;
-               }
+               } // END - if
 
                // Return the result
                return $alreadyTaken;
index d9a11d9b950e8e652219f6d2dcf4a52b6fd3fbe8..a86505a094e797163d50545395cbce3daecd4251 100644 (file)
@@ -60,7 +60,7 @@ class UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filte
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get a user instance for comparison
-               $userInstance = Member::createUserByRequest($requestInstance);
+               $userInstance = Member::createMemberByRequest($requestInstance);
 
                // Is the email address valid?
                if (!$userInstance->ifEmailAddressExists()) {
index 715544eb65bb635dd29c71dcd09a61288ed3c561..ed832a9702025e7787bbd1c59ef92fc0be9f2d00 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseUser extends BaseFrameworkSystem {
+       // Exception constances
+       const EXCEPTION_USERNAME_NOT_FOUND   = 0x150;
+       const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
+       const EXCEPTION_USER_PASS_MISMATCH   = 0x152;
+
        /**
         * Username of current user
         */
index 1cf97e945e90b187651640ed6e1b5282be7b8365..a71c746d4455b0460fe7464e000ec023bd96d506 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class Member extends BaseUser implements ManageableMember, Registerable, Updateable {
-       // Exception constances
-       const EXCEPTION_USERNAME_NOT_FOUND   = 0x150;
-       const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
-       const EXCEPTION_USER_PASS_MISMATCH   = 0x152;
-
        /**
         * Protected constructor
         *
@@ -69,7 +64,7 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea
         * @return      $userInstance   An instance of this user class
         * @throws      UsernameMissingException        If the username does not exist
         */
-       public final static function createUserByUsername ($userName) {
+       public final static function createMemberByUsername ($userName) {
                // Get a new instance
                $userInstance = new Member();
 
@@ -93,7 +88,7 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea
         * @param       $email                  Email address of the user
         * @return      $userInstance   An instance of this user class
         */
-       public final static function createUserByEmail ($email) {
+       public final static function createMemberByEmail ($email) {
                // Get a new instance
                $userInstance = new Member();
 
@@ -110,14 +105,14 @@ class Member extends BaseUser implements ManageableMember, Registerable, Updatea
         * @param       $requestInstance        An instance of a Requestable class
         * @return      $userInstance           An instance of this user class
         */
-       public final static function createUserByRequest (Requestable $requestInstance) {
+       public final static function createMemberByRequest (Requestable $requestInstance) {
                // Determine if by email or username
                if (!is_null($requestInstance->getRequestElement('username'))) {
                        // Username supplied
-                       $userInstance = self::createUserByUserName($requestInstance->getRequestElement('username'));
+                       $userInstance = self::createMemberByUserName($requestInstance->getRequestElement('username'));
                } elseif (!is_null($requestInstance->getRequestElement('email'))) {
                        // Email supplied
-                       $userInstance = self::createUserByEmail($requestInstance->getRequestElement('email'));
+                       $userInstance = self::createMemberByEmail($requestInstance->getRequestElement('email'));
                } else {
                        // Unsupported mode
                        $userInstance = new Member();