class_ShipSimuRegistration.php

Go to the documentation of this file.
00001 <?php
00024 class ShipSimuRegistration extends BaseRegistration implements UserRegister {
00028         private $hashedPassword = "";
00029 
00033         private $criteriaElements = array(
00034                 'username',
00035                 'pass_hash',
00036                 'email' => 'email1',
00037                 'surname',
00038                 'family',
00039                 'street',
00040                 'zip',
00041                 'city',
00042                 'icq',
00043                 'jabber',
00044                 'yahoo',
00045                 'aol',
00046                 'msn'
00047         );
00048 
00054         protected function __construct () {
00055                 // Call parent constructor
00056                 parent::__construct(__CLASS__);
00057         }
00058 
00064         public final static function createShipSimuRegistration () {
00065                 // Get a new instance
00066                 $registrationInstance = new ShipSimuRegistration();
00067 
00068                 // Initialize the filter chains
00069                 $registrationInstance->initFilterChains();
00070 
00071                 // And return it
00072                 return $registrationInstance;
00073         }
00074 
00082         public function encryptPassword ($requestKey) {
00083                 // Check if password is found in request
00084                 if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
00085                         // So encrypt the password and store it for later usage in
00086                         // the request:
00087 
00088                         // 1.: Get the plain password
00089                         $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
00090 
00091                         // 2. Get a crypto helper and hash the password
00092                         $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword);
00093 
00094                         // 3. Store the hash back in request
00095                         $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
00096                 }
00097         }
00098 
00106         public function doPreRegistration () {
00107                 // First run all pre filters
00108                 $this->executePreFilters();
00109         }
00110 
00118         public function registerNewUser () {
00119                 // Get a user database wrapper
00120                 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
00121 
00122                 // Use this instance to insert the whole registration instance
00123                 $wrapperInstance->insertRegistrationObject($this);
00124         }
00125 
00132         public function doPostRegistration () {
00133                 // First run all post filters
00134                 $this->executePostFilters();
00135         }
00136 
00144         public function doPostAction () {
00145                 // Get an action instance from our factory
00146                 $actionInstance = ObjectFactory::createObjectByConfiguredName('post_registration_class');
00147 
00148                 // Execute the action
00149                 $actionInstance->execute($this->getRequestInstance(), $this->getResponseInstance());
00150         }
00151 
00158         public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
00159                 // Default is unconfirmed!
00160                 $configEntry = 'user_status_unconfirmed';
00161 
00162                 // Is the confirmation process entirely disabled?
00163                 if ($this->getConfigInstance()->readConfig('confirm_email_enabled') === "N") {
00164                         // No confirmation of email needed
00165                         $configEntry = 'user_status_confirmed';
00166                 } // END - if
00167 
00168                 // Add a lot elements to the dataset criteria
00169                 foreach ($this->criteriaElements as $alias => $element) {
00170                         // Do we have an alias?
00171                         if (is_string($alias)) {
00172                                 // Yes, so use it
00173                                 $criteriaInstance->addCriteria($alias, $this->getRequestInstance()->getRequestElement($element));
00174                         } else {
00175                                 // No, default entry
00176                                 $criteriaInstance->addCriteria($element, $this->getRequestInstance()->getRequestElement($element));
00177                         }
00178 
00179                         // Is this a guest account?
00180                         if ((($element == "username") || ($alias == "username")) && ($this->getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->readConfig('guest_login_user'))) {
00181                                 // Yes, then set the config entry to guest status
00182                                 $configEntry = 'user_status_guest';
00183                         } // END - if
00184                 } // END - foreach
00185 
00186                 // Mark the username as unique key
00187                 $criteriaInstance->setUniqueKey(UserDatabaseWrapper::DB_COLUMN_USERNAME);
00188 
00189                 // Add account status as configured
00190                 $criteriaInstance->addConfiguredCriteria(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $configEntry);
00191 
00192                 // Include registration timestamp
00193                 $criteriaInstance->addCriteria("registered", date("Y-m-d H:i:s", time()));
00194         }
00195 }
00196 
00197 //
00198 ?>

Generated on Mon Dec 8 01:06:44 2008 for Ship-Simulator by  doxygen 1.5.6