Version Notes
Version 1.2.0
Download this release
Release Info
Developer | GoMage |
Extension | gomage_social_connector |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.2.0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/AbstractRedirectUri.php +35 -0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/General.php +3 -3
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/Information.php +3 -3
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Amazon.php +18 -0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Google.php +18 -0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Linkedin.php +18 -0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Reddit.php +18 -0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Tumblr.php +18 -0
- app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Twitter.php +18 -0
- app/code/local/GoMage/Social/Block/Head.php +32 -0
- app/code/local/GoMage/Social/Block/Login.php +25 -9
- app/code/local/GoMage/Social/Block/Login/Facebook.php +20 -0
- app/code/local/GoMage/Social/Block/Login/Google.php +20 -0
- app/code/local/GoMage/Social/Block/Login/Service.php +20 -0
- app/code/local/GoMage/Social/Controller/Social.php +30 -31
- app/code/local/GoMage/Social/Controller/SocialNoMail.php +147 -0
- app/code/local/GoMage/Social/Helper/Data.php +85 -31
- app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type.php +3 -3
- app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Facebook.php +3 -3
- app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Google.php +3 -3
- app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Services.php +8 -4
- app/code/local/GoMage/Social/Model/Entity.php +4 -5
- app/code/local/GoMage/Social/Model/Mysql4/Entity.php +3 -3
- app/code/local/GoMage/Social/Model/Mysql4/Entity/Collection.php +4 -4
- app/code/local/GoMage/Social/Model/Observer.php +20 -6
- app/code/local/GoMage/Social/Model/Observer/Notify.php +4 -4
- app/code/local/GoMage/Social/Model/Type.php +35 -6
- app/code/local/GoMage/Social/controllers/AmazonController.php +129 -0
- app/code/local/GoMage/Social/controllers/FacebookController.php +3 -3
- app/code/local/GoMage/Social/controllers/GoogleController.php +3 -3
- app/code/local/GoMage/Social/controllers/LinkedinController.php +3 -3
- app/code/local/GoMage/Social/controllers/RedditController.php +123 -0
- app/code/local/GoMage/Social/controllers/TumblrController.php +135 -0
- app/code/local/GoMage/Social/controllers/TwitterController.php +131 -0
- app/code/local/GoMage/Social/etc/adminhtml.xml +22 -3
- app/code/local/GoMage/Social/etc/config.xml +52 -5
- app/code/local/GoMage/Social/etc/system.xml +463 -20
- app/code/local/GoMage/Social/sql/gomage_social_setup/mysql4-upgrade-1.0.0-1.1.0.php +17 -0
- app/code/local/GoMage/Social/sql/gomage_social_setup/mysql4-upgrade-1.0.1-1.2.0.php +12 -0
- app/design/frontend/base/default/layout/gomage-social.xml +26 -24
- app/design/frontend/base/default/template/gomage/social/config.phtml +179 -80
- app/design/frontend/base/default/template/gomage/social/login.phtml +16 -68
- app/design/frontend/base/default/template/gomage/social/login/facebook.phtml +27 -0
- app/design/frontend/base/default/template/gomage/social/login/google.phtml +36 -0
- app/design/frontend/base/default/template/gomage/social/login/service.phtml +22 -0
- app/etc/modules/GoMage_Social.xml +4 -4
- js/gomage/social.js +210 -0
- lib/GoMage/Amazon/Credentials.php +25 -0
- lib/GoMage/Amazon/Service.php +156 -0
- lib/GoMage/Linkedin/linkedinoauth.php +5 -2
- lib/GoMage/Reddit/Client.php +484 -0
- lib/GoMage/Reddit/GrantType/AuthorizationCode.php +41 -0
- lib/GoMage/Reddit/GrantType/IGrantType.php +15 -0
- lib/GoMage/Tumblr/OAuth.php +874 -0
- lib/GoMage/Tumblr/tumblroauth.php +245 -0
- lib/GoMage/Twitter/OAuth.php +870 -0
- lib/GoMage/Twitter/twitteroauth.php +241 -0
- media/gomage/social/facebook_button.png +0 -0
- package.xml +18 -14
- skin/frontend/base/default/css/gomage/social.css +81 -6
- skin/frontend/rwd/default/css/gomage/social.css +162 -0
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/AbstractRedirectUri.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
abstract class GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
16 |
+
$store = Mage::app()->getRequest()
|
17 |
+
->getParam('store');
|
18 |
+
|
19 |
+
$store_id = Mage::app()->getStore($store)
|
20 |
+
->getStoreId();
|
21 |
+
|
22 |
+
$url = Mage::getUrl(
|
23 |
+
'gomage_social/' . $this->getTypeService() . '/callback',
|
24 |
+
array(
|
25 |
+
'_secure' => true,
|
26 |
+
'_store' => ($store_id ? $store_id : 1),
|
27 |
+
'_nosid' => true,
|
28 |
+
)
|
29 |
+
);
|
30 |
+
|
31 |
+
return '<span style="font-weight:bold">' . $url . '</span>';
|
32 |
+
}
|
33 |
+
|
34 |
+
abstract public function getTypeService();
|
35 |
+
}
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/General.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Block_Adminhtml_System_Config_Fieldset_General
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Block_Adminhtml_System_Config_Fieldset_General
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/Information.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Block_Adminhtml_System_Config_Fieldset_Information extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Block_Adminhtml_System_Config_Fieldset_Information extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Amazon.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Amazon extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri {
|
15 |
+
public function getTypeService() {
|
16 |
+
return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::AMAZON);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Google.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Google extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri {
|
15 |
+
public function getTypeService() {
|
16 |
+
return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::GOOGLE);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Linkedin.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Linkedin extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri {
|
15 |
+
public function getTypeService() {
|
16 |
+
return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::LINKEDIN);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Reddit.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Reddit extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri {
|
15 |
+
public function getTypeService() {
|
16 |
+
return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::REDDIT);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Tumblr.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Tumblr extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri {
|
15 |
+
public function getTypeService() {
|
16 |
+
return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::TUMBLR);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Twitter.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Twitter extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri {
|
15 |
+
public function getTypeService() {
|
16 |
+
return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::TWITTER);
|
17 |
+
}
|
18 |
+
}
|
app/code/local/GoMage/Social/Block/Head.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Head extends Mage_Core_Block_Template{
|
15 |
+
|
16 |
+
protected function _prepareLayout()
|
17 |
+
{
|
18 |
+
parent::_prepareLayout();
|
19 |
+
if (! Mage::getSingleton('customer/session')->isLoggedIn() && Mage::helper('gomage_social')->isActive()) {
|
20 |
+
|
21 |
+
if(!Mage::helper('gomage_social')->getIsAnymoreVersion(1, 7)){
|
22 |
+
$this->getLayout()->getBlock('head')->addItem('js_css', 'prototype/windows/themes/magento.css');
|
23 |
+
}else{
|
24 |
+
$this->getLayout()->getBlock('head')->addItem('skin_css', 'lib/prototype/windows/themes/magento.css');
|
25 |
+
}
|
26 |
+
$this->getLayout()->getBlock('head')->addItem('js_css', 'prototype/windows/themes/default.css');
|
27 |
+
$this->getLayout()->getBlock('head')->addCss('css/gomage/social.css');
|
28 |
+
$this->getLayout()->getBlock('head')->addjs('prototype/window.js');
|
29 |
+
$this->getLayout()->getBlock('head')->addjs('gomage/social.js');
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
app/code/local/GoMage/Social/Block/Login.php
CHANGED
@@ -3,31 +3,33 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
|
15 |
|
16 |
-
|
17 |
|
18 |
public function __construct() {
|
19 |
parent::__construct();
|
|
|
20 |
if (! $this->getSession()->isLoggedIn() && Mage::helper('gomage_social')->isActive()) {
|
21 |
$this->setTemplate('gomage/social/login.phtml');
|
22 |
}
|
23 |
}
|
24 |
-
|
25 |
private function getSession() {
|
26 |
return Mage::getSingleton('customer/session');
|
27 |
}
|
28 |
|
29 |
public function setPlace($place) {
|
30 |
$this->place = $place;
|
|
|
31 |
return $this;
|
32 |
}
|
33 |
|
@@ -38,16 +40,19 @@ class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
|
|
38 |
public function getImage($service = '') {
|
39 |
if ($service) {
|
40 |
$image = Mage::getStoreConfig('gomage_social/' . $service . '/image');
|
|
|
41 |
if ($image) {
|
42 |
return Mage::getBaseUrl('media') . 'gomage/social/' . $image;
|
43 |
}
|
44 |
}
|
|
|
45 |
return false;
|
46 |
}
|
47 |
|
48 |
public function getText($service = '') {
|
49 |
if ($service) {
|
50 |
$text = Mage::getStoreConfig('gomage_social/' . $service . '/text');
|
|
|
51 |
if ($text) {
|
52 |
return $text;
|
53 |
}
|
@@ -55,11 +60,22 @@ class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
|
|
55 |
|
56 |
return $this->__('Login');
|
57 |
}
|
58 |
-
|
59 |
-
public function getLoginType($service = '') {
|
60 |
|
|
|
61 |
return Mage::getStoreConfig('gomage_social/'. $service .'/' . $this->getPlace() . '_type');
|
62 |
-
|
63 |
}
|
64 |
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
|
15 |
|
16 |
+
protected $place;
|
17 |
|
18 |
public function __construct() {
|
19 |
parent::__construct();
|
20 |
+
|
21 |
if (! $this->getSession()->isLoggedIn() && Mage::helper('gomage_social')->isActive()) {
|
22 |
$this->setTemplate('gomage/social/login.phtml');
|
23 |
}
|
24 |
}
|
25 |
+
|
26 |
private function getSession() {
|
27 |
return Mage::getSingleton('customer/session');
|
28 |
}
|
29 |
|
30 |
public function setPlace($place) {
|
31 |
$this->place = $place;
|
32 |
+
|
33 |
return $this;
|
34 |
}
|
35 |
|
40 |
public function getImage($service = '') {
|
41 |
if ($service) {
|
42 |
$image = Mage::getStoreConfig('gomage_social/' . $service . '/image');
|
43 |
+
|
44 |
if ($image) {
|
45 |
return Mage::getBaseUrl('media') . 'gomage/social/' . $image;
|
46 |
}
|
47 |
}
|
48 |
+
|
49 |
return false;
|
50 |
}
|
51 |
|
52 |
public function getText($service = '') {
|
53 |
if ($service) {
|
54 |
$text = Mage::getStoreConfig('gomage_social/' . $service . '/text');
|
55 |
+
|
56 |
if ($text) {
|
57 |
return $text;
|
58 |
}
|
60 |
|
61 |
return $this->__('Login');
|
62 |
}
|
|
|
|
|
63 |
|
64 |
+
public function getLoginType($service = '') {
|
65 |
return Mage::getStoreConfig('gomage_social/'. $service .'/' . $this->getPlace() . '_type');
|
|
|
66 |
}
|
67 |
|
68 |
+
public function getServiceBlock($type, $is_last) {
|
69 |
+
$service = GoMage_Social_Model_Type::getTypeService($type);
|
70 |
+
$block = $this->getLayout()->createBlock('gomage_social/login_' . $service);
|
71 |
+
|
72 |
+
if (!$block) {
|
73 |
+
$block = $this->getLayout()->createBlock('gomage_social/login_service');
|
74 |
+
}
|
75 |
+
|
76 |
+
return $block->setData('is_last', $is_last)
|
77 |
+
->setData('service', $service)
|
78 |
+
->setPlace($this->getPlace())
|
79 |
+
->toHtml();
|
80 |
+
}
|
81 |
+
}
|
app/code/local/GoMage/Social/Block/Login/Facebook.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Login_Facebook extends GoMage_Social_Block_Login {
|
15 |
+
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
$this->setTemplate('gomage/social/login/facebook.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/local/GoMage/Social/Block/Login/Google.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Login_Google extends GoMage_Social_Block_Login {
|
15 |
+
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
$this->setTemplate('gomage/social/login/google.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/local/GoMage/Social/Block/Login/Service.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_Block_Login_Service extends GoMage_Social_Block_Login {
|
15 |
+
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
$this->setTemplate('gomage/social/login/service.phtml');
|
19 |
+
}
|
20 |
+
}
|
app/code/local/GoMage/Social/Controller/Social.php
CHANGED
@@ -3,84 +3,83 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Front_Action {
|
15 |
|
16 |
abstract function getSocialType();
|
17 |
|
18 |
-
protected function getSession(){
|
19 |
return Mage::getSingleton('customer/session');
|
20 |
}
|
21 |
|
22 |
-
protected function createSocial($social_id, $customer_id){
|
23 |
return Mage::getModel('gomage_social/entity')
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
}
|
30 |
|
31 |
-
protected function createCustomer($profile){
|
32 |
-
|
33 |
$customer = Mage::getModel('customer/customer');
|
34 |
$password = $customer->generatePassword(8);
|
35 |
|
36 |
-
if (is_array($profile)){
|
37 |
$profile = (object)$profile;
|
38 |
}
|
39 |
|
40 |
$customer->setData('firstname', $profile->first_name)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
$errors = $customer->validate();
|
48 |
-
|
49 |
-
if (is_array($errors) && count($errors)){
|
50 |
$this->getSession()->addError(implode(' ', $errors));
|
|
|
51 |
return false;
|
52 |
}
|
53 |
|
54 |
$customer->save();
|
55 |
$customer->sendNewAccountEmail();
|
56 |
|
57 |
-
return $customer;
|
58 |
-
|
59 |
}
|
60 |
|
61 |
-
protected function _getRedirectUrl($url){
|
62 |
-
if (!$url){
|
63 |
$url = $this->getRequest()->getParam('gs_url', '');
|
64 |
|
65 |
-
if (!$url && Mage::getSingleton('core/session')->getData('gs_url')){
|
66 |
$url = Mage::getSingleton('core/session')->getData('gs_url');
|
67 |
Mage::getSingleton('core/session')->unsetData('gs_url');
|
68 |
}
|
69 |
|
70 |
-
if ($url){
|
71 |
$url = Mage::helper('core')->urlDecode($url);
|
72 |
}
|
73 |
}
|
74 |
-
|
|
|
75 |
$url = Mage::getBaseUrl();
|
76 |
}
|
77 |
|
78 |
return $url;
|
79 |
}
|
80 |
|
81 |
-
protected function _redirectUrl($url)
|
82 |
-
|
83 |
-
return parent::_redirectUrl($this->_getRedirectUrl($url));
|
84 |
}
|
85 |
-
|
86 |
}
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Front_Action {
|
15 |
|
16 |
abstract function getSocialType();
|
17 |
|
18 |
+
protected function getSession() {
|
19 |
return Mage::getSingleton('customer/session');
|
20 |
}
|
21 |
|
22 |
+
protected function createSocial($social_id, $customer_id) {
|
23 |
return Mage::getModel('gomage_social/entity')
|
24 |
+
->setData('social_id', $social_id)
|
25 |
+
->setData('type_id', $this->getSocialType())
|
26 |
+
->setData('customer_id', $customer_id)
|
27 |
+
->setData('website_id', Mage::app()->getWebsite()->getId())
|
28 |
+
->save();
|
29 |
}
|
30 |
|
31 |
+
protected function createCustomer($profile) {
|
|
|
32 |
$customer = Mage::getModel('customer/customer');
|
33 |
$password = $customer->generatePassword(8);
|
34 |
|
35 |
+
if (is_array($profile)) {
|
36 |
$profile = (object)$profile;
|
37 |
}
|
38 |
|
39 |
$customer->setData('firstname', $profile->first_name)
|
40 |
+
->setData('lastname', $profile->last_name)
|
41 |
+
->setData('email', $profile->email)
|
42 |
+
->setData('password', $password)
|
43 |
+
->setData('password_confirmation', $password)
|
44 |
+
->setSkipConfirmationIfEmail($profile->email)
|
45 |
+
->setConfirmation($password);
|
46 |
|
47 |
$errors = $customer->validate();
|
48 |
+
|
49 |
+
if (is_array($errors) && count($errors)) {
|
50 |
$this->getSession()->addError(implode(' ', $errors));
|
51 |
+
|
52 |
return false;
|
53 |
}
|
54 |
|
55 |
$customer->save();
|
56 |
$customer->sendNewAccountEmail();
|
57 |
|
58 |
+
return $customer;
|
|
|
59 |
}
|
60 |
|
61 |
+
protected function _getRedirectUrl($url = '') {
|
62 |
+
if (!$url) {
|
63 |
$url = $this->getRequest()->getParam('gs_url', '');
|
64 |
|
65 |
+
if (!$url && Mage::getSingleton('core/session')->getData('gs_url')) {
|
66 |
$url = Mage::getSingleton('core/session')->getData('gs_url');
|
67 |
Mage::getSingleton('core/session')->unsetData('gs_url');
|
68 |
}
|
69 |
|
70 |
+
if ($url) {
|
71 |
$url = Mage::helper('core')->urlDecode($url);
|
72 |
}
|
73 |
}
|
74 |
+
|
75 |
+
if (!$url) {
|
76 |
$url = Mage::getBaseUrl();
|
77 |
}
|
78 |
|
79 |
return $url;
|
80 |
}
|
81 |
|
82 |
+
protected function _redirectUrl($url = '') {
|
83 |
+
return parent::_redirectUrl($this->_getRedirectUrl($url));
|
|
|
84 |
}
|
|
|
85 |
}
|
app/code/local/GoMage/Social/Controller/SocialNoMail.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Controller_Social {
|
15 |
+
|
16 |
+
protected function createCustomer($profile) {
|
17 |
+
$customer = Mage::getModel('customer/customer');
|
18 |
+
$password = $customer->generatePassword(8);
|
19 |
+
|
20 |
+
if (is_array($profile)) {
|
21 |
+
$profile = (object) $profile;
|
22 |
+
}
|
23 |
+
|
24 |
+
$customer->setData('firstname', $profile->first_name)
|
25 |
+
->setData('lastname', $profile->last_name)
|
26 |
+
->setData('email', $profile->email)
|
27 |
+
->setData('password', $password)
|
28 |
+
->setData('password_confirmation', $password)
|
29 |
+
->setConfirmation($password);
|
30 |
+
|
31 |
+
$errors = $customer->validate();
|
32 |
+
|
33 |
+
if (is_array($errors) && count($errors)) {
|
34 |
+
$this->getSession()->addError(implode(' ', $errors));
|
35 |
+
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
$customer->save();
|
40 |
+
|
41 |
+
$customer->sendNewAccountEmail(
|
42 |
+
'confirmation',
|
43 |
+
Mage::getSingleton('core/session')->getBeforeAuthUrl(),
|
44 |
+
Mage::app()->getStore()
|
45 |
+
->getId()
|
46 |
+
);
|
47 |
+
Mage::getSingleton('core/session')->addSuccess(
|
48 |
+
$this->__(
|
49 |
+
'Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.',
|
50 |
+
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
return $customer;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function checkEmailAction() {
|
58 |
+
$message = array();
|
59 |
+
$message['redirect'] = null;
|
60 |
+
|
61 |
+
if ($customer_email = $this->getRequest()->getParam('email')) {
|
62 |
+
$customer = Mage::getModel("customer/customer");
|
63 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
64 |
+
$customer->loadByEmail($customer_email);
|
65 |
+
|
66 |
+
if ($profile = Mage::getSingleton('core/session')->getGsProfile()) {
|
67 |
+
if ($customer->getId()) {
|
68 |
+
$message['redirect'] = Mage::getUrl('customer/account/login',array('_secure'=>true));
|
69 |
+
$profile->url = null;
|
70 |
+
Mage::getSingleton('core/session')->setGsProfile($profile);
|
71 |
+
Mage::getSingleton('core/session')->addNotice('There is already an account with this email address. We suggest using the standard login form.');
|
72 |
+
} else {
|
73 |
+
$social_collection = Mage::getModel('gomage_social/entity')
|
74 |
+
->getCollection()
|
75 |
+
->addFieldToFilter('social_id', $profile->id)
|
76 |
+
->addFieldToFilter('type_id', $profile->type_id);
|
77 |
+
|
78 |
+
if(Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
79 |
+
$social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
|
80 |
+
}
|
81 |
+
|
82 |
+
$social = $social_collection->getFirstItem();
|
83 |
+
$customer = null;
|
84 |
+
|
85 |
+
if ($social && $social->getId()) {
|
86 |
+
$customer = Mage::getModel('customer/customer');
|
87 |
+
|
88 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
89 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
90 |
+
}
|
91 |
+
|
92 |
+
$customer->load($social->getData('customer_id'));
|
93 |
+
}
|
94 |
+
|
95 |
+
if ($customer && $customer->getId()) {
|
96 |
+
if (!$customer->getConfirmation()) {
|
97 |
+
$this->getSession()->loginById($customer->getId());
|
98 |
+
}
|
99 |
+
} else {
|
100 |
+
$customer = Mage::getModel('customer/customer');
|
101 |
+
|
102 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
103 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
104 |
+
}
|
105 |
+
|
106 |
+
$name = explode(" ", $profile->name);
|
107 |
+
$profile->email = $customer_email;
|
108 |
+
$profile->first_name = $name[0];
|
109 |
+
|
110 |
+
if (isset($name[1])) {
|
111 |
+
$profile->last_name = $name[1];
|
112 |
+
} else {
|
113 |
+
$profile->last_name = $name[0];
|
114 |
+
}
|
115 |
+
|
116 |
+
$customer->loadByEmail($profile->email);
|
117 |
+
|
118 |
+
if (!$customer->getId()) {
|
119 |
+
$customer = $this->createCustomer($profile);
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($customer && $customer->getId()) {
|
123 |
+
$this->createSocial($profile->id, $customer->getId());
|
124 |
+
$customer->setConfirmation(true);
|
125 |
+
|
126 |
+
if (!$customer->getConfirmation()) {
|
127 |
+
$this->getSession()->loginById($customer->getId());
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
Mage::getSingleton('core/session')->unsGsProfile();
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
if (!$message['redirect']) {
|
138 |
+
$message['success'] = true;
|
139 |
+
}
|
140 |
+
|
141 |
+
return $this->getResponse()->setBody(Zend_Json::encode($message));
|
142 |
+
}
|
143 |
+
|
144 |
+
public function emailCloseAction() {
|
145 |
+
Mage::getSingleton('core/session')->unsGsProfile();
|
146 |
+
}
|
147 |
+
}
|
app/code/local/GoMage/Social/Helper/Data.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
@@ -24,13 +24,28 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
24 |
public function isLIActive() {
|
25 |
return Mage::getStoreConfig('gomage_social/linkedin/enable') && Mage::getStoreConfig('gomage_social/linkedin/id') && Mage::getStoreConfig('gomage_social/linkedin/secret');
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
public function isActive() {
|
29 |
-
return Mage::getStoreConfig('gomage_social/general/enable') && ($this->isFBActive() || $this->isGActive() || $this->isLIActive());
|
30 |
}
|
31 |
|
32 |
-
public function getServices($place = '') {
|
33 |
-
|
34 |
$result = array();
|
35 |
|
36 |
if (! $place) {
|
@@ -44,24 +59,40 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
44 |
if ($this->isFBActive() && in_array(GoMage_Social_Model_Type::FACEBOOK, $selected_services)) {
|
45 |
$result[GoMage_Social_Model_Type::FACEBOOK] = Mage::getStoreConfig('gomage_social/facebook/order');
|
46 |
}
|
|
|
47 |
if ($this->isGActive() && in_array(GoMage_Social_Model_Type::GOOGLE, $selected_services)) {
|
48 |
$result[GoMage_Social_Model_Type::GOOGLE] = Mage::getStoreConfig('gomage_social/google/order');
|
49 |
}
|
|
|
50 |
if ($this->isLIActive() && in_array(GoMage_Social_Model_Type::LINKEDIN, $selected_services)) {
|
51 |
$result[GoMage_Social_Model_Type::LINKEDIN] = Mage::getStoreConfig('gomage_social/linkedin/order');
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
natcasesort($result);
|
55 |
|
56 |
return $result;
|
57 |
}
|
58 |
|
59 |
-
public function getAllStoreDomains() {
|
60 |
-
|
61 |
$domains = array();
|
62 |
|
63 |
-
foreach (Mage::app()->getWebsites() as $website) {
|
64 |
-
|
65 |
$url = $website->getConfig('web/unsecure/base_url');
|
66 |
|
67 |
if ($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))) {
|
@@ -74,19 +105,18 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
74 |
$domains[] = $domain;
|
75 |
}
|
76 |
}
|
|
|
77 |
return array_unique($domains);
|
78 |
-
|
79 |
}
|
80 |
|
81 |
-
public function setInformation() {
|
82 |
-
|
83 |
$value = "";
|
84 |
|
85 |
try {
|
86 |
$ch = curl_init();
|
87 |
curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_downloadable/key/getinformation'));
|
88 |
curl_setopt($ch, CURLOPT_POST, true);
|
89 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector&domains=' . urlencode(implode(',', $this->getAllStoreDomains())) . '&ver=' . urlencode('1.
|
90 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
91 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
92 |
|
@@ -94,8 +124,8 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
94 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
95 |
|
96 |
$value = curl_exec($ch);
|
97 |
-
}
|
98 |
-
|
99 |
}
|
100 |
|
101 |
if ($value && ($value != Mage::getStoreConfig('gomage_social/information/text'))) {
|
@@ -106,12 +136,13 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
106 |
|
107 |
}
|
108 |
|
109 |
-
public function notify(){
|
110 |
-
|
111 |
$frequency = intval(Mage::app()->loadCache('gomage_notifications_frequency'));
|
112 |
-
|
|
|
113 |
$frequency = 24;
|
114 |
}
|
|
|
115 |
$last_update = intval(Mage::app()->loadCache('gomage_notifications_last_update'));
|
116 |
|
117 |
if (($frequency * 60 * 60 + $last_update) > time()) {
|
@@ -119,18 +150,18 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
119 |
}
|
120 |
|
121 |
$timestamp = $last_update;
|
122 |
-
|
|
|
123 |
$timestamp = time();
|
124 |
}
|
125 |
|
126 |
-
try{
|
127 |
$ch = curl_init();
|
128 |
curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_notification/index/data'));
|
129 |
curl_setopt($ch, CURLOPT_POST, true);
|
130 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector×tamp='
|
131 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
132 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
133 |
-
|
134 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
135 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
136 |
|
@@ -138,21 +169,44 @@ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
138 |
|
139 |
$result = Zend_Json::decode($content);
|
140 |
|
141 |
-
if ($result && isset($result['frequency']) && ($result['frequency'] != $frequency)){
|
142 |
Mage::app()->saveCache($result['frequency'], 'gomage_notifications_frequency');
|
143 |
}
|
144 |
|
145 |
-
if ($result && isset($result['data'])){
|
146 |
-
if (!empty($result['data'])){
|
147 |
Mage::getModel('adminnotification/inbox')->parse($result['data']);
|
148 |
}
|
149 |
}
|
150 |
-
} catch (Exception $e){
|
151 |
-
|
152 |
-
|
153 |
|
|
|
154 |
}
|
155 |
-
|
156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
|
24 |
public function isLIActive() {
|
25 |
return Mage::getStoreConfig('gomage_social/linkedin/enable') && Mage::getStoreConfig('gomage_social/linkedin/id') && Mage::getStoreConfig('gomage_social/linkedin/secret');
|
26 |
}
|
27 |
+
|
28 |
+
public function isTWActive() {
|
29 |
+
return Mage::getStoreConfig('gomage_social/twitter/enable') && Mage::getStoreConfig('gomage_social/twitter/id') && Mage::getStoreConfig('gomage_social/twitter/secret');
|
30 |
+
}
|
31 |
+
|
32 |
+
public function isTUActive() {
|
33 |
+
return Mage::getStoreConfig('gomage_social/tumblr/enable') && Mage::getStoreConfig('gomage_social/tumblr/id') && Mage::getStoreConfig('gomage_social/tumblr/secret');
|
34 |
+
}
|
35 |
+
|
36 |
+
public function isREActive() {
|
37 |
+
return Mage::getStoreConfig('gomage_social/reddit/enable') && Mage::getStoreConfig('gomage_social/reddit/id') && Mage::getStoreConfig('gomage_social/reddit/secret');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function isAMActive() {
|
41 |
+
return Mage::getStoreConfig('gomage_social/amazon/enable') && Mage::getStoreConfig('gomage_social/amazon/id') && Mage::getStoreConfig('gomage_social/amazon/secret');
|
42 |
+
}
|
43 |
|
44 |
public function isActive() {
|
45 |
+
return Mage::getStoreConfig('gomage_social/general/enable') && ($this->isFBActive() || $this->isGActive() || $this->isLIActive() || $this->isTWActive() || $this->isTUActive() || $this->isREActive() || $this->isAMActive());
|
46 |
}
|
47 |
|
48 |
+
public function getServices($place = '') {
|
|
|
49 |
$result = array();
|
50 |
|
51 |
if (! $place) {
|
59 |
if ($this->isFBActive() && in_array(GoMage_Social_Model_Type::FACEBOOK, $selected_services)) {
|
60 |
$result[GoMage_Social_Model_Type::FACEBOOK] = Mage::getStoreConfig('gomage_social/facebook/order');
|
61 |
}
|
62 |
+
|
63 |
if ($this->isGActive() && in_array(GoMage_Social_Model_Type::GOOGLE, $selected_services)) {
|
64 |
$result[GoMage_Social_Model_Type::GOOGLE] = Mage::getStoreConfig('gomage_social/google/order');
|
65 |
}
|
66 |
+
|
67 |
if ($this->isLIActive() && in_array(GoMage_Social_Model_Type::LINKEDIN, $selected_services)) {
|
68 |
$result[GoMage_Social_Model_Type::LINKEDIN] = Mage::getStoreConfig('gomage_social/linkedin/order');
|
69 |
}
|
70 |
|
71 |
+
if ($this->isTWActive() && in_array(GoMage_Social_Model_Type::TWITTER, $selected_services)) {
|
72 |
+
$result[GoMage_Social_Model_Type::TWITTER] = Mage::getStoreConfig('gomage_social/twitter/order');
|
73 |
+
}
|
74 |
+
|
75 |
+
if ($this->isTUActive() && in_array(GoMage_Social_Model_Type::TUMBLR, $selected_services)) {
|
76 |
+
$result[GoMage_Social_Model_Type::TUMBLR] = Mage::getStoreConfig('gomage_social/tumblr/order');
|
77 |
+
}
|
78 |
+
|
79 |
+
if ($this->isREActive() && in_array(GoMage_Social_Model_Type::REDDIT, $selected_services)) {
|
80 |
+
$result[GoMage_Social_Model_Type::REDDIT] = Mage::getStoreConfig('gomage_social/reddit/order');
|
81 |
+
}
|
82 |
+
|
83 |
+
if ($this->isAMActive() && in_array(GoMage_Social_Model_Type::AMAZON, $selected_services)) {
|
84 |
+
$result[GoMage_Social_Model_Type::AMAZON] = Mage::getStoreConfig('gomage_social/amazon/order');
|
85 |
+
}
|
86 |
+
|
87 |
natcasesort($result);
|
88 |
|
89 |
return $result;
|
90 |
}
|
91 |
|
92 |
+
public function getAllStoreDomains() {
|
|
|
93 |
$domains = array();
|
94 |
|
95 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
|
|
96 |
$url = $website->getConfig('web/unsecure/base_url');
|
97 |
|
98 |
if ($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))) {
|
105 |
$domains[] = $domain;
|
106 |
}
|
107 |
}
|
108 |
+
|
109 |
return array_unique($domains);
|
|
|
110 |
}
|
111 |
|
112 |
+
public function setInformation() {
|
|
|
113 |
$value = "";
|
114 |
|
115 |
try {
|
116 |
$ch = curl_init();
|
117 |
curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_downloadable/key/getinformation'));
|
118 |
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector&domains=' . urlencode(implode(',', $this->getAllStoreDomains())) . '&ver=' . urlencode('1.2'));
|
120 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
121 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
122 |
|
124 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
125 |
|
126 |
$value = curl_exec($ch);
|
127 |
+
} catch (Exception $e) {
|
128 |
+
|
129 |
}
|
130 |
|
131 |
if ($value && ($value != Mage::getStoreConfig('gomage_social/information/text'))) {
|
136 |
|
137 |
}
|
138 |
|
139 |
+
public function notify() {
|
|
|
140 |
$frequency = intval(Mage::app()->loadCache('gomage_notifications_frequency'));
|
141 |
+
|
142 |
+
if (!$frequency) {
|
143 |
$frequency = 24;
|
144 |
}
|
145 |
+
|
146 |
$last_update = intval(Mage::app()->loadCache('gomage_notifications_last_update'));
|
147 |
|
148 |
if (($frequency * 60 * 60 + $last_update) > time()) {
|
150 |
}
|
151 |
|
152 |
$timestamp = $last_update;
|
153 |
+
|
154 |
+
if (!$timestamp) {
|
155 |
$timestamp = time();
|
156 |
}
|
157 |
|
158 |
+
try {
|
159 |
$ch = curl_init();
|
160 |
curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_notification/index/data'));
|
161 |
curl_setopt($ch, CURLOPT_POST, true);
|
162 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector×tamp=' . $timestamp . '&ver=' . urlencode('1.2'));
|
163 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
164 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
165 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
166 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
167 |
|
169 |
|
170 |
$result = Zend_Json::decode($content);
|
171 |
|
172 |
+
if ($result && isset($result['frequency']) && ($result['frequency'] != $frequency)) {
|
173 |
Mage::app()->saveCache($result['frequency'], 'gomage_notifications_frequency');
|
174 |
}
|
175 |
|
176 |
+
if ($result && isset($result['data'])) {
|
177 |
+
if (!empty($result['data'])) {
|
178 |
Mage::getModel('adminnotification/inbox')->parse($result['data']);
|
179 |
}
|
180 |
}
|
181 |
+
} catch (Exception $e){
|
182 |
+
|
183 |
+
}
|
184 |
|
185 |
+
Mage::app()->saveCache(time(), 'gomage_notifications_last_update');
|
186 |
}
|
|
|
187 |
|
188 |
+
|
189 |
+
public function getIsAnymoreVersion($major, $minor, $revision = 0) {
|
190 |
+
$version_info = Mage::getVersion();
|
191 |
+
$version_info = explode('.', $version_info);
|
192 |
+
|
193 |
+
if ($version_info[0] > $major) {
|
194 |
+
return true;
|
195 |
+
} elseif ($version_info[0] == $major){
|
196 |
+
if ($version_info[1] > $minor) {
|
197 |
+
return true;
|
198 |
+
} elseif ($version_info[1] == $minor) {
|
199 |
+
if ($version_info[2] >= $revision) {
|
200 |
+
return true;
|
201 |
+
} else {
|
202 |
+
return false;
|
203 |
+
}
|
204 |
+
} else {
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
} else {
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
}
|
211 |
}
|
212 |
|
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type{
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 11.1.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type{
|
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Facebook.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type_Facebook extends GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type{
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type_Facebook extends GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type{
|
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Google.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type_Google extends GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type{
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type_Google extends GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type{
|
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Services.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Services{
|
@@ -19,9 +19,13 @@ class GoMage_Social_Model_Adminhtml_System_Config_Source_Services{
|
|
19 |
|
20 |
return array(
|
21 |
array('value' => '', 'label' => ''),
|
22 |
-
array('value' => GoMage_Social_Model_Type::FACEBOOK, 'label' => $helper->__('
|
23 |
array('value' => GoMage_Social_Model_Type::LINKEDIN, 'label' => $helper->__('LinkedIn')),
|
24 |
array('value' => GoMage_Social_Model_Type::GOOGLE, 'label' => $helper->__('Google')),
|
|
|
|
|
|
|
|
|
25 |
);
|
26 |
}
|
27 |
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Adminhtml_System_Config_Source_Services{
|
19 |
|
20 |
return array(
|
21 |
array('value' => '', 'label' => ''),
|
22 |
+
array('value' => GoMage_Social_Model_Type::FACEBOOK, 'label' => $helper->__('Facebook')),
|
23 |
array('value' => GoMage_Social_Model_Type::LINKEDIN, 'label' => $helper->__('LinkedIn')),
|
24 |
array('value' => GoMage_Social_Model_Type::GOOGLE, 'label' => $helper->__('Google')),
|
25 |
+
array('value' => GoMage_Social_Model_Type::TWITTER, 'label' => $helper->__('Twitter')),
|
26 |
+
array('value' => GoMage_Social_Model_Type::TUMBLR, 'label' => $helper->__('Tumblr')),
|
27 |
+
array('value' => GoMage_Social_Model_Type::REDDIT, 'label' => $helper->__('Reddit')),
|
28 |
+
array('value' => GoMage_Social_Model_Type::AMAZON, 'label' => $helper->__('Amazon')),
|
29 |
);
|
30 |
}
|
31 |
|
app/code/local/GoMage/Social/Model/Entity.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Entity extends Mage_Core_Model_Abstract {
|
@@ -16,6 +16,5 @@ class GoMage_Social_Model_Entity extends Mage_Core_Model_Abstract {
|
|
16 |
protected function _construct() {
|
17 |
$this->_init("gomage_social/entity");
|
18 |
}
|
19 |
-
|
20 |
-
}
|
21 |
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Entity extends Mage_Core_Model_Abstract {
|
16 |
protected function _construct() {
|
17 |
$this->_init("gomage_social/entity");
|
18 |
}
|
19 |
+
}
|
|
|
20 |
|
app/code/local/GoMage/Social/Model/Mysql4/Entity.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Mysql4_Entity extends Mage_Core_Model_Mysql4_Abstract {
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Mysql4_Entity extends Mage_Core_Model_Mysql4_Abstract {
|
app/code/local/GoMage/Social/Model/Mysql4/Entity/Collection.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Mysql4_Entity_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
@@ -17,5 +17,5 @@ class GoMage_Social_Model_Mysql4_Entity_Collection extends Mage_Core_Model_Mysql
|
|
17 |
$this->_init("gomage_social/entity");
|
18 |
}
|
19 |
|
20 |
-
}
|
21 |
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Mysql4_Entity_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
17 |
$this->_init("gomage_social/entity");
|
18 |
}
|
19 |
|
20 |
+
}
|
21 |
|
app/code/local/GoMage/Social/Model/Observer.php
CHANGED
@@ -3,20 +3,34 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Observer {
|
15 |
|
16 |
public static function saveConfig() {
|
17 |
-
|
18 |
-
Mage::helper('gomage_social')->setInformation();
|
19 |
-
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Observer {
|
15 |
|
16 |
public static function saveConfig() {
|
17 |
+
Mage::helper('gomage_social')->setInformation();
|
|
|
|
|
18 |
}
|
19 |
|
20 |
+
public function GSCustomerLoggedIn() {
|
21 |
+
if($profile = Mage::getSingleton('core/session')->getGsProfile() && Mage::getSingleton('core/session')->getGsProfile()->url == null ){
|
22 |
+
$this->createSocial();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
private function createSocial(){
|
27 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
28 |
+
|
29 |
+
return Mage::getModel('gomage_social/entity')
|
30 |
+
->setData('social_id', Mage::getSingleton('core/session')->getGsProfile()->id)
|
31 |
+
->setData('type_id', Mage::getSingleton('core/session')->getGsProfile()->type_id)
|
32 |
+
->setData('customer_id', $customer->getId())
|
33 |
+
->setData('website_id', Mage::app()->getWebsite()->getId())
|
34 |
+
->save();
|
35 |
+
}
|
36 |
}
|
app/code/local/GoMage/Social/Model/Observer/Notify.php
CHANGED
@@ -3,18 +3,18 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Observer_Notify {
|
15 |
|
16 |
public function notify($event) {
|
17 |
-
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
|
18 |
Mage::helper('gomage_social')->notify();
|
19 |
}
|
20 |
}
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Observer_Notify {
|
15 |
|
16 |
public function notify($event) {
|
17 |
+
if (Mage::getSingleton('admin/session')->isLoggedIn() && Mage::getStoreConfig('gomage_notification/notification/enable')) {
|
18 |
Mage::helper('gomage_social')->notify();
|
19 |
}
|
20 |
}
|
app/code/local/GoMage/Social/Model/Type.php
CHANGED
@@ -3,18 +3,47 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Type {
|
15 |
|
16 |
-
const FACEBOOK
|
17 |
-
const LINKEDIN
|
18 |
-
const GOOGLE
|
|
|
|
|
|
|
|
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
class GoMage_Social_Model_Type {
|
15 |
|
16 |
+
const FACEBOOK = 1;
|
17 |
+
const LINKEDIN = 2;
|
18 |
+
const GOOGLE = 3;
|
19 |
+
const TWITTER = 4;
|
20 |
+
const TUMBLR = 5;
|
21 |
+
const REDDIT = 6;
|
22 |
+
const AMAZON = 7;
|
23 |
|
24 |
+
public static function getTypeService($type) {
|
25 |
+
switch ($type) {
|
26 |
+
case self::FACEBOOK :
|
27 |
+
return 'facebook';
|
28 |
+
break;
|
29 |
+
case self::LINKEDIN :
|
30 |
+
return 'linkedin';
|
31 |
+
break;
|
32 |
+
case self::GOOGLE :
|
33 |
+
return 'google';
|
34 |
+
break;
|
35 |
+
case self::TWITTER :
|
36 |
+
return 'twitter';
|
37 |
+
break;
|
38 |
+
case self::TUMBLR :
|
39 |
+
return 'tumblr';
|
40 |
+
break;
|
41 |
+
case self::REDDIT :
|
42 |
+
return 'reddit';
|
43 |
+
break;
|
44 |
+
case self::AMAZON :
|
45 |
+
return 'amazon';
|
46 |
+
break;
|
47 |
+
}
|
48 |
+
}
|
49 |
}
|
app/code/local/GoMage/Social/controllers/AmazonController.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Social_AmazonController extends GoMage_Social_Controller_Social {
|
15 |
+
|
16 |
+
protected $credentials;
|
17 |
+
|
18 |
+
public function getSocialType() {
|
19 |
+
return GoMage_Social_Model_Type::AMAZON;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getCredentials() {
|
23 |
+
if (!$this->credentials) {
|
24 |
+
$redirect_uri = Mage::getUrl('gomage_social/amazon/callback', array('_secure' => true));
|
25 |
+
|
26 |
+
$this->credentials = new GoMage_Amazon_Credentials(array(
|
27 |
+
'client_id' => Mage::getStoreConfig('gomage_social/amazon/id'),
|
28 |
+
'client_secret' => Mage::getStoreConfig('gomage_social/amazon/secret'),
|
29 |
+
'redirect_uri' => $redirect_uri,
|
30 |
+
));
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->credentials;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function loginAction() {
|
37 |
+
try {
|
38 |
+
if ($this->getSession()->isLoggedIn()) {
|
39 |
+
return $this->_redirectUrl();
|
40 |
+
}
|
41 |
+
|
42 |
+
$service = new GoMage_Amazon_Service($this->getCredentials());
|
43 |
+
$redirect_url = $service->getAuthorizationUrl(array('scope' => 'profile'));
|
44 |
+
} catch(Exception $e) {
|
45 |
+
$this->getSession()->addError($this->__($e->getMessage()));
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->_redirectUrl($redirect_url);
|
49 |
+
}
|
50 |
+
|
51 |
+
public function callbackAction() {
|
52 |
+
try {
|
53 |
+
$code = $this->getRequest()->getParam('code');
|
54 |
+
|
55 |
+
if ($this->getSession()->isLoggedIn() || empty($code)) {
|
56 |
+
return $this->_redirectUrl();
|
57 |
+
}
|
58 |
+
|
59 |
+
$credentials = $this->getCredentials();
|
60 |
+
$credentials->setData('code', $code);
|
61 |
+
|
62 |
+
$service = new GoMage_Amazon_Service($credentials);
|
63 |
+
//GoMage_Amazon_Service::$return_request_error = true;
|
64 |
+
$oauth_token = $service->requestToken();
|
65 |
+
|
66 |
+
if ($oauth_token->getAccessToken()) {
|
67 |
+
Mage::getSingleton('core/session')->setData('oauth_token', $oauth_token);
|
68 |
+
$service->getCredentials()->setData('oauth_token', $oauth_token);
|
69 |
+
|
70 |
+
$profile = new Varien_Object($service->requestUserProfile()->getData('Profile'));
|
71 |
+
|
72 |
+
if ($profile->getData('CustomerId')) {
|
73 |
+
$social_collection = Mage::getModel('gomage_social/entity')
|
74 |
+
->getCollection()
|
75 |
+
->addFieldToFilter('social_id', $profile->getData('CustomerId'))
|
76 |
+
->addFieldToFilter('type_id', $this->getSocialType());
|
77 |
+
|
78 |
+
if(Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
79 |
+
$social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
|
80 |
+
}
|
81 |
+
|
82 |
+
$social = $social_collection->getFirstItem();
|
83 |
+
$customer = Mage::getModel('customer/customer');
|
84 |
+
|
85 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
86 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($social && $social->getId()){
|
90 |
+
$customer->load($social->getData('customer_id'));
|
91 |
+
|
92 |
+
if ($customer->getId()){
|
93 |
+
$this->getSession()->loginById($customer->getId());
|
94 |
+
}
|
95 |
+
} else {
|
96 |
+
$_profile = array(
|
97 |
+
'id' => $profile->getData('CustomerId'),
|
98 |
+
'email' => $profile->getData('PrimaryEmail'),
|
99 |
+
'first_name' => $profile->getData('Name'),
|
100 |
+
'last_name' => $profile->getData('Name'),
|
101 |
+
);
|
102 |
+
|
103 |
+
$_profile = (object) $_profile;
|
104 |
+
$customer->loadByEmail($_profile->email);
|
105 |
+
|
106 |
+
if (!$customer->getId()){
|
107 |
+
$customer = $this->createCustomer($_profile);
|
108 |
+
}
|
109 |
+
|
110 |
+
if ($customer && $customer->getId()){
|
111 |
+
$this->createSocial($_profile->id, $customer->getId());
|
112 |
+
$this->getSession()->loginById($customer->getId());
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
return $this->_redirectUrl();
|
118 |
+
} else {
|
119 |
+
$this->getSession()->addError($this->__('Could not connect to Amazon. Refresh the page or try again later.'));
|
120 |
+
|
121 |
+
return $this->_redirectUrl();
|
122 |
+
}
|
123 |
+
} catch(Exception $e) {
|
124 |
+
$this->getSession()->addError($this->__($e->getMessage()));
|
125 |
+
|
126 |
+
return $this->_redirectUrl();
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
app/code/local/GoMage/Social/controllers/FacebookController.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Facebook' . DS . 'facebook.php');
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Facebook' . DS . 'facebook.php');
|
app/code/local/GoMage/Social/controllers/GoogleController.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'Google_Client.php');
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
*/
|
13 |
|
14 |
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'Google_Client.php');
|
app/code/local/GoMage/Social/controllers/LinkedinController.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
|
14 |
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Linkedin' . DS . 'linkedinoauth.php');
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
|
14 |
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Linkedin' . DS . 'linkedinoauth.php');
|
app/code/local/GoMage/Social/controllers/RedditController.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'Client.php');
|
15 |
+
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'GrantType/IGrantType.php');
|
16 |
+
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'GrantType/AuthorizationCode.php');
|
17 |
+
|
18 |
+
class GoMage_Social_RedditController extends GoMage_Social_Controller_SocialNoMail {
|
19 |
+
|
20 |
+
protected $authorizeUrl = 'https://ssl.reddit.com/api/v1/authorize';
|
21 |
+
protected $accessTokenUrl = 'https://ssl.reddit.com/api/v1/access_token';
|
22 |
+
|
23 |
+
public function getSocialType() {
|
24 |
+
return GoMage_Social_Model_Type::REDDIT;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function loginAction() {
|
28 |
+
$callback_url = Mage::getUrl('gomage_social/reddit/callback', array('_secure' => true));
|
29 |
+
$client = new OAuth2\Client(
|
30 |
+
Mage::getStoreConfig('gomage_social/reddit/id'),
|
31 |
+
Mage::getStoreConfig('gomage_social/reddit/secret'),
|
32 |
+
OAuth2\Client::AUTH_TYPE_AUTHORIZATION_BASIC
|
33 |
+
);
|
34 |
+
|
35 |
+
$authUrl = $client->getAuthenticationUrl(
|
36 |
+
$this->authorizeUrl,
|
37 |
+
$callback_url,
|
38 |
+
array(
|
39 |
+
"scope" => "identity",
|
40 |
+
"state" => "SomeUnguessableValue"
|
41 |
+
)
|
42 |
+
);
|
43 |
+
|
44 |
+
return $this->_redirectUrl($authUrl);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function callbackAction() {
|
48 |
+
$callback_url = Mage::getUrl('gomage_social/reddit/callback', array('_secure' => true));
|
49 |
+
$client = new OAuth2\Client(
|
50 |
+
Mage::getStoreConfig('gomage_social/reddit/id'),
|
51 |
+
Mage::getStoreConfig('gomage_social/reddit/secret'),
|
52 |
+
OAuth2\Client::AUTH_TYPE_AUTHORIZATION_BASIC
|
53 |
+
);
|
54 |
+
$params = array(
|
55 |
+
"code" => $this->getRequest()->getParam('code'),
|
56 |
+
"redirect_uri" => $callback_url
|
57 |
+
);
|
58 |
+
|
59 |
+
if ($params['code']) {
|
60 |
+
$response = $client->getAccessToken($this->accessTokenUrl, "authorization_code", $params);
|
61 |
+
$accessTokenResult = $response["result"];
|
62 |
+
|
63 |
+
$client->setAccessToken($accessTokenResult["access_token"]);
|
64 |
+
$client->setAccessTokenType(OAuth2\Client::ACCESS_TOKEN_BEARER);
|
65 |
+
|
66 |
+
$response = (object) $client->fetch("https://oauth.reddit.com/api/v1/me.json");
|
67 |
+
$profile = null;
|
68 |
+
|
69 |
+
switch ($response->code) {
|
70 |
+
case 200 :
|
71 |
+
$profile = (object) $response->result;
|
72 |
+
break;
|
73 |
+
default :
|
74 |
+
$this->getSession()->addError($this->__('Could not connect to Reddit. Refresh the page or try again later.'));
|
75 |
+
|
76 |
+
return $this->_redirectUrl();
|
77 |
+
}
|
78 |
+
|
79 |
+
if ($profile) {
|
80 |
+
if ($profile->id) {
|
81 |
+
$social_collection = Mage::getModel('gomage_social/entity')
|
82 |
+
->getCollection()
|
83 |
+
->addFieldToFilter('social_id', $profile->id)
|
84 |
+
->addFieldToFilter('type_id', GoMage_Social_Model_Type::REDDIT);
|
85 |
+
|
86 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
87 |
+
$social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
|
88 |
+
}
|
89 |
+
|
90 |
+
$social = $social_collection->getFirstItem();
|
91 |
+
|
92 |
+
if ($social && $social->getId()) {
|
93 |
+
if ($social->social_id == $profile->id) {
|
94 |
+
$customer = Mage::getModel('customer/customer');
|
95 |
+
|
96 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
97 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
98 |
+
}
|
99 |
+
|
100 |
+
$customer->load($social->getData('customer_id'));
|
101 |
+
|
102 |
+
if ($customer && $customer->getId()) {
|
103 |
+
if (!$customer->getConfirmation()) {
|
104 |
+
$this->getSession()->loginById($customer->getId());
|
105 |
+
} else{
|
106 |
+
$this->getSession()->addError($this->__('This account is not confirmed.'));
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
} else {
|
111 |
+
$profile->url = Mage::getUrl('gomage_social/reddit/checkEmail', array('_secure' => true));
|
112 |
+
$profile->urlEmailClose = Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => true));
|
113 |
+
$profile->type_id = GoMage_Social_Model_Type::REDDIT;
|
114 |
+
|
115 |
+
Mage::getSingleton('core/session')->setGsProfile($profile);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
return $this->_redirectUrl();
|
122 |
+
}
|
123 |
+
}
|
app/code/local/GoMage/Social/controllers/TumblrController.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Tumblr' . DS . 'tumblroauth.php');
|
15 |
+
|
16 |
+
class GoMage_Social_TumblrController extends GoMage_Social_Controller_SocialNoMail {
|
17 |
+
|
18 |
+
public function getSocialType() {
|
19 |
+
return GoMage_Social_Model_Type::TUMBLR;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function loginAction() {
|
23 |
+
if ($this->getSession()->isLoggedIn()) {
|
24 |
+
return $this->_redirectUrl();
|
25 |
+
}
|
26 |
+
|
27 |
+
$connection = new TumblrOAuth(Mage::getStoreConfig('gomage_social/tumblr/id'), Mage::getStoreConfig('gomage_social/tumblr/secret'));
|
28 |
+
$callback_params = array('_secure' => true);
|
29 |
+
|
30 |
+
if ($this->getRequest()->getParam('gs_url', '')) {
|
31 |
+
$callback_params['gs_url'] = $this->getRequest()->getParam('gs_url');
|
32 |
+
}
|
33 |
+
|
34 |
+
$callback_url = Mage::getUrl('gomage_social/tumblr/callback', $callback_params);
|
35 |
+
$request_token = $connection->getRequestToken($callback_url);
|
36 |
+
|
37 |
+
switch ($connection->http_code) {
|
38 |
+
case 200 :
|
39 |
+
Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
|
40 |
+
Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
|
41 |
+
|
42 |
+
$url = $connection->getAuthorizeURL($request_token['oauth_token']);
|
43 |
+
|
44 |
+
return $this->_redirectUrl($url);
|
45 |
+
break;
|
46 |
+
default :
|
47 |
+
$this->getSession()->addError($this->__('Could not connect to Tumblr. Refresh the page or try again later.'));
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->_redirectUrl();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function callbackAction() {
|
54 |
+
$oauth_token = $this->getRequest()->getParam('oauth_token');
|
55 |
+
$oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
|
56 |
+
|
57 |
+
if (!$oauth_token || !$oauth_verifier) {
|
58 |
+
return $this->_redirectUrl();
|
59 |
+
}
|
60 |
+
|
61 |
+
if ($oauth_token != Mage::getSingleton('core/session')->getData('oauth_token')) {
|
62 |
+
return $this->_redirectUrl();
|
63 |
+
}
|
64 |
+
|
65 |
+
$connection = new TumblrOAuth(
|
66 |
+
Mage::getStoreConfig('gomage_social/tumblr/id'),
|
67 |
+
Mage::getStoreConfig('gomage_social/tumblr/secret'),
|
68 |
+
Mage::getSingleton('core/session')->getData('oauth_token'),
|
69 |
+
Mage::getSingleton('core/session')->getData('oauth_token_secret')
|
70 |
+
);
|
71 |
+
$access_token = $connection->getAccessToken($oauth_verifier);
|
72 |
+
|
73 |
+
Mage::getSingleton('core/session')->unsetData('oauth_token');
|
74 |
+
Mage::getSingleton('core/session')->unsetData('oauth_token_secret');
|
75 |
+
|
76 |
+
$profile = null;
|
77 |
+
|
78 |
+
switch ($connection->http_code) {
|
79 |
+
case 200 :
|
80 |
+
$profile = $connection->get("http://api.tumblr.com/v2/user/info");
|
81 |
+
|
82 |
+
break;
|
83 |
+
default :
|
84 |
+
$this->getSession()->addError($this->__('Could not connect to Tumblr. Refresh the page or try again later.'));
|
85 |
+
|
86 |
+
return $this->_redirectUrl();
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($profile) {
|
90 |
+
$profile->name = $profile->response->user->name;
|
91 |
+
$profile->id = $profile->name;
|
92 |
+
|
93 |
+
if ($profile->id) {
|
94 |
+
$social_collection = Mage::getModel('gomage_social/entity')
|
95 |
+
->getCollection()
|
96 |
+
->addFieldToFilter('social_id', $profile->id)
|
97 |
+
->addFieldToFilter('type_id', GoMage_Social_Model_Type::TUMBLR);
|
98 |
+
|
99 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
100 |
+
$social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
|
101 |
+
}
|
102 |
+
|
103 |
+
$social = $social_collection->getFirstItem();
|
104 |
+
|
105 |
+
if ($social && $social->getId()) {
|
106 |
+
if ($social->social_id == $profile->id) {
|
107 |
+
$customer = Mage::getModel('customer/customer');
|
108 |
+
|
109 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
110 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
111 |
+
}
|
112 |
+
|
113 |
+
$customer->load($social->getData('customer_id'));
|
114 |
+
|
115 |
+
if ($customer && $customer->getId()) {
|
116 |
+
if (!$customer->getConfirmation()) {
|
117 |
+
$this->getSession()->loginById($customer->getId());
|
118 |
+
} else {
|
119 |
+
$this->getSession()->addError($this->__('This account is not confirmed.'));
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
$profile->url = Mage::getUrl('gomage_social/tumblr/checkEmail', array('_secure' => true));
|
125 |
+
$profile->urlEmailClose = Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => true));
|
126 |
+
$profile->type_id = GoMage_Social_Model_Type::TUMBLR;
|
127 |
+
|
128 |
+
Mage::getSingleton('core/session')->setGsProfile($profile);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
return $this->_redirectUrl();
|
134 |
+
}
|
135 |
+
}
|
app/code/local/GoMage/Social/controllers/TwitterController.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Twitter' . DS . 'twitteroauth.php');
|
15 |
+
|
16 |
+
class GoMage_Social_TwitterController extends GoMage_Social_Controller_SocialNoMail {
|
17 |
+
|
18 |
+
public function getSocialType() {
|
19 |
+
return GoMage_Social_Model_Type::TWITTER;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function loginAction() {
|
23 |
+
if ($this->getSession()->isLoggedIn()) {
|
24 |
+
return $this->_redirectUrl();
|
25 |
+
}
|
26 |
+
|
27 |
+
$connection = new TwitterOAuth(Mage::getStoreConfig('gomage_social/twitter/id'), Mage::getStoreConfig('gomage_social/twitter/secret'));
|
28 |
+
$callback_params = array('_secure' => true);
|
29 |
+
|
30 |
+
if ($this->getRequest()->getParam('gs_url', '')) {
|
31 |
+
$callback_params['gs_url'] = $this->getRequest()->getParam('gs_url');
|
32 |
+
}
|
33 |
+
|
34 |
+
$callback_url = Mage::getUrl('gomage_social/twitter/callback', $callback_params);
|
35 |
+
$request_token = $connection->getRequestToken($callback_url);
|
36 |
+
|
37 |
+
switch ($connection->http_code) {
|
38 |
+
case 200 :
|
39 |
+
Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
|
40 |
+
Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
|
41 |
+
|
42 |
+
$url = $connection->getAuthorizeURL($request_token['oauth_token']);
|
43 |
+
|
44 |
+
return $this->_redirectUrl($url);
|
45 |
+
break;
|
46 |
+
default :
|
47 |
+
$this->getSession()->addError($this->__('Could not connect to Twitter. Refresh the page or try again later.'));
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->_redirectUrl();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function callbackAction() {
|
54 |
+
$oauth_token = $this->getRequest()->getParam('oauth_token');
|
55 |
+
$oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
|
56 |
+
|
57 |
+
if (!$oauth_token || !$oauth_verifier) {
|
58 |
+
return $this->_redirectUrl();
|
59 |
+
}
|
60 |
+
|
61 |
+
if ($oauth_token != Mage::getSingleton('core/session')->getData('oauth_token')){
|
62 |
+
return $this->_redirectUrl();
|
63 |
+
}
|
64 |
+
|
65 |
+
$connection = new TwitterOAuth(
|
66 |
+
Mage::getStoreConfig('gomage_social/twitter/id'),
|
67 |
+
Mage::getStoreConfig('gomage_social/twitter/secret'),
|
68 |
+
Mage::getSingleton('core/session')->getData('oauth_token'),
|
69 |
+
Mage::getSingleton('core/session')->getData('oauth_token_secret')
|
70 |
+
);
|
71 |
+
$access_token = $connection->getAccessToken($oauth_verifier);
|
72 |
+
|
73 |
+
Mage::getSingleton('core/session')->unsetData('oauth_token');
|
74 |
+
Mage::getSingleton('core/session')->unsetData('oauth_token_secret');
|
75 |
+
|
76 |
+
$profile = null;
|
77 |
+
|
78 |
+
switch ($connection->http_code) {
|
79 |
+
case 200:
|
80 |
+
$profile = $connection->get('account/verify_credentials');
|
81 |
+
break;
|
82 |
+
default:
|
83 |
+
$this->getSession()->addError($this->__('Could not connect to Twitter. Refresh the page or try again later.'));
|
84 |
+
|
85 |
+
return $this->_redirectUrl();
|
86 |
+
}
|
87 |
+
|
88 |
+
if ($profile) {
|
89 |
+
if ($profile->id) {
|
90 |
+
$social_collection = Mage::getModel('gomage_social/entity')
|
91 |
+
->getCollection()
|
92 |
+
->addFieldToFilter('social_id', $profile->id)
|
93 |
+
->addFieldToFilter('type_id', GoMage_Social_Model_Type::TWITTER);
|
94 |
+
|
95 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
96 |
+
$social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
|
97 |
+
}
|
98 |
+
|
99 |
+
$social = $social_collection->getFirstItem();
|
100 |
+
|
101 |
+
if ($social && $social->getId()) {
|
102 |
+
if ($social->social_id == $profile->id) {
|
103 |
+
$customer = Mage::getModel('customer/customer');
|
104 |
+
|
105 |
+
if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
|
106 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
107 |
+
}
|
108 |
+
|
109 |
+
$customer->load($social->getData('customer_id'));
|
110 |
+
|
111 |
+
if ($customer && $customer->getId()) {
|
112 |
+
if (!$customer->getConfirmation()) {
|
113 |
+
$this->getSession()->loginById($customer->getId());
|
114 |
+
} else {
|
115 |
+
$this->getSession()->addError($this->__('This account is not confirmed.'));
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
} else {
|
120 |
+
$profile->url = Mage::getUrl('gomage_social/twitter/checkEmail', array('_secure' => true));
|
121 |
+
$profile->urlEmailClose = Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => true));
|
122 |
+
$profile->type_id = GoMage_Social_Model_Type::TWITTER;
|
123 |
+
|
124 |
+
Mage::getSingleton('core/session')->setGsProfile($profile);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return $this->_redirectUrl();
|
130 |
+
}
|
131 |
+
}
|
app/code/local/GoMage/Social/etc/adminhtml.xml
CHANGED
@@ -4,12 +4,12 @@
|
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
-
* @version Release: 1.0
|
12 |
-
* @since Class available since Release 1.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
@@ -32,4 +32,23 @@
|
|
32 |
</admin>
|
33 |
</resources>
|
34 |
</acl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
</config>
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
+
* @version Release: 1.2.0
|
12 |
+
* @since Class available since Release 1.0.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
32 |
</admin>
|
33 |
</resources>
|
34 |
</acl>
|
35 |
+
<acl>
|
36 |
+
<resources>
|
37 |
+
<admin>
|
38 |
+
<children>
|
39 |
+
<system>
|
40 |
+
<children>
|
41 |
+
<config>
|
42 |
+
<children>
|
43 |
+
<gomage_notification>
|
44 |
+
<title>GoMage - Notifications</title>
|
45 |
+
</gomage_notification>
|
46 |
+
</children>
|
47 |
+
</config>
|
48 |
+
</children>
|
49 |
+
</system>
|
50 |
+
</children>
|
51 |
+
</admin>
|
52 |
+
</resources>
|
53 |
+
</acl>
|
54 |
</config>
|
app/code/local/GoMage/Social/etc/config.xml
CHANGED
@@ -4,18 +4,18 @@
|
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
-
* @version Release: 1.0
|
12 |
-
* @since Class available since Release 1.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
16 |
<modules>
|
17 |
<GoMage_Social>
|
18 |
-
<version>1.
|
19 |
</GoMage_Social>
|
20 |
</modules>
|
21 |
<frontend>
|
@@ -62,6 +62,17 @@
|
|
62 |
<class>GoMage_Social_Block</class>
|
63 |
</gomage_social>
|
64 |
</blocks>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
<models>
|
66 |
<gomage_social>
|
67 |
<class>GoMage_Social_Model</class>
|
@@ -133,11 +144,47 @@
|
|
133 |
<text>Login with Google</text>
|
134 |
<order>3</order>
|
135 |
</google>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
<information>
|
137 |
<text>
|
138 |
-
<![CDATA[<h2>GoMage Extensions</h2
|
|
|
139 |
</text>
|
140 |
</information>
|
141 |
</gomage_social>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
</default>
|
143 |
</config>
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
+
* @version Release: 1.2.0
|
12 |
+
* @since Class available since Release 1.0.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
16 |
<modules>
|
17 |
<GoMage_Social>
|
18 |
+
<version>1.2.0</version>
|
19 |
</GoMage_Social>
|
20 |
</modules>
|
21 |
<frontend>
|
62 |
<class>GoMage_Social_Block</class>
|
63 |
</gomage_social>
|
64 |
</blocks>
|
65 |
+
<events>
|
66 |
+
<customer_login>
|
67 |
+
<observers>
|
68 |
+
<gomage_social_customer_login>
|
69 |
+
<type>singleton</type>
|
70 |
+
<class>gomage_social/observer</class>
|
71 |
+
<method>GSCustomerLoggedIn</method>
|
72 |
+
</gomage_social_customer_login>
|
73 |
+
</observers>
|
74 |
+
</customer_login>
|
75 |
+
</events>
|
76 |
<models>
|
77 |
<gomage_social>
|
78 |
<class>GoMage_Social_Model</class>
|
144 |
<text>Login with Google</text>
|
145 |
<order>3</order>
|
146 |
</google>
|
147 |
+
<twitter>
|
148 |
+
<fast_links_type>1</fast_links_type>
|
149 |
+
<login_type>1</login_type>
|
150 |
+
<checkout_type>1</checkout_type>
|
151 |
+
<text>Login with Twitter</text>
|
152 |
+
<order>4</order>
|
153 |
+
</twitter>
|
154 |
+
<tumblr>
|
155 |
+
<fast_links_type>1</fast_links_type>
|
156 |
+
<login_type>1</login_type>
|
157 |
+
<checkout_type>1</checkout_type>
|
158 |
+
<text>Login with Tumblr</text>
|
159 |
+
<order>5</order>
|
160 |
+
</tumblr>
|
161 |
+
<reddit>
|
162 |
+
<fast_links_type>1</fast_links_type>
|
163 |
+
<login_type>1</login_type>
|
164 |
+
<checkout_type>1</checkout_type>
|
165 |
+
<text>Login with Reddit</text>
|
166 |
+
<order>6</order>
|
167 |
+
</reddit>
|
168 |
+
<amazon>
|
169 |
+
<fast_links_type>1</fast_links_type>
|
170 |
+
<login_type>1</login_type>
|
171 |
+
<checkout_type>1</checkout_type>
|
172 |
+
<text>Login with Amazon</text>
|
173 |
+
<order>7</order>
|
174 |
+
</amazon>
|
175 |
<information>
|
176 |
<text>
|
177 |
+
<![CDATA[<h2>GoMage Extensions</h2>
|
178 |
+
<p><a href="http://www.gomage.com/extensions/gomage-lightcheckout.html"><img title="GoMage LightCheckout - only one step on the checkout page" src="http://www.gomage.com/media/magentoconnect_image/lightcheckout.png" alt="GoMage LightCheckout" /></a> <a href="http://www.gomage.com/extensions/gomage-feed-pro.html"><img title="GoMage Feed Pro - send your product data to all Search Engines you know" src="http://www.gomage.com/media/magentoconnect_image/feed_pro.png" alt="GoMage Feed Pro" /></a> <a href="http://www.gomage.com/extensions/gomage-advanced-navigation.html"><img title="GoMage Advanced Navigation - helps you to optimize and improve navigation on your site" src="http://www.gomage.com/media/magentoconnect_image/advanced_navigation.png" alt="GoMage Advanced Navigation" /></a> <a href="http://www.gomage.com/extensions/promo.html"><img title="GoMage Ads & Promo - simple, flexible, yet powerful solution for advertising and promoting your products" src="http://www.gomage.com/media/magentoconnect_image/ads_and_promo.png" alt="GoMage Ads & Promo" /></a> <a href="http://www.gomage.com/extensions/procart.html"><img title="GoMage ProCart - allows your customers to add products to cart without page reloading or redirecting" src="http://www.gomage.com/media/magentoconnect_image/procart.png" alt="GoMage ProCart" /></a> <a href="http://www.gomage.com/extensions/gomage-sales-and-deals.html"><img title="GoMage Sales and Deals extension is all about providing the best deals for your customers" src="http://www.gomage.com/media/magentoconnect_image/sales_and_deals.png" alt="GoMage Sales and Deals" /></a> <a href="https://www.gomage.com/extensions/gomage-product-designer.html"><img title="GoMage Product Designer the superior extension for Magento which will help you to personalize the products using, cliparts, texts and uploading images" src="https://www.gomage.com/media/magentoconnect_image/product_designer.png" alt="GoMage Product Designer" /></a> <a href="https://www.gomage. com/extensions/gomage-seo-booster.html"><img title="The GoMage SEO Booster extension helps you improve the search engine optimization and the visibility of your store in the search engines' results without any technical knowledge" src="http://www.gomage.com/media/magentoconnect_image/seo_booster.png" alt="GoMage SEO Booster" /></a></p>]]>
|
179 |
</text>
|
180 |
</information>
|
181 |
</gomage_social>
|
182 |
+
|
183 |
+
<gomage_notification>
|
184 |
+
<notification>
|
185 |
+
<enable>1</enable>
|
186 |
+
</notification>
|
187 |
+
</gomage_notification>
|
188 |
+
|
189 |
</default>
|
190 |
</config>
|
app/code/local/GoMage/Social/etc/system.xml
CHANGED
@@ -4,12 +4,12 @@
|
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
-
* @version Release: 1.0
|
12 |
-
* @since Class available since Release 1.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
@@ -21,7 +21,7 @@
|
|
21 |
</tabs>
|
22 |
<sections>
|
23 |
<gomage_social>
|
24 |
-
<label>Social Connector v.1.
|
25 |
<tab>gomage</tab>
|
26 |
<frontend_type>text</frontend_type>
|
27 |
<sort_order>250</sort_order>
|
@@ -86,7 +86,7 @@
|
|
86 |
</fields>
|
87 |
</general>
|
88 |
<facebook translate="label">
|
89 |
-
<label>
|
90 |
<frontend_type>text</frontend_type>
|
91 |
<sort_order>10</sort_order>
|
92 |
<show_in_default>1</show_in_default>
|
@@ -103,7 +103,7 @@
|
|
103 |
<show_in_store>1</show_in_store>
|
104 |
</enable>
|
105 |
<id>
|
106 |
-
<label>Application
|
107 |
<frontend_type>text</frontend_type>
|
108 |
<sort_order>20</sort_order>
|
109 |
<show_in_default>1</show_in_default>
|
@@ -111,7 +111,7 @@
|
|
111 |
<show_in_store>1</show_in_store>
|
112 |
</id>
|
113 |
<secret>
|
114 |
-
<label>
|
115 |
<frontend_type>text</frontend_type>
|
116 |
<sort_order>30</sort_order>
|
117 |
<show_in_default>1</show_in_default>
|
@@ -119,7 +119,7 @@
|
|
119 |
<show_in_store>1</show_in_store>
|
120 |
</secret>
|
121 |
<fast_links_type>
|
122 |
-
<label>Fast Links
|
123 |
<frontend_type>select</frontend_type>
|
124 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
|
125 |
<sort_order>40</sort_order>
|
@@ -128,7 +128,7 @@
|
|
128 |
<show_in_store>1</show_in_store>
|
129 |
</fast_links_type>
|
130 |
<login_type>
|
131 |
-
<label>Login Page
|
132 |
<frontend_type>select</frontend_type>
|
133 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
|
134 |
<sort_order>43</sort_order>
|
@@ -137,7 +137,7 @@
|
|
137 |
<show_in_store>1</show_in_store>
|
138 |
</login_type>
|
139 |
<checkout_type>
|
140 |
-
<label>Checkout
|
141 |
<frontend_type>select</frontend_type>
|
142 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
|
143 |
<sort_order>46</sort_order>
|
@@ -191,8 +191,17 @@
|
|
191 |
<show_in_website>1</show_in_website>
|
192 |
<show_in_store>1</show_in_store>
|
193 |
</enable>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
<id>
|
195 |
-
<label>API
|
196 |
<frontend_type>text</frontend_type>
|
197 |
<sort_order>20</sort_order>
|
198 |
<show_in_default>1</show_in_default>
|
@@ -208,7 +217,7 @@
|
|
208 |
<show_in_store>1</show_in_store>
|
209 |
</secret>
|
210 |
<fast_links_type>
|
211 |
-
<label>Fast Links
|
212 |
<frontend_type>select</frontend_type>
|
213 |
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
214 |
<sort_order>40</sort_order>
|
@@ -217,7 +226,7 @@
|
|
217 |
<show_in_store>1</show_in_store>
|
218 |
</fast_links_type>
|
219 |
<login_type>
|
220 |
-
<label>Login Page
|
221 |
<frontend_type>select</frontend_type>
|
222 |
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
223 |
<sort_order>43</sort_order>
|
@@ -226,7 +235,7 @@
|
|
226 |
<show_in_store>1</show_in_store>
|
227 |
</login_type>
|
228 |
<checkout_type>
|
229 |
-
<label>Checkout
|
230 |
<frontend_type>select</frontend_type>
|
231 |
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
232 |
<sort_order>46</sort_order>
|
@@ -280,6 +289,15 @@
|
|
280 |
<show_in_website>1</show_in_website>
|
281 |
<show_in_store>1</show_in_store>
|
282 |
</enable>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
<id>
|
284 |
<label>Client ID</label>
|
285 |
<frontend_type>text</frontend_type>
|
@@ -289,7 +307,7 @@
|
|
289 |
<show_in_store>1</show_in_store>
|
290 |
</id>
|
291 |
<secret>
|
292 |
-
<label>Client
|
293 |
<frontend_type>text</frontend_type>
|
294 |
<sort_order>30</sort_order>
|
295 |
<show_in_default>1</show_in_default>
|
@@ -297,7 +315,7 @@
|
|
297 |
<show_in_store>1</show_in_store>
|
298 |
</secret>
|
299 |
<api>
|
300 |
-
<label>API
|
301 |
<frontend_type>text</frontend_type>
|
302 |
<sort_order>40</sort_order>
|
303 |
<show_in_default>1</show_in_default>
|
@@ -305,7 +323,7 @@
|
|
305 |
<show_in_store>1</show_in_store>
|
306 |
</api>
|
307 |
<fast_links_type>
|
308 |
-
<label>Fast Links
|
309 |
<frontend_type>select</frontend_type>
|
310 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
|
311 |
<sort_order>50</sort_order>
|
@@ -314,7 +332,7 @@
|
|
314 |
<show_in_store>1</show_in_store>
|
315 |
</fast_links_type>
|
316 |
<login_type>
|
317 |
-
<label>Login Page
|
318 |
<frontend_type>select</frontend_type>
|
319 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
|
320 |
<sort_order>53</sort_order>
|
@@ -323,7 +341,7 @@
|
|
323 |
<show_in_store>1</show_in_store>
|
324 |
</login_type>
|
325 |
<checkout_type>
|
326 |
-
<label>Checkout
|
327 |
<frontend_type>select</frontend_type>
|
328 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
|
329 |
<sort_order>56</sort_order>
|
@@ -359,8 +377,433 @@
|
|
359 |
<show_in_store>1</show_in_store>
|
360 |
</order>
|
361 |
</fields>
|
362 |
-
</google>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
</groups>
|
364 |
</gomage_social>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
</sections>
|
366 |
</config>
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
+
* @version Release: 1.2.0
|
12 |
+
* @since Class available since Release 1.0.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
21 |
</tabs>
|
22 |
<sections>
|
23 |
<gomage_social>
|
24 |
+
<label>Social Connector v.1.2</label>
|
25 |
<tab>gomage</tab>
|
26 |
<frontend_type>text</frontend_type>
|
27 |
<sort_order>250</sort_order>
|
86 |
</fields>
|
87 |
</general>
|
88 |
<facebook translate="label">
|
89 |
+
<label>Facebook</label>
|
90 |
<frontend_type>text</frontend_type>
|
91 |
<sort_order>10</sort_order>
|
92 |
<show_in_default>1</show_in_default>
|
103 |
<show_in_store>1</show_in_store>
|
104 |
</enable>
|
105 |
<id>
|
106 |
+
<label>Application API</label>
|
107 |
<frontend_type>text</frontend_type>
|
108 |
<sort_order>20</sort_order>
|
109 |
<show_in_default>1</show_in_default>
|
111 |
<show_in_store>1</show_in_store>
|
112 |
</id>
|
113 |
<secret>
|
114 |
+
<label>Secret Key</label>
|
115 |
<frontend_type>text</frontend_type>
|
116 |
<sort_order>30</sort_order>
|
117 |
<show_in_default>1</show_in_default>
|
119 |
<show_in_store>1</show_in_store>
|
120 |
</secret>
|
121 |
<fast_links_type>
|
122 |
+
<label>Fast Links View</label>
|
123 |
<frontend_type>select</frontend_type>
|
124 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
|
125 |
<sort_order>40</sort_order>
|
128 |
<show_in_store>1</show_in_store>
|
129 |
</fast_links_type>
|
130 |
<login_type>
|
131 |
+
<label>Login Page View</label>
|
132 |
<frontend_type>select</frontend_type>
|
133 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
|
134 |
<sort_order>43</sort_order>
|
137 |
<show_in_store>1</show_in_store>
|
138 |
</login_type>
|
139 |
<checkout_type>
|
140 |
+
<label>Checkout View</label>
|
141 |
<frontend_type>select</frontend_type>
|
142 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
|
143 |
<sort_order>46</sort_order>
|
191 |
<show_in_website>1</show_in_website>
|
192 |
<show_in_store>1</show_in_store>
|
193 |
</enable>
|
194 |
+
<redirect_uri>
|
195 |
+
<label>Redirect Uri</label>
|
196 |
+
<frontend_type>text</frontend_type>
|
197 |
+
<frontend_model>gomage_social/adminhtml_system_config_redirectUri_linkedin</frontend_model>
|
198 |
+
<sort_order>11</sort_order>
|
199 |
+
<show_in_default>1</show_in_default>
|
200 |
+
<show_in_website>1</show_in_website>
|
201 |
+
<show_in_store>1</show_in_store>
|
202 |
+
</redirect_uri>
|
203 |
<id>
|
204 |
+
<label>API Key</label>
|
205 |
<frontend_type>text</frontend_type>
|
206 |
<sort_order>20</sort_order>
|
207 |
<show_in_default>1</show_in_default>
|
217 |
<show_in_store>1</show_in_store>
|
218 |
</secret>
|
219 |
<fast_links_type>
|
220 |
+
<label>Fast Links View</label>
|
221 |
<frontend_type>select</frontend_type>
|
222 |
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
223 |
<sort_order>40</sort_order>
|
226 |
<show_in_store>1</show_in_store>
|
227 |
</fast_links_type>
|
228 |
<login_type>
|
229 |
+
<label>Login Page View</label>
|
230 |
<frontend_type>select</frontend_type>
|
231 |
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
232 |
<sort_order>43</sort_order>
|
235 |
<show_in_store>1</show_in_store>
|
236 |
</login_type>
|
237 |
<checkout_type>
|
238 |
+
<label>Checkout View</label>
|
239 |
<frontend_type>select</frontend_type>
|
240 |
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
241 |
<sort_order>46</sort_order>
|
289 |
<show_in_website>1</show_in_website>
|
290 |
<show_in_store>1</show_in_store>
|
291 |
</enable>
|
292 |
+
<redirect_uri>
|
293 |
+
<label>Redirect Uri</label>
|
294 |
+
<frontend_type>text</frontend_type>
|
295 |
+
<frontend_model>gomage_social/adminhtml_system_config_redirectUri_google</frontend_model>
|
296 |
+
<sort_order>11</sort_order>
|
297 |
+
<show_in_default>1</show_in_default>
|
298 |
+
<show_in_website>1</show_in_website>
|
299 |
+
<show_in_store>1</show_in_store>
|
300 |
+
</redirect_uri>
|
301 |
<id>
|
302 |
<label>Client ID</label>
|
303 |
<frontend_type>text</frontend_type>
|
307 |
<show_in_store>1</show_in_store>
|
308 |
</id>
|
309 |
<secret>
|
310 |
+
<label>Client Secret</label>
|
311 |
<frontend_type>text</frontend_type>
|
312 |
<sort_order>30</sort_order>
|
313 |
<show_in_default>1</show_in_default>
|
315 |
<show_in_store>1</show_in_store>
|
316 |
</secret>
|
317 |
<api>
|
318 |
+
<label>API Key</label>
|
319 |
<frontend_type>text</frontend_type>
|
320 |
<sort_order>40</sort_order>
|
321 |
<show_in_default>1</show_in_default>
|
323 |
<show_in_store>1</show_in_store>
|
324 |
</api>
|
325 |
<fast_links_type>
|
326 |
+
<label>Fast Links View</label>
|
327 |
<frontend_type>select</frontend_type>
|
328 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
|
329 |
<sort_order>50</sort_order>
|
332 |
<show_in_store>1</show_in_store>
|
333 |
</fast_links_type>
|
334 |
<login_type>
|
335 |
+
<label>Login Page View</label>
|
336 |
<frontend_type>select</frontend_type>
|
337 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
|
338 |
<sort_order>53</sort_order>
|
341 |
<show_in_store>1</show_in_store>
|
342 |
</login_type>
|
343 |
<checkout_type>
|
344 |
+
<label>Checkout View</label>
|
345 |
<frontend_type>select</frontend_type>
|
346 |
<source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
|
347 |
<sort_order>56</sort_order>
|
377 |
<show_in_store>1</show_in_store>
|
378 |
</order>
|
379 |
</fields>
|
380 |
+
</google>
|
381 |
+
<twitter translate="label">
|
382 |
+
<label>Twitter</label>
|
383 |
+
<frontend_type>text</frontend_type>
|
384 |
+
<sort_order>40</sort_order>
|
385 |
+
<show_in_default>1</show_in_default>
|
386 |
+
<show_in_website>1</show_in_website>
|
387 |
+
<show_in_store>1</show_in_store>
|
388 |
+
<fields>
|
389 |
+
<enable>
|
390 |
+
<label>Enable</label>
|
391 |
+
<frontend_type>select</frontend_type>
|
392 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
393 |
+
<sort_order>10</sort_order>
|
394 |
+
<show_in_default>1</show_in_default>
|
395 |
+
<show_in_website>1</show_in_website>
|
396 |
+
<show_in_store>1</show_in_store>
|
397 |
+
</enable>
|
398 |
+
<redirect_uri>
|
399 |
+
<label>Redirect Uri</label>
|
400 |
+
<frontend_type>text</frontend_type>
|
401 |
+
<frontend_model>gomage_social/adminhtml_system_config_redirectUri_twitter</frontend_model>
|
402 |
+
<sort_order>11</sort_order>
|
403 |
+
<show_in_default>1</show_in_default>
|
404 |
+
<show_in_website>1</show_in_website>
|
405 |
+
<show_in_store>1</show_in_store>
|
406 |
+
</redirect_uri>
|
407 |
+
<id>
|
408 |
+
<label>Application API</label>
|
409 |
+
<frontend_type>text</frontend_type>
|
410 |
+
<sort_order>20</sort_order>
|
411 |
+
<show_in_default>1</show_in_default>
|
412 |
+
<show_in_website>1</show_in_website>
|
413 |
+
<show_in_store>1</show_in_store>
|
414 |
+
</id>
|
415 |
+
<secret>
|
416 |
+
<label>Secret Key</label>
|
417 |
+
<frontend_type>text</frontend_type>
|
418 |
+
<sort_order>30</sort_order>
|
419 |
+
<show_in_default>1</show_in_default>
|
420 |
+
<show_in_website>1</show_in_website>
|
421 |
+
<show_in_store>1</show_in_store>
|
422 |
+
</secret>
|
423 |
+
<fast_links_type>
|
424 |
+
<label>Fast Links View</label>
|
425 |
+
<frontend_type>select</frontend_type>
|
426 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
427 |
+
<sort_order>40</sort_order>
|
428 |
+
<show_in_default>1</show_in_default>
|
429 |
+
<show_in_website>1</show_in_website>
|
430 |
+
<show_in_store>1</show_in_store>
|
431 |
+
</fast_links_type>
|
432 |
+
<login_type>
|
433 |
+
<label>Login Page View</label>
|
434 |
+
<frontend_type>select</frontend_type>
|
435 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
436 |
+
<sort_order>43</sort_order>
|
437 |
+
<show_in_default>1</show_in_default>
|
438 |
+
<show_in_website>1</show_in_website>
|
439 |
+
<show_in_store>1</show_in_store>
|
440 |
+
</login_type>
|
441 |
+
<checkout_type>
|
442 |
+
<label>Checkout View</label>
|
443 |
+
<frontend_type>select</frontend_type>
|
444 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
445 |
+
<sort_order>46</sort_order>
|
446 |
+
<show_in_default>1</show_in_default>
|
447 |
+
<show_in_website>1</show_in_website>
|
448 |
+
<show_in_store>1</show_in_store>
|
449 |
+
</checkout_type>
|
450 |
+
<image>
|
451 |
+
<label>Login Image</label>
|
452 |
+
<frontend_type>image</frontend_type>
|
453 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
454 |
+
<upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
|
455 |
+
<base_url type="media" scope_info="1">gomage/social</base_url>
|
456 |
+
<sort_order>50</sort_order>
|
457 |
+
<show_in_default>1</show_in_default>
|
458 |
+
<show_in_website>1</show_in_website>
|
459 |
+
<show_in_store>1</show_in_store>
|
460 |
+
</image>
|
461 |
+
<text>
|
462 |
+
<label>Login Text</label>
|
463 |
+
<frontend_type>text</frontend_type>
|
464 |
+
<sort_order>60</sort_order>
|
465 |
+
<show_in_default>1</show_in_default>
|
466 |
+
<show_in_website>1</show_in_website>
|
467 |
+
<show_in_store>1</show_in_store>
|
468 |
+
</text>
|
469 |
+
<order>
|
470 |
+
<label>Sort Order</label>
|
471 |
+
<frontend_type>text</frontend_type>
|
472 |
+
<sort_order>70</sort_order>
|
473 |
+
<show_in_default>1</show_in_default>
|
474 |
+
<show_in_website>1</show_in_website>
|
475 |
+
<show_in_store>1</show_in_store>
|
476 |
+
</order>
|
477 |
+
</fields>
|
478 |
+
</twitter>
|
479 |
+
<tumblr translate="label">
|
480 |
+
<label>Tumblr</label>
|
481 |
+
<frontend_type>text</frontend_type>
|
482 |
+
<sort_order>50</sort_order>
|
483 |
+
<show_in_default>1</show_in_default>
|
484 |
+
<show_in_website>1</show_in_website>
|
485 |
+
<show_in_store>1</show_in_store>
|
486 |
+
<fields>
|
487 |
+
<enable>
|
488 |
+
<label>Enable</label>
|
489 |
+
<frontend_type>select</frontend_type>
|
490 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
491 |
+
<sort_order>10</sort_order>
|
492 |
+
<show_in_default>1</show_in_default>
|
493 |
+
<show_in_website>1</show_in_website>
|
494 |
+
<show_in_store>1</show_in_store>
|
495 |
+
</enable>
|
496 |
+
<redirect_uri>
|
497 |
+
<label>Redirect Uri</label>
|
498 |
+
<frontend_type>text</frontend_type>
|
499 |
+
<frontend_model>gomage_social/adminhtml_system_config_redirectUri_tumblr</frontend_model>
|
500 |
+
<sort_order>11</sort_order>
|
501 |
+
<show_in_default>1</show_in_default>
|
502 |
+
<show_in_website>1</show_in_website>
|
503 |
+
<show_in_store>1</show_in_store>
|
504 |
+
</redirect_uri>
|
505 |
+
<id>
|
506 |
+
<label>Application API</label>
|
507 |
+
<frontend_type>text</frontend_type>
|
508 |
+
<sort_order>20</sort_order>
|
509 |
+
<show_in_default>1</show_in_default>
|
510 |
+
<show_in_website>1</show_in_website>
|
511 |
+
<show_in_store>1</show_in_store>
|
512 |
+
</id>
|
513 |
+
<secret>
|
514 |
+
<label>Secret Key</label>
|
515 |
+
<frontend_type>text</frontend_type>
|
516 |
+
<sort_order>30</sort_order>
|
517 |
+
<show_in_default>1</show_in_default>
|
518 |
+
<show_in_website>1</show_in_website>
|
519 |
+
<show_in_store>1</show_in_store>
|
520 |
+
</secret>
|
521 |
+
<fast_links_type>
|
522 |
+
<label>Fast Links View</label>
|
523 |
+
<frontend_type>select</frontend_type>
|
524 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
525 |
+
<sort_order>40</sort_order>
|
526 |
+
<show_in_default>1</show_in_default>
|
527 |
+
<show_in_website>1</show_in_website>
|
528 |
+
<show_in_store>1</show_in_store>
|
529 |
+
</fast_links_type>
|
530 |
+
<login_type>
|
531 |
+
<label>Login Page View</label>
|
532 |
+
<frontend_type>select</frontend_type>
|
533 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
534 |
+
<sort_order>43</sort_order>
|
535 |
+
<show_in_default>1</show_in_default>
|
536 |
+
<show_in_website>1</show_in_website>
|
537 |
+
<show_in_store>1</show_in_store>
|
538 |
+
</login_type>
|
539 |
+
<checkout_type>
|
540 |
+
<label>Checkout View</label>
|
541 |
+
<frontend_type>select</frontend_type>
|
542 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
543 |
+
<sort_order>46</sort_order>
|
544 |
+
<show_in_default>1</show_in_default>
|
545 |
+
<show_in_website>1</show_in_website>
|
546 |
+
<show_in_store>1</show_in_store>
|
547 |
+
</checkout_type>
|
548 |
+
<image>
|
549 |
+
<label>Login Image</label>
|
550 |
+
<frontend_type>image</frontend_type>
|
551 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
552 |
+
<upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
|
553 |
+
<base_url type="media" scope_info="1">gomage/social</base_url>
|
554 |
+
<sort_order>50</sort_order>
|
555 |
+
<show_in_default>1</show_in_default>
|
556 |
+
<show_in_website>1</show_in_website>
|
557 |
+
<show_in_store>1</show_in_store>
|
558 |
+
</image>
|
559 |
+
<text>
|
560 |
+
<label>Login Text</label>
|
561 |
+
<frontend_type>text</frontend_type>
|
562 |
+
<sort_order>60</sort_order>
|
563 |
+
<show_in_default>1</show_in_default>
|
564 |
+
<show_in_website>1</show_in_website>
|
565 |
+
<show_in_store>1</show_in_store>
|
566 |
+
</text>
|
567 |
+
<order>
|
568 |
+
<label>Sort Order</label>
|
569 |
+
<frontend_type>text</frontend_type>
|
570 |
+
<sort_order>70</sort_order>
|
571 |
+
<show_in_default>1</show_in_default>
|
572 |
+
<show_in_website>1</show_in_website>
|
573 |
+
<show_in_store>1</show_in_store>
|
574 |
+
</order>
|
575 |
+
</fields>
|
576 |
+
</tumblr>
|
577 |
+
<reddit translate="label">
|
578 |
+
<label>Reddit</label>
|
579 |
+
<frontend_type>text</frontend_type>
|
580 |
+
<sort_order>60</sort_order>
|
581 |
+
<show_in_default>1</show_in_default>
|
582 |
+
<show_in_website>1</show_in_website>
|
583 |
+
<show_in_store>1</show_in_store>
|
584 |
+
<fields>
|
585 |
+
<enable>
|
586 |
+
<label>Enable</label>
|
587 |
+
<frontend_type>select</frontend_type>
|
588 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
589 |
+
<sort_order>10</sort_order>
|
590 |
+
<show_in_default>1</show_in_default>
|
591 |
+
<show_in_website>1</show_in_website>
|
592 |
+
<show_in_store>1</show_in_store>
|
593 |
+
</enable>
|
594 |
+
<redirect_uri>
|
595 |
+
<label>Redirect Uri</label>
|
596 |
+
<frontend_type>text</frontend_type>
|
597 |
+
<frontend_model>gomage_social/adminhtml_system_config_redirectUri_reddit</frontend_model>
|
598 |
+
<sort_order>11</sort_order>
|
599 |
+
<show_in_default>1</show_in_default>
|
600 |
+
<show_in_website>1</show_in_website>
|
601 |
+
<show_in_store>1</show_in_store>
|
602 |
+
</redirect_uri>
|
603 |
+
<id>
|
604 |
+
<label>Application API</label>
|
605 |
+
<frontend_type>text</frontend_type>
|
606 |
+
<sort_order>20</sort_order>
|
607 |
+
<show_in_default>1</show_in_default>
|
608 |
+
<show_in_website>1</show_in_website>
|
609 |
+
<show_in_store>1</show_in_store>
|
610 |
+
</id>
|
611 |
+
<secret>
|
612 |
+
<label>Secret Key</label>
|
613 |
+
<frontend_type>text</frontend_type>
|
614 |
+
<sort_order>30</sort_order>
|
615 |
+
<show_in_default>1</show_in_default>
|
616 |
+
<show_in_website>1</show_in_website>
|
617 |
+
<show_in_store>1</show_in_store>
|
618 |
+
</secret>
|
619 |
+
<fast_links_type>
|
620 |
+
<label>Fast Links View</label>
|
621 |
+
<frontend_type>select</frontend_type>
|
622 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
623 |
+
<sort_order>40</sort_order>
|
624 |
+
<show_in_default>1</show_in_default>
|
625 |
+
<show_in_website>1</show_in_website>
|
626 |
+
<show_in_store>1</show_in_store>
|
627 |
+
</fast_links_type>
|
628 |
+
<login_type>
|
629 |
+
<label>Login Page View</label>
|
630 |
+
<frontend_type>select</frontend_type>
|
631 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
632 |
+
<sort_order>43</sort_order>
|
633 |
+
<show_in_default>1</show_in_default>
|
634 |
+
<show_in_website>1</show_in_website>
|
635 |
+
<show_in_store>1</show_in_store>
|
636 |
+
</login_type>
|
637 |
+
<checkout_type>
|
638 |
+
<label>Checkout View</label>
|
639 |
+
<frontend_type>select</frontend_type>
|
640 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
641 |
+
<sort_order>46</sort_order>
|
642 |
+
<show_in_default>1</show_in_default>
|
643 |
+
<show_in_website>1</show_in_website>
|
644 |
+
<show_in_store>1</show_in_store>
|
645 |
+
</checkout_type>
|
646 |
+
<image>
|
647 |
+
<label>Login Image</label>
|
648 |
+
<frontend_type>image</frontend_type>
|
649 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
650 |
+
<upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
|
651 |
+
<base_url type="media" scope_info="1">gomage/social</base_url>
|
652 |
+
<sort_order>50</sort_order>
|
653 |
+
<show_in_default>1</show_in_default>
|
654 |
+
<show_in_website>1</show_in_website>
|
655 |
+
<show_in_store>1</show_in_store>
|
656 |
+
</image>
|
657 |
+
<text>
|
658 |
+
<label>Login Text</label>
|
659 |
+
<frontend_type>text</frontend_type>
|
660 |
+
<sort_order>60</sort_order>
|
661 |
+
<show_in_default>1</show_in_default>
|
662 |
+
<show_in_website>1</show_in_website>
|
663 |
+
<show_in_store>1</show_in_store>
|
664 |
+
</text>
|
665 |
+
<order>
|
666 |
+
<label>Sort Order</label>
|
667 |
+
<frontend_type>text</frontend_type>
|
668 |
+
<sort_order>70</sort_order>
|
669 |
+
<show_in_default>1</show_in_default>
|
670 |
+
<show_in_website>1</show_in_website>
|
671 |
+
<show_in_store>1</show_in_store>
|
672 |
+
</order>
|
673 |
+
</fields>
|
674 |
+
</reddit>
|
675 |
+
<amazon translate="label">
|
676 |
+
<label>Amazon</label>
|
677 |
+
<frontend_type>text</frontend_type>
|
678 |
+
<sort_order>70</sort_order>
|
679 |
+
<show_in_default>1</show_in_default>
|
680 |
+
<show_in_website>1</show_in_website>
|
681 |
+
<show_in_store>1</show_in_store>
|
682 |
+
<fields>
|
683 |
+
<enable>
|
684 |
+
<label>Enable</label>
|
685 |
+
<frontend_type>select</frontend_type>
|
686 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
687 |
+
<comment>
|
688 |
+
<![CDATA[Amazon uses the HTTPS protocol to access the system authorization. Please keep this in mind when registering and configuring applications.]]>
|
689 |
+
</comment>
|
690 |
+
<sort_order>10</sort_order>
|
691 |
+
<show_in_default>1</show_in_default>
|
692 |
+
<show_in_website>1</show_in_website>
|
693 |
+
<show_in_store>1</show_in_store>
|
694 |
+
</enable>
|
695 |
+
<redirect_uri>
|
696 |
+
<label>Redirect Uri</label>
|
697 |
+
<frontend_type>text</frontend_type>
|
698 |
+
<frontend_model>gomage_social/adminhtml_system_config_redirectUri_amazon</frontend_model>
|
699 |
+
<sort_order>11</sort_order>
|
700 |
+
<show_in_default>1</show_in_default>
|
701 |
+
<show_in_website>1</show_in_website>
|
702 |
+
<show_in_store>1</show_in_store>
|
703 |
+
</redirect_uri>
|
704 |
+
<id>
|
705 |
+
<label>Client ID</label>
|
706 |
+
<frontend_type>text</frontend_type>
|
707 |
+
<sort_order>20</sort_order>
|
708 |
+
<show_in_default>1</show_in_default>
|
709 |
+
<show_in_website>1</show_in_website>
|
710 |
+
<show_in_store>1</show_in_store>
|
711 |
+
</id>
|
712 |
+
<secret>
|
713 |
+
<label>Client Secret</label>
|
714 |
+
<frontend_type>text</frontend_type>
|
715 |
+
<sort_order>30</sort_order>
|
716 |
+
<show_in_default>1</show_in_default>
|
717 |
+
<show_in_website>1</show_in_website>
|
718 |
+
<show_in_store>1</show_in_store>
|
719 |
+
</secret>
|
720 |
+
<fast_links_type>
|
721 |
+
<label>Fast Links View</label>
|
722 |
+
<frontend_type>select</frontend_type>
|
723 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
724 |
+
<sort_order>40</sort_order>
|
725 |
+
<show_in_default>1</show_in_default>
|
726 |
+
<show_in_website>1</show_in_website>
|
727 |
+
<show_in_store>1</show_in_store>
|
728 |
+
</fast_links_type>
|
729 |
+
<login_type>
|
730 |
+
<label>Login Page View</label>
|
731 |
+
<frontend_type>select</frontend_type>
|
732 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
733 |
+
<sort_order>43</sort_order>
|
734 |
+
<show_in_default>1</show_in_default>
|
735 |
+
<show_in_website>1</show_in_website>
|
736 |
+
<show_in_store>1</show_in_store>
|
737 |
+
</login_type>
|
738 |
+
<checkout_type>
|
739 |
+
<label>Checkout View</label>
|
740 |
+
<frontend_type>select</frontend_type>
|
741 |
+
<source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
|
742 |
+
<sort_order>46</sort_order>
|
743 |
+
<show_in_default>1</show_in_default>
|
744 |
+
<show_in_website>1</show_in_website>
|
745 |
+
<show_in_store>1</show_in_store>
|
746 |
+
</checkout_type>
|
747 |
+
<image>
|
748 |
+
<label>Login Image</label>
|
749 |
+
<frontend_type>image</frontend_type>
|
750 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
751 |
+
<upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
|
752 |
+
<base_url type="media" scope_info="1">gomage/social</base_url>
|
753 |
+
<sort_order>50</sort_order>
|
754 |
+
<show_in_default>1</show_in_default>
|
755 |
+
<show_in_website>1</show_in_website>
|
756 |
+
<show_in_store>1</show_in_store>
|
757 |
+
</image>
|
758 |
+
<text>
|
759 |
+
<label>Login Text</label>
|
760 |
+
<frontend_type>text</frontend_type>
|
761 |
+
<sort_order>60</sort_order>
|
762 |
+
<show_in_default>1</show_in_default>
|
763 |
+
<show_in_website>1</show_in_website>
|
764 |
+
<show_in_store>1</show_in_store>
|
765 |
+
</text>
|
766 |
+
<order>
|
767 |
+
<label>Sort Order</label>
|
768 |
+
<frontend_type>text</frontend_type>
|
769 |
+
<sort_order>70</sort_order>
|
770 |
+
<show_in_default>1</show_in_default>
|
771 |
+
<show_in_website>1</show_in_website>
|
772 |
+
<show_in_store>1</show_in_store>
|
773 |
+
</order>
|
774 |
+
</fields>
|
775 |
+
</amazon>
|
776 |
</groups>
|
777 |
</gomage_social>
|
778 |
+
<gomage_notification>
|
779 |
+
<label>Notifications</label>
|
780 |
+
<tab>gomage</tab>
|
781 |
+
<frontend_type>text</frontend_type>
|
782 |
+
<sort_order>1100</sort_order>
|
783 |
+
<show_in_default>1</show_in_default>
|
784 |
+
<show_in_website>0</show_in_website>
|
785 |
+
<show_in_store>0</show_in_store>
|
786 |
+
<groups>
|
787 |
+
<notification>
|
788 |
+
<label>Notifications</label>
|
789 |
+
<frontend_type>text</frontend_type>
|
790 |
+
<sort_order>10</sort_order>
|
791 |
+
<show_in_default>1</show_in_default>
|
792 |
+
<show_in_website>0</show_in_website>
|
793 |
+
<show_in_store>0</show_in_store>
|
794 |
+
<fields>
|
795 |
+
<enable>
|
796 |
+
<label>I'd like to get advertising by GoMage</label>
|
797 |
+
<frontend_type>select</frontend_type>
|
798 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
799 |
+
<sort_order>10</sort_order>
|
800 |
+
<show_in_default>1</show_in_default>
|
801 |
+
<show_in_website>0</show_in_website>
|
802 |
+
<show_in_store>0</show_in_store>
|
803 |
+
</enable>
|
804 |
+
</fields>
|
805 |
+
</notification>
|
806 |
+
</groups>
|
807 |
+
</gomage_notification>
|
808 |
</sections>
|
809 |
</config>
|
app/code/local/GoMage/Social/sql/gomage_social_setup/mysql4-upgrade-1.0.0-1.1.0.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
|
5 |
+
$sql = <<<SQLTEXT
|
6 |
+
ALTER TABLE `{$this->getTable('gomage_social_entity')}` modify `customer_id` int(10) unsigned NOT NULL;
|
7 |
+
|
8 |
+
ALTER TABLE `{$this->getTable('gomage_social_entity')}`
|
9 |
+
ADD CONSTRAINT `FK_gomage_social_entity_customer_id_customer_entity_entity_id`
|
10 |
+
FOREIGN KEY (`customer_id`)
|
11 |
+
REFERENCES `{$this->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
12 |
+
SQLTEXT;
|
13 |
+
|
14 |
+
$installer->run($sql);
|
15 |
+
|
16 |
+
$installer->endSetup();
|
17 |
+
|
app/code/local/GoMage/Social/sql/gomage_social_setup/mysql4-upgrade-1.0.1-1.2.0.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
|
5 |
+
$sql = <<<SQLTEXT
|
6 |
+
DELETE FROM `{$this->getTable('core_config_data')}` WHERE `path` = "gomage_social/information/text"
|
7 |
+
SQLTEXT;
|
8 |
+
|
9 |
+
$installer->run($sql);
|
10 |
+
|
11 |
+
$installer->endSetup();
|
12 |
+
|
app/design/frontend/base/default/layout/gomage-social.xml
CHANGED
@@ -4,50 +4,52 @@
|
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
-
* @version Release: 1.0
|
12 |
-
* @since Class available since Release 1.0
|
13 |
-
*/
|
14 |
-->
|
15 |
<layout version="0.1.0">
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
<reference name="after_body_start">
|
18 |
<block type="core/template" name="gomage.social.config" template="gomage/social/config.phtml" />
|
19 |
</reference>
|
20 |
<block type="gomage_social/login" name="gomage.social.fast.links">
|
21 |
-
<action method="setPlace"><place>fast_links</place></action>
|
22 |
<action method="setPosition"><position>1000</position></action>
|
23 |
<action method="setUsedList"><used_list>1</used_list></action>
|
24 |
</block>
|
25 |
<reference name="top.links">
|
26 |
-
<action ifconfig="gomage_social/general/
|
27 |
</reference>
|
28 |
-
|
29 |
-
<action method="addItem"><type>skin_css</type><name>css/gomage/social.css</name></action>
|
30 |
-
</reference>
|
31 |
-
</customer_logged_out>
|
32 |
<checkout_onepage_index>
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
</checkout_onepage_index>
|
39 |
<gomage_checkout_onepage_index>
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
</gomage_checkout_onepage_index>
|
46 |
-
<customer_account_login>
|
47 |
<reference name="content">
|
48 |
<block after="customer_form_login" type="gomage_social/login" name="gomage.social.login.login">
|
49 |
-
<action method="setPlace"><place>login</place></action>
|
50 |
-
</block>
|
51 |
</reference>
|
52 |
</customer_account_login>
|
53 |
</layout>
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
+
* @version Release: 1.2.0
|
12 |
+
* @since Class available since Release 1.0.0
|
13 |
+
*/
|
14 |
-->
|
15 |
<layout version="0.1.0">
|
16 |
+
<default>
|
17 |
+
<reference name="head">
|
18 |
+
<block type="gomage_social/head" name="gomage.social.head" />
|
19 |
+
</reference>
|
20 |
+
</default>
|
21 |
+
<customer_logged_out>
|
22 |
<reference name="after_body_start">
|
23 |
<block type="core/template" name="gomage.social.config" template="gomage/social/config.phtml" />
|
24 |
</reference>
|
25 |
<block type="gomage_social/login" name="gomage.social.fast.links">
|
26 |
+
<action method="setPlace"><place>fast_links</place></action>
|
27 |
<action method="setPosition"><position>1000</position></action>
|
28 |
<action method="setUsedList"><used_list>1</used_list></action>
|
29 |
</block>
|
30 |
<reference name="top.links">
|
31 |
+
<action ifconfig="gomage_social/general/fast_links" method="addLinkBlock"><blockName>gomage.social.fast.links</blockName></action>
|
32 |
</reference>
|
33 |
+
</customer_logged_out>
|
|
|
|
|
|
|
34 |
<checkout_onepage_index>
|
35 |
+
<reference name="content">
|
36 |
+
<block type="gomage_social/login" name="gomage.social.login.checkout" before="-">
|
37 |
+
<action method="setPlace"><place>checkout</place></action>
|
38 |
+
</block>
|
39 |
+
</reference>
|
40 |
</checkout_onepage_index>
|
41 |
<gomage_checkout_onepage_index>
|
42 |
+
<reference name="content">
|
43 |
+
<block type="gomage_social/login" name="gomage.social.login.checkout" before="-">
|
44 |
+
<action method="setPlace"><place>checkout</place></action>
|
45 |
+
</block>
|
46 |
+
</reference>
|
47 |
</gomage_checkout_onepage_index>
|
48 |
+
<customer_account_login>
|
49 |
<reference name="content">
|
50 |
<block after="customer_form_login" type="gomage_social/login" name="gomage.social.login.login">
|
51 |
+
<action method="setPlace"><place>login</place></action>
|
52 |
+
</block>
|
53 |
</reference>
|
54 |
</customer_account_login>
|
55 |
</layout>
|
app/design/frontend/base/default/template/gomage/social/config.phtml
CHANGED
@@ -3,94 +3,136 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
*/
|
13 |
?>
|
14 |
-
<?php if (Mage::helper('gomage_social')->isActive()): ?>
|
15 |
<script type="text/javascript">
|
16 |
-
|
17 |
-
function gomageSocialPrepareFastLinks(){
|
18 |
-
try{
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
var fast_links = $$('.gs-login-fast_links')[0];
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
}
|
25 |
}
|
|
|
26 |
}
|
27 |
-
}catch(e){
|
|
|
|
|
28 |
}
|
29 |
-
|
|
|
30 |
setTimeout(gomageSocialPrepareFastLinks, 3000);
|
31 |
});
|
32 |
-
|
33 |
</script>
|
34 |
-
<?php
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
<div id="fb-root"></div>
|
37 |
<script type="text/javascript">
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
}
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
84 |
</script>
|
85 |
<?php endif; ?>
|
86 |
-
<?php if (Mage::helper('gomage_social')->isGActive() && Mage::getStoreConfig('gomage_social/general/enable')): ?>
|
87 |
<script type="text/javascript">
|
88 |
-
|
89 |
-
|
90 |
-
function gomageSocialGSigninCallback(authResult){
|
91 |
if (authResult['code']) {
|
92 |
-
var params = {code: authResult['code'], google_plus: 1};
|
93 |
-
var request = new Ajax.Request('<?php echo $this->getUrl('gomage_social/google/callback', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl())));
|
94 |
{
|
95 |
method: 'post',
|
96 |
parameters: params,
|
@@ -102,19 +144,76 @@
|
|
102 |
window.location.reload();
|
103 |
}
|
104 |
}
|
105 |
-
});
|
106 |
}
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
</script>
|
120 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
*/
|
13 |
?>
|
14 |
+
<?php if (Mage::helper('gomage_social')->isActive()) : ?>
|
15 |
<script type="text/javascript">
|
16 |
+
//<![CDATA[
|
17 |
+
function gomageSocialPrepareFastLinks() {
|
18 |
+
try {
|
19 |
+
var wrapper = document.getElementById('___signin_0');
|
20 |
+
|
21 |
+
if (wrapper) {
|
22 |
+
wrapper.style.height = '25px';
|
23 |
+
wrapper.style.width = '82px';
|
24 |
+
|
25 |
+
var button = wrapper.getElementsByTagName('button')[0];
|
26 |
+
|
27 |
+
if (button) {
|
28 |
+
button.style.height = '25px';
|
29 |
+
button.style.width = '82px';
|
30 |
+
}
|
31 |
+
|
32 |
+
var iframe = wrapper.getElementsByTagName('iframe')[0];
|
33 |
+
|
34 |
+
if (iframe) {
|
35 |
+
iframe.style.height = '25px';
|
36 |
+
iframe.style.width = '82px';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
if ($$('.gs-login-fast_links').length > 0) {
|
41 |
var fast_links = $$('.gs-login-fast_links')[0];
|
42 |
+
|
43 |
+
if (fast_links.up('ul.links') != 'undefined') {
|
44 |
+
if (fast_links.up('ul.links').getHeight() > 30) {
|
45 |
+
fast_links.up('li').previous().addClassName('last');
|
46 |
}
|
47 |
}
|
48 |
+
|
49 |
}
|
50 |
+
} catch(e){
|
51 |
+
|
52 |
+
}
|
53 |
}
|
54 |
+
|
55 |
+
document.observe("dom:loaded", function () {
|
56 |
setTimeout(gomageSocialPrepareFastLinks, 3000);
|
57 |
});
|
58 |
+
//]]>
|
59 |
</script>
|
60 |
+
<?php else: ?>
|
61 |
+
<script type="text/javascript">
|
62 |
+
//<![CDATA[
|
63 |
+
function lastLinks() {
|
64 |
+
var gs_li = $$('div.header ul.links li');
|
65 |
+
if (gs_li) {
|
66 |
+
var gs_last_li = gs_li[gs_li.length - 1];
|
67 |
+
gs_last_li.className = 'last';
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
document.observe("dom:loaded", lastLinks);
|
72 |
+
//]]>
|
73 |
+
</script>
|
74 |
+
<?php endif; ?>
|
75 |
+
<?php if (Mage::helper('gomage_social')->isFBActive() && Mage::getStoreConfig('gomage_social/general/enable')) : ?>
|
76 |
<div id="fb-root"></div>
|
77 |
<script type="text/javascript">
|
78 |
+
//<![CDATA[
|
79 |
+
function gomageSocialFBLogin() {
|
80 |
+
FB.login(function (response) {
|
81 |
+
gomageSocialFBLoginResponse(response);
|
82 |
+
}, {scope:'email'});
|
83 |
+
}
|
|
|
84 |
|
85 |
+
function gomageSocialFBCheckLogin() {
|
86 |
+
FB.getLoginStatus(function (response) {
|
87 |
+
gomageSocialFBLoginResponse(response);
|
88 |
+
});
|
89 |
+
}
|
90 |
|
91 |
+
function gomageSocialFBLoginResponse(response) {
|
92 |
+
if (response.status == 'connected') {
|
93 |
+
setLocation('<?php echo $this->getUrl('gomage_social/facebook/login', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()))); ?>');
|
94 |
+
} else {
|
95 |
+
window.location.reload();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
window.fbAsyncInit = function() {
|
100 |
+
FB.init({
|
101 |
+
appId: '<?php echo Mage::getStoreConfig('gomage_social/facebook/id') ?>',
|
102 |
+
status: false,
|
103 |
+
cookie: true,
|
104 |
+
xfbml: true,
|
105 |
+
oauth: true
|
106 |
+
});
|
107 |
+
|
108 |
+
FB.Event.subscribe('auth.login', function (response) {
|
109 |
+
gomageSocialFBCheckLogin();
|
110 |
+
});
|
111 |
+
};
|
112 |
+
|
113 |
+
(function (d) {
|
114 |
+
var js,
|
115 |
+
id = 'facebook-jssdk',
|
116 |
+
ref = d.getElementsByTagName('script')[0];
|
117 |
+
|
118 |
+
if (d.getElementById(id)) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
|
122 |
+
js = d.createElement('script'); js.id = id; js.async = true;
|
123 |
+
js.src = "//connect.facebook.net/<?php echo Mage::app()->getLocale()->getLocaleCode() ?>/all.js";
|
124 |
+
ref.parentNode.insertBefore(js, ref);
|
125 |
+
}(document));
|
126 |
+
//]]>
|
127 |
</script>
|
128 |
<?php endif; ?>
|
129 |
+
<?php if (Mage::helper('gomage_social')->isGActive() && Mage::getStoreConfig('gomage_social/general/enable')) : ?>
|
130 |
<script type="text/javascript">
|
131 |
+
//<![CDATA[
|
132 |
+
function gomageSocialGSigninCallback(authResult){
|
|
|
133 |
if (authResult['code']) {
|
134 |
+
var params = {code: authResult['code'], google_plus: 1};
|
135 |
+
var request = new Ajax.Request('<?php echo $this->getUrl('gomage_social/google/callback', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()))); ?>',
|
136 |
{
|
137 |
method: 'post',
|
138 |
parameters: params,
|
144 |
window.location.reload();
|
145 |
}
|
146 |
}
|
147 |
+
});
|
148 |
}
|
149 |
+
}
|
150 |
+
|
151 |
+
(function() {
|
152 |
+
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
|
153 |
+
po.src = 'https://apis.google.com/js/client:plusone.js';
|
154 |
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
|
155 |
+
window.___gcfg = {
|
156 |
+
lang: '<?php echo Mage::app()->getLocale()->getLocaleCode() ?>',
|
157 |
+
parsetags: 'onload'
|
158 |
+
}
|
159 |
+
})();
|
160 |
+
//]]>
|
161 |
</script>
|
162 |
+
<?php endif; ?>
|
163 |
+
|
164 |
+
|
165 |
+
<?php if (Mage::getSingleton('core/session')->getGsProfile()) : ?>
|
166 |
+
<?php if (Mage::getSingleton('core/session')->getGsProfile()->url) : ?>
|
167 |
+
<script type="text/javascript">
|
168 |
+
var GomageSocialClass = new GomageSocialClass ;
|
169 |
+
</script>
|
170 |
+
|
171 |
+
<div id="gs-popup-content" style="display:none;">
|
172 |
+
<div id="gs-validate-detail">
|
173 |
+
<form onsubmit="GomageSocialClass.sendEmail('<?php echo Mage::getSingleton('core/session')->getGsProfile()->url; ?>'); return false;" action="<?php echo Mage::getSingleton('core/session')->getGsProfile()->url; ?>" method="post" id="gs-form" >
|
174 |
+
<ul class="form-list">
|
175 |
+
<li>
|
176 |
+
<label for="gs-email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
177 |
+
<div class="input-box">
|
178 |
+
<input type="text" name="email" value="" id="gs-email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
|
179 |
+
</div>
|
180 |
+
</li>
|
181 |
+
<li>
|
182 |
+
<div class="actions">
|
183 |
+
<button type="submit" class="button validation-passed" ><span><span><?php echo $this->__('Login') ?></span></span></button>
|
184 |
+
<span style="display: none;" id="gs-please-wait" class="please-wait">
|
185 |
+
<img class="v-middle" title="<?php echo $this->__('Loading...') ?>" alt="<?php echo $this->__('Loading...') ?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" />
|
186 |
+
</span>
|
187 |
+
<div id="gs-message" ></div>
|
188 |
+
</div>
|
189 |
+
</li>
|
190 |
+
</ul>
|
191 |
+
</form>
|
192 |
+
</div>
|
193 |
+
</div>
|
194 |
+
|
195 |
+
<script type="text/javascript">
|
196 |
+
//<![CDATA[
|
197 |
+
win = GomageSocialClass.createWindow("<?php echo __('Enter your email'); ?>", 300, 100);
|
198 |
+
win.getContent().update($('gs-popup-content').innerHTML);
|
199 |
+
win.showCenter();
|
200 |
+
|
201 |
+
if (GomageSocialClass.overlay) {
|
202 |
+
GomageSocialClass.overlay.show();
|
203 |
+
}
|
204 |
+
|
205 |
+
var gs_id_window = GomageSocialClass.id_window();
|
206 |
+
$(gs_id_window.replace('_close','')).className = 'dialog dialog-gs';
|
207 |
+
|
208 |
+
$(gs_id_window).onclick = function() {
|
209 |
+
GomageSocialClass.unsGsProfile('<?php echo Mage::getSingleton('core/session')->getGsProfile()->urlEmailClose; ?>');
|
210 |
+
window.parent.Windows.close(gs_id_window.replace('_close',''));
|
211 |
+
|
212 |
+
if(GomageSocialClass.overlay){
|
213 |
+
GomageSocialClass.overlay.hide();
|
214 |
+
}
|
215 |
+
}
|
216 |
+
//]]>
|
217 |
+
</script>
|
218 |
+
<?php endif; ?>
|
219 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/gomage/social/login.phtml
CHANGED
@@ -1,82 +1,30 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
-
* @version Release: 1.0
|
11 |
-
* @since Class available since Release 1.0
|
12 |
-
*/
|
13 |
?>
|
14 |
-
<?php
|
15 |
-
$services = Mage::helper('gomage_social')->getServices($this->getPlace());
|
16 |
?>
|
17 |
-
<?php if (count($services)): ?>
|
18 |
<?php if ($this->getUsedList()): ?><li class="last gs-list"><?php endif; ?>
|
19 |
<ul class="gs-login <?php if(Mage::getConfig()->getModuleConfig('Enterprise_Enterprise' )): ?>gs-login-ee<?php endif; ?> gs-login-<?php echo $this->getPlace() ?>">
|
20 |
-
<?php
|
21 |
end($services);
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
?>
|
24 |
-
<?php foreach ($services as $key => $value): ?>
|
25 |
-
|
26 |
-
<?php switch ($key): ?>
|
27 |
-
<?php case (GoMage_Social_Model_Type::FACEBOOK): ?>
|
28 |
-
<li <?php if ($key == $last_key): ?>class="last"<?php endif; ?>>
|
29 |
-
<?php if ($this->getLoginType('facebook') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::BUTTON): ?>
|
30 |
-
<fb:login-button scope="email" onlogin="gomageSocialFBCheckLogin()" v="2"></fb:login-button>
|
31 |
-
<?php else: ?>
|
32 |
-
<a href="#" onclick="gomageSocialFBLogin();return false;" title="<?php echo $this->getText('facebook') ?>">
|
33 |
-
<?php if (($image = $this->getImage('facebook')) && ($this->getLoginType('facebook') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::IMAGE)): ?>
|
34 |
-
<img src="<?php echo $image ?>" alt="<?php echo $this->getText('facebook') ?>" />
|
35 |
-
<?php else: ?>
|
36 |
-
<?php echo $this->getText('facebook') ?>
|
37 |
-
<?php endif; ?>
|
38 |
-
</a>
|
39 |
-
<?php endif; ?>
|
40 |
-
</li>
|
41 |
-
<?php break; ?>
|
42 |
-
<?php case (GoMage_Social_Model_Type::GOOGLE): ?>
|
43 |
-
<li <?php if ($key == $last_key): ?>class="last"<?php endif; ?>>
|
44 |
-
<?php if ($this->getLoginType('google') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::BUTTON): ?>
|
45 |
-
<button class="g-signin"
|
46 |
-
data-scope="https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
|
47 |
-
data-requestvisibleactions="http://schemas.google.com/AddActivity"
|
48 |
-
data-clientId="<?php echo Mage::getStoreConfig('gomage_social/google/id') ?>"
|
49 |
-
data-accesstype="offline"
|
50 |
-
data-callback="gomageSocialGSigninCallback"
|
51 |
-
data-approvalprompt="force"
|
52 |
-
data-cookiepolicy="single_host_origin"
|
53 |
-
data-height="short">
|
54 |
-
</button>
|
55 |
-
<?php else: ?>
|
56 |
-
<a href="<?php echo $this->getUrl('gomage_social/google/login', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()))); ?>" title="<?php echo $this->getText('google') ?>">
|
57 |
-
<?php if (($image = $this->getImage('google')) && ($this->getLoginType('google') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::IMAGE)): ?>
|
58 |
-
<img src="<?php echo $image ?>" alt="<?php echo $this->getText('google') ?>" />
|
59 |
-
<?php else: ?>
|
60 |
-
<?php echo $this->getText('google') ?>
|
61 |
-
<?php endif; ?>
|
62 |
-
</a>
|
63 |
-
<?php endif; ?>
|
64 |
-
</li>
|
65 |
-
<?php break; ?>
|
66 |
-
<?php case (GoMage_Social_Model_Type::LINKEDIN): ?>
|
67 |
-
<li <?php if ($key == $last_key): ?>class="last"<?php endif; ?>>
|
68 |
-
<a href="<?php echo $this->getUrl('gomage_social/linkedin/login', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()))); ?>" title="<?php echo $this->getText('linkedin') ?>">
|
69 |
-
<?php if (($image = $this->getImage('linkedin')) && ($this->getLoginType('linkedin') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::IMAGE)): ?>
|
70 |
-
<img src="<?php echo $image ?>" alt="<?php echo $this->getText('linkedin') ?>" />
|
71 |
-
<?php else: ?>
|
72 |
-
<?php echo $this->getText('linkedin') ?>
|
73 |
-
<?php endif; ?>
|
74 |
-
</a>
|
75 |
-
</li>
|
76 |
-
<?php break; ?>
|
77 |
-
<?php endswitch; ?>
|
78 |
-
|
79 |
-
<?php endforeach; ?>
|
80 |
</ul>
|
81 |
-
<?php if ($this->getUsedList()): ?></li><?php endif; ?>
|
82 |
-
<?php endif; ?>
|
1 |
+
<?php
|
2 |
/**
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.0.0
|
12 |
+
*/
|
13 |
?>
|
14 |
+
<?php
|
15 |
+
$services = Mage::helper('gomage_social')->getServices($this->getPlace());
|
16 |
?>
|
17 |
+
<?php if (count($services)) : ?>
|
18 |
<?php if ($this->getUsedList()): ?><li class="last gs-list"><?php endif; ?>
|
19 |
<ul class="gs-login <?php if(Mage::getConfig()->getModuleConfig('Enterprise_Enterprise' )): ?>gs-login-ee<?php endif; ?> gs-login-<?php echo $this->getPlace() ?>">
|
20 |
+
<?php
|
21 |
end($services);
|
22 |
+
$last_type = key($services);
|
23 |
+
|
24 |
+
foreach ($services as $type => $value) {
|
25 |
+
echo $this->getServiceBlock($type, $type == $last_type);
|
26 |
+
}
|
27 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
</ul>
|
29 |
+
<?php if ($this->getUsedList()) : ?></li><?php endif; ?>
|
30 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/gomage/social/login/facebook.phtml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
|
15 |
+
<li <?php if ($this->is_last): ?>class="last"<?php endif; ?>>
|
16 |
+
<?php if ($this->getLoginType('facebook') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::BUTTON) : ?>
|
17 |
+
<fb:login-button scope="email" onlogin="gomageSocialFBCheckLogin()" v="2"></fb:login-button>
|
18 |
+
<?php else: ?>
|
19 |
+
<a href="#" onclick="gomageSocialFBLogin();return false;" title="<?php echo $this->getText('facebook') ?>">
|
20 |
+
<?php if (($image = $this->getImage('facebook')) && ($this->getLoginType('facebook') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::IMAGE)): ?>
|
21 |
+
<img src="<?php echo $image ?>" alt="<?php echo $this->getText('facebook') ?>" />
|
22 |
+
<?php else: ?>
|
23 |
+
<?php echo $this->getText('facebook') ?>
|
24 |
+
<?php endif; ?>
|
25 |
+
</a>
|
26 |
+
<?php endif; ?>
|
27 |
+
</li>
|
app/design/frontend/base/default/template/gomage/social/login/google.phtml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
|
15 |
+
<li <?php if ($this->is_last): ?>class="last"<?php endif; ?>>
|
16 |
+
<?php if ($this->getLoginType('google') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::BUTTON) : ?>
|
17 |
+
<button class="g-signin"
|
18 |
+
data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email"
|
19 |
+
data-requestvisibleactions="http://schemas.google.com/AddActivity"
|
20 |
+
data-clientId="<?php echo Mage::getStoreConfig('gomage_social/google/id') ?>"
|
21 |
+
data-accesstype="offline"
|
22 |
+
data-callback="gomageSocialGSigninCallback"
|
23 |
+
data-approvalprompt="force"
|
24 |
+
data-cookiepolicy="single_host_origin"
|
25 |
+
data-height="short">
|
26 |
+
</button>
|
27 |
+
<?php else: ?>
|
28 |
+
<a href="<?php echo $this->getUrl('gomage_social/google/login', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()))); ?>" title="<?php echo $this->getText('google') ?>">
|
29 |
+
<?php if (($image = $this->getImage('google')) && ($this->getLoginType('google') == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::IMAGE)) : ?>
|
30 |
+
<img src="<?php echo $image ?>" alt="<?php echo $this->getText('google') ?>" />
|
31 |
+
<?php else : ?>
|
32 |
+
<?php echo $this->getText('google') ?>
|
33 |
+
<?php endif; ?>
|
34 |
+
</a>
|
35 |
+
<?php endif; ?>
|
36 |
+
</li>
|
app/design/frontend/base/default/template/gomage/social/login/service.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.1.0
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
<li <?php if ($this->is_last): ?>class="last"<?php endif; ?>>
|
15 |
+
<a href="<?php echo $this->getUrl('gomage_social/'.$this->service.'/login', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()))); ?>" title="<?php echo $this->getText($this->service) ?>">
|
16 |
+
<?php if (($image = $this->getImage($this->service)) && ($this->getLoginType($this->service) == GoMage_Social_Model_Adminhtml_System_Config_Source_Login_Type::IMAGE)): ?>
|
17 |
+
<img src="<?php echo $image ?>" alt="<?php echo $this->getText($this->service) ?>" />
|
18 |
+
<?php else: ?>
|
19 |
+
<?php echo $this->getText($this->service) ?>
|
20 |
+
<?php endif; ?>
|
21 |
+
</a>
|
22 |
+
</li>
|
app/etc/modules/GoMage_Social.xml
CHANGED
@@ -4,12 +4,12 @@
|
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
-
* @version Release: 1.0
|
12 |
-
* @since Class available since Release 1.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
@@ -17,7 +17,7 @@
|
|
17 |
<GoMage_Social>
|
18 |
<active>true</active>
|
19 |
<codePool>local</codePool>
|
20 |
-
<version>1.
|
21 |
</GoMage_Social>
|
22 |
</modules>
|
23 |
</config>
|
4 |
* GoMage Social Connector Extension
|
5 |
*
|
6 |
* @category Extension
|
7 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
8 |
* @author GoMage
|
9 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
10 |
* @terms of use http://www.gomage.com/terms-of-use
|
11 |
+
* @version Release: 1.2.0
|
12 |
+
* @since Class available since Release 1.0.0
|
13 |
*/
|
14 |
-->
|
15 |
<config>
|
17 |
<GoMage_Social>
|
18 |
<active>true</active>
|
19 |
<codePool>local</codePool>
|
20 |
+
<version>1.1.0</version>
|
21 |
</GoMage_Social>
|
22 |
</modules>
|
23 |
</config>
|
js/gomage/social.js
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* GoMage Social Connector Extension
|
3 |
+
*
|
4 |
+
* @category Extension
|
5 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
6 |
+
* @author GoMage
|
7 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
8 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
9 |
+
* @version Release: 1.2.0
|
10 |
+
* @since Class available since Release 1.1.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
GomageSocialClass = Class.create({
|
14 |
+
|
15 |
+
config: null,
|
16 |
+
overlay: null,
|
17 |
+
|
18 |
+
initialize: function (config) {
|
19 |
+
this.overlay = $('gomage-social-overlay');
|
20 |
+
if (!this.overlay) {
|
21 |
+
var element = $$('body')[0];
|
22 |
+
this.overlay = $(document.createElement('div'));
|
23 |
+
this.overlay.id = 'gomage-social-overlay';
|
24 |
+
document.body.appendChild(this.overlay);
|
25 |
+
var offsets = element.cumulativeOffset();
|
26 |
+
window.onload = function(){
|
27 |
+
$('gs-email').focus();
|
28 |
+
var wrapper = GomageSocialClass.elementsByClass('wrapper');
|
29 |
+
if(wrapper){
|
30 |
+
|
31 |
+
GomageSocialClass.overlay.setStyle({
|
32 |
+
'height': wrapper.getHeight() + 'px',
|
33 |
+
'width': wrapper.getWidth() + 'px'
|
34 |
+
});
|
35 |
+
|
36 |
+
}
|
37 |
+
}
|
38 |
+
this.overlay.setStyle({
|
39 |
+
'top': offsets[1] + 'px',
|
40 |
+
'left': offsets[0] + 'px',
|
41 |
+
'width': element.offsetWidth + 'px',
|
42 |
+
'height': screen.height + 'px',
|
43 |
+
'position': 'absolute',
|
44 |
+
'display': 'none',
|
45 |
+
'zIndex': '2000'
|
46 |
+
|
47 |
+
});
|
48 |
+
}
|
49 |
+
},
|
50 |
+
|
51 |
+
|
52 |
+
sendEmail : function(url) {
|
53 |
+
var gsForm = new VarienForm('gs-validate-detail', true);
|
54 |
+
var params = this.getFormData();
|
55 |
+
if (gsForm.validator && gsForm.validator.validate()) {
|
56 |
+
$('gs-please-wait').show();
|
57 |
+
$('gs-message').innerHTML = '';
|
58 |
+
parameters: params;
|
59 |
+
|
60 |
+
var request = new Ajax.Request(url, {
|
61 |
+
method : 'POST',
|
62 |
+
parameters : params,
|
63 |
+
loaderArea : false,
|
64 |
+
onSuccess : function(transport) {
|
65 |
+
var response = eval('(' + (transport.responseText || false)
|
66 |
+
+ ')');
|
67 |
+
if(response.error){
|
68 |
+
$('gs-message').innerHTML = response.error;
|
69 |
+
}
|
70 |
+
if(response.success){
|
71 |
+
$('gs-popup-content').hide();
|
72 |
+
window.location.replace(location.href.replace('#_=_', ''));
|
73 |
+
}
|
74 |
+
if(response.redirect){
|
75 |
+
window.location.replace(response.redirect);
|
76 |
+
}
|
77 |
+
$('gs-please-wait').hide();
|
78 |
+
|
79 |
+
}
|
80 |
+
});
|
81 |
+
|
82 |
+
}
|
83 |
+
},
|
84 |
+
|
85 |
+
id_window: function() {
|
86 |
+
var elements = window.parent.document.getElementsByClassName('dialog');
|
87 |
+
for (i = 0; i < elements.length; i++){
|
88 |
+
id = elements[i].firstChild.id;
|
89 |
+
break;
|
90 |
+
}
|
91 |
+
return id;
|
92 |
+
|
93 |
+
},
|
94 |
+
unsGsProfile: function(url) {
|
95 |
+
var request = new Ajax.Request(url, {
|
96 |
+
method : 'POST',
|
97 |
+
loaderArea : false
|
98 |
+
});
|
99 |
+
},
|
100 |
+
elementsByClass: function(name) {
|
101 |
+
var elements = window.parent.document.getElementsByClassName(name);
|
102 |
+
for (i = 0; i < elements.length; i++){
|
103 |
+
obj = elements[i];
|
104 |
+
break;
|
105 |
+
}
|
106 |
+
return obj;
|
107 |
+
},
|
108 |
+
|
109 |
+
getFormData:function(){
|
110 |
+
var form_data = $('gs-form').serialize(true);
|
111 |
+
for (var key in form_data){
|
112 |
+
form_data[key] = GlcUrl.encode(form_data[key]);
|
113 |
+
}
|
114 |
+
|
115 |
+
return form_data;
|
116 |
+
},
|
117 |
+
|
118 |
+
createWindow : function (title,width,height)
|
119 |
+
{
|
120 |
+
win = new Window({
|
121 |
+
className:'dialog-gs magento',
|
122 |
+
title: title,
|
123 |
+
width:width,
|
124 |
+
height:height,
|
125 |
+
maximizable:false,
|
126 |
+
minimizable:false,
|
127 |
+
resizable:false,
|
128 |
+
draggable:false,
|
129 |
+
closeOnEsc: false,
|
130 |
+
showEffect:Effect.BlindDown,
|
131 |
+
hideEffect:Effect.BlindUp,
|
132 |
+
showEffectOptions: {duration: 0.4},
|
133 |
+
hideEffectOptions: {duration: 0.4}}
|
134 |
+
|
135 |
+
);
|
136 |
+
win.setZIndex(5000);
|
137 |
+
return win;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
|
142 |
+
|
143 |
+
});
|
144 |
+
|
145 |
+
var GlcUrl = {
|
146 |
+
|
147 |
+
encode : function (string) {
|
148 |
+
return escape(this._utf8_encode(string));
|
149 |
+
},
|
150 |
+
|
151 |
+
decode : function (string) {
|
152 |
+
return this._utf8_decode(unescape(string));
|
153 |
+
},
|
154 |
+
|
155 |
+
_utf8_encode : function (string) {
|
156 |
+
string = string.replace(/\r\n/g,"\n");
|
157 |
+
var utftext = "";
|
158 |
+
|
159 |
+
for (var n = 0; n < string.length; n++) {
|
160 |
+
|
161 |
+
var c = string.charCodeAt(n);
|
162 |
+
|
163 |
+
if (c < 128) {
|
164 |
+
utftext += String.fromCharCode(c);
|
165 |
+
}
|
166 |
+
else if((c > 127) && (c < 2048)) {
|
167 |
+
utftext += String.fromCharCode((c >> 6) | 192);
|
168 |
+
utftext += String.fromCharCode((c & 63) | 128);
|
169 |
+
}
|
170 |
+
else {
|
171 |
+
utftext += String.fromCharCode((c >> 12) | 224);
|
172 |
+
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
173 |
+
utftext += String.fromCharCode((c & 63) | 128);
|
174 |
+
}
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
return utftext;
|
179 |
+
},
|
180 |
+
|
181 |
+
_utf8_decode : function (utftext) {
|
182 |
+
var string = "";
|
183 |
+
var i = 0;
|
184 |
+
var c = c1 = c2 = 0;
|
185 |
+
|
186 |
+
while ( i < utftext.length ) {
|
187 |
+
|
188 |
+
c = utftext.charCodeAt(i);
|
189 |
+
|
190 |
+
if (c < 128) {
|
191 |
+
string += String.fromCharCode(c);
|
192 |
+
i++;
|
193 |
+
}
|
194 |
+
else if((c > 191) && (c < 224)) {
|
195 |
+
c2 = utftext.charCodeAt(i+1);
|
196 |
+
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
197 |
+
i += 2;
|
198 |
+
}
|
199 |
+
else {
|
200 |
+
c2 = utftext.charCodeAt(i+1);
|
201 |
+
c3 = utftext.charCodeAt(i+2);
|
202 |
+
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
203 |
+
i += 3;
|
204 |
+
}
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
return string;
|
209 |
+
}
|
210 |
+
};
|
lib/GoMage/Amazon/Credentials.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Amazon_Credentials extends Varien_Object {
|
15 |
+
|
16 |
+
public function _construct() {
|
17 |
+
if (!$this->getClientId()) {
|
18 |
+
throw new Exception('client_id is required');
|
19 |
+
} else if (!$this->getClientSecret()) {
|
20 |
+
throw new Exception('client_secret is required');
|
21 |
+
} else if (!$this->getRedirectUri()) {
|
22 |
+
throw new Exception('redirect_uri is required');
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
lib/GoMage/Amazon/Service.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* GoMage Social Connector Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
+
* @author GoMage
|
8 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
10 |
+
* @version Release: 1.2.0
|
11 |
+
* @since Class available since Release 1.2.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
class GoMage_Amazon_Service {
|
15 |
+
|
16 |
+
const SERVICE_ENDPOINT = 'https://www.amazon.com/ap';
|
17 |
+
const AUTHORIZATION_ENDPOINT = 'https://www.amazon.com/ap/oa';
|
18 |
+
const ACCESS_TOKEN_ENDPOINT = 'https://www.amazon.com/ap/oatoken';
|
19 |
+
|
20 |
+
public static $return_request_error = false;
|
21 |
+
|
22 |
+
public $http_info = array();
|
23 |
+
public $http_response = '';
|
24 |
+
public $useragent = 'Amazon OAuth';
|
25 |
+
public $connecttimeout = 30;
|
26 |
+
public $timeout = 30;
|
27 |
+
public $ssl_verifypeer = false;
|
28 |
+
|
29 |
+
protected $credentials;
|
30 |
+
|
31 |
+
public function __construct(GoMage_Amazon_Credentials $credentials) {
|
32 |
+
$this->credentials = $credentials;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getCredentials() {
|
36 |
+
return $this->credentials;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function request($url, $method, $parameters = array(), $extraHeaders = array()) {
|
40 |
+
$this->http_info = array();
|
41 |
+
$this->http_response = '';
|
42 |
+
$ci = curl_init();
|
43 |
+
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
|
44 |
+
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
|
45 |
+
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
|
46 |
+
curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
|
47 |
+
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
|
48 |
+
curl_setopt($ci, CURLOPT_HEADER, false);
|
49 |
+
|
50 |
+
switch ($method) {
|
51 |
+
case 'GET' :
|
52 |
+
if (!empty($parameters)) {
|
53 |
+
$url .= '?' . http_build_query($parameters);
|
54 |
+
}
|
55 |
+
break;
|
56 |
+
case 'POST' :
|
57 |
+
curl_setopt($ci, CURLOPT_POST, true);
|
58 |
+
|
59 |
+
if (!empty($parameters)) {
|
60 |
+
curl_setopt($ci, CURLOPT_POSTFIELDS, $parameters);
|
61 |
+
}
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
|
65 |
+
curl_setopt($ci, CURLOPT_HTTPHEADER, $extraHeaders);
|
66 |
+
curl_setopt($ci, CURLOPT_URL, $url);
|
67 |
+
|
68 |
+
$this->http_response = curl_exec($ci);
|
69 |
+
$this->http_info = curl_getinfo($ci);
|
70 |
+
$error = curl_error($ci);
|
71 |
+
|
72 |
+
curl_close($ci);
|
73 |
+
|
74 |
+
if ($error) {
|
75 |
+
throw new Exception($error);
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($this->http_info['http_code'] !== 200) {
|
79 |
+
switch (self::$return_request_error) {
|
80 |
+
case false :
|
81 |
+
throw new Exception('Could not connect to Amazon. Refresh the page or try again later.');
|
82 |
+
break;
|
83 |
+
case true :
|
84 |
+
throw new Exception(
|
85 |
+
"Amazon OAuth request failed: " .
|
86 |
+
"\t\r\n HTTP code: " . $this->http_info['http_code'] .
|
87 |
+
"\t\r\n HTTP response: " . $this->http_response
|
88 |
+
);
|
89 |
+
break;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
return $this->http_response;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function getAuthorizationUrl($parameters = array()) {
|
97 |
+
$parameters = array_merge(
|
98 |
+
$parameters,
|
99 |
+
array(
|
100 |
+
'type' => 'web_server',
|
101 |
+
'client_id' => $this->credentials->getClientId(),
|
102 |
+
'redirect_uri' => $this->credentials->getRedirectUri(),
|
103 |
+
'response_type' => 'code',
|
104 |
+
)
|
105 |
+
);
|
106 |
+
|
107 |
+
return self::AUTHORIZATION_ENDPOINT . '?' . http_build_query($parameters);
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getTokenUrl($parameters = array()) {
|
111 |
+
$parameters = array_merge(
|
112 |
+
$parameters,
|
113 |
+
array(
|
114 |
+
'code' => $this->credentials->getCode(),
|
115 |
+
'client_id' => $this->credentials->getClientId(),
|
116 |
+
'client_secret' => $this->credentials->getClientSecret(),
|
117 |
+
'redirect_uri' => $this->credentials->getRedirectUri(),
|
118 |
+
'grant_type' => 'authorization_code',
|
119 |
+
)
|
120 |
+
);
|
121 |
+
|
122 |
+
return self::ACCESS_TOKEN_ENDPOINT . '?' . http_build_query($parameters);
|
123 |
+
}
|
124 |
+
|
125 |
+
public function requestToken($parameters = array()) {
|
126 |
+
$parameters = array_merge(
|
127 |
+
$parameters,
|
128 |
+
array(
|
129 |
+
'code' => $this->credentials->getCode(),
|
130 |
+
'client_id' => $this->credentials->getClientId(),
|
131 |
+
'client_secret' => $this->credentials->getClientSecret(),
|
132 |
+
'redirect_uri' => $this->credentials->getRedirectUri(),
|
133 |
+
'grant_type' => 'authorization_code',
|
134 |
+
)
|
135 |
+
);
|
136 |
+
|
137 |
+
$this->request(self::ACCESS_TOKEN_ENDPOINT, 'POST', $parameters);
|
138 |
+
|
139 |
+
return new Varien_Object(Zend_Json::decode($this->http_response));
|
140 |
+
}
|
141 |
+
|
142 |
+
public function requestUserProfile($parameters = array()) {
|
143 |
+
$parameters = array_merge(
|
144 |
+
$parameters,
|
145 |
+
array(
|
146 |
+
'access_token' => $this->credentials
|
147 |
+
->getOauthToken()
|
148 |
+
->getAccessToken(),
|
149 |
+
)
|
150 |
+
);
|
151 |
+
|
152 |
+
$this->request(self::SERVICE_ENDPOINT . '/user/profile', 'GET', $parameters);
|
153 |
+
|
154 |
+
return new Varien_Object(Zend_Json::decode($this->http_response));
|
155 |
+
}
|
156 |
+
}
|
lib/GoMage/Linkedin/linkedinoauth.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
@@ -64,7 +64,10 @@ class LinkedInOAuth {
|
|
64 |
$parameters['scope'] = 'r_emailaddress';
|
65 |
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
|
66 |
$token = OAuthUtil::parse_parameters($request);
|
67 |
-
|
|
|
|
|
|
|
68 |
return $token;
|
69 |
}
|
70 |
|
3 |
* GoMage Social Connector Extension
|
4 |
*
|
5 |
* @category Extension
|
6 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
7 |
* @author GoMage
|
8 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
9 |
* @terms of use http://www.gomage.com/terms-of-use
|
64 |
$parameters['scope'] = 'r_emailaddress';
|
65 |
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
|
66 |
$token = OAuthUtil::parse_parameters($request);
|
67 |
+
if(!empty($token['oauth_token']) and !empty($token['oauth_token_secret'])){
|
68 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
69 |
+
}
|
70 |
+
|
71 |
return $token;
|
72 |
}
|
73 |
|
lib/GoMage/Reddit/Client.php
ADDED
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Note : Code is released under the GNU LGPL
|
4 |
+
*
|
5 |
+
* Please do not change the header of this file
|
6 |
+
*
|
7 |
+
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU
|
8 |
+
* Lesser General Public License as published by the Free Software Foundation; either version 2 of
|
9 |
+
* the License, or (at your option) any later version.
|
10 |
+
*
|
11 |
+
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
12 |
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
13 |
+
*
|
14 |
+
* See the GNU Lesser General Public License for more details.
|
15 |
+
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Light PHP wrapper for the OAuth 2.0 protocol.
|
19 |
+
*
|
20 |
+
* This client is based on the OAuth2 specification draft v2.15
|
21 |
+
* http://tools.ietf.org/html/draft-ietf-oauth-v2-15
|
22 |
+
*
|
23 |
+
* @author Pierrick Charron <pierrick@webstart.fr>
|
24 |
+
* @author Anis Berejeb <anis.berejeb@gmail.com>
|
25 |
+
* @version 1.2-dev
|
26 |
+
*/
|
27 |
+
namespace OAuth2;
|
28 |
+
|
29 |
+
class Client
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* Different AUTH method
|
33 |
+
*/
|
34 |
+
const AUTH_TYPE_URI = 0;
|
35 |
+
const AUTH_TYPE_AUTHORIZATION_BASIC = 1;
|
36 |
+
const AUTH_TYPE_FORM = 2;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Different Access token type
|
40 |
+
*/
|
41 |
+
const ACCESS_TOKEN_URI = 0;
|
42 |
+
const ACCESS_TOKEN_BEARER = 1;
|
43 |
+
const ACCESS_TOKEN_OAUTH = 2;
|
44 |
+
const ACCESS_TOKEN_MAC = 3;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Different Grant types
|
48 |
+
*/
|
49 |
+
const GRANT_TYPE_AUTH_CODE = 'authorization_code';
|
50 |
+
const GRANT_TYPE_PASSWORD = 'password';
|
51 |
+
const GRANT_TYPE_CLIENT_CREDENTIALS = 'client_credentials';
|
52 |
+
const GRANT_TYPE_REFRESH_TOKEN = 'refresh_token';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* HTTP Methods
|
56 |
+
*/
|
57 |
+
const HTTP_METHOD_GET = 'GET';
|
58 |
+
const HTTP_METHOD_POST = 'POST';
|
59 |
+
const HTTP_METHOD_PUT = 'PUT';
|
60 |
+
const HTTP_METHOD_DELETE = 'DELETE';
|
61 |
+
const HTTP_METHOD_HEAD = 'HEAD';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* HTTP Form content types
|
65 |
+
*/
|
66 |
+
const HTTP_FORM_CONTENT_TYPE_APPLICATION = 0;
|
67 |
+
const HTTP_FORM_CONTENT_TYPE_MULTIPART = 1;
|
68 |
+
|
69 |
+
public $useragent = 'Reddit OAuth';
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Client ID
|
73 |
+
*
|
74 |
+
* @var string
|
75 |
+
*/
|
76 |
+
protected $client_id = null;
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Client Secret
|
80 |
+
*
|
81 |
+
* @var string
|
82 |
+
*/
|
83 |
+
protected $client_secret = null;
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Client Authentication method
|
87 |
+
*
|
88 |
+
* @var int
|
89 |
+
*/
|
90 |
+
protected $client_auth = self::AUTH_TYPE_URI;
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Access Token
|
94 |
+
*
|
95 |
+
* @var string
|
96 |
+
*/
|
97 |
+
protected $access_token = null;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Access Token Type
|
101 |
+
*
|
102 |
+
* @var int
|
103 |
+
*/
|
104 |
+
protected $access_token_type = self::ACCESS_TOKEN_URI;
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Access Token Secret
|
108 |
+
*
|
109 |
+
* @var string
|
110 |
+
*/
|
111 |
+
protected $access_token_secret = null;
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Access Token crypt algorithm
|
115 |
+
*
|
116 |
+
* @var string
|
117 |
+
*/
|
118 |
+
protected $access_token_algorithm = null;
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Access Token Parameter name
|
122 |
+
*
|
123 |
+
* @var string
|
124 |
+
*/
|
125 |
+
protected $access_token_param_name = 'access_token';
|
126 |
+
|
127 |
+
/**
|
128 |
+
* The path to the certificate file to use for https connections
|
129 |
+
*
|
130 |
+
* @var string Defaults to .
|
131 |
+
*/
|
132 |
+
protected $certificate_file = null;
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Construct
|
136 |
+
*
|
137 |
+
* @param string $client_id Client ID
|
138 |
+
* @param string $client_secret Client Secret
|
139 |
+
* @param int $client_auth (AUTH_TYPE_URI, AUTH_TYPE_AUTHORIZATION_BASIC, AUTH_TYPE_FORM)
|
140 |
+
* @param string $certificate_file Indicates if we want to use a certificate file to trust the server. Optional, defaults to null.
|
141 |
+
* @return void
|
142 |
+
*/
|
143 |
+
public function __construct($client_id, $client_secret, $client_auth = self::AUTH_TYPE_URI, $certificate_file = null)
|
144 |
+
{
|
145 |
+
if (!extension_loaded('curl')) {
|
146 |
+
throw new Exception('The PHP exention curl must be installed to use this library.', Exception::CURL_NOT_FOUND);
|
147 |
+
}
|
148 |
+
|
149 |
+
$this->client_id = $client_id;
|
150 |
+
$this->client_secret = $client_secret;
|
151 |
+
$this->client_auth = $client_auth;
|
152 |
+
$this->certificate_file = $certificate_file;
|
153 |
+
if (!empty($this->certificate_file) && !is_file($this->certificate_file)) {
|
154 |
+
throw new InvalidArgumentException('The certificate file was not found', InvalidArgumentException::CERTIFICATE_NOT_FOUND);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Get the client Id
|
160 |
+
*
|
161 |
+
* @return string Client ID
|
162 |
+
*/
|
163 |
+
public function getClientId()
|
164 |
+
{
|
165 |
+
return $this->client_id;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Get the client Secret
|
170 |
+
*
|
171 |
+
* @return string Client Secret
|
172 |
+
*/
|
173 |
+
public function getClientSecret()
|
174 |
+
{
|
175 |
+
return $this->client_secret;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* getAuthenticationUrl
|
180 |
+
*
|
181 |
+
* @param string $auth_endpoint Url of the authentication endpoint
|
182 |
+
* @param string $redirect_uri Redirection URI
|
183 |
+
* @param array $extra_parameters Array of extra parameters like scope or state (Ex: array('scope' => null, 'state' => ''))
|
184 |
+
* @return string URL used for authentication
|
185 |
+
*/
|
186 |
+
public function getAuthenticationUrl($auth_endpoint, $redirect_uri, array $extra_parameters = array())
|
187 |
+
{
|
188 |
+
$parameters = array_merge(array(
|
189 |
+
'response_type' => 'code',
|
190 |
+
'client_id' => $this->client_id,
|
191 |
+
'redirect_uri' => $redirect_uri
|
192 |
+
), $extra_parameters);
|
193 |
+
return $auth_endpoint . '?' . http_build_query($parameters, null, '&');
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* getAccessToken
|
198 |
+
*
|
199 |
+
* @param string $token_endpoint Url of the token endpoint
|
200 |
+
* @param int $grant_type Grand Type ('authorization_code', 'password', 'client_credentials', 'refresh_token', or a custom code (@see GrantType Classes)
|
201 |
+
* @param array $parameters Array sent to the server (depend on which grant type you're using)
|
202 |
+
* @return array Array of parameters required by the grant_type (CF SPEC)
|
203 |
+
*/
|
204 |
+
public function getAccessToken($token_endpoint, $grant_type, array $parameters)
|
205 |
+
{
|
206 |
+
if (!$grant_type) {
|
207 |
+
throw new InvalidArgumentException('The grant_type is mandatory.', InvalidArgumentException::INVALID_GRANT_TYPE);
|
208 |
+
}
|
209 |
+
$grantTypeClassName = $this->convertToCamelCase($grant_type);
|
210 |
+
$grantTypeClass = __NAMESPACE__ . '\\GrantType\\' . $grantTypeClassName;
|
211 |
+
if (!class_exists($grantTypeClass)) {
|
212 |
+
throw new InvalidArgumentException('Unknown grant type \'' . $grant_type . '\'', InvalidArgumentException::INVALID_GRANT_TYPE);
|
213 |
+
}
|
214 |
+
$grantTypeObject = new $grantTypeClass();
|
215 |
+
$grantTypeObject->validateParameters($parameters);
|
216 |
+
if (!defined($grantTypeClass . '::GRANT_TYPE')) {
|
217 |
+
throw new Exception('Unknown constant GRANT_TYPE for class ' . $grantTypeClassName, Exception::GRANT_TYPE_ERROR);
|
218 |
+
}
|
219 |
+
$parameters['grant_type'] = $grantTypeClass::GRANT_TYPE;
|
220 |
+
$http_headers = array();
|
221 |
+
switch ($this->client_auth) {
|
222 |
+
case self::AUTH_TYPE_URI:
|
223 |
+
case self::AUTH_TYPE_FORM:
|
224 |
+
$parameters['client_id'] = $this->client_id;
|
225 |
+
$parameters['client_secret'] = $this->client_secret;
|
226 |
+
break;
|
227 |
+
case self::AUTH_TYPE_AUTHORIZATION_BASIC:
|
228 |
+
$parameters['client_id'] = $this->client_id;
|
229 |
+
$http_headers['Authorization'] = 'Basic ' . base64_encode($this->client_id . ':' . $this->client_secret);
|
230 |
+
break;
|
231 |
+
default:
|
232 |
+
throw new Exception('Unknown client auth type.', Exception::INVALID_CLIENT_AUTHENTICATION_TYPE);
|
233 |
+
break;
|
234 |
+
}
|
235 |
+
|
236 |
+
return $this->executeRequest($token_endpoint, $parameters, self::HTTP_METHOD_POST, $http_headers, self::HTTP_FORM_CONTENT_TYPE_APPLICATION);
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* setToken
|
241 |
+
*
|
242 |
+
* @param string $token Set the access token
|
243 |
+
* @return void
|
244 |
+
*/
|
245 |
+
public function setAccessToken($token)
|
246 |
+
{
|
247 |
+
$this->access_token = $token;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Set the client authentication type
|
252 |
+
*
|
253 |
+
* @param string $client_auth (AUTH_TYPE_URI, AUTH_TYPE_AUTHORIZATION_BASIC, AUTH_TYPE_FORM)
|
254 |
+
* @return void
|
255 |
+
*/
|
256 |
+
public function setClientAuthType($client_auth)
|
257 |
+
{
|
258 |
+
$this->client_auth = $client_auth;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Set the access token type
|
263 |
+
*
|
264 |
+
* @param int $type Access token type (ACCESS_TOKEN_BEARER, ACCESS_TOKEN_MAC, ACCESS_TOKEN_URI)
|
265 |
+
* @param string $secret The secret key used to encrypt the MAC header
|
266 |
+
* @param string $algorithm Algorithm used to encrypt the signature
|
267 |
+
* @return void
|
268 |
+
*/
|
269 |
+
public function setAccessTokenType($type, $secret = null, $algorithm = null)
|
270 |
+
{
|
271 |
+
$this->access_token_type = $type;
|
272 |
+
$this->access_token_secret = $secret;
|
273 |
+
$this->access_token_algorithm = $algorithm;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Fetch a protected ressource
|
278 |
+
*
|
279 |
+
* @param string $protected_ressource_url Protected resource URL
|
280 |
+
* @param array $parameters Array of parameters
|
281 |
+
* @param string $http_method HTTP Method to use (POST, PUT, GET, HEAD, DELETE)
|
282 |
+
* @param array $http_headers HTTP headers
|
283 |
+
* @param int $form_content_type HTTP form content type to use
|
284 |
+
* @return array
|
285 |
+
*/
|
286 |
+
public function fetch($protected_resource_url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = array(), $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
|
287 |
+
{
|
288 |
+
if ($this->access_token) {
|
289 |
+
switch ($this->access_token_type) {
|
290 |
+
case self::ACCESS_TOKEN_URI:
|
291 |
+
if (is_array($parameters)) {
|
292 |
+
$parameters[$this->access_token_param_name] = $this->access_token;
|
293 |
+
} else {
|
294 |
+
throw new InvalidArgumentException(
|
295 |
+
'You need to give parameters as array if you want to give the token within the URI.',
|
296 |
+
InvalidArgumentException::REQUIRE_PARAMS_AS_ARRAY
|
297 |
+
);
|
298 |
+
}
|
299 |
+
break;
|
300 |
+
case self::ACCESS_TOKEN_BEARER:
|
301 |
+
$http_headers['Authorization'] = 'Bearer ' . $this->access_token;
|
302 |
+
break;
|
303 |
+
case self::ACCESS_TOKEN_OAUTH:
|
304 |
+
$http_headers['Authorization'] = 'OAuth ' . $this->access_token;
|
305 |
+
break;
|
306 |
+
case self::ACCESS_TOKEN_MAC:
|
307 |
+
$http_headers['Authorization'] = 'MAC ' . $this->generateMACSignature($protected_resource_url, $parameters, $http_method);
|
308 |
+
break;
|
309 |
+
default:
|
310 |
+
throw new Exception('Unknown access token type.', Exception::INVALID_ACCESS_TOKEN_TYPE);
|
311 |
+
break;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
return $this->executeRequest($protected_resource_url, $parameters, $http_method, $http_headers, $form_content_type);
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Generate the MAC signature
|
319 |
+
*
|
320 |
+
* @param string $url Called URL
|
321 |
+
* @param array $parameters Parameters
|
322 |
+
* @param string $http_method Http Method
|
323 |
+
* @return string
|
324 |
+
*/
|
325 |
+
private function generateMACSignature($url, $parameters, $http_method)
|
326 |
+
{
|
327 |
+
$timestamp = time();
|
328 |
+
$nonce = uniqid();
|
329 |
+
$parsed_url = parse_url($url);
|
330 |
+
if (!isset($parsed_url['port']))
|
331 |
+
{
|
332 |
+
$parsed_url['port'] = ($parsed_url['scheme'] == 'https') ? 443 : 80;
|
333 |
+
}
|
334 |
+
if ($http_method == self::HTTP_METHOD_GET) {
|
335 |
+
if (is_array($parameters)) {
|
336 |
+
$parsed_url['path'] .= '?' . http_build_query($parameters, null, '&');
|
337 |
+
} elseif ($parameters) {
|
338 |
+
$parsed_url['path'] .= '?' . $parameters;
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
$signature = base64_encode(hash_hmac($this->access_token_algorithm,
|
343 |
+
$timestamp . "\n"
|
344 |
+
. $nonce . "\n"
|
345 |
+
. $http_method . "\n"
|
346 |
+
. $parsed_url['path'] . "\n"
|
347 |
+
. $parsed_url['host'] . "\n"
|
348 |
+
. $parsed_url['port'] . "\n\n"
|
349 |
+
, $this->access_token_secret, true));
|
350 |
+
|
351 |
+
return 'id="' . $this->access_token . '", ts="' . $timestamp . '", nonce="' . $nonce . '", mac="' . $signature . '"';
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Execute a request (with curl)
|
356 |
+
*
|
357 |
+
* @param string $url URL
|
358 |
+
* @param mixed $parameters Array of parameters
|
359 |
+
* @param string $http_method HTTP Method
|
360 |
+
* @param array $http_headers HTTP Headers
|
361 |
+
* @param int $form_content_type HTTP form content type to use
|
362 |
+
* @return array
|
363 |
+
*/
|
364 |
+
private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
|
365 |
+
{
|
366 |
+
|
367 |
+
$curl_options = array(
|
368 |
+
CURLOPT_RETURNTRANSFER => true,
|
369 |
+
CURLOPT_SSL_VERIFYPEER => true,
|
370 |
+
CURLOPT_CUSTOMREQUEST => $http_method
|
371 |
+
);
|
372 |
+
|
373 |
+
switch($http_method) {
|
374 |
+
case self::HTTP_METHOD_POST:
|
375 |
+
$curl_options[CURLOPT_POST] = true;
|
376 |
+
/* No break */
|
377 |
+
case self::HTTP_METHOD_PUT:
|
378 |
+
error_reporting(0);
|
379 |
+
/**
|
380 |
+
* Passing an array to CURLOPT_POSTFIELDS will encode the data as multipart/form-data,
|
381 |
+
* while passing a URL-encoded string will encode the data as application/x-www-form-urlencoded.
|
382 |
+
* http://php.net/manual/en/function.curl-setopt.php
|
383 |
+
*/
|
384 |
+
if(is_array($parameters) && self::HTTP_FORM_CONTENT_TYPE_APPLICATION === $form_content_type) {
|
385 |
+
$parameters = http_build_query($parameters);
|
386 |
+
}
|
387 |
+
$curl_options[CURLOPT_POSTFIELDS] = $parameters;
|
388 |
+
break;
|
389 |
+
case self::HTTP_METHOD_HEAD:
|
390 |
+
$curl_options[CURLOPT_NOBODY] = true;
|
391 |
+
/* No break */
|
392 |
+
case self::HTTP_METHOD_DELETE:
|
393 |
+
case self::HTTP_METHOD_GET:
|
394 |
+
if (is_array($parameters)) {
|
395 |
+
$url .= '?' . http_build_query($parameters, null, '&');
|
396 |
+
} elseif ($parameters) {
|
397 |
+
$url .= '?' . $parameters;
|
398 |
+
}
|
399 |
+
break;
|
400 |
+
default:
|
401 |
+
break;
|
402 |
+
}
|
403 |
+
|
404 |
+
$curl_options[CURLOPT_URL] = $url;
|
405 |
+
|
406 |
+
if (is_array($http_headers)) {
|
407 |
+
$header = array();
|
408 |
+
foreach($http_headers as $key => $parsed_urlvalue) {
|
409 |
+
$header[] = "$key: $parsed_urlvalue";
|
410 |
+
}
|
411 |
+
$curl_options[CURLOPT_HTTPHEADER] = $header;
|
412 |
+
}
|
413 |
+
|
414 |
+
$ch = curl_init();
|
415 |
+
curl_setopt_array($ch, $curl_options);
|
416 |
+
// https handling
|
417 |
+
if (!empty($this->certificate_file)) {
|
418 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
419 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
420 |
+
curl_setopt($ch, CURLOPT_CAINFO, $this->certificate_file);
|
421 |
+
} else {
|
422 |
+
// bypass ssl verification
|
423 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
424 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
|
425 |
+
}
|
426 |
+
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
|
427 |
+
$result = curl_exec($ch);
|
428 |
+
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
429 |
+
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
|
430 |
+
if ($curl_error = curl_error($ch)) {
|
431 |
+
throw new Exception($curl_error, Exception::CURL_ERROR);
|
432 |
+
} else {
|
433 |
+
$json_decode = json_decode($result, true);
|
434 |
+
}
|
435 |
+
curl_close($ch);
|
436 |
+
|
437 |
+
return array(
|
438 |
+
'result' => (null === $json_decode) ? $result : $json_decode,
|
439 |
+
'code' => $http_code,
|
440 |
+
'content_type' => $content_type
|
441 |
+
);
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Set the name of the parameter that carry the access token
|
446 |
+
*
|
447 |
+
* @param string $name Token parameter name
|
448 |
+
* @return void
|
449 |
+
*/
|
450 |
+
public function setAccessTokenParamName($name)
|
451 |
+
{
|
452 |
+
$this->access_token_param_name = $name;
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Converts the class name to camel case
|
457 |
+
*
|
458 |
+
* @param mixed $grant_type the grant type
|
459 |
+
* @return string
|
460 |
+
*/
|
461 |
+
private function convertToCamelCase($grant_type)
|
462 |
+
{
|
463 |
+
$parts = explode('_', $grant_type);
|
464 |
+
array_walk($parts, function(&$item) { $item = ucfirst($item);});
|
465 |
+
return implode('', $parts);
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
class Exception extends \Exception
|
470 |
+
{
|
471 |
+
const CURL_NOT_FOUND = 0x01;
|
472 |
+
const CURL_ERROR = 0x02;
|
473 |
+
const GRANT_TYPE_ERROR = 0x03;
|
474 |
+
const INVALID_CLIENT_AUTHENTICATION_TYPE = 0x04;
|
475 |
+
const INVALID_ACCESS_TOKEN_TYPE = 0x05;
|
476 |
+
}
|
477 |
+
|
478 |
+
class InvalidArgumentException extends \InvalidArgumentException
|
479 |
+
{
|
480 |
+
const INVALID_GRANT_TYPE = 0x01;
|
481 |
+
const CERTIFICATE_NOT_FOUND = 0x02;
|
482 |
+
const REQUIRE_PARAMS_AS_ARRAY = 0x03;
|
483 |
+
const MISSING_PARAMETER = 0x04;
|
484 |
+
}
|
lib/GoMage/Reddit/GrantType/AuthorizationCode.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace OAuth2\GrantType;
|
3 |
+
|
4 |
+
use OAuth2\InvalidArgumentException;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Authorization code Grant Type Validator
|
8 |
+
*/
|
9 |
+
class AuthorizationCode implements IGrantType
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Defines the Grant Type
|
13 |
+
*
|
14 |
+
* @var string Defaults to 'authorization_code'.
|
15 |
+
*/
|
16 |
+
const GRANT_TYPE = 'authorization_code';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Adds a specific Handling of the parameters
|
20 |
+
*
|
21 |
+
* @return array of Specific parameters to be sent.
|
22 |
+
* @param mixed $parameters the parameters array (passed by reference)
|
23 |
+
*/
|
24 |
+
public function validateParameters(&$parameters)
|
25 |
+
{
|
26 |
+
if (!isset($parameters['code']))
|
27 |
+
{
|
28 |
+
throw new InvalidArgumentException(
|
29 |
+
'The \'code\' parameter must be defined for the Authorization Code grant type',
|
30 |
+
InvalidArgumentException::MISSING_PARAMETER
|
31 |
+
);
|
32 |
+
}
|
33 |
+
elseif (!isset($parameters['redirect_uri']))
|
34 |
+
{
|
35 |
+
throw new InvalidArgumentException(
|
36 |
+
'The \'redirect_uri\' parameter must be defined for the Authorization Code grant type',
|
37 |
+
InvalidArgumentException::MISSING_PARAMETER
|
38 |
+
);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
lib/GoMage/Reddit/GrantType/IGrantType.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace OAuth2\GrantType;
|
3 |
+
/**
|
4 |
+
* Specific GrantType Interface
|
5 |
+
*/
|
6 |
+
interface IGrantType
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* Adds a specific Handling of the parameters
|
10 |
+
*
|
11 |
+
* @return array of Specific parameters to be sent.
|
12 |
+
* @param mixed $parameters the parameters array (passed by reference)
|
13 |
+
*/
|
14 |
+
public function validateParameters(&$parameters);
|
15 |
+
}
|
lib/GoMage/Tumblr/OAuth.php
ADDED
@@ -0,0 +1,874 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// vim: foldmethod=marker
|
3 |
+
|
4 |
+
/* Generic exception class
|
5 |
+
*/
|
6 |
+
class OAuthException extends Exception {
|
7 |
+
// pass
|
8 |
+
}
|
9 |
+
|
10 |
+
class OAuthConsumer {
|
11 |
+
public $key;
|
12 |
+
public $secret;
|
13 |
+
|
14 |
+
function __construct($key, $secret, $callback_url=NULL) {
|
15 |
+
$this->key = $key;
|
16 |
+
$this->secret = $secret;
|
17 |
+
$this->callback_url = $callback_url;
|
18 |
+
}
|
19 |
+
|
20 |
+
function __toString() {
|
21 |
+
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
class OAuthToken {
|
26 |
+
// access tokens and request tokens
|
27 |
+
public $key;
|
28 |
+
public $secret;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* key = the token
|
32 |
+
* secret = the token secret
|
33 |
+
*/
|
34 |
+
function __construct($key, $secret) {
|
35 |
+
$this->key = $key;
|
36 |
+
$this->secret = $secret;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* generates the basic string serialization of a token that a server
|
41 |
+
* would respond to request_token and access_token calls with
|
42 |
+
*/
|
43 |
+
function to_string() {
|
44 |
+
return "oauth_token=" .
|
45 |
+
OAuthUtil::urlencode_rfc3986($this->key) .
|
46 |
+
"&oauth_token_secret=" .
|
47 |
+
OAuthUtil::urlencode_rfc3986($this->secret);
|
48 |
+
}
|
49 |
+
|
50 |
+
function __toString() {
|
51 |
+
return $this->to_string();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* A class for implementing a Signature Method
|
57 |
+
* See section 9 ("Signing Requests") in the spec
|
58 |
+
*/
|
59 |
+
abstract class OAuthSignatureMethod {
|
60 |
+
/**
|
61 |
+
* Needs to return the name of the Signature Method (ie HMAC-SHA1)
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
abstract public function get_name();
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Build up the signature
|
68 |
+
* NOTE: The output of this function MUST NOT be urlencoded.
|
69 |
+
* the encoding is handled in OAuthRequest when the final
|
70 |
+
* request is serialized
|
71 |
+
* @param OAuthRequest $request
|
72 |
+
* @param OAuthConsumer $consumer
|
73 |
+
* @param OAuthToken $token
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
abstract public function build_signature($request, $consumer, $token);
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Verifies that a given signature is correct
|
80 |
+
* @param OAuthRequest $request
|
81 |
+
* @param OAuthConsumer $consumer
|
82 |
+
* @param OAuthToken $token
|
83 |
+
* @param string $signature
|
84 |
+
* @return bool
|
85 |
+
*/
|
86 |
+
public function check_signature($request, $consumer, $token, $signature) {
|
87 |
+
$built = $this->build_signature($request, $consumer, $token);
|
88 |
+
return $built == $signature;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
|
94 |
+
* where the Signature Base String is the text and the key is the concatenated values (each first
|
95 |
+
* encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
|
96 |
+
* character (ASCII code 38) even if empty.
|
97 |
+
* - Chapter 9.2 ("HMAC-SHA1")
|
98 |
+
*/
|
99 |
+
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
|
100 |
+
function get_name() {
|
101 |
+
return "HMAC-SHA1";
|
102 |
+
}
|
103 |
+
|
104 |
+
public function build_signature($request, $consumer, $token) {
|
105 |
+
$base_string = $request->get_signature_base_string();
|
106 |
+
$request->base_string = $base_string;
|
107 |
+
|
108 |
+
$key_parts = array(
|
109 |
+
$consumer->secret,
|
110 |
+
($token) ? $token->secret : ""
|
111 |
+
);
|
112 |
+
|
113 |
+
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
114 |
+
$key = implode('&', $key_parts);
|
115 |
+
|
116 |
+
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* The PLAINTEXT method does not provide any security protection and SHOULD only be used
|
122 |
+
* over a secure channel such as HTTPS. It does not use the Signature Base String.
|
123 |
+
* - Chapter 9.4 ("PLAINTEXT")
|
124 |
+
*/
|
125 |
+
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
|
126 |
+
public function get_name() {
|
127 |
+
return "PLAINTEXT";
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* oauth_signature is set to the concatenated encoded values of the Consumer Secret and
|
132 |
+
* Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
|
133 |
+
* empty. The result MUST be encoded again.
|
134 |
+
* - Chapter 9.4.1 ("Generating Signatures")
|
135 |
+
*
|
136 |
+
* Please note that the second encoding MUST NOT happen in the SignatureMethod, as
|
137 |
+
* OAuthRequest handles this!
|
138 |
+
*/
|
139 |
+
public function build_signature($request, $consumer, $token) {
|
140 |
+
$key_parts = array(
|
141 |
+
$consumer->secret,
|
142 |
+
($token) ? $token->secret : ""
|
143 |
+
);
|
144 |
+
|
145 |
+
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
146 |
+
$key = implode('&', $key_parts);
|
147 |
+
$request->base_string = $key;
|
148 |
+
|
149 |
+
return $key;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
|
155 |
+
* [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
|
156 |
+
* EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
|
157 |
+
* verified way to the Service Provider, in a manner which is beyond the scope of this
|
158 |
+
* specification.
|
159 |
+
* - Chapter 9.3 ("RSA-SHA1")
|
160 |
+
*/
|
161 |
+
abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
|
162 |
+
public function get_name() {
|
163 |
+
return "RSA-SHA1";
|
164 |
+
}
|
165 |
+
|
166 |
+
// Up to the SP to implement this lookup of keys. Possible ideas are:
|
167 |
+
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
168 |
+
// (2) fetch via http using a url provided by the requester
|
169 |
+
// (3) some sort of specific discovery code based on request
|
170 |
+
//
|
171 |
+
// Either way should return a string representation of the certificate
|
172 |
+
protected abstract function fetch_public_cert(&$request);
|
173 |
+
|
174 |
+
// Up to the SP to implement this lookup of keys. Possible ideas are:
|
175 |
+
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
176 |
+
//
|
177 |
+
// Either way should return a string representation of the certificate
|
178 |
+
protected abstract function fetch_private_cert(&$request);
|
179 |
+
|
180 |
+
public function build_signature($request, $consumer, $token) {
|
181 |
+
$base_string = $request->get_signature_base_string();
|
182 |
+
$request->base_string = $base_string;
|
183 |
+
|
184 |
+
// Fetch the private key cert based on the request
|
185 |
+
$cert = $this->fetch_private_cert($request);
|
186 |
+
|
187 |
+
// Pull the private key ID from the certificate
|
188 |
+
$privatekeyid = openssl_get_privatekey($cert);
|
189 |
+
|
190 |
+
// Sign using the key
|
191 |
+
$ok = openssl_sign($base_string, $signature, $privatekeyid);
|
192 |
+
|
193 |
+
// Release the key resource
|
194 |
+
openssl_free_key($privatekeyid);
|
195 |
+
|
196 |
+
return base64_encode($signature);
|
197 |
+
}
|
198 |
+
|
199 |
+
public function check_signature($request, $consumer, $token, $signature) {
|
200 |
+
$decoded_sig = base64_decode($signature);
|
201 |
+
|
202 |
+
$base_string = $request->get_signature_base_string();
|
203 |
+
|
204 |
+
// Fetch the public key cert based on the request
|
205 |
+
$cert = $this->fetch_public_cert($request);
|
206 |
+
|
207 |
+
// Pull the public key ID from the certificate
|
208 |
+
$publickeyid = openssl_get_publickey($cert);
|
209 |
+
|
210 |
+
// Check the computed signature against the one passed in the query
|
211 |
+
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
|
212 |
+
|
213 |
+
// Release the key resource
|
214 |
+
openssl_free_key($publickeyid);
|
215 |
+
|
216 |
+
return $ok == 1;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
class OAuthRequest {
|
221 |
+
private $parameters;
|
222 |
+
private $http_method;
|
223 |
+
private $http_url;
|
224 |
+
// for debug purposes
|
225 |
+
public $base_string;
|
226 |
+
public static $version = '1.0';
|
227 |
+
public static $POST_INPUT = 'php://input';
|
228 |
+
|
229 |
+
function __construct($http_method, $http_url, $parameters=NULL) {
|
230 |
+
@$parameters or $parameters = array();
|
231 |
+
$parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
232 |
+
$this->parameters = $parameters;
|
233 |
+
$this->http_method = $http_method;
|
234 |
+
$this->http_url = $http_url;
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
/**
|
239 |
+
* attempt to build up a request from what was passed to the server
|
240 |
+
*/
|
241 |
+
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
|
242 |
+
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
|
243 |
+
? 'http'
|
244 |
+
: 'https';
|
245 |
+
@$http_url or $http_url = $scheme .
|
246 |
+
'://' . $_SERVER['HTTP_HOST'] .
|
247 |
+
':' .
|
248 |
+
$_SERVER['SERVER_PORT'] .
|
249 |
+
$_SERVER['REQUEST_URI'];
|
250 |
+
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
|
251 |
+
|
252 |
+
// We weren't handed any parameters, so let's find the ones relevant to
|
253 |
+
// this request.
|
254 |
+
// If you run XML-RPC or similar you should use this to provide your own
|
255 |
+
// parsed parameter-list
|
256 |
+
if (!$parameters) {
|
257 |
+
// Find request headers
|
258 |
+
$request_headers = OAuthUtil::get_headers();
|
259 |
+
|
260 |
+
// Parse the query-string to find GET parameters
|
261 |
+
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
|
262 |
+
|
263 |
+
// It's a POST request of the proper content-type, so parse POST
|
264 |
+
// parameters and add those overriding any duplicates from GET
|
265 |
+
if ($http_method == "POST"
|
266 |
+
&& @strstr($request_headers["Content-Type"],
|
267 |
+
"application/x-www-form-urlencoded")
|
268 |
+
) {
|
269 |
+
$post_data = OAuthUtil::parse_parameters(
|
270 |
+
file_get_contents(self::$POST_INPUT)
|
271 |
+
);
|
272 |
+
$parameters = array_merge($parameters, $post_data);
|
273 |
+
}
|
274 |
+
|
275 |
+
// We have a Authorization-header with OAuth data. Parse the header
|
276 |
+
// and add those overriding any duplicates from GET or POST
|
277 |
+
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
|
278 |
+
$header_parameters = OAuthUtil::split_header(
|
279 |
+
$request_headers['Authorization']
|
280 |
+
);
|
281 |
+
$parameters = array_merge($parameters, $header_parameters);
|
282 |
+
}
|
283 |
+
|
284 |
+
}
|
285 |
+
|
286 |
+
return new OAuthRequest($http_method, $http_url, $parameters);
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* pretty much a helper function to set up the request
|
291 |
+
*/
|
292 |
+
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
|
293 |
+
@$parameters or $parameters = array();
|
294 |
+
$defaults = array("oauth_version" => OAuthRequest::$version,
|
295 |
+
"oauth_nonce" => OAuthRequest::generate_nonce(),
|
296 |
+
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
|
297 |
+
"oauth_consumer_key" => $consumer->key);
|
298 |
+
if ($token)
|
299 |
+
$defaults['oauth_token'] = $token->key;
|
300 |
+
|
301 |
+
$parameters = array_merge($defaults, $parameters);
|
302 |
+
|
303 |
+
return new OAuthRequest($http_method, $http_url, $parameters);
|
304 |
+
}
|
305 |
+
|
306 |
+
public function set_parameter($name, $value, $allow_duplicates = true) {
|
307 |
+
if ($allow_duplicates && isset($this->parameters[$name])) {
|
308 |
+
// We have already added parameter(s) with this name, so add to the list
|
309 |
+
if (is_scalar($this->parameters[$name])) {
|
310 |
+
// This is the first duplicate, so transform scalar (string)
|
311 |
+
// into an array so we can add the duplicates
|
312 |
+
$this->parameters[$name] = array($this->parameters[$name]);
|
313 |
+
}
|
314 |
+
|
315 |
+
$this->parameters[$name][] = $value;
|
316 |
+
} else {
|
317 |
+
$this->parameters[$name] = $value;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
public function get_parameter($name) {
|
322 |
+
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
|
323 |
+
}
|
324 |
+
|
325 |
+
public function get_parameters() {
|
326 |
+
return $this->parameters;
|
327 |
+
}
|
328 |
+
|
329 |
+
public function unset_parameter($name) {
|
330 |
+
unset($this->parameters[$name]);
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* The request parameters, sorted and concatenated into a normalized string.
|
335 |
+
* @return string
|
336 |
+
*/
|
337 |
+
public function get_signable_parameters() {
|
338 |
+
// Grab all parameters
|
339 |
+
$params = $this->parameters;
|
340 |
+
|
341 |
+
// Remove oauth_signature if present
|
342 |
+
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
|
343 |
+
if (isset($params['oauth_signature'])) {
|
344 |
+
unset($params['oauth_signature']);
|
345 |
+
}
|
346 |
+
|
347 |
+
return OAuthUtil::build_http_query($params);
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Returns the base string of this request
|
352 |
+
*
|
353 |
+
* The base string defined as the method, the url
|
354 |
+
* and the parameters (normalized), each urlencoded
|
355 |
+
* and the concated with &.
|
356 |
+
*/
|
357 |
+
public function get_signature_base_string() {
|
358 |
+
$parts = array(
|
359 |
+
$this->get_normalized_http_method(),
|
360 |
+
$this->get_normalized_http_url(),
|
361 |
+
$this->get_signable_parameters()
|
362 |
+
);
|
363 |
+
|
364 |
+
$parts = OAuthUtil::urlencode_rfc3986($parts);
|
365 |
+
|
366 |
+
return implode('&', $parts);
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* just uppercases the http method
|
371 |
+
*/
|
372 |
+
public function get_normalized_http_method() {
|
373 |
+
return strtoupper($this->http_method);
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* parses the url and rebuilds it to be
|
378 |
+
* scheme://host/path
|
379 |
+
*/
|
380 |
+
public function get_normalized_http_url() {
|
381 |
+
$parts = parse_url($this->http_url);
|
382 |
+
|
383 |
+
$port = @$parts['port'];
|
384 |
+
$scheme = $parts['scheme'];
|
385 |
+
$host = $parts['host'];
|
386 |
+
$path = @$parts['path'];
|
387 |
+
|
388 |
+
$port or $port = ($scheme == 'https') ? '443' : '80';
|
389 |
+
|
390 |
+
if (($scheme == 'https' && $port != '443')
|
391 |
+
|| ($scheme == 'http' && $port != '80')) {
|
392 |
+
$host = "$host:$port";
|
393 |
+
}
|
394 |
+
return "$scheme://$host$path";
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* builds a url usable for a GET request
|
399 |
+
*/
|
400 |
+
public function to_url() {
|
401 |
+
$post_data = $this->to_postdata();
|
402 |
+
$out = $this->get_normalized_http_url();
|
403 |
+
if ($post_data) {
|
404 |
+
$out .= '?'.$post_data;
|
405 |
+
}
|
406 |
+
return $out;
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* builds the data one would send in a POST request
|
411 |
+
*/
|
412 |
+
public function to_postdata() {
|
413 |
+
return OAuthUtil::build_http_query($this->parameters);
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* builds the Authorization: header
|
418 |
+
*/
|
419 |
+
public function to_header($realm=null) {
|
420 |
+
$first = true;
|
421 |
+
if($realm) {
|
422 |
+
$out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
|
423 |
+
$first = false;
|
424 |
+
} else
|
425 |
+
$out = 'Authorization: OAuth';
|
426 |
+
|
427 |
+
$total = array();
|
428 |
+
foreach ($this->parameters as $k => $v) {
|
429 |
+
if (substr($k, 0, 5) != "oauth") continue;
|
430 |
+
if (is_array($v)) {
|
431 |
+
throw new OAuthException('Arrays not supported in headers');
|
432 |
+
}
|
433 |
+
$out .= ($first) ? ' ' : ',';
|
434 |
+
$out .= OAuthUtil::urlencode_rfc3986($k) .
|
435 |
+
'="' .
|
436 |
+
OAuthUtil::urlencode_rfc3986($v) .
|
437 |
+
'"';
|
438 |
+
$first = false;
|
439 |
+
}
|
440 |
+
return $out;
|
441 |
+
}
|
442 |
+
|
443 |
+
public function __toString() {
|
444 |
+
return $this->to_url();
|
445 |
+
}
|
446 |
+
|
447 |
+
|
448 |
+
public function sign_request($signature_method, $consumer, $token) {
|
449 |
+
$this->set_parameter(
|
450 |
+
"oauth_signature_method",
|
451 |
+
$signature_method->get_name(),
|
452 |
+
false
|
453 |
+
);
|
454 |
+
$signature = $this->build_signature($signature_method, $consumer, $token);
|
455 |
+
$this->set_parameter("oauth_signature", $signature, false);
|
456 |
+
}
|
457 |
+
|
458 |
+
public function build_signature($signature_method, $consumer, $token) {
|
459 |
+
$signature = $signature_method->build_signature($this, $consumer, $token);
|
460 |
+
return $signature;
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* util function: current timestamp
|
465 |
+
*/
|
466 |
+
private static function generate_timestamp() {
|
467 |
+
return time();
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* util function: current nonce
|
472 |
+
*/
|
473 |
+
private static function generate_nonce() {
|
474 |
+
$mt = microtime();
|
475 |
+
$rand = mt_rand();
|
476 |
+
|
477 |
+
return md5($mt . $rand); // md5s look nicer than numbers
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
class OAuthServer {
|
482 |
+
protected $timestamp_threshold = 300; // in seconds, five minutes
|
483 |
+
protected $version = '1.0'; // hi blaine
|
484 |
+
protected $signature_methods = array();
|
485 |
+
|
486 |
+
protected $data_store;
|
487 |
+
|
488 |
+
function __construct($data_store) {
|
489 |
+
$this->data_store = $data_store;
|
490 |
+
}
|
491 |
+
|
492 |
+
public function add_signature_method($signature_method) {
|
493 |
+
$this->signature_methods[$signature_method->get_name()] =
|
494 |
+
$signature_method;
|
495 |
+
}
|
496 |
+
|
497 |
+
// high level functions
|
498 |
+
|
499 |
+
/**
|
500 |
+
* process a request_token request
|
501 |
+
* returns the request token on success
|
502 |
+
*/
|
503 |
+
public function fetch_request_token(&$request) {
|
504 |
+
$this->get_version($request);
|
505 |
+
|
506 |
+
$consumer = $this->get_consumer($request);
|
507 |
+
|
508 |
+
// no token required for the initial token request
|
509 |
+
$token = NULL;
|
510 |
+
|
511 |
+
$this->check_signature($request, $consumer, $token);
|
512 |
+
|
513 |
+
// Rev A change
|
514 |
+
$callback = $request->get_parameter('oauth_callback');
|
515 |
+
$new_token = $this->data_store->new_request_token($consumer, $callback);
|
516 |
+
|
517 |
+
return $new_token;
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* process an access_token request
|
522 |
+
* returns the access token on success
|
523 |
+
*/
|
524 |
+
public function fetch_access_token(&$request) {
|
525 |
+
$this->get_version($request);
|
526 |
+
|
527 |
+
$consumer = $this->get_consumer($request);
|
528 |
+
|
529 |
+
// requires authorized request token
|
530 |
+
$token = $this->get_token($request, $consumer, "request");
|
531 |
+
|
532 |
+
$this->check_signature($request, $consumer, $token);
|
533 |
+
|
534 |
+
// Rev A change
|
535 |
+
$verifier = $request->get_parameter('oauth_verifier');
|
536 |
+
$new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
|
537 |
+
|
538 |
+
return $new_token;
|
539 |
+
}
|
540 |
+
|
541 |
+
/**
|
542 |
+
* verify an api call, checks all the parameters
|
543 |
+
*/
|
544 |
+
public function verify_request(&$request) {
|
545 |
+
$this->get_version($request);
|
546 |
+
$consumer = $this->get_consumer($request);
|
547 |
+
$token = $this->get_token($request, $consumer, "access");
|
548 |
+
$this->check_signature($request, $consumer, $token);
|
549 |
+
return array($consumer, $token);
|
550 |
+
}
|
551 |
+
|
552 |
+
// Internals from here
|
553 |
+
/**
|
554 |
+
* version 1
|
555 |
+
*/
|
556 |
+
private function get_version(&$request) {
|
557 |
+
$version = $request->get_parameter("oauth_version");
|
558 |
+
if (!$version) {
|
559 |
+
// Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
|
560 |
+
// Chapter 7.0 ("Accessing Protected Ressources")
|
561 |
+
$version = '1.0';
|
562 |
+
}
|
563 |
+
if ($version !== $this->version) {
|
564 |
+
throw new OAuthException("OAuth version '$version' not supported");
|
565 |
+
}
|
566 |
+
return $version;
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* figure out the signature with some defaults
|
571 |
+
*/
|
572 |
+
private function get_signature_method(&$request) {
|
573 |
+
$signature_method =
|
574 |
+
@$request->get_parameter("oauth_signature_method");
|
575 |
+
|
576 |
+
if (!$signature_method) {
|
577 |
+
// According to chapter 7 ("Accessing Protected Ressources") the signature-method
|
578 |
+
// parameter is required, and we can't just fallback to PLAINTEXT
|
579 |
+
throw new OAuthException('No signature method parameter. This parameter is required');
|
580 |
+
}
|
581 |
+
|
582 |
+
if (!in_array($signature_method,
|
583 |
+
array_keys($this->signature_methods))) {
|
584 |
+
throw new OAuthException(
|
585 |
+
"Signature method '$signature_method' not supported " .
|
586 |
+
"try one of the following: " .
|
587 |
+
implode(", ", array_keys($this->signature_methods))
|
588 |
+
);
|
589 |
+
}
|
590 |
+
return $this->signature_methods[$signature_method];
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* try to find the consumer for the provided request's consumer key
|
595 |
+
*/
|
596 |
+
private function get_consumer(&$request) {
|
597 |
+
$consumer_key = @$request->get_parameter("oauth_consumer_key");
|
598 |
+
if (!$consumer_key) {
|
599 |
+
throw new OAuthException("Invalid consumer key");
|
600 |
+
}
|
601 |
+
|
602 |
+
$consumer = $this->data_store->lookup_consumer($consumer_key);
|
603 |
+
if (!$consumer) {
|
604 |
+
throw new OAuthException("Invalid consumer");
|
605 |
+
}
|
606 |
+
|
607 |
+
return $consumer;
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* try to find the token for the provided request's token key
|
612 |
+
*/
|
613 |
+
private function get_token(&$request, $consumer, $token_type="access") {
|
614 |
+
$token_field = @$request->get_parameter('oauth_token');
|
615 |
+
$token = $this->data_store->lookup_token(
|
616 |
+
$consumer, $token_type, $token_field
|
617 |
+
);
|
618 |
+
if (!$token) {
|
619 |
+
throw new OAuthException("Invalid $token_type token: $token_field");
|
620 |
+
}
|
621 |
+
return $token;
|
622 |
+
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
* all-in-one function to check the signature on a request
|
626 |
+
* should guess the signature method appropriately
|
627 |
+
*/
|
628 |
+
private function check_signature(&$request, $consumer, $token) {
|
629 |
+
// this should probably be in a different method
|
630 |
+
$timestamp = @$request->get_parameter('oauth_timestamp');
|
631 |
+
$nonce = @$request->get_parameter('oauth_nonce');
|
632 |
+
|
633 |
+
$this->check_timestamp($timestamp);
|
634 |
+
$this->check_nonce($consumer, $token, $nonce, $timestamp);
|
635 |
+
|
636 |
+
$signature_method = $this->get_signature_method($request);
|
637 |
+
|
638 |
+
$signature = $request->get_parameter('oauth_signature');
|
639 |
+
$valid_sig = $signature_method->check_signature(
|
640 |
+
$request,
|
641 |
+
$consumer,
|
642 |
+
$token,
|
643 |
+
$signature
|
644 |
+
);
|
645 |
+
|
646 |
+
if (!$valid_sig) {
|
647 |
+
throw new OAuthException("Invalid signature");
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
/**
|
652 |
+
* check that the timestamp is new enough
|
653 |
+
*/
|
654 |
+
private function check_timestamp($timestamp) {
|
655 |
+
if( ! $timestamp )
|
656 |
+
throw new OAuthException(
|
657 |
+
'Missing timestamp parameter. The parameter is required'
|
658 |
+
);
|
659 |
+
|
660 |
+
// verify that timestamp is recentish
|
661 |
+
$now = time();
|
662 |
+
if (abs($now - $timestamp) > $this->timestamp_threshold) {
|
663 |
+
throw new OAuthException(
|
664 |
+
"Expired timestamp, yours $timestamp, ours $now"
|
665 |
+
);
|
666 |
+
}
|
667 |
+
}
|
668 |
+
|
669 |
+
/**
|
670 |
+
* check that the nonce is not repeated
|
671 |
+
*/
|
672 |
+
private function check_nonce($consumer, $token, $nonce, $timestamp) {
|
673 |
+
if( ! $nonce )
|
674 |
+
throw new OAuthException(
|
675 |
+
'Missing nonce parameter. The parameter is required'
|
676 |
+
);
|
677 |
+
|
678 |
+
// verify that the nonce is uniqueish
|
679 |
+
$found = $this->data_store->lookup_nonce(
|
680 |
+
$consumer,
|
681 |
+
$token,
|
682 |
+
$nonce,
|
683 |
+
$timestamp
|
684 |
+
);
|
685 |
+
if ($found) {
|
686 |
+
throw new OAuthException("Nonce already used: $nonce");
|
687 |
+
}
|
688 |
+
}
|
689 |
+
|
690 |
+
}
|
691 |
+
|
692 |
+
class OAuthDataStore {
|
693 |
+
function lookup_consumer($consumer_key) {
|
694 |
+
// implement me
|
695 |
+
}
|
696 |
+
|
697 |
+
function lookup_token($consumer, $token_type, $token) {
|
698 |
+
// implement me
|
699 |
+
}
|
700 |
+
|
701 |
+
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
|
702 |
+
// implement me
|
703 |
+
}
|
704 |
+
|
705 |
+
function new_request_token($consumer, $callback = null) {
|
706 |
+
// return a new token attached to this consumer
|
707 |
+
}
|
708 |
+
|
709 |
+
function new_access_token($token, $consumer, $verifier = null) {
|
710 |
+
// return a new access token attached to this consumer
|
711 |
+
// for the user associated with this token if the request token
|
712 |
+
// is authorized
|
713 |
+
// should also invalidate the request token
|
714 |
+
}
|
715 |
+
|
716 |
+
}
|
717 |
+
|
718 |
+
class OAuthUtil {
|
719 |
+
public static function urlencode_rfc3986($input) {
|
720 |
+
if (is_array($input)) {
|
721 |
+
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
|
722 |
+
} else if (is_scalar($input)) {
|
723 |
+
return str_replace(
|
724 |
+
'+',
|
725 |
+
' ',
|
726 |
+
str_replace('%7E', '~', rawurlencode($input))
|
727 |
+
);
|
728 |
+
} else {
|
729 |
+
return '';
|
730 |
+
}
|
731 |
+
}
|
732 |
+
|
733 |
+
|
734 |
+
// This decode function isn't taking into consideration the above
|
735 |
+
// modifications to the encoding process. However, this method doesn't
|
736 |
+
// seem to be used anywhere so leaving it as is.
|
737 |
+
public static function urldecode_rfc3986($string) {
|
738 |
+
return urldecode($string);
|
739 |
+
}
|
740 |
+
|
741 |
+
// Utility function for turning the Authorization: header into
|
742 |
+
// parameters, has to do some unescaping
|
743 |
+
// Can filter out any non-oauth parameters if needed (default behaviour)
|
744 |
+
public static function split_header($header, $only_allow_oauth_parameters = true) {
|
745 |
+
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
|
746 |
+
$offset = 0;
|
747 |
+
$params = array();
|
748 |
+
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
|
749 |
+
$match = $matches[0];
|
750 |
+
$header_name = $matches[2][0];
|
751 |
+
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
|
752 |
+
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
|
753 |
+
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
|
754 |
+
}
|
755 |
+
$offset = $match[1] + strlen($match[0]);
|
756 |
+
}
|
757 |
+
|
758 |
+
if (isset($params['realm'])) {
|
759 |
+
unset($params['realm']);
|
760 |
+
}
|
761 |
+
|
762 |
+
return $params;
|
763 |
+
}
|
764 |
+
|
765 |
+
// helper to try to sort out headers for people who aren't running apache
|
766 |
+
public static function get_headers() {
|
767 |
+
if (function_exists('apache_request_headers')) {
|
768 |
+
// we need this to get the actual Authorization: header
|
769 |
+
// because apache tends to tell us it doesn't exist
|
770 |
+
$headers = apache_request_headers();
|
771 |
+
|
772 |
+
// sanitize the output of apache_request_headers because
|
773 |
+
// we always want the keys to be Cased-Like-This and arh()
|
774 |
+
// returns the headers in the same case as they are in the
|
775 |
+
// request
|
776 |
+
$out = array();
|
777 |
+
foreach( $headers AS $key => $value ) {
|
778 |
+
$key = str_replace(
|
779 |
+
" ",
|
780 |
+
"-",
|
781 |
+
ucwords(strtolower(str_replace("-", " ", $key)))
|
782 |
+
);
|
783 |
+
$out[$key] = $value;
|
784 |
+
}
|
785 |
+
} else {
|
786 |
+
// otherwise we don't have apache and are just going to have to hope
|
787 |
+
// that $_SERVER actually contains what we need
|
788 |
+
$out = array();
|
789 |
+
if( isset($_SERVER['CONTENT_TYPE']) )
|
790 |
+
$out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
|
791 |
+
if( isset($_ENV['CONTENT_TYPE']) )
|
792 |
+
$out['Content-Type'] = $_ENV['CONTENT_TYPE'];
|
793 |
+
|
794 |
+
foreach ($_SERVER as $key => $value) {
|
795 |
+
if (substr($key, 0, 5) == "HTTP_") {
|
796 |
+
// this is chaos, basically it is just there to capitalize the first
|
797 |
+
// letter of every word that is not an initial HTTP and strip HTTP
|
798 |
+
// code from przemek
|
799 |
+
$key = str_replace(
|
800 |
+
" ",
|
801 |
+
"-",
|
802 |
+
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
|
803 |
+
);
|
804 |
+
$out[$key] = $value;
|
805 |
+
}
|
806 |
+
}
|
807 |
+
}
|
808 |
+
return $out;
|
809 |
+
}
|
810 |
+
|
811 |
+
// This function takes a input like a=b&a=c&d=e and returns the parsed
|
812 |
+
// parameters like this
|
813 |
+
// array('a' => array('b','c'), 'd' => 'e')
|
814 |
+
public static function parse_parameters( $input ) {
|
815 |
+
if (!isset($input) || !$input) return array();
|
816 |
+
|
817 |
+
$pairs = explode('&', $input);
|
818 |
+
|
819 |
+
$parsed_parameters = array();
|
820 |
+
foreach ($pairs as $pair) {
|
821 |
+
$split = explode('=', $pair, 2);
|
822 |
+
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
|
823 |
+
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
|
824 |
+
|
825 |
+
if (isset($parsed_parameters[$parameter])) {
|
826 |
+
// We have already recieved parameter(s) with this name, so add to the list
|
827 |
+
// of parameters with this name
|
828 |
+
|
829 |
+
if (is_scalar($parsed_parameters[$parameter])) {
|
830 |
+
// This is the first duplicate, so transform scalar (string) into an array
|
831 |
+
// so we can add the duplicates
|
832 |
+
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
|
833 |
+
}
|
834 |
+
|
835 |
+
$parsed_parameters[$parameter][] = $value;
|
836 |
+
} else {
|
837 |
+
$parsed_parameters[$parameter] = $value;
|
838 |
+
}
|
839 |
+
}
|
840 |
+
return $parsed_parameters;
|
841 |
+
}
|
842 |
+
|
843 |
+
public static function build_http_query($params) {
|
844 |
+
if (!$params) return '';
|
845 |
+
|
846 |
+
// Urlencode both keys and values
|
847 |
+
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
|
848 |
+
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
|
849 |
+
$params = array_combine($keys, $values);
|
850 |
+
|
851 |
+
// Parameters are sorted by name, using lexicographical byte value ordering.
|
852 |
+
// Ref: Spec: 9.1.1 (1)
|
853 |
+
uksort($params, 'strcmp');
|
854 |
+
|
855 |
+
$pairs = array();
|
856 |
+
foreach ($params as $parameter => $value) {
|
857 |
+
if (is_array($value)) {
|
858 |
+
// If two or more parameters share the same name, they are sorted by their value
|
859 |
+
// Ref: Spec: 9.1.1 (1)
|
860 |
+
natsort($value);
|
861 |
+
foreach ($value as $duplicate_value) {
|
862 |
+
$pairs[] = $parameter . '=' . $duplicate_value;
|
863 |
+
}
|
864 |
+
} else {
|
865 |
+
$pairs[] = $parameter . '=' . $value;
|
866 |
+
}
|
867 |
+
}
|
868 |
+
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
|
869 |
+
// Each name-value pair is separated by an '&' character (ASCII code 38)
|
870 |
+
return implode('&', $pairs);
|
871 |
+
}
|
872 |
+
}
|
873 |
+
|
874 |
+
?>
|
lib/GoMage/Tumblr/tumblroauth.php
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Abraham Williams (abraham@abrah.am) http://abrah.am
|
5 |
+
*
|
6 |
+
* The first PHP Library to support OAuth for Tumblr's REST API. (Originally for Twitter, modified for Tumblr by Lucas)
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* Load OAuth lib. You can find it at http://oauth.net */
|
10 |
+
require_once('OAuth.php');
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Tumblr OAuth class
|
14 |
+
*/
|
15 |
+
class TumblrOAuth {
|
16 |
+
/* Contains the last HTTP status code returned. */
|
17 |
+
public $http_code;
|
18 |
+
/* Contains the last API call. */
|
19 |
+
public $url;
|
20 |
+
/* Set up the API root URL. */
|
21 |
+
public $host = "http://api.tumblr.com/v2/";
|
22 |
+
/* Set timeout default. */
|
23 |
+
public $timeout = 30;
|
24 |
+
/* Set connect timeout. */
|
25 |
+
public $connecttimeout = 30;
|
26 |
+
/* Verify SSL Cert. */
|
27 |
+
public $ssl_verifypeer = FALSE;
|
28 |
+
/* Respons format. */
|
29 |
+
public $format = 'json';
|
30 |
+
/* Decode returned json data. */
|
31 |
+
public $decode_json = TRUE;
|
32 |
+
/* Contains the last HTTP headers returned. */
|
33 |
+
public $http_info;
|
34 |
+
/* Set the useragnet. */
|
35 |
+
public $useragent = 'TumblrOAuth v0.2.0-beta2';
|
36 |
+
/* Immediately retry the API call if the response was not successful. */
|
37 |
+
//public $retry = TRUE;
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Set API URLS
|
44 |
+
*/
|
45 |
+
function accessTokenURL() { return 'http://www.tumblr.com/oauth/access_token'; }
|
46 |
+
function authenticateURL() { return 'http://www.tumblr.com/oauth/authorize'; }
|
47 |
+
function authorizeURL() { return 'http://www.tumblr.com/oauth/authorize'; }
|
48 |
+
function requestTokenURL() { return 'http://www.tumblr.com/oauth/request_token'; }
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Debug helpers
|
52 |
+
*/
|
53 |
+
function lastStatusCode() { return $this->http_status; }
|
54 |
+
function lastAPICall() { return $this->last_api_call; }
|
55 |
+
|
56 |
+
/**
|
57 |
+
* construct TumblrOAuth object
|
58 |
+
*/
|
59 |
+
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
|
60 |
+
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
|
61 |
+
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
|
62 |
+
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
|
63 |
+
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
|
64 |
+
} else {
|
65 |
+
$this->token = NULL;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get a request_token from Tumblr
|
72 |
+
*
|
73 |
+
* @returns a key/value array containing oauth_token and oauth_token_secret
|
74 |
+
*/
|
75 |
+
function getRequestToken($oauth_callback = NULL) {
|
76 |
+
$parameters = array();
|
77 |
+
if (!empty($oauth_callback)) {
|
78 |
+
$parameters['oauth_callback'] = $oauth_callback;
|
79 |
+
}
|
80 |
+
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
|
81 |
+
$token = OAuthUtil::parse_parameters($request);
|
82 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
83 |
+
return $token;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Get the authorize URL
|
88 |
+
*
|
89 |
+
* @returns a string
|
90 |
+
*/
|
91 |
+
function getAuthorizeURL($token, $sign_in_with_tumblr = TRUE) {
|
92 |
+
if (is_array($token)) {
|
93 |
+
$token = $token['oauth_token'];
|
94 |
+
}
|
95 |
+
if (empty($sign_in_with_tumblr)) {
|
96 |
+
return $this->authorizeURL() . "?oauth_token={$token}";
|
97 |
+
} else {
|
98 |
+
return $this->authenticateURL() . "?oauth_token={$token}";
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Exchange request token and secret for an access token and
|
104 |
+
* secret, to sign API calls.
|
105 |
+
*
|
106 |
+
* @returns array("oauth_token" => "the-access-token",
|
107 |
+
* "oauth_token_secret" => "the-access-secret",
|
108 |
+
* "user_id" => "9436992",
|
109 |
+
* "screen_name" => "abraham")
|
110 |
+
*/
|
111 |
+
function getAccessToken($oauth_verifier = FALSE) {
|
112 |
+
$parameters = array();
|
113 |
+
if (!empty($oauth_verifier)) {
|
114 |
+
$parameters['oauth_verifier'] = $oauth_verifier;
|
115 |
+
}
|
116 |
+
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
|
117 |
+
$token = OAuthUtil::parse_parameters($request);
|
118 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
119 |
+
return $token;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* One time exchange of username and password for access token and secret.
|
124 |
+
*
|
125 |
+
* @returns array("oauth_token" => "the-access-token",
|
126 |
+
* "oauth_token_secret" => "the-access-secret",
|
127 |
+
* "user_id" => "9436992",
|
128 |
+
* "screen_name" => "abraham",
|
129 |
+
* "x_auth_expires" => "0")
|
130 |
+
*/
|
131 |
+
function getXAuthToken($username, $password) {
|
132 |
+
$parameters = array();
|
133 |
+
$parameters['x_auth_username'] = $username;
|
134 |
+
$parameters['x_auth_password'] = $password;
|
135 |
+
$parameters['x_auth_mode'] = 'client_auth';
|
136 |
+
$request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
|
137 |
+
$token = OAuthUtil::parse_parameters($request);
|
138 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
139 |
+
return $token;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* GET wrapper for oAuthRequest.
|
144 |
+
*/
|
145 |
+
function get($url, $parameters = array()) {
|
146 |
+
$response = $this->oAuthRequest($url, 'GET', $parameters);
|
147 |
+
if ($this->format === 'json' && $this->decode_json) {
|
148 |
+
return json_decode($response);
|
149 |
+
}
|
150 |
+
return $response;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* POST wrapper for oAuthRequest.
|
155 |
+
*/
|
156 |
+
function post($url, $parameters = array()) {
|
157 |
+
$response = $this->oAuthRequest($url, 'POST', $parameters);
|
158 |
+
if ($this->format === 'json' && $this->decode_json) {
|
159 |
+
return json_decode($response);
|
160 |
+
}
|
161 |
+
return $response;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* DELETE wrapper for oAuthReqeust.
|
166 |
+
*/
|
167 |
+
function delete($url, $parameters = array()) {
|
168 |
+
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
|
169 |
+
if ($this->format === 'json' && $this->decode_json) {
|
170 |
+
return json_decode($response);
|
171 |
+
}
|
172 |
+
return $response;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Format and sign an OAuth / API request
|
177 |
+
*/
|
178 |
+
function oAuthRequest($url, $method, $parameters) {
|
179 |
+
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
|
180 |
+
$url = "{$this->host}{$url}";
|
181 |
+
}
|
182 |
+
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
|
183 |
+
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
|
184 |
+
switch ($method) {
|
185 |
+
case 'GET':
|
186 |
+
return $this->http($request->to_url(), 'GET');
|
187 |
+
default:
|
188 |
+
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Make an HTTP request
|
194 |
+
*
|
195 |
+
* @return API results
|
196 |
+
*/
|
197 |
+
function http($url, $method, $postfields = NULL) {
|
198 |
+
$this->http_info = array();
|
199 |
+
$ci = curl_init();
|
200 |
+
/* Curl settings */
|
201 |
+
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
|
202 |
+
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
|
203 |
+
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
|
204 |
+
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
|
205 |
+
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
|
206 |
+
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
|
207 |
+
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
|
208 |
+
curl_setopt($ci, CURLOPT_HEADER, FALSE);
|
209 |
+
|
210 |
+
switch ($method) {
|
211 |
+
case 'POST':
|
212 |
+
curl_setopt($ci, CURLOPT_POST, TRUE);
|
213 |
+
if (!empty($postfields)) {
|
214 |
+
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
|
215 |
+
}
|
216 |
+
break;
|
217 |
+
case 'DELETE':
|
218 |
+
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
219 |
+
if (!empty($postfields)) {
|
220 |
+
$url = "{$url}?{$postfields}";
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
curl_setopt($ci, CURLOPT_URL, $url);
|
225 |
+
$response = curl_exec($ci);
|
226 |
+
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
|
227 |
+
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
|
228 |
+
$this->url = $url;
|
229 |
+
curl_close ($ci);
|
230 |
+
return $response;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Get the header info to store.
|
235 |
+
*/
|
236 |
+
function getHeader($ch, $header) {
|
237 |
+
$i = strpos($header, ':');
|
238 |
+
if (!empty($i)) {
|
239 |
+
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
|
240 |
+
$value = trim(substr($header, $i + 2));
|
241 |
+
$this->http_header[$key] = $value;
|
242 |
+
}
|
243 |
+
return strlen($header);
|
244 |
+
}
|
245 |
+
}
|
lib/GoMage/Twitter/OAuth.php
ADDED
@@ -0,0 +1,870 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// vim: foldmethod=marker
|
3 |
+
|
4 |
+
/* Generic exception class
|
5 |
+
*/
|
6 |
+
|
7 |
+
|
8 |
+
class OAuthConsumer {
|
9 |
+
public $key;
|
10 |
+
public $secret;
|
11 |
+
|
12 |
+
function __construct($key, $secret, $callback_url=NULL) {
|
13 |
+
$this->key = $key;
|
14 |
+
$this->secret = $secret;
|
15 |
+
$this->callback_url = $callback_url;
|
16 |
+
}
|
17 |
+
|
18 |
+
function __toString() {
|
19 |
+
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
class OAuthToken {
|
24 |
+
// access tokens and request tokens
|
25 |
+
public $key;
|
26 |
+
public $secret;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* key = the token
|
30 |
+
* secret = the token secret
|
31 |
+
*/
|
32 |
+
function __construct($key, $secret) {
|
33 |
+
$this->key = $key;
|
34 |
+
$this->secret = $secret;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* generates the basic string serialization of a token that a server
|
39 |
+
* would respond to request_token and access_token calls with
|
40 |
+
*/
|
41 |
+
function to_string() {
|
42 |
+
return "oauth_token=" .
|
43 |
+
OAuthUtil::urlencode_rfc3986($this->key) .
|
44 |
+
"&oauth_token_secret=" .
|
45 |
+
OAuthUtil::urlencode_rfc3986($this->secret);
|
46 |
+
}
|
47 |
+
|
48 |
+
function __toString() {
|
49 |
+
return $this->to_string();
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* A class for implementing a Signature Method
|
55 |
+
* See section 9 ("Signing Requests") in the spec
|
56 |
+
*/
|
57 |
+
abstract class OAuthSignatureMethod {
|
58 |
+
/**
|
59 |
+
* Needs to return the name of the Signature Method (ie HMAC-SHA1)
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
abstract public function get_name();
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Build up the signature
|
66 |
+
* NOTE: The output of this function MUST NOT be urlencoded.
|
67 |
+
* the encoding is handled in OAuthRequest when the final
|
68 |
+
* request is serialized
|
69 |
+
* @param OAuthRequest $request
|
70 |
+
* @param OAuthConsumer $consumer
|
71 |
+
* @param OAuthToken $token
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
abstract public function build_signature($request, $consumer, $token);
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Verifies that a given signature is correct
|
78 |
+
* @param OAuthRequest $request
|
79 |
+
* @param OAuthConsumer $consumer
|
80 |
+
* @param OAuthToken $token
|
81 |
+
* @param string $signature
|
82 |
+
* @return bool
|
83 |
+
*/
|
84 |
+
public function check_signature($request, $consumer, $token, $signature) {
|
85 |
+
$built = $this->build_signature($request, $consumer, $token);
|
86 |
+
return $built == $signature;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
|
92 |
+
* where the Signature Base String is the text and the key is the concatenated values (each first
|
93 |
+
* encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
|
94 |
+
* character (ASCII code 38) even if empty.
|
95 |
+
* - Chapter 9.2 ("HMAC-SHA1")
|
96 |
+
*/
|
97 |
+
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
|
98 |
+
function get_name() {
|
99 |
+
return "HMAC-SHA1";
|
100 |
+
}
|
101 |
+
|
102 |
+
public function build_signature($request, $consumer, $token) {
|
103 |
+
$base_string = $request->get_signature_base_string();
|
104 |
+
$request->base_string = $base_string;
|
105 |
+
|
106 |
+
$key_parts = array(
|
107 |
+
$consumer->secret,
|
108 |
+
($token) ? $token->secret : ""
|
109 |
+
);
|
110 |
+
|
111 |
+
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
112 |
+
$key = implode('&', $key_parts);
|
113 |
+
|
114 |
+
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* The PLAINTEXT method does not provide any security protection and SHOULD only be used
|
120 |
+
* over a secure channel such as HTTPS. It does not use the Signature Base String.
|
121 |
+
* - Chapter 9.4 ("PLAINTEXT")
|
122 |
+
*/
|
123 |
+
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
|
124 |
+
public function get_name() {
|
125 |
+
return "PLAINTEXT";
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* oauth_signature is set to the concatenated encoded values of the Consumer Secret and
|
130 |
+
* Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
|
131 |
+
* empty. The result MUST be encoded again.
|
132 |
+
* - Chapter 9.4.1 ("Generating Signatures")
|
133 |
+
*
|
134 |
+
* Please note that the second encoding MUST NOT happen in the SignatureMethod, as
|
135 |
+
* OAuthRequest handles this!
|
136 |
+
*/
|
137 |
+
public function build_signature($request, $consumer, $token) {
|
138 |
+
$key_parts = array(
|
139 |
+
$consumer->secret,
|
140 |
+
($token) ? $token->secret : ""
|
141 |
+
);
|
142 |
+
|
143 |
+
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
144 |
+
$key = implode('&', $key_parts);
|
145 |
+
$request->base_string = $key;
|
146 |
+
|
147 |
+
return $key;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
|
153 |
+
* [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
|
154 |
+
* EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
|
155 |
+
* verified way to the Service Provider, in a manner which is beyond the scope of this
|
156 |
+
* specification.
|
157 |
+
* - Chapter 9.3 ("RSA-SHA1")
|
158 |
+
*/
|
159 |
+
abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
|
160 |
+
public function get_name() {
|
161 |
+
return "RSA-SHA1";
|
162 |
+
}
|
163 |
+
|
164 |
+
// Up to the SP to implement this lookup of keys. Possible ideas are:
|
165 |
+
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
166 |
+
// (2) fetch via http using a url provided by the requester
|
167 |
+
// (3) some sort of specific discovery code based on request
|
168 |
+
//
|
169 |
+
// Either way should return a string representation of the certificate
|
170 |
+
protected abstract function fetch_public_cert(&$request);
|
171 |
+
|
172 |
+
// Up to the SP to implement this lookup of keys. Possible ideas are:
|
173 |
+
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
174 |
+
//
|
175 |
+
// Either way should return a string representation of the certificate
|
176 |
+
protected abstract function fetch_private_cert(&$request);
|
177 |
+
|
178 |
+
public function build_signature($request, $consumer, $token) {
|
179 |
+
$base_string = $request->get_signature_base_string();
|
180 |
+
$request->base_string = $base_string;
|
181 |
+
|
182 |
+
// Fetch the private key cert based on the request
|
183 |
+
$cert = $this->fetch_private_cert($request);
|
184 |
+
|
185 |
+
// Pull the private key ID from the certificate
|
186 |
+
$privatekeyid = openssl_get_privatekey($cert);
|
187 |
+
|
188 |
+
// Sign using the key
|
189 |
+
$ok = openssl_sign($base_string, $signature, $privatekeyid);
|
190 |
+
|
191 |
+
// Release the key resource
|
192 |
+
openssl_free_key($privatekeyid);
|
193 |
+
|
194 |
+
return base64_encode($signature);
|
195 |
+
}
|
196 |
+
|
197 |
+
public function check_signature($request, $consumer, $token, $signature) {
|
198 |
+
$decoded_sig = base64_decode($signature);
|
199 |
+
|
200 |
+
$base_string = $request->get_signature_base_string();
|
201 |
+
|
202 |
+
// Fetch the public key cert based on the request
|
203 |
+
$cert = $this->fetch_public_cert($request);
|
204 |
+
|
205 |
+
// Pull the public key ID from the certificate
|
206 |
+
$publickeyid = openssl_get_publickey($cert);
|
207 |
+
|
208 |
+
// Check the computed signature against the one passed in the query
|
209 |
+
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
|
210 |
+
|
211 |
+
// Release the key resource
|
212 |
+
openssl_free_key($publickeyid);
|
213 |
+
|
214 |
+
return $ok == 1;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
class OAuthRequest {
|
219 |
+
private $parameters;
|
220 |
+
private $http_method;
|
221 |
+
private $http_url;
|
222 |
+
// for debug purposes
|
223 |
+
public $base_string;
|
224 |
+
public static $version = '1.0';
|
225 |
+
public static $POST_INPUT = 'php://input';
|
226 |
+
|
227 |
+
function __construct($http_method, $http_url, $parameters=NULL) {
|
228 |
+
@$parameters or $parameters = array();
|
229 |
+
$parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
230 |
+
$this->parameters = $parameters;
|
231 |
+
$this->http_method = $http_method;
|
232 |
+
$this->http_url = $http_url;
|
233 |
+
}
|
234 |
+
|
235 |
+
|
236 |
+
/**
|
237 |
+
* attempt to build up a request from what was passed to the server
|
238 |
+
*/
|
239 |
+
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
|
240 |
+
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
|
241 |
+
? 'http'
|
242 |
+
: 'https';
|
243 |
+
@$http_url or $http_url = $scheme .
|
244 |
+
'://' . $_SERVER['HTTP_HOST'] .
|
245 |
+
':' .
|
246 |
+
$_SERVER['SERVER_PORT'] .
|
247 |
+
$_SERVER['REQUEST_URI'];
|
248 |
+
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
|
249 |
+
|
250 |
+
// We weren't handed any parameters, so let's find the ones relevant to
|
251 |
+
// this request.
|
252 |
+
// If you run XML-RPC or similar you should use this to provide your own
|
253 |
+
// parsed parameter-list
|
254 |
+
if (!$parameters) {
|
255 |
+
// Find request headers
|
256 |
+
$request_headers = OAuthUtil::get_headers();
|
257 |
+
|
258 |
+
// Parse the query-string to find GET parameters
|
259 |
+
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
|
260 |
+
|
261 |
+
// It's a POST request of the proper content-type, so parse POST
|
262 |
+
// parameters and add those overriding any duplicates from GET
|
263 |
+
if ($http_method == "POST"
|
264 |
+
&& @strstr($request_headers["Content-Type"],
|
265 |
+
"application/x-www-form-urlencoded")
|
266 |
+
) {
|
267 |
+
$post_data = OAuthUtil::parse_parameters(
|
268 |
+
file_get_contents(self::$POST_INPUT)
|
269 |
+
);
|
270 |
+
$parameters = array_merge($parameters, $post_data);
|
271 |
+
}
|
272 |
+
|
273 |
+
// We have a Authorization-header with OAuth data. Parse the header
|
274 |
+
// and add those overriding any duplicates from GET or POST
|
275 |
+
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
|
276 |
+
$header_parameters = OAuthUtil::split_header(
|
277 |
+
$request_headers['Authorization']
|
278 |
+
);
|
279 |
+
$parameters = array_merge($parameters, $header_parameters);
|
280 |
+
}
|
281 |
+
|
282 |
+
}
|
283 |
+
|
284 |
+
return new OAuthRequest($http_method, $http_url, $parameters);
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* pretty much a helper function to set up the request
|
289 |
+
*/
|
290 |
+
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
|
291 |
+
@$parameters or $parameters = array();
|
292 |
+
$defaults = array("oauth_version" => OAuthRequest::$version,
|
293 |
+
"oauth_nonce" => OAuthRequest::generate_nonce(),
|
294 |
+
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
|
295 |
+
"oauth_consumer_key" => $consumer->key);
|
296 |
+
if ($token)
|
297 |
+
$defaults['oauth_token'] = $token->key;
|
298 |
+
|
299 |
+
$parameters = array_merge($defaults, $parameters);
|
300 |
+
|
301 |
+
return new OAuthRequest($http_method, $http_url, $parameters);
|
302 |
+
}
|
303 |
+
|
304 |
+
public function set_parameter($name, $value, $allow_duplicates = true) {
|
305 |
+
if ($allow_duplicates && isset($this->parameters[$name])) {
|
306 |
+
// We have already added parameter(s) with this name, so add to the list
|
307 |
+
if (is_scalar($this->parameters[$name])) {
|
308 |
+
// This is the first duplicate, so transform scalar (string)
|
309 |
+
// into an array so we can add the duplicates
|
310 |
+
$this->parameters[$name] = array($this->parameters[$name]);
|
311 |
+
}
|
312 |
+
|
313 |
+
$this->parameters[$name][] = $value;
|
314 |
+
} else {
|
315 |
+
$this->parameters[$name] = $value;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
public function get_parameter($name) {
|
320 |
+
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
|
321 |
+
}
|
322 |
+
|
323 |
+
public function get_parameters() {
|
324 |
+
return $this->parameters;
|
325 |
+
}
|
326 |
+
|
327 |
+
public function unset_parameter($name) {
|
328 |
+
unset($this->parameters[$name]);
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* The request parameters, sorted and concatenated into a normalized string.
|
333 |
+
* @return string
|
334 |
+
*/
|
335 |
+
public function get_signable_parameters() {
|
336 |
+
// Grab all parameters
|
337 |
+
$params = $this->parameters;
|
338 |
+
|
339 |
+
// Remove oauth_signature if present
|
340 |
+
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
|
341 |
+
if (isset($params['oauth_signature'])) {
|
342 |
+
unset($params['oauth_signature']);
|
343 |
+
}
|
344 |
+
|
345 |
+
return OAuthUtil::build_http_query($params);
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Returns the base string of this request
|
350 |
+
*
|
351 |
+
* The base string defined as the method, the url
|
352 |
+
* and the parameters (normalized), each urlencoded
|
353 |
+
* and the concated with &.
|
354 |
+
*/
|
355 |
+
public function get_signature_base_string() {
|
356 |
+
$parts = array(
|
357 |
+
$this->get_normalized_http_method(),
|
358 |
+
$this->get_normalized_http_url(),
|
359 |
+
$this->get_signable_parameters()
|
360 |
+
);
|
361 |
+
|
362 |
+
$parts = OAuthUtil::urlencode_rfc3986($parts);
|
363 |
+
|
364 |
+
return implode('&', $parts);
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* just uppercases the http method
|
369 |
+
*/
|
370 |
+
public function get_normalized_http_method() {
|
371 |
+
return strtoupper($this->http_method);
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* parses the url and rebuilds it to be
|
376 |
+
* scheme://host/path
|
377 |
+
*/
|
378 |
+
public function get_normalized_http_url() {
|
379 |
+
$parts = parse_url($this->http_url);
|
380 |
+
|
381 |
+
$port = @$parts['port'];
|
382 |
+
$scheme = $parts['scheme'];
|
383 |
+
$host = $parts['host'];
|
384 |
+
$path = @$parts['path'];
|
385 |
+
|
386 |
+
$port or $port = ($scheme == 'https') ? '443' : '80';
|
387 |
+
|
388 |
+
if (($scheme == 'https' && $port != '443')
|
389 |
+
|| ($scheme == 'http' && $port != '80')) {
|
390 |
+
$host = "$host:$port";
|
391 |
+
}
|
392 |
+
return "$scheme://$host$path";
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* builds a url usable for a GET request
|
397 |
+
*/
|
398 |
+
public function to_url() {
|
399 |
+
$post_data = $this->to_postdata();
|
400 |
+
$out = $this->get_normalized_http_url();
|
401 |
+
if ($post_data) {
|
402 |
+
$out .= '?'.$post_data;
|
403 |
+
}
|
404 |
+
return $out;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* builds the data one would send in a POST request
|
409 |
+
*/
|
410 |
+
public function to_postdata() {
|
411 |
+
return OAuthUtil::build_http_query($this->parameters);
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* builds the Authorization: header
|
416 |
+
*/
|
417 |
+
public function to_header($realm=null) {
|
418 |
+
$first = true;
|
419 |
+
if($realm) {
|
420 |
+
$out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
|
421 |
+
$first = false;
|
422 |
+
} else
|
423 |
+
$out = 'Authorization: OAuth';
|
424 |
+
|
425 |
+
$total = array();
|
426 |
+
foreach ($this->parameters as $k => $v) {
|
427 |
+
if (substr($k, 0, 5) != "oauth") continue;
|
428 |
+
if (is_array($v)) {
|
429 |
+
throw new OAuthException('Arrays not supported in headers');
|
430 |
+
}
|
431 |
+
$out .= ($first) ? ' ' : ',';
|
432 |
+
$out .= OAuthUtil::urlencode_rfc3986($k) .
|
433 |
+
'="' .
|
434 |
+
OAuthUtil::urlencode_rfc3986($v) .
|
435 |
+
'"';
|
436 |
+
$first = false;
|
437 |
+
}
|
438 |
+
return $out;
|
439 |
+
}
|
440 |
+
|
441 |
+
public function __toString() {
|
442 |
+
return $this->to_url();
|
443 |
+
}
|
444 |
+
|
445 |
+
|
446 |
+
public function sign_request($signature_method, $consumer, $token) {
|
447 |
+
$this->set_parameter(
|
448 |
+
"oauth_signature_method",
|
449 |
+
$signature_method->get_name(),
|
450 |
+
false
|
451 |
+
);
|
452 |
+
$signature = $this->build_signature($signature_method, $consumer, $token);
|
453 |
+
$this->set_parameter("oauth_signature", $signature, false);
|
454 |
+
}
|
455 |
+
|
456 |
+
public function build_signature($signature_method, $consumer, $token) {
|
457 |
+
$signature = $signature_method->build_signature($this, $consumer, $token);
|
458 |
+
return $signature;
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* util function: current timestamp
|
463 |
+
*/
|
464 |
+
private static function generate_timestamp() {
|
465 |
+
return time();
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* util function: current nonce
|
470 |
+
*/
|
471 |
+
private static function generate_nonce() {
|
472 |
+
$mt = microtime();
|
473 |
+
$rand = mt_rand();
|
474 |
+
|
475 |
+
return md5($mt . $rand); // md5s look nicer than numbers
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
class OAuthServer {
|
480 |
+
protected $timestamp_threshold = 300; // in seconds, five minutes
|
481 |
+
protected $version = '1.0'; // hi blaine
|
482 |
+
protected $signature_methods = array();
|
483 |
+
|
484 |
+
protected $data_store;
|
485 |
+
|
486 |
+
function __construct($data_store) {
|
487 |
+
$this->data_store = $data_store;
|
488 |
+
}
|
489 |
+
|
490 |
+
public function add_signature_method($signature_method) {
|
491 |
+
$this->signature_methods[$signature_method->get_name()] =
|
492 |
+
$signature_method;
|
493 |
+
}
|
494 |
+
|
495 |
+
// high level functions
|
496 |
+
|
497 |
+
/**
|
498 |
+
* process a request_token request
|
499 |
+
* returns the request token on success
|
500 |
+
*/
|
501 |
+
public function fetch_request_token(&$request) {
|
502 |
+
$this->get_version($request);
|
503 |
+
|
504 |
+
$consumer = $this->get_consumer($request);
|
505 |
+
|
506 |
+
// no token required for the initial token request
|
507 |
+
$token = NULL;
|
508 |
+
|
509 |
+
$this->check_signature($request, $consumer, $token);
|
510 |
+
|
511 |
+
// Rev A change
|
512 |
+
$callback = $request->get_parameter('oauth_callback');
|
513 |
+
$new_token = $this->data_store->new_request_token($consumer, $callback);
|
514 |
+
|
515 |
+
return $new_token;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* process an access_token request
|
520 |
+
* returns the access token on success
|
521 |
+
*/
|
522 |
+
public function fetch_access_token(&$request) {
|
523 |
+
$this->get_version($request);
|
524 |
+
|
525 |
+
$consumer = $this->get_consumer($request);
|
526 |
+
|
527 |
+
// requires authorized request token
|
528 |
+
$token = $this->get_token($request, $consumer, "request");
|
529 |
+
|
530 |
+
$this->check_signature($request, $consumer, $token);
|
531 |
+
|
532 |
+
// Rev A change
|
533 |
+
$verifier = $request->get_parameter('oauth_verifier');
|
534 |
+
$new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
|
535 |
+
|
536 |
+
return $new_token;
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* verify an api call, checks all the parameters
|
541 |
+
*/
|
542 |
+
public function verify_request(&$request) {
|
543 |
+
$this->get_version($request);
|
544 |
+
$consumer = $this->get_consumer($request);
|
545 |
+
$token = $this->get_token($request, $consumer, "access");
|
546 |
+
$this->check_signature($request, $consumer, $token);
|
547 |
+
return array($consumer, $token);
|
548 |
+
}
|
549 |
+
|
550 |
+
// Internals from here
|
551 |
+
/**
|
552 |
+
* version 1
|
553 |
+
*/
|
554 |
+
private function get_version(&$request) {
|
555 |
+
$version = $request->get_parameter("oauth_version");
|
556 |
+
if (!$version) {
|
557 |
+
// Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
|
558 |
+
// Chapter 7.0 ("Accessing Protected Ressources")
|
559 |
+
$version = '1.0';
|
560 |
+
}
|
561 |
+
if ($version !== $this->version) {
|
562 |
+
throw new OAuthException("OAuth version '$version' not supported");
|
563 |
+
}
|
564 |
+
return $version;
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* figure out the signature with some defaults
|
569 |
+
*/
|
570 |
+
private function get_signature_method(&$request) {
|
571 |
+
$signature_method =
|
572 |
+
@$request->get_parameter("oauth_signature_method");
|
573 |
+
|
574 |
+
if (!$signature_method) {
|
575 |
+
// According to chapter 7 ("Accessing Protected Ressources") the signature-method
|
576 |
+
// parameter is required, and we can't just fallback to PLAINTEXT
|
577 |
+
throw new OAuthException('No signature method parameter. This parameter is required');
|
578 |
+
}
|
579 |
+
|
580 |
+
if (!in_array($signature_method,
|
581 |
+
array_keys($this->signature_methods))) {
|
582 |
+
throw new OAuthException(
|
583 |
+
"Signature method '$signature_method' not supported " .
|
584 |
+
"try one of the following: " .
|
585 |
+
implode(", ", array_keys($this->signature_methods))
|
586 |
+
);
|
587 |
+
}
|
588 |
+
return $this->signature_methods[$signature_method];
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* try to find the consumer for the provided request's consumer key
|
593 |
+
*/
|
594 |
+
private function get_consumer(&$request) {
|
595 |
+
$consumer_key = @$request->get_parameter("oauth_consumer_key");
|
596 |
+
if (!$consumer_key) {
|
597 |
+
throw new OAuthException("Invalid consumer key");
|
598 |
+
}
|
599 |
+
|
600 |
+
$consumer = $this->data_store->lookup_consumer($consumer_key);
|
601 |
+
if (!$consumer) {
|
602 |
+
throw new OAuthException("Invalid consumer");
|
603 |
+
}
|
604 |
+
|
605 |
+
return $consumer;
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* try to find the token for the provided request's token key
|
610 |
+
*/
|
611 |
+
private function get_token(&$request, $consumer, $token_type="access") {
|
612 |
+
$token_field = @$request->get_parameter('oauth_token');
|
613 |
+
$token = $this->data_store->lookup_token(
|
614 |
+
$consumer, $token_type, $token_field
|
615 |
+
);
|
616 |
+
if (!$token) {
|
617 |
+
throw new OAuthException("Invalid $token_type token: $token_field");
|
618 |
+
}
|
619 |
+
return $token;
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* all-in-one function to check the signature on a request
|
624 |
+
* should guess the signature method appropriately
|
625 |
+
*/
|
626 |
+
private function check_signature(&$request, $consumer, $token) {
|
627 |
+
// this should probably be in a different method
|
628 |
+
$timestamp = @$request->get_parameter('oauth_timestamp');
|
629 |
+
$nonce = @$request->get_parameter('oauth_nonce');
|
630 |
+
|
631 |
+
$this->check_timestamp($timestamp);
|
632 |
+
$this->check_nonce($consumer, $token, $nonce, $timestamp);
|
633 |
+
|
634 |
+
$signature_method = $this->get_signature_method($request);
|
635 |
+
|
636 |
+
$signature = $request->get_parameter('oauth_signature');
|
637 |
+
$valid_sig = $signature_method->check_signature(
|
638 |
+
$request,
|
639 |
+
$consumer,
|
640 |
+
$token,
|
641 |
+
$signature
|
642 |
+
);
|
643 |
+
|
644 |
+
if (!$valid_sig) {
|
645 |
+
throw new OAuthException("Invalid signature");
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* check that the timestamp is new enough
|
651 |
+
*/
|
652 |
+
private function check_timestamp($timestamp) {
|
653 |
+
if( ! $timestamp )
|
654 |
+
throw new OAuthException(
|
655 |
+
'Missing timestamp parameter. The parameter is required'
|
656 |
+
);
|
657 |
+
|
658 |
+
// verify that timestamp is recentish
|
659 |
+
$now = time();
|
660 |
+
if (abs($now - $timestamp) > $this->timestamp_threshold) {
|
661 |
+
throw new OAuthException(
|
662 |
+
"Expired timestamp, yours $timestamp, ours $now"
|
663 |
+
);
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
/**
|
668 |
+
* check that the nonce is not repeated
|
669 |
+
*/
|
670 |
+
private function check_nonce($consumer, $token, $nonce, $timestamp) {
|
671 |
+
if( ! $nonce )
|
672 |
+
throw new OAuthException(
|
673 |
+
'Missing nonce parameter. The parameter is required'
|
674 |
+
);
|
675 |
+
|
676 |
+
// verify that the nonce is uniqueish
|
677 |
+
$found = $this->data_store->lookup_nonce(
|
678 |
+
$consumer,
|
679 |
+
$token,
|
680 |
+
$nonce,
|
681 |
+
$timestamp
|
682 |
+
);
|
683 |
+
if ($found) {
|
684 |
+
throw new OAuthException("Nonce already used: $nonce");
|
685 |
+
}
|
686 |
+
}
|
687 |
+
|
688 |
+
}
|
689 |
+
|
690 |
+
class OAuthDataStore {
|
691 |
+
function lookup_consumer($consumer_key) {
|
692 |
+
// implement me
|
693 |
+
}
|
694 |
+
|
695 |
+
function lookup_token($consumer, $token_type, $token) {
|
696 |
+
// implement me
|
697 |
+
}
|
698 |
+
|
699 |
+
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
|
700 |
+
// implement me
|
701 |
+
}
|
702 |
+
|
703 |
+
function new_request_token($consumer, $callback = null) {
|
704 |
+
// return a new token attached to this consumer
|
705 |
+
}
|
706 |
+
|
707 |
+
function new_access_token($token, $consumer, $verifier = null) {
|
708 |
+
// return a new access token attached to this consumer
|
709 |
+
// for the user associated with this token if the request token
|
710 |
+
// is authorized
|
711 |
+
// should also invalidate the request token
|
712 |
+
}
|
713 |
+
|
714 |
+
}
|
715 |
+
|
716 |
+
class OAuthUtil {
|
717 |
+
public static function urlencode_rfc3986($input) {
|
718 |
+
if (is_array($input)) {
|
719 |
+
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
|
720 |
+
} else if (is_scalar($input)) {
|
721 |
+
return str_replace(
|
722 |
+
'+',
|
723 |
+
' ',
|
724 |
+
str_replace('%7E', '~', rawurlencode($input))
|
725 |
+
);
|
726 |
+
} else {
|
727 |
+
return '';
|
728 |
+
}
|
729 |
+
}
|
730 |
+
|
731 |
+
|
732 |
+
// This decode function isn't taking into consideration the above
|
733 |
+
// modifications to the encoding process. However, this method doesn't
|
734 |
+
// seem to be used anywhere so leaving it as is.
|
735 |
+
public static function urldecode_rfc3986($string) {
|
736 |
+
return urldecode($string);
|
737 |
+
}
|
738 |
+
|
739 |
+
// Utility function for turning the Authorization: header into
|
740 |
+
// parameters, has to do some unescaping
|
741 |
+
// Can filter out any non-oauth parameters if needed (default behaviour)
|
742 |
+
public static function split_header($header, $only_allow_oauth_parameters = true) {
|
743 |
+
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
|
744 |
+
$offset = 0;
|
745 |
+
$params = array();
|
746 |
+
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
|
747 |
+
$match = $matches[0];
|
748 |
+
$header_name = $matches[2][0];
|
749 |
+
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
|
750 |
+
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
|
751 |
+
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
|
752 |
+
}
|
753 |
+
$offset = $match[1] + strlen($match[0]);
|
754 |
+
}
|
755 |
+
|
756 |
+
if (isset($params['realm'])) {
|
757 |
+
unset($params['realm']);
|
758 |
+
}
|
759 |
+
|
760 |
+
return $params;
|
761 |
+
}
|
762 |
+
|
763 |
+
// helper to try to sort out headers for people who aren't running apache
|
764 |
+
public static function get_headers() {
|
765 |
+
if (function_exists('apache_request_headers')) {
|
766 |
+
// we need this to get the actual Authorization: header
|
767 |
+
// because apache tends to tell us it doesn't exist
|
768 |
+
$headers = apache_request_headers();
|
769 |
+
|
770 |
+
// sanitize the output of apache_request_headers because
|
771 |
+
// we always want the keys to be Cased-Like-This and arh()
|
772 |
+
// returns the headers in the same case as they are in the
|
773 |
+
// request
|
774 |
+
$out = array();
|
775 |
+
foreach( $headers AS $key => $value ) {
|
776 |
+
$key = str_replace(
|
777 |
+
" ",
|
778 |
+
"-",
|
779 |
+
ucwords(strtolower(str_replace("-", " ", $key)))
|
780 |
+
);
|
781 |
+
$out[$key] = $value;
|
782 |
+
}
|
783 |
+
} else {
|
784 |
+
// otherwise we don't have apache and are just going to have to hope
|
785 |
+
// that $_SERVER actually contains what we need
|
786 |
+
$out = array();
|
787 |
+
if( isset($_SERVER['CONTENT_TYPE']) )
|
788 |
+
$out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
|
789 |
+
if( isset($_ENV['CONTENT_TYPE']) )
|
790 |
+
$out['Content-Type'] = $_ENV['CONTENT_TYPE'];
|
791 |
+
|
792 |
+
foreach ($_SERVER as $key => $value) {
|
793 |
+
if (substr($key, 0, 5) == "HTTP_") {
|
794 |
+
// this is chaos, basically it is just there to capitalize the first
|
795 |
+
// letter of every word that is not an initial HTTP and strip HTTP
|
796 |
+
// code from przemek
|
797 |
+
$key = str_replace(
|
798 |
+
" ",
|
799 |
+
"-",
|
800 |
+
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
|
801 |
+
);
|
802 |
+
$out[$key] = $value;
|
803 |
+
}
|
804 |
+
}
|
805 |
+
}
|
806 |
+
return $out;
|
807 |
+
}
|
808 |
+
|
809 |
+
// This function takes a input like a=b&a=c&d=e and returns the parsed
|
810 |
+
// parameters like this
|
811 |
+
// array('a' => array('b','c'), 'd' => 'e')
|
812 |
+
public static function parse_parameters( $input ) {
|
813 |
+
if (!isset($input) || !$input) return array();
|
814 |
+
|
815 |
+
$pairs = explode('&', $input);
|
816 |
+
|
817 |
+
$parsed_parameters = array();
|
818 |
+
foreach ($pairs as $pair) {
|
819 |
+
$split = explode('=', $pair, 2);
|
820 |
+
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
|
821 |
+
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
|
822 |
+
|
823 |
+
if (isset($parsed_parameters[$parameter])) {
|
824 |
+
// We have already recieved parameter(s) with this name, so add to the list
|
825 |
+
// of parameters with this name
|
826 |
+
|
827 |
+
if (is_scalar($parsed_parameters[$parameter])) {
|
828 |
+
// This is the first duplicate, so transform scalar (string) into an array
|
829 |
+
// so we can add the duplicates
|
830 |
+
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
|
831 |
+
}
|
832 |
+
|
833 |
+
$parsed_parameters[$parameter][] = $value;
|
834 |
+
} else {
|
835 |
+
$parsed_parameters[$parameter] = $value;
|
836 |
+
}
|
837 |
+
}
|
838 |
+
return $parsed_parameters;
|
839 |
+
}
|
840 |
+
|
841 |
+
public static function build_http_query($params) {
|
842 |
+
if (!$params) return '';
|
843 |
+
|
844 |
+
// Urlencode both keys and values
|
845 |
+
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
|
846 |
+
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
|
847 |
+
$params = array_combine($keys, $values);
|
848 |
+
|
849 |
+
// Parameters are sorted by name, using lexicographical byte value ordering.
|
850 |
+
// Ref: Spec: 9.1.1 (1)
|
851 |
+
uksort($params, 'strcmp');
|
852 |
+
|
853 |
+
$pairs = array();
|
854 |
+
foreach ($params as $parameter => $value) {
|
855 |
+
if (is_array($value)) {
|
856 |
+
// If two or more parameters share the same name, they are sorted by their value
|
857 |
+
// Ref: Spec: 9.1.1 (1)
|
858 |
+
natsort($value);
|
859 |
+
foreach ($value as $duplicate_value) {
|
860 |
+
$pairs[] = $parameter . '=' . $duplicate_value;
|
861 |
+
}
|
862 |
+
} else {
|
863 |
+
$pairs[] = $parameter . '=' . $value;
|
864 |
+
}
|
865 |
+
}
|
866 |
+
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
|
867 |
+
// Each name-value pair is separated by an '&' character (ASCII code 38)
|
868 |
+
return implode('&', $pairs);
|
869 |
+
}
|
870 |
+
}
|
lib/GoMage/Twitter/twitteroauth.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Abraham Williams (abraham@abrah.am) http://abrah.am
|
5 |
+
*
|
6 |
+
* The first PHP Library to support OAuth for Twitter's REST API.
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* Load OAuth lib. You can find it at http://oauth.net */
|
10 |
+
require_once('OAuth.php');
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Twitter OAuth class
|
14 |
+
*/
|
15 |
+
class TwitterOAuth {
|
16 |
+
/* Contains the last HTTP status code returned. */
|
17 |
+
public $http_code;
|
18 |
+
/* Contains the last API call. */
|
19 |
+
public $url;
|
20 |
+
/* Set up the API root URL. */
|
21 |
+
public $host = "https://api.twitter.com/1.1/";
|
22 |
+
/* Set timeout default. */
|
23 |
+
public $timeout = 30;
|
24 |
+
/* Set connect timeout. */
|
25 |
+
public $connecttimeout = 30;
|
26 |
+
/* Verify SSL Cert. */
|
27 |
+
public $ssl_verifypeer = FALSE;
|
28 |
+
/* Respons format. */
|
29 |
+
public $format = 'json';
|
30 |
+
/* Decode returned json data. */
|
31 |
+
public $decode_json = TRUE;
|
32 |
+
/* Contains the last HTTP headers returned. */
|
33 |
+
public $http_info;
|
34 |
+
/* Set the useragnet. */
|
35 |
+
public $useragent = 'TwitterOAuth v0.2.0-beta2';
|
36 |
+
/* Immediately retry the API call if the response was not successful. */
|
37 |
+
//public $retry = TRUE;
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Set API URLS
|
44 |
+
*/
|
45 |
+
function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
|
46 |
+
function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
|
47 |
+
function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
|
48 |
+
function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Debug helpers
|
52 |
+
*/
|
53 |
+
function lastStatusCode() { return $this->http_status; }
|
54 |
+
function lastAPICall() { return $this->last_api_call; }
|
55 |
+
|
56 |
+
/**
|
57 |
+
* construct TwitterOAuth object
|
58 |
+
*/
|
59 |
+
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
|
60 |
+
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
|
61 |
+
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
|
62 |
+
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
|
63 |
+
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
|
64 |
+
} else {
|
65 |
+
$this->token = NULL;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get a request_token from Twitter
|
72 |
+
*
|
73 |
+
* @returns a key/value array containing oauth_token and oauth_token_secret
|
74 |
+
*/
|
75 |
+
function getRequestToken($oauth_callback) {
|
76 |
+
$parameters = array();
|
77 |
+
$parameters['oauth_callback'] = $oauth_callback;
|
78 |
+
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
|
79 |
+
$token = OAuthUtil::parse_parameters($request);
|
80 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
81 |
+
return $token;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get the authorize URL
|
86 |
+
*
|
87 |
+
* @returns a string
|
88 |
+
*/
|
89 |
+
function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
|
90 |
+
if (is_array($token)) {
|
91 |
+
$token = $token['oauth_token'];
|
92 |
+
}
|
93 |
+
if (empty($sign_in_with_twitter)) {
|
94 |
+
return $this->authorizeURL() . "?oauth_token={$token}";
|
95 |
+
} else {
|
96 |
+
return $this->authenticateURL() . "?oauth_token={$token}";
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Exchange request token and secret for an access token and
|
102 |
+
* secret, to sign API calls.
|
103 |
+
*
|
104 |
+
* @returns array("oauth_token" => "the-access-token",
|
105 |
+
* "oauth_token_secret" => "the-access-secret",
|
106 |
+
* "user_id" => "9436992",
|
107 |
+
* "screen_name" => "abraham")
|
108 |
+
*/
|
109 |
+
function getAccessToken($oauth_verifier) {
|
110 |
+
$parameters = array();
|
111 |
+
$parameters['oauth_verifier'] = $oauth_verifier;
|
112 |
+
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
|
113 |
+
$token = OAuthUtil::parse_parameters($request);
|
114 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
115 |
+
return $token;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* One time exchange of username and password for access token and secret.
|
120 |
+
*
|
121 |
+
* @returns array("oauth_token" => "the-access-token",
|
122 |
+
* "oauth_token_secret" => "the-access-secret",
|
123 |
+
* "user_id" => "9436992",
|
124 |
+
* "screen_name" => "abraham",
|
125 |
+
* "x_auth_expires" => "0")
|
126 |
+
*/
|
127 |
+
function getXAuthToken($username, $password) {
|
128 |
+
$parameters = array();
|
129 |
+
$parameters['x_auth_username'] = $username;
|
130 |
+
$parameters['x_auth_password'] = $password;
|
131 |
+
$parameters['x_auth_mode'] = 'client_auth';
|
132 |
+
$request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
|
133 |
+
$token = OAuthUtil::parse_parameters($request);
|
134 |
+
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
|
135 |
+
return $token;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* GET wrapper for oAuthRequest.
|
140 |
+
*/
|
141 |
+
function get($url, $parameters = array()) {
|
142 |
+
$response = $this->oAuthRequest($url, 'GET', $parameters);
|
143 |
+
if ($this->format === 'json' && $this->decode_json) {
|
144 |
+
return json_decode($response);
|
145 |
+
}
|
146 |
+
return $response;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* POST wrapper for oAuthRequest.
|
151 |
+
*/
|
152 |
+
function post($url, $parameters = array()) {
|
153 |
+
$response = $this->oAuthRequest($url, 'POST', $parameters);
|
154 |
+
if ($this->format === 'json' && $this->decode_json) {
|
155 |
+
return json_decode($response);
|
156 |
+
}
|
157 |
+
return $response;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* DELETE wrapper for oAuthReqeust.
|
162 |
+
*/
|
163 |
+
function delete($url, $parameters = array()) {
|
164 |
+
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
|
165 |
+
if ($this->format === 'json' && $this->decode_json) {
|
166 |
+
return json_decode($response);
|
167 |
+
}
|
168 |
+
return $response;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Format and sign an OAuth / API request
|
173 |
+
*/
|
174 |
+
function oAuthRequest($url, $method, $parameters) {
|
175 |
+
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
|
176 |
+
$url = "{$this->host}{$url}.{$this->format}";
|
177 |
+
}
|
178 |
+
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
|
179 |
+
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
|
180 |
+
switch ($method) {
|
181 |
+
case 'GET':
|
182 |
+
return $this->http($request->to_url(), 'GET');
|
183 |
+
default:
|
184 |
+
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Make an HTTP request
|
190 |
+
*
|
191 |
+
* @return API results
|
192 |
+
*/
|
193 |
+
function http($url, $method, $postfields = NULL) {
|
194 |
+
$this->http_info = array();
|
195 |
+
$ci = curl_init();
|
196 |
+
/* Curl settings */
|
197 |
+
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
|
198 |
+
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
|
199 |
+
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
|
200 |
+
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
|
201 |
+
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
|
202 |
+
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
|
203 |
+
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
|
204 |
+
curl_setopt($ci, CURLOPT_HEADER, FALSE);
|
205 |
+
|
206 |
+
switch ($method) {
|
207 |
+
case 'POST':
|
208 |
+
curl_setopt($ci, CURLOPT_POST, TRUE);
|
209 |
+
if (!empty($postfields)) {
|
210 |
+
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
|
211 |
+
}
|
212 |
+
break;
|
213 |
+
case 'DELETE':
|
214 |
+
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
215 |
+
if (!empty($postfields)) {
|
216 |
+
$url = "{$url}?{$postfields}";
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
curl_setopt($ci, CURLOPT_URL, $url);
|
221 |
+
$response = curl_exec($ci);
|
222 |
+
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
|
223 |
+
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
|
224 |
+
$this->url = $url;
|
225 |
+
curl_close ($ci);
|
226 |
+
return $response;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Get the header info to store.
|
231 |
+
*/
|
232 |
+
function getHeader($ch, $header) {
|
233 |
+
$i = strpos($header, ':');
|
234 |
+
if (!empty($i)) {
|
235 |
+
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
|
236 |
+
$value = trim(substr($header, $i + 2));
|
237 |
+
$this->http_header[$key] = $value;
|
238 |
+
}
|
239 |
+
return strlen($header);
|
240 |
+
}
|
241 |
+
}
|
media/gomage/social/facebook_button.png
DELETED
Binary file
|
package.xml
CHANGED
@@ -1,24 +1,28 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>gomage_social_connector</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gomage.com/license-agreement/">Single domain license</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>GoMage Social Connector allows your customers to login with the most popular social connectors: Facebook, LinkedIn, Google and Google
|
10 |
<description>Features of GoMage Social Connector:
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
<
|
|
|
|
|
|
|
|
|
22 |
<compatible/>
|
23 |
-
<dependencies
|
24 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>gomage_social_connector</name>
|
4 |
+
<version>1.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.gomage.com/license-agreement/">Single domain license</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>GoMage Social Connector allows your customers to login with the most popular social connectors: Amazon, Facebook, LinkedIn, Google and Google+!, Twitter, Tumblr and Reddit.</summary>
|
10 |
<description>Features of GoMage Social Connector:
|
11 |
+
Connect with Amazon;
|
12 |
+
Connect with Facebook;
|
13 |
+
Connect with Google or Google+ button;
|
14 |
+
Connect with LinkedIn;
|
15 |
+
Connect with Twitter;
|
16 |
+
Connect with Tumblr;
|
17 |
+
Connect with Reddit;
|
18 |
+
No connections to the 3rd party services and monthly fees;
|
19 |
+
No core modifications require;
|
20 |
+
Easy installation of the extension allows you to just upload files and use it.</description>
|
21 |
+
<notes>Version 1.2.0</notes>
|
22 |
+
<authors><author><name>GoMage</name><user>GoMage</user><email>support@gomage.com</email></author></authors>
|
23 |
+
<date>2015-02-24</date>
|
24 |
+
<time>09:05:27</time>
|
25 |
+
<contents><target name="magelocal"><dir name="GoMage"><dir name="Social"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="AbstractRedirectUri.php" hash="60fbad2557b341767c742ac78410ee72"/><dir name="Fieldset"><file name="General.php" hash="f23f692e8f5c7a202c960a5c71cf086b"/><file name="Information.php" hash="e31cf783f18248793a3a6c9c284bec82"/></dir><dir name="RedirectUri"><file name="Amazon.php" hash="1baa41f7b1773c83032d6f502b8f82d5"/><file name="Google.php" hash="82b3c556b085e6aa5f4d3b4e09298064"/><file name="Linkedin.php" hash="6304742cf9ace32f4c98b5f995792992"/><file name="Reddit.php" hash="2bd5c2450c21eca002a6cf691436a81b"/><file name="Tumblr.php" hash="9ab00c069d2c2a41fe4fbdc8d664a426"/><file name="Twitter.php" hash="744d361aa1e06adab3dc0a26b7af772b"/></dir></dir></dir></dir><file name="Head.php" hash="f8a30d108f58076343327fa797628100"/><dir name="Login"><file name="Facebook.php" hash="7a5db2348510bbf11bfc681949610f50"/><file name="Google.php" hash="4b5d589a540a99257a43b8cc03ddbc28"/><file name="Service.php" hash="7727133f01318de6cf5f8e4949c7665c"/></dir><file name="Login.php" hash="ce36cb71ec27f689989939df5fd14309"/></dir><dir name="Controller"><file name="Social.php" hash="374544106ea0872daf1c9552da762998"/><file name="SocialNoMail.php" hash="4f13aae824663b83b1c80b3bd19a8059"/></dir><dir name="Helper"><file name="Data.php" hash="5b75185bae3afccde066e905def21710"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Login"><dir name="Type"><file name="Facebook.php" hash="6216ccfc7f4f0a9a2e14fcaa3b146c1a"/><file name="Google.php" hash="172612f9065d45687f2ec3c15eef8456"/></dir><file name="Type.php" hash="2585b5260c1c70b94460592fda6a7c00"/></dir><file name="Services.php" hash="9eef1aef3275f584ed36f62d29c6855c"/></dir></dir></dir></dir><file name="Entity.php" hash="b93de09a53b97fd187b422b490108f3c"/><dir name="Mysql4"><dir name="Entity"><file name="Collection.php" hash="00e7f804fa0a0527bc9d3870299ce182"/></dir><file name="Entity.php" hash="3f430c0136ae9c269806981374a764dd"/></dir><dir name="Observer"><file name="Notify.php" hash="aa4df6b132dc48efa0bebaebdd06a00e"/></dir><file name="Observer.php" hash="73a72e996fa648fb062c32e1f0a20469"/><file name="Type.php" hash="b772a187101c9c8ac3ad886e9f99b5d2"/></dir><dir name="controllers"><file name="AmazonController.php" hash="f7f60b385d0041026008dee1330074a6"/><file name="FacebookController.php" hash="0fab15e6592035b6aab196f64f3c51fc"/><file name="GoogleController.php" hash="24e6ee9848650e8c27182586b78ac402"/><file name="LinkedinController.php" hash="29e0885b2c86294b5106e9936ed71cf4"/><file name="RedditController.php" hash="74a906ef5fe09c77e7b2ce9857337916"/><file name="TumblrController.php" hash="47f16d380d804de5f017c711b20df254"/><file name="TwitterController.php" hash="533ecb17ac6e42d8a6b11d2203e0b92c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="64d9cea31dd8927d4a8c5baa2c8c5749"/><file name="config.xml" hash="5a70fa98b30ebbff0910a5d821a2108c"/><file name="system.xml" hash="f24765d94e348db681350af4bd123472"/></dir><dir name="sql"><dir name="gomage_social_setup"><file name="mysql4-install-1.0.0.php" hash="8cb49d7aa72ae13c3b62787ff31b24d7"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="624c3202f151a91714171d34f02faef2"/><file name="mysql4-upgrade-1.0.1-1.2.0.php" hash="362b01a230b9ddbe2e54f754c710f73b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GoMage_Social.xml" hash="91ccb1854d1a1a2ba375c6a0a6fc368f"/></dir></target><target name="magelib"><dir name="GoMage"><dir name="Amazon"><file name="Credentials.php" hash="e3948cf4f7a8a4b3bb07862d158ba1ba"/><file name="Service.php" hash="f289253949a2cc260cd0a2895432142f"/></dir><dir name="Facebook"><file name="base_facebook.php" hash="f2a629c25efa36fc02f699f7e52dc61e"/><file name="facebook.php" hash="dcb23268876023d6fa7e1d3349d13819"/><file name="fb_ca_chain_bundle.crt" hash="c4290b9deb70d0bef2f88b67fc68c8ec"/></dir><dir name="Google"><file name="Google_Client.php" hash="7b85279df4c0d845415c97a579df614e"/><dir name="auth"><file name="Google_AssertionCredentials.php" hash="19ec1a0bc3ffdeb07083e225f3e0ac7b"/><file name="Google_Auth.php" hash="15873dc9c390eadbd5da2c0297062d7c"/><file name="Google_AuthNone.php" hash="093b237c59e2e085a97e664c0ce88ebe"/><file name="Google_LoginTicket.php" hash="4397ba773564c0c73f32ae118c24b5d2"/><file name="Google_OAuth2.php" hash="39f54796674f476271ce8d5c05c9ec71"/><file name="Google_P12Signer.php" hash="e33e570503ed42cf7d25dd6c32d67263"/><file name="Google_PemVerifier.php" hash="e9fb745bc98981953a270e0374e77e58"/><file name="Google_Signer.php" hash="b89eb963b836860aa622c2111915e5ac"/><file name="Google_Verifier.php" hash="08c9de305f4824c6d94d7c40bfe7be58"/></dir><dir name="cache"><file name="Google_ApcCache.php" hash="38942168cb94c15a9064aa8faa6c1817"/><file name="Google_Cache.php" hash="98c92b5d919c9143e68230e612298a9b"/><file name="Google_FileCache.php" hash="7cb3f047c1e3774474de8e8b2f5bd638"/><file name="Google_MemcacheCache.php" hash="48f2b20eb2481b40954d0a7a130fa766"/></dir><file name="config.php" hash="a26b007bba5cd5ca2a48bb13f8e7b663"/><dir name="contrib"><file name="Google_AdExchangeSellerService.php" hash="318705a28a809a1d23e3cb834dcf32be"/><file name="Google_AdexchangebuyerService.php" hash="9998193782e0677dc8cba52a126bb3d5"/><file name="Google_AdsenseService.php" hash="7acdc4933f20648c8b4122c9650dc6df"/><file name="Google_AdsensehostService.php" hash="5b2907beaca5a177fc4e06558b20e711"/><file name="Google_AnalyticsService.php" hash="1c1b987a22ed153cc4cf64adf1ff4cb9"/><file name="Google_BigqueryService.php" hash="52cdc203a5959b43c6a8a69b9cb16f45"/><file name="Google_BloggerService.php" hash="65336d21d58f8f2c983246b2a768064c"/><file name="Google_BooksService.php" hash="1d3ea79436b063f95f1b1995217ff105"/><file name="Google_CalendarService.php" hash="1828cfdabcded687997e5cad9999b4bb"/><file name="Google_ComputeService.php" hash="6e02a8f3a711bd99f5c1a5d2fb7c472f"/><file name="Google_CustomsearchService.php" hash="71e240765a29ee901ad1f5f30a7164e6"/><file name="Google_DfareportingService.php" hash="3f2e8a38a9a2ce577a07510785fcf38d"/><file name="Google_DriveService.php" hash="e55201ec487c65eea2dcbbc957d50e0e"/><file name="Google_FreebaseService.php" hash="eb53801d59a2edd1c16e5c5b33fba221"/><file name="Google_FusiontablesService.php" hash="2e484e55d79e219246a7ef8f56dfd5ee"/><file name="Google_GanService.php" hash="0f82b88d1f736652fb0568885329515c"/><file name="Google_LatitudeService.php" hash="165096ab7a3a8b05f97ea3a3f02d28d6"/><file name="Google_LicensingService.php" hash="8f55c323fb03447bab1b7403fd4ab2f6"/><file name="Google_ModeratorService.php" hash="f20f92b05539441192ccf98ef0d6cc90"/><file name="Google_Oauth2Service.php" hash="9273a2ae188738ccd091017212495197"/><file name="Google_OrkutService.php" hash="d0cd466c78cd9c8dcd1e0cfef384696b"/><file name="Google_PagespeedonlineService.php" hash="b73efb6889f190c4aeb01758f8cfc43a"/><file name="Google_PlusMomentsService.php" hash="a4455c8ef47558346a85d2e47588146a"/><file name="Google_PlusService.php" hash="7749cc0a3927896cb3ec038417f65938"/><file name="Google_PredictionService.php" hash="2c4739a3ef181178eb4f76f9ab2d56f6"/><file name="Google_ShoppingService.php" hash="3dbda05eb3f7f8baa7f0188a0a391eac"/><file name="Google_SiteVerificationService.php" hash="9792e2bbe628fdae91dbfae35c00df14"/><file name="Google_StorageService.php" hash="51b240f63170d0c0dd27a2c6e435ddbe"/><file name="Google_TaskqueueService.php" hash="e34f538ffc1e2e412431e85c7cdec662"/><file name="Google_TasksService.php" hash="3065ef4ba7b95317e149191432cb8440"/><file name="Google_TranslateService.php" hash="5dc38b483a051aab0ded6c327beb0025"/><file name="Google_UrlshortenerService.php" hash="ef4fe776c3fa2324dde4afbe0494f979"/><file name="Google_WebfontsService.php" hash="04260525d97d2a1701821eced43fd96e"/><file name="Google_YouTubeService.php" hash="41740022788c34e3bba26abb889855a7"/></dir><dir name="external"><file name="URITemplateParser.php" hash="dc829ddd424801e2bc4bf83bfb5e698c"/></dir><dir name="io"><file name="Google_CacheParser.php" hash="a8524de4f95bc1d237a7bf22dd3dfb8a"/><file name="Google_CurlIO.php" hash="9f5d2871c87ba61cced0efab8c57d4dc"/><file name="Google_HttpRequest.php" hash="01f22c8d762d21fd7c93d4d60737b041"/><file name="Google_IO.php" hash="872ddfd60a5ef638517ef81c7c0b6b95"/><file name="Google_REST.php" hash="61d31688aa7d280b1e7a7ba4d2fcacb3"/><file name="cacerts.pem" hash="2dc185f345f7ca634aec690243f346d8"/></dir><dir name="service"><file name="Google_BatchRequest.php" hash="3c5f95b98e16d1a4a3fe2cc5cf48e9b6"/><file name="Google_MediaFileUpload.php" hash="90cc23d99dd18df03372a02a67de1cce"/><file name="Google_Model.php" hash="2c2d018441c8e8971d6b0528f3f34d85"/><file name="Google_Service.php" hash="213627cf943f19478ecd263b1f253195"/><file name="Google_ServiceResource.php" hash="6aa5fb58563b8c00f5210a9b3db67def"/><file name="Google_Utils.php" hash="612e0e3add05f9cf52d64065b7ccca0a"/></dir></dir><dir name="Linkedin"><file name="OAuth.php" hash="d645162e3e8906ab8c24d1ce54bf0279"/><file name="linkedinoauth.php" hash="9f2758f8acd31780d79fc63c8d391ec5"/></dir><dir name="Reddit"><file name="Client.php" hash="50cc076cfc7dbc0eb06a847c85291878"/><dir name="GrantType"><file name="AuthorizationCode.php" hash="62826c19d8e800bf0ab0a9670911c2c2"/><file name="IGrantType.php" hash="a40c9dfd20b347b518284ab52bb8394c"/></dir></dir><dir name="Tumblr"><file name="OAuth.php" hash="d645162e3e8906ab8c24d1ce54bf0279"/><file name="tumblroauth.php" hash="f43b428616dfb3f2b0938dfd3d334f7e"/></dir><dir name="Twitter"><file name="OAuth.php" hash="b5d02968f42da08c1b80ea70f9aacef6"/><file name="twitteroauth.php" hash="5aed3de5ecb0cd985f670ba8c79526b8"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="gomage-social.xml" hash="e152b0f543ca5710eac37c650314cee2"/></dir><dir name="template"><dir name="gomage"><dir name="social"><file name="config.phtml" hash="af5b3f46ecdd1f4c27dd161e83ed15e7"/><dir name="login"><file name="facebook.phtml" hash="1534737e42b850f7a77b7a3e5bc27fda"/><file name="google.phtml" hash="9f60cc43343e4e59aaa1c0e720432d0e"/><file name="service.phtml" hash="dd3b75b4fb2b6f08d8257b179d3a82bc"/></dir><file name="login.phtml" hash="a3f50d13acd384c58acf5db43b50aa3c"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="gomage"><file name="social.css" hash="1d0249d2c00031f0ec6ae4218ba2dd99"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="css"><dir name="gomage"><file name="social.css" hash="aabc7ba1c5746716d080b3b3a2b04bee"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="gomage"><file name="social.js" hash="c1d702826c8062d0d51661b9c58be97f"/></dir></dir></target></contents>
|
26 |
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>Core</name><min></min><max></max></extension></required></dependencies>
|
28 |
</package>
|
skin/frontend/base/default/css/gomage/social.css
CHANGED
@@ -2,15 +2,15 @@
|
|
2 |
* GoMage Social Connector Extension
|
3 |
*
|
4 |
* @category Extension
|
5 |
-
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
6 |
* @author GoMage
|
7 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
8 |
* @terms of use http://www.gomage.com/terms-of-use
|
9 |
-
* @version Release: 1.0
|
10 |
-
* @since Class available since Release 1.0
|
11 |
*/
|
12 |
|
13 |
-
/* Header Fast Links
|
14 |
-------------------------------------------------- */
|
15 |
.header .links li{
|
16 |
float: none;
|
@@ -32,7 +32,7 @@
|
|
32 |
padding-right: 0 !important;
|
33 |
}
|
34 |
|
35 |
-
/* Lightcheckout
|
36 |
-------------------------------------------------- */
|
37 |
html .glc-login-and-paypal #gcheckout-login-link,
|
38 |
html .glc-login-and-paypal .gs-login-checkout,
|
@@ -50,7 +50,7 @@ html .glc-rtl.glc-login-and-paypal .gs-login-checkout{
|
|
50 |
text-align: left;
|
51 |
}
|
52 |
|
53 |
-
/* Login Page
|
54 |
-------------------------------------------------- */
|
55 |
.gs-login-login,
|
56 |
.gs-login-checkout{
|
@@ -77,4 +77,79 @@ html .glc-rtl.glc-login-and-paypal .gs-login-checkout{
|
|
77 |
.gs-login-ee.gs-login-checkout{
|
78 |
padding: 5px 20px;
|
79 |
text-align: left;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
2 |
* GoMage Social Connector Extension
|
3 |
*
|
4 |
* @category Extension
|
5 |
+
* @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
|
6 |
* @author GoMage
|
7 |
* @license http://www.gomage.com/license-agreement/ Single domain license
|
8 |
* @terms of use http://www.gomage.com/terms-of-use
|
9 |
+
* @version Release: 1.2.0
|
10 |
+
* @since Class available since Release 1.0.0
|
11 |
*/
|
12 |
|
13 |
+
/* Header Fast Links
|
14 |
-------------------------------------------------- */
|
15 |
.header .links li{
|
16 |
float: none;
|
32 |
padding-right: 0 !important;
|
33 |
}
|
34 |
|
35 |
+
/* Lightcheckout
|
36 |
-------------------------------------------------- */
|
37 |
html .glc-login-and-paypal #gcheckout-login-link,
|
38 |
html .glc-login-and-paypal .gs-login-checkout,
|
50 |
text-align: left;
|
51 |
}
|
52 |
|
53 |
+
/* Login Page
|
54 |
-------------------------------------------------- */
|
55 |
.gs-login-login,
|
56 |
.gs-login-checkout{
|
77 |
.gs-login-ee.gs-login-checkout{
|
78 |
padding: 5px 20px;
|
79 |
text-align: left;
|
80 |
+
}
|
81 |
+
.gs-popup-content {
|
82 |
+
|
83 |
+
position: absolute;
|
84 |
+
margin-left: 60%;
|
85 |
+
margin-top: 10%;
|
86 |
+
background: #ffffff;
|
87 |
+
|
88 |
+
text-align: center;
|
89 |
+
z-index: 999;
|
90 |
+
|
91 |
+
}
|
92 |
+
#gsc_message{
|
93 |
+
color: red;
|
94 |
+
}
|
95 |
+
|
96 |
+
#gomage-social-overlay,
|
97 |
+
.overlay_gomage_cp{
|
98 |
+
background:#000;
|
99 |
+
z-index:2000 !important;
|
100 |
+
filter:alpha(opacity=60);
|
101 |
+
-webkit-opacity:.6;
|
102 |
+
-moz-opacity:.6;
|
103 |
+
opacity:.6;
|
104 |
+
}
|
105 |
+
|
106 |
+
/* Popup
|
107 |
+
-------------------------------------------------- */
|
108 |
+
#gs-validate-detail{
|
109 |
+
padding: 10px 6px 0;
|
110 |
+
}
|
111 |
+
#gs-validate-detail .form-list label{
|
112 |
+
width: auto;
|
113 |
+
padding: 0;
|
114 |
+
float: left;
|
115 |
+
position: relative;
|
116 |
+
}
|
117 |
+
#gs-validate-detail .form-list label em{
|
118 |
+
position: absolute;
|
119 |
+
right: -8px;
|
120 |
+
margin: 0;
|
121 |
+
}
|
122 |
+
#gs-validate-detail .input-box,
|
123 |
+
#gs-validate-detail .form-list input.input-text{
|
124 |
+
width: 100%;
|
125 |
+
-webkit-box-sizing: border-box;
|
126 |
+
-moz-box-sizing : border-box;
|
127 |
+
box-sizing : border-box;
|
128 |
+
}
|
129 |
+
#gs-validate-detail .actions{
|
130 |
+
overflow: hidden;
|
131 |
+
}
|
132 |
+
#gs-validate-detail .actions button.button{
|
133 |
+
float: right;
|
134 |
+
}
|
135 |
+
#gs-please-wait{
|
136 |
+
float: left;
|
137 |
+
position: static;
|
138 |
+
margin: 0;
|
139 |
+
background: none;
|
140 |
+
border: 0;
|
141 |
+
padding: 0;
|
142 |
+
}
|
143 |
+
#gs-message{
|
144 |
+
color: red;
|
145 |
+
clear: both;
|
146 |
+
margin: 5px 0;
|
147 |
+
}
|
148 |
+
.dialog-gs .magento_w,
|
149 |
+
.dialog-gs .magento_e{
|
150 |
+
width: 0;
|
151 |
+
}
|
152 |
+
.dialog-gs.dialog,
|
153 |
+
.dialog-gs.magento_content{
|
154 |
+
height: auto !important;
|
155 |
}
|
skin/frontend/rwd/default/css/gomage/social.css
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* GoMage Social Connector Extension
|
3 |
+
*
|
4 |
+
* @category Extension
|
5 |
+
* @copyright Copyright (c) 2013 GoMage (http://www.gomage.com)
|
6 |
+
* @author GoMage
|
7 |
+
* @license http://www.gomage.com/license-agreement/ Single domain license
|
8 |
+
* @terms of use http://www.gomage.com/terms-of-use
|
9 |
+
* @version Release: 1.1.0
|
10 |
+
* @since Class available since Release 1.0.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
/* Header Fast Links
|
14 |
+
-------------------------------------------------- */
|
15 |
+
.header .links li{
|
16 |
+
float: none;
|
17 |
+
display: inline-block;
|
18 |
+
vertical-align: middle;
|
19 |
+
}
|
20 |
+
.header .gs-list{
|
21 |
+
padding: 0 !important;
|
22 |
+
}
|
23 |
+
|
24 |
+
/* Fixed height for Google + */
|
25 |
+
.gs-login [id^="___signin"]{
|
26 |
+
height: 20px !important;
|
27 |
+
vertical-align: middle !important;
|
28 |
+
}
|
29 |
+
.header .gs-list.last,
|
30 |
+
.header .gs-list .last{
|
31 |
+
background: none !important;
|
32 |
+
padding-right: 0 !important;
|
33 |
+
}
|
34 |
+
|
35 |
+
/* Lightcheckout
|
36 |
+
-------------------------------------------------- */
|
37 |
+
html .glc-login-and-paypal #gcheckout-login-link,
|
38 |
+
html .glc-login-and-paypal .gs-login-checkout,
|
39 |
+
html .glc-rtl.glc-login-and-paypal #gcheckout-login-link,
|
40 |
+
html .glc-rtl.glc-login-and-paypal .gs-login-checkout{
|
41 |
+
float: none;
|
42 |
+
display: inline-block;
|
43 |
+
vertical-align: middle;
|
44 |
+
}
|
45 |
+
html .glc-login-and-paypal .gs-login-checkout *{
|
46 |
+
vertical-align: middle;
|
47 |
+
}
|
48 |
+
.glc-login-and-paypal .gs-login-ee.gs-login-checkout{
|
49 |
+
padding: 0;
|
50 |
+
text-align: left;
|
51 |
+
}
|
52 |
+
|
53 |
+
/* Login Page
|
54 |
+
-------------------------------------------------- */
|
55 |
+
.gs-login-login,
|
56 |
+
.gs-login-checkout{
|
57 |
+
text-align: right;
|
58 |
+
padding: 5px 0;
|
59 |
+
}
|
60 |
+
.gs-login-login li{
|
61 |
+
padding: 0 2px;
|
62 |
+
}
|
63 |
+
.gs-login li{
|
64 |
+
display: inline-block;
|
65 |
+
vertical-align: middle;
|
66 |
+
}
|
67 |
+
.gs-login img{
|
68 |
+
vertical-align: middle;
|
69 |
+
}
|
70 |
+
.gs-login-fast_links li{
|
71 |
+
display: block;
|
72 |
+
text-align: center;
|
73 |
+
}
|
74 |
+
.gs-login-fast_links img{
|
75 |
+
display: inline-block;
|
76 |
+
}
|
77 |
+
|
78 |
+
/* EE
|
79 |
+
-------------------------------------------------- */
|
80 |
+
.gs-login-ee.gs-login-login{
|
81 |
+
text-align: left;
|
82 |
+
clear: both;
|
83 |
+
}
|
84 |
+
.gs-login-ee.gs-login-checkout{
|
85 |
+
padding: 5px 20px;
|
86 |
+
text-align: left;
|
87 |
+
}
|
88 |
+
.gs-popup-content {
|
89 |
+
|
90 |
+
position: absolute;
|
91 |
+
margin-left: 60%;
|
92 |
+
margin-top: 10%;
|
93 |
+
background: #ffffff;
|
94 |
+
|
95 |
+
text-align: center;
|
96 |
+
z-index: 999;
|
97 |
+
|
98 |
+
}
|
99 |
+
#gsc_message{
|
100 |
+
color: red;
|
101 |
+
}
|
102 |
+
|
103 |
+
#gomage-social-overlay,
|
104 |
+
.overlay_gomage_cp{
|
105 |
+
background:#000;
|
106 |
+
z-index:2000 !important;
|
107 |
+
filter:alpha(opacity=60);
|
108 |
+
-webkit-opacity:.6;
|
109 |
+
-moz-opacity:.6;
|
110 |
+
opacity:.6;
|
111 |
+
}
|
112 |
+
|
113 |
+
/* Popup
|
114 |
+
-------------------------------------------------- */
|
115 |
+
#gs-validate-detail{
|
116 |
+
padding: 10px 6px 0;
|
117 |
+
}
|
118 |
+
#gs-validate-detail .form-list label{
|
119 |
+
width: auto;
|
120 |
+
padding: 0;
|
121 |
+
float: left;
|
122 |
+
position: relative;
|
123 |
+
}
|
124 |
+
#gs-validate-detail .form-list label em{
|
125 |
+
position: absolute;
|
126 |
+
right: -8px;
|
127 |
+
margin: 0;
|
128 |
+
}
|
129 |
+
#gs-validate-detail .input-box,
|
130 |
+
#gs-validate-detail .form-list input.input-text{
|
131 |
+
width: 100%;
|
132 |
+
-webkit-box-sizing: border-box;
|
133 |
+
-moz-box-sizing : border-box;
|
134 |
+
box-sizing : border-box;
|
135 |
+
}
|
136 |
+
#gs-validate-detail .actions{
|
137 |
+
overflow: hidden;
|
138 |
+
}
|
139 |
+
#gs-validate-detail .actions button.button{
|
140 |
+
float: right;
|
141 |
+
}
|
142 |
+
#gs-please-wait{
|
143 |
+
float: left;
|
144 |
+
position: static;
|
145 |
+
margin: 0;
|
146 |
+
background: none;
|
147 |
+
border: 0;
|
148 |
+
padding: 0;
|
149 |
+
}
|
150 |
+
#gs-message{
|
151 |
+
color: red;
|
152 |
+
clear: both;
|
153 |
+
margin: 5px 0;
|
154 |
+
}
|
155 |
+
.dialog-gs .magento_w,
|
156 |
+
.dialog-gs .magento_e{
|
157 |
+
width: 0;
|
158 |
+
}
|
159 |
+
.dialog-gs.dialog,
|
160 |
+
.dialog-gs.magento_content{
|
161 |
+
height: auto !important;
|
162 |
+
}
|