$entry = $this->resultInstance->current();
// So does the hashes match?
+ //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash'];
$matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
} // END - if
// And return the hash
return $passHash;
}
+
+ /**
+ * Updates the last activity timestamp and last performed action in the
+ * database result. You should call flushUpdates() to flush these updates
+ * to the database layer.
+ *
+ * @param $requestInstance A requestable class instance
+ * @return void
+ */
+ public function updateLastActivity (Requestable $requestInstance) {
+ // Set last action
+ $lastAction = $requestInstance->getRequestElement('action');
+
+ // If there is no action use the default on
+ if (is_null($lastAction)) {
+ $lastAction = $this->getConfigInstance()->readConfig('login_default_action');
+ } // END - if
+
+ // Get a critieria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add search criteria
+ $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $searchInstance->setLimit(1);
+
+ // Now get another criteria
+ $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
+
+ // And add our both entries
+ $updateInstance->addCriteria('last_activity', date("Y-m-d H:i:s", time()));
+ $updateInstance->addCriteria('last_action', $lastAction);
+
+ // Add the search criteria for searching for the right entry
+ $updateInstance->setSearchInstance($searchInstance);
+
+ // Remember the update in database result
+ $this->resultInstance->add2UpdateQueue($updateInstance);
+ }
+
+ /**
+ * Flushs all updated entries to the database layer
+ *
+ * @return void
+ */
+ public function flushUpdates () {
+ // Get a database wrapper
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+ // Do we have data to update?
+ if ($this->resultInstance->ifDataNeedsFlush()) {
+ // Yes, then send the whole result to the database layer
+ $wrapperInstance->doUpdateByResult($this->resultInstance);
+ } // END - if
+ }
}
// [EOF]