Social_Facebook - Version 2.0.0

Version Notes

Facebook Open Graph 2.0 extension is compatible with Magento Enterprise Edition and Professional Edition 1.11 or later, and Magento Community Edition 1.6 or later.

Download this release

Release Info

Developer Magento Core Team
Extension Social_Facebook
Version 2.0.0
Comparing to
See all releases


Code changes from version 1.4.0.0 to 2.0.0

Files changed (39) hide show
  1. app/code/community/Social/Facebook/Block/Action.php +28 -5
  2. app/code/community/Social/Facebook/Block/Adminhtml/Facebuttons.php +9 -44
  3. app/code/community/Social/Facebook/Block/Adminhtml/Select.php +3 -10
  4. app/code/community/Social/Facebook/Block/Adminhtml/System/Form/Renderer/Config/AuthButton.php +94 -0
  5. app/code/community/Social/Facebook/Block/Adminhtml/System/Form/Renderer/Config/RegisterButton.php +97 -0
  6. app/code/community/Social/Facebook/Block/Box.php +61 -11
  7. app/code/community/Social/Facebook/Block/Head.php +1 -1
  8. app/code/community/Social/Facebook/Block/Like.php +0 -23
  9. app/code/community/Social/Facebook/Block/Socialdata.php +86 -0
  10. app/code/community/Social/Facebook/Block/Start.php +3 -38
  11. app/code/community/Social/Facebook/Helper/Data.php +73 -35
  12. app/code/community/Social/Facebook/Model/Api.php +231 -31
  13. app/code/community/Social/Facebook/Model/Facebook.php +154 -61
  14. app/code/community/Social/Facebook/Model/Facebuttons.php +1 -1
  15. app/code/community/Social/Facebook/Model/Mysql4/Facebook.php +0 -129
  16. app/code/community/Social/Facebook/Model/Mysql4/Facebook/Collection.php +0 -44
  17. app/code/community/Social/Facebook/Model/Observer.php +15 -53
  18. app/code/community/Social/Facebook/Model/System/Config/Backend/Authorization.php +87 -0
  19. app/code/community/Social/Facebook/controllers/IndexController.php +67 -3
  20. app/code/community/Social/Facebook/etc/adminhtml.xml +49 -0
  21. app/code/community/Social/Facebook/etc/config.xml +13 -45
  22. app/code/community/Social/Facebook/etc/social.events.product.fetch.json +11 -0
  23. app/code/community/Social/Facebook/etc/social.events.product.fetchSucceeded.json +11 -0
  24. app/code/community/Social/Facebook/etc/social.events.product.new.json +19 -0
  25. app/code/community/Social/Facebook/etc/system.tenant.relationship.created.json +1 -0
  26. app/code/community/Social/Facebook/etc/system.xml +74 -11
  27. app/code/community/Social/Facebook/etc/xfabric.tenant.updated.json +19 -0
  28. app/code/community/Social/Facebook/locale/Social_Facebook.csv +0 -0
  29. app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-install-1.4.0.php +0 -42
  30. app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-upgrade-1.4.0-1.4.0.1.php +0 -41
  31. app/design/adminhtml/default/default/template/social/facebook/system/config/button.phtml +49 -0
  32. app/design/frontend/base/default/layout/facebook.xml +13 -23
  33. app/design/frontend/base/default/template/social/facebook/action.phtml +18 -6
  34. app/design/frontend/base/default/template/social/facebook/box.phtml +9 -7
  35. app/design/frontend/base/default/template/social/facebook/box.phtml~ +0 -55
  36. app/design/frontend/base/default/template/social/facebook/empty.phtml +56 -9
  37. app/design/frontend/base/default/template/social/facebook/socialdata.phtml +8 -0
  38. package.xml +9 -9
  39. skin/frontend/base/default/css/facebook.css +58 -23
app/code/community/Social/Facebook/Block/Action.php CHANGED
@@ -14,8 +14,8 @@
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
18
- * @license http://www.magentocommerce.com/license/enterprise-edition
19
  */
20
 
21
  class Social_Facebook_Block_Action extends Mage_Core_Block_Template
@@ -33,9 +33,32 @@ class Social_Facebook_Block_Action extends Mage_Core_Block_Template
33
  parent::_construct();
34
 
35
  $product = Mage::registry('product');
36
- $this->setProductId($product->getId());
 
37
 
38
- $this->setAllActions(Mage::helper('social_facebook')->getAllActions());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  return $this;
41
  }
@@ -52,7 +75,7 @@ class Social_Facebook_Block_Action extends Mage_Core_Block_Template
52
  'facebook/index/redirect/',
53
  array(
54
  'productId' => $this->getProductId(),
55
- 'action' => $this->htmlEscape($action),
56
  ));
57
  }
58
  }
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
21
  class Social_Facebook_Block_Action extends Mage_Core_Block_Template
33
  parent::_construct();
34
 
35
  $product = Mage::registry('product');
36
+ $productId = $product->getId();
37
+ $this->setProductId($productId);
38
 
39
+ $session = Mage::getSingleton('core/session');
40
+ $user = $session->getData('facebook_user');
41
+ $actions = Mage::helper('social_facebook')->getAllActions();
42
+ $api = Mage::getSingleton('social_facebook/api');
43
+
44
+ $this->setTemplate('social/facebook/action.phtml');
45
+
46
+ $json = $api->getSocialData();
47
+
48
+ if (empty($json->count)) {
49
+ $this->setAllActions($actions);
50
+ return $this;
51
+ }
52
+
53
+ if ($user) {
54
+ foreach ($actions as $aid => $attrs) {
55
+ $actions[$aid]['selected'] = false;
56
+ if (!empty($json->actions->$attrs['action'])) {
57
+ $actions[$aid]['selected'] = in_array($user['facebook_id'], $json->actions->$attrs['action']);
58
+ }
59
+ }
60
+ }
61
+ $this->setAllActions($actions);
62
 
63
  return $this;
64
  }
75
  'facebook/index/redirect/',
76
  array(
77
  'productId' => $this->getProductId(),
78
+ 'action' => $this->escapeHtml($action),
79
  ));
80
  }
81
  }
app/code/community/Social/Facebook/Block/Adminhtml/Facebuttons.php CHANGED
@@ -18,19 +18,12 @@
18
  * versions in the future. If you wish to customize Magento for your
19
  * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
- * @category Mage
22
- * @package Mage_Adminhtml
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
- /**
28
- * Adminhtml system config array field renderer
29
- *
30
- * @category Mage
31
- * @package Mage_Adminhtml
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
  class Social_Facebook_Block_Adminhtml_Facebuttons extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
35
  {
36
  /**
@@ -38,20 +31,6 @@ class Social_Facebook_Block_Adminhtml_Facebuttons extends Mage_Adminhtml_Block_S
38
  */
39
  protected $_selectRenderer;
40
 
41
- /**
42
- * Check if columns are defined, set template
43
- *
44
- */
45
- public function __construct()
46
- {
47
- if (!$this->_addButtonLabel) {
48
- $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add');
49
- }
50
- if (!$this->getTemplate()) {
51
- $this->setTemplate('system/config/form/field/array.phtml');
52
- }
53
- }
54
-
55
  /**
56
  * Retrieve checkbox column renderer
57
  *
@@ -72,11 +51,13 @@ class Social_Facebook_Block_Adminhtml_Facebuttons extends Mage_Adminhtml_Block_S
72
 
73
  /**
74
  * Prepare to render
 
 
75
  */
76
  protected function _prepareToRender()
77
  {
78
  $this->addColumn('action', array(
79
- 'label' => Mage::helper('social_facebook')->__('Action'),
80
  'style' => 'width:120px',
81
  ));
82
  $this->addColumn('title', array(
@@ -88,29 +69,13 @@ class Social_Facebook_Block_Adminhtml_Facebuttons extends Mage_Adminhtml_Block_S
88
  'renderer' => $this->_selectRenderer(),
89
  ));
90
  $this->addColumn('count', array(
91
- 'label' => Mage::helper('social_facebook')->__('Count in FriendBox'),
92
  'style' => 'width:120px',
 
93
  ));
94
 
95
  $this->_addAfter = false;
96
- $this->_addButtonLabel = Mage::helper('social_facebook')->__('Add Action Button');
97
- }
98
-
99
- /**
100
- * Render block HTML
101
- *
102
- * @return string
103
- */
104
- protected function _toHtml()
105
- {
106
- if (!$this->_isPreparedToRender) {
107
- $this->_prepareToRender();
108
- $this->_isPreparedToRender = true;
109
- }
110
- if (empty($this->_columns)) {
111
- throw new Exception('At least one column must be defined.');
112
- }
113
- return parent::_toHtml();
114
  }
115
 
116
  /**
18
  * versions in the future. If you wish to customize Magento for your
19
  * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
+ * @category Social
22
+ * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
 
 
 
 
 
 
 
27
  class Social_Facebook_Block_Adminhtml_Facebuttons extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
28
  {
29
  /**
31
  */
32
  protected $_selectRenderer;
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Retrieve checkbox column renderer
36
  *
51
 
52
  /**
53
  * Prepare to render
54
+ *
55
+ * @return void
56
  */
57
  protected function _prepareToRender()
58
  {
59
  $this->addColumn('action', array(
60
+ 'label' => Mage::helper('social_facebook')->__('Facebook Action'),
61
  'style' => 'width:120px',
62
  ));
63
  $this->addColumn('title', array(
69
  'renderer' => $this->_selectRenderer(),
70
  ));
71
  $this->addColumn('count', array(
72
+ 'label' => Mage::helper('social_facebook')->__('Number of friends to show (default %d)', Mage::helper('social_facebook')->getAppFriendCount('')),
73
  'style' => 'width:120px',
74
+ 'value' => 5
75
  ));
76
 
77
  $this->_addAfter = false;
78
+ $this->_addButtonLabel = Mage::helper('social_facebook')->__('Add an Action');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  /**
app/code/community/Social/Facebook/Block/Adminhtml/Select.php CHANGED
@@ -18,19 +18,12 @@
18
  * versions in the future. If you wish to customize Magento for your
19
  * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
- * @category Mage
22
- * @package Mage_Adminhtml
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
- /**
28
- * Adminhtml system config array field renderer
29
- *
30
- * @category Mage
31
- * @package Mage_Adminhtml
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
  class Social_Facebook_Block_Adminhtml_Select extends Mage_Core_Block_Html_Select
35
  {
36
  protected $_options = array();
18
  * versions in the future. If you wish to customize Magento for your
19
  * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
+ * @category Social
22
+ * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
 
 
 
 
 
 
 
27
  class Social_Facebook_Block_Adminhtml_Select extends Mage_Core_Block_Html_Select
28
  {
29
  protected $_options = array();
app/code/community/Social/Facebook/Block/Adminhtml/System/Form/Renderer/Config/AuthButton.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Social
22
+ * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Social_Facebook_Block_Adminhtml_System_Form_Renderer_Config_AuthButton
27
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
28
+ implements Varien_Data_Form_Element_Renderer_Interface
29
+ {
30
+ protected $_template = 'social/facebook/system/config/button.phtml';
31
+
32
+ /**
33
+ * Unset scope label and pass further to parent render()
34
+ *
35
+ * @param Varien_Data_Form_Element_Abstract $element
36
+ * @return string
37
+ */
38
+ public function render(Varien_Data_Form_Element_Abstract $element)
39
+ {
40
+ // Unset the scope label near the button
41
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
42
+ return parent::render($element);
43
+ }
44
+
45
+ /**
46
+ * Get the button and scripts contents
47
+ *
48
+ * @param Varien_Data_Form_Element_Abstract $element
49
+ * @return string
50
+ */
51
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
52
+ {
53
+ $postData = array(
54
+ 'target_capability_name' => 'Social Commerce',
55
+ 'is_registered' => false,
56
+ 'legal_agreement_url' => 'http://www.magentocommerce.com\/company\/terms',
57
+ 'store-front-platform' => 'Magento ' . Mage::getVersion()
58
+ );
59
+
60
+ $postData = urlencode(Mage::helper('core')->jsonEncode($postData));
61
+
62
+ $client = new Zend_Http_Client(Social_Facebook_Model_Facebook::ONBOARDING_URL_DOMAIN
63
+ . Social_Facebook_Model_Facebook::ONBOARDING_URL, array(
64
+ 'maxredirects' => 0,
65
+ 'timeout' => 30));
66
+
67
+ $client->setParameterPost('onboarding_info', $postData);
68
+
69
+ $client->request('POST');
70
+
71
+ $headers = Zend_Http_Response::extractHeaders($client->getLastResponse());
72
+
73
+ $buttonUrl = Social_Facebook_Model_Facebook::ONBOARDING_URL_DOMAIN .
74
+ Social_Facebook_Model_Facebook::ONBOARDING_URL;
75
+
76
+ if (!empty($headers['location'])) {
77
+ $buttonUrl = Social_Facebook_Model_Facebook::ONBOARDING_URL_DOMAIN . $headers['location'];
78
+ }
79
+
80
+ $originalData = $element->getOriginalData();
81
+
82
+ $this->addData(array(
83
+ 'button_label' => $originalData['button_label'],
84
+ 'html_id' => $element->getHtmlId(),
85
+ 'button_url' => trim($buttonUrl),
86
+ ));
87
+
88
+ $token = Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_CAP_TOKEN);
89
+ if (empty($token)) {
90
+ $this->setIsDisabled(true);
91
+ }
92
+ return $this->_toHtml();
93
+ }
94
+ }
app/code/community/Social/Facebook/Block/Adminhtml/System/Form/Renderer/Config/RegisterButton.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Social
22
+ * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Social_Facebook_Block_Adminhtml_System_Form_Renderer_Config_RegisterButton
27
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
28
+ implements Varien_Data_Form_Element_Renderer_Interface
29
+ {
30
+ protected $_template = 'social/facebook/system/config/button.phtml';
31
+
32
+ /**
33
+ * Unset scope label and pass further to parent render()
34
+ *
35
+ * @param Varien_Data_Form_Element_Abstract $element
36
+ * @return string
37
+ */
38
+ public function render(Varien_Data_Form_Element_Abstract $element)
39
+ {
40
+ // Unset the scope label near the button
41
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
42
+ return parent::render($element);
43
+ }
44
+
45
+ /**
46
+ * Get the button and scripts contents
47
+ *
48
+ * @param Varien_Data_Form_Element_Abstract $element
49
+ * @return string
50
+ */
51
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
52
+ {
53
+ $store = Mage::app()->getStore();
54
+ //
55
+ $postData = array(
56
+ 'store_instance_name' => $store->getName(),
57
+ 'is_registered' => false,
58
+ );
59
+
60
+ $postData = urlencode(Mage::helper('core')->jsonEncode($postData));
61
+
62
+ $client = new Zend_Http_Client(Social_Facebook_Model_Facebook::ONBOARDING_URL_DOMAIN .
63
+ Social_Facebook_Model_Facebook::ONBOARDING_URL, array(
64
+ 'maxredirects' => 0,
65
+ 'timeout' => 30));
66
+
67
+ $client->setParameterPost('fabric_config_info', $postData);
68
+
69
+ $client->request('POST');
70
+
71
+ $headers = Zend_Http_Response::extractHeaders($client->getLastResponse());
72
+
73
+ $buttonUrl = Social_Facebook_Model_Facebook::ONBOARDING_URL_DOMAIN .
74
+ Social_Facebook_Model_Facebook::ONBOARDING_URL;
75
+
76
+ if (!empty($headers['location'])) {
77
+ $buttonUrl = Social_Facebook_Model_Facebook::ONBOARDING_URL_DOMAIN . $headers['location'];
78
+ }
79
+
80
+ $originalData = $element->getOriginalData();
81
+
82
+ $this->addData(array(
83
+ 'button_label' => $originalData['button_label'],
84
+ 'html_id' => $element->getHtmlId(),
85
+ 'button_url' => trim($buttonUrl),
86
+ ));
87
+
88
+ $token = Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_CAP_TOKEN);
89
+ if (!empty($token)) {
90
+ $this->setToken($token);
91
+ $this->setFabricUrl(Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_FABRIC_URL));
92
+ $this->setTenantName(Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_TENANT_NAME));
93
+ }
94
+
95
+ return $this->_toHtml();
96
+ }
97
+ }
app/code/community/Social/Facebook/Block/Box.php CHANGED
@@ -14,7 +14,7 @@
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
- * @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
@@ -27,17 +27,34 @@ class Social_Facebook_Block_Box extends Mage_Core_Block_Template
27
  */
