Version Notes
Auto Twitt
Download this release
Release Info
Developer | Magento Core Team |
Extension | magestore_autotwitt |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Magestore/Autotwitt/Helper/Data.php +6 -0
- app/code/community/Magestore/Autotwitt/Model/Autotwitt.php +63 -0
- app/code/community/Magestore/Autotwitt/etc/config.xml +95 -0
- app/code/community/Magestore/Autotwitt/etc/system.xml +138 -0
- app/etc/modules/Magestore_Autotwitt.xml +9 -0
- package.xml +18 -0
app/code/community/Magestore/Autotwitt/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Autotwitt_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Magestore/Autotwitt/Model/Autotwitt.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Autotwitt_Model_Autotwitt extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('autotwitt/autotwitt');
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
/*
|
13 |
+
|
14 |
+
*/
|
15 |
+
public function add_product_to_twitter($observer)
|
16 |
+
{
|
17 |
+
if (!Mage::getStoreConfig('autotwitt/general/enable'))
|
18 |
+
{
|
19 |
+
return;
|
20 |
+
}
|
21 |
+
|
22 |
+
if (!Mage::getStoreConfig('autotwitt/site_events/add_to_cart'))
|
23 |
+
{
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
$observer_data = $observer->getData();
|
28 |
+
$product = $observer_data['product'];
|
29 |
+
$prefix_text = Mage::getStoreConfig('autotwitt/general/prefix_text');
|
30 |
+
|
31 |
+
$tt_message = $prefix_text . " " . Mage::getBaseUrl() . 'catalog/product/view/id/' . $product->getId() . " " . $product->getName();
|
32 |
+
|
33 |
+
$this->postToTwitter($tt_message);
|
34 |
+
}
|
35 |
+
|
36 |
+
function postToTwitter($message){
|
37 |
+
$username = Mage::getStoreConfig('autotwitt/account/username');
|
38 |
+
$password = Mage::getStoreConfig('autotwitt/account/password');
|
39 |
+
|
40 |
+
$host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));
|
41 |
+
|
42 |
+
$ch = curl_init();
|
43 |
+
curl_setopt($ch, CURLOPT_URL, $host);
|
44 |
+
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
45 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
46 |
+
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
|
47 |
+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
48 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
49 |
+
|
50 |
+
$result = curl_exec($ch);
|
51 |
+
// Look at the returned header
|
52 |
+
$resultArray = curl_getinfo($ch);
|
53 |
+
|
54 |
+
curl_close($ch);
|
55 |
+
|
56 |
+
if($resultArray['http_code'] == "200"){
|
57 |
+
$twitter_status='Your message has been sended! <a href="http://twitter.com/'.$username.'">See your profile</a>';
|
58 |
+
} else {
|
59 |
+
$twitter_status="Error posting to Twitter. Retry";
|
60 |
+
}
|
61 |
+
return $twitter_status;
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Magestore/Autotwitt/etc/config.xml
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<default>
|
4 |
+
<autotwitt>
|
5 |
+
<general>
|
6 |
+
<enable>1</enable>
|
7 |
+
</general>
|
8 |
+
<site_events>
|
9 |
+
<view_product>1</view_product>
|
10 |
+
<add_to_cart>1</add_to_cart>
|
11 |
+
</site_events>
|
12 |
+
</autotwitt>
|
13 |
+
</default>
|
14 |
+
<modules>
|
15 |
+
<Magestore_Autotwitt>
|
16 |
+
<version>0.1.0</version>
|
17 |
+
</Magestore_Autotwitt>
|
18 |
+
</modules>
|
19 |
+
<frontend>
|
20 |
+
<routers>
|
21 |
+
<autotwitt>
|
22 |
+
<use>standard</use>
|
23 |
+
<args>
|
24 |
+
<module>Magestore_Autotwitt</module>
|
25 |
+
<frontName>autotwitt</frontName>
|
26 |
+
</args>
|
27 |
+
</autotwitt>
|
28 |
+
</routers>
|
29 |
+
|
30 |
+
|
31 |
+
<events>
|
32 |
+
<checkout_cart_product_add_after>
|
33 |
+
<observers>
|
34 |
+
<magestore_autotwitt_observer>
|
35 |
+
<type>singleton</type>
|
36 |
+
<class>autotwitt/autotwitt</class>
|
37 |
+
<method>add_product_to_twitter</method>
|
38 |
+
</magestore_autotwitt_observer>
|
39 |
+
</observers>
|
40 |
+
</checkout_cart_product_add_after>
|
41 |
+
|
42 |
+
<catalog_controller_product_view>
|
43 |
+
<observers>
|
44 |
+
<magestore_autotwitt_observer>
|
45 |
+
<type>singleton</type>
|
46 |
+
<class>autotwitt/autotwitt</class>
|
47 |
+
<method>add_product_to_twitter</method>
|
48 |
+
</magestore_autotwitt_observer>
|
49 |
+
</observers>
|
50 |
+
</catalog_controller_product_view>
|
51 |
+
</events>
|
52 |
+
</frontend>
|
53 |
+
|
54 |
+
<adminhtml>
|
55 |
+
|
56 |
+
<acl>
|
57 |
+
<resources>
|
58 |
+
<all>
|
59 |
+
<title>Allow Everything</title>
|
60 |
+
</all>
|
61 |
+
<admin>
|
62 |
+
<children>
|
63 |
+
<system>
|
64 |
+
<children>
|
65 |
+
<config>
|
66 |
+
<children>
|
67 |
+
<autotwitt translate="title" >
|
68 |
+
<title>Magestore</title>
|
69 |
+
<sort_order>50</sort_order>
|
70 |
+
</autotwitt>
|
71 |
+
</children>
|
72 |
+
</config>
|
73 |
+
</children>
|
74 |
+
</system>
|
75 |
+
|
76 |
+
</children>
|
77 |
+
</admin>
|
78 |
+
</resources>
|
79 |
+
</acl>
|
80 |
+
|
81 |
+
</adminhtml>
|
82 |
+
<global>
|
83 |
+
<models>
|
84 |
+
<autotwitt>
|
85 |
+
<class>Magestore_Autotwitt_Model</class>
|
86 |
+
<resourceModel>autotwitt_mysql4</resourceModel>
|
87 |
+
</autotwitt>
|
88 |
+
</models>
|
89 |
+
<helpers>
|
90 |
+
<autotwitt>
|
91 |
+
<class>Magestore_Autotwitt_Helper</class>
|
92 |
+
</autotwitt>
|
93 |
+
</helpers>
|
94 |
+
</global>
|
95 |
+
</config>
|
app/code/community/Magestore/Autotwitt/etc/system.xml
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Mage
|
23 |
+
* @package Mage_GiftMessage
|
24 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
<config>
|
29 |
+
<tabs>
|
30 |
+
<magestore translate="label">
|
31 |
+
<label>Magestore Extension</label>
|
32 |
+
<sort_order>400</sort_order>
|
33 |
+
</magestore>
|
34 |
+
</tabs>
|
35 |
+
<sections>
|
36 |
+
<autotwitt translate="label" module="autotwitt">
|
37 |
+
<class>separator-top</class>
|
38 |
+
<label>Auto Twitt</label>
|
39 |
+
<tab>magestore</tab>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>300</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
<groups>
|
46 |
+
<general translate="label">
|
47 |
+
<label>General Configuration</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>1</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>0</show_in_store>
|
53 |
+
<fields>
|
54 |
+
<enable translate="label">
|
55 |
+
<label>Enable AutoTwitt</label>
|
56 |
+
<frontend_type>select</frontend_type>
|
57 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
58 |
+
<sort_order>1</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>1</show_in_website>
|
61 |
+
<show_in_store>1</show_in_store>
|
62 |
+
</enable>
|
63 |
+
|
64 |
+
<prefix_text translate="label">
|
65 |
+
<label>Text Before Product Link</label>
|
66 |
+
<frontend_type>text</frontend_type>
|
67 |
+
<sort_order>2</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
</prefix_text>
|
72 |
+
</fields>
|
73 |
+
</general>
|
74 |
+
|
75 |
+
<site_events translate="label">
|
76 |
+
<label>Event to sumit product on Twitter</label>
|
77 |
+
<frontend_type>text</frontend_type>
|
78 |
+
<sort_order>2</sort_order>
|
79 |
+
<show_in_default>1</show_in_default>
|
80 |
+
<show_in_website>1</show_in_website>
|
81 |
+
<show_in_store>0</show_in_store>
|
82 |
+
<fields>
|
83 |
+
<view_product translate="label">
|
84 |
+
<label>View Product Page</label>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
+
<sort_order>1</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>1</show_in_website>
|
90 |
+
<show_in_store>1</show_in_store>
|
91 |
+
</view_product>
|
92 |
+
|
93 |
+
<add_to_cart translate="label">
|
94 |
+
<label>After add a product to cart</label>
|
95 |
+
<frontend_type>select</frontend_type>
|
96 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
97 |
+
<sort_order>1</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 |
+
</add_to_cart>
|
102 |
+
</fields>
|
103 |
+
</site_events>
|
104 |
+
|
105 |
+
|
106 |
+
<account translate="label">
|
107 |
+
<label>Twitter Account</label>
|
108 |
+
<frontend_type>text</frontend_type>
|
109 |
+
<sort_order>3</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>0</show_in_store>
|
113 |
+
<fields>
|
114 |
+
<username translate="label">
|
115 |
+
<label>Twitter Username</label>
|
116 |
+
<frontend_type>text</frontend_type>
|
117 |
+
<sort_order>1</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>1</show_in_store>
|
121 |
+
</username>
|
122 |
+
|
123 |
+
<password translate="label">
|
124 |
+
<label>Twitter Password</label>
|
125 |
+
<frontend_type>text</frontend_type>
|
126 |
+
<sort_order>2</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>1</show_in_store>
|
130 |
+
</password>
|
131 |
+
</fields>
|
132 |
+
</account>
|
133 |
+
|
134 |
+
</groups>
|
135 |
+
</autotwitt>
|
136 |
+
|
137 |
+
</sections>
|
138 |
+
</config>
|
app/etc/modules/Magestore_Autotwitt.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magestore_Autotwitt>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Magestore_Autotwitt>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>magestore_autotwitt</name>
|
4 |
+
<version>0.1.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>Auto Twitt</summary>
|
10 |
+
<description>Auto Twitt</description>
|
11 |
+
<notes>Auto Twitt</notes>
|
12 |
+
<authors><author><name>Magestore</name><user>auto-converted</user><email>magestore@gmail.com</email></author></authors>
|
13 |
+
<date>2009-10-01</date>
|
14 |
+
<time>09:35:37</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Magestore"><dir name="Autotwitt"><dir name="etc"><file name="config.xml" hash="043ee16b2da0648b6778c3fb54b65b78"/><file name="system.xml" hash="fba3a2d5bec941a3e609eb9b9cb6de1c"/></dir><dir name="Helper"><file name="Data.php" hash="1177149d6a763585c7d3e910797f4ba1"/></dir><dir name="Model"><file name="Autotwitt.php" hash="a5e1df790eae3d769a96de5ef64ad220"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magestore_Autotwitt.xml" hash="f2d821ae029ef8bd53a99ced7cff94df"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|