IncentiBox_Communityrewards - Version 1.0.2

Version Notes

Initial release

Download this release

Release Info

Developer Magento Core Team
Extension IncentiBox_Communityrewards
Version 1.0.2
Comparing to
See all releases


Version 1.0.2

app/design/adminhtml/default/default/layout/communityrewards.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_communityrewards_index>
4
+ <reference name="content">
5
+ <block type="communityrewards/communityrewards" name="communityrewards_communityrewards"></block>
6
+ </reference>
7
+ </adminhtml_communityrewards_index>
8
+ </layout>
app/design/frontend/base/default/layout/communityrewards.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+
5
+ <default>
6
+ <reference name="before_body_end">
7
+ <block type="core/template" name="incentibox.footer.script" as="incentibox_footer_script" template="communityrewards/footer_script.phtml"/>
8
+ </reference>
9
+ </default>
10
+ </layout>
app/design/frontend/base/default/template/communityrewards/footer_script.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(Mage::getStoreConfig("communityrewards/communityrewards_settings/active")){ ?>
2
+ <?php $_programeId = Mage::getStoreConfig("communityrewards/communityrewards_settings/program_id"); ?>
3
+ <?php if($_programeId){?>
4
+ <script type='text/javascript'>
5
+ (function() {
6
+ var iBx = document.createElement('script'); iBx.type = 'text/javascript'; iBx.async = true; iBx.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.incentibox.com/ib.js?program_id=<?php echo $_programeId; ?>'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(iBx);
7
+ })();
8
+ </script>
9
+ <div class='incentibox_static' program_id='<?php echo $_programeId; ?>' style='position: fixed; top: 40px; right: 0px; z-index:100;'></div>
10
+ <?php } ?>
11
+ <?php } ?>
app/etc/modules/IncentiBox_Communityrewards.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <IncentiBox_Communityrewards>
6
+ <active>true</active>
7
+ <codePool>local</codePool>
8
+ </IncentiBox_Communityrewards>
9
+ </modules>
10
+ </config>
app/locale/en_US/IncentiBox_Communityrewards.csv ADDED
@@ -0,0 +1 @@
 
