DataFeedWatch_Connector - Version 0.2.9

Version Notes

DataFeedWatch Release version 0.2.9

Download this release

Release Info

Developer DataFeedWatch
Extension DataFeedWatch_Connector
Version 0.2.9
Comparing to
See all releases


Code changes from version 0.2.8 to 0.2.9

app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Connectorbackend.php CHANGED
@@ -20,4 +20,8 @@ class DataFeedWatch_Connector_Block_Adminhtml_Connectorbackend extends Mage_Admi
20
  $model = Mage::getModel('api/user');
21
  return $model->load($this->email, 'email');
22
  }
 
 
 
 
23
  }
20
  $model = Mage::getModel('api/user');
21
  return $model->load($this->email, 'email');
22
  }
23
+
24
+ public function getRedirectUrl() {
25
+ return $this->getUrl('*/*/redirect');
26
+ }
27
  }
app/code/community/DataFeedWatch/Connector/Model/Api/User.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: hexacode
5
+ * Date: 5/19/14
6
+ * Time: 9:24 AM
7
+ */
8
+
9
+ class DataFeedWatch_Connector_Model_Api_User extends Mage_Api_Model_User {
10
+
11
+ public function save()
12
+ {
13
+ $this->_beforeSave();
14
+ $data = array(
15
+ 'firstname' => $this->getFirstname(),
16
+ 'lastname' => $this->getLastname(),
17
+ 'email' => $this->getEmail(),
18
+ 'modified' => Mage::getSingleton('core/date')->gmtDate(),
19
+ );
20
+
21
+ if ($this->getId() > 0) {
22
+ $data['user_id'] = $this->getId();
23
+ }
24
+
25
+ if ( $this->getUsername() ) {
26
+ $data['username'] = $this->getUsername();
27
+ }
28
+
29
+ if ($this->getApiKey()) {
30
+ $data['api_key'] = $this->_getEncodedApiKey($this->getApiKey());
31
+ }
32
+
33
+ if ($this->getNewApiKey()) {
34
+ $data['api_key'] = $this->_getEncodedApiKey($this->getNewApiKey());
35
+ }
36
+
37
+ if ( !is_null($this->getIsActive()) ) {
38
+ $data['is_active'] = intval($this->getIsActive());
39
+ }
40
+ if ( $this->getDfwConnectHash() ) {
41
+ $data['dfw_connect_hash'] = $this->getDfwConnectHash();
42
+ }
43
+
44
+
45
+ $this->setData($data);
46
+ $this->_getResource()->save($this);
47
+ $this->_afterSave();
48
+ return $this;
49
+ }
50
+ }
app/code/community/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php CHANGED
@@ -30,7 +30,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
30
  }
31
 
32
  public function version() {
33
- return "0.2.8"; // this needs to be updated in etc/config.xml as well
34
  }
35
 
36
  public function product_count($options = array()) {
@@ -160,7 +160,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
160
  } else {
161
  $product = Mage::getModel('catalog/product')->load($product->getId());
162
  }
163
- $parent_id = '0';
164
  $configrable = false;
165
 
166
  if ($product->getTypeId() == "simple") {
30
  }
31
 
32
  public function version() {
33
+ return "0.2.9"; // this needs to be updated in etc/config.xml as well
34
  }
35
 
36
  public function product_count($options = array()) {
160
  } else {
161
  $product = Mage::getModel('catalog/product')->load($product->getId());
162
  }
163
+ $parent_id = null;
164
  $configrable = false;
165
 
166
  if ($product->getTypeId() == "simple") {
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorbackendController.php CHANGED
@@ -5,6 +5,7 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
5
  protected $lastname = 'DataFeedWatch';
6
  protected $email = 'magento@datafeedwatch.com';
7
  protected $register_url = 'https://my.datafeedwatch.com/platforms/magento/sessions/finalize';
 
8
 
9
  public function indexAction() {
10
  $this->loadLayout();
@@ -20,8 +21,8 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
20
  'firstname' => $this->firstname,
21
  'lastname' => $this->lastname,
22
  'email' => $this->email,
23
- 'api_key' => $api_key,
24
- 'api_key_confirmation' => $api_key,
25
  'is_active' => 1
26
  );
27
 
@@ -50,28 +51,42 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
50
  $user->setRoleId($role->getId())->setUserId($user->getId());
51
  $user->add();
52
 
53
- $this->getResponse()->setRedirect($this->_registerUrl($api_key));
 
 
 
 
 
 
 
54
  return;
55
  }
