aftership - Version 0.2.1

Version Notes

Minor bugs fixed

Download this release

Release Info

Developer aftership
Extension aftership
Version 0.2.1
Comparing to
See all releases


Code changes from version 0.2.0 to 0.2.1

app/code/community/Aftership/Track/Helper/Data.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- class Aftership_Track_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
- }
5
- ?>
 
 
 
 
 
app/code/community/Aftership/Track/Model/Methods.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- class Aftership_Track_Model_Methods
3
- {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- array('value'=>1, 'label'=>Mage::helper('aftership')->__('Email')),
8
- array('value'=>2, 'label'=>Mage::helper('aftership')->__('SMS')),
9
- );
10
- }
11
-
12
- }
13
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/Model/Mysql4/Track.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- class Aftership_Track_Model_Mysql4_Track extends Mage_Core_Model_Mysql4_Abstract
3
- {
4
- protected function _construct()
5
- {
6
- $this->_init('track/track','track_id');
7
- }
8
- }
9
- ?>
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/Model/Mysql4/Track/Collection.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- class Aftership_Track_Model_Mysql4_Track_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
- {
4
- protected function _construct()
5
- {
6
- $this->_init('track/track');
7
- }
8
- }
9
- ?>
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/Model/Observer.php DELETED
@@ -1,179 +0,0 @@
1
- <?php
2
-
3
- class Aftership_Track_Model_Observer
4
- {
5
- public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
6
- {
7
- ob_start();
8
- $config = Mage::getStoreConfig('aftership_options/messages');
9
-
10
- /*if(array_key_exists("notification",$config)){
11
- $notifications = explode(",",$config["notification"]);
12
- if(array_search("1",$notifications)!==False){ // email
13
- $is_notify_email = true;
14
- }else{
15
- $is_notify_email = false;
16
- }
17
- if(array_search("2",$notifications)!==False){ // sms
18
- $is_notify_sms = true;
19
- }else{
20
- $is_notify_sms = false;
21
- }
22
- }else{
23
- $is_notify_email = false;
24
- $is_notify_sms = false;
25
- }*/
26
-
27
- $track = $observer->getEvent()->getTrack();
28
- $track_data = $track->getData();
29
- $order_data = $track->getShipment()->getOrder()->getData();
30
- $shipment_data = $track->getShipment()->getData();
31
- $shipping_address_data = $track->getShipment()->getOrder()->getShippingAddress()->getData();
32
- if (strlen(trim($track_data["track_number"])) > 0) {
33
- //1.6.2.0 or later
34
- $track_no = trim($track_data["track_number"]);
35
- } else {
36
- //1.5.1.0
37
- $track_no = trim($track_data["number"]);
38
- }
39
-
40
- $exist_track_data = Mage::getModel('track/track')
41
- ->getCollection()
42
- ->addFieldToFilter('tracking_number', array('eq' => $track_no))
43
- ->addFieldToFilter('order_id', array('eq' => $order_data["order_id"]))
44
- ->getData();
45
-
46
-
47
- if (!$exist_track_data) {
48
- $track = Mage::getModel('track/track');
49
-
50
- $track->setTrackingNumber($track_no);
51
-
52
- $track->setShipCompCode($track_data["carrier_code"]);
53
- //$track->setTitle($_SERVER['HTTP_HOST'] . " " . $order_data["increment_id"]);
54
- //$track->setTitle($_SERVER['HTTP_ORIGIN'] . " " . $order_data["increment_id"]);
55
- $track->setTitle($order_data["increment_id"]);
56
-
57
- $track->setOrderId($order_data["increment_id"]);
58
-
59
- if ($order_data["customer_email"] && $order_data["customer_email"] != "") {
60
- $track->setEmail($order_data["customer_email"]);
61
- }
62
-
63
- if ($shipping_address_data["telephone"] && $shipping_address_data["telephone"] != "") {
64
- $track->setTelephone($shipping_address_data["telephone"]);
65
- }
66
-
67
- /*
68
- if($is_notify_email){
69
- $track->setEmail($order_data["customer_email"]);
70
- }
71
-
72
- if($is_notify_sms){
73
- $track->setTelephone($shipping_address_data["telephone"]);
74
- }*/
75
-
76
-
77
- if (array_key_exists("status", $config) && $config["status"]) {
78
- $track->setPosted(0);
79
- } else {
80
- $track->setPosted(2);
81
- }
82
-
83
- $track->save();
84
- }
85
-
86
-
87
- if (array_key_exists("status", $config) && $config["status"])
88
- {
89
- $api_key = $config["api_key"];
90
-
91
- $post_tracks = Mage::getModel('track/track')
92
- ->getCollection()
93
- ->addFieldToFilter('posted', array('eq' => 0))
94
- ->getData();
95
-
96
- $url_params = array("api_key" => $api_key);
97
-
98
- foreach ($post_tracks as $track) {
99
- $url = "https://api.aftership.com/v1/trackings";
100
- $url_params["tracking_number"] = $track["tracking_number"];
101
- $url_params["smses"] = array($track["telephone"]);
102
- $url_params["emails"] = array($track["email"]);
103
- $url_params["title"] = $track["title"];
104
- $url_params["order_id"] = $track["order_id"];
105
-
106
- $ch = curl_init();
107
- curl_setopt($ch, CURLOPT_URL, $url);
108
-
109
- curl_setopt($ch, CURLOPT_POST, true);
110
- curl_setopt($ch, CURLOPT_POSTFIELDS, $url_params);
111
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
112
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
113
- curl_setopt($ch, CURLOPT_HEADER, 0);
114
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
115
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //the SSL is not correct
116
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //the SSL is not correct
117
-
118
- $response = curl_exec($ch);
119
- $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
120
- $error = curl_error($ch);
121
- curl_close($ch);
122
- $response_obj = json_decode($response, true);
123
-
124
- if ($http_status == "201" || $http_status == "422") //422: repeated
125
- {
126
- $track_obj = Mage::getModel('track/track');
127
- $track_obj->load($track["track_id"]);
128
- $track_obj->setPosted(1);
129
- $track_obj->save();
130
- } else {
131
-
132
- }
133
- }
134
- }
135
-
136
- ob_end_clean();
137
- }
138
-
139
- public function adminSystemConfigChangedSectionAftership($obj)
140
- {
141
- $post_data = Mage::app()->getRequest()->getPost();
142
- $api_key = $post_data["groups"]["messages"]["fields"]["api_key"]["value"];
143
- if (!array_key_exists("notification", $post_data["groups"]["messages"]["fields"])) {
144
- Mage::getModel('core/config')->saveConfig('aftership_options/messages/notification', 0);
145
- }
146
-
147
- $url_params = array(
148
- "api_key" => $api_key
149
- );
150
- $url = "https://api.aftership.com/v1/users/authenticate";
151
-
152
- $ch = curl_init();
153
- curl_setopt($ch, CURLOPT_URL, $url);
154
- curl_setopt($ch, CURLOPT_POST, true);
155
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($url_params));
156
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
157
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
158
- curl_setopt($ch, CURLOPT_HEADER, 0);
159
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
160
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
161
-
162
- $response = curl_exec($ch);
163
- $error = curl_error($ch);
164
- $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
165
- curl_close($ch);
166
- $response_obj = json_decode($response, true);
167
-
168
- if ($http_status != "200" && $http_status != "401") {
169
- Mage::getModel('core/config')->saveConfig('aftership_options/messages/status', 0);
170
- Mage::throwException(Mage::helper('adminhtml')->__("Connection error, please try again later."));
171
- } else {
172
- if (!$response_obj["success"]) //error
173
- {
174
- Mage::getModel('core/config')->saveConfig('aftership_options/messages/status', 0);
175
- Mage::throwException(Mage::helper('adminhtml')->__("Incorrect API Key"));
176
- }
177
- }
178
- }
179
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/Model/Resource/Mysql4/Setup.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- class Aftership_Track_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
3
- }
4
- ?>
 
 
 
 
app/code/community/Aftership/Track/Model/Track.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- class Aftership_Track_Model_Track extends Mage_Core_Model_Abstract
3
- {
4
- protected function _construct()
5
- {
6
- $this->_init('track/track');
7
- }
8
- }
9
- ?>
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/Model/Words.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- class Aftership_Track_Model_Words
3
- {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- array('value'=>0, 'label'=>Mage::helper('aftership')->__('Disable')),
8
- array('value'=>1, 'label'=>Mage::helper('aftership')->__('Enable')),
9
- );
10
- }
11
-
12
- }
13
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/controllers/IndexController.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- class Aftership_Track_IndexController extends Mage_Core_Controller_Front_Action {
3
-
4
- public function indexAction() {
5
- }
6
- }
7
- ?>
 
 
 
 
 
 
 