1
+ "Incentibox","Incentibox"
lib/Incentibox/incentibox_api.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ $Id: admin/includes/classes/incentibox_api.php,v 1.0.0 2011/07/10 awaage Exp $
4
+
5
+ CRE Loaded, Open Source E-Commerce Solutions
6
+ http://www.creloaded.com
7
+
8
+ Copyright (c) 2008 CRE Loaded
9
+ Copyright (c) 2003 osCommerce
10
+
11
+ Released under the GNU General Public License
12
+ */
13
+ class IncentiboxApi {
14
+ const DEBUG = false;
15
+ const INCENTIBOX_API_URL = 'http://api.incentibox.com';
16
+ const INCENTIBOX_API_PORT = 80;
17
+ const API_VERSION = '1';
18
+
19
+ private $password;
20
+ private $time_out = 60;
21
+ private $user_agent;
22
+ private $username;
23
+
24
+ // class methods
25
+ public function __construct($username = null, $password = null) {
26
+ if($username !== null) $this->set_username($username);
27
+ if($password !== null) $this->set_password($password);
28
+ }
29
+
30
+ private function perform_call($url, $params = array(), $authenticate = false, $use_post = true) {
31
+ // redefine
32
+ $url = (string) $url;
33
+ $aParameters = (array) $params;
34
+ $authenticate = (bool) $authenticate;
35
+ $use_post = (bool) $use_post;
36
+
37
+ // build url
38
+ $url = self::INCENTIBOX_API_URL .'/v'. self::API_VERSION . '/' . $url;
39
+
40
+ // validate needed authentication
41
+ if($authenticate && ($this->get_username() == '' || $this->get_password() == '')) {
42
+ throw new IncentiboxException('No username or password was set.');
43
+ }
44
+
45
+ // build GET URL if not using post
46
+ if(!empty($params) && !$use_post){
47
+ $url .= '?'. http_build_query( $params );
48
+ }
49
+
50
+ // set options
51
+ $options[CURLOPT_URL] = $url;
52
+ $options[CURLOPT_PORT] = self::INCENTIBOX_API_PORT;
53
+ $options[CURLOPT_USERAGENT] = $this->get_useragent();
54
+ $options[CURLOPT_FOLLOWLOCATION] = true;
55
+ $options[CURLOPT_RETURNTRANSFER] = true;
56
+ $options[CURLOPT_TIMEOUT] = (int) $this->get_time_out();
57
+
58
+ // HTTP basic auth
59
+ if($authenticate) {
60
+ $options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
61
+ $options[CURLOPT_USERPWD] = $this->get_username() .':'. $this->get_password();
62
+ }
63
+
64
+ // build post params if $use_post
65
+ if(!empty($params) && $use_post) {
66
+ $options[CURLOPT_POST] = true;
67
+ $options[CURLOPT_POSTFIELDS] = http_build_query( $params );
68
+ }
69
+
70
+ // curl init
71
+ $curl = curl_init();
72
+ // set options
73
+ curl_setopt_array($curl, $options);
74
+ // execute
75
+ $response = curl_exec($curl);
76
+ $headers = curl_getinfo($curl);
77
+ // fetch errors and status code
78
+ $errorNumber = curl_errno($curl);
79
+ $errorMessage = curl_error($curl);
80
+ $http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
81
+
82
+ if ($errorNumber != 0) {
83
+ $response = 'cURL ERROR: [' . $errorNumber . "] " . $errorMessage;
84
+ }
85
+ // close
86
+ curl_close($curl);
87
+ return array('response_code' => $http_status_code,
88
+ 'response' => $response);
89
+ }
90
+
91
+
92
+ // Getters
93
+ private function get_password(){
94
+ return (string) $this->password;
95
+ }
96
+ public function get_time_out(){
97
+ return (int) $this->time_out;
98
+ }
99
+ public function get_useragent(){
100
+ return (string) 'PHP IncentiBox API Client/'. self::API_VERSION .' '. $this->user_agent;
101
+ }
102
+ private function get_username(){
103
+ return (string) $this->username;
104
+ }
105
+
106
+ // Setters
107
+ private function set_username($username){
108
+ $this->username = (string) $username;
109
+ }
110
+ private function set_password($password){
111
+ $this->password = (string) $password;
112
+ }
113
+ public function set_time_out($seconds){
114
+ $this->time_out = (int) $seconds;
115
+ }
116
+ public function set_user_agent($user_agent){
117
+ $this->user_agent = (string) $user_agent;
118
+ }
119
+
120
+ /**
121
+ * Returns all redeemed_rewards for the given program_id.
122
+ * If param @last_redeemed_reward_id is given, returns all redeemed_rewards where id > @last_redeemed_reward_id
123
+ *
124
+ * @return array
125
+ * @param $program_id
126
+ * @param $last_redeemed_reward_id (optional)
127
+ */
128
+ public function get_redeemed_rewards($program_id, $last_redeemed_reward_id = null) {
129
+ // build url
130
+ $url = 'programs/'.urlencode($program_id).'/redeemed_rewards';
131
+ $url = ($last_redeemed_reward_id != null) ? $url . '/' . urlencode($last_redeemed_reward_id) : $url;
132
+
133
+ $response = $this->perform_call($url, array(), true, false);
134
+
135
+ $response_code = $response['response_code'];
136
+ $response = $response['response'];
137
+
138
+ // decode the returned json
139
+ if ($response_code == 200){
140
+ return json_decode($response,true);
141
+ } else {
142
+ throw new IncentiboxException($response_code . ' - ' . $response);
143
+ }
144
+ }
145
+ }
146
+
147
+
148
+ // IncentiboxException
149
+ class IncentiboxException extends Exception { }
150
+
151
+ ?>
package.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>IncentiBox_Communityrewards</name>
4
+ <version>1.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License 2.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Create a community rewards (loyalty) program for your Magento store and turn visitors into Brand Promoters.</summary>
10
+ <description>Magento social media login with incentiBox community rewards extension&#x2028;&#x2028;&#xD;
11
+ &#xD;
12
+ The Magento social media login with incentiBox community rewards extension allows you to create a community rewards (loyalty) program and incentivize your store visitors to promote your brand and your products. The extension will display a widget that enables participants to sign in to your Magento store via Facebook account, and incentivizes your customers and store-visitors to "like" your Facebook page, and share your products with their friends via social media (Facebook, Twitter, Tumblr, and 300+ others). In return, your customers will receive store credit, redeemable only at your store!&#x2028;&#x2028;&#xD;
13
+ &#xD;
14
+ Coupon codes are auto-generated, and will show up in the admin panel, so you can see how many coupons have been generated. Coupon codes and rewards program emails are customizable, as is the look and feel of the widget. The widget is collapsible, and can hover on the side of your store, to remind users to join your rewards program. &#xD;
15
+ &#xD;
16
+ &#x2028;&#x2028;Example: Give participants a $5 off coupon when they share about your products with their social networks. You gain valuable word-of-mouth advertising for your Magento store, AND generate additional sales when participants and their friends redeem their store credit!&#x2028;&#x2028;&#xD;
17
+ &#xD;
18
+ Notes: This extension interfaces with incentiBox, and communicates through the incentiBox API. For more information, and to sign up for incentiBox for API access, please see www.incentibox.com.</description>
19
+ <notes>Initial release</notes>
20
+ <authors><author><name>incentiBox</name><user>auto-converted</user><email>support@incentibox.com</email></author></authors>
21
+ <date>2011-09-29</date>
22
+ <time>22:12:15</time>
23
+ <contents><target name="magelib"><dir name="Incentibox"><file name="incentibox_api.php" hash="06490bf2d59166ab0ad4cec6f33d9398"/></dir></target><target name="magelocal"><dir name="IncentiBox"><dir name="Communityrewards"><dir name="Block"><dir name="Communityrewards"><file name="Grid.php" hash=""/></dir><file name="Communityrewards.php" hash=""/></dir><dir name="Helper"><file name="Data.php" hash=""/></dir><dir name="Model"><dir name="Mysql4"><dir name="Listener"><file name="Collection.php" hash=""/></dir><file name="Listener.php" hash=""/></dir><file name="Listener.php" hash=""/></dir><dir name="controllers"><file name="CommunityrewardsController.php" hash=""/><file name="ListenerController.php" hash=""/></dir><dir name="etc"><file name="adminhtml.xml" hash=""/><file name="config.xml" hash=""/><file name="system.xml" hash=""/></dir><dir name="sql"><dir name="communityrewards_setup"><file name="mysql4-install-1.0.1.php" hash=""/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="communityrewards.xml" hash="384dd484ddce3264fb17cfb107c02f9a"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="communityrewards.xml" hash="0bf6e0c40c944be8b51f0513bdd17a7f"/></dir><dir name="template"><dir name="communityrewards"><file name="footer_script.phtml" hash="4202d828ae1370916ba041c7bf4747f7"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="IncentiBox_Communityrewards.xml" hash="77b7740933f8020e6b23e541ccf00145"/></dir></target><target name="magelocale"><dir name="en_US"><file name="IncentiBox_Communityrewards.csv" hash="b957c5e9040d798f9ce2a838fce55ee8"/></dir></target></contents>
24
+ <compatible/>
25
+ <dependencies/>
26
+ </package>