3 * A money bank which may lend points to the user
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class MoneyBank extends BaseBank implements Registerable {
26 * Protected constructor
30 protected function __construct () {
31 // Call parent constructor
32 parent::__construct(__CLASS__);
36 * Creates an instance of this money bank class
38 * @param $userInstance A class instance of a user object
39 * @return $bankInstance An instance of this class
41 public static final function createMoneyBank (ManageableAccount $userInstance) {
43 $moneyInstance = new MoneyBank();
45 // Set the user instance
46 $moneyInstance->setUserInstance($userInstance);
48 // Return the prepared instance
49 return $moneyInstance;
53 * Checks wether the bank lends more money to the current user
55 * @return $lendsMoreMoney Wether this bank lends more money to the user
57 public function ifBankLendsMoreMoney () {
62 * Checks wethert the current user has maximum allowed credits with this bank
64 * @return $hasMaximumCredits Wether the user has maximum allowed credits
66 public function ifUserHasMaxCredits () {
71 * Checks wether this money bank has opened
73 * @return $hasOpened Wether this money bank has opened
75 public function ifMoneyBankHasOpened () {
76 // Has not opened by default
79 // Is the money bank activated in config?
80 if ($this->getConfigInstance()->getConfigEntry('moneybank_activated')) {
81 // Okay, does the user ask within the opening times? To find this out we need a OpeningTimes class
82 $openingInstance = ObjectFactory::createObjectByConfiguredName('moneybank_opening_class', array($this));
84 // Then we simply "ask" the opening time instance if the user asks within the opening time
85 $hasOpened = $openingInstance->ifWithinOpeningTimes();