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 2084758..4efc684 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 ef95a7c..242de41 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 b59eb2b..24c44f6 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 367103c..7ca65d2 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 25641dc..572d2b0 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 b130712..23dff14 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 43927a7..4150d2c 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 b130712..23dff14 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 e4f180a..c223af9 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 5ca8c8b..da4791c 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 d9a11d9..a86505a 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 715544e..ed832a9 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 1cf97e9..a71c746 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();