*/
private $userName = "";
+ /**
+ * User id of current user
+ */
+ private $userId = 0;
+
/**
* Email of current user
*/
* @return void
*/
public final function setUserName ($userName) {
- $this->userName = $userName;
+ $this->userName = (string) $userName;
}
/**
- * Setter for email
+ * Getter for username
*
- * @param $email The email to set
+ * @return $userName The username to get
+ */
+ public final function getUserName () {
+ return $this->userName;
+ }
+
+ /**
+ * Setter for user id
+ *
+ * @param $userId The user id to set
* @return void
+ * @todo Find a way of casting here. "(int)" might destroy the user id > 32766
*/
- protected final function setEmail ($email) {
- $this->email = $email;
+ public final function setUserId ($userId) {
+ $this->userId = $userId;
}
/**
- * Getter for username
+ * Getter for user id
*
- * @return $userName The username to get
+ * @return $userId The user id to get
*/
- public final function getUsername () {
- return $this->userName;
+ public final function getUserId () {
+ return $this->userId;
+ }
+
+ /**
+ * Setter for email
+ *
+ * @param $email The email to set
+ * @return void
+ */
+ protected final function setEmail ($email) {
+ $this->email = (string) $email;
}
/**
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
+ $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
$criteriaInstance->setLimit(1);
// Get a search result
- $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
- } else {
- // Rewind it
- $this->getResultInstance()->rewind();
- }
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Set the index "solver"
+ $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+
+ // And finally set it
+ $this->setResultInstance($resultInstance);
+ } // END - if
+
+ // Rewind it
+ $this->getResultInstance()->rewind();
// Search for it
if ($this->getResultInstance()->next()) {
$criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
$criteriaInstance->setLimit(1);
- // Get a search resultInstance
- $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
- } else {
- // Rewind it
- $this->getResultInstance()->rewind();
- }
+ // Get a search result
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Set the index "solver"
+ $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+
+ // And finally set it
+ $this->setResultInstance($resultInstance);
+ } // END - if
+
+ // Rewind it
+ $this->getResultInstance()->rewind();
// Search for it
if ($this->getResultInstance()->next()) {
}
/**
- * Checks if the supplied password hash in request matches with the stored
- * in database.
+ * Checks if supplied password hash in request matches with the stored in
+ * database.
*
* @param $requestInstance A requestable class instance
* @return $matches Wether the supplied password hash matches
// By default nothing matches... ;)
$matches = false;
- // Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+ // Is a previous result there?
+ if (is_null($this->getResultInstance())) {
+ // Get a UserDatabaseWrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+ // Create a search criteria
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add the username as a criteria and set limit to one entry
+ $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $criteriaInstance->setLimit(1);
+
+ // Get a search result
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
- // Create a search criteria
- $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ // Set the index "solver"
+ $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
- // Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
- $criteriaInstance->setLimit(1);
+ // And finally set it
+ $this->setResultInstance($resultInstance);
+ } // END - if
- // Get a search resultInstance
- $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
+ // Rewind it
+ $this->getResultInstance()->rewind();
// Search for it
- if ($this->getResultInstance()->next()) {
- // Get the current entry (can only be one!)
- $entry = $this->getResultInstance()->current();
-
+ if ($this->getResultInstance()->find('pass_hash')) {
// So does the hashes match?
//* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash'];
- $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
+ $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue());
} // END - if
// Return the status