Version Notes
Stable
Download this release
Release Info
| Developer | Sasha |
| Extension | test_22 |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Social/Facebook/Block/Action.php +58 -0
- app/code/community/Social/Facebook/Block/Adminhtml/Facebuttons.php +84 -0
- app/code/community/Social/Facebook/Block/Adminhtml/Select.php +41 -0
- app/code/community/Social/Facebook/Block/Box.php +70 -0
- app/code/community/Social/Facebook/Block/Head.php +80 -0
- app/code/community/Social/Facebook/Block/Like.php +24 -0
- app/code/community/Social/Facebook/Block/Start.php +80 -0
- app/code/community/Social/Facebook/Helper/Data.php +136 -0
- app/code/community/Social/Facebook/Model/Api.php +255 -0
- app/code/community/Social/Facebook/Model/Facebook.php +314 -0
- app/code/community/Social/Facebook/Model/Facebuttons.php +56 -0
- app/code/community/Social/Facebook/Model/Observer.php +121 -0
- app/code/community/Social/Facebook/Model/Resource/Facebook.php +129 -0
- app/code/community/Social/Facebook/Model/Resource/Facebook/Collection.php +44 -0
- app/code/community/Social/Facebook/Model/Resource/Setup.php +35 -0
- app/code/community/Social/Facebook/controllers/IndexController.php +101 -0
- app/code/community/Social/Facebook/etc/adminhtml.xml +49 -0
- app/code/community/Social/Facebook/etc/config.xml +125 -0
- app/code/community/Social/Facebook/etc/system.xml +108 -0
- app/code/community/Social/Facebook/sql/social_facebook_setup/install-1.6.0.0.php +56 -0
- app/code/community/Social/Facebook/sql/social_facebook_setup/upgrade-1.6.0.0-1.6.0.1.php +39 -0
- package.xml +18 -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,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
} catch (Exception $e) {
|
| 217 |
+
Mage::getSingleton('core/session')->addError(
|
| 218 |
+
Mage::helper('social_facebook')->__('Cannot Get Facebook Access Token')
|
| 219 |
+
);
|
| 220 |
+
Mage::logException($e);
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
if (!empty($this->_accessToken)) {
|
| 224 |
+
$session->setData('access_token', $this->_accessToken);
|
| 225 |
+
if (!empty($facebookCode)) {
|
| 226 |
+
Mage::app()->getResponse()->setRedirect($productUrl);
|
| 227 |
+
Mage::app()->getResponse()->sendResponse();
|
| 228 |
+
exit();
|
| 229 |
+
}
|
| 230 |
+
return $this->_accessToken;
|
| 231 |
+
} else {
|
| 232 |
+
$session->unsetData('access_token');
|
| 233 |
+
$session->unsetData('facebook_action');
|
| 234 |
+
return false;
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* Send Facebook Action
|
| 240 |
+
*
|
| 241 |
+
* @return mixed
|
| 242 |
+
*/
|
| 243 |
+
public function sendFacebookAction()
|
| 244 |
+
{
|
| 245 |
+
try {
|
| 246 |
+
if (!$this->getAccessToken()) {
|
| 247 |
+
return false;
|
| 248 |
+
}
|
| 249 |
+
$action = $this->getApi()->sendFacebookAction();
|
| 250 |
+
} catch (Mage_Core_Exception $e) {
|
| 251 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 252 |
+
} catch (Exception $e) {
|
| 253 |
+
$action = Mage::getSingleton('core/session')->getData('facebook_action');
|
| 254 |
+
Mage::getSingleton('core/session')->addError(
|
| 255 |
+
Mage::helper('social_facebook')->__('Cannot Make "%s" Action. Please, try later.', $action)
|
| 256 |
+
);
|
| 257 |
+
Mage::logException($e);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
return $action;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
/**
|
| 264 |
+
* Get Facebook Friends
|
| 265 |
+
*
|
| 266 |
+
* @return mixed
|
| 267 |
+
*/
|
| 268 |
+
public function getFacebookFriends()
|
| 269 |
+
{
|
| 270 |
+
try {
|
| 271 |
+
if (!$this->getAccessToken()) {
|
| 272 |
+
return false;
|
| 273 |
+
}
|
| 274 |
+
$friends = $this->getApi()->getFacebookFriends();
|
| 275 |
+
} catch (Mage_Core_Exception $e) {
|
| 276 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 277 |
+
} catch (Exception $e) {
|
| 278 |
+
Mage::getSingleton('core/session')->addError(
|
| 279 |
+
Mage::helper('social_facebook')->__('Cannot Get Your Facebook Friends')
|
| 280 |
+
);
|
| 281 |
+
Mage::logException($e);
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
return $friends;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* Get Facebook User
|
| 289 |
+
*
|
| 290 |
+
* @return mixed
|
| 291 |
+
*/
|
| 292 |
+
public function getFacebookUser()
|
| 293 |
+
{
|
| 294 |
+
try {
|
| 295 |
+
if (!$this->getAccessToken()) {
|
| 296 |
+
return false;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
$user = $this->getApi()->getFacebookUser();
|
| 300 |
+
if ($user) {
|
| 301 |
+
Mage::getSingleton('core/session')->setData('facebook_id', $user['facebook_id']);
|
| 302 |
+
}
|
| 303 |
+
} catch (Mage_Core_Exception $e) {
|
| 304 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 305 |
+
} catch (Exception $e) {
|
| 306 |
+
Mage::getSingleton('core/session')->addError(
|
| 307 |
+
Mage::helper('social_facebook')->__('Cannot Get Facebook User')
|
| 308 |
+
);
|
| 309 |
+
Mage::logException($e);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
return $user;
|
| 313 |
+
}
|
| 314 |
+
}
|
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/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/Model/Resource/Facebook.php
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 resource
|
| 29 |
+
*
|
| 30 |
+
* @category Social
|
| 31 |
+
* @package Social_Facebook
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Social_Facebook_Model_Resource_Facebook extends Mage_Core_Model_Resource_Db_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/Resource/Facebook/Collection.php
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 collection
|
| 29 |
+
*
|
| 30 |
+
* @category Social
|
| 31 |
+
* @package Social_Facebook
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Social_Facebook_Model_Resource_Facebook_Collection
|
| 35 |
+
extends Mage_Core_Model_Resource_Db_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/Resource/Setup.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 module setup
|
| 29 |
+
*
|
| 30 |
+
* @category Social
|
| 31 |
+
* @package Social_Facebook
|
| 32 |
+
*/
|
| 33 |
+
class Social_Facebook_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup
|
| 34 |
+
{
|
| 35 |
+
}
|
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/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>Facebook Section</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
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.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 |
+
<social_facebook_setup>
|
| 51 |
+
<setup>
|
| 52 |
+
<module>Social_Facebook</module>
|
| 53 |
+
<class>Social_Facebook_Model_Resource_Setup</class>
|
| 54 |
+
</setup>
|
| 55 |
+
</social_facebook_setup>
|
| 56 |
+
</resources>
|
| 57 |
+
<blocks>
|
| 58 |
+
<social_facebook>
|
| 59 |
+
<class>Social_Facebook_Block</class>
|
| 60 |
+
</social_facebook>
|
| 61 |
+
</blocks>
|
| 62 |
+
<helpers>
|
| 63 |
+
<social_facebook>
|
| 64 |
+
<class>Social_Facebook_Helper</class>
|
| 65 |
+
</social_facebook>
|
| 66 |
+
</helpers>
|
| 67 |
+
</global>
|
| 68 |
+
<admin>
|
| 69 |
+
<routers>
|
| 70 |
+
<adminhtml>
|
| 71 |
+
<args>
|
| 72 |
+
<modules>
|
| 73 |
+
<social_facebook before="Mage_Adminhtml">Social_Facebook_Adminhtml</social_facebook>
|
| 74 |
+
</modules>
|
| 75 |
+
</args>
|
| 76 |
+
</adminhtml>
|
| 77 |
+
</routers>
|
| 78 |
+
</admin>
|
| 79 |
+
<adminhtml>
|
| 80 |
+
<layout>
|
| 81 |
+
<updates>
|
| 82 |
+
<social_facebook>
|
| 83 |
+
<file>facebook.xml</file>
|
| 84 |
+
</social_facebook>
|
| 85 |
+
</updates>
|
| 86 |
+
</layout>
|
| 87 |
+
</adminhtml>
|
| 88 |
+
<frontend>
|
| 89 |
+
<layout>
|
| 90 |
+
<updates>
|
| 91 |
+
<social_facebook>
|
| 92 |
+
<file>facebook.xml</file>
|
| 93 |
+
</social_facebook>
|
| 94 |
+
</updates>
|
| 95 |
+
</layout>
|
| 96 |
+
<translate>
|
| 97 |
+
<modules>
|
| 98 |
+
<Social_Facebook>
|
| 99 |
+
<files>
|
| 100 |
+
<default>Social_Facebook.csv</default>
|
| 101 |
+
</files>
|
| 102 |
+
</Social_Facebook>
|
| 103 |
+
</modules>
|
| 104 |
+
</translate>
|
| 105 |
+
<routers>
|
| 106 |
+
<social_facebook>
|
| 107 |
+
<use>standard</use>
|
| 108 |
+
<args>
|
| 109 |
+
<module>Social_Facebook</module>
|
| 110 |
+
<frontName>facebook</frontName>
|
| 111 |
+
</args>
|
| 112 |
+
</social_facebook>
|
| 113 |
+
</routers>
|
| 114 |
+
<events>
|
| 115 |
+
<controller_action_predispatch_catalog_product_view>
|
| 116 |
+
<observers>
|
| 117 |
+
<social_facebook_code>
|
| 118 |
+
<class>social_facebook/observer</class>
|
| 119 |
+
<method>catalogProduct</method>
|
| 120 |
+
</social_facebook_code>
|
| 121 |
+
</observers>
|
| 122 |
+
</controller_action_predispatch_catalog_product_view>
|
| 123 |
+
</events>
|
| 124 |
+
</frontend>
|
| 125 |
+
</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/install-1.6.0.0.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 |
+
/** @var $installer Social_Facebook_Model_Resource_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Create table 'social_facebook/facebook'
|
| 32 |
+
*/
|
| 33 |
+
$table = $installer->getConnection()
|
| 34 |
+
->newTable($installer->getTable('social_facebook/facebook'))
|
| 35 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 36 |
+
'identity' => true,
|
| 37 |
+
'unsigned' => true,
|
| 38 |
+
'nullable' => false,
|
| 39 |
+
'primary' => true,
|
| 40 |
+
), 'Entity Id')
|
| 41 |
+
->addColumn('facebook_id', Varien_Db_Ddl_Table::TYPE_TEXT, 100, array(
|
| 42 |
+
'nullable' => false,
|
| 43 |
+
), 'Facebook User Id')
|
| 44 |
+
->addColumn('facebook_name', Varien_Db_Ddl_Table::TYPE_TEXT, 100, array(
|
| 45 |
+
'nullable' => false,
|
| 46 |
+
), 'Facebook User Name')
|
| 47 |
+
->addColumn('facebook_action', Varien_Db_Ddl_Table::TYPE_SMALLINT, 5, array(
|
| 48 |
+
'unsigned' => true,
|
| 49 |
+
'nullable' => false,
|
| 50 |
+
), 'User Action')
|
| 51 |
+
->addColumn('item_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 52 |
+
'unsigned' => true,
|
| 53 |
+
'nullable' => false,
|
| 54 |
+
), 'Product Id')
|
| 55 |
+
->setComment('Social Facebook Actions');
|
| 56 |
+
$installer->getConnection()->createTable($table);
|
app/code/community/Social/Facebook/sql/social_facebook_setup/upgrade-1.6.0.0-1.6.0.1.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/** @var $installer Social_Facebook_Model_Resource_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
|
| 30 |
+
$installer->getConnection()->modifyColumn(
|
| 31 |
+
$installer->getTable('social_facebook/facebook'),
|
| 32 |
+
'facebook_action',
|
| 33 |
+
array(
|
| 34 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 35 |
+
'length' => 100,
|
| 36 |
+
'nullable' => false,
|
| 37 |
+
'comment' => 'User Action'
|
| 38 |
+
)
|
| 39 |
+
);
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>test_22</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>gsdrfe</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Summary</summary>
|
| 10 |
+
<description>The same</description>
|
| 11 |
+
<notes>Stable</notes>
|
| 12 |
+
<authors><author><name>Sasha</name><user>usatyi</user><email>ousatyi@ebay.com</email></author></authors>
|
| 13 |
+
<date>2012-05-07</date>
|
| 14 |
+
<time>16:09:15</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir><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="8b6e4f4cecabe9bb247cf28b6bf5b111"/><file name="Facebuttons.php" hash="f15aa66ba13f5977adf09b067f0fa3d9"/><file name="Observer.php" hash="168c3c3a9ae234f7f491bbf654e83d91"/><dir name="Resource"><dir name="Facebook"><file name="Collection.php" hash="7e472319938814bf68d221bb1c40f294"/></dir><file name="Facebook.php" hash="ee24ca1592576f75404e6e99f9f91dd6"/><file name="Setup.php" hash="53e978ad7976c17ea9dab84b65217d79"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="da8bfd193c2cc8087bf2db946504d2b6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a32cfb60ca4d8a576ae086635318c704"/><file name="config.xml" hash="b29ba65fd8f8db796d1d67b4a8d68d01"/><file name="system.xml" hash="5e210bbfaa8e0dab376cc7a9ee52eedb"/></dir><dir name="sql"><dir name="social_facebook_setup"><file name="install-1.6.0.0.php" hash="e9b71dc811c2c510fc25a72beb928dea"/><file name="upgrade-1.6.0.0-1.6.0.1.php" hash="222c31c400b9632c561f6b147e28f6de"/></dir></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
