Social_Facebook - Version 1.5.0.0

Version Notes

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

Download this release

Release Info

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


Version 1.5.0.0

Files changed (27) hide show
  1. app/code/community/Social/Facebook/Block/Action.php +58 -0
  2. app/code/community/Social/Facebook/Block/Adminhtml/Facebuttons.php +84 -0
  3. app/code/community/Social/Facebook/Block/Adminhtml/Select.php +41 -0
  4. app/code/community/Social/Facebook/Block/Box.php +70 -0
  5. app/code/community/Social/Facebook/Block/Head.php +80 -0
  6. app/code/community/Social/Facebook/Block/Like.php +24 -0
  7. app/code/community/Social/Facebook/Block/Start.php +80 -0
  8. app/code/community/Social/Facebook/Helper/Data.php +136 -0
  9. app/code/community/Social/Facebook/Model/Api.php +255 -0
  10. app/code/community/Social/Facebook/Model/Facebook.php +321 -0
  11. app/code/community/Social/Facebook/Model/Facebuttons.php +56 -0
  12. app/code/community/Social/Facebook/Model/Mysql4/Facebook.php +129 -0
  13. app/code/community/Social/Facebook/Model/Mysql4/Facebook/Collection.php +44 -0
  14. app/code/community/Social/Facebook/Model/Observer.php +121 -0
  15. app/code/community/Social/Facebook/controllers/IndexController.php +101 -0
  16. app/code/community/Social/Facebook/etc/config.xml +157 -0
  17. app/code/community/Social/Facebook/etc/system.xml +108 -0
  18. app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-install-1.5.0.php +42 -0
  19. app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-upgrade-1.5.0-1.5.0.1.php +41 -0
  20. app/design/frontend/base/default/layout/facebook.xml +59 -0
  21. app/design/frontend/base/default/template/social/facebook/action.phtml +35 -0
  22. app/design/frontend/base/default/template/social/facebook/box.phtml +55 -0
  23. app/design/frontend/base/default/template/social/facebook/empty.phtml +47 -0
  24. app/design/frontend/base/default/template/social/facebook/page.phtml +44 -0
  25. app/etc/modules/Social_Facebook.xml +32 -0
  26. package.xml +18 -0
  27. skin/frontend/base/default/css/facebook.css +69 -0