56
 
 
 
 
 
 
57
  public function updatetokenAction() {
58
  $api_key = $this->_generateApiKey();
59
  $model = $this->getUser();
60
 
 
 
61
  $data = array(
62
  'user_id' => $model->getId(),
63
  'username' => $this->username,
64
  'firstname' => $this->firstname,
65
  'lastname' => $this->lastname,
66
  'email' => $this->email,
67
- 'api_key' => $api_key,
68
- 'api_key_confirmation' => $api_key
69
  );
70
 
71
- $model->setData($data);
72
  $model->save();
73
 
74
- $this->getResponse()->setRedirect($this->_registerUrl($api_key));
75
  return;
76
  }
77
 
@@ -84,7 +99,8 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
84
  return sha1(time()+substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32));
85
  }
86
 
87
- private function _registerUrl($api_key) {
88
- return $this->register_url.'?shop='.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'&token='.$api_key;
 
89
  }
90
  }
5
  protected $lastname = 'DataFeedWatch';
6
  protected $email = 'magento@datafeedwatch.com';
7
  protected $register_url = 'https://my.datafeedwatch.com/platforms/magento/sessions/finalize';
8
+ protected $redirect_url = 'https://my.datafeedwatch.com/';
9
 
10
  public function indexAction() {
11
  $this->loadLayout();
21
  'firstname' => $this->firstname,
22
  'lastname' => $this->lastname,
23
  'email' => $this->email,
24
+ 'api_key' => '',
25
+ 'api_key_confirmation' => '',
26
  'is_active' => 1
27
  );
28
 
51
  $user->setRoleId($role->getId())->setUserId($user->getId());
52
  $user->add();
53
 
54
+ //add new hash
55
+ $user = Mage::getModel('api/user')->load($user->getUserId());
56
+ $hash = md5($user->getEmail().$user->getCreated());
57
+ $user->setDfwConnectHash($hash);
58
+ $user->save();
59
+ Mage::log($user->getData());
60
+
61
+ $this->getResponse()->setRedirect($this->_registerUrl($api_key,$user->getData('dfw_connect_hash')));
62
  return;
63
  }
64
 
65
+ public function redirectAction(){
66
+ $this->getResponse()->setRedirect($this->redirect_url);
67
+ return;
68
+ }
69
+
70
  public function updatetokenAction() {
71
  $api_key = $this->_generateApiKey();
72
  $model = $this->getUser();
73
 
74
+ $hash = $model->getDfwConnectHash();
75
+
76
  $data = array(
77
  'user_id' => $model->getId(),
78
  'username' => $this->username,
79
  'firstname' => $this->firstname,
80
  'lastname' => $this->lastname,
81
  'email' => $this->email,
82
+ 'api_key' => '',
83
+ 'api_key_confirmation' => ''
84
  );
85
 
86
+ $model->setData($data);
87
  $model->save();
88
 
89
+ $this->getResponse()->setRedirect($this->_registerUrl($api_key,$hash));
90
  return;
91
  }
92
 
99
  return sha1(time()+substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32));
100
  }
101
 
102
+ private function _registerUrl($api_key,$hash) {
103
+
104
+ return $this->register_url.'?shop='.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'&token='.$api_key.'&hash='.$hash;
105
  }
106
  }
