inc/classes/interfaces/user/class_ManageableAccount.php -text
inc/classes/interfaces/user/extended/.htaccess -text
inc/classes/interfaces/user/extended/class_ManageableGuest.php -text
-inc/classes/interfaces/user/extended/class_ManageableUser.php -text
+inc/classes/interfaces/user/extended/class_ManageableMember.php -text
inc/classes/main/.htaccess -text
inc/classes/main/actions/.htaccess -text
inc/classes/main/actions/class_ -text
inc/classes/main/user/class_BaseUser.php -text
inc/classes/main/user/guest/.htaccess -text
inc/classes/main/user/guest/class_Guest.php -text
-inc/classes/main/user/user/.htaccess -text
-inc/classes/main/user/user/class_User.php -text
+inc/classes/main/user/member/.htaccess -text
+inc/classes/main/user/member/class_Member.php -text
inc/classes/middleware/.htaccess -text
inc/classes/middleware/class_BaseMiddleware.php -text
inc/classes/middleware/compressor/.htaccess -text
* @param $userInstance A user class
* @return $companyInstance Prepared company instance
*/
- public final static function createShippingCompany (BaseUser $userInstance) {
+ public final static function createShippingCompany (ManageableAccount $userInstance) {
// Get new instance
$companyInstance = new ShippingCompany();
* @param $userInstance An instance of a user class
* @return $participates Wether the user participates at lease in one company
*/
- protected function ifUserParticipatesInCompany (BaseUser $userInstance) {
+ protected function ifUserParticipatesInCompany (ManageableAccount $userInstance) {
// By default no user owns any company... ;)
$participates = false;
// Is the password correct?
if (!$userInstance->ifPasswordHashMatches($requestInstance)) {
// Mismatching password
- throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
+ throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
} // END - if
// Now do the real login. This can be cookie- or session-based login
// Is there an instance?
if (is_null($userInstance)) {
// Get a user instance
- $userInstance = User::createUserByRequest($requestInstance);
+ $userInstance = Member::createUserByRequest($requestInstance);
// Remember this new instance in registry
Registry::getRegistry()->addInstance($userInstance);
// Is the password correct?
if (!$userInstance->ifPasswordHashMatches($requestInstance)) {
// Mismatching password
- throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
+ throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
} // END - if
// ToDo place
* @param $userInstance An instance of a user class
* @return $participates Wether the user participates at lease in one company
*/
- public function ifUserParticipatesInCompany (BaseUser $userInstance) {
+ public function ifUserParticipatesInCompany (ManageableAccount $userInstance) {
// By default no user owns any company... ;)
$participates = false;
* @param $userInstance An instance of a user class
* @return void
*/
- function addRecipientByUserInstance (ManageableUser $userInstance);
+ function addRecipientByUserInstance (ManageableMember $userInstance);
/**
* Use subject line provided by the (XML) template otherwise a subject line must be set
--- /dev/null
+<?php
+/**
+ * An interface for manageable users
+ *
+ * @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/>.
+ */
+interface ManageableMember extends ManageableAccount {
+}
+
+//
+?>
+++ /dev/null
-<?php
-/**
- * An interface for manageable users
- *
- * @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/>.
- */
-interface ManageableUser extends ManageableAccount {
-}
-
-//
-?>
// Prepare a template instance
$templateInstance = $this->prepareTemplateInstance($appInstance);
+ // Transfer application data
+ $templateInstance->assignApplicationData($appInstance);
+
// Load the master template
$masterTemplate = $appInstance->getMasterTemplate();
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
- * @throws InvalidInterfaceException If the user class does not implement ManageableUser
+ * @throws InvalidInterfaceException If the user class does not implement ManageableMember
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get user instance from registry
$userInstance = Registry::getRegistry()->getInstance('user');
- // Does the user instance implement ManageableUser?
- if (!$userInstance instanceof ManageableUser) {
+ // Does the user instance implement ManageableMember?
+ if (!$userInstance instanceof ManageableMember) {
// Throw exception here
- throw new InvalidInterfaceException(array($userInstance, 'ManageableUser'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
+ throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
} // END - if
// Get an application instance
$userInstance = Guest::createGuestByUserName($authLogin);
} else {
// Regular user account
- $userInstance = User::createUserByUserName($authLogin);
+ $userInstance = Member::createUserByUserName($authLogin);
}
// Is the password correct?
if ($userInstance->getPasswordHash() !== $authHash) {
// Mismatching password
- throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
+ throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
} // END - if
// Remember auth and user instances in registry
// Does it match?
if ($oldHash != $passHash) {
// Throw an exception here to stop the proccessing
- throw new AccountPasswordMismatchException($this, User::EXCEPTION_USER_PASS_MISMATCH);
+ throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH);
} // END - if
}
}
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get a user instance for comparison
- $userInstance = User::createUserByRequest($requestInstance);
+ $userInstance = Member::createUserByRequest($requestInstance);
// Is the email address valid?
if (!$userInstance->ifEmailAddressExists()) {
* @param $userInstance An instance of a user class
* @return void
*/
- public function addRecipientByUserInstance (ManageableUser $userInstance) {
+ public function addRecipientByUserInstance (ManageableMember $userInstance) {
// Get template name
$templateName = $this->getTemplateName();
// Walk through all recipients and "sent", or better print, it out
foreach ($recipientList['recipients'] as $recipientInstance) {
// The recipient should be a user instance, right?
- if ($recipientInstance instanceof ManageableUser) {
+ if ($recipientInstance instanceof ManageableMember) {
// User class found, so entry is valid, first load the template
$this->loadTemplate($templateName);
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A generic class for handling users
+ *
+ * @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 Member extends BaseUser implements ManageableMember, Registerable, Updateable {
+ // Exception constances
+ const EXCEPTION_USERNAME_NOT_FOUND = 0x150;
+ const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
+ const EXCEPTION_USER_PASS_MISMATCH = 0x152;
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className = "") {
+ // Is the class name empty? Then this is not a specialized user class
+ if (empty($className)) $className = __CLASS__;
+
+ // Call parent constructor
+ parent::__construct($className);
+
+ // Set part description
+ $this->setObjectDescription("Generic user class");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * Destructor to always flush updates
+ *
+ * @return void
+ */
+ public function __destruct () {
+ // Flush any updated entries to the database
+ $this->flushPendingUpdates();
+
+ // Call parent destructor
+ parent::__destruct();
+ }
+
+ /**
+ * Creates an instance of this user class by a provided username. This
+ * factory method will check if the username is already taken and if not
+ * so it will throw an exception.
+ *
+ * @param $userName Username we need a class instance for
+ * @return $userInstance An instance of this user class
+ * @throws UsernameMissingException If the username does not exist
+ */
+ public final static function createUserByUsername ($userName) {
+ // Get a new instance
+ $userInstance = new Member();
+
+ // Set the username
+ $userInstance->setUserName($userName);
+
+ // Check if the username exists
+ if (!$userInstance->ifUsernameExists()) {
+ // Throw an exception here
+ throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
+ }
+
+ // Return the instance
+ return $userInstance;
+ }
+
+ /**
+ * Creates an instance of this user class by a provided email address. This
+ * factory method will not check if the email address is there.
+ *
+ * @param $email Email address of the user
+ * @return $userInstance An instance of this user class
+ */
+ public final static function createUserByEmail ($email) {
+ // Get a new instance
+ $userInstance = new Member();
+
+ // Set the username
+ $userInstance->setEmail($email);
+
+ // Return the instance
+ return $userInstance;
+ }
+
+ /**
+ * Creates a user by a given request instance
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return $userInstance An instance of this user class
+ */
+ public final static function createUserByRequest (Requestable $requestInstance) {
+ // Determine if by email or username
+ if (!is_null($requestInstance->getRequestElement('username'))) {
+ // Username supplied
+ $userInstance = self::createUserByUserName($requestInstance->getRequestElement('username'));
+ } elseif (!is_null($requestInstance->getRequestElement('email'))) {
+ // Email supplied
+ $userInstance = self::createUserByEmail($requestInstance->getRequestElement('email'));
+ } else {
+ // Unsupported mode
+ $userInstance = new Member();
+ $userInstance->partialStub("We need to add more ways of creating user classes here.");
+ $userInstance->debugBackTrace();
+ exit();
+ }
+
+ // Return the prepared instance
+ return $userInstance;
+ }
+
+ /**
+ * Adds data for later complete update
+ *
+ * @param $column Column we want to update
+ * @param $value New value to store in database
+ * @return void
+ * @deprecated
+ */
+ public function addUpdateData ($column, $value) {
+ $this->deprecatedMethod("Please use updateDatabaseField() instead!");
+ $this->updateDatabaseField($column, $value);
+ }
+
+ /**
+ * Updates the last activity timestamp and last performed action in the
+ * database result. You should call flushPendingUpdates() 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->getResultInstance()->add2UpdateQueue($updateInstance);
+ }
+
+ /**
+ * Flushs all pending updates to the database layer
+ *
+ * @return void
+ */
+ public function flushPendingUpdates () {
+ // Do we have data to update?
+ if ($this->getResultInstance()->ifDataNeedsFlush()) {
+ // Get a database wrapper
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+ // Yes, then send the whole result to the database layer
+ $wrapperInstance->doUpdateByResult($this->getResultInstance());
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A generic class for handling users
- *
- * @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 User extends BaseUser implements ManageableUser, Registerable, Updateable {
- // Exception constances
- const EXCEPTION_USERNAME_NOT_FOUND = 0x150;
- const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
- const EXCEPTION_USER_PASS_MISMATCH = 0x152;
-
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className = "") {
- // Is the class name empty? Then this is not a specialized user class
- if (empty($className)) $className = __CLASS__;
-
- // Call parent constructor
- parent::__construct($className);
-
- // Set part description
- $this->setObjectDescription("Generic user class");
-
- // Create unique ID number
- $this->generateUniqueId();
- }
-
- /**
- * Destructor to always flush updates
- *
- * @return void
- */
- public function __destruct () {
- // Flush any updated entries to the database
- $this->flushPendingUpdates();
-
- // Call parent destructor
- parent::__destruct();
- }
-
- /**
- * Creates an instance of this user class by a provided username. This
- * factory method will check if the username is already taken and if not
- * so it will throw an exception.
- *
- * @param $userName Username we need a class instance for
- * @return $userInstance An instance of this user class
- * @throws UsernameMissingException If the username does not exist
- */
- public final static function createUserByUsername ($userName) {
- // Get a new instance
- $userInstance = new User();
-
- // Set the username
- $userInstance->setUserName($userName);
-
- // Check if the username exists
- if (!$userInstance->ifUsernameExists()) {
- // Throw an exception here
- throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
- }
-
- // Return the instance
- return $userInstance;
- }
-
- /**
- * Creates an instance of this user class by a provided email address. This
- * factory method will not check if the email address is there.
- *
- * @param $email Email address of the user
- * @return $userInstance An instance of this user class
- */
- public final static function createUserByEmail ($email) {
- // Get a new instance
- $userInstance = new User();
-
- // Set the username
- $userInstance->setEmail($email);
-
- // Return the instance
- return $userInstance;
- }
-
- /**
- * Creates a user by a given request instance
- *
- * @param $requestInstance An instance of a Requestable class
- * @return $userInstance An instance of this user class
- */
- public final static function createUserByRequest (Requestable $requestInstance) {
- // Determine if by email or username
- if (!is_null($requestInstance->getRequestElement('username'))) {
- // Username supplied
- $userInstance = self::createUserByUserName($requestInstance->getRequestElement('username'));
- } elseif (!is_null($requestInstance->getRequestElement('email'))) {
- // Email supplied
- $userInstance = self::createUserByEmail($requestInstance->getRequestElement('email'));
- } else {
- // Unsupported mode
- $userInstance = new User();
- $userInstance->partialStub("We need to add more ways of creating user classes here.");
- $userInstance->debugBackTrace();
- exit();
- }
-
- // Return the prepared instance
- return $userInstance;
- }
-
- /**
- * Adds data for later complete update
- *
- * @param $column Column we want to update
- * @param $value New value to store in database
- * @return void
- * @deprecated
- */
- public function addUpdateData ($column, $value) {
- $this->deprecatedMethod("Please use updateDatabaseField() instead!");
- $this->updateDatabaseField($column, $value);
- }
-
- /**
- * Updates the last activity timestamp and last performed action in the
- * database result. You should call flushPendingUpdates() 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->getResultInstance()->add2UpdateQueue($updateInstance);
- }
-
- /**
- * Flushs all pending updates to the database layer
- *
- * @return void
- */
- public function flushPendingUpdates () {
- // Do we have data to update?
- if ($this->getResultInstance()->ifDataNeedsFlush()) {
- // Get a database wrapper
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
-
- // Yes, then send the whole result to the database layer
- $wrapperInstance->doUpdateByResult($this->getResultInstance());
- } // END - if
- }
-}
-
-// [EOF]
-?>
$cfg->setConfigEntry('post_registration_class', "LoginAfterRegistrationAction");
// CFG: USER-CLASS
-$cfg->setConfigEntry('user_class', "User");
+$cfg->setConfigEntry('user_class', "Member");
// CFG: GUEST-CLASS
$cfg->setConfigEntry('guest_class', "Guest");