462e8bfb87f118cdbe2ba3578149893585ce06fc
[shipsimu.git] / inc / classes / main / helper / web / class_BaseWebHelper.php
1 <?php
2 /**
3  * A general purpose web helper. You should not instance this like all the other
4  * base classes. Instead write your own web helper class and inherit this class.
5  *
6  * @author              Roland Haeder <webmaster@ship-simu.org>
7  * @version             0.0.0
8  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, this is free software
9  * @license             GNU GPL 3.0 or any newer version
10  * @link                http://www.ship-simu.org
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 class BaseWebHelper extends BaseHelper {
26         /**
27          * Protected constructor
28          *
29          * @param       $className      The real class name
30          * @return      void
31          */
32         protected function __construct ($className) {
33                 // Call parent constructor
34                 parent::__construct($className);
35         }
36
37         /**
38          * Checks wether the registration requires a valid email address
39          *
40          * @return      $required       Wether the email address is required
41          */
42         public function ifRegisterRequiresEmailVerification () {
43                 $required = ($this->getConfigInstance()->readConfig('register_requires_email') === "Y");
44                 return $required;
45         }
46
47         /**
48          * Checks wether profile data shall be asked
49          *
50          * @return      $required       Wether profile shall be asked
51          */
52         public function ifRegisterIncludesProfile () {
53                 $required = ($this->getConfigInstance()->readConfig('register_includes_profile') === "Y");
54                 return $required;
55         }
56
57         /**
58          * Checks wether personal data shall be asked
59          *
60          * @return      $required       Wether personal data shall be asked
61          */
62         public function ifRegisterIncludesPersonaData () {
63                 $required = ($this->getConfigInstance()->readConfig('register_personal_data') === "Y");
64                 return $required;
65         }
66
67         /**
68          * Checks wether email addresses can only be once used
69          *
70          * @return      $isUnique
71          */
72         public function ifEmailMustBeUnique () {
73                 $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') === "Y");
74                 return $isUnique;
75         }
76
77         /**
78          * Checks wether the specified chat protocol is enabled in this form
79          *
80          * @return      $required       Wether the specified chat protocol is enabled
81          */
82         public function ifChatEnabled ($chatProtocol) {
83                 $required = ($this->getConfigInstance()->readConfig(sprintf("chat_enabled_%s", $chatProtocol)) == "Y");
84                 return $required;
85         }
86
87         /**
88          * Checks wether login is enabled or disabled
89          *
90          * @return      $isEnabled      Wether the login is enabled or disabled
91          */
92         public function ifLoginIsEnabled () {
93                 $isEnabled = ($this->getConfigInstance()->readConfig('login_enabled') === "Y");
94                 return $isEnabled;
95         }
96
97         /**
98          * Checks wether login shall be done by username
99          *
100          * @return      $isEnabled      Wether the login shall be done by username
101          */
102         public function ifLoginWithUsername () {
103                 $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "username");
104                 return $isEnabled;
105         }
106
107         /**
108          * Checks wether login shall be done by email
109          *
110          * @return      $isEnabled      Wether the login shall be done by email
111          */
112         public function ifLoginWithEmail () {
113                 $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "email");
114                 return $isEnabled;
115         }
116
117         /**
118          * Checks wether guest login is allowed
119          *
120          * @return      $isAllowed      Wether guest login is allowed
121          */
122         public function ifGuestLoginAllowed () {
123                 $isAllowed = ($this->getConfigInstance()->readConfig('guest_login_allowed') === "Y");
124                 return $isAllowed;
125         }
126
127         /**
128          * Checks wether the email address change must be confirmed
129          *
130          * @return      $requireConfirm         Wether email change must be confirmed
131          */
132         public function ifEmailChangeRequireConfirmation () {
133                 $requireConfirm = ($this->getConfigInstance()->readConfig('email_change_confirmation') === "Y");
134                 return $requireConfirm;
135         }
136
137         /**
138          * Checks wether the rules has been updated
139          *
140          * @return      $rulesUpdated   Wether rules has been updated
141          * @todo        Implement check if rules have been changed
142          */
143         public function ifRulesHaveChanged () {
144                 return false;
145         }
146
147         /**
148          * Checks wether email change is allowed
149          *
150          * @return      $emailChange    Wether changing email address is allowed
151          */
152         public function ifEmailChangeAllowed () {
153                 $emailChange = ($this->getConfigInstance()->readConfig('email_change_allowed') === "Y");
154                 return $emailChange;
155         }
156
157         /**
158          * Checks wether the user account is unconfirmed
159          *
160          * @return      $isUnconfirmed  Wether the user account is unconfirmed
161          */
162         public function ifUserAccountUnconfirmed () {
163                 $isUnconfirmed = ($this->getField('user_status') === $this->getConfigInstance()->readConfig('user_status_unconfirmed'));
164                 return $isUnconfirmed;
165         }
166
167         /**
168          * Checks wether the user account is locked
169          *
170          * @return      $isUnconfirmed  Wether the user account is locked
171          */
172         public function ifUserAccountLocked () {
173                 $isUnconfirmed = ($this->getField('user_status') === $this->getConfigInstance()->readConfig('user_status_locked'));
174                 return $isUnconfirmed;
175         }
176
177         /**
178          * Checks wether the user account is a guest
179          *
180          * @return      $isUnconfirmed  Wether the user account is a guest
181          */
182         public function ifUserAccountGuest () {
183                 $isUnconfirmed = ($this->getField('user_status') === $this->getConfigInstance()->readConfig('user_status_guest'));
184                 return $isUnconfirmed;
185         }
186 }
187
188 // [EOF]
189 ?>