28
  protected function _construct()
29
  {
30
- if (!Mage::helper('social_facebook')->isEnabled() || Mage::getSingleton('core/session')->getNoBoxes()) {
 
 
 
31
  return;
32
  }
 
 
 
 
 
 
 
33
  parent::_construct();
34
 
35
  $product = Mage::registry('product');
36
- $this->setProductId($product->getId());
37
 
38
- $this->setAllActions(Mage::helper('social_facebook')->getAllActions());
 
39
 
40
- $this->setFacebookId(Mage::getSingleton('core/session')->getData('facebook_id'));
 
 
 
 
 
 
 
41
 
42
  return $this;
43
  }
@@ -50,8 +67,41 @@ class Social_Facebook_Block_Box extends Mage_Core_Block_Template
50
  */
51
  public function getFriendBox($action)
52
  {
53
- return Mage::getModel('social_facebook/facebook')->getLinkedFriends($this->getFacebookId(),
54
- $this->getProductId(), $action);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  /**
@@ -62,9 +112,9 @@ class Social_Facebook_Block_Box extends Mage_Core_Block_Template
62
  */
63
  public function getCountOfUsers($action)
64
  {
65
- return Mage::getModel('social_facebook/facebook')->getCountByActionProduct(
66
- $this->escapeHtml($action),
67
- $this->getProductId()
68
- );
69
  }
70
  }
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
27
  */
28
  protected function _construct()
29
  {
30
+ $model = Mage::getSingleton('social_facebook/api');
31
+ $json = $model->getSocialData();
32
+
33
+ if (!Mage::helper('social_facebook')->isEnabled()) {
34
  return;
35
  }
36
+
37
+ if (!is_object($json) || !sizeof(get_object_vars($json->actions))) {
38
+ Mage::helper('social_facebook')->__('The Social Commerce
39
+ extension is enabled but no actions have been setup');
40
+ return;
41
+ }
42
+
43
  parent::_construct();
44
 
45
  $product = Mage::registry('product');
 
46
 
47
+ if ($product) {
48
+ $this->setProductId($product->getId());
49
 
50
+ $this->setAllActions(Mage::helper('social_facebook')->getAllActions());
51
+
52
+ $this->setFacebookId(Mage::getSingleton('core/session')->getData('facebook_id'));
53
+
54
+ $this->setSocialData(Mage::getSingleton('social_facebook/api')->getSocialData());
55
+ }
56
+
57
+ $this->setTemplate('social/facebook/box.phtml');
58
 
59
  return $this;
60
  }
67
  */
68
  public function getFriendBox($action)
69
  {
70
+ static $friendInfo = array();
71
+
72
+ $currFbId = $this->getFacebookId();
73
+ $json = $this->getSocialData();
74
+ $friends = array();
75
+ $api = Mage::getSingleton('social_facebook/api');
76
+ $accessToken = Mage::getSingleton('core/session')->getAccessToken();
77
+
78
+ if (empty($json->actions->$action)) {
79
+ return $friends;
80
+ }
81
+
82
+ $friends = $json->actions->$action;
83
+
84
+ $idx = 0;
85
+ foreach ($friends as $fbId) {
86
+ unset($friends[$idx++]);
87
+ if (empty($friendInfo[$fbId])) {
88
+ $response = $api->makeFacebookRequest(
89
+ array('access_token' => $accessToken),
90
+ Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_OBJECT_ID . $fbId, Zend_Http_Client::GET);
91
+
92
+ $friendInfo[$fbId] = $result = $response[1];
93
+ } else {
94
+ $result = $friendInfo[$fbId];
95
+ }
96
+ $friends[$fbId] = $result->first_name;
97
+ }
98
+
99
+ foreach (array_keys($friends) as $fbId) {
100
+ if ($fbId==$currFbId) {
101
+ $friends[$fbId] = 'you';break;
102
+ }
103
+ }
104
+ return $friends;
105
  }
106
 
107
  /**
112
  */
113
  public function getCountOfUsers($action)
114
  {
115
+ $json = $this->getSocialData();
116
+ if (!empty($json->actions->$action)) {
117
+ return sizeof($json->actions->$action);
118
+ }
119
  }
120
  }
app/code/community/Social/Facebook/Block/Head.php CHANGED
@@ -14,7 +14,7 @@
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
- * @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
app/code/community/Social/Facebook/Block/Like.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @category Social
16
- * @package Social_Facebook
17
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
18
- * @license http://www.magentocommerce.com/license/enterprise-edition
19
- */
20
- class Social_Facebook_Block_Like extends Mage_Core_Block_Template
21
- {
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Social/Facebook/Block/Socialdata.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Social
16
+ * @package Social_Facebook
17
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Social_Facebook_Block_Socialdata extends Mage_Core_Block_Template
22
+ {
23
+ private $_count;
24
+
25
+ /**
26
+ * Block Initialization
27
+ *
28
+ * @return Social_Facebook_Block_Head
29
+ */
30
+ protected function _construct()
31
+ {
32
+ $helper = Mage::helper('social_facebook');
33
+ $api = Mage::getSingleton('social_facebook/api');
34
+ $this->_count = 0;
35
+
36
+ if (!$helper->isEnabled()) {
37
+ return;
38
+ }
39
+ parent::_construct();
40
+
41
+ /** @var $product Mage_Catalog_Model_Product */
42
+ $product = Mage::registry('product');
43
+ $json = $api->getSocialData();
44
+ $this->setSocialData($json);
45
+
46
+ if ($product) {
47
+ if (!empty($json->count)) {
48
+ $this->setPeopleCount($json->count);
49
+ }
50
+ }
51
+
52
+ $this->setTemplate('social/facebook/empty.phtml');
53
+
54
+ $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_NO_TEXT);
55
+
56
+ $session = Mage::getSingleton('core/session');
57
+ $session->setData('product_id', $product->getId());
58
+ $session->setData('product_url', $product->getUrlModel()->getUrlInStore($product));
59
+ $this->setFbUserId($session->getData('facebook_id'));
60
+
61
+ $accessToken = $session->getData('access_token');
62
+
63
+ if (!$accessToken) {
64
+ $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_CONNECT);
65
+ $this->setConnectUrl(Mage::helper('social_facebook')->getRedirectUrl($product));
66
+ $session->unsetData('facebook_action');
67
+ $session->setData('no_boxes', 1);
68
+ } else {
69
+ $actions = Mage::helper('social_facebook')->getAllActions();
70
+ foreach ($actions as $action) {
71
+ if (!empty($json->actions->$action['action'])) {
72
+ $data = true; break;
73
+ }
74
+ }
75
+
76
+ if (empty($data)) {
77
+ $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_FRIENDS);
78
+ $session->setData('no_boxes', 1);
79
+ } else {
80
+ $session->unsetData('no_boxes');
81
+ }
82
+ }
83
+
84
+ return $this;
85
+ }
86
+ }
app/code/community/Social/Facebook/Block/Start.php CHANGED
@@ -14,7 +14,7 @@
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
- * @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
@@ -24,19 +24,15 @@ class Social_Facebook_Block_Start extends Mage_Core_Block_Template
24
  const FACEBOOK_BLOCK_START_CONNECT = 1;
25
  const FACEBOOK_BLOCK_START_FRIENDS = 2;
26
 
27
- /**
28
- * Block Initialization
29
- *
30
- * @return
31
- */
32
  protected function _construct()
33
  {
34
  if (!Mage::helper('social_facebook')->isEnabled()) {
35
  return;
36
  }
 
37
  parent::_construct();
38
 
39
- $this->setTemplate('social/facebook/empty.phtml');
40
 
41
  $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_NO_TEXT);
42
 
@@ -45,36 +41,5 @@ class Social_Facebook_Block_Start extends Mage_Core_Block_Template
45
  $session = Mage::getSingleton('core/session');
46
  $session->setData('product_id', $product->getId());
47
  $session->setData('product_url', $product->getUrlModel()->getUrlInStore($product));
48
-
49
- $accessToken = $session->getData('access_token');
50
- $facebookId = $session->getData('facebook_id');
51
-
52
- $this->setPeopleCount(
53
- Mage::getModel('social_facebook/facebook')->getCountByProduct($product->getId())
54
- );
55
-
56
- if (!$accessToken) {
57
- $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_CONNECT);
58
- $this->setConnectUrl(Mage::helper('social_facebook')->getRedirectUrl($product));
59
- $session->unsetData('facebook_action');
60
- $session->setData('no_boxes', 1);
61
- } else {
62
- $actions = Mage::helper('social_facebook')->getAllActions();
63
- $users = array();
64
- foreach ($actions as $action) {
65
- $data = Mage::getModel('social_facebook/facebook')->getLinkedFriends($facebookId, $product->getId(),
66
- $action['action']);
67
- if (!empty($data)) {
68
- break;
69
- }
70
- }
71
-
72
- if (empty($data)) {
73
- $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_FRIENDS);
74
- $session->setData('no_boxes', 1);
75
- } else {
76
- $session->unsetData('no_boxes');
77
- }
78
- }
79
  }
80
  }
14
  *
15
  * @category Social
16
  * @package Social_Facebook
17
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
24
  const FACEBOOK_BLOCK_START_CONNECT = 1;
25
  const FACEBOOK_BLOCK_START_FRIENDS = 2;
26
 
 
 
 
 
 
27
  protected function _construct()
28
  {
29
  if (!Mage::helper('social_facebook')->isEnabled()) {
30
  return;
31
  }
32
+
33
  parent::_construct();
34
 
35
+ $this->setTemplate('social/facebook/socialdata.phtml');
36
 
37
  $this->setShowSumm(Social_Facebook_Block_Start::FACEBOOK_BLOCK_NO_TEXT);
38
 
41
  $session = Mage::getSingleton('core/session');
42
  $session->setData('product_id', $product->getId());
43
  $session->setData('product_url', $product->getUrlModel()->getUrlInStore($product));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
  }
app/code/community/Social/Facebook/Helper/Data.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -34,73 +34,110 @@
34
  class Social_Facebook_Helper_Data extends Mage_Core_Helper_Abstract
35
  {
36
  /**
37
- * Checks whether Facebook module is enabled for frontend in system config
38
- *
39
- * @return bool
40
- */
41
  public function isEnabled()
42
  {
 
 
 
 
 
 
 
43
  return Mage::getStoreConfigFlag(Social_Facebook_Model_Facebook::XML_PATH_ENABLED);
44
  }
45
 
46
  /**
47
- * Get Facebook App Id
48
- *
49
- * @return string
50
- */
51
  public function getAppId()
52
  {
53
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_ID);
54
  }
55
 
56
  /**
57
- * Get Facebook App Secret
58
- *
59
- * @return string
60
- */
61
  public function getAppSecret()
62
  {
63
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_SECRET);
64
  }
65
 
66
  /**
67
- * Get Facebook App Name
68
- *
69
- * @return string
70
- */
71
  public function getAppName()
72
  {
73
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_NAME);
74
  }
75
 
76
  /**
77
- * Get Facebook App Name
78
- *
79
- * @return string
80
- */
81
  public function getObjectType()
82
  {
83
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_OBJECT_TYPE);
84
  }
85
 
86
  /**
87
- * Get Facebook App Name
88
- *
89
- * @return string
90
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  public function getAllActions()
92
  {
 
 
 
 
 
 
93
  $actions = Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_ACTIONS);
94
  $actions = unserialize($actions);
95
  return $actions;
96
  }
97
 
98
  /**
99
- * Get Facebook App Friend Count in FriendBox
100
- *
101
- * @param string $action
102
- * @return string
103
- */
104
  public function getAppFriendCount($action)
105
  {
106
  $count = 0;
@@ -113,6 +150,7 @@ class Social_Facebook_Helper_Data extends Mage_Core_Helper_Abstract
113
  }
114
  }
115
  }
 
116
  if (empty($count)) {
117
  $count = Social_Facebook_Model_Facebook::XML_PATH_APP_USER_COUNT;
118
  }
@@ -120,11 +158,11 @@ class Social_Facebook_Helper_Data extends Mage_Core_Helper_Abstract
120
  }
121
 
122
  /**
123
- * Get Redirect Url fo Facebook Authorization
124
- *
125
- * @param Mage_Catalog_Model_Product $product
126
- * @return string
127
- */
128
  public function getRedirectUrl($product)
129
  {
130
  return Social_Facebook_Model_Api::URL_GRAPH_DIALOG_OAUTH
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
34
  class Social_Facebook_Helper_Data extends Mage_Core_Helper_Abstract
35
  {
36
  /**
37
+ * Checks whether Facebook module is enabled for frontend in system config
38
+ *
39
+ * @return bool
40
+ */
41
  public function isEnabled()
42
  {
43
+ if (!class_exists('Xcom')) {
44
+ Mage::throwException(
45
+ Mage::helper('social_facebook')->__('The xcommerce extension wasn\'t loaded,
46
+ please install and enable the X.commerce PHP5 extension'));
47
+ return false;
48
+ }
49
+
50
  return Mage::getStoreConfigFlag(Social_Facebook_Model_Facebook::XML_PATH_ENABLED);
51
  }
52
 
53
  /**
54
+ * Get Facebook App Id
55
+ *
56
+ * @return string
57
+ */
58
  public function getAppId()
59
  {
60
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_ID);
61
  }
62
 
63
  /**
64
+ * Get Facebook App Secret
65
+ *
66
+ * @return string
67
+ */
68
  public function getAppSecret()
69
  {
70
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_SECRET);
71
  }
72
 
73
  /**
74
+ * Get Facebook App Name
75
+ *
76
+ * @return string
77
+ */
78
  public function getAppName()
79
  {
80
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_NAME);
81
  }
82
 
83
  /**
84
+ * Get Facebook Object Type (usually product)
85
+ *
86
+ * @return string
87
+ */
88
  public function getObjectType()
89
  {
90
  return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_OBJECT_TYPE);
91
  }
92
 
93
  /**
94
+ * Get XFabric URL
95
+ *
96
+ * @return string
97
+ */
98
+ public function getXcomFabricURL($sync=false)
99
+ {
100
+ if ($sync) {
101
+ return str_replace('/fabric', '/xbridge/invoke',
102
+ Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_FABRIC_URL));
103
+ }
104
+ return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_FABRIC_URL);
105
+ }
106
+
107
+ /**
108
+ * Get the capability token
109
+ *
110
+ * @return string
111
+ */
112
+ public function getXcomCapToken()
113
+ {
114
+ return Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_CAP_TOKEN);
115
+ }
116
+
117
+ /**
118
+ * Get Facebook Actions
119
+ *
120
+ * @return string
121
+ */
122
  public function getAllActions()
