]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/registration/class_ShipSimuRegistration.php
Guest login basicly supported (not finished yet!)
[shipsimu.git] / application / ship-simu / main / registration / class_ShipSimuRegistration.php
index 9909c3d6d128af731c9771b8940013cdd2b1017e..eac7106f6a4944d74be64a6ea2f446fa60d772ee 100644 (file)
@@ -27,6 +27,25 @@ class ShipSimuRegistration extends BaseRegistration {
         */
        private $hashedPassword = "";
 
+       /**
+        * Elements for criteria
+        */
+       private $criteriaElements = array(
+               'username',
+               'pass_hash',
+               'email' => 'email1',
+               'surname',
+               'family',
+               'street',
+               'zip',
+               'city',
+               'icq',
+               'jabber',
+               'yahoo',
+               'aol',
+               'msn'
+       );
+
        /**
         * Protected constructor
         *
@@ -40,7 +59,7 @@ class ShipSimuRegistration extends BaseRegistration {
                $this->setObjectDescription("Ship-Simu registration class");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
        }
 
        /**
@@ -74,7 +93,7 @@ class ShipSimuRegistration extends BaseRegistration {
                        // 1.: Get the plain password
                        $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
                        // 2. Get a crypto helper and hash the password
-                       $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_heler')->hashPassword($plainPassword);
+                       $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashPassword($plainPassword);
                        // 3. Store the hash back in the request
                        $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
                }
@@ -99,7 +118,7 @@ class ShipSimuRegistration extends BaseRegistration {
         */
        public function registerNewUser () {
                // Get a user database wrapper
-               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
                // Use this instance to insert the whole registration instance
                $wrapperInstance->insertRegistrationObject($this);
@@ -123,7 +142,46 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function doPostAction () {
-               $this->partialStub();
+               // Get an action instance from our factory
+               $actionInstance = ObjectFactory::createObjectByConfiguredName('post_registration_class');
+
+               // Execute the action
+               $actionInstance->execute($this->getRequestInstance(), $this->getResponseInstance());
+       }
+
+       /**
+        * Adds registration elements to a given dataset instance
+        *
+        * @param       $criteriaInstance       An instance of a storeable criteria
+        * @return      void
+        */
+       public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
+               // Default is user account!
+               $configEntry = 'user_status_register';
+
+               // Add a lot elements to the dataset criteria
+               foreach ($this->criteriaElements as $alias=>$element) {
+                       // Do we have an alias?
+                       if (is_string($alias)) {
+                               // Yes, so use it
+                               $criteriaInstance->addCriteria($alias, $this->getRequestInstance()->getRequestElement($element));
+                       } else {
+                               // No, default entry
+                               $criteriaInstance->addCriteria($element, $this->getRequestInstance()->getRequestElement($element));
+                       }
+
+                       // Is this a guest account?
+                       if ((($element == "username") || ($alias == "username")) && ($this->getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->readConfig('guest_login_username'))) {
+                               // Yes, then set the config entry to guest status
+                               $configEntry = 'user_status_guest';
+                       } // END - if
+               } // END - foreach
+
+               // Mark the username as unique key
+               $criteriaInstance->setUniqueKey('username');
+
+               // Add account status as configured
+               $criteriaInstance->addConfiguredCriteria('user_status', $configEntry);
        }
 }