Updated 'core' + renamed 'main' -> 'classes'.
[shipsimu.git] / application / shipsimu / classes / bank / money / class_MoneyBank.php
1 <?php
2 /**
3  * A money bank which may lend points to the user
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
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
10  *
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.
15  *
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.
20  *
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/>.
23  */
24 class MoneyBank extends BaseBank implements Registerable {
25         /**
26          * Protected constructor
27          *
28          * @return      void
29          */
30         protected function __construct () {
31                 // Call parent constructor
32                 parent::__construct(__CLASS__);
33         }
34
35         /**
36          * Creates an instance of this money bank class
37          *
38          * @param       $userInstance   A class instance of a user object
39          * @return      $bankInstance   An instance of this class
40          */
41         public static final function createMoneyBank (ManageableAccount $userInstance) {
42                 // Get a new instance
43                 $moneyInstance = new MoneyBank();
44
45                 // Set the user instance
46                 $moneyInstance->setUserInstance($userInstance);
47
48                 // Return the prepared instance
49                 return $moneyInstance;
50         }
51
52         /**
53          * Checks wether the bank lends more money to the current user
54          *
55          * @return      $lendsMoreMoney         Wether this bank lends more money to the user
56          */
57         public function ifBankLendsMoreMoney () {
58                 $this->partialStub();
59         }
60
61         /**
62          * Checks wethert the current user has maximum allowed credits with this bank
63          *
64          * @return      $hasMaximumCredits      Wether the user has maximum allowed credits
65          */
66         public function ifUserHasMaxCredits () {
67                 $this->partialStub();
68         }
69
70         /**
71          * Checks wether this money bank has opened
72          *
73          * @return      $hasOpened      Wether this money bank has opened
74          */
75         public function ifMoneyBankHasOpened () {
76                 // Has not opened by default
77                 $hasOpened = false;
78
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));
83
84                         // Then we simply "ask" the opening time instance if the user asks within the opening time
85                         $hasOpened = $openingInstance->ifWithinOpeningTimes();
86                 } // END - if
87
88                 // Return status
89                 return $hasOpened;
90         }
91 }
92
93 // [EOF]
94 ?>