app/code/community/DataFeedWatch/Connector/controllers/TokenController.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class DataFeedWatch_Connector_TokenController extends Mage_Core_Controller_Front_Action {
3
+
4
+ /**
5
+ *reachable by
6
+ * http://magentostore.com/datafeedwatch/token/confirm/hash/b271ecf10045d888245202b3268a72fb/new_api_key/yournewkey
7
+ */
8
+ public function confirmAction()
9
+ {
10
+ $request = $this->getRequest();
11
+ if(!$request->isPost()){
12
+ Mage::log(__METHOD__.' - not sent through POST');
13
+ } else {
14
+ $params = $request->getParams();
15
+ if(array_key_exists('hash',$params) && array_key_exists('new_api_key',$params)){
16
+ $matchingUser = Mage::getModel('api/user')->load($params['hash'],'dfw_connect_hash');
17
+ if(is_object($matchingUser) && $matchingUser->getId()>0){
18
+ $matchingUser->setApiKey($params['new_api_key']);
19
+ $matchingUser->save();
20
+ } else {
21
+ Mage::log(__METHOD__.' - no matching user found');
22
+ }
23
+ } else {
24
+ Mage::log(__METHOD__.' - params are missing');
25
+ }
26
+ }
27
+ }
28
+ }
app/code/community/DataFeedWatch/Connector/etc/config.xml CHANGED
@@ -2,18 +2,18 @@
2
  <config>
3
  <modules>
4
  <DataFeedWatch_Connector>
5
- <version>0.2.8</version>
6
  </DataFeedWatch_Connector>
7
  </modules>
8
  <frontend>
9
  <routers>
10
- <connector>
11
  <use>standard</use>
12
  <args>
13
  <module>DataFeedWatch_Connector</module>
14
- <frontName>connector</frontName>
15
  </args>
16
- </connector>
17
  </routers>
18
  </frontend>
19
  <admin>
@@ -64,6 +64,11 @@
64
  <connector>
65
  <class>DataFeedWatch_Connector_Model</class>
66
  </connector>
 
 
 
 
 
67
  </models>
68
  <helpers>
69
  <connector>
@@ -80,9 +85,6 @@
80
  <setup>
81
  <module>DataFeedWatch_Connector</module>
82
  </setup>
83
- <connection>
84
- <use>core_setup</use>
85
- </connection>
86
  </datafeedwatch_connector_setup>
87
  </resources>
88
  </global>
2
  <config>
3
  <modules>
4
  <DataFeedWatch_Connector>
5
+ <version>0.2.9</version>
6
  </DataFeedWatch_Connector>
7
  </modules>
8
  <frontend>
9
  <routers>
10
+ <token>
11
  <use>standard</use>
12
  <args>
13
  <module>DataFeedWatch_Connector</module>
14
+ <frontName>datafeedwatch</frontName>
15
  </args>
16
+ </token>
17
  </routers>
18
  </frontend>
19
  <admin>
64
  <connector>
65
  <class>DataFeedWatch_Connector_Model</class>
66
  </connector>
67
+ <api>
68
+ <rewrite>
69
+ <user>DataFeedWatch_Connector_Model_Api_User</user>
70
+ </rewrite>
71
+ </api>
72
  </models>
73
  <helpers>
74
  <connector>
85
  <setup>
86
  <module>DataFeedWatch_Connector</module>
87
  </setup>
 
 
 
88
  </datafeedwatch_connector_setup>
89
  </resources>
90
  </global>
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/install-0.2.9.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ // Add custom_hash for finding users
7
+ $installer->getConnection()->addColumn($installer->getTable('api/user'), 'dfw_connect_hash', array(
8
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
9
+ 'length' => 32,
10
+ 'comment' => 'Hash used to update keys'
11
+ ));
12
+
13
+ $installer->endSetup();
app/design/adminhtml/default/default/template/connector/connectorbackend.phtml CHANGED
@@ -4,11 +4,12 @@
4
  <?php
5
  if ($user->isObjectNew()) {
6
  ?>
7
- <button onclick="setLocation('<?php echo $this->getCreateUserUrl()?>')" type="button" class="scalable">Go to my DataFeedWatch</button>
8
  <?php
9
  } else {
10
  ?>
11
- <button onclick="setLocation('<?php echo $this->getUpdateTokenUrl()?>')" type="button" class="scalable">Go to my DataFeedWatch</button>
12
  <?php
13
  }
