*/
class ShipSimuRegistration extends BaseRegistration {
/**
- * Private constructor
+ * Hashed password
+ */
+ 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
*
* @return void
*/
$this->setObjectDescription("Ship-Simu registration class");
// Create unique ID number
- $this->createUniqueID();
+ $this->generateUniqueId();
}
/**
// Get a new instance
$registrationInstance = new ShipSimuRegistration();
+ // Initialize the filter chains
+ $registrationInstance->initFilterChains();
+
// And return it
return $registrationInstance;
}
/**
- * Encrypt the given request key or throws an exception if the key was not
+ * Encrypt the given request key or throw an exception if the key was not
* found in the request
*
* @param $requestKey Key in request class
* @return void
*/
public function encryptPassword ($requestKey) {
- $this->partialStub(sprintf("requestKey=%s", $requestKey));
+ // Check if the password is found in the request
+ if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
+ // So encrypt the password and store it for later usage in
+ // the request:
+ // 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);
+ // 3. Store the hash back in the request
+ $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
+ }
}
/**
* @return void
*/
public function doPreRegistration () {
- $this->partialStub();
+ // First run all pre filters
+ $this->executePreFilters();
}
/**
* @return void
*/
public function registerNewUser () {
- $this->partialStub();
+ // Get a user database wrapper
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
+
+ // Use this instance to insert the whole registration instance
+ $wrapperInstance->insertRegistrationObject($this);
}
/**
* @return void
*/
public function doPostRegistration () {
- $this->partialStub();
+ // First run all post filters
+ $this->executePostFilters();
}
/**
* @return void
*/
public function doPostAction () {
- $this->partialStub();
+ // Get an action instance from our factory
+ $actionInstance = ObjectFactory::createObjectByConfiguredName('post_registration_action');
+
+ // 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) {
+ // 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));
+ }
+ } // END - foreach
+
+ // Mark the username as unique key
+ $criteriaInstance->setUniqueKey('username');
+
+ // Add account status as configured
+ $criteriaInstance->addConfiguredCriteria('user_status', 'user_status_register');
}
}