app/code/community/Social/Facebook/Block/Action.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Action extends Mage_Core_Block_Template
22
+ {
23
+ /**
24
+ * Block Initialization
25
+ *
26
+ * @return Social_Facebook_Block_Action
27
+ */
28
+ protected function _construct()
29
+ {
30
+ if (!Mage::helper('social_facebook')->isEnabled()) {
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
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Get Url for redirect to Facebook
45
+ *
46
+ * @param string $action
47
+ * @return string
48
+ */
49
+ public function getFacebookUrl($action)
50
+ {
51
+ return $this->getUrl(
52
+ 'facebook/index/redirect/',
53
+ array(
54
+ 'productId' => $this->getProductId(),
55
+ 'action' => $this->escapeHtml($action),
56
+ ));
57
+ }
58
+ }
app/code/community/Social/Facebook/Block/Adminhtml/Facebuttons.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Adminhtml_Facebuttons extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
22
+ {
23
+ /**
24
+ * @var Mage_CatalogInventory_Block_Adminhtml_Form_Field_Customergroup
25
+ */
26
+ protected $_selectRenderer;
27
+
28
+ /**
29
+ * Retrieve checkbox column renderer
30
+ *
31
+ * @return Social_Facebook_Block_Adminhtml_Select
32
+ */
33
+ protected function _selectRenderer()
34
+ {
35
+ if (!$this->_selectRenderer) {
36
+ $this->_selectRenderer = $this->getLayout()->createBlock(
37
+ 'social_facebook/adminhtml_select', '',
38
+ array('is_render_to_js_template' => true)
39
+ );
40
+ $this->_selectRenderer->setClass('customer_group_select');
41
+ $this->_selectRenderer->setExtraParams('style="width:120px"');
42
+ }
43
+ return $this->_selectRenderer;
44
+ }
45
+
46
+ /**
47
+ * Prepare to render
48
+ */
49
+ protected function _prepareToRender()
50
+ {
51
+ $this->addColumn('action', array(
52
+ 'label' => Mage::helper('social_facebook')->__('Action'),
53
+ 'style' => 'width:120px',
54
+ ));
55
+ $this->addColumn('title', array(
56
+ 'label' => Mage::helper('social_facebook')->__('Button Title'),
57
+ 'style' => 'width:120px',
58
+ ));
59
+ $this->addColumn('box', array(
60
+ 'label' => Mage::helper('social_facebook')->__('Enable FriendBox'),
61
+ 'renderer' => $this->_selectRenderer(),
62
+ ));
63
+ $this->addColumn('count', array(
64
+ 'label' => Mage::helper('social_facebook')->__('Count in FriendBox'),
65
+ 'style' => 'width:120px',
66
+ ));
67
+
68
+ $this->_addAfter = false;
69
+ $this->_addButtonLabel = Mage::helper('social_facebook')->__('Add Action Button');
70
+ }
71
+
72
+ /**
73
+ * Prepare existing row data object
74
+ *
75
+ * @param Varien_Object
76
+ */
77
+ protected function _prepareArrayRow(Varien_Object $row)
78
+ {
79
+ $row->setData(
80
+ 'option_extra_attr_' . $this->_selectRenderer()->calcOptionHash($row->getData('box')),
81
+ 'selected="selected"'
82
+ );
83
+ }
84
+ }
app/code/community/Social/Facebook/Block/Adminhtml/Select.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Adminhtml_Select extends Mage_Core_Block_Html_Select
22
+ {
23
+ protected $_options = array();
24
+
25
+ public function setInputName($value)
26
+ {
27
+ return $this->setName($value);
28
+ }
29
+
30
+ public function _toHtml()
31
+ {
32
+ $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
33
+
34
+ foreach ($yesnoSource as $action) {
35
+ $this->addOption($action['value'], $action['label']);
36
+ }
37
+
38
+ return parent::_toHtml();
39
+ }
40
+
41
+ }
app/code/community/Social/Facebook/Block/Box.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Box extends Mage_Core_Block_Template
22
+ {
23
+ /**
24
+ * Block Initialization
25
+ *
26
+ * @return Social_Facebook_Block_Box
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
+ }
44
+
45
+ /**
46
+ * Get Facebook Friend Box By Action
47
+ *
48
+ * @param string $action
49
+ * @return array
50
+ */
51
+ public function getFriendBox($action)
52
+ {
53
+ return Mage::getModel('social_facebook/facebook')->getLinkedFriends($this->getFacebookId(),
54
+ $this->getProductId(), $action);
55
+ }
56
+
57
+ /**
58
+ * Get Count of Facebook User
59
+ *
60
+ * @param string $action
61
+ * @return int
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
+ }
app/code/community/Social/Facebook/Block/Head.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Head extends Mage_Core_Block_Template
22
+ {
23
+ /**
24
+ * Block Initialization
25
+ *
26
+ * @return Social_Facebook_Block_Head
27
+ */
28
+ protected function _construct()
29
+ {
30
+ $helper = Mage::helper('social_facebook');
31
+ if (!$helper->isEnabled()) {
32
+ return;
33
+ }
34
+ parent::_construct();
35
+
36
+ /** @var $product Mage_Catalog_Model_Product */
37
+ $product = Mage::registry('product');
38
+
39
+ if ($product) {
40
+ $this->setTemplate('social/facebook/page.phtml');
41
+
42
+ $tags[] = array(
43
+ 'property' => 'fb:app_id',
44
+ 'content' => $helper->getAppId()
45
+ );
46
+ $tags[] = array(
47
+ 'property' => 'og:type',
48
+ 'content' => $helper->getAppName() . ':' . $helper->getObjectType()
49
+ );
50
+ $tags[] = array(
51
+ 'property' => 'og:url',
52
+ 'content' => Mage::getUrl('facebook/index/page', array('id' => $product->getId()))
53
+ );
54
+ $tags[] = array(
55
+ 'property' => 'og:title',
56
+ 'content' => $this->escapeHtml($product->getName())
57
+ );
58
+ $tags[] = array(
59
+ 'property' => 'og:image',
60
+ 'content' => $this->escapeHtml(Mage::helper('catalog/image')->init($product, 'image')->resize(256))
61
+ );
62
+ $tags[] = array(
63
+ 'property' => 'og:description',
64
+ 'content' => $this->escapeHtml($product->getShortDescription())
65
+ );
66
+ $tags[] = array(
67
+ 'property' => $helper->getAppName(). ':price',
68
+ 'content' => Mage::helper('core')->currency($product->getFinalPrice(), true, false)
69
+ );
70
+
71
+ $this->setMetaTags($tags);
72
+
73
+ $this->setRedirectUrl($product->getUrlModel()->getUrlInStore($product));
74
+
75
+ $this->setAppName($helper->getAppName());
76
+ }
77
+
78
+ return $this;
79
+ }
80
+ }
app/code/community/Social/Facebook/Block/Like.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Like extends Mage_Core_Block_Template
22
+ {
23
+
24
+ }
app/code/community/Social/Facebook/Block/Start.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) 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
+
21
+ class Social_Facebook_Block_Start extends Mage_Core_Block_Template
22
+ {
23
+ const FACEBOOK_BLOCK_NO_TEXT = 0;
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
+
43
+ /** @var $product Mage_Catalog_Model_Product */
44
+ $product = Mage::registry('product');
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
+ }
app/code/community/Social/Facebook/Helper/Data.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
27
+
28
+ /**
29
+ * Facebook helper
30
+ *
31
+ * @category Social
32
+ * @package Social_Facebook
33
+ */
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;
107
+ $actions = $this->getAllActions();
108
+ if (!empty($actions)) {
109
+ foreach ($actions as $act) {
110
+ if ($act['action'] == $action) {
111
+ $count = $act['count'];
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ if (empty($count)) {
117
+ $count = Social_Facebook_Model_Facebook::XML_PATH_APP_USER_COUNT;
118
+ }
119
+ return $count;
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
131
+ . '?client_id=' . $this->getAppId()
132
+ . '&redirect_uri=' . urlencode($product->getUrlModel()->getUrlInStore($product))
133
+ . '&scope=publish_actions'
134
+ . '&response_type=code';
135
+ }
136
+ }
app/code/community/Social/Facebook/Model/Api.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
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
+ /**
49
+ * Set Product Url
50
+ *
51
+ * @param string $productUrl
52
+ * @return Social_Facebook_Model_Api
53
+ */
54
+ public function setProductUrl($productUrl)
55
+ {
56
+ $this->_productUrl = $productUrl;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Set Facebook Code
62
+ *
63
+ * @param string $facebookCode
64
+ * @return Social_Facebook_Model_Api
65
+ */
66
+ public function setFacebookCode($facebookCode)
67
+ {
68
+ $this->_facebookCode = $facebookCode;
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Set Facebook Action
74
+ *
75
+ * @param string $facebookAction
76
+ * @return Social_Facebook_Model_Api
77
+ */
78
+ public function setFacebookAction($facebookAction)
79
+ {
80
+ $this->_facebookAction = $facebookAction;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Set Product Og Url
86
+ *
87
+ * @param string $productOgUrl
88
+ * @return Social_Facebook_Model_Api
89
+ */
90
+ public function setProductOgUrl($productOgUrl)
91
+ {
92
+ $this->_productOgUrl = $productOgUrl;
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * Set Facebook Access Token
98
+ *
99
+ * @param string $accessToken
100
+ * @return Social_Facebook_Model_Api
101
+ */
102
+ public function setAccessToken($accessToken)
103
+ {
104
+ $this->_accessToken = $accessToken;
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * Make Request To Facebook
110
+ *
111
+ * @param array $params
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
+ {
119
+ try {
120
+ $client = new Varien_Http_Client();
121
+
122
+ $client->setUri($uri);
123
+ $client->setConfig(array(
124
+ 'maxredirects' => 5,
125
+ 'timeout' => 30,
126
+ ));
127
+ $client->setParameterGet($params);
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
+ {
150
+ if (empty($this->_facebookCode)) {
151
+ return false;
152
+ }
153
+
154
+ $response = $this->makeFacebookRequest(
155
+ array(
156
+ 'client_id' => Mage::helper('social_facebook')->getAppId(),
157
+ 'redirect_uri' => $this->_productUrl,
158
+ 'client_secret' => Mage::helper('social_facebook')->getAppSecret(),
159
+ 'code' => $this->_facebookCode
160
+ ),
161
+ Social_Facebook_Model_Api::URL_GRAPH_OAUTH_ACCESS_TOKEN,
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;
171
+ }
172
+
173
+ /**
174
+ * Get Facebook User
175
+ *
176
+ * @return mixed
177
+ */
178
+ public function getFacebookUser()
179
+ {
180
+ if (empty($this->_accessToken)) {
181
+ $this->getAccessToken();
182
+ }
183
+
184
+ if (empty($this->_accessToken)) {
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
+ {
209
+ if (empty($this->_accessToken)) {
210
+ $this->getAccessToken();
211
+ }
212
+
213
+ $appName = Mage::helper('social_facebook')->getAppName();
214
+ $objectType = Mage::helper('social_facebook')->getObjectType();
215
+
216
+ if (empty($this->_accessToken) || empty($this->_productOgUrl) || empty($appName) || empty($objectType)) {
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
+ {
239
+ if (empty($this->_accessToken)) {
240
+ $this->getAccessToken();
241
+ }
242
+
243
+ if (empty($this->_accessToken)) {
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
+ }
app/code/community/Social/Facebook/Model/Facebook.php ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
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_Facebook extends Mage_Core_Model_Abstract
35
+ {
36
+ /**
37
+ * XML configuration paths
38
+ */
39
+ const XML_PATH_SECTION_FACEBOOK = 'facebook/config';
40
+ const XML_PATH_ENABLED = 'facebook/config/enabled';
41
+ const XML_PATH_APP_ID = 'facebook/config/id';
42
+ const XML_PATH_APP_SECRET = 'facebook/config/secret';
43
+ const XML_PATH_APP_NAME = 'facebook/config/name';
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
+
50
+ /**
51
+ * Init resource model
52
+ */
53
+ protected function _construct()
54
+ {
55
+ $this->_init('social_facebook/facebook');
56
+ parent::_construct();
57
+ }
58
+
59
+ /**
60
+ * Load User by Action and Facebook Id
61
+ *
62
+ * @param int $action
63
+ * @param int $id
64
+ * @param int $productId
65
+ *
66
+ * @return Social_Facebook_Model_Facebook
67
+ */
68
+ public function loadUserByActionId($action, $id, $productId)
69
+ {
70
+ return $this->_getResource()->loadUserByActionId($action, $id, $productId);
71
+ }
72
+
73
+ /**
74
+ * Get Count of all Users by Action, Product Id
75
+ *
76
+ * @param int $action
77
+ * @param int $productId
78
+ *
79
+ * @return int
80
+ */
81
+ public function getCountByActionProduct($action, $productId)
82
+ {
83
+ return $this->_getResource()->getCountByActionProduct($action, $productId);
84
+ }
85
+
86
+ /**
87
+ * Get Count of all Users by Product Id
88
+ *
89
+ * @param int $productId
90
+ *
91
+ * @return int
92
+ */
93
+ public function getCountByProduct($productId)
94
+ {
95
+ return $this->_getResource()->getCountByProduct($productId);
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
+ /**
147
+ * Get Facebook Api
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
+ /**
164
+ * Facebook Api Remove Session
165
+ *
166
+ * @return Social_Facebook_Model_Facebook
167
+ */
168
+ public function removeSessionApi()
169
+ {
170
+ Mage::getSingleton('core/session')
171
+ ->unsetData('product_url')
172
+ ->unsetData('facebook_action')
173
+ ->unsetData('product_og_url')
174
+ ->unsetData('access_token')
175
+ ->unsetData('facebook_id')
176
+ ;
177
+
178
+ $this->_accessToken = false;
179
+
180
+ return $this;
181
+ }
182
+
183
+ /**
184
+ * Get Access Token
185
+ *
186
+ * @return mixed
187
+ */
188
+ public function getAccessToken()
189
+ {
190
+ if (!empty($this->_accessToken)) {
191
+ return $this->_accessToken;
192
+ }
193
+
194
+ try {
195
+ $session = Mage::getSingleton('core/session');
196
+
197
+ $productUrl = $session->getData('product_url');
198
+ $this->_accessToken = $session->getData('access_token');
199
+
200
+ if (!empty($this->_accessToken) && $this->getApi()->getFacebookUser()) {
201
+ return $this->_accessToken;
202
+ } else {
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
+ }
238
+
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;
264
+ }
265
+
266
+ /**
267
+ * Get Facebook Friends
268
+ *
269
+ * @return mixed
270
+ */
271
+ public function getFacebookFriends()
272
+ {
273
+ try {
274
+ if (!$this->getAccessToken()) {
275
+ return false;
276
+ }
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;
290
+ }
291
+
292
+ /**
293
+ * Get Facebook User
294
+ *
295
+ * @return mixed
296
+ */
297
+ public function getFacebookUser()
298
+ {
299
+ try {
300
+ if (!$this->getAccessToken()) {
301
+ return false;
302
+ }
303
+
304
+ $user = $this->getApi()->getFacebookUser();
305
+ if ($user) {
306
+ Mage::getSingleton('core/session')->setData('facebook_id', $user['facebook_id']);
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
+ }
app/code/community/Social/Facebook/Model/Facebuttons.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
27
+ /**
28
+ * Facebuttons model
29
+ *
30
+ * @category Social
31
+ * @package Social_Facebook
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Social_Facebook_Model_Facebuttons extends Mage_Core_Model_Config_Data
35
+ {
36
+ /**
37
+ * Process data after load
38
+ */
39
+ protected function _afterLoad()
40
+ {
41
+ $value = $this->getValue();
42
+ $this->setValue(unserialize($value));
43
+ }
44
+
45
+ /**
46
+ * Prepare data before save
47
+ */
48
+ protected function _beforeSave()
49
+ {
50
+ $value = $this->getValue();
51
+ if (isset($value['__empty'])) {
52
+ unset($value['__empty']);
53
+ }
54
+ $this->setValue(serialize($value));
55
+ }
56
+ }
app/code/community/Social/Facebook/Model/Mysql4/Facebook.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
27
+
28
+ /**
29
+ * Facebook Observer
30
+ *
31
+ * @category Social
32
+ * @package Social_Facebook
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Social_Facebook_Model_Observer
36
+ {
37
+ /**
38
+ * Save & Send Actions to Facebook
39
+ *
40
+ * @return Social_Facebook_Model_Observer
41
+ */
42
+ public function catalogProduct()
43
+ {
44
+ if (!Mage::helper('social_facebook')->isEnabled()) {
45
+ return false;
46
+ }
47
+ $session = Mage::getSingleton('core/session');
48
+
49
+ $facebookAction = $session->getData('facebook_action');
50
+ $productId = $session->getData('product_id');
51
+ $productUrl = $session->getData('product_url');
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
+ }
app/code/community/Social/Facebook/controllers/IndexController.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
27
+ class Social_Facebook_IndexController extends Mage_Core_Controller_Front_Action
28
+ {
29
+ /**
30
+ * Action For Facebook Action Redirect
31
+ */
32
+ public function redirectAction()
33
+ {
34
+ $link = $this->_facebookRedirect();
35
+ if (!$link) {
36
+ return;
37
+ }
38
+
39
+ $this->_redirectUrl($link);
40
+ return;
41
+ }
42
+
43
+ /**
44
+ * Get Facebook Redirect For Current Action
45
+ *
46
+ * @return string
47
+ */
48
+ private function _facebookRedirect()
49
+ {
50
+ $session = Mage::getSingleton('core/session');
51
+ $action = $this->getRequest()->getParam('action');
52
+ $productId = $this->getRequest()->getParam('productId');
53
+ $product = Mage::getModel('catalog/product')->load($productId);
54
+ $productUrl = $product->getUrlModel()->getUrlInStore($product);
55
+
56
+ $session->setData('product_id', $productId);
57
+ $session->setData('product_url', $productUrl);
58
+ $session->setData('product_og_url', Mage::getUrl('facebook/index/page', array('id' => $productId)));
59
+ $session->setData('facebook_action', $action);
60
+
61
+ if ($session->getData('access_token') && $this->_checkAnswer() && $action) {
62
+ $this->_redirectUrl($productUrl);
63
+ return;
64
+ }
65
+
66
+ return Mage::helper('social_facebook')->getRedirectUrl($product);
67
+ }
68
+
69
+ /**
70
+ * Check is Facebook Token Alive
71
+ *
72
+ * @return bool
73
+ */
74
+ protected function _checkAnswer()
75
+ {
76
+ if (Mage::getSingleton('social_facebook/facebook')->getFacebookUser()) {
77
+ return true;
78
+ }
79
+
80
+ return false;
81
+ }
82
+
83
+ /**
84
+ * Get Metatags for Facebook
85
+ */
86
+ public function pageAction()
87
+ {
88
+ $productId = (int)$this->getRequest()->getParam('id');
89
+ if ($productId) {
90
+ $product = Mage::getModel('catalog/product')->load($productId);
91
+
92
+ if ($product->getId()) {
93
+ Mage::register('product', $product);
94
+ }
95
+
96
+ $this->loadLayout();
97
+ $response = $this->getLayout()->createBlock('social_facebook/head')->toHtml();
98
+ $this->getResponse()->setBody($response);
99
+ }
100
+ }
101
+ }
app/code/community/Social/Facebook/etc/config.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <modules>
30
+ <Social_Facebook>
31
+ <version>1.5.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>
72
+ </social_facebook>
73
+ </blocks>
74
+ <helpers>
75
+ <social_facebook>
76
+ <class>Social_Facebook_Helper</class>
77
+ </social_facebook>
78
+ </helpers>
79
+ </global>
80
+ <admin>
81
+ <routers>
82
+ <adminhtml>
83
+ <args>
84
+ <modules>
85
+ <social_facebook before="Mage_Adminhtml">Social_Facebook_Adminhtml</social_facebook>
86
+ </modules>
87
+ </args>
88
+ </adminhtml>
89
+ </routers>
90
+ </admin>
91
+ <adminhtml>
92
+ <layout>
93
+ <updates>
94
+ <social_facebook>
95
+ <file>facebook.xml</file>
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>
122
+ <updates>
123
+ <social_facebook>
124
+ <file>facebook.xml</file>
125
+ </social_facebook>
126
+ </updates>
127
+ </layout>
128
+ <translate>
129
+ <modules>
130
+ <Social_Facebook>
131
+ <files>
132
+ <default>Social_Facebook.csv</default>
133
+ </files>
134
+ </Social_Facebook>
135
+ </modules>
136
+ </translate>
137
+ <routers>
138
+ <social_facebook>
139
+ <use>standard</use>
140
+ <args>
141
+ <module>Social_Facebook</module>
142
+ <frontName>facebook</frontName>
143
+ </args>
144
+ </social_facebook>
145
+ </routers>
146
+ <events>
147
+ <controller_action_predispatch_catalog_product_view>
148
+ <observers>
149
+ <social_facebook_code>
150
+ <class>social_facebook/observer</class>
151
+ <method>catalogProduct</method>
152
+ </social_facebook_code>
153
+ </observers>
154
+ </controller_action_predispatch_catalog_product_view>
155
+ </events>
156
+ </frontend>
157
+ </config>
app/code/community/Social/Facebook/etc/system.xml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <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>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <fields>
52
+ <enabled translate="label" module="social_facebook">
53
+ <label>Enable Facebook on Frontend</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>20</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
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>
96
+ <backend_model>social_facebook/facebuttons</backend_model>
97
+ <sort_order>70</sort_order>
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>
app/code/community/Social/Facebook/sql/social_facebook_setup/mysql4-install-1.5.0.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.5.0-1.5.0.1.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/frontend/base/default/layout/facebook.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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 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/action" name="social_facebook_action" as="social_facebook_action" template="social/facebook/action.phtml" />
39
+ <block type="social_facebook/box" name="social_facebook_box" as="social_facebook_box" template="social/facebook/box.phtml" />
40
+ </block>
41
+ </reference>
42
+ </catalog_product_view>
43
+
44
+ <review_product_list translate="label">
45
+ <reference name="head">
46
+ <action method="addCss"><stylesheet>css/facebook.css</stylesheet></action>
47
+ </reference>
48
+ <reference name="product.info.extrahint">
49
+ <block type="social_facebook/start" name="social_facebook_start" >
50
+ <block type="social_facebook/action" name="social_facebook_action" as="social_facebook_action" template="social/facebook/action.phtml" />
51
+ <block type="social_facebook/box" name="social_facebook_box" as="social_facebook_box" template="social/facebook/box.phtml" />
52
+ </block>
53
+ </reference>
54
+ </review_product_list>
55
+
56
+ <facebook_index_page translate="label">
57
+ <block type="social_facebook/head" name="social_facebook_head" template="social/facebook/page.phtml" />
58
+ </facebook_index_page>
59
+ </layout>
app/design/frontend/base/default/template/social/facebook/action.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_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; ?>
app/design/frontend/base/default/template/social/facebook/box.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 || count($this->getFriendBox($action['action'])) < 1): ?>
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; ?>
app/design/frontend/base/default/template/social/facebook/empty.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_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>
app/design/frontend/base/default/template/social/facebook/page.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Head */
28
+ ?>
29
+ <html>
30
+ <head prefix="og: http://ogp.me/ns# <?php echo $this->getAppName()?>: http://ogp.me/ns/apps/<?php echo $this->getAppName()?>#">
31
+ <?php if ($this->getMetaTags() && is_array($this->getMetaTags())): ?>
32
+ <?php foreach ($this->getMetaTags() as $tag): ?>
33
+ <meta<?php if (isset($tag['name'])): ?> name="<?php echo $this->escapeHtml($tag['name']) ?>"<?php endif; ?><?php if (isset($tag['property'])): ?> property="<?php echo $this->escapeHtml($tag['property']) ?>"<?php endif; ?><?php if (isset($tag['content'])): ?> content="<?php echo $this->escapeHtml($tag['content']) ?>"<?php endif; ?> />
34
+ <?php endforeach; ?>
35
+ <?php endif; ?>
36
+ </head>
37
+ <body>
38
+ <script type="text/javascript">
39
+ //<![CDATA[
40
+ window.location = '<?php echo $this->getRedirectUrl()?>';
41
+ //]]>
42
+ </script>
43
+ </body>
44
+ </html>
app/etc/modules/Social_Facebook.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-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
+ * @category Phoenix
17
+ * @package Phoenix_Moneybookers
18
+ * @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Social_Facebook>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ <depends>
28
+ <Mage_Catalog/>
29
+ </depends>
30
+ </Social_Facebook>
31
+ </modules>
32
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Social_Facebook</name>
4
+ <version>1.5.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.10.0.0 or later, and Magento Community Edition 1.5.0.0 or later.</notes>
12
+ <authors><author><name>Magento Core Team</name><user>core</user><email>core@magentocommerce.com</email></author></authors>
13
+ <date>2011-10-19</date>
14
+ <time>13:10:51</time>
15
+ <contents><target name="magecommunity"><dir name="Social"><dir name="Facebook"><dir name="Block"><file name="Action.php" hash="2a195319b750004552da18e082cb8184"/><dir name="Adminhtml"><file name="Facebuttons.php" hash="d73d32ba2b900e00e9705608b203b502"/><file name="Select.php" hash="036c43ac96033cf26c32e14884b83a6b"/></dir><file name="Box.php" hash="516adc472c9bf244cc4e1bfaa9c72969"/><file name="Head.php" hash="dbb35ead2ed9b6444e552335efd678e4"/><file name="Like.php" hash="3d1eb6c1c4f0e1dafdd1f90bdf54183e"/><file name="Start.php" hash="2e61c7814dc9c7c23d34c1e8ed74c518"/></dir><dir name="Helper"><file name="Data.php" hash="4997be7dfb07b5967ddc3d783c7c3ade"/></dir><dir name="Model"><file name="Api.php" hash="52c453a2fe92e84efbbe63a3eea63d6a"/><file name="Facebook.php" hash="788881a98c74b692b75680689c52e6a5"/><file name="Facebuttons.php" hash="f15aa66ba13f5977adf09b067f0fa3d9"/><dir name="Mysql4"><dir name="Facebook"><file name="Collection.php" hash="dc4fcda1d7c351876eeca1e439ba723d"/></dir><file name="Facebook.php" hash="f15b9ae8739da03fe6ab68cac466339f"/></dir><file name="Observer.php" hash="168c3c3a9ae234f7f491bbf654e83d91"/></dir><dir name="controllers"><file name="IndexController.php" hash="da8bfd193c2cc8087bf2db946504d2b6"/></dir><dir name="etc"><file name="config.xml" hash="8bf99f25f31981531661fc6d0671d85e"/><file name="system.xml" hash="2717316adc05041cc7c9eaa36dfc6ef5"/></dir><dir name="sql"><dir name="social_facebook_setup"><file name="mysql4-install-1.5.0.php" hash="ee195ec6e7b57830ced3f3c4a2a41233"/><file name="mysql4-upgrade-1.5.0-1.5.0.1.php" hash="63a0f7a199dd72e782d1f28dbfbbadb6"/></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="27e827abf0bfb795d5a8b6db7ec48c95"/></dir><dir name="template"><dir name="social"><dir name="facebook"><file name="action.phtml" hash="9d12c6e116652f0fc5bf5b516e07b0af"/><file name="box.phtml" hash="2ca758ee05423fad428770ca47e33384"/><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="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="facebook.css" hash="732ee944e67155fc9c5aabd5282dd93f"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/facebook.css ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Academic Free License (AFL 3.0)
7
+ * that is bundled with this package in the file LICENSE_AFL.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/afl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
17
+ * versions in the future. If you wish to customize Magento for your
18
+ * needs please refer to http://www.magentocommerce.com for more information.
19
+ *
20
+ * @category design
21
+ * @package base_default
22
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
23
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
+ */
25
+ .fb_image {
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
+ }