inc/classes/main/filter/news/class_NewsProcessFilter.php -text
inc/classes/main/filter/null/.htaccess -text
inc/classes/main/filter/null/class_NullFilter.php -text
+inc/classes/main/filter/update/.htaccess -text
+inc/classes/main/filter/update/class_UserUpdateFilter.php -text
inc/classes/main/filter/validator/.htaccess -text
inc/classes/main/filter/validator/class_EmailValidatorFilter.php -text
inc/classes/main/filter/validator/class_PasswordValidatorFilter.php -text
// CFG: NEWS-READER-CLASS
$cfg->setConfigEntry('news_reader_class', "DefaultNewsReader");
-// CFG: NEWS-DOWNLOAD-FILTER
+// CFG: NEWS-DOWNLOAD-CLASS
$cfg->setConfigEntry('news_download_class', "NewsDownloadFilter");
-// CFG: NEWS-PROCESS-FILTER
+// CFG: NEWS-PROCESS-CLASS
$cfg->setConfigEntry('news_process_class', "NewsProcessFilter");
-// CFG: USER-AUTH-FILTER
+// CFG: USER-AUTH-CLASS
$cfg->setConfigEntry('user_auth_class', "UserAuthFilter");
+// CFG: USER-UPDATE-CLASS
+$cfg->setConfigEntry('user_update_class', "UserUpdateFilter");
+
// CFG: NEWS-HOME-LIMIT
$cfg->setConfigEntry('news_home_limit', 10);
// Set the command resolver
$controllerInstance->setResolverInstance($resolverInstance);
- // Add some filters to this controller
+ // User auth filter
$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class'));
+
+ // User update filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_class'));
+
+ // News fetcher filter
$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class'));
+
+ // News proccess/display-preparation
$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class'));
+ /* @TODO: Add some filters to this controller */
+
// Return the prepared instance
return $controllerInstance;
}
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
* @throws UserAuthorizationException If the auth login was not found or if it was invalid
+ * @throws UserPasswordMismatchException If the supplied password hash does not match
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Then get an auth instance for checking and updating the auth cookies
// Stop here
throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID);
- }
+ } // END - if
- // Destroy safely the auth instance
- unset($authInstance);
+ // Now, try to get a user instance
+ $userInstance = User::createUserByUserName($authLogin);
+
+ // Is the password correct?
+ if ($userInstance->getPasswordHash() !== $authHash) {
+ // Mismatching password
+ throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
+ } // END - if
+
+ // Remember auth and user instances in registry
+ Registry::getRegistry()->addInstance('auth', $authInstance);
+ Registry::getRegistry()->addInstance('user', $userInstance);
}
}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A filter for updating the user account like last activity, last action
+ * performed and so on.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UserUpdateFilter extends BaseFrameworkSystem implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("User update filter");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createUserUpdateFilter () {
+ // Get a new instance
+ $filterInstance = new UserUpdateFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get user instance from registry
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Now update last activity
+ $userInstance->updateLastActivity();
+
+ // Update auth data as well
+ /* @TODO Add more user updates here */
+
+ // Write all updates to the database
+ $userInstance->flushUpdates();
+ }
+}
+
+// [EOF]
+?>
* @return $result Found result entry
*/
public function searchEntry (LocalSearchCriteria $criteriaInstance) {
- die("OK");
+ die(__METHOD__.": OK");
}
}