123
  {
124
+ static $actions = NULL;
125
+
126
+ if($actions) {
127
+ return $actions;
128
+ }
129
+
130
  $actions = Mage::getStoreConfig(Social_Facebook_Model_Facebook::XML_PATH_APP_ACTIONS);
131
  $actions = unserialize($actions);
132
  return $actions;
133
  }
134
 
135
  /**
136
+ * Get Facebook App Friend Count in FriendBox
137
+ *
138
+ * @param string $action
139
+ * @return string
140
+ */
141
  public function getAppFriendCount($action)
142
  {
143
  $count = 0;
150
  }
151
  }
152
  }
153
+
154
  if (empty($count)) {
155
  $count = Social_Facebook_Model_Facebook::XML_PATH_APP_USER_COUNT;
156
  }
158
  }
159
 
160
  /**
161
+ * Get Redirect Url fo Facebook Authorization
162
+ *
163
+ * @param Mage_Catalog_Model_Product $product
164
+ * @return string
165
+ */
166
  public function getRedirectUrl($product)
167
  {
168
  return Social_Facebook_Model_Api::URL_GRAPH_DIALOG_OAUTH
app/code/community/Social/Facebook/Model/Api.php CHANGED
@@ -20,29 +20,29 @@
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
27
- /**
28
- * Facebook model
29
- *
30
- * @category Social
31
- * @package Social_Facebook
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
  class Social_Facebook_Model_Api extends Varien_Object
35
  {
36
  const URL_GRAPH_DIALOG_OAUTH = 'http://www.facebook.com/dialog/oauth';
37
  const URL_GRAPH_OAUTH_ACCESS_TOKEN = 'https://graph.facebook.com/oauth/access_token';
38
  const URL_GRAPH_FACEBOOK_ABOUT_ME = 'https://graph.facebook.com/me/';
39
  const URL_GRAPH_FACEBOOK_ME_FRIENDS = 'https://graph.facebook.com/me/friends';
 
 
 
40
 
41
  protected $_accessToken = false;
42
  protected $_productUrl = false;
43
  protected $_facebookCode = false;
44
  protected $_facebookAction = false;
45
  protected $_productOgUrl = false;
 
 
 
 
46
 
47
 
48
  /**
@@ -105,6 +105,90 @@ class Social_Facebook_Model_Api extends Varien_Object
105
  return $this;
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  /**
109
  * Make Request To Facebook
110
  *
@@ -112,7 +196,7 @@ class Social_Facebook_Model_Api extends Varien_Object
112
  * @param string $uri
113
  * @param string $method
114
  * @throws Mage_Core_Exception
115
- * @return Zend_Http_Response
116
  */
117
  public function makeFacebookRequest($params, $uri, $method)
118
  {
@@ -128,22 +212,37 @@ class Social_Facebook_Model_Api extends Varien_Object
128
  $client->setMethod($method);
129
 
130
  $response = $client->request();
131
- $result = json_decode($response->getBody());
 
 
 
 
 
132
  } catch (Exception $e) {
133
  Mage::throwException(Mage::helper('social_facebook')->__('Facebook Request API Error'));
134
  }
135
 
136
  if (!empty($result) && (!empty($result->error) || !empty($result->error->message))) {
 
 
 
 
 
 
 
 
 
 
137
  Mage::throwException(Mage::helper('social_facebook')->__('Facebook error: ') . $result->error->message);
138
  }
139
 
140
- return $client->request();
141
  }
142
 
143
  /**
144
  * Get Access Token
145
  *
146
- * @return mixed
147
  */
148
  public function getAccessToken()
149
  {
@@ -151,7 +250,11 @@ class Social_Facebook_Model_Api extends Varien_Object
151
  return false;
152
  }
153
 
154
- $response = $this->makeFacebookRequest(
 
 
 
 
155
  array(
156
  'client_id' => Mage::helper('social_facebook')->getAppId(),
157
  'redirect_uri' => $this->_productUrl,
@@ -162,9 +265,13 @@ class Social_Facebook_Model_Api extends Varien_Object
162
  Zend_Http_Client::GET
163
  );
164
 
165
- // remove the @expires
166
  $params = null;
167
- parse_str($response->getBody(), $params);
 
 
 
 
 
168
  $this->_accessToken = $params['access_token'];
169
 
170
  return $this->_accessToken;
@@ -173,10 +280,16 @@ class Social_Facebook_Model_Api extends Varien_Object
173
  /**
174
  * Get Facebook User
175
  *
176
- * @return mixed
177
  */
178
  public function getFacebookUser()
179
  {
 
 
 
 
 
 
180
  if (empty($this->_accessToken)) {
181
  $this->getAccessToken();
182
  }
@@ -185,24 +298,26 @@ class Social_Facebook_Model_Api extends Varien_Object
185
  return false;
186
  }
187
 
188
- $response = $this->makeFacebookRequest(
189
  array('access_token' => $this->_accessToken),
190
  Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ABOUT_ME,
191
  Zend_Http_Client::GET
192
  );
193
 
194
- $result = json_decode($response->getBody());
195
-
196
- return array(
197
  'facebook_id' => $result->id,
198
  'facebook_name' => $result->name
199
  );
 
 
 
 
200
  }
201
 
202
  /**
203
  * Send Facebook Action
204
  *
205
- * @return mixed
206
  */
207
  public function sendFacebookAction()
208
  {
@@ -217,22 +332,27 @@ class Social_Facebook_Model_Api extends Varien_Object
217
  return false;
218
  }
219
 
220
- $response = $this->makeFacebookRequest(
221
- array(
222
- 'access_token' => $this->_accessToken,
223
- $objectType => $this->_productOgUrl
224
- ),
225
- Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ABOUT_ME . $appName . ':' . $this->_facebookAction,
226
  Zend_Http_Client::POST
227
  );
228
 
229
- return json_decode($response->getBody());
 
 
 
 
 
 
230
  }
231
 
232
  /**
233
  * Get Facebook Friends
234
  *
235
- * @return mixed
236
  */
237
  public function getFacebookFriends()
238
  {
@@ -244,12 +364,92 @@ class Social_Facebook_Model_Api extends Varien_Object
244
  return false;
245
  }
246
 
247
- $response = $this->makeFacebookRequest(
248
  array('access_token' => $this->_accessToken),
249
  Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ME_FRIENDS,
250
  Zend_Http_Client::GET
251
  );
252
 
253
- return json_decode($response->getBody());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
  }
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
 
 
 
 
 
 
 
27
  class Social_Facebook_Model_Api extends Varien_Object
28
  {
29
  const URL_GRAPH_DIALOG_OAUTH = 'http://www.facebook.com/dialog/oauth';
30
  const URL_GRAPH_OAUTH_ACCESS_TOKEN = 'https://graph.facebook.com/oauth/access_token';
31
  const URL_GRAPH_FACEBOOK_ABOUT_ME = 'https://graph.facebook.com/me/';
32
  const URL_GRAPH_FACEBOOK_ME_FRIENDS = 'https://graph.facebook.com/me/friends';
33
+ const URL_GRAPH_FACEBOOK_OBJECT_ID = 'https://graph.facebook.com/';
34
+ const FB_ERR_ACTION_EXISTS = 3501;
35
+ const HTTP_OK = 200;
36
 
37
  protected $_accessToken = false;
38
  protected $_productUrl = false;
39
  protected $_facebookCode = false;
40
  protected $_facebookAction = false;
41
  protected $_productOgUrl = false;
42
+ protected $_socialData = false;
43
+ private $_Xcom = false;
44
+ private $_XcomSync = false;
45
+ private $_social_data = NULL;
46
 
47
 
48
  /**
105
  return $this;
106
  }
107
 
108
+ /**
109
+ * Get the local schema location
110
+ *
111
+ * @param string $schema
112
+ * @return string
113
+ */
114
+ public function getSchemaLocation($schema)
115
+ {
116
+ return Mage::getModuleDir('etc', 'Social_Facebook') . '/' . $schema;
117
+ }
118
+
119
+ /**
120
+ * send message to Xfabric
121
+ *
122
+ * @param object $params
123
+ * @throws Mage_Core_Exception
124
+ * @return int
125
+ */
126
+ public function makeXcomRequest($topic, $object, $schemaFile, $sync=false, $debug=false)
127
+ {
128
+ $httpCode = 0;
129
+ $xcom = NULL;
130
+ try {
131
+ if (!$sync) {
132
+ $xcom = $this->getXcom();
133
+ } else {
134
+ $xcom = $this->getXcomSync();
135
+ }
136
+
137
+ if ($debug) {
138
+ $xcom->__debug = true;
139
+ }
140
+
141
+ $fileLocation = $this->getSchemaLocation($schemaFile);
142
+
143
+ if (!is_readable($fileLocation)) {
144
+ Mage::throwException(Mage::helper('social_facebook')->__('Unable to load schema file: %s'),
145
+ $fileLocation);
146
+ }
147
+
148
+ $httpCode = $xcom->send($topic, $object, file_get_contents($fileLocation), '1.0');
149
+ } catch (Exception $e) {
150
+ Mage::logException($e);
151
+ }
152
+
153
+ if ($httpCode!=self::HTTP_OK) {
154
+ try {
155
+ Mage::throwException(Mage::helper('social_facebook')->__( 'Error sending message to fabric, HTTP CODE: %s', $httpCode));
156
+ } catch(Exception $e) {
157
+ Mage::logException($e);
158
+ }
159
+ }
160
+
161
+ return $httpCode;
162
+ }
163
+
164
+ /**
165
+ * Get a sync instance of Xcom
166
+ *
167
+ * @return Xcom
168
+ */
169
+ public function getXcomSync()
170
+ {
171
+ if (empty($this->_XcomSync)) {
172
+ $this->_XcomSync = new Xcom(Mage::helper('social_facebook')->getXcomFabricURL(true), '',
173
+ Mage::helper('social_facebook')->getXcomCapToken());
174
+ }
175
+ return $this->_XcomSync;
176
+ }
177
+
178
+ /**
179
+ * Get an async instance of Xcom
180
+ *
181
+ * @return Xcom
182
+ */
183
+ public function getXcom()
184
+ {
185
+ if (empty($this->_Xcom)) {
186
+ $this->_Xcom = new Xcom(Mage::helper('social_facebook')->getXcomFabricURL(), '',
187
+ Mage::helper('social_facebook')->getXcomCapToken());
188
+ }
189
+ return $this->_Xcom;
190
+ }
191
+
192
  /**
193
  * Make Request To Facebook
194
  *
196
  * @param string $uri
197
  * @param string $method
198
  * @throws Mage_Core_Exception
199
+ * @return array | string
200
  */
201
  public function makeFacebookRequest($params, $uri, $method)
202
  {
212
  $client->setMethod($method);
213
 
214
  $response = $client->request();
215
+ try {
216
+ $result = Mage::helper('core')->jsonDecode($response->getBody(), Zend_Json::TYPE_OBJECT);
217
+ } catch(Zend_Json_Exception $e) {
218
+ /* failed to decode, that's fine, we'll pass through */
219
+ $result = $response->getBody();
220
+ }
221
  } catch (Exception $e) {
222
  Mage::throwException(Mage::helper('social_facebook')->__('Facebook Request API Error'));
223
  }
224
 
225
  if (!empty($result) && (!empty($result->error) || !empty($result->error->message))) {
226
+ if($result->error->code==self::FB_ERR_ACTION_EXISTS) {
227
+ /*
228
+ * user already associated with this action/product
229
+ */
230
+ $matches = array();
231
+ preg_match('/Original Action ID: (\d+)/i', $result->error->message, $matches);
232
+ if (!empty($matches)) {
233
+ return $matches[1];
234
+ }
235
+ }
236
  Mage::throwException(Mage::helper('social_facebook')->__('Facebook error: ') . $result->error->message);
237
  }
238
 
239
+ return array($response, $result);
240
  }
241
 
242
  /**
243
  * Get Access Token
244
  *
245
+ * @return string | false
246
  */
247
  public function getAccessToken()
248
  {
250
  return false;
251
  }
252
 
253
+ if (!empty($this->_accessToken)) {
254
+ return $this->_accessToken;
255
+ }
256
+
257
+ $result = $this->makeFacebookRequest(
258
  array(
259
  'client_id' => Mage::helper('social_facebook')->getAppId(),
260
  'redirect_uri' => $this->_productUrl,
265
  Zend_Http_Client::GET
266
  );
267
 
 
268
  $params = null;
269
+ parse_str($result[1], $params);
270
+
271
+ if (empty($params['access_token'])) {
272
+ return false;
273
+ }
274
+
275
  $this->_accessToken = $params['access_token'];
276
 
277
  return $this->_accessToken;
280
  /**
281
  * Get Facebook User
282
  *
283
+ * @return array | false
284
  */
285
  public function getFacebookUser()
286
  {
287
+ $_authInfo = Mage::getSingleton('social_facebook/facebook')->getFacebookAuthInfo();
288
+
289
+ if(!empty($_authInfo)) {
290
+ return $_authInfo;
291
+ }
292
+
293
  if (empty($this->_accessToken)) {
294
  $this->getAccessToken();
295
  }
298
  return false;
299
  }
300
 
301
+ list($response, $result) = $this->makeFacebookRequest(
302
  array('access_token' => $this->_accessToken),
303
  Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ABOUT_ME,
304
  Zend_Http_Client::GET
305
  );
306
 
307
+ $_authInfo = array(
 
 
308
  'facebook_id' => $result->id,
309
  'facebook_name' => $result->name
310
  );
311
+
312
+ Mage::getSingleton('social_facebook/facebook')->setFacebookAuthInfo($_authInfo);
313
+
314
+ return $_authInfo;
315
  }
316
 
317
  /**
318
  * Send Facebook Action
319
  *
320
+ * @return array | false
321
  */
322
  public function sendFacebookAction()
323
  {
332
  return false;
333
  }
334
 
335
+ list($response, $result) = $this->makeFacebookRequest(
336
+ array(),
337
+ Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ABOUT_ME . $appName . ':' . $this->_facebookAction
338
+ . '?access_token=' . urlencode($this->_accessToken)
339
+ . "&$objectType=". urlencode($this->_productOgUrl),
 
340
  Zend_Http_Client::POST
341
  );
342
 
343
+ if (!is_object($response)) {
344
+ $action = new stdClass();
345
+ $action->id = $response;
346
+ return $action;
347
+ }
348
+
349
+ return $result;
350
  }
351
 
352
  /**
353
  * Get Facebook Friends
354
  *
355
+ * @return array | false
356
  */
357
  public function getFacebookFriends()
358
  {
364
  return false;
365
  }
366
 
367
+ list($response, $result) = $this->makeFacebookRequest(
368
  array('access_token' => $this->_accessToken),
369
  Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ME_FRIENDS,
370
  Zend_Http_Client::GET
371
  );
372
 