14
  ?>
 
4
  <?php
5
  if ($user->isObjectNew()) {
6
  ?>
7
+ <button onclick="setLocation('<?php echo $this->getCreateUserUrl()?>')" type="button" class="scalable">Create my DataFeedWatch Token </button>
8
  <?php
9
  } else {
10
  ?>
11
+ <button onclick="setLocation('<?php echo $this->getUpdateTokenUrl()?>')" type="button" class="scalable">Regenerate my DataFeedWatch Access Token</button>
12
  <?php
13
  }
14
  ?>
15
+ <button onclick="setLocation('<?php echo $this->getRedirectUrl()?>')" type="button" class="scalable">Go to my DataFeedWatch</button>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DataFeedWatch_Connector</name>
4
- <version>0.2.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
9
  <summary>DataFeedWatch extension for Magento</summary>
10
  <description>DataFeedWatch enables Magento shops to optimize their product datafeed for Google Shopping and other channels&#xD;
11
  </description>
12
- <notes>DataFeedWatch Release version 0.2.8</notes>
13
  <authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
14
- <date>2014-04-22</date>
15
- <time>12:09:03</time>
16
- <contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir><dir name="Adminhtml"><file name="Connectorbackend.php" hash="afe5bd4888768229d5b668f466b770b5"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="dfa561302ef7eebe656b229fe275a2eb"/></dir></dir><dir name="etc"><file name="api.xml" hash="2ece4a0209f667be766d0dbabed6fae5"/><file name="config.xml" hash="bae1c897167b09509aaec9cb79da2adb"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir><dir name="Helper"><file name="Data.php" hash="983d7ad023616b365dce180680e4f9f0"/></dir><dir name="Model"><dir name="Datafeedwatch"><file name="Api.php" hash="768f67cd5a0868e80f2d6aa7588999bb"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="connector.xml" hash="14d59b8e9f66fba5d7c1f8d0f62dfc3c"/></dir><dir name="template"><dir name="connector"><file name="connectorbackend.phtml" hash="87fbcd16a96af52ce352bc45d9aeab4a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="658a7b36ae7eb5915f40993a191aaa13"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DataFeedWatch_Connector</name>
4
+ <version>0.2.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
9
  <summary>DataFeedWatch extension for Magento</summary>
10
  <description>DataFeedWatch enables Magento shops to optimize their product datafeed for Google Shopping and other channels&#xD;
11
  </description>
12
+ <notes>DataFeedWatch Release version 0.2.9</notes>
13
  <authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
14
+ <date>2014-05-20</date>
15
+ <time>15:54:06</time>
16
+ <contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="a5d0e6e40805181efa2f3b36b7c8d7e5"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="09313d4b3d59712a01d98b9da8c70e73"/></dir><dir><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="09313d4b3d59712a01d98b9da8c70e73"/></dir></dir><file name="TokenController.php" hash="bf462203d013237e10d463e7b6292212"/></dir><dir name="etc"><file name="api.xml" hash="2ece4a0209f667be766d0dbabed6fae5"/><file name="config.xml" hash="6d06591f79a1d69417022139d74f8b75"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir><dir name="Helper"><file name="Data.php" hash="983d7ad023616b365dce180680e4f9f0"/></dir><dir name="Model"><dir name="Api"><file name="User.php" hash="de27f5eccf323fa37502dbf59e9ec20a"/></dir><dir name="Datafeedwatch"><file name="Api.php" hash="7022b8cf3083573311ac1ac60a88eeae"/></dir></dir><dir name="sql"><dir><dir name="datafeedwatch_connector_setup"><file name="install-0.2.9.php" hash="326a2968b7af5a987604f880ed7c4a3c"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="connector.xml" hash="14d59b8e9f66fba5d7c1f8d0f62dfc3c"/></dir><dir name="template"><dir name="connector"><file name="connectorbackend.phtml" hash="bf983f35062ee9f2669a18cf22174bf4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="658a7b36ae7eb5915f40993a191aaa13"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>