Facebook_store_application - Version 0.1.6

Version Notes

This module freely creates the Magento API required for importing your store into Facebook using StoreYa.

Download this release

Release Info

Developer Magento Core Team
Extension Facebook_store_application
Version 0.1.6
Comparing to
See all releases


Version 0.1.6

app/code/local/Akdev/Storeya/Block/Storeya.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Akdev_Storeya_Block_Storeya extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getStoreya()
10
+ {
11
+ if (!$this->hasData('storeya')) {
12
+ $this->setData('storeya', Mage::registry('storeya'));
13
+ }
14
+ return $this->getData('storeya');
15
+
16
+ }
17
+ }
app/code/local/Akdev/Storeya/Block/storeya.phtml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tbody><tr>
4
+ <td style="width: 50%;"><h3 class="icon-head head-notification">StoreYa</h3></td>
5
+ <td class="form-buttons"></td>
6
+ </tr>
7
+ </tbody></table>
8
+ </div>
9
+ <div>
10
+
11
+ <div id="notificationGrid">
12
+
13
+ <div id="notificationGrid_massaction">
14
+ <table cellspacing="0" cellpadding="0" class="massaction">
15
+ <tbody><tr>
16
+ <td>Create Api User&nbsp;</td>
17
+ <td>
18
+ <div class="right">
19
+ <div class="entry-edit">
20
+ <form method="post" id="notificationGrid_massaction-form" action="">
21
+ <div><input type="hidden" value="QPSXxWavarNAvn07" name="form_key"></div>
22
+ <fieldset>
23
+
24
+ <span class="field-row">
25
+ <button style="" onclick="setLocation('{{@@url@@}}')" class="scalable" type="button" id="btn-create-storeya"><span>Create API</span></button> </span>
26
+ </fieldset>
27
+ </form>
28
+ </div>
29
+
30
+
31
+ </div>
32
+ </td>
33
+ </tr>
34
+ </tbody></table>
35
+ </div>
36
+ <div class="grid">
37
+ <div class="hor-scroll">
38
+ <table cellspacing="0" id="notificationGrid_table" class="data">
39
+ <col width="20" class="a-center">
40
+ <col width="60">
41
+ <col width="150">
42
+ <col>
43
+ <col width="250">
44
+ <thead>
45
+ <!--
46
+ <tr class="headings">
47
+ <th><span class="nobr">&nbsp;</span></th>
48
+ <th><span class="nobr"><a class="not-sort" title="asc" name="severity" href="#"><span class="sort-title">Severity</span></a></span></th>
49
+ <th><span class="nobr"><a class="sort-arrow-desc" title="asc" name="date_added" href="#"><span class="sort-title">Date Added</span></a></span></th>
50
+ <th><span class="nobr"><a class="not-sort" title="asc" name="title" href="#"><span class="sort-title">Message</span></a></span></th>
51
+ <th class=" no-link last"><span class="nobr">Actions</span></th>
52
+ </tr>
53
+ -->
54
+ </thead>
55
+
56
+ <tbody id="">
57
+ <tr class="even" id="">
58
+ <td colspan="5" class="empty-text a-center">{{@@msg@@}}</td>
59
+ </tr>
60
+ </tbody>
61
+
62
+ </table>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
app/code/local/Akdev/Storeya/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Akdev_Storeya_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Akdev/Storeya/controllers/AdminController.php ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Akdev
5
+ * @package Akdev_Storeya
6
+ * @author AjayKwatra@gmail.com
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Akdev_Storeya_AdminController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+
13
+ private $apiKey = null;
14
+
15
+
16
+
17
+ protected function _initAction() {
18
+ $this->loadLayout()
19
+ ->_setActiveMenu('storeya/items');
20
+
21
+ return $this;
22
+ }
23
+
24
+ public function indexAction()
25
+ {
26
+
27
+ //create a text block with the name of "storya-block"
28
+ $this->loadLayout()->_setActiveMenu('storeya/items');
29
+ $filepath = Mage::getBaseDir('app').DS. 'code' .DS. 'local' .DS. 'Akdev' .DS. 'Storeya'.DS. 'Block' .DS. 'storeya.phtml';
30
+ $fileContent = file_get_contents($filepath);
31
+ $msg = '';
32
+ $msg = 'Api Not created Yet. Click on Create Button to do now.';
33
+
34
+ $isApiExits = $this->_checkApiExists();
35
+ if($isApiExits){
36
+
37
+ $siteUrl = 'http://www.storeya.com/createaccount'.$isApiExits;
38
+
39
+ $msg = 'API setup completed, please <a href="'.$siteUrl.'" target="_blank">click here </a> to start';
40
+ //$this->getResponse()->setRedirect($this->getUrl('storeya/admin/index'));
41
+ }
42
+
43
+
44
+ $fileContent = str_replace('{{@@url@@}}', $this->getUrl('storeya/admin/create')
45
+ ,$fileContent);
46
+ $fileContent = str_replace('{{@@msg@@}}',$msg,$fileContent);
47
+
48
+ //create a text block with the name of "storeya-block"
49
+ $block = $this->getLayout()
50
+ ->createBlock('core/text', 'storeya-block')
51
+ ->setText($fileContent);
52
+
53
+ $this->_addContent($block);
54
+
55
+ // $this->_initAction()->renderLayout();
56
+
57
+ $this->renderLayout();
58
+
59
+ }
60
+
61
+ public function createAction(){
62
+
63
+
64
+ //AK
65
+
66
+ $version = (string) substr(Mage::getVersion(),0,3);
67
+ //1.4.x.x
68
+ //1.5.1.0
69
+ //1.6.0.0
70
+
71
+ ## check storeya role is exists or not
72
+ $roleStoreyaExists = FALSE;
73
+ $objApiRole = Mage::getSingleton('api/roles');
74
+ $roleNames = $objApiRole->getCollection();
75
+ $roleNames->getSelect()->where('role_name=?','storeya');//storeya
76
+ $api_role_data = $roleNames->getData();
77
+
78
+ //->setId($id)->delete()
79
+ /*
80
+ echo '<pre>';
81
+ print_r($api_role_data);
82
+ die;
83
+ */
84
+
85
+ if(!empty($api_role_data)){
86
+ $roleStoreyaExists = TRUE;
87
+ //$objApiRole->setId($api_role_data[0]['role_id'])->delete();
88
+ }
89
+ ## check storeya api user is exists or not
90
+ $apiUserStoreyaExists = FALSE;
91
+ $objApiUser = Mage::getSingleton('api/user');
92
+ $apiUsernames = $objApiUser->getCollection();
93
+ $apiUsernames->getSelect()->where('username=?','storeya_api_user');//storeya_api_user
94
+ $api_user_data = $apiUsernames->getData();
95
+
96
+ if(!empty($api_user_data)){
97
+ $apiUserStoreyaExists = TRUE;
98
+ //$objApiUser->setId($api_user_data[0]['user_id'])->delete();
99
+ }
100
+
101
+ $this->apiKey = $this->_genRandomString();
102
+ $appDir = Mage::getBaseDir('app'); # /data/htdocs/magento15/app
103
+ //print_r(get_defined_constants());
104
+
105
+ switch($version){
106
+
107
+ case '1.4':
108
+ $var14_file_1 = '/code/core/Mage/Api/Model/Server/Adapter/Soap.php';
109
+ $txt_find = "\$this->fault('0', 'Unable to load Soap extension on the server');";
110
+ $txt_replace = "\$this->fault('0', 'Unable to load Soap extension on the server'); \n } ";
111
+
112
+ if(!file_exists($appDir . dirname($var14_file_1) . '/Soap_copy.php')){
113
+ copy($appDir . $var14_file_1 , $appDir . dirname($var14_file_1) . '/Soap_copy.php' );
114
+ }
115
+ $file_content = file_get_contents($appDir . $var14_file_1);
116
+ //if replace text not already there , then replace
117
+ if( strpos($file_content,$txt_replace) === FALSE ) {
118
+ $file_content = str_ireplace($txt_find,$txt_replace,$file_content);
119
+ file_put_contents($appDir . $var14_file_1,$file_content);
120
+ }
121
+
122
+
123
+ break;
124
+
125
+ case '1.5':
126
+ //app/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php
127
+ $var15_file_1 = '/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php';
128
+ $txt_find = "->setHeader('Content-Type','text/xml; charset='.\$apiConfigCharset)";
129
+ $txt_replace = "->setHeader('Content-Type','text/xml; charset='.\$apiConfigCharset, true)";
130
+
131
+ if(!file_exists($appDir . dirname($var15_file_1) . '/Soap_copy.php')){
132
+ copy($appDir . $var15_file_1 , $appDir . dirname($var15_file_1) . '/Soap_copy.php' );
133
+ }
134
+ $file_content = file_get_contents($appDir . $var15_file_1);
135
+
136
+ //if replace text not already there , then replace
137
+ if( strpos($file_content,$txt_replace) === FALSE ) {
138
+ $file_content = str_ireplace($txt_find,$txt_replace,$file_content);
139
+ file_put_contents($appDir . $var15_file_1,$file_content);
140
+ }
141
+
142
+
143
+
144
+ ## second file
145
+ $var15_file_2 = '/code/core/Mage/Api/Model/Server/Wsi/Adapter/Soap.php';
146
+
147
+ if(!file_exists($appDir . dirname($var15_file_2) . '/Soap_copy.php')){
148
+ copy($appDir . $var15_file_2 , $appDir . dirname($var15_file_2) . '/Soap_copy.php' );
149
+ }
150
+ $file_content = file_get_contents($appDir . $var15_file_2);
151
+
152
+ //if replace text not already there , then replace
153
+ if( strpos($file_content,$txt_replace) === FALSE ) {
154
+ $file_content = str_ireplace($txt_find,$txt_replace,$file_content);
155
+ file_put_contents($appDir . $var15_file_2, $file_content);
156
+ }
157
+
158
+
159
+ break;
160
+
161
+ //case '1.6':
162
+ //break;
163
+
164
+ default:
165
+ }
166
+
167
+ /*
168
+
169
+ if($apiUserStoreyaExists && $roleStoreyaExists){
170
+
171
+ /*
172
+ * Array
173
+ (
174
+ [0] => Array
175
+ (
176
+ [role_id] => 3
177
+ [parent_id] => 0
178
+ [tree_level] => 1
179
+ [sort_order] => 0
180
+ [role_type] => G
181
+ [user_id] => 0
182
+ [role_name] => admin
183
+ )
184
+
185
+ )
186
+
187
+
188
+
189
+ echo $api_user_data[0]['user_id'];
190
+ die('<br>jkjkkj');
191
+
192
+ //$roleNames->setApiKey($apiKey);
193
+ //$roleNames->save();
194
+
195
+ //$this->_setApiXml($api_user_data[0]['username'],$apiKey,$api_role_data[0]['role_id'],$api_user_data[0]['user_id']);
196
+
197
+
198
+
199
+ }
200
+
201
+ */
202
+
203
+ //die('dd');
204
+
205
+ if( ($roleStoreyaExists) && (!$apiUserStoreyaExists) )
206
+ {
207
+ $this->_bindApiRoleToUser($api_role_data[0]['role_id']);
208
+
209
+ }
210
+
211
+ if( (!$roleStoreyaExists) && ($apiUserStoreyaExists) )
212
+ {
213
+ //$this->_bindApiRoleToUser($api_role_data[0]['role_id']);
214
+ $this->_createStoreyaApiRoleUser(true,$api_user_data[0]['user_id']);//true - delete true to api user and create new
215
+ }
216
+
217
+ if( (!$roleStoreyaExists) && (!$apiUserStoreyaExists) )
218
+ {
219
+ $this->_createStoreyaApiRoleUser();
220
+
221
+ }
222
+
223
+
224
+ if( ($roleStoreyaExists) && ($apiUserStoreyaExists) ){
225
+
226
+ $this->getResponse()->setRedirect($this->getUrl('storeya/admin/index'));
227
+ return;
228
+
229
+ }
230
+
231
+
232
+ //Mage::app()->cleanCache();
233
+ //AK
234
+
235
+ $this->getResponse()->setRedirect($this->getUrl('storeya/admin/index'));
236
+ return;
237
+ //$this->_initAction()->renderLayout();
238
+
239
+
240
+ }
241
+
242
+ //check the api is created yet or not
243
+ public function _checkApiExists(){
244
+
245
+ $this->_resetXmlApi();
246
+
247
+ $xmlPath = Mage::getBaseDir('app').DS. 'code' .DS. 'local' .DS. 'Akdev' .DS. 'Storeya'.DS. 'etc' .DS. 'storeya_api.xml';
248
+ //$xmlObj = new Varien_Simplexml_Config($xmlPath);
249
+ //$xmlData = $this->xmlObj->getNode();
250
+ //print_r($xmlData);
251
+
252
+ //echo '<pre>';
253
+
254
+ $xmlObj = simplexml_load_file($xmlPath);
255
+
256
+ //$xmlObj->api_role_id = 22;
257
+ //$xmlContent = $xmlObj->asXML();
258
+ //file_put_contents($xmlPath,$xmlContent);
259
+ //ADHGTYUIOK
260
+ //print_r($xmlObj);
261
+ //die;
262
+
263
+ $storeyaApiKey = $xmlObj->api_key;
264
+ $storeyaApiUser = $xmlObj->api_username;
265
+
266
+ //chmod($xmlPath,0777);
267
+ //echo (int) is_writable($xmlPath);
268
+
269
+ //echo $storeyaApiKey;
270
+ //die('chk');
271
+
272
+ // $objConfig = Mage::getSingleton('core/config_data')->getCollection();
273
+ //$objConfig->getSelect()->where('path=?','web/unsecure/base_url');
274
+ //$configData = $objConfig->getData();
275
+ $shopUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
276
+ //$configData[0]['value'];
277
+
278
+
279
+ if($storeyaApiKey !=''){
280
+ //$this->getResponse()->setRedirect($this->getUrl('storeya/admin/index'));
281
+ return '?user='.$storeyaApiUser .'&amp;key=' .$storeyaApiKey.'&amp;shopurl='.$shopUrl;
282
+ }else{
283
+ return FALSE;
284
+ }
285
+
286
+ }
287
+
288
+
289
+ public function _checkApiRoleExists(){
290
+
291
+ ## check storeya role is exists or not
292
+ $roleStoreyaExists = FALSE;
293
+ $objApiRole = Mage::getSingleton('api/roles');
294
+ $roleNames = $objApiRole->getCollection();
295
+ $roleNames->getSelect()->where('role_name=?','storeya');//storeya
296
+ $api_role_data = $roleNames->getData();
297
+
298
+ return $api_role_data;
299
+
300
+ }
301
+
302
+ public function _checkApiUserExists(){
303
+
304
+
305
+ ## check storeya api user is exists or not
306
+ $apiUserStoreyaExists = FALSE;
307
+ $objApiUser = Mage::getSingleton('api/user');
308
+ $apiUsernames = $objApiUser->getCollection();
309
+ $apiUsernames->getSelect()->where('username=?','storeya_api_user');//storeya_api_user
310
+ $api_user_data = $apiUsernames->getData();
311
+
312
+ return $api_user_data;
313
+ }
314
+
315
+
316
+ public function _resetXmlApi(){
317
+
318
+ $api_role_data = $this->_checkApiRoleExists();
319
+ $api_user_data = $this->_checkApiUserExists();
320
+
321
+ if( (empty($api_role_data)) || (empty($api_user_data)) ) {
322
+
323
+ $xmlPath = Mage::getBaseDir('app').DS. 'code' .DS. 'local' .DS. 'Akdev' .DS. 'Storeya'.DS. 'etc' .DS. 'storeya_api.xml';
324
+ //$xmlObj = new Varien_Simplexml_Config($xmlPath);
325
+ $xmlObj = simplexml_load_file($xmlPath);
326
+ //$xmlObj->api_role_id = 22;
327
+ //$xmlContent = $xmlObj->asXML();
328
+ //file_put_contents($xmlPath,$xmlContent);
329
+
330
+
331
+ //$xmlObj->setNode('api_key','newkey');
332
+ $xmlObj->api_key = '';
333
+ $xmlObj->api_username = '';
334
+ $xmlObj->api_role_id = '';
335
+ $xmlObj->api_user_id = '';
336
+
337
+ $xmlContent = $xmlObj->asXML();
338
+ file_put_contents($xmlPath,$xmlContent);
339
+
340
+
341
+ }
342
+
343
+
344
+ }
345
+
346
+
347
+ public function _bindApiRoleToUser($roleId){
348
+
349
+ // echo $this->apiKey,$roleId;
350
+ // die('dsddd');
351
+
352
+ try{
353
+ //create api user
354
+ $user = Mage::getSingleton('api/user');
355
+ $user->setData(array(
356
+ 'username' => 'storeya_api_user',
357
+ 'firstname' => 'Api',
358
+ 'lastname' => 'User',
359
+ 'email' => 'support@storeya.com',
360
+ 'api_key' => $this->apiKey,
361
+ 'api_key_confirmation' => $this->apiKey,
362
+ 'is_active' => 1,
363
+ 'user_roles' => '',
364
+ 'assigned_user_role' => '',
365
+ 'role_name' => '',
366
+ 'roles' => array($roleId)
367
+ ));
368
+ $user->save()->load($user->getId());
369
+
370
+ $user->setRoleIds(array($roleId))
371
+ ->setRoleUserId($user->getUserId())
372
+ ->saveRelations();
373
+
374
+ $this->_setApiXml('storeya_api_user',$this->apiKey,$roleId,$user->getUserId());
375
+
376
+
377
+ return TRUE;
378
+
379
+ } catch (Exception $e){
380
+ //echo $e->getMessage();
381
+ // echo 'Unable to create now, please try again.';
382
+ return FALSE;
383
+
384
+ }
385
+
386
+ }
387
+
388
+ //check the api is created yet or not
389
+ public function _setApiXml($user,$key,$role_id,$user_id){
390
+
391
+ //echo 'kkkk:: ',$user,$key,$role_id,$user_id;
392
+ //die('dddd');
393
+
394
+ $xmlPath = Mage::getBaseDir('app').DS. 'code' .DS. 'local' .DS. 'Akdev' .DS. 'Storeya'.DS. 'etc' .DS. 'storeya_api.xml';
395
+ //$xmlObj = new Varien_Simplexml_Config($xmlPath);
396
+ $xmlObj = simplexml_load_file($xmlPath);
397
+ //$xmlObj->api_role_id = 22;
398
+ //$xmlContent = $xmlObj->asXML();
399
+ //file_put_contents($xmlPath,$xmlContent);
400
+
401
+
402
+ //$xmlObj->setNode('api_key','newkey');
403
+ $xmlObj->api_key = $key;
404
+ $xmlObj->api_username = $user;
405
+ $xmlObj->api_role_id = $role_id;
406
+ $xmlObj->api_user_id = $user_id;
407
+
408
+ $xmlContent = $xmlObj->asXML();
409
+ file_put_contents($xmlPath,$xmlContent);
410
+
411
+ $storeyaApiUser = $xmlObj->api_username;
412
+ $storeyaApiKey = $xmlObj->api_key;
413
+
414
+ if($storeyaApiKey !='' && $storeyaApiUser != ''){
415
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('storeya')->__('API setup completed'));
416
+ $this->getResponse()->setRedirect($this->getUrl('storeya/admin/index'));
417
+ return ;
418
+ }else{
419
+ return FALSE;
420
+ }
421
+
422
+ }
423
+
424
+ public function _createStoreyaApiRoleUser($delUser=false,$apiUserId=0){
425
+
426
+
427
+ try {
428
+
429
+ //create roles
430
+
431
+ $role = Mage::getSingleton('api/roles')
432
+ ->setName('storeya')
433
+ ->setPid(false)
434
+ ->setRoleType('G')
435
+ ->save();
436
+
437
+ Mage::getSingleton("api/rules")
438
+ ->setRoleId($role->getId())
439
+ ->setResources(array('all'))
440
+ ->saveRel();
441
+
442
+
443
+
444
+ //create api user
445
+ $user = Mage::getSingleton('api/user');
446
+
447
+ if($delUser)
448
+ {
449
+ $user->setId($apiUserId)->delete();
450
+ }
451
+
452
+ $user->setData(array(
453
+ 'username' => 'storeya_api_user',
454
+ 'firstname' => 'Api',
455
+ 'lastname' => 'User',
456
+ 'email' => 'support@storeya.com',
457
+ 'api_key' => $this->apiKey,
458
+ 'api_key_confirmation' => $this->apiKey,
459
+ 'is_active' => 1,
460
+ 'user_roles' => '',
461
+ 'assigned_user_role' => '',
462
+ 'role_name' => '',
463
+ 'roles' => array($role->getId())
464
+ ));
465
+ $user->save()->load($user->getId());
466
+
467
+ $user->setRoleIds(array($role->getId()))
468
+ ->setRoleUserId($user->getUserId())
469
+ ->saveRelations();
470
+
471
+ $this->_setApiXml('storeya_api_user',$this->apiKey,$role->getId(),$user->getUserId());
472
+
473
+
474
+ return TRUE;
475
+
476
+ } catch (Exception $e){
477
+ //echo $e->getMessage();
478
+ // echo 'Unable to create now, please try again.';
479
+ return FALSE;
480
+ }
481
+
482
+
483
+ }
484
+
485
+
486
+ //ak api key random generator
487
+ private function _genRandomString($length=10) {
488
+ //$length = 10;
489
+ $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
490
+ $string = '';
491
+
492
+ for ($p = 0; $p < $length; $p++) {
493
+ $string .= $characters[mt_rand(0, strlen($characters))];
494
+ }
495
+
496
+ return $string;
497
+ }
498
+
499
+
500
+
501
+ }
app/code/local/Akdev/Storeya/controllers/IndexController.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Akdev_Storeya_IndexController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/storeya?id=15
11
+ * or
12
+ * http://site.com/storeya/id/15
13
+ */
14
+ /*
15
+ $storeya_id = $this->getRequest()->getParam('id');
16
+
17
+ if($storeya_id != null && $storeya_id != '') {
18
+ $storeya = Mage::getModel('storeya/storeya')->load($storeya_id)->getData();
19
+ } else {
20
+ $storeya = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($storeya == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $storeyaTable = $resource->getTableName('storeya');
32
+
33
+ $select = $read->select()
34
+ ->from($storeyaTable,array('storeya_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $storeya = $read->fetchRow($select);
39
+ }
40
+ Mage::register('storeya', $storeya);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+
46
+ //create a text block with the name of "example-block"
47
+ $block = $this->getLayout()
48
+ ->createBlock('core/text', 'example-block')
49
+ ->setText('<h1>No Access Area</h1>');
50
+
51
+ $this->_addContent($block);
52
+
53
+
54
+ $this->renderLayout();
55
+ }
56
+ }
app/code/local/Akdev/Storeya/etc/config.xml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Akdev
5
+ * @package Akdev_Storeya
6
+ * @author AjayKwatra@gmail.com
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Akdev_Storeya>
13
+ <version>0.1.2</version>
14
+ </Akdev_Storeya>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <storeya>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Akdev_Storeya</module>
22
+ <frontName>storeya</frontName>
23
+ </args>
24
+ </storeya>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <storeya>
29
+ <file>storeya.xml</file>
30
+ </storeya>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <storeya>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Akdev_Storeya</module>
40
+ <frontName>storeya</frontName>
41
+ </args>
42
+
43
+ </storeya>
44
+ </routers>
45
+ </admin>
46
+ <adminhtml>
47
+ <menu>
48
+ <storeya module="storeya">
49
+ <title>Storeya</title>
50
+ <sort_order>71</sort_order>
51
+ <children>
52
+ <items module="storeya">
53
+ <title>Create API</title>
54
+ <sort_order>0</sort_order>
55
+ <!--<action>storeya/adminhtml_storeya</action> -->
56
+ <action>storeya/admin/</action>
57
+ </items>
58
+ </children>
59
+ </storeya>
60
+ </menu>
61
+ <acl>
62
+ <resources>
63
+ <all>
64
+ <title>Allow Everything</title>
65
+ </all>
66
+ <admin>
67
+ <children>
68
+ <Akdev_Storeya>
69
+ <title>Storeya Module</title>
70
+ <sort_order>10</sort_order>
71
+ </Akdev_Storeya>
72
+ </children>
73
+ </admin>
74
+ </resources>
75
+ </acl>
76
+ <layout>
77
+ <updates>
78
+ <storeya>
79
+ <file>storeya.xml</file>
80
+ </storeya>
81
+ </updates>
82
+ </layout>
83
+ </adminhtml>
84
+ <global>
85
+ <!-- <models>
86
+ <storeya>
87
+ <class>Akdev_Storeya_Model</class>
88
+ <resourceModel>storeya_mysql4</resourceModel>
89
+ </storeya>
90
+ <storeya_mysql4>
91
+ <class>Akdev_Storeya_Model_Mysql4</class>
92
+ <entities>
93
+ <storeya>
94
+ <table>storeya</table>
95
+ </storeya>
96
+ </entities>
97
+ </storeya_mysql4>
98
+ </models>
99
+ <resources>
100
+ <storeya_setup>
101
+ <setup>
102
+ <module>Akdev_Storeya</module>
103
+ </setup>
104
+ <connection>
105
+ <use>core_setup</use>
106
+ </connection>
107
+ </storeya_setup>
108
+ <storeya_write>
109
+ <connection>
110
+ <use>core_write</use>
111
+ </connection>
112
+ </storeya_write>
113
+ <storeya_read>
114
+ <connection>
115
+ <use>core_read</use>
116
+ </connection>
117
+ </storeya_read>
118
+ </resources> -->
119
+ <blocks>
120
+ <storeya>
121
+ <class>Akdev_Storeya_Block</class>
122
+ </storeya>
123
+ </blocks>
124
+ <helpers>
125
+ <storeya>
126
+ <class>Akdev_Storeya_Helper</class>
127
+ </storeya>
128
+ </helpers>
129
+ </global>
130
+ </config>
app/code/local/Akdev/Storeya/etc/storeya_api.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <api>
3
+ <api_key>XOCCACSM</api_key>
4
+ <api_username>storeya_api_user</api_username>
5
+ <api_role_id>18</api_role_id>
6
+ <api_user_id>12</api_user_id>
7
+ </api>
app/etc/modules/Akdev_Storeya.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Akdev
5
+ * @package Akdev_Storeya
6
+ * @author AjayKwatra@gmail.com
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Akdev_Storeya>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Akdev_Storeya>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Facebook_store_application</name>
4
+ <version>0.1.6</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>This module freely creates the Magento API required for importing your store into Facebook using StoreYa.</summary>
10
+ <description>This module freely creates the Magento API required for importing your store into Facebook using StoreYa.</description>
11
+ <notes>This module freely creates the Magento API required for importing your store into Facebook using StoreYa.</notes>
12
+ <authors><author><name>StoreYa.com</name><user>auto-converted</user><email>ajaykwatra@gmail.com</email></author></authors>
13
+ <date>2011-08-23</date>
14
+ <time>05:27:11</time>
15
+ <contents><target name="magelocal"><dir name="Akdev"><dir name="Storeya"><dir name="Block"><file name="Storeya.php" hash="9e59143a2af62e324e666b798906491a"/><file name="storeya.phtml" hash="c790c3bbbdfa61e0a67359cf665a1861"/></dir><dir name="controllers"><file name="AdminController.php" hash="d4c6ae3f0ebd344251462887c0d7a370"/><file name="IndexController.php" hash="ebae9de7452caeeebd6bcb80dddcb0e5"/></dir><dir name="etc"><file name="config.xml" hash="6acdcff8d5b57f34201c9736f5bcd5d3"/><file name="storeya_api.xml" hash="55ccf4a43577f6ca96455718d2b9adbb"/></dir><dir name="Helper"><file name="Data.php" hash="67604218d3b6854ad3a10c969fda2050"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Akdev_Storeya.xml" hash="82f4b2503e2b221c72813e227ba2203b"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>