373
+ return $result;
374
+ }
375
+
376
+ /**
377
+ * Set Social Data
378
+ *
379
+ * @return void
380
+ */
381
+ public function setSocialData($json)
382
+ {
383
+ $this->_socialData = $json;
384
+ }
385
+
386
+ /**
387
+ * Get Social Data
388
+ *
389
+ * @return stdClass
390
+ */
391
+ public function getSocialData()
392
+ {
393
+ return $this->_socialData;
394
+ }
395
+
396
+ /**
397
+ * Fetch Social Data
398
+ *
399
+ * @return stdClass | false
400
+ */
401
+ public function fetchSocialData($productData, $categoryData) {
402
+ $dataObj = new stdClass();
403
+
404
+ $schema = 'social.events.product.fetch.json';
405
+
406
+ $data = array('actions' => Mage::helper('social_facebook')->getAllActions(),
407
+ 'url' => Mage::app()->getStore()->getCurrentUrl(false));
408
+
409
+ $facebookModel = Mage::getSingleton('social_facebook/facebook');
410
+ $session = Mage::getSingleton('core/session');
411
+ $accessToken = $session->getData('access_token');
412
+
413
+ if (!empty($accessToken)) {
414
+ $user = $facebookModel->getFacebookUser();
415
+ if (!empty($user["facebook_id"])) {
416
+ $data['fb_uid'] = $user["facebook_id"];
417
+ $data['friends'] = $facebookModel->getFriendsForUser($user["facebook_id"]);
418
+ }
419
+ }
420
+
421
+ $data['actions'] = array();
422
+
423
+ $actions = Mage::helper('social_facebook')->getAllActions();
424
+
425
+ if (empty($actions)) {
426
+ Mage::throwException(Mage::helper('social_facebook')->__('[error] no social commerce
427
+ actions have been setup, please setup some actions in the Social Commerce
428
+ configuration'));
429
+ }
430
+
431
+ foreach ($actions as $action) {
432
+ $data['actions'][$action['action']] = array('info' => $action,
433
+ 'limit' => Mage::helper('social_facebook')->getAppFriendCount($action['action']));
434
+ }
435
+
436
+ $data['product_info'] = array('product' => $productData, 'category' => $categoryData);
437
+
438
+ $dataObj->social = Mage::helper('core')->jsonEncode($data);
439
+
440
+ $this->makeXcomRequest('/social/events/product/fetch', $dataObj, $schema, true);
441
+
442
+ $response = $this->getXcomSync()->decode($this->getXcomSync()->getLastResponse(),
443
+ file_get_contents($this->getSchemaLocation($schema)));
444
+
445
+ $json = Mage::helper('core')->jsonDecode($response->social, Zend_Json::TYPE_OBJECT);
446
+
447
+ if (empty($json)) {
448
+ return false;
449
+ }
450
+
451
+ $this->setSocialData($json);
452
+
453
+ return $json;
454
  }
455
  }
app/code/community/Social/Facebook/Model/Facebook.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -44,6 +44,15 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
44
  const XML_PATH_APP_OBJECT_TYPE = 'facebook/config/otype';
45
  const XML_PATH_APP_USER_COUNT = 3;
46
  const XML_PATH_APP_ACTIONS = 'facebook/config/action';
 
 
 
 
 
 
 
 
 
47
 
48
  protected $_accessToken = false;
49
 
@@ -96,51 +105,53 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
96
  }
97
 
98
  /**
99
- * Cache Friends From Facebook
100
  *
101
- * @param object $data
102
  * @param string $facebookId
103
- * @return array
104
  */
105
- public function cacheFriends($data, $facebookId)
106
  {
107
- $name = 'social_facebook_' . $facebookId;
108
-
109
- $users = Mage::app()->loadCache($name);
110
-
111
- if (empty($users)) {
112
- if (empty($data)) {
113
- return false;
114
- }
115
- $users = array();
116
- $users[] = $facebookId;
117
- foreach ($data->data as $user) {
118
- $users[] = $user->id;
119
- }
120
 
121
- Mage::app()->saveCache(serialize($users), $name, array(), 3600);
122
- } else {
123
- $users = unserialize($users);
 
 
 
 
 
 
 
 
124
  }
125
-
126
- return $users;
127
  }
128
 
 
129
  /**
130
- * Get Linked Facebook Friends
131
  *
 
132
  * @param string $facebookId
133
- * @param int $productId
134
- * @param string $action
135
  * @return array
136
  */
137
- public function getLinkedFriends($facebookId, $productId, $action)
138
  {
139
- $friends = $this->cacheFriends(array(), $facebookId);
140
- if (!empty($friends)) {
141
- return $this->_getResource()->getLinkedFriends($friends, $productId, $action);
 
 
 
 
 
142
  }
143
- return array();
 
 
144
  }
145
 
146
  /**
@@ -148,16 +159,23 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
148
  *
149
  * @return Social_Facebook_Model_Api
150
  */
151
- public function getApi()
152
  {
153
- $session = Mage::getSingleton('core/session');
 
154
 
155
- return Mage::getSingleton('social_facebook/api')
156
- ->setProductUrl($session->getData('product_url'))
157
- ->setFacebookAction($session->getData('facebook_action'))
158
- ->setProductOgUrl($session->getData('product_og_url'))
159
- ->setAccessToken($this->_accessToken)
160
- ;
 
 
 
 
 
 
161
  }
162
 
163
  /**
@@ -203,35 +221,34 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
203
  $session->unsetData('access_token');
204
  }
205
 
206
- $facebookCode = Mage::app()->getRequest()->getParam('code');
207
 
208
- if (!empty($facebookCode)) {
209
- $this->_accessToken = $this->getApi()
210
- ->setFacebookCode($facebookCode)
211
  ->getAccessToken()
212
  ;
213
  }
214
  } catch (Mage_Core_Exception $e) {
215
  Mage::getSingleton('core/session')->addError($e->getMessage());
216
- $this->removeSessionApi();
217
  } catch (Exception $e) {
218
  Mage::getSingleton('core/session')->addError(
219
  Mage::helper('social_facebook')->__('Cannot Get Facebook Access Token')
220
  );
221
  Mage::logException($e);
222
- $this->removeSessionApi();
223
  }
224
 
225
  if (!empty($this->_accessToken)) {
226
  $session->setData('access_token', $this->_accessToken);
227
- if (!empty($facebookCode)) {
228
  Mage::app()->getResponse()->setRedirect($productUrl);
229
  Mage::app()->getResponse()->sendResponse();
230
- exit();
231
  }
232
  return $this->_accessToken;
233
  } else {
234
- $this->removeSessionApi();
 
235
  return false;
236
  }
237
  }
@@ -239,25 +256,84 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
239
  /**
240
  * Send Facebook Action
241
  *
242
- * @return mixed
243
  */
244
- public function sendFacebookAction()
245
  {
246
  try {
247
  if (!$this->getAccessToken()) {
248
  return false;
249
  }
250
- $action = $this->getApi()->sendFacebookAction();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  } catch (Mage_Core_Exception $e) {
252
  Mage::getSingleton('core/session')->addError($e->getMessage());
253
- $this->removeSessionApi();
254
  } catch (Exception $e) {
255
  $action = Mage::getSingleton('core/session')->getData('facebook_action');
256
  Mage::getSingleton('core/session')->addError(
257
- Mage::helper('social_facebook')->__('Cannot Make "%s" Action. Please, try later.', $action)
258
  );
259
  Mage::logException($e);
260
- $this->removeSessionApi();
261
  }
262
 
263
  return $action;
@@ -266,9 +342,9 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
266
  /**
267
  * Get Facebook Friends
268
  *
269
- * @return mixed
270
  */
271
- public function getFacebookFriends()
272
  {
273
  try {
274
  if (!$this->getAccessToken()) {
@@ -277,13 +353,13 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
277
  $friends = $this->getApi()->getFacebookFriends();
278
  } catch (Mage_Core_Exception $e) {
279
  Mage::getSingleton('core/session')->addError($e->getMessage());
280
- $this->removeSessionApi();
281
  } catch (Exception $e) {
282
  Mage::getSingleton('core/session')->addError(
283
  Mage::helper('social_facebook')->__('Cannot Get Your Facebook Friends')
284
  );
285
  Mage::logException($e);
286
- $this->removeSessionApi();
287
  }
288
 
289
  return $friends;
@@ -292,7 +368,7 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
292
  /**
293
  * Get Facebook User
294
  *
295
- * @return mixed
296
  */
297
  public function getFacebookUser()
298
  {
@@ -307,15 +383,32 @@ class Social_Facebook_Model_Facebook extends Mage_Core_Model_Abstract
307
  }
308
  } catch (Mage_Core_Exception $e) {
309
  Mage::getSingleton('core/session')->addError($e->getMessage());
310
- $this->removeSessionApi();
311
  } catch (Exception $e) {
312
  Mage::getSingleton('core/session')->addError(
313
  Mage::helper('social_facebook')->__('Cannot Get Facebook User')
314
  );
315
  Mage::logException($e);
316
- $this->removeSessionApi();
317
  }
318
 
319
  return $user;
320
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  }
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
44
  const XML_PATH_APP_OBJECT_TYPE = 'facebook/config/otype';
45
  const XML_PATH_APP_USER_COUNT = 3;
46
  const XML_PATH_APP_ACTIONS = 'facebook/config/action';
47
+ const XML_PATH_FABRIC_URL = 'facebook/config/fabric_url';
48
+ const XML_PATH_CAP_TOKEN = 'facebook/config/cap_token';
49
+ const XML_PATH_TENANT_NAME = 'facebook/config/tenant_name';
50
+ const XML_PATH_RAW_AUTH_JSON = 'facebook/config/raw_json_auth';
51
+ const XML_PATH_REGISTER_BUTTON = 'facebook/config/registration_extension_button';
52
+ const ONBOARDING_URL = '/merchant_onboarding';
53
+ const ONBOARDING_URL_DOMAIN = 'https://devportal.x.com';
54
+ const NEW_EVENT_TOPIC = '/social/events/product/new';
55
+ const NEW_EVENT_SCHEMA = 'social.events.product.new.json';
56
 
57
  protected $_accessToken = false;
58
 
105
  }
106
 
107
  /**
108
+ * Get cache key name
109
  *
 
110
  * @param string $facebookId
111
+ * @return string
112
  */
113
+ protected function getFriendsCacheKey($facebookId)
114
  {
115
+ return 'social_facebook_' . $facebookId;
116
+ }
 
 
 
 
 
 
 
 
 
 
 
117
 
118
+ /**
119
+ * Get friends from cache
120
+ *
121
+ * @param string $facebookId
122
+ * @return array | false
123
+ */
124
+ protected function getFriends($facebookId)
125
+ {
126
+ $users = Mage::app()->loadCache($this->getFriendsCacheKey($facebookId));
127
+ if(empty($users)) {
128
+ return false;
129
  }
130
+ return unserialize($users);
 
131
  }
132
 
133
+
134
  /**
135
+ * Set friend info in cache
136
  *
137
+ * @param object $data
138
  * @param string $facebookId
 
 
139
  * @return array
140
  */
141
+ protected function cacheFriends($data, $facebookId)
142
  {
143
+ if (empty($data)) {
144
+ return false;
145
+ }
146
+
147
+ $users = array();
148
+ $users[] = $facebookId;
149
+ foreach ($data->data as $user) {
150
+ $users[] = $user->id;
151
  }
152
+
153
+ Mage::app()->saveCache(serialize($users), $this->getFriendsCacheKey($facebookId), array(), 3600);
154
+ return $users;
155
  }
156
 
157
  /**
159
  *
160
  * @return Social_Facebook_Model_Api
161
  */
162
+ public function getApi($exchangingToken=false)
163
  {
164
+ $api = Mage::getSingleton('social_facebook/api');
165
+ $apiSession = $api->getSessionApi();
166
 
167
+ if(empty($apiSession)) {
168
+ $session = Mage::getSingleton('core/session');
169
+
170
+ $apiSession = Mage::getSingleton('social_facebook/api')
171
+ ->setProductUrl($session->getData('product_url'))
172
+ ->setFacebookAction($session->getData('facebook_action'))
173
+ ->setProductOgUrl($session->getData('product_og_url'))
174
+ ->setAccessToken($exchangingToken ? '' : $this->getAccessToken());
175
+
176
+ $api->setSessionApi($apiSession);
177
+ }
178
+ return $apiSession;
179
  }
180
 
181
  /**
221
  $session->unsetData('access_token');
222
  }
223
 
224
+ $accessCode = Mage::app()->getRequest()->getParam('code');
225
 
226
+ if (!empty($accessCode)) {
227
+ $this->_accessToken = $this->getApi(true)
228
+ ->setFacebookCode($accessCode)
229
  ->getAccessToken()
230
  ;
231
  }
232
  } catch (Mage_Core_Exception $e) {
233
  Mage::getSingleton('core/session')->addError($e->getMessage());
 
234
  } catch (Exception $e) {
235
  Mage::getSingleton('core/session')->addError(
236
  Mage::helper('social_facebook')->__('Cannot Get Facebook Access Token')
237
  );
238
  Mage::logException($e);
 
239
  }
240
 
241
  if (!empty($this->_accessToken)) {
242
  $session->setData('access_token', $this->_accessToken);
243
+ if (!empty($accessCode)) {
244
  Mage::app()->getResponse()->setRedirect($productUrl);
245
  Mage::app()->getResponse()->sendResponse();
246
+ return false;
247
  }
248
  return $this->_accessToken;
249
  } else {
250
+ $session->unsetData('access_token');
251
+ $session->unsetData('facebook_action');
252
  return false;
253
  }
254
  }
256
  /**
257
  * Send Facebook Action
258
  *
259
+ * @return array | false
260
  */
