From 333fda7938c0463a52d4990aac82cb47f935ea7b Mon Sep 17 00:00:00 2001 From: Philippe Deatherage Date: Sun, 6 Dec 2015 20:34:11 -0800 Subject: [PATCH] Exclude IP Addresses Added code to allow you to set IP addresses to exclude from login requirement. This is helpful if certain IP addresses should be able to access the site without login. --- .../B2BProfessional/Helper/Customer.php | 15 +++++++++++++++ .../Sitewards/B2BProfessional/etc/system.xml | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/code/community/Sitewards/B2BProfessional/Helper/Customer.php b/app/code/community/Sitewards/B2BProfessional/Helper/Customer.php index 8db06a3..266acaf 100644 --- a/app/code/community/Sitewards/B2BProfessional/Helper/Customer.php +++ b/app/code/community/Sitewards/B2BProfessional/Helper/Customer.php @@ -17,6 +17,11 @@ class Sitewards_B2BProfessional_Helper_Customer extends Sitewards_B2BProfessiona */ const CONFIG_EXTENSION_REQUIRES_LOGIN = 'b2bprofessional/requirelogin/requirelogin'; + /** + * Path for the config for extension allowed ip addresses that don't need to login + */ + //const CONFIG_EXTENSION_REQUIRES_LOGIN_IPADDRESSES = 'b2bprofessional/exemptips/ipaddresses'; + /** * Path for the config for extension is active by customer group */ @@ -157,7 +162,17 @@ public function isCustomerGroupActive() */ public function isLoginRequired() { + //added by Philip pd@dwdonline.com DWD + $allowedIPAddresses = Mage::getStoreConfig('b2bprofessional/exemptips/ipaddresses'); + $ip = $_SERVER['REMOTE_ADDR']; + $allowed = explode(",",$allowedIPAddresses); + + if (in_array($ip, $allowed)) { + return $this->getStoreFlag('0', 'bLoginRequired'); + } else { return $this->getStoreFlag(self::CONFIG_EXTENSION_REQUIRES_LOGIN, 'bLoginRequired'); + } + //end added by Philip pd@dwdonline.com DWD } /** diff --git a/app/code/community/Sitewards/B2BProfessional/etc/system.xml b/app/code/community/Sitewards/B2BProfessional/etc/system.xml index ed9d312..134aeb7 100644 --- a/app/code/community/Sitewards/B2BProfessional/etc/system.xml +++ b/app/code/community/Sitewards/B2BProfessional/etc/system.xml @@ -96,6 +96,25 @@ + + + text + 3 + 1 + 1 + 1 + + + + text + 3 + 1 + 1 + 1 + + + + text