Version Notes
Initial Release
Download this release
Release Info
Developer | Lexity |
Extension | Incentivibe |
Version | 1.3.1 |
Comparing to | |
See all releases |
Version 1.3.1
- app/code/local/Incentivibe/Block/Credentials/Form/Edit.php +23 -0
- app/code/local/Incentivibe/Block/Credentials/Form/Edit/Form.php +20 -0
- app/code/local/Incentivibe/Block/Credentials/Form/Edit/Tab/Form.php +47 -0
- app/code/local/Incentivibe/Block/Credentials/Form/Edit/Tabs.php +23 -0
- app/code/local/Incentivibe/Block/Embed.php +10 -0
- app/code/local/Incentivibe/Helper/Data.php +5 -0
- app/code/local/Incentivibe/Model/Core.php +183 -0
- app/code/local/Incentivibe/Model/Core/Api.php +18 -0
- app/code/local/Incentivibe/Model/Order/Api.php +95 -0
- app/code/local/Incentivibe/controllers/MarketingController.php +57 -0
- app/code/local/Incentivibe/etc/api.xml +22 -0
- app/code/local/Incentivibe/etc/config.xml +69 -0
- app/etc/modules/Incentivibe.xml +8 -0
- package.xml +44 -0
app/code/local/Incentivibe/Block/Credentials/Form/Edit.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Block_Credentials_Form_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
3 |
+
|
4 |
+
public function __construct() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit');
|
6 |
+
parent::__construct();
|
7 |
+
$this->_objectId = 'credentials';
|
8 |
+
$this->_blockGroup = 'inventivibe';
|
9 |
+
$this->_controller = 'credentials_form';
|
10 |
+
$this->_mode = 'edit';
|
11 |
+
$this->_removeButton('reset')
|
12 |
+
->_removeButton('back')
|
13 |
+
->_removeButton('save');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getHeaderText() {
|
17 |
+
Mage::log('Lexity: You got the header text');
|
18 |
+
return Mage::helper('inventivibe')->__('Account Information');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
app/code/local/Incentivibe/Block/Credentials/Form/Edit/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Block_Credentials_Form_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
3 |
+
|
4 |
+
protected function _prepareForm() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit Form');
|
6 |
+
$form = new Varien_Data_Form(array(
|
7 |
+
'id' => 'edit_form',
|
8 |
+
'action' => $this->getUrl(
|
9 |
+
'*/*/newapp',
|
10 |
+
array('credentials' => $this->getRequest()->getParam('credentials'))
|
11 |
+
),
|
12 |
+
'method' => 'post',
|
13 |
+
'enctype' => 'multipart/form-data'
|
14 |
+
));
|
15 |
+
|
16 |
+
$form->setUseContainer(true);
|
17 |
+
$this->setForm($form);
|
18 |
+
return parent::_prepareForm();
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Incentivibe/Block/Credentials/Form/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Block_Credentials_Form_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
3 |
+
|
4 |
+
protected function _prepareForm() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit Tab Form');
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
$fieldset = $form->addFieldset(
|
9 |
+
'form_form',
|
10 |
+
array('legend'=>Mage::helper('inventivibe')->__('Account Information')));
|
11 |
+
Mage::log('Lexity: fieldset');
|
12 |
+
$fieldset->addField('email', 'text', array(
|
13 |
+
'label' => Mage::helper('inventivibe')->__('Email'),
|
14 |
+
'class' => 'required-entry',
|
15 |
+
'required' => true,
|
16 |
+
'name' => 'email',
|
17 |
+
'value' => Mage::getSingleton('admin/session')->getUser()->getEmail(),
|
18 |
+
'tabindex' => 1
|
19 |
+
));
|
20 |
+
Mage::log('Lexity: addfield email');
|
21 |
+
$fieldset->addField('password', 'password', array(
|
22 |
+
'label' => Mage::helper('inventivibe')->__('Password'),
|
23 |
+
'class' => 'required-entry',
|
24 |
+
'required' => true,
|
25 |
+
'name' => 'password',
|
26 |
+
'after_element_html' => '<small>This is your Lexity account password</small>',
|
27 |
+
'tabindex' => 2
|
28 |
+
));
|
29 |
+
Mage::log('Lexity: addfield password');
|
30 |
+
$fieldset->addField('domain', 'text', array(
|
31 |
+
'label' => Mage::helper('inventivibe')->__('Domain'),
|
32 |
+
'class' => 'required-entry',
|
33 |
+
'required' => true,
|
34 |
+
'name' => 'domain',
|
35 |
+
'value' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
|
36 |
+
'readonly' => true,
|
37 |
+
'tabindex' => 3
|
38 |
+
));
|
39 |
+
Mage::log('Lexity: addfield domain');
|
40 |
+
$fieldset->addField('submit', 'submit', array(
|
41 |
+
'value' => 'Create Account',
|
42 |
+
'tabindex' => 4
|
43 |
+
));
|
44 |
+
Mage::log('Lexity: addfield submit');
|
45 |
+
return parent::_prepareForm();
|
46 |
+
}
|
47 |
+
}
|
app/code/local/Incentivibe/Block/Credentials/Form/Edit/Tabs.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Block_Credentials_Form_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
3 |
+
|
4 |
+
public function __construct() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit Tabs');
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('form_tabs');
|
8 |
+
// this should be same as the form id in Credentials_Form_Edit_Form.php
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('inventivibe')->__('Lexity Account'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml() {
|
14 |
+
Mage::log('Lexity: Writing form to html');
|
15 |
+
$this->addTab('form_section', array(
|
16 |
+
'label' => Mage::helper('inventivibe')->__('Account Information'),
|
17 |
+
'title' => Mage::helper('inventivibe')->__('Account Information'),
|
18 |
+
'content' => $this->getLayout()->createBlock('inventivibe/credentials_form_edit_tab_form')->toHtml(),
|
19 |
+
));
|
20 |
+
|
21 |
+
return parent::_beforeToHtml();
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Incentivibe/Block/Embed.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Block_Embed extends Mage_Adminhtml_Block_Template
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('inventivibe/embed.phtml');
|
8 |
+
}
|
9 |
+
}
|
10 |
+
?>
|
app/code/local/Incentivibe/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
?>
|
app/code/local/Incentivibe/Model/Core.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_Model_Core extends Mage_Core_Model_Config {
|
3 |
+
|
4 |
+
public $platform = 'magento';
|
5 |
+
|
6 |
+
public function report_error($errors) {
|
7 |
+
$message = 'An error has occured <br>';
|
8 |
+
foreach ($errors as $sub => $msg) {
|
9 |
+
$message .= $sub . ': ' . $msg . '<br>';
|
10 |
+
}
|
11 |
+
$message .= 'Please contact Lexity support for more assistance <br> '
|
12 |
+
.' support@lexity.com or 1-855-533-8144';
|
13 |
+
// Mage::getSingleton('core/session')->addError($message);
|
14 |
+
die($message);
|
15 |
+
}
|
16 |
+
|
17 |
+
public function has_lexity_user() {
|
18 |
+
$resource = Mage::getSingleton('core/resource');
|
19 |
+
$readConnection = $resource->getConnection('core_read');
|
20 |
+
$tableName = $resource->getTableName('api/user');
|
21 |
+
$results = $readConnection->fetchALL("SELECT * FROM api_user where username = 'lexity_incentivibe' LIMIT 1");
|
22 |
+
return isset($results[0]);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function get_api_key() {
|
26 |
+
if ($this->has_lexity_user()) {
|
27 |
+
$user = Mage::getModel('api/user');
|
28 |
+
$user->loadByUsername('lexity_incentivibe');
|
29 |
+
return $user->getApiKey();
|
30 |
+
} else {
|
31 |
+
return null;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function check_credentials() {
|
36 |
+
$token = $this->get_api_key();
|
37 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
38 |
+
$public_id = Mage::getStoreConfig('lexity/public_id');
|
39 |
+
$email = Mage::getStoreConfig('lexity/email');
|
40 |
+
if ($token == null && $public_id == null && $email == null) {
|
41 |
+
return 'getcredentials';
|
42 |
+
} else if (isset($public_id) && isset($email) && $token == null) {
|
43 |
+
return 'newapp';
|
44 |
+
} else {
|
45 |
+
return 'redirect';
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function create_account($email=null, $password=null) {
|
50 |
+
$token = md5(uniqid());
|
51 |
+
$errors = array();
|
52 |
+
if ($email == null) {
|
53 |
+
$email = Mage::getStoreConfig('lexity/email');
|
54 |
+
}
|
55 |
+
|
56 |
+
try {
|
57 |
+
$role = Mage::getModel('api/roles')
|
58 |
+
->setName('lexity_incentivibe')
|
59 |
+
->setPid(false)
|
60 |
+
// RoleType is either 'G' for group or 'U' for user since we create
|
61 |
+
// a new api and role for each app maybe we should change it to 'U'
|
62 |
+
->setRoleType('G')
|
63 |
+
->save();
|
64 |
+
} catch (Exception $e) {
|
65 |
+
$errors['Role'] = 'Api Role could not be made: ' . $e->getMessage();
|
66 |
+
}
|
67 |
+
|
68 |
+
try {
|
69 |
+
Mage::getModel("api/rules")
|
70 |
+
->setRoleId($role->getId())
|
71 |
+
->setResources(array('all'))
|
72 |
+
->saveRel();
|
73 |
+
} catch (Exception $e) {
|
74 |
+
$errors['Rule'] = 'Api Rule could not be made: ' . $e->getMessage();
|
75 |
+
}
|
76 |
+
$user = Mage::getModel('api/user');
|
77 |
+
$user->setData(array(
|
78 |
+
'username' => 'lexity_incentivibe',
|
79 |
+
'firstname' => 'lexity',
|
80 |
+
'lastname' => 'lexity',
|
81 |
+
'email' => 'support+incentivibe@lexity.com',
|
82 |
+
'api_key' => $token,
|
83 |
+
'api_key_confirmation' => $token,
|
84 |
+
'is_active' => 1,
|
85 |
+
'user_roles' => '',
|
86 |
+
'assigned_user_role' => '',
|
87 |
+
'role_name' => '',
|
88 |
+
'roles' => array($role->getId())
|
89 |
+
));
|
90 |
+
try {
|
91 |
+
$user->save()->load($user->getId());
|
92 |
+
$user->setRoleIds(array($role->getId()))
|
93 |
+
->setRoleUserId($user->getUserId())
|
94 |
+
->saveRelations();
|
95 |
+
} catch (Exception $e) {
|
96 |
+
$errors['User'] = 'Api User could not be made: ' . $e->getMessage();
|
97 |
+
}
|
98 |
+
|
99 |
+
$hash = $this->get_api_key();
|
100 |
+
$hash_array = explode(':', $hash);
|
101 |
+
if (count($hash_array) == 2) {
|
102 |
+
$skey = $hash_array[1];
|
103 |
+
}
|
104 |
+
|
105 |
+
$uri = "https://lexity.com/api/account/create?app="
|
106 |
+
. "incentivibe"
|
107 |
+
. "&platform=" . $this->platform . "&password=" . $token
|
108 |
+
. "&login=lexity_incentivibe"
|
109 |
+
. "&email=" . urlencode($email)
|
110 |
+
. "&url=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
111 |
+
if (isset($skey)) {
|
112 |
+
$uri .= "&skey=" . $skey;
|
113 |
+
}
|
114 |
+
if (isset($password)) {
|
115 |
+
// should I hash this password?...at least urlencode it
|
116 |
+
$uri .= "&user_password=" . urlencode($password);
|
117 |
+
}
|
118 |
+
// initiate handshake
|
119 |
+
$client = new Varien_Http_Client($uri);
|
120 |
+
$response = $client->request('GET');
|
121 |
+
$body = $response->getBody();
|
122 |
+
// interpret response
|
123 |
+
$decode = json_decode($body);
|
124 |
+
if (!isset($decode->error) && isset($decode->public_id)) {
|
125 |
+
$this->saveConfig('lexity/public_id', $decode->public_id);
|
126 |
+
$this->saveConfig('lexity/email', $email);
|
127 |
+
Mage::getConfig()->reinit();
|
128 |
+
Mage::app()->reinitStores();
|
129 |
+
} else {
|
130 |
+
$errors['Registration'] = $decode->error . '<br>' . $uri;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($errors) {
|
134 |
+
$this->report_error($errors);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
public function get_lexity_login_url($target = null) {
|
139 |
+
Mage::log('Lexity: getting lexity login url');
|
140 |
+
$errors = array();
|
141 |
+
$token = $this->get_api_key();
|
142 |
+
$token_array = explode(':', $token);
|
143 |
+
if (count($token_array) == 2) {
|
144 |
+
$token = $token_array[0];
|
145 |
+
} else {
|
146 |
+
$redirect['errors']['API User'] = 'token does not have hash key';
|
147 |
+
} // else the token has no skey
|
148 |
+
// Clean Cache
|
149 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
150 |
+
$public_id = Mage::getStoreConfig('lexity/public_id');
|
151 |
+
$email = Mage::getStoreConfig('lexity/email');
|
152 |
+
$redirect_url= "https://lexity.com/api/account/login?app="
|
153 |
+
. "incentivibe"
|
154 |
+
. "&platform=" . $this->platform . "&token=" . $token
|
155 |
+
. "&public_id=" . $public_id
|
156 |
+
. "&email=" . urlencode($email)
|
157 |
+
. "&domain=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
158 |
+
if (!empty($target)) {
|
159 |
+
$redirect_url .= "&target=${target}";
|
160 |
+
}
|
161 |
+
Mage::log('Lexity: this is the url: ' . $redirect_url);
|
162 |
+
try {
|
163 |
+
$client = new Varien_Http_Client($redirect_url);
|
164 |
+
$response = $client->request('GET');
|
165 |
+
$body = $response->getBody();
|
166 |
+
// interpret response
|
167 |
+
$decode = json_decode($body);
|
168 |
+
if (isset($decode->error)) {
|
169 |
+
Mage::log('Lexity: Error encountered while getting redirect');
|
170 |
+
$errors['Redirect URL'] = $decode->error . '<br>' . $redirect_url;
|
171 |
+
}
|
172 |
+
} catch (Exception $e) {
|
173 |
+
Mage::log('Lexity: Redirect successful');
|
174 |
+
}
|
175 |
+
|
176 |
+
if ($errors) {
|
177 |
+
$this->report_error($errors);
|
178 |
+
} else {
|
179 |
+
return $redirect_url;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
?>
|
app/code/local/Incentivibe/Model/Core/Api.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Incentivibe_Model_Core_Api extends Mage_Api_Model_Resource_Abstract
|
4 |
+
{
|
5 |
+
public function getMisc()
|
6 |
+
{
|
7 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
8 |
+
$js = Mage::getStoreConfig('design/head/includes');
|
9 |
+
return $js;
|
10 |
+
}
|
11 |
+
|
12 |
+
public function setMisc($js)
|
13 |
+
{
|
14 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
15 |
+
Mage::getModel('core/config')->saveConfig('design/head/includes', $js );
|
16 |
+
return array('status' => 'updated');
|
17 |
+
}
|
18 |
+
}
|
app/code/local/Incentivibe/Model/Order/Api.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Incentivibe_Model_Order_Api extends Mage_Sales_Model_Order_Api_V2
|
4 |
+
{
|
5 |
+
public function limiteditems($size='3',$page='1',$filters = null)
|
6 |
+
{
|
7 |
+
// Why the hell is this scoping brace here?!
|
8 |
+
{
|
9 |
+
//TODO: add full name logic
|
10 |
+
$billingAliasName = 'billing_o_a';
|
11 |
+
$shippingAliasName = 'shipping_o_a';
|
12 |
+
|
13 |
+
$collection = Mage::getModel("sales/order")->getCollection()
|
14 |
+
->addAttributeToSelect('*')
|
15 |
+
->addAddressFields()
|
16 |
+
->addExpressionFieldToSelect(
|
17 |
+
'billing_firstname', "{{billing_firstname}}", array('billing_firstname'=>"$billingAliasName.firstname")
|
18 |
+
)
|
19 |
+
->addExpressionFieldToSelect(
|
20 |
+
'billing_lastname', "{{billing_lastname}}", array('billing_lastname'=>"$billingAliasName.lastname")
|
21 |
+
)
|
22 |
+
->addExpressionFieldToSelect(
|
23 |
+
'shipping_firstname', "{{shipping_firstname}}", array('shipping_firstname'=>"$shippingAliasName.firstname")
|
24 |
+
)
|
25 |
+
->addExpressionFieldToSelect(
|
26 |
+
'shipping_lastname', "{{shipping_lastname}}", array('shipping_lastname'=>"$shippingAliasName.lastname")
|
27 |
+
)
|
28 |
+
->addExpressionFieldToSelect(
|
29 |
+
'billing_name',
|
30 |
+
"CONCAT({{billing_firstname}}, ' ', {{billing_lastname}})",
|
31 |
+
array('billing_firstname'=>"$billingAliasName.firstname", 'billing_lastname'=>"$billingAliasName.lastname")
|
32 |
+
)
|
33 |
+
->addExpressionFieldToSelect(
|
34 |
+
'shipping_name',
|
35 |
+
'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
|
36 |
+
array('shipping_firstname'=>"$shippingAliasName.firstname", 'shipping_lastname'=>"$shippingAliasName.lastname")
|
37 |
+
)
|
38 |
+
->setPageSize($size)
|
39 |
+
->setCurPage($page);
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
$preparedFilters = array();
|
44 |
+
if (isset($filters->filter)) {
|
45 |
+
foreach ($filters->filter as $_filter) {
|
46 |
+
$preparedFilters[][$_filter->key] = $_filter->value;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
if (isset($filters->complex_filter)) {
|
51 |
+
foreach ($filters->complex_filter as $_filter) {
|
52 |
+
$_value = $_filter->value;
|
53 |
+
if (is_object($_value)) {
|
54 |
+
$preparedFilters[][$_filter->key] = array(
|
55 |
+
$_value->key => $_value->value
|
56 |
+
);
|
57 |
+
}
|
58 |
+
elseif (is_array($_value)) {
|
59 |
+
$preparedFilters[][$_filter->key] = array(
|
60 |
+
$_value['key'] => $_value['value']
|
61 |
+
);
|
62 |
+
}
|
63 |
+
else {
|
64 |
+
$preparedFilters[][$_filter->key] = $_value;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
if (!empty($preparedFilters)) {
|
70 |
+
try {
|
71 |
+
foreach ($preparedFilters as $preparedFilter) {
|
72 |
+
foreach ($preparedFilter as $field => $value) {
|
73 |
+
if (isset($this->_attributesMap['order'][$field])) {
|
74 |
+
$field = $this->_attributesMap['order'][$field];
|
75 |
+
}
|
76 |
+
|
77 |
+
$collection->addFieldToFilter($field, $value);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
catch (Mage_Core_Exception $e) {
|
82 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
$result = array();
|
87 |
+
|
88 |
+
foreach ($collection as $order) {
|
89 |
+
$result[] = $this->_getAttributes($order, 'order');
|
90 |
+
}
|
91 |
+
|
92 |
+
return $result;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
?>
|
app/code/local/Incentivibe/controllers/MarketingController.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Incentivibe_MarketingController extends Mage_Adminhtml_Controller_Action {
|
3 |
+
|
4 |
+
public $embed = false;
|
5 |
+
|
6 |
+
public function goLexityAction() {
|
7 |
+
$core = Mage::getModel('inventivibe/core');
|
8 |
+
$action = $core->check_credentials();
|
9 |
+
$this->_forward($action);
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getCredentialsAction() {
|
13 |
+
Mage::log('Lexity: forworded to getCredentialsAction');
|
14 |
+
$this->_title('Confirm Credentials');
|
15 |
+
$this->loadLayout()->_setActiveMenu('Marketing');
|
16 |
+
$block = $this->getLayout()->createBlock('inventivibe/credentials_form_edit');
|
17 |
+
$left_block = $this->getLayout()->createBlock('inventivibe/credentials_form_edit_tabs');
|
18 |
+
$this->_addContent($block)->_addLeft($left_block);
|
19 |
+
$this->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function newAppAction() {
|
23 |
+
Mage::log('Lexity: submitted to newAppAction');
|
24 |
+
$core = Mage::getModel('inventivibe/core');
|
25 |
+
if ($data = $this->getRequest()->getPost()) {
|
26 |
+
$email = $data['email'];
|
27 |
+
$password = $data['password'];
|
28 |
+
$core->create_account($email, $password);
|
29 |
+
} else {
|
30 |
+
$core->create_account();
|
31 |
+
}
|
32 |
+
$this->_forward('goLexity');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function redirectAction() {
|
36 |
+
$core = Mage::getModel('inventivibe/core');
|
37 |
+
if ($this->embed) {
|
38 |
+
$target = urlencode('admin/incentivibe?embed=true');
|
39 |
+
} else {
|
40 |
+
$target = null;
|
41 |
+
}
|
42 |
+
$url = $core->get_lexity_login_url($target);
|
43 |
+
if ($this->embed) {
|
44 |
+
Mage::log('Lexity: forwarded to embedAction');
|
45 |
+
Mage::register('embed_url', $url);
|
46 |
+
$this->_title('Incentivibe');
|
47 |
+
$this->loadLayout()->_setActiveMenu('Marketing');
|
48 |
+
$block = $this->getLayout()->createBlock('inventivibe/embed');
|
49 |
+
$this->_addContent($block);
|
50 |
+
$this->renderLayout();
|
51 |
+
} else {
|
52 |
+
Mage::log('Lexity: forwarded to redirectAction');
|
53 |
+
$this->getResponse()->setRedirect($url);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
?>
|
app/code/local/Incentivibe/etc/api.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<inventivibe_core translate="title" module="inventivibe">
|
6 |
+
<model>inventivibe/core_api</model>
|
7 |
+
<title>Lexity Core API</title>
|
8 |
+
<acl>inventivibe/core</acl>
|
9 |
+
<methods>
|
10 |
+
<getMisc translate="title" module="inventivibe">
|
11 |
+
<title>Get header scripts</title>
|
12 |
+
<method>getMisc</method>
|
13 |
+
</getMisc>
|
14 |
+
<setMisc translate="title" module="inventivibe">
|
15 |
+
<title>Set header scripts</title>
|
16 |
+
<method>setMisc</method>
|
17 |
+
</setMisc>
|
18 |
+
</methods>
|
19 |
+
</inventivibe_core>
|
20 |
+
</resources>
|
21 |
+
</api>
|
22 |
+
</config>
|
app/code/local/Incentivibe/etc/config.xml
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<inventivibe>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</inventivibe>
|
7 |
+
</modules>
|
8 |
+
<adminhtml>
|
9 |
+
<menu>
|
10 |
+
<Lexity translate="title">
|
11 |
+
<title>Marketing</title>
|
12 |
+
<children>
|
13 |
+
<inventivibe translate="title" module="inventivibe">
|
14 |
+
<title>Incentivibe</title>
|
15 |
+
<action>inventivibe/marketing/golexity</action>
|
16 |
+
<sort_order>0</sort_order>
|
17 |
+
</inventivibe>
|
18 |
+
</children>
|
19 |
+
<sort_order>900</sort_order>
|
20 |
+
</Lexity>
|
21 |
+
</menu>
|
22 |
+
</adminhtml>
|
23 |
+
<global>
|
24 |
+
<helpers>
|
25 |
+
<inventivibe>
|
26 |
+
<class>Incentivibe_Helper</class>
|
27 |
+
</inventivibe>
|
28 |
+
</helpers>
|
29 |
+
<models>
|
30 |
+
<inventivibe>
|
31 |
+
<class>Incentivibe_Model</class>
|
32 |
+
</inventivibe>
|
33 |
+
</models>
|
34 |
+
<blocks>
|
35 |
+
<inventivibe>
|
36 |
+
<class>Incentivibe_Block</class>
|
37 |
+
</inventivibe>
|
38 |
+
</blocks>
|
39 |
+
</global>
|
40 |
+
|
41 |
+
<admin>
|
42 |
+
<routers>
|
43 |
+
<inventivibe>
|
44 |
+
<use>admin</use>
|
45 |
+
<args>
|
46 |
+
<module>Incentivibe</module>
|
47 |
+
<frontName>inventivibe</frontName>
|
48 |
+
</args>
|
49 |
+
</inventivibe>
|
50 |
+
</routers>
|
51 |
+
</admin>
|
52 |
+
|
53 |
+
<adminhtml>
|
54 |
+
<menu>
|
55 |
+
<Lexity translate="title">
|
56 |
+
<title>Marketing</title>
|
57 |
+
<children>
|
58 |
+
<inventivibe translate="title" module="inventivibe">
|
59 |
+
<title>Incentivibe</title>
|
60 |
+
<action>inventivibe/marketing/golexity</action>
|
61 |
+
<sort_order>0</sort_order>
|
62 |
+
</inventivibe>
|
63 |
+
</children>
|
64 |
+
<sort_order>900</sort_order>
|
65 |
+
</Lexity>
|
66 |
+
</menu>
|
67 |
+
</adminhtml>
|
68 |
+
|
69 |
+
</config>
|
app/etc/modules/Incentivibe.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Incentivibe>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>local</codePool>
|
6 |
+
</Incentivibe>
|
7 |
+
</modules>
|
8 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Incentivibe</name>
|
4 |
+
<version>1.3.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>BSD License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Incentivibe specializes in shared giveaways for small businesses. With Incentivibe's Shared Giveaways, small businesses become co-sponsors of a great prize by sharing a fraction (e.g. $19.99) of the prize cost with other small businesses (free trial available), and offer their visitors a legitimate chance to win that prize.</summary>
|
10 |
+
<description>Incentivibe specializes in shared giveaways for small businesses. With Incentivibe's Shared Giveaways, small businesses become co-sponsors of a great prize by sharing a fraction (e.g. $19.99) of the prize cost with other small businesses (free trial available), and offer their visitors a legitimate chance to win that prize.
|
11 |
+

|
12 |
+
With a chance to win BIG prizes, your visitors and customers will be extremely motivated to take these actions:
|
13 |
+

|
14 |
+
*Subscribe to your newsletter
|
15 |
+
*Share your marketing messages in their social networks
|
16 |
+
*Tweet any message you want to their followers
|
17 |
+
*Follow you on Twitter
|
18 |
+
*Become your fan on Facebook
|
19 |
+
*And much more ..
|
20 |
+

|
21 |
+
45 seconds to set-up. We take care of all the legal and prize-distribution responsibilities, free, forever!!
|
22 |
+

|
23 |
+
First, you select the prize from our wide variety of prize options.
|
24 |
+
Then, you decide the required action you want your visitors and customers to take (i.e Subscribe to Newsletter, Like etc.), and what messages you want them to share in their social networks.
|
25 |
+
Voila! You’re set to go. We automatically integrate our app with your store with your company's name on it. Now every time a visitor will come to your website, they'll see the giveaway message and will be able to enter into the giveaway by taking your required actions through our tool. See screenshots for more detail.
|
26 |
+
Every client of ours has generated up to 400% more leads and up to $2500 worth of additional marketing while paying as little as $19.99 to co-sponsor a prize.
|
27 |
+

|
28 |
+
Business owners like yourself are already seeing tremendous results. See what they have to say about Incentivibe:
|
29 |
+

|
30 |
+
“Our company, Splashtop, wanted to increase our email subscribers and used Incentivibe as one of our strategies. It increased our followers and fans tremendously. I’d definitely use them again, and recommend it for all businesses that are budget conscious.”– Joanne D., SplashTop - Featured in NY times
|
31 |
+

|
32 |
+
"Incentivibe's model was cost-effective, and was very easy to implement and monitor. After seeing a 40% increase in our Facebook Page interaction, and a 25% increase in our blog traffic, we are excited to get started on our next contest." Steph G, Vidyard - Featured in Forbes
|
33 |
+

|
34 |
+
“The idea of paying a fraction of the amount for costly giveaway prizes by sharing the cost with others is just sheer brilliance. WizeNation generated a lot of traffic for the period of time the giveaway contest was taking place.”– Asim S., WizeNation
|
35 |
+

|
36 |
+
For any questions, concerns or issues, please don't hesitate to contact us at info@incentivibe.com or call us at 647-262-6877. We will reply ASAP.</description>
|
37 |
+
<notes>Initial Release</notes>
|
38 |
+
<authors><author><name>Lexity</name><user>lexity</user><email>support@lexity.com</email></author></authors>
|
39 |
+
<date>2013-07-02</date>
|
40 |
+
<time>17:39:31</time>
|
41 |
+
<contents><target name="magelocal"><dir name="Incentivibe"><dir name="Block"><dir name="Credentials"><dir name="Form"><dir name="Edit"><file name="Form.php" hash="f474348231fc5f2fbf55a088960c8dfe"/><dir name="Tab"><file name="Form.php" hash="fe505960ddd44b9d93be23f228b5c063"/></dir><file name="Tabs.php" hash="bdeb480aa420b2c39ed730f43aab7718"/></dir><file name="Edit.php" hash="f2f82146ba01e707bdd2ce402328de80"/></dir></dir><file name="Embed.php" hash="34659ee0bde3882e48df140fe757aa86"/></dir><dir name="Helper"><file name="Data.php" hash="8e1bd9769ef8aceedadfc4621eca7be8"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="a77a553ac4df826971b30d32146ba62f"/></dir><file name="Core.php" hash="7555a3cca59fd20555202f91d92b690f"/><dir name="Order"><file name="Api.php" hash="96490635b3c01115c9fa97e66600909b"/></dir></dir><dir name="controllers"><file name="MarketingController.php" hash="54e36d03763ef131acf8b248215dc595"/></dir><dir name="etc"><file name="api.xml" hash="2643e43d8079d913b86ec90037452e4c"/><file name="config.xml" hash="453e544dbe9e851c8259c7e3e7613ccd"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Incentivibe.xml" hash="b1a9b462fde762efa4e3adfa97c887c3"/></dir></target></contents>
|
42 |
+
<compatible/>
|
43 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
44 |
+
</package>
|