├── app ├── locale │ └── fr_FR │ │ └── Inchoo_SocialConnect.csv ├── code │ └── community │ │ └── Inchoo │ │ └── SocialConnect │ │ ├── Model │ │ ├── Facebook │ │ │ ├── Oauth2 │ │ │ │ └── Exception.php │ │ │ ├── Info │ │ │ │ └── User.php │ │ │ └── Info.php │ │ ├── Google │ │ │ ├── Oauth2 │ │ │ │ └── Exception.php │ │ │ ├── Info │ │ │ │ └── User.php │ │ │ └── Info.php │ │ ├── Twitter │ │ │ ├── Oauth │ │ │ │ └── Exception.php │ │ │ ├── Info │ │ │ │ └── User.php │ │ │ └── Info.php │ │ ├── Linkedin │ │ │ ├── Oauth2 │ │ │ │ └── Exception.php │ │ │ ├── Info │ │ │ │ └── User.php │ │ │ └── Info.php │ │ └── Resource │ │ │ └── Setup.php │ │ ├── Block │ │ ├── Facebook │ │ │ ├── Adminhtml │ │ │ │ └── System │ │ │ │ │ └── Config │ │ │ │ │ └── Form │ │ │ │ │ └── Field │ │ │ │ │ ├── Origins.php │ │ │ │ │ ├── Redirects.php │ │ │ │ │ └── Links.php │ │ │ ├── Button.php │ │ │ └── Account.php │ │ ├── Google │ │ │ ├── Adminhtml │ │ │ │ └── System │ │ │ │ │ └── Config │ │ │ │ │ └── Form │ │ │ │ │ └── Field │ │ │ │ │ ├── Origins.php │ │ │ │ │ ├── Redirects.php │ │ │ │ │ └── Links.php │ │ │ ├── Button.php │ │ │ └── Account.php │ │ ├── Linkedin │ │ │ ├── Adminhtml │ │ │ │ └── System │ │ │ │ │ └── Config │ │ │ │ │ └── Form │ │ │ │ │ └── Field │ │ │ │ │ ├── Origins.php │ │ │ │ │ ├── Redirects.php │ │ │ │ │ └── Links.php │ │ │ ├── Button.php │ │ │ └── Account.php │ │ ├── Twitter │ │ │ ├── Adminhtml │ │ │ │ └── System │ │ │ │ │ └── Config │ │ │ │ │ └── Form │ │ │ │ │ └── Field │ │ │ │ │ ├── Origins.php │ │ │ │ │ ├── Redirects.php │ │ │ │ │ └── Links.php │ │ │ ├── Button.php │ │ │ └── Account.php │ │ ├── Adminhtml │ │ │ └── System │ │ │ │ └── Config │ │ │ │ └── Form │ │ │ │ └── Field │ │ │ │ ├── Origins.php │ │ │ │ ├── Redirects.php │ │ │ │ └── Links.php │ │ ├── Checkout.php │ │ ├── Register.php │ │ └── Login.php │ │ ├── Helper │ │ ├── Data.php │ │ ├── Linkedin.php │ │ ├── Twitter.php │ │ ├── Facebook.php │ │ └── Google.php │ │ ├── sql │ │ └── inchoo_socialconnect_setup │ │ │ ├── upgrade-0.2.6-0.3.0.php │ │ │ ├── upgrade-0.1.0-0.2.0.php │ │ │ └── install-0.1.0.php │ │ ├── Controller │ │ └── Abstract.php │ │ ├── controllers │ │ ├── AccountController.php │ │ ├── TwitterController.php │ │ ├── GoogleController.php │ │ ├── FacebookController.php │ │ └── LinkedinController.php │ │ └── etc │ │ └── config.xml ├── etc │ └── modules │ │ └── Inchoo_SocialConnect.xml └── design │ └── frontend │ └── base │ └── default │ └── template │ └── inchoo │ └── socialconnect │ ├── google │ ├── button.phtml │ └── account.phtml │ ├── linkedin │ ├── button.phtml │ └── account.phtml │ ├── twitter │ ├── button.phtml │ └── account.phtml │ ├── facebook │ ├── button.phtml │ └── account.phtml │ ├── checkout.phtml │ ├── register.phtml │ ├── login.phtml │ └── checkout │ └── onepage │ └── login.phtml ├── skin └── frontend │ └── base │ └── default │ └── inchoo_socialconnect │ ├── facebook │ ├── images │ │ ├── login-button-left.png │ │ ├── login-button-inner.png │ │ └── login-button-right.png │ └── css │ │ └── button.css │ ├── google │ ├── images │ │ ├── login-button-inner.png │ │ ├── login-button-left.png │ │ └── login-button-right.png │ └── css │ │ └── button.css │ ├── linkedin │ ├── images │ │ ├── login-button-left.png │ │ ├── login-button-inner.png │ │ └── login-button-right.png │ └── css │ │ └── button.css │ ├── twitter │ ├── images │ │ ├── login-button-inner.png │ │ ├── login-button-left.png │ │ └── login-button-right.png │ └── css │ │ └── button.css │ └── css │ └── styles.css ├── README.md └── modman /app/locale/fr_FR/Inchoo_SocialConnect.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chapagain/Inchoo_SocialConnect/master/app/locale/fr_FR/Inchoo_SocialConnect.csv -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Facebook/Oauth2/Exception.php: -------------------------------------------------------------------------------- 1 | %s', Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Twitter/Adminhtml/System/Config/Form/Field/Links.php: -------------------------------------------------------------------------------- 1 | %ssocialconnect/%s/connect/', 15 | Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB), 16 | $this->getAuthProvider() 17 | ); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Adminhtml/System/Config/Form/Field/Links.php: -------------------------------------------------------------------------------- 1 | %s', 20 | $this->getAuthProviderLinkHref(), 21 | $this->getAuthProviderLink() 22 | ); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /modman: -------------------------------------------------------------------------------- 1 | app/code/community/Inchoo/SocialConnect/ app/code/community/Inchoo/SocialConnect/ 2 | app/design/frontend/base/default/layout/inchoo_socialconnect.xml app/design/frontend/base/default/layout/inchoo_socialconnect.xml 3 | app/design/frontend/base/default/template/inchoo/socialconnect/ app/design/frontend/base/default/template/inchoo/socialconnect/ 4 | app/etc/modules/Inchoo_SocialConnect.xml app/etc/modules/Inchoo_SocialConnect.xml 5 | skin/frontend/base/default/inchoo_socialconnect/ skin/frontend/base/default/inchoo_socialconnect/ 6 | app/locale/da_DK/Inchoo_SocialConnect.csv app/locale/da_DK/Inchoo_SocialConnect.csv 7 | app/locale/en_US/Inchoo_SocialConnect.csv app/locale/en_US/Inchoo_SocialConnect.csv 8 | app/locale/sl_SI/Inchoo_SocialConnect.csv app/locale/sl_SI/Inchoo_SocialConnect.csv 9 | app/locale/de_DE/Inchoo_SocialConnect.csv app/locale/de_DE/Inchoo_SocialConnect.csv 10 | app/locale/fr_FR/Inchoo_SocialConnect.csv app/locale/fr_FR/Inchoo_SocialConnect.csv 11 | -------------------------------------------------------------------------------- /app/etc/modules/Inchoo_SocialConnect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | 37 | 38 | 39 | 40 | true 41 | community 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Helper/Data.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Helper_Data extends Mage_Core_Helper_Abstract 35 | { 36 | public static function log($message, $level = null, $file = '', $forceLog = false) 37 | { 38 | if(Mage::getIsDeveloperMode()) { 39 | Mage::log($message, $level, $file, $forceLog); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/google/button.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 |
35 |
36 | 39 |
40 |
41 |
42 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/linkedin/button.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 |
35 |
36 | 39 |
40 |
41 |
-------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/twitter/button.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 |
35 |
36 | 39 |
40 |
41 |
-------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/facebook/button.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 |
35 |
36 | 39 |
40 |
41 |
42 | -------------------------------------------------------------------------------- /skin/frontend/base/default/inchoo_socialconnect/css/styles.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Inchoo 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/osl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@magentocommerce.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Please do not edit or add to this file if you wish to upgrade 17 | * Magento or this extension to newer versions in the future. 18 | ** Inchoo *give their best to conform to 19 | * "non-obtrusive, best Magento practices" style of coding. 20 | * However,* Inchoo *guarantee functional accuracy of 21 | * specific extension behavior. Additionally we take no responsibility 22 | * for any possible issue(s) resulting from extension usage. 23 | * We reserve the full right not to provide any kind of support for our free extensions. 24 | * Thank you for your understanding. 25 | * 26 | * @category Inchoo 27 | * @package SocialConnect 28 | * @author Marko Martinović 29 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 30 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 31 | */ 32 | 33 | div.inchoo-socialconnect-register, 34 | div.inchoo-socialconnect-checkout, 35 | div.inchoo-socialconnect-login { 36 | margin-top: 28px; 37 | } 38 | 39 | div.inchoo-socialconnect-login .content { 40 | min-height: 100px; 41 | } 42 | 43 | div.inchoo-socialconnect-register .fieldset { 44 | margin: 0px; 45 | } 46 | 47 | div.inchoo-socialconnect-account .col3-set .col-1 { 48 | width: 29% 49 | } 50 | 51 | div.inchoo-socialconnect-account .col3-set .col-2 { 52 | width: 49% 53 | } 54 | 55 | div.inchoo-socialconnect-account .col3-set .col-3 { 56 | width: 19% 57 | } 58 | 59 | div.inchoo-socialconnect-account .col2-set .col-1 { 60 | width: 79% 61 | } 62 | 63 | div.inchoo-socialconnect-account .col2-set .col-2 { 64 | width: 19% 65 | } 66 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/sql/inchoo_socialconnect_setup/upgrade-0.2.6-0.3.0.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | $installer = $this; 35 | $installer->startSetup(); 36 | 37 | $installer->setCustomerAttributes( 38 | array( 39 | 'inchoo_socialconnect_lid' => array( 40 | 'type' => 'text', 41 | 'visible' => false, 42 | 'required' => false, 43 | 'user_defined' => false 44 | ), 45 | 'inchoo_socialconnect_ltoken' => array( 46 | 'type' => 'text', 47 | 'visible' => false, 48 | 'required' => false, 49 | 'user_defined' => false 50 | ) 51 | ) 52 | ); 53 | 54 | // Install our custom attributes 55 | $installer->installCustomerAttributes(); 56 | 57 | // Remove our custom attributes (for testing) 58 | //$installer->removeCustomerAttributes(); 59 | 60 | $installer->endSetup(); -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/sql/inchoo_socialconnect_setup/upgrade-0.1.0-0.2.0.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | $installer = $this; 35 | $installer->startSetup(); 36 | 37 | $installer->setCustomerAttributes( 38 | array( 39 | 'inchoo_socialconnect_tid' => array( 40 | 'type' => 'text', 41 | 'visible' => false, 42 | 'required' => false, 43 | 'user_defined' => false 44 | ), 45 | 'inchoo_socialconnect_ttoken' => array( 46 | 'type' => 'text', 47 | 'visible' => false, 48 | 'required' => false, 49 | 'user_defined' => false 50 | ) 51 | ) 52 | ); 53 | 54 | // Install our custom attributes 55 | $installer->installCustomerAttributes(); 56 | 57 | // Remove our custom attributes (for testing) 58 | //$installer->removeCustomerAttributes(); 59 | 60 | $installer->endSetup(); -------------------------------------------------------------------------------- /skin/frontend/base/default/inchoo_socialconnect/google/css/button.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Inchoo 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/osl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@magentocommerce.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Please do not edit or add to this file if you wish to upgrade 17 | * Magento or this extension to newer versions in the future. 18 | ** Inchoo *give their best to conform to 19 | * "non-obtrusive, best Magento practices" style of coding. 20 | * However,* Inchoo *guarantee functional accuracy of 21 | * specific extension behavior. Additionally we take no responsibility 22 | * for any possible issue(s) resulting from extension usage. 23 | * We reserve the full right not to provide any kind of support for our free extensions. 24 | * Thank you for your understanding. 25 | * 26 | * @category Inchoo 27 | * @package SocialConnect 28 | * @author Marko Martinović 29 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 30 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 31 | */ 32 | 33 | div.inchoo-socialconnect-google{ 34 | float: right; 35 | height: 30px !important; 36 | background: transparent url('../images/login-button-left.png') no-repeat top left !important; 37 | } 38 | 39 | div.inchoo-socialconnect-google-inner{ 40 | height: 30px !important; 41 | float: left !important; 42 | margin-left: 30px !important; 43 | background: transparent url('../images/login-button-inner.png') repeat-x top left !important; 44 | padding: 0 5px !important; 45 | text-shadow: 1px 1px #000000; 46 | } 47 | 48 | div.inchoo-socialconnect-google-right{ 49 | float: left !important; 50 | height: 30px !important; 51 | width: 3px !important; 52 | background: transparent url('../images/login-button-right.png') no-repeat top left !important; 53 | } 54 | 55 | div.inchoo-socialconnect-google-inner a{ 56 | color: #FFFFFF !important; 57 | padding: 0 !important; 58 | margin: 0 !important; 59 | text-decoration: none !important; 60 | line-height: 30px !important; 61 | } 62 | -------------------------------------------------------------------------------- /skin/frontend/base/default/inchoo_socialconnect/twitter/css/button.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Inchoo 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/osl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@magentocommerce.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Please do not edit or add to this file if you wish to upgrade 17 | * Magento or this extension to newer versions in the future. 18 | ** Inchoo *give their best to conform to 19 | * "non-obtrusive, best Magento practices" style of coding. 20 | * However,* Inchoo *guarantee functional accuracy of 21 | * specific extension behavior. Additionally we take no responsibility 22 | * for any possible issue(s) resulting from extension usage. 23 | * We reserve the full right not to provide any kind of support for our free extensions. 24 | * Thank you for your understanding. 25 | * 26 | * @category Inchoo 27 | * @package SocialConnect 28 | * @author Marko Martinović 29 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 30 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 31 | */ 32 | 33 | div.inchoo-socialconnect-twitter{ 34 | float: right; 35 | height: 30px !important; 36 | background: transparent url('../images/login-button-left.png') no-repeat top left !important; 37 | } 38 | 39 | div.inchoo-socialconnect-twitter-inner{ 40 | height: 30px !important; 41 | float: left !important; 42 | margin-left: 30px !important; 43 | background: transparent url('../images/login-button-inner.png') repeat-x top left !important; 44 | padding: 0 5px !important; 45 | text-shadow: 1px 1px #00a1c4; 46 | } 47 | 48 | div.inchoo-socialconnect-twitter-right{ 49 | float: left !important; 50 | height: 30px !important; 51 | width: 3px !important; 52 | background: transparent url('../images/login-button-right.png') no-repeat top left !important; 53 | } 54 | 55 | div.inchoo-socialconnect-twitter-inner a{ 56 | color: #FFFFFF !important; 57 | padding: 0 !important; 58 | margin: 0 !important; 59 | text-decoration: none !important; 60 | line-height: 30px !important; 61 | } 62 | -------------------------------------------------------------------------------- /skin/frontend/base/default/inchoo_socialconnect/facebook/css/button.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Inchoo 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/osl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@magentocommerce.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Please do not edit or add to this file if you wish to upgrade 17 | * Magento or this extension to newer versions in the future. 18 | ** Inchoo *give their best to conform to 19 | * "non-obtrusive, best Magento practices" style of coding. 20 | * However,* Inchoo *guarantee functional accuracy of 21 | * specific extension behavior. Additionally we take no responsibility 22 | * for any possible issue(s) resulting from extension usage. 23 | * We reserve the full right not to provide any kind of support for our free extensions. 24 | * Thank you for your understanding. 25 | * 26 | * @category Inchoo 27 | * @package SocialConnect 28 | * @author Marko Martinović 29 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 30 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 31 | */ 32 | 33 | div.inchoo-socialconnect-facebook{ 34 | float: right; 35 | height: 30px !important; 36 | background: transparent url('../images/login-button-left.png') no-repeat top left !important; 37 | } 38 | 39 | div.inchoo-socialconnect-facebook-inner{ 40 | height: 30px !important; 41 | float: left !important; 42 | margin-left: 30px !important; 43 | background: transparent url('../images/login-button-inner.png') repeat-x top left !important; 44 | padding: 0 5px !important; 45 | text-shadow: 1px 1px #1c376d; 46 | } 47 | 48 | div.inchoo-socialconnect-facebook-right{ 49 | float: left !important; 50 | height: 30px !important; 51 | width: 3px !important; 52 | background: transparent url('../images/login-button-right.png') no-repeat top left !important; 53 | } 54 | 55 | div.inchoo-socialconnect-facebook-inner a{ 56 | color: #FFFFFF !important; 57 | padding: 0 !important; 58 | margin: 0 !important; 59 | text-decoration: none !important; 60 | line-height: 30px !important; 61 | } 62 | -------------------------------------------------------------------------------- /skin/frontend/base/default/inchoo_socialconnect/linkedin/css/button.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Inchoo 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/osl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@magentocommerce.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Please do not edit or add to this file if you wish to upgrade 17 | * Magento or this extension to newer versions in the future. 18 | ** Inchoo *give their best to conform to 19 | * "non-obtrusive, best Magento practices" style of coding. 20 | * However,* Inchoo *guarantee functional accuracy of 21 | * specific extension behavior. Additionally we take no responsibility 22 | * for any possible issue(s) resulting from extension usage. 23 | * We reserve the full right not to provide any kind of support for our free extensions. 24 | * Thank you for your understanding. 25 | * 26 | * @category Inchoo 27 | * @package SocialConnect 28 | * @author Marko Martinović 29 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 30 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 31 | */ 32 | 33 | div.inchoo-socialconnect-linkedin{ 34 | float: right; 35 | height: 30px !important; 36 | background: transparent url('../images/login-button-left.png') no-repeat top left !important; 37 | } 38 | 39 | div.inchoo-socialconnect-linkedin-inner{ 40 | height: 30px !important; 41 | float: left !important; 42 | margin-left: 30px !important; 43 | background: transparent url('../images/login-button-inner.png') repeat-x top left !important; 44 | padding: 0 5px !important; 45 | text-shadow: 1px 1px #1c376d; 46 | } 47 | 48 | div.inchoo-socialconnect-linkedin-right{ 49 | float: left !important; 50 | height: 30px !important; 51 | width: 3px !important; 52 | background: transparent url('../images/login-button-right.png') no-repeat top left !important; 53 | } 54 | 55 | div.inchoo-socialconnect-linkedin-inner a{ 56 | color: #FFFFFF !important; 57 | padding: 0 !important; 58 | margin: 0 !important; 59 | text-decoration: none !important; 60 | line-height: 30px !important; 61 | } 62 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Resource/Setup.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup 35 | { 36 | protected $_customerAttributes = array(); 37 | 38 | public function setCustomerAttributes($customerAttributes) 39 | { 40 | $this->_customerAttributes = $customerAttributes; 41 | 42 | return $this; 43 | } 44 | 45 | /** 46 | * Add our custom attributes 47 | * 48 | * @return Mage_Eav_Model_Entity_Setup 49 | */ 50 | public function installCustomerAttributes() 51 | { 52 | foreach ($this->_customerAttributes as $code => $attr) { 53 | $this->addAttribute('customer', $code, $attr); 54 | } 55 | 56 | return $this; 57 | } 58 | 59 | /** 60 | * Remove custom attributes 61 | * 62 | * @return Mage_Eav_Model_Entity_Setup 63 | */ 64 | public function removeCustomerAttributes() 65 | { 66 | foreach ($this->_customerAttributes as $code => $attr) { 67 | $this->removeAttribute('customer', $code); 68 | } 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/sql/inchoo_socialconnect_setup/install-0.1.0.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | $installer = $this; 35 | $installer->startSetup(); 36 | 37 | $installer->setCustomerAttributes( 38 | array( 39 | 'inchoo_socialconnect_gid' => array( 40 | 'type' => 'text', 41 | 'visible' => false, 42 | 'required' => false, 43 | 'user_defined' => false 44 | ), 45 | 'inchoo_socialconnect_gtoken' => array( 46 | 'type' => 'text', 47 | 'visible' => false, 48 | 'required' => false, 49 | 'user_defined' => false 50 | ), 51 | 'inchoo_socialconnect_fid' => array( 52 | 'type' => 'text', 53 | 'visible' => false, 54 | 'required' => false, 55 | 'user_defined' => false 56 | ), 57 | 'inchoo_socialconnect_ftoken' => array( 58 | 'type' => 'text', 59 | 'visible' => false, 60 | 'required' => false, 61 | 'user_defined' => false 62 | ) 63 | ) 64 | ); 65 | 66 | // Install our custom attributes 67 | $installer->installCustomerAttributes(); 68 | 69 | // Remove our custom attributes (for testing) 70 | //$installer->removeCustomerAttributes(); 71 | 72 | $installer->endSetup(); -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Google/Info/User.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Google_Info_User extends Inchoo_SocialConnect_Model_Google_Info 35 | { 36 | 37 | /** 38 | * 39 | * @var type Mage_Core_Model_Customer 40 | */ 41 | protected $customer = null; 42 | 43 | 44 | /** 45 | * Load customer user info 46 | * 47 | * @param null|int $id Customer Id 48 | * @return Inchoo_SocialConnect_Model_Google_Userinfo 49 | */ 50 | public function load($id = null) 51 | { 52 | if(is_null($id) && Mage::getSingleton('customer/session')->isLoggedIn()) { 53 | $this->customer = Mage::getSingleton('customer/session')->getCustomer(); 54 | } else if(is_int($id)){ 55 | $this->customer = Mage::getModel('customer/customer')->load($id); 56 | 57 | // TODO: Implement 58 | } 59 | 60 | if(!$this->customer->getId()) { 61 | return $this; 62 | } 63 | 64 | if(!($socialconnectGid = $this->customer->getInchooSocialconnectGid()) || 65 | !($socialconnectGtoken = $this->customer->getInchooSocialconnectGtoken())) { 66 | return $this; 67 | } 68 | 69 | $this->setAccessToken($socialconnectGtoken); 70 | $this->_load(); 71 | 72 | return $this; 73 | } 74 | 75 | protected function _onException($e) { 76 | parent::_onException($e); 77 | 78 | $helper = Mage::helper('inchoo_socialconnect/google'); 79 | /* @var $helper Inchoo_SocialConnect_Helper_Google */ 80 | 81 | $helper->disconnect($this->customer); 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Twitter/Info/User.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Twitter_Info_User extends Inchoo_SocialConnect_Model_Twitter_Info 35 | { 36 | 37 | /** 38 | * 39 | * @var type Mage_Core_Model_Customer 40 | */ 41 | protected $customer = null; 42 | 43 | 44 | /** 45 | * Load customer user info 46 | * 47 | * @param null|int $id Customer Id 48 | * @return Inchoo_SocialConnect_Model_Twitter_Userinfo 49 | */ 50 | public function load($id = null) 51 | { 52 | if(is_null($id) && Mage::getSingleton('customer/session')->isLoggedIn()) { 53 | $this->customer = Mage::getSingleton('customer/session')->getCustomer(); 54 | } else if(is_int($id)) { 55 | $this->customer = Mage::getModel('customer/customer')->load($id); 56 | 57 | // TODO: Implement 58 | } 59 | 60 | if(!$this->customer->getId()) { 61 | return $this; 62 | } 63 | 64 | if(!($socialconnectLid = $this->customer->getInchooSocialconnectTid()) || 65 | !($socialconnectTtoken = $this->customer->getInchooSocialconnectTtoken())) { 66 | return $this; 67 | } 68 | 69 | $this->setAccessToken($socialconnectTtoken); 70 | $this->_load(); 71 | 72 | return $this; 73 | } 74 | 75 | protected function _onException($e) { 76 | parent::_onException($e); 77 | 78 | $helper = Mage::helper('inchoo_socialconnect/twitter'); 79 | /* @var $helper Inchoo_SocialConnect_Helper_Twitter */ 80 | 81 | $helper->disconnect($this->customer); 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Linkedin/Info/User.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Linkedin_Info_User extends Inchoo_SocialConnect_Model_Linkedin_Info 35 | { 36 | 37 | /** 38 | * 39 | * @var type Mage_Core_Model_Customer 40 | */ 41 | protected $customer = null; 42 | 43 | 44 | /** 45 | * Load customer user info 46 | * 47 | * @param null|int $id Customer Id 48 | * @return Inchoo_SocialConnect_Model_Linkedin_Userinfo 49 | */ 50 | public function load($id = null) 51 | { 52 | if(is_null($id) && Mage::getSingleton('customer/session')->isLoggedIn()) { 53 | $this->customer = Mage::getSingleton('customer/session')->getCustomer(); 54 | } else if(is_int($id)){ 55 | 56 | $this->customer = Mage::getModel('customer/customer')->load($id); 57 | 58 | // TODO: Implement 59 | } 60 | 61 | if(!$this->customer->getId()) { 62 | return $this; 63 | } 64 | 65 | if(!($socialconnectLid = $this->customer->getInchooSocialconnectLid()) || 66 | !($socialconnectLtoken = $this->customer->getInchooSocialconnectLtoken())) { 67 | return $this; 68 | } 69 | 70 | $this->setAccessToken($socialconnectLtoken); 71 | $this->_load(); 72 | 73 | return $this; 74 | } 75 | 76 | protected function _onException($e) { 77 | parent::_onException($e); 78 | 79 | $helper = Mage::helper('inchoo_socialconnect/linkedin'); 80 | /* @var $helper Inchoo_SocialConnect_Helper_Linkedin */ 81 | 82 | $helper->disconnect($this->customer); 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Twitter/Button.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Twitter_Button extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Twitter_Oauth_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Twitter_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/twitter_oauth_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_twitter_userinfo'); 57 | 58 | Mage::getSingleton('customer/session') 59 | ->setSocialConnectRedirect(Mage::helper('core/url')->getCurrentUrl()); 60 | 61 | $this->setTemplate('inchoo/socialconnect/twitter/button.phtml'); 62 | } 63 | 64 | protected function _getButtonUrl() 65 | { 66 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 67 | return $this->client->createAuthUrl(); 68 | } else { 69 | return $this->getUrl('socialconnect/twitter/disconnect'); 70 | } 71 | } 72 | 73 | protected function _getButtonText() 74 | { 75 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 76 | if(!($text = Mage::registry('inchoo_socialconnect_button_text'))){ 77 | $text = $this->__('Connect'); 78 | } 79 | } else { 80 | $text = $this->__('Disconnect'); 81 | } 82 | 83 | return $text; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Facebook/Info/User.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Facebook_Info_User extends Inchoo_SocialConnect_Model_Facebook_Info 35 | { 36 | 37 | protected $params = array( 38 | 'fields' => 'id,name,first_name,last_name,link,birthday,gender,email,picture.type(large)' 39 | ); 40 | 41 | /** 42 | * 43 | * @var type Mage_Core_Model_Customer 44 | */ 45 | protected $customer = null; 46 | 47 | 48 | /** 49 | * Load customer user info 50 | * 51 | * @param null|int $id Customer Id 52 | * @return Inchoo_SocialConnect_Model_Facebook_Userinfo 53 | */ 54 | public function load($id = null) 55 | { 56 | if(is_null($id) && Mage::getSingleton('customer/session')->isLoggedIn()) { 57 | $this->customer = Mage::getSingleton('customer/session')->getCustomer(); 58 | } else if(is_int($id)){ 59 | $this->customer = Mage::getModel('customer/customer')->load($id); 60 | 61 | // TODO: Implement 62 | } 63 | 64 | if(!$this->customer->getId()) { 65 | return $this; 66 | } 67 | 68 | if(!($socialconnectFid = $this->customer->getInchooSocialconnectFid()) || 69 | !($socialconnectFtoken = $this->customer->getInchooSocialconnectFtoken())) { 70 | return $this; 71 | } 72 | 73 | $this->setAccessToken($socialconnectFtoken); 74 | $this->_load(); 75 | 76 | return $this; 77 | } 78 | 79 | protected function _onException($e) { 80 | parent::_onException($e); 81 | 82 | $helper = Mage::helper('inchoo_socialconnect/facebook'); 83 | /* @var $helper Inchoo_SocialConnect_Helper_Facebook */ 84 | 85 | $helper->disconnect($this->customer); 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Twitter/Account.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Twitter_Account extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Twitter_Oauth_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Twitter_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/twitter_oauth_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_twitter_userinfo'); 57 | 58 | $this->setTemplate('inchoo/socialconnect/twitter/account.phtml'); 59 | 60 | } 61 | 62 | protected function _hasData() 63 | { 64 | return $this->userInfo->hasData(); 65 | } 66 | 67 | 68 | protected function _getTwitterId() 69 | { 70 | return $this->userInfo->getId(); 71 | } 72 | 73 | protected function _getStatus() 74 | { 75 | return ''. 76 | $this->htmlEscape($this->userInfo->getScreenName()).''; 77 | } 78 | 79 | protected function _getPicture() 80 | { 81 | if($this->userInfo->getProfileImageUrl()) { 82 | return Mage::helper('inchoo_socialconnect/twitter') 83 | ->getProperDimensionsPictureUrl($this->userInfo->getId(), 84 | $this->userInfo->getProfileImageUrl()); 85 | } 86 | 87 | return null; 88 | } 89 | 90 | protected function _getName() 91 | { 92 | return $this->userInfo->getName(); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Google/Button.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Google_Button extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Google_Oauth2_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Google_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_google_userinfo'); 57 | 58 | // CSRF protection 59 | Mage::getSingleton('core/session')->setGoogleCsrf($csrf = md5(uniqid(rand(), true))); 60 | $this->client->setState($csrf); 61 | 62 | Mage::getSingleton('customer/session') 63 | ->setSocialConnectRedirect(Mage::helper('core/url')->getCurrentUrl()); 64 | 65 | $this->setTemplate('inchoo/socialconnect/google/button.phtml'); 66 | } 67 | 68 | protected function _getButtonUrl() 69 | { 70 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 71 | return $this->client->createAuthUrl(); 72 | } else { 73 | return $this->getUrl('socialconnect/google/disconnect'); 74 | } 75 | } 76 | 77 | protected function _getButtonText() 78 | { 79 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 80 | if(!($text = Mage::registry('inchoo_socialconnect_button_text'))){ 81 | $text = $this->__('Connect'); 82 | } 83 | } else { 84 | $text = $this->__('Disconnect'); 85 | } 86 | 87 | return $text; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Facebook/Button.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Facebook_Button extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Facebook_Oauth2_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Facebook_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_facebook_userinfo'); 57 | 58 | // CSRF protection 59 | Mage::getSingleton('core/session')->setFacebookCsrf($csrf = md5(uniqid(rand(), true))); 60 | $this->client->setState($csrf); 61 | 62 | Mage::getSingleton('customer/session') 63 | ->setSocialConnectRedirect(Mage::helper('core/url')->getCurrentUrl()); 64 | 65 | $this->setTemplate('inchoo/socialconnect/facebook/button.phtml'); 66 | } 67 | 68 | protected function _getButtonUrl() 69 | { 70 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 71 | return $this->client->createAuthUrl(); 72 | } else { 73 | return $this->getUrl('socialconnect/facebook/disconnect'); 74 | } 75 | } 76 | 77 | protected function _getButtonText() 78 | { 79 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 80 | if(!($text = Mage::registry('inchoo_socialconnect_button_text'))){ 81 | $text = $this->__('Connect'); 82 | } 83 | } else { 84 | $text = $this->__('Disconnect'); 85 | } 86 | 87 | return $text; 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Linkedin/Button.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Linkedin_Button extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Linkedin_Oauth2_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Linkedin_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/linkedin_oauth2_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_linkedin_userinfo'); 57 | 58 | // CSRF protection 59 | Mage::getSingleton('core/session')->setLinkedinCsrf($csrf = md5(uniqid(rand(), true))); 60 | $this->client->setState($csrf); 61 | 62 | Mage::getSingleton('customer/session') 63 | ->setSocialConnectRedirect(Mage::helper('core/url')->getCurrentUrl()); 64 | 65 | $this->setTemplate('inchoo/socialconnect/linkedin/button.phtml'); 66 | } 67 | 68 | protected function _getButtonUrl() 69 | { 70 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 71 | return $this->client->createAuthUrl(); 72 | } else { 73 | return $this->getUrl('socialconnect/linkedin/disconnect'); 74 | } 75 | } 76 | 77 | protected function _getButtonText() 78 | { 79 | if(is_null($this->userInfo) || !$this->userInfo->hasData()) { 80 | if(!($text = Mage::registry('inchoo_socialconnect_button_text'))){ 81 | $text = $this->__('Connect'); 82 | } 83 | } else { 84 | $text = $this->__('Disconnect'); 85 | } 86 | 87 | return $text; 88 | } 89 | 90 | } -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/checkout.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 |
35 |
36 | _googleEnabled()): ?> 37 |
38 |