261
+ public function sendFacebookAction($fbUid, $productId)
262
  {
263
  try {
264
  if (!$this->getAccessToken()) {
265
  return false;
266
  }
267
+
268
+ $action = $this->getApi()->sendFacebookAction();
269
+ $session = Mage::getSingleton('core/session');
270
+
271
+ $product = Mage::getModel('catalog/product')->load($productId);
272
+ $productData = $product->getData();
273
+
274
+ $categories = $product->getCategoryIds();
275
+ $categoryData = array();
276
+
277
+ if (!empty($categories)) {
278
+ foreach ($categories as $categoryId) {
279
+ $category = Mage::getModel('catalog/category')->load($categoryId);
280
+ $categoryData[] = $category->getData();
281
+ }
282
+ }
283
+
284
+ $merchantInfo = Mage::app()->getStore();
285
+
286
+ $merchantData = new stdClass();
287
+ $merchantData->current_url = $merchantInfo->getCurrentUrl();
288
+ $merchantData->current_url_from_store = $merchantInfo->getCurrentUrl(true);
289
+ $merchantData->frontend_name = $merchantInfo->getFrontendName();
290
+ $merchantData->is_active = $merchantInfo->getIsActive();
291
+ $merchantData->website = $merchantInfo->getWebsite();
292
+ $merchantData->is_admin = $merchantInfo->isAdmin();
293
+
294
+ $eventInfo = new stdClass();
295
+ $eventInfo->app_name = Mage::helper('social_facebook')->getAppName();
296
+ $eventInfo->object_type = Mage::helper('social_facebook')->getObjectType();
297
+ $eventInfo->product_url = $session->getData('product_url');
298
+ $eventInfo->action = $session->getData('facebook_action');
299
+ $eventInfo->og_product_url = $session->getData('product_og_url');
300
+ $eventInfo->fb_uid = $session->getData('facebook_id');
301
+ $eventInfo->fb_action_id = $action->id;
302
+
303
+ $productData["product_categories"] = $categoryData;
304
+
305
+ $response = $this->getApi()->makeFacebookRequest(
306
+ array('access_token' => $this->getAccessToken()),
307
+ Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_OBJECT_ID . (string)$action->id, Zend_Http_Client::GET);
308
+
309
+ $actionInfo = $response[1];
310
+
311
+ $response = $this->getApi()->makeFacebookRequest(
312
+ array('access_token' => $this->getAccessToken()),
313
+ Social_Facebook_Model_Api::URL_GRAPH_FACEBOOK_ME_FRIENDS, Zend_Http_Client::GET);
314
+
315
+ $friends = $response[1];
316
+
317
+ $eventInfo->fb_action_info = array('fb' => Mage::helper('core')->jsonEncode($actionInfo),
318
+ 'actions' => Mage::helper('social_facebook')->getAllActions(),
319
+ 'friends' => Mage::helper('core')->jsonEncode($friends));
320
+
321
+ $dataObj = new stdClass();
322
+ $dataObj->product_info = Mage::helper('core')->jsonEncode($productData);
323
+ $dataObj->merchant_info = Mage::helper('core')->jsonEncode($merchantData);
324
+ $dataObj->event_info = Mage::helper('core')->jsonEncode($eventInfo);
325
+
326
+ $this->getApi()->makeXcomRequest(self::NEW_EVENT_TOPIC, $dataObj, self::NEW_EVENT_SCHEMA);
327
  } catch (Mage_Core_Exception $e) {
328
  Mage::getSingleton('core/session')->addError($e->getMessage());
329
+ return false;
330
  } catch (Exception $e) {
331
  $action = Mage::getSingleton('core/session')->getData('facebook_action');
332
  Mage::getSingleton('core/session')->addError(
333
+ Mage::helper('social_facebook')->__('Could not create the "%s" action...can you try again?', $action)
334
  );
335
  Mage::logException($e);
336
+ return false;
337
  }
338
 
339
  return $action;
342
  /**
343
  * Get Facebook Friends
344
  *
345
+ * @return array | false
346
  */
347
+ protected function getFacebookFriends()
348
  {
349
  try {
350
  if (!$this->getAccessToken()) {
353
  $friends = $this->getApi()->getFacebookFriends();
354
  } catch (Mage_Core_Exception $e) {
355
  Mage::getSingleton('core/session')->addError($e->getMessage());
356
+ return false;
357
  } catch (Exception $e) {
358
  Mage::getSingleton('core/session')->addError(
359
  Mage::helper('social_facebook')->__('Cannot Get Your Facebook Friends')
360
  );
361
  Mage::logException($e);
362
+ return false;
363
  }
364
 
365
  return $friends;
368
  /**
369
  * Get Facebook User
370
  *
371
+ * @return array | false
372
  */
373
  public function getFacebookUser()
374
  {
383
  }
384
  } catch (Mage_Core_Exception $e) {
385
  Mage::getSingleton('core/session')->addError($e->getMessage());
386
+ return false;
387
  } catch (Exception $e) {
388
  Mage::getSingleton('core/session')->addError(
389
  Mage::helper('social_facebook')->__('Cannot Get Facebook User')
390
  );
391
  Mage::logException($e);
392
+ return false;
393
  }
394
 
395
  return $user;
396
  }
397
+
398
+ /**
399
+ * Get Facebook Friends
400
+ *
401
+ * @return array
402
+ */
403
+ public function getFriendsForUser($facebookId)
404
+ {
405
+ $users = $this->getFriends($facebookId);
406
+ if (empty($users)) {
407
+ $result = $this->getFacebookFriends();
408
+ if (!empty($result)) {
409
+ return $this->cacheFriends($result, $facebookId);
410
+ }
411
+ }
412
+ return $users;
413
+ }
414
  }
app/code/community/Social/Facebook/Model/Facebuttons.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
app/code/community/Social/Facebook/Model/Mysql4/Facebook.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Enterprise Edition
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Magento Enterprise Edition License
8
- * that is bundled with this package in the file LICENSE_EE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://www.magentocommerce.com/license/enterprise-edition
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Social
22
- * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://www.magentocommerce.com/license/enterprise-edition
25
- */
26
-
27
- /**
28
- * Facebook resource
29
- *
30
- * @category Social
31
- * @package Social_Facebook
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Social_Facebook_Model_Mysql4_Facebook extends Mage_Core_Model_Mysql4_Abstract
35
- {
36
- /**
37
- * Internal constructor
38
- */
39
- protected function _construct()
40
- {
41
- $this->_init('social_facebook/facebook', 'entity_id');
42
- }
43
-
44
- /**
45
- * Get Count of all Users by Action, Product Id
46
- *
47
- * @param int $facebookAction
48
- * @param int $productId
49
- *
50
- * @return int
51
- */
52
- public function getCountByActionProduct($facebookAction, $productId)
53
- {
54
- $read = $this->_getReadAdapter();
55
- $select = $read->select()
56
- ->from(array('main_table' => $this->getMainTable()), array('count(*)'))
57
- ->where('facebook_action = ?', $facebookAction)
58
- ->where('item_id = ?', $productId);
59
-
60
- return $read->fetchOne($select);
61
- }
62
-
63
- /**
64
- * Load User by Action and Facebook Id
65
- *
66
- * @param int $facebookAction
67
- * @param int $facebookId
68
- * @param int $productId
69
- *
70
- * @return Social_Facebook_Model_Facebook
71
- */
72
- public function loadUserByActionId($facebookAction, $facebookId, $productId)
73
- {
74
- $read = $this->_getReadAdapter();
75
- $select = $read->select()
76
- ->from(array('main_table' => $this->getMainTable()), array('*'))
77
- ->where('facebook_id = ?', $facebookId)
78
- ->where('facebook_action = ?', $facebookAction)
79
- ->where('item_id = ?', $productId);
80
-
81
- return $read->fetchRow($select);
82
- }
83
-
84
- /**
85
- * Get Count of all Users by Product Id
86
- *
87
- * @param int $productId
88
- *
89
- * @return int
90
- */
91
- public function getCountByProduct($productId)
92
- {
93
- $actions = Mage::helper('social_facebook')->getAllActions();
94
- $actionArray = array();
95
- foreach ($actions as $action) {
96
- $actionArray[] = $action['action'];
97
- }
98
- $read = $this->_getReadAdapter();
99
- $select = $read->select()
100
- ->from(array('main_table' => $this->getMainTable()), array('count(*)'))
101
- ->where('facebook_action in (?)', $actionArray)
102
- ->where('item_id = ?', $productId);
103
-
104
- return $read->fetchOne($select);
105
- }
106
-
107
- /**
108
- * Get Linked Facebook Friends
109
- *
110
- * @param array $friends
111
- * @param int $productId
112
- * @param string $facebookAction
113
- * @return array
114
- */
115
- public function getLinkedFriends($friends, $productId, $facebookAction)
116
- {
117
- $read = $this->_getReadAdapter();
118
- $select = $read->select()
119
- ->from(array('main_table' => $this->getMainTable()), array('facebook_id', 'facebook_name'))
120
- ->where('facebook_id in (?)', $friends)
121
- ->where('facebook_action = ?', $facebookAction)
122
- ->where('item_id = ?', $productId)
123
- ->order(array('entity_id DESC'))
124
- ->limit(Mage::helper('social_facebook')->getAppFriendCount($facebookAction))
125
- ->group('facebook_id');
126
-
127
- return $read->fetchPairs($select);
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Social/Facebook/Model/Mysql4/Facebook/Collection.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * Magento Enterprise Edition
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Magento Enterprise Edition License
8
- * that is bundled with this package in the file LICENSE_EE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://www.magentocommerce.com/license/enterprise-edition
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Social
22
- * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://www.magentocommerce.com/license/enterprise-edition
25
- */
26
-
27
- /**
28
- * Facebook collection
29
- *
30
- * @category Social
31
- * @package Social_Facebook
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Social_Facebook_Model_Mysql4_Facebook_Collection
35
- extends Mage_Core_Model_Mysql4_Collection_Abstract
36
- {
37
- /**
38
- * Internal constructor
39
- */
40
- protected function _construct()
41
- {
42
- $this->_init('social_facebook/facebook');
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Social/Facebook/Model/Observer.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -52,70 +52,32 @@ class Social_Facebook_Model_Observer
52
 
53
  /** @var $facebookModel Social_Facebook_Model_Facebook */
54
  $facebookModel = Mage::getSingleton('social_facebook/facebook');
 
 
 
55
 
56
  if ($facebookAction) {
57
- $result = $facebookModel->sendFacebookAction();
58
 
59
  if (!empty($result)) {
60
- $session->addSuccess(Mage::helper('social_facebook')->__('I %s this product', $facebookAction));
61
- $session->unsetData('facebook_action');
62
-
63
- $user = $facebookModel->getFacebookUser();
64
- if ($user) {
65
- $facebookUser = $facebookModel->loadUserByActionId($facebookAction, $user['facebook_id'],
66
- $productId);
67
-
68
- if (!$facebookUser) {
69
- $data = array(
70
- 'facebook_id' => $user['facebook_id'],
71
- 'facebook_action' => $facebookAction,
72
- 'facebook_name' => $user['facebook_name'],
73
- 'item_id' => $productId
74
- );
75
-
76
- $facebookModel->setData($data)
77
- ->save();
78
- }
79
- }
80
- Mage::app()->getResponse()->setRedirect($productUrl);
81
- Mage::app()->getResponse()->sendResponse();
82
- exit();
83
  }
84
- }
85
 
86
- if (!isset($facebookId)) {
87
- $user = $facebookModel->getFacebookUser();
88
- if ($user) {
89
- $facebookId = $user['facebook_id'];
90
- }
91
 
 
 
92
  }
 
93
  if (isset($facebookId)) {
94
- $this->_cacheFriends($facebookId);
95
  }
96
 
97
  return $this;
98
  }
99
 
100
- /**
101
- * Cache Facebook Friends
102
- *
103
- * @param int $facebookId
104
- * @return Social_Facebook_Model_Observer
105
- */
106
- protected function _cacheFriends($facebookId)
107
- {
108
- $facebookModel = Mage::getSingleton('social_facebook/facebook');
109
-
110
- $users = $facebookModel->cacheFriends(array(), $facebookId);
111
-
112
- if (empty($users)) {
113
- $result = $facebookModel->getFacebookFriends();
114
- if (!empty($result)) {
115
- $facebookModel->cacheFriends($result, $facebookId);
116
- }
117
- }
118
-
119
- return $this;
120
- }
121
  }
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
52
 
53
  /** @var $facebookModel Social_Facebook_Model_Facebook */
54
  $facebookModel = Mage::getSingleton('social_facebook/facebook');
55
+ $user = $facebookModel->getFacebookUser();
56
+
57
+ $session->setData('facebook_user', $user);
58
 