app/code/community/Aftership/Track/etc/config.xml DELETED
@@ -1,107 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <global>
4
- <models>
5
- <track>
6
- <class>Aftership_Track_Model</class>
7
- <resourceModel>track_mysql4</resourceModel>
8
- </track>
9
- <track_mysql4>
10
- <class>Aftership_Track_Model_Mysql4</class>
11
- <entities>
12
- <track>
13
- <table>as_track</table>
14
- </track>
15
- </entities>
16
- </track_mysql4>
17
- <status>
18
- <class>Aftership_Track_Model</class>
19
- </status>
20
- <notification>
21
- <class>Aftership_Track_Model</class>
22
- </notification>
23
- </models>
24
- <resources>
25
- <track_write>
26
- <connection>
27
- <use>core_write</use>
28
- </connection>
29
- </track_write>
30
- <track_read>
31
- <connection>
32
- <use>core_read</use>
33
- </connection>
34
- </track_read>
35
- <track_setup>
36
- <setup>
37
- <module>Aftership_Track</module>
38
- <class>Aftership_Track_Model_Resource_Mysql4_Setup</class>
39
- </setup>
40
- <connection>
41
- <use>core_setup</use>
42
- </connection>
43
- </track_setup>
44
- </resources>
45
- <helpers>
46
- <aftership>
47
- <class>Aftership_Track_Helper</class>
48
- </aftership>
49
- </helpers>
50
- </global>
51
- <modules>
52
- <Aftership_Track>
53
- <version>0.1.16</version>
54
- </Aftership_Track>
55
- </modules>
56
- <frontend>
57
- <routers>
58
- <track>
59
- <use>standard</use>
60
- <args>
61
- <module>Aftership_Track</module>
62
- <frontName>track</frontName>
63
- </args>
64
- </track>
65
- </routers>
66
- </frontend>
67
- <adminhtml>
68
- <events>
69
- <sales_order_shipment_track_save_after>
70
- <observers>
71
- <fishpig_save_product_data>
72
- <type>singleton</type>
73
- <class>track/observer</class>
74
- <method>salesOrderShipmentTrackSaveAfter</method>
75
- </fishpig_save_product_data>
76
- </observers>
77
- </sales_order_shipment_track_save_after>
78
- <admin_system_config_changed_section_aftership_options>
79
- <observers>
80
- <index>
81
- <class>track/observer</class>
82
- <method>adminSystemConfigChangedSectionAftership</method>
83
- </index>
84
- </observers>
85
- </admin_system_config_changed_section_aftership_options>
86
- </events>
87
- <acl>
88
- <resources>
89
- <admin>
90
- <children>
91
- <system>
92
- <children>
93
- <config>
94
- <children>
95
- <aftership_options>
96
- <title>Aftership tracking config</title>
97
- </aftership_options>
98
- </children>
99
- </config>
100
- </children>
101
- </system>
102
- </children>
103
- </admin>
104
- </resources>
105
- </acl>
106
- </adminhtml>
107
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/etc/system.xml DELETED
@@ -1,58 +0,0 @@
1
- <config>
2
- <tabs>
3
- <aftershipconfig translate="label" module="aftership">
4
- <label>Aftership</label>
5
- <sort_order>99999</sort_order>
6
- </aftershipconfig>
7
- </tabs>
8
- <sections>
9
- <aftership_options translate="label" module="aftership">
10
- <label>AfterShip Config Options</label>
11
- <tab>aftershipconfig</tab>
12
- <frontend_type>text</frontend_type>
13
- <sort_order>1000</sort_order>
14
- <show_in_default>1</show_in_default>
15
- <show_in_website>1</show_in_website>
16
- <show_in_store>1</show_in_store>
17
- <groups>
18
- <messages translate="label">
19
- <label>Account setting</label>
20
- <frontend_type>text</frontend_type>
21
- <sort_order>1</sort_order>
22
- <show_in_default>1</show_in_default>
23
- <show_in_website>1</show_in_website>
24
- <show_in_store>1</show_in_store>
25
- <fields>
26
- <api_key>
27
- <label>API key</label>
28
- <frontend_type>text</frontend_type>
29
- <sort_order>10</sort_order>
30
- <show_in_default>1</show_in_default>
31
- <show_in_website>1</show_in_website>
32
- <show_in_store>0</show_in_store>
33
- <comment>You can find your API key in <![CDATA[<a target='_blank' href="https://www.aftership.com/connect/magento">https://www.aftership.com/connect/magento</a>]]></comment>
34
- </api_key>
35
- <status>
36
- <label>Status</label>
37
- <frontend_type>Select</frontend_type>
38
- <source_model>status/words</source_model>
39
- <sort_order>30</sort_order>
40
- <show_in_default>1</show_in_default>
41
- <show_in_website>1</show_in_website>
42
- <show_in_store>0</show_in_store>
43
- </status>
44
- <!--<notification>
45
- <label>Notification</label>
46
- <frontend_type>Multiselect</frontend_type>
47
- <source_model>notification/methods</source_model>
48
- <sort_order>40</sort_order>
49
- <show_in_default>1</show_in_default>
50
- <show_in_website>1</show_in_website>
51
- <show_in_store>0</show_in_store>
52
- </notification>-->
53
- </fields>
54
- </messages>
55
- </groups>
56
- </aftership_options>
57
- </sections>
58
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Aftership/Track/sql/track_setup/mysql4-install-0.1.16.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- //echo "start";
3
- $installer = $this;
4
- $installer->startSetup();
5
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('track/track')}`;");
6
- $installer->run("
7
- CREATE TABLE `{$installer->getTable('track/track')}` (
8
- `track_id` int(11) NOT NULL AUTO_INCREMENT,
9
- `tracking_number` varchar(255) NOT NULL,
10
- `ship_comp_code` varchar(255) NOT NULL,
11
- `email` varchar(255) NOT NULL,
12
- `telephone` varchar(255) NOT NULL,
13
- `title` varchar(255) NOT NULL,
14
- `posted` int(11) NOT NULL DEFAULT '0',
15
- `order_id` varchar(255) NOT NULL,
16
- PRIMARY KEY (`track_id`),
17
- KEY `posted` (`posted`)
18
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
19
-
20
-
21
- ");
22
- $installer->endSetup();
23
-
24
-
25
- //echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
26
- //die("Exit for now");
27
- /*
28
- CREATE TABLE `{$installer->getTable('track/user')}` (
29
- `user_id` int(11) NOT NULL,
30
- `login_name` varchar(255) NOT NULL,
31
- `password` varchar(255) NOT NULL,
32
- `consumer_key` varchar(255) NOT NULL,
33
- `consumer_secret` varchar(255) NOT NULL,
34
- `status` int(11) NOT NULL,
35
- PRIMARY KEY (`user_id`),
36
- KEY `status` (`status`)
37
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
38
- */
39
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>aftership</name>
4
- <version>0.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
@@ -16,8 +16,8 @@ Tracking number will be added to the aftership.com &lt;https://www.aftership.com
16
  <notes>Minor bugs fixed</notes>
17
  <authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
18
  <date>2012-10-20</date>
19
- <time>14:32:34</time>
20
- <contents><target name="magecommunity"><dir name="Aftership"><dir name="Track"><dir name="Helper"><file name="Data.php" hash="970d03deb3e5fc478f5d86e5ff3670cb"/></dir><dir name="Model"><file name="Methods.php" hash="d9fa7ef3df0353c01662ff4bdf210f60"/><dir name="Mysql4"><dir name="Track"><file name="Collection.php" hash="336c4b0fba8db78e1222da01aa8c5744"/></dir><file name="Track.php" hash="90ad226fa98576fceb223b85fe88b642"/></dir><file name="Observer.php" hash="8c79116a10240f064f19aa68b06414ff"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="b53f65ecc832752c8394f0da74b2f90d"/></dir></dir><file name="Track.php" hash="eb12833d5f084b0b919cbde45f8170eb"/><file name="Words.php" hash="7789e47b991f718fb3097b5e274eb71f"/></dir><dir name="controllers"><file name="IndexController.php" hash="3ee34f42957e816ff336f8f8215a218b"/></dir><dir name="etc"><file name="config.xml" hash="9464ce90e641252897520a5a4b0afc6b"/><file name="system.xml" hash="857fa4fae0433c10ba468bff794ca9ef"/></dir><dir name="sql"><dir name="track_setup"><file name="mysql4-install-0.1.0.php" hash="a8f81083585c85a89e8a3097f5f3045c"/><file name="mysql4-install-0.1.16.php" hash="a8f81083585c85a89e8a3097f5f3045c"/></dir></dir></dir></dir></target></contents>
21
  <compatible/>
22
- <dependencies><required><php><min>5.2.17</min><max>0.0.0</max></php></required></dependencies>
23
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>aftership</name>
4
+ <version>0.2.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
16
  <notes>Minor bugs fixed</notes>
17
  <authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
18
  <date>2012-10-20</date>
19
+ <time>14:37:30</time>
20
+ <contents><target name="magecommunity"><dir name="Aftership"><dir name="Track"><dir name="sql"><dir name="track_setup"><file name="mysql4-install-0.1.0.php" hash="a8f81083585c85a89e8a3097f5f3045c"/></dir></dir></dir></dir></target></contents>
21
  <compatible/>
22
+ <dependencies><required><php><min>5.2.13</min><max>5.4.8</max></php></required></dependencies>
23
  </package>