__('Google Connect') ?>

39 |

__('You can continue with checkout using your Google account.') ?>

40 | getChildHtml('inchoo_socialconnect_checkout_google_button')?> 41 |
42 | 43 | _facebookEnabled()): ?> 44 |
45 |

__('Facebook Connect') ?>

46 |

__('You can continue with checkout using your Facebook account.') ?>

47 | getChildHtml('inchoo_socialconnect_checkout_facebook_button')?> 48 |
49 | 50 | _twitterEnabled()): ?> 51 |
52 |

__('Twitter Connect') ?>

53 |

__('You can continue with checkout using your Twitter account.') ?>

54 | getChildHtml('inchoo_socialconnect_checkout_twitter_button')?> 55 |
56 | 57 | _linkedinEnabled()): ?> 58 |
59 |

__('LinkedIn Connect') ?>

60 |

__('You can continue with checkout using your Linkedin account.') ?>

61 | getChildHtml('inchoo_socialconnect_checkout_linkedin_button')?> 62 |
63 | 64 |
65 |
66 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Controller/Abstract.php: -------------------------------------------------------------------------------- 1 | _connectCallback(); 10 | } catch (Exception $e) { 11 | Mage::getSingleton('core/session')->addError($e->getMessage()); 12 | } 13 | 14 | $this->_loginPostRedirect(); 15 | } 16 | 17 | public function disconnectAction() 18 | { 19 | $customer = Mage::getSingleton('customer/session')->getCustomer(); 20 | 21 | try { 22 | $this->_disconnectCallback($customer); 23 | } catch (Exception $e) { 24 | Mage::getSingleton('core/session')->addError($e->getMessage()); 25 | } 26 | 27 | $this->_loginPostRedirect(); 28 | } 29 | 30 | /** 31 | * Define target URL and redirect customer after logging in 32 | */ 33 | protected function _loginPostRedirect() 34 | { 35 | $session = $this->_getCustomerSession(); 36 | 37 | if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) { 38 | // Set default URL to redirect customer to 39 | $session->setBeforeAuthUrl($this->_getCustomerSession()->getSocialConnectRedirect()); 40 | // Redirect customer to the last page visited after logging in 41 | if ($session->isLoggedIn()) { 42 | if (!Mage::getStoreConfigFlag( 43 | Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD 44 | )) { 45 | $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME); 46 | if ($referer) { 47 | // Rebuild referer URL to handle the case when SID was changed 48 | $referer = $this->_getModel('core/url') 49 | ->getRebuiltUrl( $this->_getHelper('core')->urlDecode($referer)); 50 | if ($this->_isUrlInternal($referer)) { 51 | $session->setBeforeAuthUrl($referer); 52 | } 53 | } 54 | } else if ($session->getAfterAuthUrl()) { 55 | $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); 56 | } 57 | } else { 58 | $session->setBeforeAuthUrl( $this->_getHelper('customer')->getLoginUrl()); 59 | } 60 | } else if ($session->getBeforeAuthUrl() == $this->_getHelper('customer')->getLogoutUrl()) { 61 | $session->setBeforeAuthUrl( $this->_getHelper('customer')->getDashboardUrl()); 62 | } else { 63 | if (!$session->getAfterAuthUrl()) { 64 | $session->setAfterAuthUrl($session->getBeforeAuthUrl()); 65 | } 66 | if ($session->isLoggedIn()) { 67 | $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); 68 | } 69 | } 70 | $this->_redirectUrl($session->getBeforeAuthUrl(true)); 71 | } 72 | 73 | /** 74 | * Retrieve customer session model object 75 | * 76 | * @return Mage_Customer_Model_Session 77 | */ 78 | protected function _getCustomerSession() 79 | { 80 | return Mage::getSingleton('customer/session'); 81 | } 82 | 83 | /** 84 | * Get Helper 85 | * 86 | * @param string $path 87 | * @return Mage_Core_Helper_Abstract 88 | */ 89 | protected function _getHelper($path) 90 | { 91 | return Mage::helper($path); 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/twitter/account.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/register.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 |
35 |
36 | _googleEnabled()): ?> 37 |
38 |
39 |

