]> 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 a6639c5688f00013960e4a98054fc32b9c279b7c..eac7106f6a4944d74be64a6ea2f446fa60d772ee 100644 (file)
@@ -28,7 +28,26 @@ class ShipSimuRegistration extends BaseRegistration {
        private $hashedPassword = "";
 
        /**
-        * Private constructor
+        * Elements for criteria
+        */
+       private $criteriaElements = array(
+               'username',
+               'pass_hash',
+               'email' => 'email1',
+               'surname',
+               'family',
+               'street',
+               'zip',
+               'city',
+               'icq',
+               'jabber',
+               'yahoo',
+               'aol',
+               'msn'
+       );
+
+       /**
+        * Protected constructor
         *
         * @return      void
         */
@@ -40,7 +59,7 @@ class ShipSimuRegistration extends BaseRegistration {
                $this->setObjectDescription("Ship-Simu registration class");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
        }
 
        /**
@@ -52,6 +71,9 @@ class ShipSimuRegistration extends BaseRegistration {
                // Get a new instance
                $registrationInstance = new ShipSimuRegistration();
 
+               // Initialize the filter chains
+               $registrationInstance->initFilterChains();
+
                // And return it
                return $registrationInstance;
        }
@@ -71,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);
                }
@@ -84,7 +106,8 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function doPreRegistration () {
-               $this->partialStub();
+               // First run all pre filters
+               $this->executePreFilters();
        }
 
        /**
@@ -94,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);
        }
 
        /**
@@ -103,7 +130,8 @@ class ShipSimuRegistration extends BaseRegistration {
         * @return      void
         */
        public function doPostRegistration () {
-               $this->partialStub();
+               // First run all post filters
+               $this->executePostFilters();
        }
 
        /**
@@ -114,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);
        }
 }