application/ship-simu/main/actions/ship-simu/class_ShipSimuProfileAction.php -text
application/ship-simu/main/actions/web/.htaccess -text
application/ship-simu/main/actions/web/class_WebLoginCompanyAction.php -text
+application/ship-simu/main/bank/.htaccess -text
+application/ship-simu/main/bank/class_MoneyBank.php -text
application/ship-simu/main/class_ -text
application/ship-simu/main/class_BasePersonell.php -text
application/ship-simu/main/class_BaseSimulator.php -text
application/ship-simu/main/drives/motor/class_Motor.php -text
application/ship-simu/main/factories/.htaccess -text
application/ship-simu/main/factories/class_ShipSimuWebNewsFactory.php -text
+application/ship-simu/main/goverment/.htaccess -text
+application/ship-simu/main/goverment/class_SimpleGoverment.php -text
application/ship-simu/main/login/.htaccess -text
application/ship-simu/main/login/class_ShipSimuGuestLogin.php -text
application/ship-simu/main/login/class_ShipSimuUserLogin.php -text
application/ship-simu/main/structures/extended/upper/.htaccess -text
application/ship-simu/main/structures/extended/upper/class_Bridge.php -text
application/ship-simu/main/user/.htaccess -text
+application/ship-simu/main/user/class_ShipSimuBaseUser.php -text
application/ship-simu/main/user/class_ShipSimuGuest.php -text
application/ship-simu/main/user/class_ShipSimuMember.php -text
+application/ship-simu/main/user/extended/.htaccess -text
+application/ship-simu/main/user/extended/class_ShipSimuGuest.php -text
+application/ship-simu/main/user/extended/class_ShipSimuMember.php -text
application/ship-simu/main/wrapper/.htaccess -text
application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php -text
application/ship-simu/starter.php -text
db/company_user/.htaccess -text
db/news/.htaccess -text
db/user/.htaccess -text
+db/user_points/.htaccess -text
devel/.htaccess -text
devel/class_Debug.php -text
docs/COPYING -text
inc/classes/main/database/wrapper/.htaccess -text
inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php -text
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php -text
+inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php -text
inc/classes/main/debug/.htaccess -text
inc/classes/main/debug/class_DebugConsoleOutput.php -text
inc/classes/main/debug/class_DebugErrorLogOutput.php -text
inc/classes/main/output/.htaccess -text
inc/classes/main/output/class_ConsoleOutput.php -text
inc/classes/main/output/class_WebOutput.php -text
+inc/classes/main/points/.htaccess -text
+inc/classes/main/points/class_UserPoints.php -text
inc/classes/main/reader/.htaccess -text
inc/classes/main/reader/class_DefaultNewsReader.php -text
inc/classes/main/registration/.htaccess -text
// CFG: COMPANY-DB-WRAPPER-CLASS
$cfg->setConfigEntry('company_db_wrapper_class', "CompanyDatabaseWrapper");
+// CFG: USER-POINTS-DB-WRAPPER-CLASS
+$cfg->setConfigEntry('user_points_db_wrapper_class', "UserPointsDatabaseWrapper");
+
// CFG EMAIl-TPL-RESEND-LINK
$cfg->setConfigEntry('email_tpl_resend_link', "text");
// CFG: GUEST-CLASS
$cfg->setConfigEntry('guest_class', "ShipSimuGuest");
+// CFG: MAX-ALLOWED-COMPANIES-FOUND
+$cfg->setConfigEntry('max_allowed_companies_found', 10);
+
+// CFG: FOUND-NEW-COMPANY-ACTION-POINTS
+$cfg->setConfigEntry('found_new_company_action_points', 1000000);
+
+// CFG: WRITE-APPLICATION-ACTION-POINTS
+$cfg->setConfigEntry('write_applications_action_points', 10000);
+
+// CFG: USER-POINTS-CLASS
+$cfg->setConfigEntry('user_ppints_class', "UserPoints");
+
+// CFG: GOVERMENT-CLASS
+$cfg->setConfigEntry('goverment_class', "SimpleGoverment");
+
+// CFG: BANK-CLASS
+$cfg->setConfigEntry('bank_class', "MoneyBank");
+
+// CFG: REFILL-PAGE-ACTIVE
+$cfg->setConfigEntry('refill_page_active', "Y");
+
// [EOF]
?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A money bank which may lend points to the user
+ *
+ * @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 MoneyBank extends BaseFrameworkSystem implements Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A money bank class");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this money bank class
+ *
+ * @param $userInstance A class instance of a user object
+ * @return $bankInstance An instance of this class
+ */
+ public final static function createMoneyBank (ManageableAccount $userInstance) {
+ // Get a new instance
+ $moneyInstance = new MoneyBank();
+
+ // Set the user instance
+ $moneyInstance->setUserInstance($userInstance);
+
+ // Return the prepared instance
+ return $moneyInstance;
+ }
+}
+
+// [EOF]
+?>
* 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 extends BaseFrameworkSystem {
+class ??? extends BaseFrameworkSystem {
/**
* Protected constructor
*
$this->removeNumberFormaters();
$this->removeSystemArray();
}
+
+ /**
+ * Creates an instance of this money bank class
+ *
+ * @param $userInstance A class instance of a user object
+ * @return $bankInstance An instance of this class
+ */
+ public final static function create??? (ManageableAccount $userInstance) {
+ // Get a new instance
+ $moneyInstance = new ???();
+
+ // Set the user instance
+ $moneyInstance->setUserInstance($userInstance);
+
+ // Return the prepared instance
+ return $moneyInstance;
+ }
}
// [EOF]
$participates = false;
// Get a company database wrapper class
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class');
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class', array($this));
// Ask the wrapper if this user participates
$participates = $wrapperInstance->ifUserParticipatesInCompany($userInstance);
return $isEmployee;
}
- //----------------------------------------------------------------------------
- // From here is very old code which needs to be translated and changed heavily
- //----------------------------------------------------------------------------
+ //------------------------------------------------------------------------------\
+ // Below here is very old code which needs to be translated and changed heavily |
+ //------------------------------------------------------------------------------/
/**
* Intialize all lists
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A goverment class with simplified ways...
+ *
+ * @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 SimpleGoverment extends BaseFrameworkSystem implements Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A class for simplified goverment");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this goverment class by given user instance
+ *
+ * @param $userInstance The user instance
+ * @return $govermentInstance Instance of the prepared goverment instance
+ */
+ public final static function createSimpleGoverment (ManageableAccount $userInstance) {
+ // Get a new instance
+ $govermentInstance = new SimpleGoverment();
+
+ // Set the user instance
+ $govermentInstance->setUserInstance($userInstance);
+
+ // Return the prepared instance
+ return $govermentInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A special member class for Ship-Simu
+ *
+ * @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 ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Checks wether the user has reached maximum allowed companies to found
+ *
+ * @return $reached Wether the user has reached maximum allowed companies to found
+ */
+ public function ifUserCreatedMaximumAllowedCompanies () {
+ // Get max allowed companies to found
+ $maxFound = $this->getConfigInstance()->readConfig('max_allowed_companies_found');
+
+ // Get a company wrapper
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class');
+
+ // Now get a search criteria and set the user's name as criteria
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $criteriaInstance->setLimit($maxFound);
+
+ // Do the count-select by criteria
+ $totalRows = $wrapperInstance->doSelectCountByCriteria($criteriaInstance);
+
+ // Does the user have reached maximum?
+ $reached = ($totalRows >= $maxFound);
+
+ // Return the result
+ return $reached;
+ }
+
+ /**
+ * Checks wether the user has the required amount of points left for the specified action
+ *
+ * @param $action The action or configuration entry plus prefix the user wants to perform
+ * @return $hasRequired Wether the user has the required points
+ */
+ public function ifUserHasRequiredPoints ($action) {
+ // Default is that everyone is poor... ;-)
+ $hasRequired = false;
+
+ // Get a points instance from registry
+ $pointsInstance = Registry::getRegistry()->getInstance('points');
+
+ // Is there an instance?
+ if (is_null($pointsInstance)) {
+ // Then create one
+ $pointsInstance = ObjectFactory::createObjectByConfiguredName('user_ppints_class', array($this));
+
+ // And store it in registry
+ Registry::getRegistry()->addInstance('points', $pointsInstance);
+ } // END - if
+
+ // Just forward this request to the user points class
+ $hasRequired = $pointsInstance->ifUserHasRequiredPoints ($action);
+
+ // Return the result
+ return $hasRequired;
+ }
+
+ /**
+ * Determines if the goverment can still pay a "startup help" to the user
+ *
+ * @return $ifGovHelped Wether if the goverment has helped the user with startup
+ */
+ public function ifGovermentPaysStartupHelp () {
+ // By default they have not payed, which is indeed good. ;-)
+ $ifGovHelped = false;
+
+ // First get a goverment instance from registry
+ $govermentInstance = Registry::getRegistry()->getInstance('goverment');
+
+ // Is it there?
+ if (is_null($govermentInstance)) {
+ // Then create a new one
+ $govermentInstance = ObjectFactory::createObjectByConfiguredName('goverment_class', array($this));
+
+ // Store it in registry
+ Registry::getRegistry()->addInstance('goverment', $govermentInstance);
+ } // END - if
+
+ // Then ask the goverment if they want to pay a "startup help" to the user
+ if ($govermentInstance->ifGovermentAlreadyPayedsStartupHelp()) {
+ // They can't pay anymore to the user (excited amount)
+ $ifGovHelped = true;
+ } // END - if
+
+ // Return result here
+ return $ifGovHelped;
+ }
+
+ /**
+ * Checks wether the user can take points from the money bank
+ *
+ * @return $bankLends Wether the money bank is able to lend money
+ */
+ public function ifUserAllowTakeCreditsFromMoneyBank () {
+ // Per default the money bank cannot pay
+ $bankLends = false;
+
+ // Get a money bank instance from registry
+ $bankInstance = Registry::getRegistry()->getInstance('money_bank');
+
+ // Is it there?
+ if (is_null($bankInstance)) {
+ // Then create a new one
+ $bankInstance = ObjectFactory::createObjectByConfiguredName('bank_class', array($this));
+
+ // Store it in registry
+ Registry::getRegistry()->addInstance('money_bank', $bankInstance);
+ } // END - if
+
+ // Does the money bank lend more money?
+ if ($bankInstance->ifBankLendsMoreMoney()) {
+ // Okay, that they will do
+ $bankLends = true;
+ } // END - if
+
+ // Return result
+ return $bankLends;
+ }
+
+ /**
+ * Checks wether the user has maximum credits with the money bank. This
+ * should be done seperately from checking if the user is allowed to take
+ * credits from the bank.
+ *
+ * @return $hasMaxCredits Wether the user has maximum credits with the bank
+ */
+ public function ifUserHasMaximumCreditsWithMoneyBank () {
+ // For default he can still get money
+ $hasMaxCredits = false;
+
+ // Get a money bank instance from registry
+ $bankInstance = Registry::getRegistry()->getInstance('money_bank');
+
+ // Is it there?
+ if (is_null($bankInstance)) {
+ // Then create a new one
+ $bankInstance = ObjectFactory::createObjectByConfiguredName('bank_class', array($this));
+
+ // Store it in registry
+ Registry::getRegistry()->addInstance('money_bank', $bankInstance);
+ } // END - if
+
+ // Now check if the user has maximum credits
+ if ($bankInstance->ifUserHasMaxCredits()) {
+ // Yes, he does!
+ $hasMaxCredits = true;
+ } // END - if
+
+ // Return the result
+ return $hasMaxCredits;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A special guest class for Ship-Simu
+ *
+ * @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 ShipSimuGuest extends ShipSimuBaseUser implements ManageableGuest {
+ // Exceptions
+ const EXCEPTION_USERNAME_NOT_FOUND = 0x170;
+ const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171;
+ const EXCEPTION_USER_PASS_MISMATCH = 0x172;
+
+ /**
+ * 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("Special ship-simu class");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * 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 createGuestByUsername ($userName) {
+ // Get a new instance
+ $userInstance = new ShipSimuGuest();
+
+ // 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 createGuestByEmail ($email) {
+ // Get a new instance
+ $userInstance = new ShipSimuGuest();
+
+ // Set the username
+ $userInstance->setEmail($email);
+
+ // Return the instance
+ return $userInstance;
+ }
+
+ /**
+ * 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) {
+ // No activity will be logged for guest accounts
+ }
+
+ /**
+ * Flushs all pending updates to the database layer
+ *
+ * @return void
+ */
+ public function flushPendingUpdates () {
+ // No updates will be flushed to database!
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A special member class for Ship-Simu
+ *
+ * @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 ShipSimuMember extends ShipSimuBaseUser implements ManageableMember {
+ /**
+ * 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("Special member class for Ship-Simu");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * 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 createMemberByUsername ($userName) {
+ // Get a new instance
+ $userInstance = new ShipSimuMember();
+
+ // 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 createMemberByEmail ($email) {
+ // Get a new instance
+ $userInstance = new ShipSimuMember();
+
+ // 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 createMemberByRequest (Requestable $requestInstance) {
+ // Determine if by email or username
+ if (!is_null($requestInstance->getRequestElement('username'))) {
+ // Username supplied
+ $userInstance = self::createMemberByUserName($requestInstance->getRequestElement('username'));
+ } elseif (!is_null($requestInstance->getRequestElement('email'))) {
+ // Email supplied
+ $userInstance = self::createMemberByEmail($requestInstance->getRequestElement('email'));
+ } else {
+ // Unsupported mode
+ $userInstance = new ShipSimuMember();
+ $userInstance->partialStub("We need to add more ways of creating user classes here.");
+ $userInstance->debugBackTrace();
+ exit();
+ }
+
+ // Return the prepared instance
+ return $userInstance;
+ }
+
+ /**
+ * 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]
+?>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class CompanyDatabaseWrapper extends BaseDatabaseWrapper {
+ /**
+ * Company instance
+ */
+ private $companyInstance = null;
+
// Constants for database tables
const DB_TABLE_COMPANY_DATA = "company";
const DB_TABLE_COMPANY_USER = "company_user";
/**
* Creates an instance of this wrapper class
*
+ * @param $companyInstance An instance of a generic company class or null if no specific
* @return $wrapperInstance An instance of this wrapper class
+ * @todo Find an interface which is suitable for all companies
*/
- public final static function createCompanyDatabaseWrapper () {
+ public final static function createCompanyDatabaseWrapper (ShippingCompany $companyInstance = null) {
// Create a new instance
$wrapperInstance = new CompanyDatabaseWrapper();
// Set (primary!) table name
$wrapperInstance->setTableName(self::DB_TABLE_COMPANY_DATA);
+ // Set the company instance if not null
+ if (!is_null($companyInstance)) {
+ $wrapperInstance->setCompanyInstance($companyInstance);
+ } // END - if
+
// Return the instance
return $wrapperInstance;
}
// Return the result
return $participates;
}
+
+ /**
+ * Setter for company instance
+ *
+ * @param $companyInstance An instance of a generic company
+ * @return void
+ * @todo Find an interface suitable for all types of companies
+ */
+ protected final function setCompanyInstance (ShippingCompany $companyInstance) {
+ $this->companyInstance = $companyInstance;
+ }
+
+ /**
+ * Getter for company instance
+ *
+ * @return $companyInstance An instance of a generic company
+ * @todo Find an interface suitable for all types of companies
+ */
+ public final function getCompanyInstance () {
+ return $this->companyInstance;
+ }
}
// [EOF]
// Maximum of allowed companies reached?
if ($linkInstance->getValueInstance()->ifUserCreatedMaximumAllowedCompanies()) {
// No more companies allowed to create
-} elseif ($linkInstance->getValueInstance()->ifUserPointsEnough('found_new_company')) {
+} elseif ($linkInstance->getValueInstance()->ifUserHasRequiredPoints('found_new_company')) {
// Enough money to found company
-} elseif ($linkInstance->getValueInstance()->ifUserPointsEnough('write_applications')) {
+} elseif ($linkInstance->getValueInstance()->ifUserHasRequiredPoints('write_applications')) {
// Enough money to write applications to other companies
} elseif ($linkInstance->getValueInstance()->ifGovermentPaysStartupHelp()) {
// Display link to goverment for startup help
// Money bank is closed!
}
-if ($linkInstance->getValueInstance()->ifRefillPageActive()) {
+if ($linkInstance->ifRefillPageActive()) {
// Display link to refill page
} else {
// Refill page not active
--- /dev/null
+Deny from all
* @throws NullPointerException If the result instance is null
*/
function getField ($fieldName);
-
- /**
- * Updates a given field with new value
- *
- * @param $fieldName Field to update
- * @param $fieldValue New value to store
- * @return void
- * @throws DatabaseUpdateSupportException If this class does not support database updates
- */
- function updateDatabaseField ($fieldName, $fieldValue);
}
//
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface Updateable extends FrameworkInterface {
+ /**
+ * Updates a given field with new value
+ *
+ * @param $fieldName Field to update
+ * @param $fieldValue New value to store
+ * @return void
+ * @throws DatabaseUpdateSupportException If this class does not support database updates
+ */
+ function updateDatabaseField ($fieldName, $fieldValue);
}
//
*/
private $resultInstance = null;
+ /**
+ * Instance for user class
+ */
+ private $userInstance = null;
+
/**
* The real class name
*/
} elseif (is_array($args)) {
// Some arguments are there
foreach ($args as $arg) {
- // Check the type
- if (is_bool($arg)) {
- // Boolean!
- if ($arg) $argsString .= "true(bool)"; else $argsString .= "false(bool)";
- } elseif (is_int($arg)) {
- // Integer
- $argsString .= $arg."(int)";
- } elseif (is_float($arg)) {
- // Floating point
- $argsString .= $arg."(float)";
- } elseif ($arg instanceof BaseFrameworkSystem) {
- // Own object instance
- $argsString .= $arg->__toString()."(Object)";
- } elseif (is_object($arg)) {
- // External object
- $argsString .= "unknown object(!)";
- } elseif (is_array($arg)) {
- // Array
- $argsString .= "Array(array)";
- } elseif (is_string($arg)) {
- // String
- $argsString .= "\"".$arg."\"(string)";
- } elseif (is_null($arg)) {
- // Null
- $argsString .= "(null)";
- } elseif (is_resource($arg)) {
- // Resource
- $argsString .= "(resource)";
- } else {
- // Unknown type (please report!)
- $argsString .= $arg."(<em>unknown!</em>)";
- }
-
- // Add comma
- $argsString .= ", ";
- }
+ // Add the type
+ $argsString .= $arg." (".gettype($arg)."), ";
+ } // END - foreach
// Remove last comma
if (substr($argsString, -2, 1) === ",") {
}
/**
- * Updates a given field with new value
+ * Protected setter for user instance
*
- * @param $fieldName Field to update
- * @param $fieldValue New value to store
+ * @param $userInstance An instance of a user class
* @return void
- * @throws DatabaseUpdateSupportException If this class does not support database updates
*/
- public function updateDatabaseField ($fieldName, $fieldValue) {
- // Is updating database fields allowed by interface?
- if (!$this instanceof Updateable) {
- // Update not supported!
- throw new DatabaseUpdateSupportException($this, self::EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED);
- } // 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($fieldName, $fieldValue);
-
- // Add the search criteria for searching for the right entry
- $updateInstance->setSearchInstance($searchInstance);
+ protected final function setUserInstance (ManageableAccount $userInstance) {
+ $this->userInstance = $userInstance;
+ }
- // Remember the update in database result
- $this->getResultInstance()->add2UpdateQueue($updateInstance);
+ /**
+ * Getter for user instance
+ *
+ * @return $userInstance An instance of a user class
+ */
+ public final function getUserInstance () {
+ return $this->userInstance;
}
}
parent::__construct(__CLASS__);
// Set part description
- $this->setObjectDescription("Database wrapper for user objects");
+ $this->setObjectDescription("Database wrapper for news objects");
// Create unique ID number
$this->generateUniqueId();
--- /dev/null
+<?php
+/**
+ * A database wrapper for user points classes
+ *
+ * @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 UserPointsDatabaseWrapper extends BaseDatabaseWrapper {
+ // Constants for database table names
+ const DB_TABLE_USER_POINTS = "user_points";
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct() {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Database wrapper for user points objects");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public final static function createUserPointsDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new UserPointsDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_USER_POINTS);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+}
+
+// [EOF]
+?>
$isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->readConfig('user_status_guest'));
return $isUnconfirmed;
}
+
+ /**
+ * Checks wether the refill page is active which should be not the default
+ * on non-web applications.
+ *
+ * @return $refillActive Wether the refill page is active
+ */
+ public function ifRefillPageActive () {
+ $refillActive = ($this->getConfigInstance()->readConfig('refill_page_active') === "Y");
+ return $refillActive;
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A class for handling user points which can be real or Internet currency
+ *
+ * @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 UserPoints extends BaseFrameworkSystem implements Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Class for handling user points");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ $this->removeSystemArray();
+ }
+
+ /**
+ * Creates an instance of this points class
+ *
+ * @param $userInstance An instance of a user class
+ * @return $pointsInstance An instance of this class
+ */
+ public final static function createUserPoints (ManageableAccount $userInstance) {
+ // Get a new instance
+ $pointsInstance = new UserPoints();
+
+ // Set user instance
+ $pointsInstance->setUserInstance($userInstance);
+
+ // Return instance
+ return $pointsInstance;
+ }
+
+ /**
+ * Checks wether the user has the required amount of points left for the specified action
+ *
+ * @param $action The action or configuration entry plus prefix the user wants to perform
+ * @return $hasRequired Wether the user has the required points
+ */
+ public function ifUserHasRequiredPoints ($action) {
+ // Default is that everyone is poor... ;-)
+ $hasRequired = false;
+
+ // Get the required points entry
+ $requiredPoints = $this->getConfigInstance()->readConfig($action . '_action_points');
+
+ // Get a wrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_points_db_wrapper_class');
+
+ // Now get a search criteria and set the user's name as criteria
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ $criteriaInstance->addCriteria('points_uid', $this->getUserInstance()->getUserName());
+ $criteriaInstance->setLimit(1);
+
+ // Get result back
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Do we have an entry?
+ if ($resultInstance->next()) {
+ // Load points here - TODO!
+ $this->partialStub("Load points here for comparison.");
+ } // END - if
+
+ // Return the result
+ return $hasRequired;
+ }
+}
+
+// [EOF]
+?>
// Return the value
return $primaryValue;
}
+
+ /**
+ * Updates a given field with new value
+ *
+ * @param $fieldName Field to update
+ * @param $fieldValue New value to store
+ * @return void
+ * @throws DatabaseUpdateSupportException If this class does not support database updates
+ */
+ public function updateDatabaseField ($fieldName, $fieldValue) {
+ // Is updating database fields allowed by interface?
+ if (!$this instanceof Updateable) {
+ // Update not supported!
+ throw new DatabaseUpdateSupportException($this, self::EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED);
+ } // 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($fieldName, $fieldValue);
+
+ // Add the search criteria for searching for the right entry
+ $updateInstance->setSearchInstance($searchInstance);
+
+ // Remember the update in database result
+ $this->getResultInstance()->add2UpdateQueue($updateInstance);
+ }
}
// [EOF]