]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/registration/class_ShipSimuRegistration.php
Actions (so called sub-commands) may now have own pre/post filter, profile update...
[shipsimu.git] / application / ship-simu / main / registration / class_ShipSimuRegistration.php
index 252d05df20457e27e37311af7fe3ff711db0c5ea..9dc9fb372f3f7ccf59165919944b44d5249b316e 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);
                }
@@ -98,7 +117,11 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function registerNewUser () {
-               $this->partialStub();
+               // Get a user database wrapper
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+               // Use this instance to insert the whole registration instance
+               $wrapperInstance->insertRegistrationObject($this);
        }
 
        /**
@@ -119,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_unconfirmed';
+
+               // 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);
        }
 }