1 | <?php |
||
13 | class Sitewards_B2BProfessional_Helper_Customer extends Sitewards_B2BProfessional_Helper_Core |
||
14 | { |
||
15 | /** |
||
16 | * Path for the config for extension requires login |
||
17 | */ |
||
18 | const CONFIG_EXTENSION_REQUIRES_LOGIN = 'b2bprofessional/requirelogin/requirelogin'; |
||
19 | |||
20 | /** |
||
21 | * Path for the config for extension is active by customer group |
||
22 | */ |
||
23 | const CONFIG_EXTENSION_ACTIVE_BY_CUSTOMER_GROUP = 'b2bprofessional/activatebycustomersettings/activebycustomer'; |
||
24 | |||
25 | /** |
||
26 | * Path for the config for customer groups that are activated |
||
27 | */ |
||
28 | const CONFIG_EXTENSION_ACTIVE_CUSTOMER_GROUPS = 'b2bprofessional/activatebycustomersettings/activecustomers'; |
||
29 | |||
30 | /** |
||
31 | * Path for the config for global customers activation |
||
32 | */ |
||
33 | const CONFIG_EXTENSION_ACTIVE_CUSTOMER_GLOBALLY = 'b2bprofessional/generalsettings/activecustomers'; |
||
34 | |||
35 | /** |
||
36 | * Path for the config for checking customer website and not customer store |
||
37 | */ |
||
38 | const CONFIG_EXTENSION_CHECK_WEBSITE = 'b2bprofessional/generalsettings/check_website'; |
||
39 | |||
40 | /** |
||
41 | * Flag if the extension is set to require login |
||
42 | * |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $bLoginRequired; |
||
46 | |||
47 | /** |
||
48 | * Flag if the extension is active by customer group |
||
49 | * |
||
50 | * @var bool |
||
51 | */ |
||
52 | protected $bExtensionActiveByCustomerGroup; |
||
53 | |||
54 | /** |
||
55 | * Array of activated customer group ids |
||
56 | * |
||
57 | * @var int[] |
||
58 | */ |
||
59 | protected $aActivatedCustomerGroupIds = array(); |
||
60 | |||
61 | /** |
||
62 | * Check to see if the customer is logged in |
||
63 | * - Is the session logged in, |
||
64 | * - Are customers activated globally, |
||
65 | * - Is this one customer active for the current store, |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function isCustomerLoggedIn() |
||
98 | |||
99 | /** |
||
100 | * Check if the extension has customers activated globally |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | private function isCustomerActivationGlobal() |
||
108 | |||
109 | /** |
||
110 | * Check if a given customer is allowed for the current store |
||
111 | * - NOTE: users created via the admin section cannot be attached to a front end store and so are globally active |
||
112 | * |
||
113 | * @param Mage_Customer_Model_Customer $oCustomer |
||
114 | * @return bool |
||
115 | */ |
||
116 | private function isCustomerActiveForStore(Mage_Customer_Model_Customer $oCustomer) |
||
137 | |||
138 | /** |
||
139 | * Check if a given customer is allowed for the current website |
||
140 | * |
||
141 | * @param Mage_Customer_Model_Customer $oCustomer |
||
142 | * @return bool |
||
143 | */ |
||
144 | private function isCustomerActiveForWebsite(Mage_Customer_Model_Customer $oCustomer) |
||
157 | |||
158 | /** |
||
159 | * Check to see if the user has been created via the admin section |
||
160 | * |
||
161 | * @param Mage_Customer_Model_Customer $oCustomer |
||
162 | * @return bool |
||
163 | */ |
||
164 | private function isCustomerAdminCreation(Mage_Customer_Model_Customer $oCustomer) |
||
168 | |||
169 | /** |
||
170 | * Check to see if the customer's group is active |
||
171 | * - If they are not logged in then we do not need to check any further |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function isCustomerGroupActive() |
||
184 | |||
185 | /** |
||
186 | * Check to see if the website is set-up to require a user login to view pages |
||
187 | * |
||
188 | * @return bool |
||
189 | */ |
||
190 | public function isLoginRequired() |
||
194 | |||
195 | /** |
||
196 | * Check to see if the extension is activated by customer group |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | public function isExtensionActivatedByCustomerGroup() |
||
204 | |||
205 | /** |
||
206 | * Get an array of all the activated customer group ids |
||
207 | * - always include the 'NOT LOGGED IN' group |
||
208 | * |
||
209 | * @return int[] |
||
210 | */ |
||
211 | private function getActivatedCustomerGroupIds() |
||
228 | } |