59
  if ($facebookAction) {
60
+ $result = $facebookModel->sendFacebookAction($user['facebook_id'], $productId);
61
 
62
  if (!empty($result)) {
63
+ $session->addSuccess(Mage::helper('social_facebook')->__('I %s this product!', $facebookAction));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
 
65
 
66
+ Mage::app()->getResponse()->setRedirect($productUrl);
67
+ Mage::app()->getResponse()->sendResponse();
68
+ $session->unsetData('facebook_action');
69
+ exit();
70
+ }
71
 
72
+ if ($user) {
73
+ $facebookId = $user['facebook_id'];
74
  }
75
+
76
  if (isset($facebookId)) {
77
+ $facebookModel->getFriendsForUser($facebookId);
78
  }
79
 
80
  return $this;
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
app/code/community/Social/Facebook/Model/System/Config/Backend/Authorization.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Social
22
+ * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class Social_Facebook_Model_System_Config_Backend_Authorization extends Mage_Core_Model_Config_Data
27
+ {
28
+
29
+ /**
30
+ * Workaround to disable "delete" checkbox near uploaded file
31
+ * @todo going to be removed after adding functionality to revoke authorization data
32
+ *
33
+ * @return bool
34
+ */
35
+ public function getValue()
36
+ {
37
+ return false;
38
+ }
39
+
40
+ /**
41
+ * Take actions to process and save submitted authorization file
42
+ *
43
+ * @return Social_Facebook_Model_System_Config_Backend_Authorization
44
+ */
45
+ protected function _beforeSave()
46
+ {
47
+ if (!isset($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'])) {
48
+ return $this;
49
+ }
50
+
51
+ $tmpPath = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
52
+
53
+ if ($tmpPath && file_exists($tmpPath)) {
54
+ if (!filesize($tmpPath)) {
55
+ Mage::throwException(Mage::helper('xcom_xfabric')->__('XFabric authorization file is empty.'));
56
+ }
57
+
58
+ try {
59
+ $json = file_get_contents($tmpPath);
60
+ $auth = Mage::helper('core')->jsonDecode($json, Zend_Json::TYPE_OBJECT);
61
+ if (empty($auth->authorizations)) {
62
+ Mage::throwException('Invalid authorization file!');
63
+ }
64
+ foreach ($auth->authorizations as $tokenInfo) {
65
+ if (strtolower($tokenInfo->type)!='tenant') {
66
+ continue;
67
+ }
68
+ Mage::getConfig()->saveConfig(Social_Facebook_Model_Facebook::XML_PATH_FABRIC_URL,
69
+ $auth->fabricUrl, 'default', 0);
70
+ Mage::getConfig()->saveConfig(Social_Facebook_Model_Facebook::XML_PATH_CAP_TOKEN,
71
+ $tokenInfo->bearerToken, 'default', 0);
72
+ Mage::getConfig()->saveConfig(Social_Facebook_Model_Facebook::XML_PATH_TENANT_NAME,
73
+ $tokenInfo->tenantName, 'default', 0);
74
+ break;
75
+ }
76
+ Mage::getConfig()->saveConfig(Social_Facebook_Model_Facebook::XML_PATH_RAW_AUTH_JSON, $json, 'default', 0);
77
+ Mage::getConfig()->cleanCache();
78
+ } catch (Mage_Core_Exception $e) {
79
+ Mage::throwException($e->getMessage());
80
+ }
81
+
82
+ unlink($tmpPath);
83
+ }
84
+
85
+ return $this;
86
+ }
87
+ }
app/code/community/Social/Facebook/controllers/IndexController.php CHANGED
@@ -20,7 +20,7 @@
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
@@ -31,7 +31,7 @@ class Social_Facebook_IndexController extends Mage_Core_Controller_Front_Action
31
  */
32
  public function redirectAction()
33
  {
34
- $link = $this->_facebookRedirect();
35
  if (!$link) {
36
  return;
37
  }
@@ -81,7 +81,7 @@ class Social_Facebook_IndexController extends Mage_Core_Controller_Front_Action
81
  }
82
 
83
  /**
84
- * Get Metatags for Facebook
85
  */
86
  public function pageAction()
87
  {
@@ -98,4 +98,68 @@ class Social_Facebook_IndexController extends Mage_Core_Controller_Front_Action
98
  $this->getResponse()->setBody($response);
99
  }
100
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
20
  *
21
  * @category Social
22
  * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
  */
26
 
31
  */
32
  public function redirectAction()
33
  {
34
+ $link = $this->_facebookRedirect();
35
  if (!$link) {
36
  return;
37
  }
81
  }
82
 
83
  /**
84
+ * Get Meta tags for Facebook
85
  */
86
  public function pageAction()
87
  {
98
  $this->getResponse()->setBody($response);
99
  }
100
  }
101
+
102
+ /**
103
+ * get JSON for product/social info
104
+ */
105
+ public function widgetAction()
106
+ {
107
+ if (!Mage::helper('social_facebook')->isEnabled()) {
108
+ return;
109
+ }
110
+
111
+ if (!extension_loaded('xcommerce')) {
112
+ $this->getResponse()->setBody(Mage::helper('social_facebook')->__("
113
+ <strong>[error]</strong> you've enabled the Social Commerce extension
114
+ but haven't setup the xcommerce PHP extension yet,
115
+ you can download it at http://pecl.php.net/xcommerce"));
116
+ return;
117
+ }
118
+
119
+ if (!Mage::helper('social_facebook')->getXcomFabricURL()) {
120
+ $this->getResponse()->setBody(Mage::helper('social_facebook')->__("
121
+ <strong>[error]</strong> you've enabled the Social Commerce extension
122
+ but haven't uploaded a valid X.commerce authorization file yet!"));
123
+ return;
124
+ }
125
+
126
+ $productId = (int)$this->getRequest()->getParam('id');
127
+
128
+ if ($productId) {
129
+ $product = Mage::getModel('catalog/product')->load($productId);
130
+ if ($product->getId()) {
131
+ Mage::register('product', $product);
132
+ }
133
+ $product = Mage::getModel('catalog/product')->load($productId);
134
+ $productData = $product->getData();
135
+
136
+ $categories = $product->getCategoryIds();
137
+ $categoryData = array();
138
+
139
+ if (!empty($categories)) {
140
+ foreach ($categories as $categoryId) {
141
+ $category = Mage::getModel('catalog/category')->load($categoryId);
142
+ $categoryData[] = $category->getData();
143
+ }
144
+ }
145
+ } else {
146
+ return;
147
+ }
148
+
149
+ $api = Mage::getSingleton('social_facebook/api');
150
+
151
+ try {
152
+ $api->fetchSocialData($productData, $categoryData);
153
+ $this->loadLayout();
154
+
155
+ $block = $this->getLayout()->createBlock('social_facebook/socialdata');
156
+
157
+ if (!empty($block)) {
158
+ $response = $block->toHtml();
159
+ $this->getResponse()->setBody($response);
160
+ }
161
+ } catch(Exception $e) {
162
+ $this->getResponse()->setBody($e->getMessage());
163
+ }
164
+ }
165
  }
app/code/community/Social/Facebook/etc/adminhtml.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Social
23
+ * @package Social_Facebook
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <acl>
30
+ <resources>
31
+ <admin>
32
+ <children>
33
+ <system>
34
+ <children>
35
+ <config>
36
+ <children>
37
+ <facebook module="social_facebook" translate="title">
38
+ <title>Social Commerce</title>
39
+ <sort_order>75</sort_order>
40
+ </facebook>
41
+ </children>
42
+ </config>
43
+ </children>
44
+ </system>
45
+ </children>
46
+ </admin>
47
+ </resources>
48
+ </acl>
49
+ </config>
app/code/community/Social/Facebook/etc/config.xml CHANGED
@@ -28,44 +28,25 @@
28
  <config>
29
  <modules>
30
  <Social_Facebook>
31
- <version>1.4.0.1</version>
32
  </Social_Facebook>
33
  </modules>
34
  <global>
35
  <models>
36
  <social_facebook>
37
  <class>Social_Facebook_Model</class>
38
- <resourceModel>social_facebook_mysql4</resourceModel>
39
  </social_facebook>
40
- <social_facebook_mysql4>
41
- <class>Social_Facebook_Model_Mysql4</class>
42
  <entities>
43
  <facebook>
44
  <table>social_facebook_actions</table>
45
  </facebook>
46
  </entities>
47
- </social_facebook_mysql4>
48
  </models>
49
- <resources>
50
- <social_facebook_setup>
51
- <setup>
52
- <module>Social_Facebook</module>
53
- </setup>
54
- <connection>
55
- <use>core_setup</use>
56
- </connection>
57
- </social_facebook_setup>
58
- <social_facebook_write>
59
- <connection>
60
- <use>core_write</use>
61
- </connection>
62
- </social_facebook_write>
63
- <social_facebook_read>
64
- <connection>
65
- <use>core_read</use>
66
- </connection>
67
- </social_facebook_read>
68
- </resources>
69
  <blocks>
70
  <social_facebook>
71
  <class>Social_Facebook_Block</class>
@@ -96,26 +77,6 @@
96
  </social_facebook>
97
  </updates>
98
  </layout>
99
- <acl>
100
- <resources>
101
- <admin>
102
- <children>
103
- <system>
104
- <children>
105
- <config>
106
- <children>
107
- <facebook module="social_facebook" translate="title">
108
- <title>Facebook Section</title>
109
- <sort_order>75</sort_order>
110
- </facebook>yo
111
- </children>
112
- </config>
113
- </children>
114
- </system>
115
- </children>
116
- </admin>
117
- </resources>
118
- </acl>
119
  </adminhtml>
120
  <frontend>
121
  <layout>
@@ -154,4 +115,11 @@
154
  </controller_action_predispatch_catalog_product_view>
155
  </events>
156
  </frontend>
 
 
 
 
 
 
 
157
  </config>
28
  <config>
29
  <modules>
30
  <Social_Facebook>
31
+ <version>1.6.0.1</version>
32
  </Social_Facebook>
33
  </modules>
34
  <global>
35
  <models>
36
  <social_facebook>
37
  <class>Social_Facebook_Model</class>
38
+ <resourceModel>social_facebook_resource</resourceModel>
39
  </social_facebook>
40
+ <social_facebook_resource>
41
+ <class>Social_Facebook_Model_Resource</class>
42
  <entities>
43
  <facebook>
44
  <table>social_facebook_actions</table>
45
  </facebook>
46
  </entities>
47
+ </social_facebook_resource>
48
  </models>
49
+ <resources />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  <blocks>
51
  <social_facebook>
52
  <class>Social_Facebook_Block</class>
77
  </social_facebook>
78
  </updates>
79
  </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  </adminhtml>
81
  <frontend>
82
  <layout>
115
  </controller_action_predispatch_catalog_product_view>
116
  </events>
117
  </frontend>
118
+ <default>
119
+ <facebook>
120
+ <config>
121
+ <otype>product</otype>
122
+ </config>
123
+ </facebook>
124
+ </default>
125
  </config>
app/code/community/Social/Facebook/etc/social.events.product.fetch.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type" : "record",
3
+ "name" : "GetSocialEventsForProduct",
4
+ "fields" : [ {
5
+ "name" : "social",
6
+ "type" : "string"
7
+ }
8
+ ],
9
+ "topic" : "/social/events/product/fetch",
10
+ "version" : "1.0.0"
11
+ }
app/code/community/Social/Facebook/etc/social.events.product.fetchSucceeded.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type" : "record",
3
+ "name" : "GetSocialEventsForProductSuccess",
4
+ "fields" : [ {
5
+ "name" : "social",
6
+ "type" : "string"
7
+ }
8
+ ],
9
+ "topic" : "/social/events/product/fetchSucceeded",
10
+ "version" : "1.0.0"
11
+ }
app/code/community/Social/Facebook/etc/social.events.product.new.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type" : "record",
3
+ "name" : "CreateSocialEventForProduct",
4
+ "fields" : [ {
5
+ "name" : "product_info",
6
+ "type" : "string"
7
+ },
8
+ {
9
+ "name" : "merchant_info",
10
+ "type" : "string"
11
+ },
12
+ {
13
+ "name" : "event_info",
14
+ "type" : "string"
15
+ }
16
+ ],
17
+ "topic" : "/social/events/product/new",
18
+ "version" : "1.0.0"
19
+ }
app/code/community/Social/Facebook/etc/system.tenant.relationship.created.json ADDED
@@ -0,0 +1 @@
 
1
+ {"type":"record","name":"TenantRelationshipCreated", "version":"1.0.0", "topic":"/system/tenant/relationship/created","namespace":"com.x.infra.xfabric.manager.message","fields":[{"name":"tenantPseudonym","type":"string"},{"name":"bearerToken","type":"string"},{"name":"tenantName","type":"string"},{"name":"onboarding","type":{"values":"string","type":"map"}}]}
app/code/community/Social/Facebook/etc/system.xml CHANGED
@@ -28,21 +28,21 @@
28
  <config>
29
  <tabs>
30
  <social translate="label" module="social_facebook">
31
- <label>Social</label>
32
  <sort_order>300</sort_order>
33
  </social>
34
  </tabs>
35
  <sections>
36
- <facebook translate="label" module="social_facebook">
37
- <label>Facebook</label>
38
  <tab>social</tab>
39
  <sort_order>100</sort_order>
40
  <show_in_default>1</show_in_default>
41
  <show_in_website>1</show_in_website>
42
  <show_in_store>1</show_in_store>
43
- <groups>
44
- <config translate="label">
45
- <label>Facebook Config</label>
46
  <frontend_type>text</frontend_type>
47
  <sort_order>10</sort_order>
48
  <show_in_default>1</show_in_default>
@@ -59,37 +59,64 @@
59
  <show_in_store>0</show_in_store>
60
  </enabled>
61
  <name translate="label" module="social_facebook">
62
- <label>App Namespace</label>
63
  <frontend_type>text</frontend_type>
64
  <sort_order>30</sort_order>
65
  <show_in_default>1</show_in_default>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>0</show_in_store>
 
 
68
  </name>
69
  <id translate="label" module="social_facebook">
70
- <label>App ID</label>
71
  <frontend_type>text</frontend_type>
72
  <sort_order>40</sort_order>
73
  <show_in_default>1</show_in_default>
74
  <show_in_website>1</show_in_website>
75
  <show_in_store>0</show_in_store>
 
76
  </id>
77
  <secret translate="label" module="social_facebook">
78
- <label>App Secret</label>
79
  <frontend_type>text</frontend_type>
80
  <sort_order>50</sort_order>
81
  <show_in_default>1</show_in_default>
82
  <show_in_website>1</show_in_website>
83
  <show_in_store>0</show_in_store>
 
84
  </secret>
85
  <otype translate="label" module="social_facebook">
86
- <label>Object Type</label>
87
  <frontend_type>text</frontend_type>
88
  <sort_order>60</sort_order>
89
  <show_in_default>1</show_in_default>
90
  <show_in_website>1</show_in_website>
91
  <show_in_store>0</show_in_store>
 
 
92
  </otype>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  <action translate="comment">
94
  <label>Actions Settings</label>
95
  <frontend_model>social_facebook/adminhtml_facebuttons</frontend_model>
@@ -98,11 +125,47 @@
98
  <show_in_default>1</show_in_default>
99
  <show_in_website>1</show_in_website>
100
  <show_in_store>1</show_in_store>
101
- <comment>Add Actions that You Want.</comment>
102
  </action>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  </fields>
104
  </config>
105
  </groups>
106
  </facebook>
107
  </sections>
 
 
 
 
 
 
 
108
  </config>
28
  <config>
29
  <tabs>
30
  <social translate="label" module="social_facebook">
31
+ <label>Social Commerce</label>
32
  <sort_order>300</sort_order>
33
  </social>
34
  </tabs>
35
  <sections>
36
+ <facebook translate="label" module="social_facebook">
37
+ <label>X.commerce &amp; Facebook</label>
38
  <tab>social</tab>
39
  <sort_order>100</sort_order>
40
  <show_in_default>1</show_in_default>
41
  <show_in_website>1</show_in_website>
42
  <show_in_store>1</show_in_store>
43
+ <groups>
44
+ <config translate="label">
45
+ <label>Social Commerce Settings (for X.commerce and Facebook)</label>
46
  <frontend_type>text</frontend_type>
47
  <sort_order>10</sort_order>
48
  <show_in_default>1</show_in_default>
59
  <show_in_store>0</show_in_store>
60
  </enabled>
61
  <name translate="label" module="social_facebook">
62
+ <label>Facebook App Namespace</label>
63
  <frontend_type>text</frontend_type>
64
  <sort_order>30</sort_order>
65
  <show_in_default>1</show_in_default>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>0</show_in_store>
68
+ <validate>required-entry</validate>
69
+ <comment>Register your Open Graph application at https://developers.facebook.com/</comment>
70
  </name>
71
  <id translate="label" module="social_facebook">
72
+ <label>Facebook App ID</label>
73
  <frontend_type>text</frontend_type>
74
  <sort_order>40</sort_order>
75
  <show_in_default>1</show_in_default>
76
  <show_in_website>1</show_in_website>
77
  <show_in_store>0</show_in_store>
78
+ <validate>required-entry validate-digits</validate>
79
  </id>
80
  <secret translate="label" module="social_facebook">
81
+ <label>Facebook App Secret</label>
82
  <frontend_type>text</frontend_type>
83
  <sort_order>50</sort_order>
84
  <show_in_default>1</show_in_default>
85
  <show_in_website>1</show_in_website>
86
  <show_in_store>0</show_in_store>
87
+ <validate>required-entry</validate>
88
  </secret>
89
  <otype translate="label" module="social_facebook">
90
+ <label>Facebook Object Type</label>
91
  <frontend_type>text</frontend_type>
92
  <sort_order>60</sort_order>
93
  <show_in_default>1</show_in_default>
94
  <show_in_website>1</show_in_website>
95
  <show_in_store>0</show_in_store>
96
+ <validate>required-entry</validate>
97
+ <comment>Create a 'product' (or equivalent) object and associate the actions you want to it at https://developers.facebook.com/</comment>
98
  </otype>
99
+ <!--<fabric_url translate="label" module="social_facebook">
100
+ <validate>validate-url required-entry</validate>
101
+ <label>X.Commerce Fabric URL</label>
102
+ <frontend_type>text</frontend_type>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>0</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ <comment>
107
+ Sandbox URL: https://api.sandbox.x.com/fabric&lt;br&gt;
108
+ Production URL: https://api.x.com/fabric
109
+ </comment>
110
+ </fabric_url>
111
+ <cap_token translate="label" module="social_facebook">
112
+ <validate>required-entry</validate>
113
+ <label>X.Commerce Capability Token</label>
114
+ <frontend_type>text</frontend_type>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>0</show_in_website>
117
+ <show_in_store>0</show_in_store>
118
+ <required>1</required>
119
+ </cap_token>-->
120
  <action translate="comment">
121
  <label>Actions Settings</label>
122
  <frontend_model>social_facebook/adminhtml_facebuttons</frontend_model>
125
  <show_in_default>1</show_in_default>
126
  <show_in_website>1</show_in_website>
127
  <show_in_store>1</show_in_store>
128
+ <comment>Add the actions that you want. These need to be approved by Facebook (usually within 24 hours) before non-developers of your application can use them.</comment>
129
  </action>
130
+ <auth_file_upload translate="label">
131
+ <frontend_type>file</frontend_type>
132
+ <backend_model>social_facebook/system_config_backend_authorization</backend_model>
133
+ <label>X.commerce Authorization File</label>
134
+ <sort_order>22</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>0</show_in_website>
137
+ <show_in_store>0</show_in_store>
138
+ </auth_file_upload>
139
+ <registration_extension_button traslate="button_label comment">
140
+ <label/>
141
+ <frontend_model>social_facebook/adminhtml_system_form_renderer_config_registerButton</frontend_model>
142
+ <button_label>Generate an X.commerce Authorization File</button_label>
143
+ <sort_order>21</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>0</show_in_website>
146
+ <show_in_store>0</show_in_store>
147
+ <comment><![CDATA[Click the button above to generate an X.Commerce authorization file if you don't have one.]]></comment>
148
+ </registration_extension_button>
149
+ <authorize_extension_button traslate="button_label comment">
150
+ <label/>
151
+ <frontend_model>social_facebook/adminhtml_system_form_renderer_config_authButton</frontend_model>
152
+ <button_label>Authorize the Social Commerce Extension</button_label>
153
+ <sort_order>22</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>0</show_in_website>
156
+ <show_in_store>0</show_in_store>
157
+ <comment><![CDATA[After you upload your authorization file from x.com you'll need to authorize this extension (<strong>make sure you're logged out of x.com before each of these steps</strong>).]]></comment>
158
+ </authorize_extension_button>
159
  </fields>
160
  </config>
161
  </groups>
162
  </facebook>
163
  </sections>
164
+ <admin>
165
+ <fieldsets>
166
+ <facebook>
167
+ <cap_token><required>1</required></cap_token>
168
+ </facebook>
169
+ </fieldsets>
170
+ </admin>
171
  </config>
app/code/community/Social/Facebook/etc/xfabric.tenant.updated.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type" : "record",
3
+ "name" : "XFabricTenantUpdated",
4
+ "fields" : [ {
5
+ "name" : "tenantPseudonym",
6
+ "type" : "string"
7
+ },
8
+ {
9
+ "name" : "bearerToken",
10
+ "type" : "string"
11
+ },
12
+ {
13
+ "name" : "tenantName",
14
+ "type" : "string"
15
+ }
16
+ ],
17
+ "topic" : "/xfabric/tenant/updated",
18
+ "version" : "1.0.0"
19
+ }
app/code/community/Social/Facebook/locale/Social_Facebook.csv ADDED
File without changes
app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-install-1.4.0.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Social
22
- * @package Social_Facebook
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
- /* @var $installer Mage_Core_Model_Resource_Setup */
27
- $installer = $this;
28
-
29
- $installer->startSetup();
30
-
31
- $installer->run("
32
- CREATE TABLE {$this->getTable('social_facebook/facebook')} (
33
- `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id',
34
- `facebook_id` varchar(100) NOT NULL COMMENT 'Facebook User Id',
35
- `facebook_name` varchar(100) NOT NULL COMMENT 'Facebook User Name',
36
- `facebook_action` smallint(5) unsigned NOT NULL COMMENT 'User Action',
37
- `item_id` int(10) unsigned NOT NULL COMMENT 'Product Id',
38
- PRIMARY KEY (`entity_id`)
39
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Social Facebook Actions';
40
- ");
41
-
42
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-upgrade-1.4.0-1.4.0.1.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Admin
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- $installer = $this;
28
- /* @var $installer Mage_Core_Model_Resource_Setup */
29
-
30
- /**
31
- * Change table 'social_facebook/facebook'
32
- */
33
-
34
- $installer->startSetup();
35
-
36
- $installer->run("
37
- ALTER TABLE {$this->getTable('social_facebook/facebook')}
38
- CHANGE COLUMN `facebook_action` `facebook_action` VARCHAR(100) NOT NULL COMMENT 'User Action' AFTER `facebook_name`
39
- ");
40
-
41
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/social/facebook/system/config/button.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Social
22
+ * @package Social_Facebook
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ $disabled = $this->getIsDisabled();
29
+ if(empty($disabled)) {
30
+ ?>
31
+ <button onclick="javascript:window.open('<?php echo $this->getButtonUrl(); ?>', 'get_auth_file','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=815, height=640'); return false;" class="scalable add" type="button" id="<?php echo $this->getHtmlId() ?>">
32
+ <?php
33
+ } else {
34
+ ?>
35
+ <button class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>" style="border:1px solid #727272;color:#999999;background:#cccccc;" onclick="alert('Please browse for an authorization file and save the configuration before trying to authorize this extension.');"'>
36
+ <?php
37
+ }
38
+ ?>
39
+ <span><?php echo $this->escapeHtml($this->getButtonLabel()); ?></span>
40
+ </button>
41
+ <?php
42
+
43
+ $token = $this->getToken();
44
+ if(!empty($token)) {
45
+ echo "<br /><strong><em>Current Token</em></strong>: <br />" . htmlspecialchars($token) . "<br />";
46
+ echo "<strong><em>Fabric URL</em></strong>: <br />" . htmlspecialchars($this->getFabricUrl()) . "<br />";
47
+ echo "<strong><em>Tenant Name</em></strong>: <br />" . htmlspecialchars($this->getTenantName()) . "<br />";
48
+ }
49
+ ?>
app/design/frontend/base/default/layout/facebook.xml CHANGED
@@ -21,47 +21,37 @@
21
  *
22
  * @category design
23
  * @package base_default
24
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
  */
27
  -->
28
- <layout version="1.0.0">
29
  <!--
30
  Product view
31
  -->
32
- <catalog_product_view>
33
  <reference name="head">
34
  <action method="addCss"><stylesheet>css/facebook.css</stylesheet></action>
35
  </reference>
36
- <reference name="content">
37
- <reference name="product.info">
38
- <reference name="alert.urls">
39
- <block type="social_facebook/start" name="social_facebook_start">
40
- <block type="social_facebook/action" name="social_facebook_action" as="social_facebook_action" template="social/facebook/action.phtml" />
41
- <block type="social_facebook/box" name="social_facebook_box" as="social_facebook_box" template="social/facebook/box.phtml" />
42
- </block>
43
- </reference>
44
- </reference>
45
  </reference>
46
  </catalog_product_view>
47
 
48
- <review_product_list>
49
  <reference name="head">
50
  <action method="addCss"><stylesheet>css/facebook.css</stylesheet></action>
51
  </reference>
52
- <reference name="content">
53
- <reference name="product.info">
54
- <reference name="alert.urls">
55
- <block type="social_facebook/start" name="social_facebook_start" >
56
- <block type="social_facebook/action" name="social_facebook_action" as="social_facebook_action" template="social/facebook/action.phtml" />
57
- <block type="social_facebook/box" name="social_facebook_box" as="social_facebook_box" template="social/facebook/box.phtml" />
58
- </block>
59
- </reference>
60
- </reference>
61
  </reference>
62
  </review_product_list>
63
 
64
- <facebook_index_page>
65
  <block type="social_facebook/head" name="social_facebook_head" template="social/facebook/page.phtml" />
66
  </facebook_index_page>
67
  </layout>
21
  *
22
  * @category design
23
  * @package base_default
24
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
25
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
  */
27
  -->
28
+ <layout version="1.0.0.0">
29
  <!--
30
  Product view
31
  -->
32
+ <catalog_product_view translate="label">
33
  <reference name="head">
34
  <action method="addCss"><stylesheet>css/facebook.css</stylesheet></action>
35
  </reference>
36
+ <reference name="product.info.extrahint">
37
+ <block type="social_facebook/start" name="social_facebook_start" >
38
+ <block type="social_facebook/socialdata" name="social_facebook_data" as="social_facebook_data" />
39
+ </block>
 
 
 
 
 
40
  </reference>
41
  </catalog_product_view>
42
 
43
+ <review_product_list translate="label">
44
  <reference name="head">
45
  <action method="addCss"><stylesheet>css/facebook.css</stylesheet></action>
46
  </reference>
47
+ <reference name="product.info.extrahint">
48
+ <block type="social_facebook/start" name="social_facebook_start" >
49
+ <block type="social_facebook/socialdata" name="social_facebook_data" as="social_facebook_data" />
50
+ </block>
 
 
 
 
 
51
  </reference>
52
  </review_product_list>
53
 
54
+ <facebook_index_page translate="label">
55
  <block type="social_facebook/head" name="social_facebook_head" template="social/facebook/page.phtml" />
56
  </facebook_index_page>
57
  </layout>
app/design/frontend/base/default/template/social/facebook/action.phtml CHANGED
@@ -27,9 +27,21 @@
27
  /** @var $this Social_Facebook_Block_Action */
28
  $actions = $this->getAllActions();
29
  ?>
30
- <?php if (!empty($actions)): ?>
31
- <?php foreach ($actions as $action): ?>
32
- <a class="facebookBtn" href="<?php echo $this->getFacebookUrl($action['action']) ?>"><?php echo $this->escapeHtml($action['title']) ?></a></button>
33
- <?php endforeach; ?>
34
- <div style="clear:both;"></div>
35
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
27
  /** @var $this Social_Facebook_Block_Action */
28
  $actions = $this->getAllActions();
29
  ?>
30
+ <table cellspacing=0 cellpadding=0 border=0 style="margin-top:3px;">
31
+ <tr>
32
+ <td class="facebookLeftStrip">
33
+ </td>
34
+ <td class="facebookRightBlock">
35
+ <?php if (!empty($actions)) {
36
+ foreach ($actions as $action) {
37
+ $class = 'facebookBtn';
38
+ $url = $this->getFacebookUrl($action['action']);
39
+ if(!empty($action["selected"])) {
40
+ $class = 'facebookBtn facebookBtnSelected';
41
+ $url = "javascript:void(0);";
42
+ }
43
+ echo "<a class=\"{$class}\" href=\"". $url ."\">". $this->escapeHtml($action['title']) ."</a>";
44
+ }
45
+ }
46
+ ?>
47
+ <div style="clear:both;height:5px;"></div>
app/design/frontend/base/default/template/social/facebook/box.phtml CHANGED
@@ -33,23 +33,25 @@ $actions = $this->getAllActions();
33
  <?php continue; ?>
34
  <?php endif; ?>
35
  <div class="facebookFriendsBox">
36
- <div>
37
  <?php if ($this->getCountOfUsers($action['action']) == 1): ?>
38
- <?php echo $this->__('1 user %ss this product', $this->escapeHtml($action['action'])); ?>
39
  <?php else: ?>
40
- <?php echo $this->__('%s users %s this product', $this->getCountOfUsers($action['action']), $this->escapeHtml($action['action'])) ?>
41
  <?php endif; ?>
42
  </div>
43
  <div style="clear:both;"></div>
44
  <?php foreach($this->getFriendBox($action['action']) as $facebookId => $facebookName): ?>
45
  <div class="facebookUser">
46
- <img border="0" src="http://graph.facebook.com/<?php echo $facebookId?>/picture" alt="<?php $this->escapeHtml($facebookName)?>" title="<?php $this->escapeHtml($facebookName)?>">
 
47
  <span title="<?php echo $this->escapeHtml($facebookName)?>"><?php echo $this->escapeHtml($facebookName)?></span>
 
48
  </div>
49
  <?php endforeach; ?>
50
- <div style="clear:both;"></div>
51
  </div>
52
- <div class="facebookZeroBox"></div>
53
  <?php endforeach; ?>
54
- <div style="clear:both;"></div>
55
  <?php endif; ?>
 
 
 
33
  <?php continue; ?>
34
  <?php endif; ?>
35
  <div class="facebookFriendsBox">
36
+ <div class="facebookActionBanner">
37
  <?php if ($this->getCountOfUsers($action['action']) == 1): ?>
38
+ <?php echo $this->__('one of your friends <strong>%s</strong> this product', $this->escapeHtml($action['action'])); ?>
39
  <?php else: ?>
40
+ <?php echo $this->__('%s of your friends <strong>%s</strong> this product', $this->getCountOfUsers($action['action']), $this->escapeHtml($action['action'])) ?>
41
  <?php endif; ?>
42
  </div>
43
  <div style="clear:both;"></div>
44
  <?php foreach($this->getFriendBox($action['action']) as $facebookId => $facebookName): ?>
45
  <div class="facebookUser">
46
+ <a href="https://www.facebook.com/<?php echo $facebookId?>" target="_blank">
47
+ <img border="0" src="http://graph.facebook.com/<?php echo $facebookId?>/picture" alt="<?php $this->escapeHtml($facebookName)?>" title="<?php $this->escapeHtml($facebookName)?>" class="facebookUserImg">
48
  <span title="<?php echo $this->escapeHtml($facebookName)?>"><?php echo $this->escapeHtml($facebookName)?></span>
49
+ </a>
50
  </div>
51
  <?php endforeach; ?>
 
52
  </div>
 
53
  <?php endforeach; ?>
 
54
  <?php endif; ?>
55
+ </td>
56
+ </tr>
57
+ </table>
app/design/frontend/base/default/template/social/facebook/box.phtml~ DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
-
27
- /** @var $this Social_Facebook_Block_Box */
28
- $actions = $this->getAllActions();
29
- ?>
30
- <?php if (!empty($actions)): ?>
31
- <?php foreach ($actions as $action): ?>
32
- <?php if ($action['box'] == 0): ?>
33
- <?php continue; ?>
34
- <?php endif; ?>
35
- <div class="facebookFriendsBox">
36
- <div>
37
- <?php if ($this->getCountOfUsers($action['action']) == 1): ?>
38
- 1 user <?php echo $this->htmlEscape($action['action']) ?>s this product
39
- <?php else: ?>
40
- <?php echo $this->getCountOfUsers($action['action'])?> users <?php echo $this->htmlEscape($action['action']) ?> this product
41
- <?php endif; ?>
42
- </div>
43
- <div style="clear:both;"></div>
44
- <?php foreach($this->getFriendBox($action['action']) as $user): ?>
45
- <div class="facebookUser">
46
- <img border="0" src="http://graph.facebook.com/<?php echo $user['facebook_id']?>/picture" alt="<?php $this->htmlEscape($user['facebook_name'])?>" title="<?php $this->htmlEscape($user['facebook_name'])?>">
47
- <span title="<?php echo $this->escapeHtml($user['facebook_name'])?>"><?php echo $this->escapeHtml($user['facebook_name'])?></span>
48
- </div>
49
- <?php endforeach; ?>
50
- <div style="clear:both;"></div>
51
- </div>
52
- <div class="facebookZeroBox"></div>
53
- <?php endforeach; ?>
54
- <div style="clear:both;"></div>
55
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/social/facebook/empty.phtml CHANGED
@@ -20,28 +20,75 @@
20
  *
21
  * @category design
22
  * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
 
27
  /** @var $this Social_Facebook_Block_Start */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ?>
29
  <div>
30
- <?php echo $this->getChildHtml('social_facebook_action'); ?>
 
 
 
31
  </div>
32
 
33
  <?php if ($this->getShowSumm() != Social_Facebook_Block_Start::FACEBOOK_BLOCK_NO_TEXT): ?>
34
- <div style="padding-bottom:10px;">
35
- <span class="fb_image"></span> <span><?php echo $this->__('%s people own or want this.', $this->getPeopleCount()) ?>
36
- <?php if ($this->getShowSumm() == Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_CONNECT): ?>
37
  <a href="<?php echo $this->getConnectUrl()?>"><?php echo $this->__('Connect') ?></a> <?php echo $this->__('to see how many are friends.') ?>
38
- <?php else: ?>
39
- <?php echo $this->__('Be the first of your friends.') ?>
40
- <?php endif; ?>
 
 
41
  </span>
42
  </div>
43
  <?php endif; ?>
44
 
45
  <div>
46
- <?php echo $this->getChildHtml('social_facebook_box'); ?>
 
 
 
47
  </div>
20
  *
21
  * @category design
22
  * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
  */
26
 
27
  /** @var $this Social_Facebook_Block_Start */
28
+
29
+ $actions = Mage::helper('social_facebook')->getAllActions();
30
+ $peopleCount = $this->getPeopleCount();
31
+ $user_id = $this->getFbUserId();
32
+ $json = $this->getSocialData();
33
+
34
+ $actionArray = array();
35
+ $action_string = "";
36
+ $be_the_first = true;
37
+
38
+ foreach ($actions as $action) {
39
+ if($peopleCount<2) { $actionArray[] = $action['action'] . 's'; } else {
40
+ $actionArray[] = $action['action'];
41
+ }
42
+ if(!empty($json->actions->$action['action'])) { $be_the_first = false; }
43
+ }
44
+
45
+ $l = sizeof($actionArray);
46
+ if($l==2) { $action_string = $actionArray[0] . " or " . $actionArray[1]; }
47
+ else if($l==1) {
48
+ $action_string = $actionArray[0];
49
+ } else {
50
+ for($i=0; $i<$l; $i++) {
51
+ $delim = "";
52
+ if($i==($l-2)) {
53
+ $delim = " or ";
54
+ } else if($i<($l-1)) {
55
+ $delim = ", ";
56
+ }
57
+ $action_string .= $actionArray[$i] . $delim;
58
+ }
59
+ }
60
+
61
+ $count_str = "No one ";
62
+ if($peopleCount>0) {
63
+ $count_str = $peopleCount . " ";
64
+ $count_str .= $peopleCount > 1 ? "people" : "person";
65
+ }
66
+
67
  ?>
68
  <div>
69
+ <?php
70
+ $html = $this->getLayout()->createBlock('social_facebook/action')->toHtml();
71
+ if(!empty($html)) { echo $html; }
72
+ ?>
73
  </div>
74
 
75
  <?php if ($this->getShowSumm() != Social_Facebook_Block_Start::FACEBOOK_BLOCK_NO_TEXT): ?>
76
+ <div class="facebookNotConnected">
77
+ <span class="fb_image"></span> <span><?php echo $this->__('%s %s this product.', $count_str, $action_string); ?>
78
+ <?php if ($this->getShowSumm() == Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_CONNECT && !empty($peopleCount)) { ?>
79
  <a href="<?php echo $this->getConnectUrl()?>"><?php echo $this->__('Connect') ?></a> <?php echo $this->__('to see how many are friends.') ?>
80
+ <?php } else if ($this->getShowSumm() == Social_Facebook_Block_Start::FACEBOOK_BLOCK_START_CONNECT && empty($peopleCount)) { ?>
81
+ <a href="<?php echo $this->getConnectUrl()?>"><?php echo $this->__('Connect') ?></a> <?php echo $this->__('to be the first of your friends!') ?>
82
+ <?php } else if($be_the_first) { ?>
83
+ <?php echo $this->__('Be the first of your friends!') ?>
84
+ <?php } ?>
85
  </span>
86
  </div>
87
  <?php endif; ?>
88
 
89
  <div>
90
+ <?php
91
+ $html = $this->getLayout()->createBlock('social_facebook/box');
92
+ if(!empty($html)) { echo $html->toHtml(); }
93
+ ?>
94
  </div>
app/design/frontend/base/default/template/social/facebook/socialdata.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <div id="social_facebook_block"></div>
2
+ <script>
3
+ new Ajax.Updater('social_facebook_block', '<?php
4
+ echo Mage::getUrl('facebook/index/widget/', array('id' => urlencode((int)$this->getRequest()->getParam('id'))));
5
+ ?>', {
6
+ method: 'get'
7
+ });
8
+ </script>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Social_Facebook</name>
4
- <version>1.4.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Facebook Open Graph 2.0 Extension for Magento</summary>
10
- <description>Facebook Open Graph 2.0 extension provides you with possibility to add new social buttons to your store. The extension uses the brand new Facebook Open Graph 2.0 protocol and allows adding the &#x201C;Want&#x201D; and &#x201C;I own this&#x201D; Facebook buttons on your product pages.</description>
11
- <notes>Facebook Open Graph 2.0 extension is compatible with Magento Enterprise Edition and Professional Edition 1.9.0.0 or later, and Magento Community Edition 1.4.0.0 or later.</notes>
12
- <authors><author><name>Magento Core Team</name><user>auto-converted</user><email>core@magentocommerce.com</email></author></authors>
13
- <date>2011-10-19</date>
14
- <time>13:10:54</time>
15
- <contents><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="facebook.css" hash="732ee944e67155fc9c5aabd5282dd93f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="facebook.xml" hash="f9ddf18c9f52d3fd7e0e131865a383c2"/></dir><dir name="template"><dir name="social"><dir name="facebook"><file name="action.phtml" hash="9d12c6e116652f0fc5bf5b516e07b0af"/><file name="box.phtml" hash="2ca758ee05423fad428770ca47e33384"/><file name="box.phtml~" hash="8d341ead7d3c7e36c6e1b796423050f8"/><file name="empty.phtml" hash="9c3bd6e1a1361c0e64cac4c78426b069"/><file name="page.phtml" hash="81bef9f0829d6b5718f8aecc3dd5a88f"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Social_Facebook.xml" hash="b15af76b10945d00b8dbad23aebc0f50"/></dir></target><target name="magecommunity"><dir name="Social"><dir name="Facebook"><dir name="Block"><dir name="Adminhtml"><file name="Facebuttons.php" hash="4981f608fdc23b78e4bc847800397b66"/><file name="Select.php" hash="dd9ad7192087cb741b9f84b8c23bff9c"/></dir><file name="Action.php" hash="a929dce825d3b184b6d236f309ab298b"/><file name="Box.php" hash="516adc472c9bf244cc4e1bfaa9c72969"/><file name="Head.php" hash="dbb35ead2ed9b6444e552335efd678e4"/><file name="Like.php" hash="d7ace82dd95b99cd282ea99c16d10077"/><file name="Start.php" hash="2e61c7814dc9c7c23d34c1e8ed74c518"/></dir><dir name="controllers"><file name="IndexController.php" hash="da8bfd193c2cc8087bf2db946504d2b6"/></dir><dir name="etc"><file name="config.xml" hash="4990a8342e06a8e6a3478e458fe94801"/><file name="system.xml" hash="2717316adc05041cc7c9eaa36dfc6ef5"/></dir><dir name="Helper"><file name="Data.php" hash="4997be7dfb07b5967ddc3d783c7c3ade"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Facebook"><file name="Collection.php" hash="dc4fcda1d7c351876eeca1e439ba723d"/></dir><file name="Facebook.php" hash="f15b9ae8739da03fe6ab68cac466339f"/></dir><file name="Api.php" hash="52c453a2fe92e84efbbe63a3eea63d6a"/><file name="Facebook.php" hash="788881a98c74b692b75680689c52e6a5"/><file name="Facebuttons.php" hash="f15aa66ba13f5977adf09b067f0fa3d9"/><file name="Observer.php" hash="168c3c3a9ae234f7f491bbf654e83d91"/></dir><dir name="sql"><dir name="social_facebook_setup"><file name="mysql4-install-1.4.0.php" hash="ee195ec6e7b57830ced3f3c4a2a41233"/><file name="mysql4-upgrade-1.4.0-1.4.0.1.php" hash="63a0f7a199dd72e782d1f28dbfbbadb6"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Social_Facebook</name>
4
+ <version>2.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Facebook Open Graph Extension for Magento</summary>
10
+ <description>Facebook Open Graph 2.0 extension allows merchants to add new social buttons to their store which results in higher click-to-sale, and upsells. The extension uses Facebook Open Graph 2.0 protocol which allows merchants to add Facebook action buttons on product pages. It is built on top of the X.commerce commerce OS.</description>
11
+ <notes>Facebook Open Graph 2.0 extension is compatible with Magento Enterprise Edition and Professional Edition 1.11 or later, and Magento Community Edition 1.6 or later.</notes>
12
+ <authors><author><name>Magento Core Team</name><user>core</user><email>core@magentocommerce.com</email></author></authors>
13
+ <date>2012-08-23</date>
14
+ <time>22:00:21</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Social_Facebook.xml" hash="b15af76b10945d00b8dbad23aebc0f50"/></dir></target><target name="magecommunity"><dir name="Social"><dir name="Facebook"><dir name="Block"><file name="Action.php" hash="3804657fa2a304d87c51f92e5ae61d27"/><file name="Box.php" hash="f856c36c36a826fc5848d6a1dc2350c2"/><file name="Head.php" hash="0f03a964f526eacb27877cbf43c31cff"/><file name="Socialdata.php" hash="36466e7a19a065bd0558c21e59b6ab63"/><file name="Start.php" hash="f37f21ecb2990a4b08e27a635a5b577a"/><dir name="Adminhtml"><file name="Facebuttons.php" hash="545099576c8530dac2c7d50c49709b10"/><file name="Select.php" hash="0835b7782edfdfa900a65b397acfd7f5"/><dir name="System"><dir name="Form"><dir name="Renderer"><dir name="Config"><file name="AuthButton.php" hash="7a9736e4b09150450a480d1867536d8b"/><file name="RegisterButton.php" hash="f871a32f3f66a6496ea30a7948be2886"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="6572649784b8c1da1983d5ab6732dfb9"/></dir><dir name="Model"><file name="Api.php" hash="ae7171794d29b812455bdee69bbaae5f"/><file name="Facebook.php" hash="1188300b052f28a0b90843e9000278f4"/><file name="Facebuttons.php" hash="174e8d6bbc004115bfe56b2a3933acc9"/><file name="Observer.php" hash="5d4c49602ffe0e437b73800e7d94e369"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Authorization.php" hash="94043f184d8909f04f93fdb91fc77d9f"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="807b7bf1bc93c9a3f1aec69736b93a58"/></dir><dir name="etc"><file name="adminhtml.xml" hash="357bed8aa09d3c21de1e255eeb656bc8"/><file name="config.xml" hash="0ec6e711a3b58ec35eb64823182c27e8"/><file name="social.events.product.fetch.json" hash="6e70834b3deb5a79000c6611c96403cc"/><file name="social.events.product.fetchSucceeded.json" hash="a26bdb243def788240cd74e83eb46944"/><file name="social.events.product.new.json" hash="c54901dccdc338263d2a62ec701ed84c"/><file name="system.tenant.relationship.created.json" hash="a9c359bd51e95fa34727d6c85e8a9aed"/><file name="system.xml" hash="8eb20913e0b6841c849760b5c35833e3"/><file name="xfabric.tenant.updated.json" hash="352322878e26806949308dc98d97538a"/></dir><dir name="locale"><file name="Social_Facebook.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="facebook.css" hash="3640ca91d7edf266c097e5afafe81de9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="social"><dir name="facebook"><file name="action.phtml" hash="3f037aefeb2c1972bae4f9f4bce6db16"/><file name="box.phtml" hash="9ec7546cc97898048712e4e4c106b580"/><file name="empty.phtml" hash="be36fe9381fb91ce85af00a3ae583396"/><file name="page.phtml" hash="81bef9f0829d6b5718f8aecc3dd5a88f"/><file name="socialdata.phtml" hash="3c30ce6b4cd6f4077a57b9f8e9204171"/></dir></dir></dir><dir name="layout"><file name="facebook.xml" hash="c18c812d68d18dc40b47f22c456033c5"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="social"><dir name="facebook"><dir name="system"><dir name="config"><file name="button.phtml" hash="f60245da1dfc1d6c8d2dd54f501043cb"/></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>PDO</name><min>1.0.0</min><max>10.0.0</max></extension></required></dependencies>
18
  </package>
skin/frontend/base/default/css/facebook.css CHANGED
@@ -26,44 +26,79 @@
26
  background-image: url("http://static.ak.fbcdn.net/rsrc.php/v1/yg/r/Uabljzt60VA.png");
27
  background-repeat: no-repeat;
28
  display: inline-block;
29
- height: 16px;
30
- width: 16px;
31
  }
 
32
  .facebookBtn {
33
- margin: 1px 10px 10px 0;
34
- padding: 4px 5px 4px 6px;
35
- text-align: center;
36
- background-color: #ECEEF5;
37
  border: 1px solid #CAD4E7;
38
  border-radius: 3px 3px 3px 3px;
39
  display: block;
40
  line-height: 14px;
41
  white-space: nowrap;
42
- color: #3B5998;
43
- cursor: pointer;
44
  text-decoration: none;
45
- width: 50px;
46
  float: left;
 
47
  }
 
 
 
 
 
 
48
  .facebookFriendsBox {
49
- background: url("../images/bkg_page-title.gif");
50
  border: 1px solid #CFCFCF;
51
- padding: 5px;
52
  border-radius: 5px;
53
- height: 110px;
54
- overflow: hidden;
55
- float: left;
56
- margin: 10px -10px 10px -10px;
 
 
 
57
  }
 
58
  .facebookZeroBox {
59
- float: left;
60
- margin: 15px;
61
  }
 
62
  .facebookUser {
63
- text-align: center;
64
- width: 65px;
65
- height: 90px;
66
- padding-top: 5px;
67
- overflow: hidden;
68
- float: left;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
26
  background-image: url("http://static.ak.fbcdn.net/rsrc.php/v1/yg/r/Uabljzt60VA.png");
27
  background-repeat: no-repeat;
28
  display: inline-block;
 
 
29
  }
30
+
31
  .facebookBtn {
32
+ margin:0 10px 10px 0;
33
+ padding:7px 10px 7px 10px;
34
+ text-align:center;
35
+ background-color:#ECEEF5;
36
  border: 1px solid #CAD4E7;
37
  border-radius: 3px 3px 3px 3px;
38
  display: block;
39
  line-height: 14px;
40
  white-space: nowrap;
41
+ color: #4F6AA3;
 
42
  text-decoration: none;
 
43
  float: left;
44
+ margin-bottom:0;
45
  }
46
+
47
+ .facebookBtn:hover, .facebookBtnSelected {
48
+ background-color:#4F6AA3;
49
+ color:#FCFCFE;
50
+ }
51
+
52
  .facebookFriendsBox {
 
53
  border: 1px solid #CFCFCF;
54
+ padding:5px;
55
  border-radius: 5px;
56
+ height:95px;
57
+ overflow:hidden;
58
+ margin:10px -10px 10px -10px;
59
+ margin-top:10px;
60
+ margin-left:0;
61
+ padding-left:0;
62
+ margin-bottom:0;
63
  }
64
+
65
  .facebookZeroBox {
66
+ float:left;
 
67
  }
68
+
69
  .facebookUser {
70
+ text-align:center;
71
+ width:65px;
72
+ height:80px;
73
+ padding-top:5px;
74
+ overflow:hidden;
75
+ float:left;"
76
+ }
77
+
78
+ .facebookUserImg {
79
+ border: 1px solid black;
80
+ -webkit-border-radius: 10px;
81
+ border-radius: 10px;
82
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
83
+ box-shadow:0 1px 3px rgba(0, 0, 0, .4);
84
+ -moz-box-shadow:0 1px 3px rgba(0, 0, 0, .4);
85
+ -moz-border-radius: 10px;
86
+ overflow:hidden;
87
+ }
88
+
89
+ .facebookActionBanner {
90
+ margin-left:8px;
91
+ margin-right:8px;
92
+ }
93
+
94
+ .facebookLeftStrip {
95
+ background-color:#627AAD;width:4px;border-radius:3px;
96
+ }
97
+
98
+ .facebookRightBlock {
99
+ padding-left:5px;
100
+ }
101
+
102
+ .facebookUser a {
103
+ text-decoration:none;
104
  }