__('Google Connect') ?>

40 |

__('You can register using your Google account.') ?>

41 |

getChildHtml('inchoo_socialconnect_checkout_google_button')?>

42 |
43 |
44 | 45 | _facebookEnabled()): ?> 46 |
47 |
48 |

__('Facebook Connect') ?>

49 |

__('You can register using your Facebook account.') ?>

50 |

getChildHtml('inchoo_socialconnect_checkout_facebook_button')?>

51 |
52 |
53 | 54 | _twitterEnabled()): ?> 55 |
56 |
57 |

__('Twitter Connect') ?>

58 |

__('You can register using your Twitter account.') ?>

59 |

getChildHtml('inchoo_socialconnect_checkout_twitter_button')?>

60 |
61 |
62 | 63 | _linkedinEnabled()): ?> 64 |
65 |
66 |

__('LinkedIn Connect') ?>

67 |

__('You can register using your LinkedIn account.') ?>

68 |

getChildHtml('inchoo_socialconnect_checkout_linkedin_button')?>

69 |
70 |
71 | 72 |
73 |
-------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Checkout.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Checkout extends Mage_Core_Block_Template 35 | { 36 | protected $clientGoogle = null; 37 | protected $clientFacebook = null; 38 | protected $clientTwitter = null; 39 | protected $clientLinkedin = null; 40 | 41 | protected $numEnabled = 0; 42 | protected $numShown = 0; 43 | 44 | protected function _construct() { 45 | parent::_construct(); 46 | 47 | $this->clientGoogle = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 48 | $this->clientFacebook = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 49 | $this->clientTwitter = Mage::getSingleton('inchoo_socialconnect/twitter_oauth_client'); 50 | $this->clientLinkedin = Mage::getSingleton('inchoo_socialconnect/linkedin_oauth2_client'); 51 | 52 | if( !$this->_googleEnabled() && 53 | !$this->_facebookEnabled() && 54 | !$this->_twitterEnabled() && 55 | !$this->_linkedinEnabled()) { 56 | return; 57 | } 58 | 59 | if($this->_googleEnabled()) { 60 | $this->numEnabled++; 61 | } 62 | 63 | if($this->_facebookEnabled()) { 64 | $this->numEnabled++; 65 | } 66 | 67 | if($this->_twitterEnabled()) { 68 | $this->numEnabled++; 69 | } 70 | 71 | if($this->_linkedinEnabled()) { 72 | $this->numEnabled++; 73 | } 74 | 75 | Mage::register('inchoo_socialconnect_button_text', $this->__('Continue')); 76 | 77 | $this->setTemplate('inchoo/socialconnect/checkout.phtml'); 78 | } 79 | 80 | protected function _getColSet() 81 | { 82 | return 'col'.$this->numEnabled.'-set'; 83 | } 84 | 85 | protected function _getCol() 86 | { 87 | return 'col-'.++$this->numShown; 88 | } 89 | 90 | protected function _googleEnabled() 91 | { 92 | return $this->clientGoogle->isEnabled(); 93 | } 94 | 95 | protected function _facebookEnabled() 96 | { 97 | return $this->clientFacebook->isEnabled(); 98 | } 99 | 100 | protected function _twitterEnabled() 101 | { 102 | return $this->clientTwitter->isEnabled(); 103 | } 104 | 105 | protected function _linkedinEnabled() 106 | { 107 | return $this->clientLinkedin->isEnabled(); 108 | } 109 | 110 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Register.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Register extends Mage_Core_Block_Template 35 | { 36 | protected $clientGoogle = null; 37 | protected $clientFacebook = null; 38 | protected $clientTwitter = null; 39 | protected $clientLinkedin = null; 40 | 41 | protected $numEnabled = 0; 42 | protected $numShown = 0; 43 | 44 | protected function _construct() { 45 | parent::_construct(); 46 | 47 | $this->clientGoogle = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 48 | $this->clientFacebook = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 49 | $this->clientTwitter = Mage::getSingleton('inchoo_socialconnect/twitter_oauth_client'); 50 | $this->clientLinkedin = Mage::getSingleton('inchoo_socialconnect/linkedin_oauth2_client'); 51 | 52 | if( !$this->_googleEnabled() && 53 | !$this->_facebookEnabled() && 54 | !$this->_twitterEnabled() && 55 | !$this->_linkedinEnabled()) { 56 | return; 57 | } 58 | 59 | if($this->_googleEnabled()) { 60 | $this->numEnabled++; 61 | } 62 | 63 | if($this->_facebookEnabled()) { 64 | $this->numEnabled++; 65 | } 66 | 67 | if($this->_twitterEnabled()) { 68 | $this->numEnabled++; 69 | } 70 | 71 | if($this->_linkedinEnabled()) { 72 | $this->numEnabled++; 73 | } 74 | 75 | Mage::register('inchoo_socialconnect_button_text', $this->__('Register')); 76 | 77 | $this->setTemplate('inchoo/socialconnect/register.phtml'); 78 | } 79 | 80 | protected function _getColSet() 81 | { 82 | return 'col'.$this->numEnabled.'-set'; 83 | } 84 | 85 | protected function _getCol() 86 | { 87 | return 'col-'.++$this->numShown; 88 | } 89 | 90 | protected function _googleEnabled() 91 | { 92 | return (bool) $this->clientGoogle->isEnabled(); 93 | } 94 | 95 | protected function _facebookEnabled() 96 | { 97 | return (bool) $this->clientFacebook->isEnabled(); 98 | } 99 | 100 | protected function _twitterEnabled() 101 | { 102 | return (bool) $this->clientTwitter->isEnabled(); 103 | } 104 | 105 | protected function _linkedinEnabled() 106 | { 107 | return $this->clientLinkedin->isEnabled(); 108 | } 109 | 110 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Google/Info.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Google_Info extends Varien_Object 35 | { 36 | protected $params = array(); 37 | 38 | /** 39 | * Google client model 40 | * 41 | * @var Inchoo_SocialConnect_Model_Google_Oauth2_Client 42 | */ 43 | protected $client = null; 44 | 45 | public function _construct() { 46 | parent::_construct(); 47 | 48 | $this->client = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 49 | if(!($this->client->isEnabled())) { 50 | return $this; 51 | } 52 | } 53 | 54 | /** 55 | * Get Google client model 56 | * 57 | * @return Inchoo_SocialConnect_Model_Google_Oauth2_Client 58 | */ 59 | public function getClient() 60 | { 61 | return $this->client; 62 | } 63 | 64 | public function setClient(Inchoo_SocialConnect_Model_Google_Oauth2_Client $client) 65 | { 66 | $this->client = $client; 67 | } 68 | 69 | public function setAccessToken($token) 70 | { 71 | $this->client->setAccessToken($token); 72 | } 73 | 74 | /** 75 | * Get Google client's access token 76 | * 77 | * @return stdClass 78 | */ 79 | public function getAccessToken() 80 | { 81 | return $this->client->getAccessToken(); 82 | } 83 | 84 | public function load($id = null) 85 | { 86 | $this->_load(); 87 | 88 | return $this; 89 | } 90 | 91 | protected function _load() 92 | { 93 | try{ 94 | $response = $this->client->api( 95 | '/userinfo', 96 | 'GET', 97 | $this->params 98 | ); 99 | 100 | foreach ($response as $key => $value) { 101 | $this->{$key} = $value; 102 | } 103 | 104 | } catch(Inchoo_SocialConnect_Google_OAuth2_Exception $e) { 105 | $this->_onException($e); 106 | } catch(Exception $e) { 107 | $this->_onException($e); 108 | } 109 | } 110 | 111 | protected function _onException($e) 112 | { 113 | if($e instanceof Inchoo_SocialConnect_Google_OAuth2_Exception) { 114 | Mage::getSingleton('core/session')->addNotice($e->getMessage()); 115 | } else { 116 | Mage::getSingleton('core/session')->addError($e->getMessage()); 117 | } 118 | } 119 | 120 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Facebook/Info.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Facebook_Info extends Varien_Object 35 | { 36 | protected $params = array(); 37 | 38 | /** 39 | * Facebook client model 40 | * 41 | * @var Inchoo_SocialConnect_Model_Facebook_Oauth2_Client 42 | */ 43 | protected $client = null; 44 | 45 | public function _construct() { 46 | parent::_construct(); 47 | 48 | $this->client = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 49 | if(!($this->client->isEnabled())) { 50 | return $this; 51 | } 52 | } 53 | 54 | /** 55 | * Get Facebook client model 56 | * 57 | * @return Inchoo_SocialConnect_Model_Facebook_Oauth2_Client 58 | */ 59 | public function getClient() 60 | { 61 | return $this->client; 62 | } 63 | 64 | public function setClient(Inchoo_SocialConnect_Model_Facebook_Oauth2_Client $client) 65 | { 66 | $this->client = $client; 67 | } 68 | 69 | public function setAccessToken($token) 70 | { 71 | $this->client->setAccessToken($token); 72 | } 73 | 74 | /** 75 | * Get Facebook client's access token 76 | * 77 | * @return stdClass 78 | */ 79 | public function getAccessToken() 80 | { 81 | return $this->client->getAccessToken(); 82 | } 83 | 84 | public function load($id = null) 85 | { 86 | $this->_load(); 87 | 88 | return $this; 89 | } 90 | 91 | protected function _load() 92 | { 93 | try{ 94 | $response = $this->client->api( 95 | '/me', 96 | 'GET', 97 | $this->params 98 | ); 99 | 100 | foreach ($response as $key => $value) { 101 | $this->{$key} = $value; 102 | } 103 | 104 | } catch(Inchoo_SocialConnect_Facebook_OAuth2_Exception $e) { 105 | $this->_onException($e); 106 | } catch(Exception $e) { 107 | $this->_onException($e); 108 | } 109 | } 110 | 111 | protected function _onException($e) 112 | { 113 | if($e instanceof Inchoo_SocialConnect_Facebook_OAuth2_Exception) { 114 | Mage::getSingleton('core/session')->addNotice($e->getMessage()); 115 | } else { 116 | Mage::getSingleton('core/session')->addError($e->getMessage()); 117 | } 118 | } 119 | 120 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Login.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Login extends Mage_Core_Block_Template 35 | { 36 | protected $clientGoogle = null; 37 | protected $clientFacebook = null; 38 | protected $clientTwitter = null; 39 | protected $clientLinkedin = null; 40 | 41 | protected $numEnabled = 0; 42 | protected $numDescShown = 0; 43 | protected $numButtShown = 0; 44 | 45 | protected function _construct() { 46 | parent::_construct(); 47 | 48 | $this->clientGoogle = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 49 | $this->clientFacebook = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 50 | $this->clientTwitter = Mage::getSingleton('inchoo_socialconnect/twitter_oauth_client'); 51 | $this->clientLinkedin = Mage::getSingleton('inchoo_socialconnect/linkedin_oauth2_client'); 52 | 53 | if( !$this->_googleEnabled() && 54 | !$this->_facebookEnabled() && 55 | !$this->_twitterEnabled() && 56 | !$this->_linkedinEnabled()) { 57 | return; 58 | } 59 | 60 | if($this->_googleEnabled()) { 61 | $this->numEnabled++; 62 | } 63 | 64 | if($this->_facebookEnabled()) { 65 | $this->numEnabled++; 66 | } 67 | 68 | if($this->_twitterEnabled()) { 69 | $this->numEnabled++; 70 | } 71 | 72 | if($this->_linkedinEnabled()) { 73 | $this->numEnabled++; 74 | } 75 | 76 | Mage::register('inchoo_socialconnect_button_text', $this->__('Login')); 77 | 78 | $this->setTemplate('inchoo/socialconnect/login.phtml'); 79 | } 80 | 81 | protected function _getColSet() 82 | { 83 | return 'col'.$this->numEnabled.'-set'; 84 | } 85 | 86 | protected function _getDescCol() 87 | { 88 | return 'col-'.++$this->numDescShown; 89 | } 90 | 91 | protected function _getButtCol() 92 | { 93 | return 'col-'.++$this->numButtShown; 94 | } 95 | 96 | protected function _googleEnabled() 97 | { 98 | return $this->clientGoogle->isEnabled(); 99 | } 100 | 101 | protected function _facebookEnabled() 102 | { 103 | return $this->clientFacebook->isEnabled(); 104 | } 105 | 106 | protected function _twitterEnabled() 107 | { 108 | return $this->clientTwitter->isEnabled(); 109 | } 110 | 111 | protected function _linkedinEnabled() 112 | { 113 | return $this->clientLinkedin->isEnabled(); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/controllers/AccountController.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_AccountController extends Mage_Core_Controller_Front_Action 35 | { 36 | 37 | public function preDispatch() 38 | { 39 | parent::preDispatch(); 40 | 41 | if (!$this->getRequest()->isDispatched()) { 42 | return $this; 43 | } 44 | 45 | /* 46 | * Avoid situations where before_auth_url redirects when doing connect 47 | * and disconnect from account dashboard. Authenticate. 48 | */ 49 | if (!Mage::getSingleton('customer/session') 50 | ->unsBeforeAuthUrl() 51 | ->unsAfterAuthUrl() 52 | ->authenticate($this)) { 53 | $this->setFlag('', 'no-dispatch', true); 54 | } 55 | 56 | } 57 | 58 | public function googleAction() 59 | { 60 | $userInfo = Mage::getSingleton('inchoo_socialconnect/google_info_user') 61 | ->load(); 62 | 63 | Mage::register('inchoo_socialconnect_google_userinfo', $userInfo); 64 | 65 | $this->loadLayout(); 66 | $this->renderLayout(); 67 | } 68 | 69 | public function facebookAction() 70 | { 71 | $userInfo = Mage::getSingleton('inchoo_socialconnect/facebook_info_user') 72 | ->load(); 73 | 74 | Mage::register('inchoo_socialconnect_facebook_userinfo', $userInfo); 75 | 76 | $this->loadLayout(); 77 | $this->renderLayout(); 78 | } 79 | 80 | public function twitterAction() 81 | { 82 | // Cache user info inside customer session due to Twitter window frame rate limits 83 | if(!($userInfo = Mage::getSingleton('customer/session') 84 | ->getInchooSocialconnectTwitterUserinfo()) || !$userInfo->hasData()) { 85 | 86 | $userInfo = Mage::getSingleton('inchoo_socialconnect/twitter_info_user') 87 | ->load(); 88 | 89 | Mage::getSingleton('customer/session') 90 | ->setInchooSocialconnectTwitterUserinfo($userInfo); 91 | } 92 | 93 | Mage::register('inchoo_socialconnect_twitter_userinfo', $userInfo); 94 | 95 | $this->loadLayout(); 96 | $this->renderLayout(); 97 | } 98 | 99 | public function linkedinAction() 100 | { 101 | $userInfo = Mage::getSingleton('inchoo_socialconnect/linkedin_info_user') 102 | ->load(); 103 | 104 | Mage::register('inchoo_socialconnect_linkedin_userinfo', $userInfo); 105 | 106 | $this->loadLayout(); 107 | $this->renderLayout(); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Facebook/Account.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Facebook_Account extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Facebook_Oauth2_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Facebook_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_facebook_userinfo'); 57 | 58 | $this->setTemplate('inchoo/socialconnect/facebook/account.phtml'); 59 | } 60 | 61 | protected function _hasData() 62 | { 63 | return $this->userInfo->hasData(); 64 | } 65 | 66 | protected function _getFacebookId() 67 | { 68 | return $this->userInfo->getId(); 69 | } 70 | 71 | protected function _getStatus() 72 | { 73 | if($this->userInfo->getLink()) { 74 | $link = ''. 75 | $this->htmlEscape($this->userInfo->getName()).''; 76 | } else { 77 | $link = $this->userInfo->getName(); 78 | } 79 | 80 | return $link; 81 | } 82 | 83 | protected function _getEmail() 84 | { 85 | return $this->userInfo->getEmail(); 86 | } 87 | 88 | protected function _getPicture() 89 | { 90 | if($this->userInfo->getPicture()) { 91 | return Mage::helper('inchoo_socialconnect/facebook') 92 | ->getProperDimensionsPictureUrl($this->userInfo->getId(), 93 | $this->userInfo->getPicture()->data->url); 94 | } 95 | 96 | return null; 97 | } 98 | 99 | protected function _getName() 100 | { 101 | return $this->userInfo->getName(); 102 | } 103 | 104 | protected function _getGender() 105 | { 106 | if($this->userInfo->getGender()) { 107 | return ucfirst($this->userInfo->getGender()); 108 | } 109 | 110 | return null; 111 | } 112 | 113 | protected function _getBirthday() 114 | { 115 | if($this->userInfo->getBirthday()) { 116 | $birthday = date('F j, Y', strtotime($this->userInfo->getBirthday())); 117 | return $birthday; 118 | } 119 | 120 | return null; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Twitter/Info.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Twitter_Info extends Varien_Object 35 | { 36 | protected $params = array( 37 | 'skip_status' => true 38 | ); 39 | 40 | /** 41 | * Twitter client model 42 | * 43 | * @var Inchoo_SocialConnect_Model_Twitter_Oauth_Client 44 | */ 45 | protected $client = null; 46 | 47 | public function _construct() { 48 | parent::_construct(); 49 | 50 | $this->client = Mage::getSingleton('inchoo_socialconnect/twitter_oauth_client'); 51 | if(!($this->client->isEnabled())) { 52 | return $this; 53 | } 54 | } 55 | 56 | /** 57 | * Get Twitter client model 58 | * 59 | * @return Inchoo_SocialConnect_Model_Twitter_Oauth_Client 60 | */ 61 | public function getClient() 62 | { 63 | return $this->client; 64 | } 65 | 66 | public function setClient(Inchoo_SocialConnect_Model_Twitter_Oauth_Client $client) 67 | { 68 | $this->client = $client; 69 | } 70 | 71 | public function setAccessToken($token) 72 | { 73 | $this->client->setAccessToken($token); 74 | } 75 | 76 | /** 77 | * Get Twitter client's access token 78 | * 79 | * @return stdClass 80 | */ 81 | public function getAccessToken() 82 | { 83 | return $this->client->getAccessToken(); 84 | } 85 | 86 | public function load($id = null) 87 | { 88 | $this->_load(); 89 | 90 | // Twitter doesn't allow email access trough API 91 | $this->setEmail(sprintf('%s@twitter-user.com', strtolower($this->getScreenName()))); 92 | 93 | return $this; 94 | } 95 | 96 | protected function _load() 97 | { 98 | try{ 99 | $this->client->getAccessToken(); 100 | 101 | $response = $this->client->api( 102 | '/account/verify_credentials.json', 103 | 'GET', 104 | $this->params 105 | ); 106 | 107 | foreach ($response as $key => $value) { 108 | $this->{$key} = $value; 109 | } 110 | 111 | } catch(Inchoo_SocialConnect_Twitter_Oauth_Exception $e) { 112 | $this->_onException($e); 113 | } catch(Exception $e) { 114 | $this->_onException($e); 115 | } 116 | } 117 | 118 | protected function _onException($e) 119 | { 120 | if($e instanceof Inchoo_SocialConnect_Twitter_Oauth_Exception) { 121 | Mage::getSingleton('core/session')->addNotice($e->getMessage()); 122 | } else { 123 | Mage::getSingleton('core/session')->addError($e->getMessage()); 124 | } 125 | } 126 | 127 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Linkedin/Account.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Linkedin_Account extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Linkedin_Oauth2_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Linkedin_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/linkedin_oauth2_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_linkedin_userinfo'); 57 | 58 | $this->setTemplate('inchoo/socialconnect/linkedin/account.phtml'); 59 | } 60 | 61 | protected function _hasData() 62 | { 63 | return $this->userInfo->hasData(); 64 | } 65 | 66 | protected function _getLinkedinId() 67 | { 68 | return $this->userInfo->getId(); 69 | } 70 | 71 | protected function _getStatus() 72 | { 73 | $siteStandardProfileRequest = $this->userInfo->getSiteStandardProfileRequest(); 74 | if($siteStandardProfileRequest && !empty($siteStandardProfileRequest->url)) { 75 | $link = ''. 76 | $this->htmlEscape($this->_getName()).''; 77 | } else { 78 | $link = $this->_getName(); 79 | } 80 | 81 | return $link; 82 | } 83 | 84 | protected function _getPublicProfileUrl() 85 | { 86 | if($this->userInfo->getPublicProfileUrl()) { 87 | $link = ''. 88 | $this->htmlEscape($this->userInfo->getPublicProfileUrl()).''; 89 | 90 | return $link; 91 | } 92 | 93 | return null; 94 | } 95 | 96 | protected function _getEmail() 97 | { 98 | return $this->userInfo->getEmailAddress(); 99 | } 100 | 101 | protected function _getPicture() 102 | { 103 | if($this->userInfo->getPictureUrl()) { 104 | return Mage::helper('inchoo_socialconnect/linkedin') 105 | ->getProperDimensionsPictureUrl($this->userInfo->getId(), 106 | $this->userInfo->getPictureUrl()); 107 | } 108 | 109 | return null; 110 | } 111 | 112 | protected function _getName() 113 | { 114 | return sprintf( 115 | '%s %s', 116 | $this->userInfo->getFirstName(), 117 | $this->userInfo->getLastName() 118 | ); 119 | } 120 | 121 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Model/Linkedin/Info.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Model_Linkedin_Info extends Varien_Object 35 | { 36 | protected $params = array( 37 | '~' => '' 38 | ); 39 | 40 | protected $fields = array( 41 | 'id', 42 | 'first-name', 43 | 'last-name', 44 | 'email-address', 45 | 'picture-url', 46 | 'public-profile-url', 47 | 'site-standard-profile-request' 48 | ); 49 | 50 | /** 51 | * LinkedIn client model 52 | * 53 | * @var Inchoo_SocialConnect_Model_Linkedin_Oauth2_Client 54 | */ 55 | protected $client = null; 56 | 57 | public function _construct() { 58 | parent::_construct(); 59 | 60 | $this->client = Mage::getSingleton('inchoo_socialconnect/linkedin_oauth2_client'); 61 | if(!($this->client->isEnabled())) { 62 | return $this; 63 | } 64 | } 65 | 66 | /** 67 | * Get LinkedIn client model 68 | * 69 | * @return Inchoo_SocialConnect_Model_Linkedin_Oauth2_Client 70 | */ 71 | public function getClient() 72 | { 73 | return $this->client; 74 | } 75 | 76 | public function setClient(Inchoo_SocialConnect_Model_Linkedin_Oauth2_Client $client) 77 | { 78 | $this->client = $client; 79 | } 80 | 81 | public function setAccessToken($token) 82 | { 83 | $this->client->setAccessToken($token); 84 | } 85 | 86 | /** 87 | * Get LinkedIn client's access token 88 | * 89 | * @return stdClass 90 | */ 91 | public function getAccessToken() 92 | { 93 | return $this->client->getAccessToken(); 94 | } 95 | 96 | public function load($id = null) 97 | { 98 | $this->_load(); 99 | 100 | return $this; 101 | } 102 | 103 | protected function _load() 104 | { 105 | try{ 106 | $response = $this->client->api( 107 | '/people', 108 | 'GET', 109 | $this->params, 110 | $this->fields 111 | ); 112 | 113 | foreach ($response as $key => $value) { 114 | $this->{$key} = $value; 115 | } 116 | 117 | } catch(Inchoo_SocialConnect_Linkedin_Oauth2_Exception $e) { 118 | $this->_onException($e); 119 | } catch(Exception $e) { 120 | $this->_onException($e); 121 | } 122 | } 123 | 124 | protected function _onException($e) 125 | { 126 | if($e instanceof Inchoo_SocialConnect_Linkedin_Oauth2_Exception) { 127 | Mage::getSingleton('core/session')->addNotice($e->getMessage()); 128 | } else { 129 | Mage::getSingleton('core/session')->addError($e->getMessage()); 130 | } 131 | } 132 | 133 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | 37 | 38 | 39 | 40 | 0.3.5 41 | 42 | 43 | 44 | 45 | 46 | 0 47 | 48 | 49 | 0 50 | 51 | 52 | 0 53 | 54 | 55 | 0 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Inchoo_SocialConnect.csv 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | inchoo_socialconnect.xml 73 | 74 | 75 | 76 | 77 | 78 | standard 79 | 80 | Inchoo_SocialConnect 81 | socialconnect 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Inchoo_SocialConnect_Model 90 | 91 | 92 | 93 | 94 | Inchoo_SocialConnect_Block 95 | 96 | 97 | 98 | 99 | Inchoo_SocialConnect_Helper 100 | 101 | 102 | 103 | 104 | 105 | Inchoo_SocialConnect 106 | Inchoo_SocialConnect_Model_Resource_Setup 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Block/Google/Account.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Block_Google_Account extends Mage_Core_Block_Template 35 | { 36 | /** 37 | * 38 | * @var Inchoo_SocialConnect_Model_Google_Oauth2_Client 39 | */ 40 | protected $client = null; 41 | 42 | /** 43 | * 44 | * @var Inchoo_SocialConnect_Model_Google_Info_User 45 | */ 46 | protected $userInfo = null; 47 | 48 | protected function _construct() { 49 | parent::_construct(); 50 | 51 | $this->client = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 52 | if(!($this->client->isEnabled())) { 53 | return; 54 | } 55 | 56 | $this->userInfo = Mage::registry('inchoo_socialconnect_google_userinfo'); 57 | 58 | $this->setTemplate('inchoo/socialconnect/google/account.phtml'); 59 | 60 | } 61 | 62 | protected function _hasData() 63 | { 64 | return $this->userInfo->hasData(); 65 | } 66 | 67 | protected function _getGoogleId() 68 | { 69 | return $this->userInfo->getId(); 70 | } 71 | 72 | protected function _getStatus() 73 | { 74 | if($this->userInfo->getLink()) { 75 | $link = ''. 76 | $this->htmlEscape($this->userInfo->getName()).''; 77 | } else { 78 | $link = $this->userInfo->getName(); 79 | } 80 | 81 | return $link; 82 | } 83 | 84 | protected function _getEmail() 85 | { 86 | return $this->userInfo->getEmail(); 87 | } 88 | 89 | protected function _getPicture() 90 | { 91 | if($this->userInfo->getPicture()) { 92 | return Mage::helper('inchoo_socialconnect/google') 93 | ->getProperDimensionsPictureUrl($this->userInfo->getId(), 94 | $this->userInfo->getPicture()); 95 | } 96 | 97 | return null; 98 | } 99 | 100 | protected function _getName() 101 | { 102 | return $this->userInfo->getName(); 103 | } 104 | 105 | protected function _getGender() 106 | { 107 | if($this->userInfo->getGender()) { 108 | return ucfirst($this->userInfo->getGender()); 109 | } 110 | 111 | return null; 112 | } 113 | 114 | protected function _getBirthday() 115 | { 116 | if($this->userInfo->getBirthday()) { 117 | if((strpos($this->userInfo->getBirthday(), '0000')) === false) { 118 | $birthday = date('F j, Y', strtotime($this->userInfo->getBirthday())); 119 | } else { 120 | $birthday = date( 121 | 'F j', 122 | strtotime( 123 | str_replace('0000', '1970', $this->userInfo->getBirthday()) 124 | ) 125 | ); 126 | } 127 | 128 | return $birthday; 129 | } 130 | 131 | return null; 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/google/account.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/facebook/account.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 | 109 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/linkedin/account.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/login.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 | 102 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/controllers/TwitterController.php: -------------------------------------------------------------------------------- 1 | isEnabled())) { 10 | $this->norouteAction(); 11 | } 12 | 13 | try { 14 | $client->fetchRequestToken(); 15 | } catch (Exception $e) { 16 | $referer = Mage::getSingleton('core/session') 17 | ->getSocialConnectRedirect(); 18 | 19 | Mage::getSingleton('core/session')->addError($e->getMessage()); 20 | Mage::logException($e); 21 | 22 | $this->_sessionCleanup(); 23 | 24 | if(!empty($referer)) { 25 | $this->_redirectUrl($referer); 26 | } else { 27 | $this->norouteAction(); 28 | } 29 | } 30 | } 31 | 32 | protected function _disconnectCallback(Mage_Customer_Model_Customer $customer) { 33 | Mage::helper('inchoo_socialconnect/twitter')->disconnect($customer); 34 | 35 | Mage::getSingleton('core/session') 36 | ->addSuccess( 37 | $this->__('You have successfully disconnected your Twitter account from our store account.') 38 | ); 39 | } 40 | 41 | protected function _connectCallback() { 42 | if (!($params = $this->getRequest()->getParams()) 43 | || 44 | !($requestToken = unserialize(Mage::getSingleton('core/session') 45 | ->getTwitterRequestToken())) 46 | ) { 47 | // Direct route access - deny 48 | return $this; 49 | } 50 | 51 | if(isset($params['denied'])) { 52 | Mage::getSingleton('core/session') 53 | ->addNotice( 54 | $this->__('Twitter Connect process aborted.') 55 | ); 56 | 57 | return $this; 58 | } 59 | 60 | $info = Mage::getModel('inchoo_socialconnect/twitter_info')->load(); 61 | 62 | $token = $info->getClient()->getAccessToken(); 63 | 64 | $customersByTwitterId = Mage::helper('inchoo_socialconnect/twitter') 65 | ->getCustomersByTwitterId($info->getId()); 66 | 67 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 68 | // Logged in user 69 | if($customersByTwitterId->getSize()) { 70 | // Twitter account already connected to other account - deny 71 | Mage::getSingleton('core/session') 72 | ->addNotice( 73 | $this->__('Your Twitter account is already connected to one of our store accounts.') 74 | ); 75 | 76 | return $this; 77 | } 78 | 79 | // Connect from account dashboard - attach 80 | $customer = Mage::getSingleton('customer/session')->getCustomer(); 81 | 82 | Mage::helper('inchoo_socialconnect/twitter')->connectByTwitterId( 83 | $customer, 84 | $info->getId(), 85 | $token 86 | ); 87 | 88 | Mage::getSingleton('core/session')->addSuccess( 89 | $this->__('Your Twitter account is now connected to your store account. You can now login using our Twitter Login button or using store account credentials you will receive to your email address.') 90 | ); 91 | 92 | return $this; 93 | } 94 | 95 | if($customersByTwitterId->getSize()) { 96 | // Existing connected user - login 97 | $customer = $customersByTwitterId->getFirstItem(); 98 | 99 | Mage::helper('inchoo_socialconnect/twitter')->loginByCustomer($customer); 100 | 101 | Mage::getSingleton('core/session') 102 | ->addSuccess( 103 | $this->__('You have successfully logged in using your Twitter account.') 104 | ); 105 | 106 | return $this; 107 | } 108 | 109 | $customersByEmail = Mage::helper('inchoo_socialconnect/twitter') 110 | ->getCustomersByEmail($info->getEmail()); 111 | 112 | if($customersByEmail->getSize()) { 113 | // Email account already exists - attach, login 114 | $customer = $customersByEmail->getFirstItem(); 115 | 116 | Mage::helper('inchoo_socialconnect/twitter')->connectByTwitterId( 117 | $customer, 118 | $info->getId(), 119 | $token 120 | ); 121 | 122 | Mage::getSingleton('core/session')->addSuccess( 123 | $this->__('We have discovered you already have an account at our store. Your Twitter account is now connected to your store account.') 124 | ); 125 | 126 | return $this; 127 | } 128 | 129 | // New connection - create, attach, login 130 | $name = $info->getName(); 131 | if(empty($name)) { 132 | throw new Exception( 133 | $this->__('Sorry, could not retrieve your Twitter last name. Please try again.') 134 | ); 135 | } 136 | 137 | Mage::helper('inchoo_socialconnect/twitter')->connectByCreatingAccount( 138 | $info->getEmail(), 139 | $info->getName(), 140 | $info->getId(), 141 | $token 142 | ); 143 | 144 | Mage::getSingleton('core/session')->addSuccess( 145 | $this->__('Your Twitter account is now connected to your new user account at our store. Now you can login using our Twitter Login button.') 146 | ); 147 | Mage::getSingleton('core/session')->addNotice( 148 | sprintf($this->__('Since Twitter doesn\'t support third-party access to your email address, we were unable to send you your store account credentials. To be able to login using store account credentials you will need to update your email address and password using our Edit Account Information.'), Mage::getUrl('customer/account/edit')) 149 | ); 150 | 151 | return $this; 152 | } 153 | 154 | } -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/inchoo/socialconnect/checkout/onepage/login.phtml: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | ?> 34 | 35 | getChildHtml('checkout.onepage.login.extra')?> 36 |
37 | getChildHtml('login_before')?> 38 |
39 |

getQuote()->isAllowedGuestCheckout() ): ?>__('Checkout as a Guest or Register') ?>__('Register to Create an Account') ?>

40 | getQuote()->isAllowedGuestCheckout() ): ?> 41 |

__('Register with us for future convenience:') ?>

42 | 43 |

__('Register and save time!') ?>
44 | __('Register with us for future convenience:') ?>

45 |
    46 |
  • __('Fast and easy check out') ?>
  • 47 |
  • __('Easy access to your order history and status') ?>
  • 48 |
49 | 50 | getQuote()->isAllowedGuestCheckout() ): ?> 51 |
    52 | getQuote()->isAllowedGuestCheckout() ): ?> 53 |
  • 54 | getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked" class="radio" /> 55 |
  • 56 | 57 |
  • 58 | getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->getQuote()->isAllowedGuestCheckout()): ?> checked="checked" class="radio" /> 59 |
  • 60 |
61 |

__('Register and save time!') ?>

62 |

__('Register with us for future convenience:') ?>

63 |
    64 |
  • __('Fast and easy check out') ?>
  • 65 |
  • __('Easy access to your order history and status') ?>
  • 66 |
67 | 68 | 69 | 70 |
71 |
72 |

__('Login') ?>

73 | getMessagesBlock()->getGroupedHtml() ?> 74 |
75 |
76 | getBlockHtml('formkey'); ?> 77 |

__('Already registered?') ?>

78 |

__('Please log in below:') ?>

79 |
    80 |
  • 81 | 82 |
    83 | 84 |
    85 |
  • 86 |
  • 87 | 88 |
    89 | 90 |
    91 |
  • 92 | getChildHtml('form.additional.info'); ?> 93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |

 

102 | 103 |
104 |
105 |
106 |
107 |

__('* Required Fields') ?>

108 | __('Forgot your password?') ?> 109 | 110 |
111 |
112 |
113 | 114 | getChildHtml('inchoo_socialconnect_checkout')?> 115 | 116 | 135 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Helper/Linkedin.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Helper_Linkedin extends Mage_Core_Helper_Abstract 35 | { 36 | 37 | public function disconnect(Mage_Customer_Model_Customer $customer) { 38 | // Note: LinkedIn API doesn't support revoking OAuth2 token programatically 39 | 40 | $pictureFilename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 41 | .DS 42 | .'inchoo' 43 | .DS 44 | .'socialconnect' 45 | .DS 46 | .'linkedin' 47 | .DS 48 | .$customer->getInchooSocialconnectLid(); 49 | 50 | if(file_exists($pictureFilename)) { 51 | @unlink($pictureFilename); 52 | } 53 | 54 | $customer->setInchooSocialconnectLid(null) 55 | ->setInchooSocialconnectLtoken(null) 56 | ->save(); 57 | } 58 | 59 | public function connectByLinkedinId( 60 | Mage_Customer_Model_Customer $customer, 61 | $linkedinId, 62 | $token) 63 | { 64 | $customer->setInchooSocialconnectLid($linkedinId) 65 | ->setInchooSocialconnectLtoken($token) 66 | ->save(); 67 | 68 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 69 | } 70 | 71 | public function connectByCreatingAccount( 72 | $email, 73 | $firstName, 74 | $lastName, 75 | $linkedinId, 76 | $token) 77 | { 78 | $customer = Mage::getModel('customer/customer'); 79 | 80 | $customer->setWebsiteId(Mage::app()->getWebsite()->getId()) 81 | ->setEmail($email) 82 | ->setFirstname($firstName) 83 | ->setLastname($lastName) 84 | ->setInchooSocialconnectLid($linkedinId) 85 | ->setInchooSocialconnectLtoken($token) 86 | ->setPassword($customer->generatePassword(10)) 87 | ->save(); 88 | 89 | $customer->setConfirmation(null); 90 | $customer->save(); 91 | 92 | $customer->sendNewAccountEmail('confirmed', '', Mage::app()->getStore()->getId()); 93 | 94 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 95 | 96 | } 97 | 98 | public function loginByCustomer(Mage_Customer_Model_Customer $customer) 99 | { 100 | if($customer->getConfirmation()) { 101 | $customer->setConfirmation(null); 102 | $customer->save(); 103 | } 104 | 105 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 106 | } 107 | 108 | public function getCustomersByLinkedinId($linkedinId) 109 | { 110 | $customer = Mage::getModel('customer/customer'); 111 | 112 | $collection = $customer->getCollection() 113 | ->addAttributeToFilter('inchoo_socialconnect_lid', $linkedinId) 114 | ->setPageSize(1); 115 | 116 | if($customer->getSharingConfig()->isWebsiteScope()) { 117 | $collection->addAttributeToFilter( 118 | 'website_id', 119 | Mage::app()->getWebsite()->getId() 120 | ); 121 | } 122 | 123 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 124 | $collection->addFieldToFilter( 125 | 'entity_id', 126 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 127 | ); 128 | } 129 | 130 | return $collection; 131 | } 132 | 133 | public function getCustomersByEmail($email) 134 | { 135 | $customer = Mage::getModel('customer/customer'); 136 | 137 | $collection = $customer->getCollection() 138 | ->addFieldToFilter('email', $email) 139 | ->setPageSize(1); 140 | 141 | if($customer->getSharingConfig()->isWebsiteScope()) { 142 | $collection->addAttributeToFilter( 143 | 'website_id', 144 | Mage::app()->getWebsite()->getId() 145 | ); 146 | } 147 | 148 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 149 | $collection->addFieldToFilter( 150 | 'entity_id', 151 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 152 | ); 153 | } 154 | 155 | return $collection; 156 | } 157 | 158 | public function getProperDimensionsPictureUrl($linkedinId, $pictureUrl) 159 | { 160 | $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) 161 | .'inchoo' 162 | .'/' 163 | .'socialconnect' 164 | .'/' 165 | .'linkedin' 166 | .'/' 167 | .$linkedinId; 168 | 169 | $filename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 170 | .DS 171 | .'inchoo' 172 | .DS 173 | .'socialconnect' 174 | .DS 175 | .'linkedin' 176 | .DS 177 | .$linkedinId; 178 | 179 | $directory = dirname($filename); 180 | 181 | if (!file_exists($directory) || !is_dir($directory)) { 182 | if (!@mkdir($directory, 0777, true)) 183 | return null; 184 | } 185 | 186 | if(!file_exists($filename) || 187 | (file_exists($filename) && (time() - filemtime($filename) >= 3600))){ 188 | $client = new Zend_Http_Client($pictureUrl); 189 | $client->setStream(); 190 | $response = $client->request('GET'); 191 | stream_copy_to_stream($response->getStream(), fopen($filename, 'w')); 192 | 193 | $imageObj = new Varien_Image($filename); 194 | $imageObj->constrainOnly(true); 195 | $imageObj->keepAspectRatio(true); 196 | $imageObj->keepFrame(false); 197 | $imageObj->resize(150, 150); 198 | $imageObj->save($filename); 199 | } 200 | 201 | return $url; 202 | } 203 | 204 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/controllers/GoogleController.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_GoogleController extends Inchoo_SocialConnect_Controller_Abstract 35 | { 36 | 37 | protected function _disconnectCallback(Mage_Customer_Model_Customer $customer) { 38 | Mage::helper('inchoo_socialconnect/google')->disconnect($customer); 39 | 40 | Mage::getSingleton('core/session') 41 | ->addSuccess( 42 | $this->__('You have successfully disconnected your Google account from our store account.') 43 | ); 44 | } 45 | 46 | protected function _connectCallback() { 47 | $errorCode = $this->getRequest()->getParam('error'); 48 | $code = $this->getRequest()->getParam('code'); 49 | $state = $this->getRequest()->getParam('state'); 50 | if(!($errorCode || $code) && !$state) { 51 | // Direct route access - deny 52 | return $this; 53 | } 54 | 55 | if(!$state || $state != Mage::getSingleton('core/session')->getGoogleCsrf()) { 56 | return $this; 57 | } 58 | 59 | if($errorCode) { 60 | // Google API read light - abort 61 | if($errorCode === 'access_denied') { 62 | Mage::getSingleton('core/session') 63 | ->addNotice( 64 | $this->__('Google Connect process aborted.') 65 | ); 66 | 67 | return $this; 68 | } 69 | 70 | throw new Exception( 71 | sprintf( 72 | $this->__('Sorry, "%s" error occured. Please try again.'), 73 | $errorCode 74 | ) 75 | ); 76 | } 77 | 78 | if ($code) { 79 | // Google API green light - proceed 80 | 81 | $info = Mage::getModel('inchoo_socialconnect/google_info')->load(); 82 | /* @var $info Inchoo_SocialConnect_Model_Google_Info */ 83 | 84 | $token = $info->getClient()->getAccessToken(); 85 | 86 | $customersByGoogleId = Mage::helper('inchoo_socialconnect/google') 87 | ->getCustomersByGoogleId($info->getId()); 88 | 89 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 90 | // Logged in user 91 | if($customersByGoogleId->getSize()) { 92 | // Google account already connected to other account - deny 93 | Mage::getSingleton('core/session') 94 | ->addNotice( 95 | $this->__('Your Google account is already connected to one of our store accounts.') 96 | ); 97 | 98 | return $this; 99 | } 100 | 101 | // Connect from account dashboard - attach 102 | $customer = Mage::getSingleton('customer/session')->getCustomer(); 103 | 104 | Mage::helper('inchoo_socialconnect/google')->connectByGoogleId( 105 | $customer, 106 | $info->getId(), 107 | $token 108 | ); 109 | 110 | Mage::getSingleton('core/session')->addSuccess( 111 | $this->__('Your Google account is now connected to your store account. You can now login using our Google Login button or using store account credentials you will receive to your email address.') 112 | ); 113 | 114 | return $this; 115 | } 116 | 117 | if($customersByGoogleId->getSize()) { 118 | // Existing connected user - login 119 | $customer = $customersByGoogleId->getFirstItem(); 120 | 121 | Mage::helper('inchoo_socialconnect/google')->loginByCustomer($customer); 122 | 123 | Mage::getSingleton('core/session') 124 | ->addSuccess( 125 | $this->__('You have successfully logged in using your Google account.') 126 | ); 127 | 128 | return $this; 129 | } 130 | 131 | $customersByEmail = Mage::helper('inchoo_socialconnect/facebook') 132 | ->getCustomersByEmail($info->getEmail()); 133 | 134 | if($customersByEmail->getSize()) { 135 | // Email account already exists - attach, login 136 | $customer = $customersByEmail->getFirstItem(); 137 | 138 | Mage::helper('inchoo_socialconnect/google')->connectByGoogleId( 139 | $customer, 140 | $info->getId(), 141 | $token 142 | ); 143 | 144 | Mage::getSingleton('core/session')->addSuccess( 145 | $this->__('We have discovered you already have an account at our store. Your Google account is now connected to your store account.') 146 | ); 147 | 148 | return $this; 149 | } 150 | 151 | // New connection - create, attach, login 152 | $givenName = $info->getGivenName(); 153 | if(empty($givenName)) { 154 | throw new Exception( 155 | $this->__('Sorry, could not retrieve your Google first name. Please try again.') 156 | ); 157 | } 158 | 159 | $familyName = $info->getFamilyName(); 160 | if(empty($familyName)) { 161 | throw new Exception( 162 | $this->__('Sorry, could not retrieve your Google last name. Please try again.') 163 | ); 164 | } 165 | 166 | Mage::helper('inchoo_socialconnect/google')->connectByCreatingAccount( 167 | $info->getEmail(), 168 | $info->getGivenName(), 169 | $info->getFamilyName(), 170 | $info->getId(), 171 | $token 172 | ); 173 | 174 | Mage::getSingleton('core/session')->addSuccess( 175 | $this->__('Your Google account is now connected to your new user account at our store. Now you can login using our Google Login button or using store account credentials you will receive to your email address.') 176 | ); 177 | } 178 | } 179 | 180 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Helper/Twitter.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Helper_Twitter extends Mage_Core_Helper_Abstract 35 | { 36 | 37 | public function disconnect(Mage_Customer_Model_Customer $customer) { 38 | Mage::getSingleton('customer/session') 39 | ->unsInchooSocialconnectTwitterUserinfo(); 40 | 41 | $pictureFilename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 42 | .DS 43 | .'inchoo' 44 | .DS 45 | .'socialconnect' 46 | .DS 47 | .'twitter' 48 | .DS 49 | .$customer->getInchooSocialconnectTid(); 50 | 51 | if(file_exists($pictureFilename)) { 52 | @unlink($pictureFilename); 53 | } 54 | 55 | $customer->setInchooSocialconnectTid(null) 56 | ->setInchooSocialconnectTtoken(null) 57 | ->save(); 58 | } 59 | 60 | public function connectByTwitterId( 61 | Mage_Customer_Model_Customer $customer, 62 | $twitterId, 63 | $token) 64 | { 65 | $customer->setInchooSocialconnectTid($twitterId) 66 | ->setInchooSocialconnectTtoken($token) 67 | ->save(); 68 | 69 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 70 | } 71 | 72 | public function connectByCreatingAccount( 73 | $email, 74 | $name, 75 | $twitterId, 76 | $token) 77 | { 78 | $customer = Mage::getModel('customer/customer'); 79 | 80 | $name = explode(' ', $name, 2); 81 | 82 | if(count($name) > 1) { 83 | $firstName = $name[0]; 84 | $lastName = $name[1]; 85 | } else { 86 | $firstName = $name[0]; 87 | $lastName = $name[0]; 88 | } 89 | 90 | $customer->setEmail($email) 91 | ->setFirstname($firstName) 92 | ->setLastname($lastName) 93 | ->setInchooSocialconnectTid($twitterId) 94 | ->setInchooSocialconnectTtoken($token) 95 | ->setPassword($customer->generatePassword(10)) 96 | ->save(); 97 | 98 | $customer->setConfirmation(null); 99 | $customer->save(); 100 | 101 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 102 | 103 | } 104 | 105 | public function loginByCustomer(Mage_Customer_Model_Customer $customer) 106 | { 107 | if($customer->getConfirmation()) { 108 | $customer->setConfirmation(null); 109 | $customer->save(); 110 | } 111 | 112 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 113 | } 114 | 115 | public function getCustomersByTwitterId($twitterId) 116 | { 117 | $customer = Mage::getModel('customer/customer'); 118 | 119 | $collection = $customer->getCollection() 120 | ->addAttributeToFilter('inchoo_socialconnect_tid', $twitterId) 121 | ->setPageSize(1); 122 | 123 | if($customer->getSharingConfig()->isWebsiteScope()) { 124 | $collection->addAttributeToFilter( 125 | 'website_id', 126 | Mage::app()->getWebsite()->getId() 127 | ); 128 | } 129 | 130 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 131 | $collection->addFieldToFilter( 132 | 'entity_id', 133 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 134 | ); 135 | } 136 | 137 | return $collection; 138 | } 139 | 140 | public function getCustomersByEmail($email) 141 | { 142 | $customer = Mage::getModel('customer/customer'); 143 | 144 | $collection = $customer->getCollection() 145 | ->addFieldToFilter('email', $email) 146 | ->setPageSize(1); 147 | 148 | if($customer->getSharingConfig()->isWebsiteScope()) { 149 | $collection->addAttributeToFilter( 150 | 'website_id', 151 | Mage::app()->getWebsite()->getId() 152 | ); 153 | } 154 | 155 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 156 | $collection->addFieldToFilter( 157 | 'entity_id', 158 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 159 | ); 160 | } 161 | 162 | return $collection; 163 | } 164 | 165 | public function getProperDimensionsPictureUrl($twitterId, $pictureUrl) 166 | { 167 | $pictureUrl = str_replace('_normal', '', $pictureUrl); 168 | 169 | $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) 170 | .'inchoo' 171 | .'/' 172 | .'socialconnect' 173 | .'/' 174 | .'twitter' 175 | .'/' 176 | .$twitterId; 177 | 178 | $filename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 179 | .DS 180 | .'inchoo' 181 | .DS 182 | .'socialconnect' 183 | .DS 184 | .'twitter' 185 | .DS 186 | .$twitterId; 187 | 188 | $directory = dirname($filename); 189 | 190 | if (!file_exists($directory) || !is_dir($directory)) { 191 | if (!@mkdir($directory, 0777, true)) 192 | return null; 193 | } 194 | 195 | if(!file_exists($filename) || 196 | (file_exists($filename) && (time() - filemtime($filename) >= 3600))){ 197 | $client = new Zend_Http_Client($pictureUrl); 198 | $client->setStream(); 199 | $response = $client->request('GET'); 200 | stream_copy_to_stream($response->getStream(), fopen($filename, 'w')); 201 | 202 | $imageObj = new Varien_Image($filename); 203 | $imageObj->constrainOnly(true); 204 | $imageObj->keepAspectRatio(true); 205 | $imageObj->keepFrame(false); 206 | $imageObj->resize(150, 150); 207 | $imageObj->save($filename); 208 | } 209 | 210 | return $url; 211 | } 212 | 213 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/controllers/FacebookController.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_FacebookController extends Inchoo_SocialConnect_Controller_Abstract 35 | { 36 | 37 | protected function _disconnectCallback(Mage_Customer_Model_Customer $customer) { 38 | Mage::helper('inchoo_socialconnect/facebook')->disconnect($customer); 39 | 40 | Mage::getSingleton('core/session') 41 | ->addSuccess( 42 | $this->__('You have successfully disconnected your Facebook account from our store account.') 43 | ); 44 | } 45 | 46 | protected function _connectCallback() { 47 | $errorCode = $this->getRequest()->getParam('error'); 48 | $code = $this->getRequest()->getParam('code'); 49 | $state = $this->getRequest()->getParam('state'); 50 | if(!($errorCode || $code) && !$state) { 51 | // Direct route access - deny 52 | return $this; 53 | } 54 | 55 | if(!$state || $state != Mage::getSingleton('core/session')->getFacebookCsrf()) { 56 | return $this; 57 | } 58 | 59 | if($errorCode) { 60 | // Facebook API read light - abort 61 | if($errorCode === 'access_denied') { 62 | Mage::getSingleton('core/session') 63 | ->addNotice( 64 | $this->__('Facebook Connect process aborted.') 65 | ); 66 | 67 | return $this; 68 | } 69 | 70 | throw new Exception( 71 | sprintf( 72 | $this->__('Sorry, "%s" error occured. Please try again.'), 73 | $errorCode 74 | ) 75 | ); 76 | } 77 | 78 | if ($code) { 79 | // Facebook API green light - proceed 80 | $info = Mage::getModel('inchoo_socialconnect/facebook_info')->load(); 81 | /* @var $info Inchoo_SocialConnect_Model_Facebook_Info */ 82 | 83 | $token = $info->getClient()->getAccessToken(); 84 | 85 | $customersByFacebookId = Mage::helper('inchoo_socialconnect/facebook') 86 | ->getCustomersByFacebookId($info->getId()); 87 | 88 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 89 | // Logged in user 90 | if($customersByFacebookId->getSize()) { 91 | // Facebook account already connected to other account - deny 92 | Mage::getSingleton('core/session') 93 | ->addNotice( 94 | $this->__('Your Facebook account is already connected to one of our store accounts.') 95 | ); 96 | 97 | return $this; 98 | } 99 | 100 | // Connect from account dashboard - attach 101 | $customer = Mage::getSingleton('customer/session')->getCustomer(); 102 | 103 | Mage::helper('inchoo_socialconnect/facebook')->connectByFacebookId( 104 | $customer, 105 | $info->getId(), 106 | $token 107 | ); 108 | 109 | Mage::getSingleton('core/session')->addSuccess( 110 | $this->__('Your Facebook account is now connected to your store account. You can now login using our Facebook Login button or using store account credentials you will receive to your email address.') 111 | ); 112 | 113 | return $this; 114 | } 115 | 116 | if($customersByFacebookId->getSize()) { 117 | // Existing connected user - login 118 | $customer = $customersByFacebookId->getFirstItem(); 119 | 120 | Mage::helper('inchoo_socialconnect/facebook')->loginByCustomer($customer); 121 | 122 | Mage::getSingleton('core/session') 123 | ->addSuccess( 124 | $this->__('You have successfully logged in using your Facebook account.') 125 | ); 126 | 127 | return $this; 128 | } 129 | 130 | $customersByEmail = Mage::helper('inchoo_socialconnect/facebook') 131 | ->getCustomersByEmail($info->getEmail()); 132 | 133 | if($customersByEmail->getSize()) { 134 | // Email account already exists - attach, login 135 | $customer = $customersByEmail->getFirstItem(); 136 | 137 | Mage::helper('inchoo_socialconnect/facebook')->connectByFacebookId( 138 | $customer, 139 | $info->getId(), 140 | $token 141 | ); 142 | 143 | Mage::getSingleton('core/session')->addSuccess( 144 | $this->__('We have discovered you already have an account at our store. Your Facebook account is now connected to your store account.') 145 | ); 146 | 147 | return $this; 148 | } 149 | 150 | // New connection - create, attach, login 151 | $firstName = $info->getFirstName(); 152 | if(empty($firstName)) { 153 | throw new Exception( 154 | $this->__('Sorry, could not retrieve your Facebook first name. Please try again.') 155 | ); 156 | } 157 | 158 | $lastName = $info->getLastName(); 159 | if(empty($lastName)) { 160 | throw new Exception( 161 | $this->__('Sorry, could not retrieve your Facebook last name. Please try again.') 162 | ); 163 | } 164 | 165 | Mage::helper('inchoo_socialconnect/facebook')->connectByCreatingAccount( 166 | $info->getEmail(), 167 | $info->getFirstName(), 168 | $info->getLastName(), 169 | $info->getId(), 170 | $token 171 | ); 172 | 173 | Mage::getSingleton('core/session')->addSuccess( 174 | $this->__('Your Facebook account is now connected to your new user account at our store. Now you can login using our Facebook Login button or using store account credentials you will receive to your email address.') 175 | ); 176 | } 177 | } 178 | 179 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/controllers/LinkedinController.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_LinkedinController extends Inchoo_SocialConnect_Controller_Abstract 35 | { 36 | 37 | protected function _disconnectCallback(Mage_Customer_Model_Customer $customer) { 38 | Mage::helper('inchoo_socialconnect/linkedin')->disconnect($customer); 39 | 40 | Mage::getSingleton('core/session') 41 | ->addSuccess( 42 | $this->__('You have successfully disconnected your Linkedin account from our store account.') 43 | ); 44 | } 45 | 46 | protected function _connectCallback() { 47 | $errorCode = $this->getRequest()->getParam('error'); 48 | $code = $this->getRequest()->getParam('code'); 49 | $state = $this->getRequest()->getParam('state'); 50 | if(!($errorCode || $code) && !$state) { 51 | // Direct route access - deny 52 | return $this; 53 | } 54 | 55 | if(!$state || $state != Mage::getSingleton('core/session')->getLinkedinCsrf()) { 56 | return $this; 57 | } 58 | 59 | if($errorCode) { 60 | // Linkedin API read light - abort 61 | if($errorCode === 'access_denied') { 62 | Mage::getSingleton('core/session') 63 | ->addNotice( 64 | $this->__('Linkedin Connect process aborted.') 65 | ); 66 | 67 | return $this; 68 | } 69 | 70 | throw new Exception( 71 | sprintf( 72 | $this->__('Sorry, "%s" error occured. Please try again.'), 73 | $errorCode 74 | ) 75 | ); 76 | } 77 | 78 | if ($code) { 79 | // Linkedin API green light - proceed 80 | 81 | $info = Mage::getModel('inchoo_socialconnect/linkedin_info')->load(); 82 | /* @var $info Inchoo_SocialConnect_Model_Linkedin_Userinfo */ 83 | 84 | $token = $info->getClient()->getAccessToken(); 85 | 86 | $customersByLinkedinId = Mage::helper('inchoo_socialconnect/linkedin') 87 | ->getCustomersByLinkedinId($info->getId()); 88 | 89 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 90 | // Logged in user 91 | if($customersByLinkedinId->getSize()) { 92 | // Linkedin account already connected to other account - deny 93 | Mage::getSingleton('core/session') 94 | ->addNotice( 95 | $this->__('Your Linkedin account is already connected to one of our store accounts.') 96 | ); 97 | 98 | return $this; 99 | } 100 | 101 | // Connect from account dashboard - attach 102 | $customer = Mage::getSingleton('customer/session')->getCustomer(); 103 | 104 | Mage::helper('inchoo_socialconnect/linkedin')->connectByLinkedinId( 105 | $customer, 106 | $info->getId(), 107 | $token 108 | ); 109 | 110 | Mage::getSingleton('core/session')->addSuccess( 111 | $this->__('Your Linkedin account is now connected to your store account. You can now login using our LinkedIn Login button or using store account credentials you will receive to your email address.') 112 | ); 113 | 114 | return $this; 115 | } 116 | 117 | if($customersByLinkedinId->getSize()) { 118 | // Existing connected user - login 119 | $customer = $customersByLinkedinId->getFirstItem(); 120 | 121 | Mage::helper('inchoo_socialconnect/linkedin')->loginByCustomer($customer); 122 | 123 | Mage::getSingleton('core/session') 124 | ->addSuccess( 125 | $this->__('You have successfully logged in using your Linkedin account.') 126 | ); 127 | 128 | return $this; 129 | } 130 | 131 | $customersByEmail = Mage::helper('inchoo_socialconnect/linkedin') 132 | ->getCustomersByEmail($info->getEmailAddress()); 133 | 134 | if($customersByEmail->getSize()) { 135 | // Email account already exists - attach, login 136 | $customer = $customersByEmail->getFirstItem(); 137 | 138 | Mage::helper('inchoo_socialconnect/linkedin')->connectByLinkedinId( 139 | $customer, 140 | $info->getId(), 141 | $token 142 | ); 143 | 144 | Mage::getSingleton('core/session')->addSuccess( 145 | $this->__('We have discovered you already have an account at our store. Your Linkedin account is now connected to your store account.') 146 | ); 147 | 148 | return $this; 149 | } 150 | 151 | // New connection - create, attach, login 152 | $firstName = $info->getFirstName(); 153 | if(empty($firstName)) { 154 | throw new Exception( 155 | $this->__('Sorry, could not retrieve your Linkedin first name. Please try again.') 156 | ); 157 | } 158 | 159 | $lastName = $info->getLastName(); 160 | if(empty($lastname)) { 161 | throw new Exception( 162 | $this->__('Sorry, could not retrieve your Linkedin last name. Please try again.') 163 | ); 164 | } 165 | 166 | Mage::helper('inchoo_socialconnect/linkedin')->connectByCreatingAccount( 167 | $info->getEmailAddress(), 168 | $info->getFirstName(), 169 | $info->getLastName(), 170 | $info->getId(), 171 | $token 172 | ); 173 | 174 | Mage::getSingleton('core/session')->addSuccess( 175 | $this->__('Your Linkedin account is now connected to your new user account at our store. Now you can login using our LinkedIn Login button or using store account credentials you will receive to your email address.') 176 | ); 177 | } 178 | } 179 | 180 | } -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Helper/Facebook.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Helper_Facebook extends Mage_Core_Helper_Abstract 35 | { 36 | 37 | public function disconnect(Mage_Customer_Model_Customer $customer) { 38 | $client = Mage::getSingleton('inchoo_socialconnect/facebook_oauth2_client'); 39 | 40 | // TODO: Move into Inchoo_SocialConnect_Model_Facebook_Info_User 41 | try { 42 | $client->setAccessToken($customer->getInchooSocialconnectFtoken()); 43 | $client->api('/me/permissions', 'DELETE'); 44 | } catch (Exception $e) { } 45 | 46 | $pictureFilename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 47 | .DS 48 | .'inchoo' 49 | .DS 50 | .'socialconnect' 51 | .DS 52 | .'facebook' 53 | .DS 54 | .$customer->getInchooSocialconnectFid(); 55 | 56 | if(file_exists($pictureFilename)) { 57 | @unlink($pictureFilename); 58 | } 59 | 60 | $customer->setInchooSocialconnectFid(null) 61 | ->setInchooSocialconnectFtoken(null) 62 | ->save(); 63 | } 64 | 65 | public function connectByFacebookId( 66 | Mage_Customer_Model_Customer $customer, 67 | $facebookId, 68 | $token) 69 | { 70 | $customer->setInchooSocialconnectFid($facebookId) 71 | ->setInchooSocialconnectFtoken($token) 72 | ->save(); 73 | 74 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 75 | } 76 | 77 | public function connectByCreatingAccount( 78 | $email, 79 | $firstName, 80 | $lastName, 81 | $facebookId, 82 | $token) 83 | { 84 | $customer = Mage::getModel('customer/customer'); 85 | 86 | $customer->setWebsiteId(Mage::app()->getWebsite()->getId()) 87 | ->setEmail($email) 88 | ->setFirstname($firstName) 89 | ->setLastname($lastName) 90 | ->setInchooSocialconnectFid($facebookId) 91 | ->setInchooSocialconnectFtoken($token) 92 | ->setPassword($customer->generatePassword(10)) 93 | ->save(); 94 | 95 | $customer->setConfirmation(null); 96 | $customer->save(); 97 | 98 | $customer->sendNewAccountEmail('confirmed', '', Mage::app()->getStore()->getId()); 99 | 100 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 101 | 102 | } 103 | 104 | public function loginByCustomer(Mage_Customer_Model_Customer $customer) 105 | { 106 | if($customer->getConfirmation()) { 107 | $customer->setConfirmation(null); 108 | $customer->save(); 109 | } 110 | 111 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 112 | } 113 | 114 | public function getCustomersByFacebookId($facebookId) 115 | { 116 | $customer = Mage::getModel('customer/customer'); 117 | 118 | $collection = $customer->getCollection() 119 | ->addAttributeToFilter('inchoo_socialconnect_fid', $facebookId) 120 | ->setPageSize(1); 121 | 122 | if($customer->getSharingConfig()->isWebsiteScope()) { 123 | $collection->addAttributeToFilter( 124 | 'website_id', 125 | Mage::app()->getWebsite()->getId() 126 | ); 127 | } 128 | 129 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 130 | $collection->addFieldToFilter( 131 | 'entity_id', 132 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 133 | ); 134 | } 135 | 136 | return $collection; 137 | } 138 | 139 | public function getCustomersByEmail($email) 140 | { 141 | $customer = Mage::getModel('customer/customer'); 142 | 143 | $collection = $customer->getCollection() 144 | ->addFieldToFilter('email', $email) 145 | ->setPageSize(1); 146 | 147 | if($customer->getSharingConfig()->isWebsiteScope()) { 148 | $collection->addAttributeToFilter( 149 | 'website_id', 150 | Mage::app()->getWebsite()->getId() 151 | ); 152 | } 153 | 154 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 155 | $collection->addFieldToFilter( 156 | 'entity_id', 157 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 158 | ); 159 | } 160 | 161 | return $collection; 162 | } 163 | 164 | public function getProperDimensionsPictureUrl($facebookId, $pictureUrl) 165 | { 166 | $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) 167 | .'inchoo' 168 | .'/' 169 | .'socialconnect' 170 | .'/' 171 | .'facebook' 172 | .'/' 173 | .$facebookId; 174 | 175 | $filename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 176 | .DS 177 | .'inchoo' 178 | .DS 179 | .'socialconnect' 180 | .DS 181 | .'facebook' 182 | .DS 183 | .$facebookId; 184 | 185 | $directory = dirname($filename); 186 | 187 | if (!file_exists($directory) || !is_dir($directory)) { 188 | if (!@mkdir($directory, 0777, true)) 189 | return null; 190 | } 191 | 192 | if(!file_exists($filename) || 193 | (file_exists($filename) && (time() - filemtime($filename) >= 3600))){ 194 | $client = new Zend_Http_Client($pictureUrl); 195 | $client->setStream(); 196 | $response = $client->request('GET'); 197 | stream_copy_to_stream($response->getStream(), fopen($filename, 'w')); 198 | 199 | $imageObj = new Varien_Image($filename); 200 | $imageObj->constrainOnly(true); 201 | $imageObj->keepAspectRatio(true); 202 | $imageObj->keepFrame(false); 203 | $imageObj->resize(150, 150); 204 | $imageObj->save($filename); 205 | } 206 | 207 | return $url; 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /app/code/community/Inchoo/SocialConnect/Helper/Google.php: -------------------------------------------------------------------------------- 1 | 30 | * @copyright Copyright (c) Inchoo (http://inchoo.net/) 31 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 32 | */ 33 | 34 | class Inchoo_SocialConnect_Helper_Google extends Mage_Core_Helper_Abstract 35 | { 36 | 37 | public function disconnect(Mage_Customer_Model_Customer $customer) { 38 | $client = Mage::getSingleton('inchoo_socialconnect/google_oauth2_client'); 39 | 40 | // TODO: Move into Inchoo_SocialConnect_Model_Google_Info_User 41 | try { 42 | $client->setAccessToken($customer->getInchooSocialconnectGtoken()); 43 | $client->revokeToken(); 44 | } catch (Exception $e) { } 45 | 46 | $pictureFilename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 47 | .DS 48 | .'inchoo' 49 | .DS 50 | .'socialconnect' 51 | .DS 52 | .'google' 53 | .DS 54 | .$customer->getInchooSocialconnectGid(); 55 | 56 | if(file_exists($pictureFilename)) { 57 | @unlink($pictureFilename); 58 | } 59 | 60 | $customer->setInchooSocialconnectGid(null) 61 | ->setInchooSocialconnectGtoken(null) 62 | ->save(); 63 | } 64 | 65 | public function connectByGoogleId( 66 | Mage_Customer_Model_Customer $customer, 67 | $googleId, 68 | $token) 69 | { 70 | $customer->setInchooSocialconnectGid($googleId) 71 | ->setInchooSocialconnectGtoken($token) 72 | ->save(); 73 | 74 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 75 | } 76 | 77 | public function connectByCreatingAccount( 78 | $email, 79 | $firstName, 80 | $lastName, 81 | $googleId, 82 | $token) 83 | { 84 | $customer = Mage::getModel('customer/customer'); 85 | 86 | $customer->setWebsiteId(Mage::app()->getWebsite()->getId()) 87 | ->setEmail($email) 88 | ->setFirstname($firstName) 89 | ->setLastname($lastName) 90 | ->setInchooSocialconnectGid($googleId) 91 | ->setInchooSocialconnectGtoken($token) 92 | ->setPassword($customer->generatePassword(10)) 93 | ->save(); 94 | 95 | $customer->setConfirmation(null); 96 | $customer->save(); 97 | 98 | $customer->sendNewAccountEmail('confirmed', '', Mage::app()->getStore()->getId()); 99 | 100 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 101 | } 102 | 103 | public function loginByCustomer(Mage_Customer_Model_Customer $customer) 104 | { 105 | if($customer->getConfirmation()) { 106 | $customer->setConfirmation(null); 107 | $customer->save(); 108 | } 109 | 110 | Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); 111 | } 112 | 113 | public function getCustomersByGoogleId($googleId) 114 | { 115 | $customer = Mage::getModel('customer/customer'); 116 | 117 | $collection = $customer->getCollection() 118 | ->addAttributeToFilter('inchoo_socialconnect_gid', $googleId) 119 | ->setPageSize(1); 120 | 121 | if($customer->getSharingConfig()->isWebsiteScope()) { 122 | $collection->addAttributeToFilter( 123 | 'website_id', 124 | Mage::app()->getWebsite()->getId() 125 | ); 126 | } 127 | 128 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 129 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 130 | $collection->addFieldToFilter( 131 | 'entity_id', 132 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 133 | ); 134 | } 135 | } 136 | 137 | return $collection; 138 | } 139 | 140 | public function getCustomersByEmail($email) 141 | { 142 | $customer = Mage::getModel('customer/customer'); 143 | 144 | $collection = $customer->getCollection() 145 | ->addFieldToFilter('email', $email) 146 | ->setPageSize(1); 147 | 148 | if($customer->getSharingConfig()->isWebsiteScope()) { 149 | $collection->addAttributeToFilter( 150 | 'website_id', 151 | Mage::app()->getWebsite()->getId() 152 | ); 153 | } 154 | 155 | if(Mage::getSingleton('customer/session')->isLoggedIn()) { 156 | $collection->addFieldToFilter( 157 | 'entity_id', 158 | array('neq' => Mage::getSingleton('customer/session')->getCustomerId()) 159 | ); 160 | } 161 | 162 | return $collection; 163 | } 164 | 165 | public function getProperDimensionsPictureUrl($googleId, $pictureUrl) 166 | { 167 | $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) 168 | .'inchoo' 169 | .'/' 170 | .'socialconnect' 171 | .'/' 172 | .'google' 173 | .'/' 174 | .$googleId; 175 | 176 | $filename = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) 177 | .DS 178 | .'inchoo' 179 | .DS 180 | .'socialconnect' 181 | .DS 182 | .'google' 183 | .DS 184 | .$googleId; 185 | 186 | $directory = dirname($filename); 187 | 188 | if (!file_exists($directory) || !is_dir($directory)) { 189 | if (!@mkdir($directory, 0777, true)) 190 | return null; 191 | } 192 | 193 | if(!file_exists($filename) || 194 | (file_exists($filename) && (time() - filemtime($filename) >= 3600))){ 195 | $client = new Zend_Http_Client($pictureUrl); 196 | $client->setStream(); 197 | $response = $client->request('GET'); 198 | stream_copy_to_stream($response->getStream(), fopen($filename, 'w')); 199 | 200 | $imageObj = new Varien_Image($filename); 201 | $imageObj->constrainOnly(true); 202 | $imageObj->keepAspectRatio(true); 203 | $imageObj->keepFrame(false); 204 | $imageObj->resize(150, 150); 205 | $imageObj->save($filename); 206 | } 207 | 208 | return $url; 209 | } 210 | 211 | } --------------------------------------------------------------------------------