TroopID_Connect - Version 0.1.0

Version Notes

N/A

Download this release

Release Info

Developer Troop ID
Extension TroopID_Connect
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (24) hide show
  1. app/code/community/TroopID/Connect/Block/Adminhtml/System/Config/Help.php +21 -0
  2. app/code/community/TroopID/Connect/Block/Adminhtml/System/Config/Instructions.php +32 -0
  3. app/code/community/TroopID/Connect/Block/Cart.php +33 -0
  4. app/code/community/TroopID/Connect/Helper/Data.php +38 -0
  5. app/code/community/TroopID/Connect/Helper/Oauth.php +119 -0
  6. app/code/community/TroopID/Connect/Model/Rule/Condition.php +55 -0
  7. app/code/community/TroopID/Connect/Model/Rule/Observer.php +25 -0
  8. app/code/community/TroopID/Connect/controllers/AuthorizeController.php +66 -0
  9. app/code/community/TroopID/Connect/etc/adminhtml.xml +23 -0
  10. app/code/community/TroopID/Connect/etc/config.xml +140 -0
  11. app/code/community/TroopID/Connect/etc/system.xml +106 -0
  12. app/code/community/TroopID/Connect/sql/troopid_connect_setup/mysql4-install-0.1.0.php +11 -0
  13. app/design/adminhtml/default/default/layout/troopid_connect.xml +16 -0
  14. app/design/adminhtml/default/default/template/troopid/connect/order.phtml +204 -0
  15. app/design/frontend/default/default/layout/troopid_connect.xml +23 -0
  16. app/design/frontend/default/default/template/troopid/connect/callback.phtml +10 -0
  17. app/design/frontend/default/default/template/troopid/connect/cart.phtml +24 -0
  18. app/design/frontend/default/default/template/troopid/connect/script.phtml +73 -0
  19. app/etc/modules/TroopID_Connect.xml +18 -0
  20. app/locale/en_US/TroopID_Connect.csv +31 -0
  21. package.xml +18 -0
  22. skin/adminhtml/default/default/troopid_connect/images/logo.png +0 -0
  23. skin/adminhtml/default/default/troopid_connect/troopid.css +25 -0
  24. skin/frontend/default/default/troopid_connect/troopid.css +49 -0
app/code/community/TroopID/Connect/Block/Adminhtml/System/Config/Help.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TroopID_Connect_Block_Adminhtml_System_Config_Help extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+
5
+ protected function _getHeaderTitleHtml($element) {
6
+ $html = '<div class="config-heading"><div class="heading"><strong>' . $element->getLegend() . '</strong>';
7
+ $html .= '<span class="heading-intro">' . $element->getComment() . '</span></div>';
8
+ $html .= '</div>';
9
+
10
+ return $html;
11
+ }
12
+
13
+ protected function _getHeaderCommentHtml($element) {
14
+ return '';
15
+ }
16
+
17
+ protected function _getCollapseState($element) {
18
+ return false;
19
+ }
20
+
21
+ }
app/code/community/TroopID/Connect/Block/Adminhtml/System/Config/Instructions.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TroopID_Connect_Block_Adminhtml_System_Config_Instructions extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+
5
+ protected function _getHeaderTitleHtml($element) {
6
+ $config = $this->getGroup($element)->asArray();
7
+
8
+ $html = '<div class="config-heading"><div class="heading"><strong>' . $element->getLegend() . '</strong></div>';
9
+ $html .= '<ul class="steps">';
10
+ $html .= '<li>' . $this->__("Create a developer account at") . ' <a href="' . $config["developer_url"] . '" target="_blank">' . $config["developer_url"] . '</a></li>';
11
+ $html .= '<li>' . $this->__("Register an application at") . ' <a href="' . $config["apps_url"] . '" target="_blank">' . $config["apps_url"] . '</a></li>';
12
+ $html .= '<li>' . $this->__("Fill in <strong>Redirect URI</strong> with") . ' ' . Mage::getUrl("troopid/authorize/callback") . '</li>';
13
+ $html .= '<li>' . $this->__("Fill in <strong>Base URI</strong> with") . ' ' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . '</li>';
14
+ $html .= '<li>' . $this->__("Copy and paste your <strong>Client ID</strong> and <strong>Client Secret</strong> values from your application settings on Troop ID") . '</li>';
15
+ $html .= '<li>' . $this->__("That's it! You are ready to go.") . '</li>';
16
+ $html .= '</ul>';
17
+ $html .= '<div class="heading"><span class="heading-intro"><a href="' . $config["learn_more_url"] . '" target="_blank">' . $this->__("Learn more about Troop ID") . '</a></span></div>';
18
+ $html .= '<div class="heading"><span class="heading-intro"><a href="' . $config["docs_url"] . '" target="_blank">' . $this->__("Read developer documentation") . '</a></span></div>';
19
+ $html .= '</div>';
20
+
21
+ return $html;
22
+ }
23
+
24
+ protected function _getHeaderCommentHtml($element) {
25
+ return '';
26
+ }
27
+
28
+ protected function _getCollapseState($element) {
29
+ return false;
30
+ }
31
+
32
+ }
app/code/community/TroopID/Connect/Block/Cart.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TroopID_Connect_Block_Cart extends Mage_Checkout_Block_Cart_Abstract {
4
+
5
+ public function isOperational() {
6
+ return Mage::helper("troopid_connect")->isOperational();
7
+ }
8
+
9
+ public function getEndpoint() {
10
+ return Mage::getUrl("troopid/authorize/authorize");
11
+ }
12
+
13
+ public function hasAffiliation() {
14
+ return $this->getQuote() && $this->getQuote()->getTroopidAffiliation() !== null;
15
+ }
16
+
17
+ public function getAffiliation() {
18
+ return $this->getQuote()->getTroopidAffiliation();
19
+ }
20
+
21
+ public function getAbout() {
22
+ return Mage::helper("troopid_connect")->getKey("about");
23
+ }
24
+
25
+ protected function _toHtml() {
26
+
27
+ if (!$this->isOperational())
28
+ return "";
29
+
30
+ return parent::_toHtml();
31
+ }
32
+
33
+ }
app/code/community/TroopID/Connect/Helper/Data.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TroopID_Connect_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ const CACHE_TAG = "troopid_connect";
6
+ const CACHE_KEY = "troopid_affiliations";
7
+
8
+ public function getKey($key, $storeId = null) {
9
+ return Mage::getStoreConfig("troopid_connect/settings/" . $key, $storeId);
10
+ }
11
+
12
+ public function isEnabled() {
13
+ return $this->getKey("enabled") == "1";
14
+ }
15
+
16
+ public function isSandbox() {
17
+ return $this->getKey("sandbox_mode") == "1";
18
+ }
19
+
20
+ public function isOperational() {
21
+ return $this->isEnabled() && $this->getKey("client_id") && $this->getKey("client_secret");
22
+ }
23
+
24
+ public function getAffiliations() {
25
+ $cache = Mage::getSingleton('core/cache');
26
+ $oauth = Mage::helper("troopid_connect/oauth");
27
+ $values = $cache->load(self::CACHE_KEY);
28
+
29
+ if (is_array($values))
30
+ return $values;
31
+
32
+ $values = $oauth->getAffiliations();
33
+ $cache->save($values, self::CACHE_KEY, array(self::CACHE_TAG), 60*60);
34
+
35
+ return $values;
36
+ }
37
+
38
+ }
app/code/community/TroopID/Connect/Helper/Oauth.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TroopID_Connect_Helper_Oauth extends Mage_Core_Helper_Abstract {
4
+
5
+ const ENDPOINT_SANDBOX = "https://api.sandbox.troopid.com";
6
+ const ENDPOINT_PRODUCTION = "https://api.troopid.com";
7
+
8
+ const AUTHORIZE_PATH = "/oauth/authorize";
9
+ const TOKEN_PATH = "/oauth/token";
10
+ const PROFILE_PATH = "/v1/me.json";
11
+ const AFFILIATIONS_PATH = "/v1/affiliations.json";
12
+
13
+ private function getConfig() {
14
+ return Mage::helper("troopid_connect");
15
+ }
16
+
17
+ private function getCallbackUrl() {
18
+ return Mage::getUrl("troopid/authorize/callback");
19
+ }
20
+
21
+ public function getAuthorizeUrl() {
22
+
23
+ $params = array(
24
+ "client_id" => $this->getConfig()->getKey("client_id"),
25
+ "redirect_uri" => $this->getCallbackUrl(),
26
+ "response_type" => "code",
27
+ "display" => "popup"
28
+ );
29
+
30
+ return $this->getDomain() . self::AUTHORIZE_PATH . "?" . $this->toQuery($params);
31
+ }
32
+
33
+ public function getAccessToken($code) {
34
+
35
+ $config = $this->getConfig();
36
+ $client = new Zend_Http_Client();
37
+
38
+ $client->setUri($this->getDomain() . self::TOKEN_PATH);
39
+ $client->setParameterPost(array(
40
+ "client_id" => $config->getKey("client_id"),
41
+ "client_secret" => $config->getKey("client_secret"),
42
+ "redirect_uri" => $this->getCallbackUrl(),
43
+ "code" => $code,
44
+ "grant_type" => "authorization_code"
45
+ ));
46
+
47
+ try {
48
+ $response = $client->request("POST");
49
+ } catch (Zend_Http_Client_Exception $e) {
50
+ return null;
51
+ }
52
+
53
+ if ($response->isError())
54
+ return null;
55
+
56
+ $json = Zend_Json::decode($response->getBody());
57
+
58
+ return $json["access_token"];
59
+ }
60
+
61
+
62
+ public function getProfileData($token) {
63
+
64
+ if (empty($token))
65
+ return null;
66
+
67
+ $config = Mage::helper("troopid_connect");
68
+
69
+ $client = new Zend_Http_Client();
70
+ $client->setUri($this->getDomain() . self::PROFILE_PATH);
71
+ $client->setParameterGet(array(
72
+ "access_token" => $token
73
+ ));
74
+
75
+ try {
76
+ $response = $client->request("GET");
77
+ } catch (Zend_Http_Client_Exception $e) {
78
+ return null;
79
+ }
80
+
81
+ if ($response->isError())
82
+ return null;
83
+
84
+ $json = Zend_Json::decode($response->getBody());
85
+
86
+ return $json;
87
+ }
88
+
89
+ public function getAffiliations() {
90
+ $client = new Zend_Http_Client($this->getDomain() . self::AFFILIATIONS_PATH);
91
+ $response = $client->request("GET");
92
+ $values = array();
93
+
94
+ if ($response->isSuccessful())
95
+ $values = Zend_Json::decode($response->getBody());
96
+
97
+ return $values;
98
+ }
99
+
100
+ private function getDomain() {
101
+ if ($this->getConfig()->isSandbox()) {
102
+ return self::ENDPOINT_SANDBOX;
103
+ } else {
104
+ return self::ENDPOINT_PRODUCTION;
105
+ }
106
+ }
107
+
108
+ private function toQuery($params) {
109
+ $output = array();
110
+
111
+ foreach ($params as $key => $value) {
112
+ $output[]= $key . "=" . urlencode($value);
113
+ }
114
+
115
+ return join("&", $output);
116
+ }
117
+
118
+
119
+ }
app/code/community/TroopID/Connect/Model/Rule/Condition.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TroopID_Connect_Model_Rule_Condition extends Mage_Rule_Model_Condition_Abstract {
3
+
4
+ public function loadAttributeOptions() {
5
+
6
+ $this->setAttributeOption(array(
7
+ "troopid_affiliation" => Mage::helper("troopid_connect")->__("Troop ID Verified Affiliation")
8
+ ));
9
+
10
+ return $this;
11
+ }
12
+
13
+ public function getInputType() {
14
+ return "select";
15
+ }
16
+
17
+ public function getValueElementType() {
18
+ return "select";
19
+ }
20
+
21
+ public function getValueSelectOptions() {
22
+ if (!$this->hasData("value_select_options")) {
23
+
24
+ $options = array();
25
+ $affiliations = Mage::helper("troopid_connect")->getAffiliations();
26
+
27
+ foreach ($affiliations as $affiliation) {
28
+ $options[$affiliation] = $affiliation;
29
+ }
30
+
31
+ $this->setData("value_select_options", $options);
32
+ }
33
+
34
+ return $this->getData("value_select_options");
35
+ }
36
+
37
+ public function getAttributeElement() {
38
+ $element = parent::getAttributeElement();
39
+ $element->setShowAsText(true);
40
+
41
+ return $element;
42
+ }
43
+
44
+ public function validate(Varien_Object $object) {
45
+
46
+ if (!Mage::helper("troopid_connect")->isEnabled())
47
+ return true;
48
+
49
+ $quote = $object->getQuote();
50
+ $value = $quote->getTroopidAffiliation();
51
+
52
+ return $value === $this->getValue();
53
+ }
54
+
55
+ }
app/code/community/TroopID/Connect/Model/Rule/Observer.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TroopID_Connect_Model_Rule_Observer {
3
+
4
+ public function addCondition(Varien_Event_Observer $observer) {
5
+
6
+ if (!Mage::helper("troopid_connect")->isEnabled())
7
+ return;
8
+
9
+ $conditions = (array) $observer->getEvent()->getAdditional()->getConditions();
10
+ $conditions = array_merge_recursive($conditions, array(
11
+ array(
12
+ "label" => Mage::helper("troopid_connect")->__("Troop ID Attribute"),
13
+ "value" => array(
14
+ array(
15
+ "label" => Mage::helper("troopid_connect")->__("Troop ID Verified Affiliation"),
16
+ "value" => "troopid_connect/rule_condition"
17
+ )
18
+ )
19
+ )
20
+ ));
21
+
22
+ $observer->getEvent()->getAdditional()->setConditions($conditions);
23
+ }
24
+
25
+ }
app/code/community/TroopID/Connect/controllers/AuthorizeController.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TroopID_Connect_AuthorizeController extends Mage_Core_Controller_Front_Action {
4
+
5
+ private function getSession() {
6
+ return Mage::getSingleton("checkout/session");
7
+ }
8
+
9
+ private function getConfig() {
10
+ return Mage::helper("troopid_connect");
11
+ }
12
+
13
+ private function getOauth() {
14
+ return Mage::helper("troopid_connect/oauth");
15
+ }
16
+
17
+ private function getCart() {
18
+ return Mage::getSingleton("checkout/cart");
19
+ }
20
+
21
+ public function authorizeAction() {
22
+ $this->getResponse()->setRedirect($this->getOauth()->getAuthorizeUrl());
23
+ }
24
+
25
+ public function callbackAction() {
26
+
27
+ $config = $this->getConfig();
28
+ $oauth = $this->getOauth();
29
+ $session = $this->getSession();
30
+
31
+ /* code from initial callback */
32
+ $code = $this->getRequest()->getParam("code");
33
+
34
+ /* code was not found, invalid callback request */
35
+ if (empty($code)) {
36
+ $session->addError($config->__("Troop ID verification failed, please contact the store owner"));
37
+ } else {
38
+
39
+ /* request access token with the given code */
40
+ $token = $oauth->getAccessToken($code);
41
+
42
+ /* request user profile data with the given access token */
43
+ $data = $oauth->getProfileData($token);
44
+
45
+ if (empty($data)) {
46
+ $session->addError($config->__("Troop ID verification failed, please contact the store owner"));
47
+ } else {
48
+ $cart = $this->getCart();
49
+ $quote = $cart->getQuote();
50
+
51
+ if ($data["verified"]) {
52
+ $quote->setTroopidAffiliation($data["affiliation"]);
53
+ $quote->setTroopidUid($data["id"]);
54
+ $quote->save();
55
+
56
+ $session->addSuccess($config->__("Successfully verified military affiliation via Troop ID"));
57
+ } else {
58
+ $session->addError($config->__("Unfortunately your have not verified your affiliation with Troop ID"));
59
+ }
60
+ }
61
+ }
62
+
63
+ $this->loadLayout()->renderLayout();
64
+ }
65
+
66
+ }
app/code/community/TroopID/Connect/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <troopid_connect translate="title" module="troopid_connect">
12
+ <title>Troop ID Connect Settings</title>
13
+ <sort_order>9999</sort_order>
14
+ </troopid_connect>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/TroopID/Connect/etc/config.xml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <TroopID_Connect>
5
+ <version>0.1.0</version>
6
+ </TroopID_Connect>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <troopid_connect>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>TroopID_Connect</module>
15
+ <frontName>troopid</frontName>
16
+ </args>
17
+ </troopid_connect>
18
+ </routers>
19
+
20
+ <layout>
21
+ <updates>
22
+ <troopid_connect>
23
+ <file>troopid_connect.xml</file>
24
+ </troopid_connect>
25
+ </updates>
26
+ </layout>
27
+
28
+ <translate>
29
+ <modules>
30
+ <TroopID_Connect>
31
+ <files>
32
+ <default>TroopID_Connect.csv</default>
33
+ </files>
34
+ </TroopID_Connect>
35
+ </modules>
36
+ </translate>
37
+ </frontend>
38
+
39
+ <adminhtml>
40
+ <layout>
41
+ <updates>
42
+ <troopid_connect>
43
+ <file>troopid_connect.xml</file>
44
+ </troopid_connect>
45
+ </updates>
46
+ </layout>
47
+
48
+ <translate>
49
+ <modules>
50
+ <TroopID_Connect>
51
+ <files>
52
+ <default>TroopID_Connect.csv</default>
53
+ </files>
54
+ </TroopID_Connect>
55
+ </modules>
56
+ </translate>
57
+ </adminhtml>
58
+
59
+ <global>
60
+ <events>
61
+ <salesrule_rule_condition_combine>
62
+ <observers>
63
+ <add_condition_to_sales_rule>
64
+ <class>troopid_connect/rule_observer</class>
65
+ <method>addCondition</method>
66
+ </add_condition_to_sales_rule>
67
+ </observers>
68
+ </salesrule_rule_condition_combine>
69
+ </events>
70
+
71
+ <fieldsets>
72
+ <sales_convert_quote>
73
+ <troopid_affiliation>
74
+ <to_order>*</to_order>
75
+ </troopid_affiliation>
76
+ <troopid_uid>
77
+ <to_order>*</to_order>
78
+ </troopid_uid>
79
+ </sales_convert_quote>
80
+ </fieldsets>
81
+
82
+ <models>
83
+ <troopid_connect>
84
+ <class>TroopID_Connect_Model</class>
85
+ </troopid_connect>
86
+ </models>
87
+
88
+ <blocks>
89
+ <troopid_connect>
90
+ <class>TroopID_Connect_Block</class>
91
+ </troopid_connect>
92
+ </blocks>
93
+
94
+ <helpers>
95
+ <troopid_connect>
96
+ <class>TroopID_Connect_Helper</class>
97
+ </troopid_connect>
98
+ </helpers>
99
+
100
+ <resources>
101
+ <troopid_connect_setup>
102
+ <setup>
103
+ <module>TroopID_Connect</module>
104
+ <class>Mage_Sales_Model_Mysql4_Setup</class>
105
+ </setup>
106
+ <connection>
107
+ <use>core_setup</use>
108
+ </connection>
109
+ </troopid_connect_setup>
110
+
111
+ <troopid_connect_write>
112
+ <connection>
113
+ <use>core_write</use>
114
+ </connection>
115
+ </troopid_connect_write>
116
+
117
+ <troopid_connect_read>
118
+ <connection>
119
+ <use>core_read</use>
120
+ </connection>
121
+ </troopid_connect_read>
122
+ </resources>
123
+ </global>
124
+
125
+ <default>
126
+ <troopid_connect>
127
+ <settings>
128
+ <enabled>1</enabled>
129
+ <sandbox_mode>1</sandbox_mode>
130
+ <about><![CDATA[
131
+ <p><strong>Who is eligible for Troop ID membership?</strong><br/>
132
+ Veterans, Service Members, Retirees, Military Spouses and their Immediate Family Members i.e. parents and children of Veterans, Service Members, Retirees and Military Spouses are eligible to sign up for Troop ID.</p>
133
+ <p><strong>Does signing up for Troop ID mean I'll start receiving newsletters and promotions from Troop ID?</strong><br/>
134
+ No, you may receive a message inviting you to opt in to relevant communications, but you are not required or automatically signed up for these newsletters.</p>
135
+ ]]>
136
+ </about>
137
+ </settings>
138
+ </troopid_connect>
139
+ </default>
140
+ </config>
app/code/community/TroopID/Connect/etc/system.xml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <tabs>
3
+ <troopid_config translate="label" module="troopid_connect">
4
+ <label>Troop ID Settings</label>
5
+ <sort_order>99999</sort_order>
6
+ </troopid_config>
7
+ </tabs>
8
+ <sections>
9
+ <troopid_connect translate="label" module="troopid_connect">
10
+ <label>Troop ID Connect</label>
11
+ <tab>troopid_config</tab>
12
+ <sort_order>9999</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ <groups>
17
+ <settings translate="label" module="troopid_connect">
18
+ <label>Application Settings</label>
19
+ <expanded>1</expanded>
20
+ <sort_order>10</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <frontend_class>troopid</frontend_class>
25
+ <fields>
26
+ <info type="group" translate="label comment">
27
+ <label>Troop ID Military Affiliation Verification</label>
28
+ <frontend_class>troopid-connect first</frontend_class>
29
+ <frontend_model>troopid_connect/adminhtml_system_config_help</frontend_model>
30
+ <comment>
31
+ <![CDATA[Create discounts on special offers exclusively for verified military members via Troop ID]]>
32
+ </comment>
33
+ <sort_order>0</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </info>
38
+ <instructions type="group" translate="label">
39
+ <label>Required steps to get started</label>
40
+ <frontend_class>troopid-connect last</frontend_class>
41
+ <frontend_model>troopid_connect/adminhtml_system_config_instructions</frontend_model>
42
+ <sort_order>1</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <developer_url><![CDATA[https://developer.troopid.com]]></developer_url>
47
+ <apps_url><![CDATA[https://developer.troopid.com/apps]]></apps_url>
48
+ <docs_url><![CDATA[https://developer.troopid.com/docs]]></docs_url>
49
+ <learn_more_url><![CDATA[https://www.troopid.com/learn_more]]></learn_more_url>
50
+ </instructions>
51
+
52
+ <enabled translate="label">
53
+ <label>Enabled?</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>2</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ <comment/>
61
+ </enabled>
62
+ <client_id translate="label">
63
+ <label>Client ID</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>3</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <comment/>
70
+ </client_id>
71
+ <client_secret translate="label">
72
+ <label>Client Secret</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>4</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <comment/>
79
+ </client_secret>
80
+ <sandbox_mode translate="label">
81
+ <label>Sandbox Mode?</label>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>adminhtml/system_config_source_yesno</source_model>
84
+ <sort_order>5</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ <comment/>
89
+ </sandbox_mode>
90
+ <about translate="label comment">
91
+ <label>Instructions</label>
92
+ <frontend_type>textarea</frontend_type>
93
+ <sort_order>6</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <comment>
98
+ <![CDATA[This text will be displayed as "What is this?" in your shopping cart next to Troop ID Connect button]]>
99
+ </comment>
100
+ </about>
101
+ </fields>
102
+ </settings>
103
+ </groups>
104
+ </troopid_connect>
105
+ </sections>
106
+ </config>
app/code/community/TroopID/Connect/sql/troopid_connect_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $this->startSetup();
4
+
5
+ $this->getConnection()->addColumn($this->getTable("sales/order"), "troopid_affiliation", "varchar(255)");
6
+ $this->getConnection()->addColumn($this->getTable("sales/order"), "troopid_uid", "varchar(128)");
7
+
8
+ $this->getConnection()->addColumn($this->getTable("sales/quote"), "troopid_affiliation", "varchar(255)");
9
+ $this->getConnection()->addColumn($this->getTable("sales/quote"), "troopid_uid", "varchar(128)");
10
+
11
+ $this->endSetup();
app/design/adminhtml/default/default/layout/troopid_connect.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>troopid_connect/troopid.css</stylesheet></action>
6
+ </reference>
7
+ </default>
8
+
9
+ <adminhtml_sales_order_view>
10
+ <reference name="order_info">
11
+ <action method="setTemplate">
12
+ <template>troopid/connect/order.phtml</template>
13
+ </action>
14
+ </reference>
15
+ </adminhtml_sales_order_view>
16
+ </layout>
app/design/adminhtml/default/default/template/troopid/connect/order.phtml ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php $_order = $this->getOrder() ?>
28
+ <?php
29
+ $orderAdminDate = $this->formatDate($_order->getCreatedAtDate(), 'medium', true);
30
+ $orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true);
31
+ ?>
32
+ <div class="box-left">
33
+ <!--Order Information-->
34
+ <div class="entry-edit">
35
+ <?php if ($_order->getEmailSent()):
36
+ $_email = Mage::helper('sales')->__('the order confirmation email was sent');
37
+ else:
38
+ $_email = Mage::helper('sales')->__('the order confirmation email is not sent');
39
+ endif; ?>
40
+ <div class="entry-edit-head">
41
+ <?php if ($this->getNoUseOrderLink()): ?>
42
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?> (<?php echo $_email ?>)</h4>
43
+ <?php else: ?>
44
+ <a href="<?php echo $this->getViewUrl($_order->getId()) ?>"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?></a>
45
+ <strong>(<?php echo $_email ?>)</strong>
46
+ <?php endif; ?>
47
+ </div>
48
+ <div class="fieldset">
49
+ <table cellspacing="0" class="form-list">
50
+ <tr>
51
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date') ?></label></td>
52
+ <td class="value"><strong><?php echo $orderAdminDate ?></strong></td>
53
+ </tr>
54
+ <?php if ($orderAdminDate != $orderStoreDate):?>
55
+ <tr>
56
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date (%s)', $_order->getCreatedAtStoreDate()->getTimezone()) ?></label></td>
57
+ <td class="value"><strong><?php echo $orderStoreDate ?></strong></td>
58
+ </tr>
59
+ <?php endif;?>
60
+ <tr>
61
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Status') ?></label></td>
62
+ <td class="value"><strong><span id="order_status"><?php echo $_order->getStatusLabel() ?></span></strong></td>
63
+ </tr>
64
+ <tr>
65
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Purchased From') ?></label></td>
66
+ <td class="value"><strong><?php echo $this->getOrderStoreName() ?></strong></td>
67
+ </tr>
68
+ <?php if($_order->getRelationChildId()): ?>
69
+ <tr>
70
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the New Order') ?></label></td>
71
+ <td class="value"><a href="<?php echo $this->getViewUrl($_order->getRelationChildId()) ?>">
72
+ <?php echo $_order->getRelationChildRealId() ?>
73
+ </a></td>
74
+ </tr>
75
+ <?php endif; ?>
76
+ <?php if($_order->getRelationParentId()): ?>
77
+ <tr>
78
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the Previous Order') ?></label></td>
79
+ <td class="value"><a href="<?php echo $this->getViewUrl($_order->getRelationParentId()) ?>">
80
+ <?php echo $_order->getRelationParentRealId() ?>
81
+ </a></td>
82
+ </tr>
83
+ <?php endif; ?>
84
+ <?php if($_order->getRemoteIp() && $this->shouldDisplayCustomerIp()): ?>
85
+ <tr>
86
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Placed from IP') ?></label></td>
87
+ <td class="value"><strong><?php echo $_order->getRemoteIp(); echo ($_order->getXForwardedFor())?' (' . $this->escapeHtml($_order->getXForwardedFor()) . ')':''; ?></strong></td>
88
+ </tr>
89
+ <?php endif; ?>
90
+ <?php if($_order->getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?>
91
+ <tr>
92
+ <td class="label"><label><?php echo Mage::helper('sales')->__('%s / %s rate:', $_order->getGlobalCurrencyCode(), $_order->getBaseCurrencyCode()) ?></label></td>
93
+ <td class="value"><strong><?php echo $_order->getBaseToGlobalRate() ?></strong></td>
94
+ </tr>
95
+ <?php endif; ?>
96
+ <?php if($_order->getBaseCurrencyCode() != $_order->getOrderCurrencyCode()): ?>
97
+ <tr>
98
+ <td class="label"><label><?php echo Mage::helper('sales')->__('%s / %s rate:', $_order->getOrderCurrencyCode(), $_order->getBaseCurrencyCode()) ?></label></td>
99
+ <td class="value"><strong><?php echo $_order->getBaseToOrderRate() ?></strong></td>
100
+ </tr>
101
+ <?php endif; ?>
102
+ </table>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ <div class="box-right">
107
+ <!--Account Information-->
108
+ <div class="entry-edit">
109
+ <div class="entry-edit-head">
110
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Account Information') ?></h4>
111
+ <div class="tools"><?php echo $this->getAccountEditLink()?></div>
112
+ </div>
113
+ <div class="fieldset">
114
+ <div class="hor-scroll">
115
+ <table cellspacing="0" class="form-list">
116
+ <tr>
117
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Name') ?></label></td>
118
+ <td class="value">
119
+ <?php if ($_customerUrl=$this->getCustomerViewUrl()) : ?>
120
+ <a href="<?php echo $_customerUrl ?>" target="_blank"><strong><?php echo $this->htmlEscape($_order->getCustomerName()) ?></strong></a>
121
+ <?php else: ?>
122
+ <strong><?php echo $this->htmlEscape($_order->getCustomerName()) ?></strong>
123
+ <?php endif; ?>
124
+ </td>
125
+ </tr>
126
+ <tr>
127
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Email') ?></label></td>
128
+ <td class="value"><a href="mailto:<?php echo $_order->getCustomerEmail() ?>"><strong><?php echo $_order->getCustomerEmail() ?></strong></a></td>
129
+ </tr>
130
+ <?php if ($_groupName = $this->getCustomerGroupName()) : ?>
131
+ <tr>
132
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Group') ?></label></td>
133
+ <td class="value"><strong><?php echo $_groupName ?></strong></td>
134
+ </tr>
135
+ <?php endif; ?>
136
+ <?php foreach ($this->getCustomerAccountData() as $data):?>
137
+ <tr>
138
+ <td class="label"><label><?php echo $data['label'] ?></label></td>
139
+ <td class="value"><strong><?php echo $data['value'] ?></strong></td>
140
+ </tr>
141
+ <?php endforeach;?>
142
+ </table>
143
+ </div>
144
+ </div>
145
+ </div>
146
+
147
+ <div class="entry-edit">
148
+ <div class="entry-edit-head">
149
+ <h4 class="icon-head head-account"><?php echo Mage::helper("troopid_connect")->__("Troop ID Verified Affiliation") ?></h4>
150
+ <div class="tools"></div>
151
+ </div>
152
+ <div class="fieldset">
153
+ <div class="hor-scroll">
154
+ <table cellspacing="0" class="form-list">
155
+ <tr>
156
+ <td class="label">
157
+ <label><?php echo Mage::helper("troopid_connect")->__("Affiliation") ?></label>
158
+ </td>
159
+ <td class="value">
160
+ <strong><?php echo $this->getOrder()->getTroopidAffiliation() ?></strong>
161
+ </td>
162
+ </tr>
163
+ <tr>
164
+ <td class="label">
165
+ <label><?php echo Mage::helper("troopid_connect")->__("UID") ?></label>
166
+ </td>
167
+ <td class="value">
168
+ <strong><?php echo $this->getOrder()->getTroopidUid() ?></strong>
169
+ </td>
170
+ </tr>
171
+ </table>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ <div class="clear"></div>
177
+
178
+ <div class="box-left">
179
+ <!--Billing Address-->
180
+ <div class="entry-edit">
181
+ <div class="entry-edit-head">
182
+ <h4 class="icon-head head-billing-address"><?php echo Mage::helper('sales')->__('Billing Address') ?></h4>
183
+ <div class="tools"><?php echo $this->getAddressEditLink($_order->getBillingAddress())?></div>
184
+ </div>
185
+ <fieldset>
186
+ <address><?php echo $_order->getBillingAddress()->getFormated(true) ?></address>
187
+ </fieldset>
188
+ </div>
189
+ </div>
190
+ <?php if (!$this->getOrder()->getIsVirtual()): ?>
191
+ <div class="box-right">
192
+ <!--Shipping Address-->
193
+ <div class="entry-edit">
194
+ <div class="entry-edit-head">
195
+ <h4 class="icon-head head-shipping-address"><?php echo Mage::helper('sales')->__('Shipping Address') ?></h4>
196
+ <div class="tools"><?php echo $this->getAddressEditLink($_order->getShippingAddress())?></div>
197
+ </div>
198
+ <fieldset>
199
+ <address><?php echo $_order->getShippingAddress()->getFormated(true) ?></address>
200
+ </fieldset>
201
+ </div>
202
+ </div>
203
+ <div class="clear"></div>
204
+ <?php endif; ?>
app/design/frontend/default/default/layout/troopid_connect.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>troopid_connect/troopid.css</stylesheet></action>
6
+ </reference>
7
+ <reference name="footer">
8
+ <block type="troopid_connect/cart" name="troopid.connect.script" as="script" template="troopid/connect/script.phtml" />
9
+ </reference>
10
+ </default>
11
+
12
+ <checkout_cart_index>
13
+ <reference name="checkout.cart">
14
+ <block type="core/text_list" name="checkout.cart.extra">
15
+ <block type="troopid_connect/cart" name="checkout.cart.connect" as="connect" template="troopid/connect/cart.phtml"/>
16
+ </block>
17
+ </reference>
18
+ </checkout_cart_index>
19
+
20
+ <troopid_connect_authorize_callback>
21
+ <block type="page/html" name="root" output="toHtml" template="troopid/connect/callback.phtml"/>
22
+ </troopid_connect_authorize_callback>
23
+ </layout>
app/design/frontend/default/default/template/troopid/connect/callback.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <script type="text/javascript">
4
+ window.opener.location.reload();
5
+ window.close();
6
+ </script>
7
+ </head>
8
+ <body>
9
+ </body>
10
+ </html>
app/design/frontend/default/default/template/troopid/connect/cart.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="discount troopid-connect">
2
+ <h2><?php echo $this->__("Military Discounts with Troop ID") ?></h2>
3
+ <?php if ($this->hasAffiliation()): ?>
4
+ <div class="affiliation">
5
+ <?php echo $this->__("You have verified yourself as") . " <strong>" . $this->getAffiliation() . "</strong>" ?>
6
+ </div>
7
+ <?php else: ?>
8
+ <div class="button">
9
+ <a href="javascript:void(0);" id="troopid-connect-trigger" title="<?php echo $this->__("Verify your military affiliation with Troop ID") ?>">
10
+ <img alt="<?php echo $this->__("Verify your military affiliation with Troop ID") ?>" src="https://s3.amazonaws.com/troopid/buttons/verify-button-red-235x40.png" />
11
+ </a>
12
+ </div>
13
+ <?php endif ?>
14
+ <div class="about">
15
+ <a href="javascript:void(0);" id="troopid-modal-trigger"><?php echo $this->__("What is this?") ?></a>
16
+ </div>
17
+
18
+ <div id="troopid-modal" style="display: none;"></div>
19
+ <div id="troopid-modal-content" style="display: none;">
20
+ <h3><?php echo $this->__("What is Troop ID?") ?></h3>
21
+ <a href="javascript:void(0);" class="close" id="troopid-modal-closer">[x]</a>
22
+ <?php echo $this->getAbout() ?>
23
+ </div>
24
+ </div>
app/design/frontend/default/default/template/troopid/connect/script.phtml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ if (typeof(TroopID) == "undefined")
3
+ TroopID = {};
4
+
5
+ TroopID.Connect = Class.create({
6
+
7
+ initialize: function(selector) {
8
+ this.selector = $(selector);
9
+ this.selector.observe("click", this.open.bind(this));
10
+ },
11
+
12
+ open: function(event) {
13
+ window.open("<?php echo $this->getEndpoint() ?>", "", "scrollbars=yes,menubar=no,status=no,location=no,toolbar=no,width=750,height=620,top=" + this.getTop() + ",left=" + this.getLeft());
14
+ },
15
+
16
+ getTop: function() {
17
+ return (document.viewport.getHeight() - 780) / 3;
18
+ },
19
+
20
+ getLeft: function() {
21
+ return (document.viewport.getWidth() - 750) / 2;
22
+ }
23
+
24
+ });
25
+
26
+ TroopID.Modal = Class.create({
27
+
28
+ initialize: function(selector) {
29
+ this.selector = $(selector);
30
+ this.selector.observe("click", this.open.bind(this));
31
+
32
+ this.overlay = $("troopid-modal");
33
+ this.content = $("troopid-modal-content");
34
+ this.closer = $("troopid-modal-closer");
35
+
36
+ this.overlay.observe("click", this.close.bind(this));
37
+ this.closer.observe("click", this.close.bind(this));
38
+
39
+ document.observe("keypress", function(event) {
40
+ if (event.keyCode == 27)
41
+ this.close();
42
+ }.bind(this));
43
+ },
44
+
45
+ open: function() {
46
+ this.content.setStyle({
47
+ width: this.getWidth() + "px",
48
+ left: ((document.viewport.getWidth() - this.getWidth()) / 2) + "px"
49
+ });
50
+ this.overlay.show();
51
+ this.content.show();
52
+ },
53
+
54
+ close: function() {
55
+ this.content.hide();
56
+ this.overlay.hide();
57
+ },
58
+
59
+ getWidth: function() {
60
+ return (document.viewport.getWidth() / 4);
61
+ },
62
+
63
+ getHeight: function() {
64
+ return (document.viewport.getHeight() / 2);
65
+ }
66
+
67
+ });
68
+
69
+ document.observe("dom:loaded", function() {
70
+ new TroopID.Connect("troopid-connect-trigger");
71
+ new TroopID.Modal("troopid-modal-trigger");
72
+ });
73
+ </script>
app/etc/modules/TroopID_Connect.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category troopid
5
+ * @package troopid_connect
6
+ */
7
+ -->
8
+ <config>
9
+ <modules>
10
+ <TroopID_Connect>
11
+ <active>true</active>
12
+ <codePool>community</codePool>
13
+ <depends>
14
+ <Mage_Sales/>
15
+ </depends>
16
+ </TroopID_Connect>
17
+ </modules>
18
+ </config>
app/locale/en_US/TroopID_Connect.csv ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Troop ID Attribute, Troop ID Attribute
2
+ Troop ID Verified Affiliation, Troop ID Verified Affiliation
3
+ Military Family, Military Family
4
+ Military Spouse, Military Spouse
5
+ Retiree, Retiree
6
+ Service Member, Service Member
7
+ Veteran, Veteran
8
+ Military Discounts with Troop ID, Military Discounts with Troop ID
9
+ Verify your military affiliation with Troop ID, Verify your military affiliation with Troop ID
10
+ Fill in <strong>Redirect URI</strong> with, Fill in <strong>Redirect URI</strong> with
11
+ Fill in <strong>Base URI</strong> with, Fill in <strong>Base URI</strong> with
12
+
13
+ Troop ID Settings, Troop ID Settings
14
+ Application Settings, Application Settings
15
+ Enabled?, Enabled?
16
+ Sandbox Mode?, Sandbox Mode?
17
+ Client ID, Client ID
18
+ Client Secret, Client Secret
19
+ Instructions, Instructions
20
+ Troop ID Military Affiliation Verification, Troop ID Military Affiliation Verification
21
+ Create discounts on special offers exclusively for verified military members via Troop ID, Create discounts on special offers exclusively for verified military members via Troop ID
22
+ Required steps to get started, Required steps to get started
23
+ Create a developer account at, Create a developer account at
24
+ Register an application at, Register an application at
25
+ Copy and paste your Client ID and Client Secret values from your application settings on Troop ID, Copy and paste your Client ID and Client Secret values from your application settings on Troop ID
26
+ This text will be displayed as "What is this?" in your shopping cart next to Troop ID Connect button, This text will be displayed as "What is this?" in your shopping cart next to Troop ID Connect button
27
+ Troop ID verification failed, please contact the store owner, Troop ID verification failed, please contact the store owner
28
+ Unfortunately your affiliation is not verified on Troop ID, Unfortunately your affiliation is not verified on Troop ID
29
+ You have verified yourself as, You have verified yourself as
30
+ What is this?, What is this?
31
+ What is Troop ID?, What is Troop ID?
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>TroopID_Connect</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>TroopID Connect integration.</summary>
10
+ <description>N/A</description>
11
+ <notes>N/A</notes>
12
+ <authors><author><name>Troop ID</name><user>troopid</user><email>support@troopid.com</email></author></authors>
13
+ <date>2012-12-13</date>
14
+ <time>18:48:14</time>
15
+ <contents><target name="magecommunity"><dir name="TroopID"><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Help.php" hash="dbb0fb61c7d5a7dbe61620d26afaea3c"/><file name="Instructions.php" hash="a418f1b2733f83a22c3c1ffd156ef237"/></dir></dir></dir><file name="Cart.php" hash="2f4aee3250d9e396f4db3cbfe0bb8c3d"/></dir><dir name="Helper"><file name="Data.php" hash="784a3105a77f3651fc26e70ad1a849b6"/><file name="Oauth.php" hash="bf60a13267c383026c3f2074378949e6"/></dir><dir name="Model"><dir name="Rule"><file name="Condition.php" hash="d11bda0d429870d3c33deffa89ad281b"/><file name="Observer.php" hash="ba4faa579190480aa5e497c5632e5649"/></dir></dir><dir name="controllers"><file name="AuthorizeController.php" hash="8b16894d853ea569bf18dbd1f0b8c287"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e96ed1474688e377a910dbbc48317978"/><file name="config.xml" hash="ac8d9da7c6b22ad2fb6e8a74febc81c5"/><file name="system.xml" hash="33a49f6320c0febe9ce136e82ac890c6"/></dir><dir name="sql"><dir name="troopid_connect_setup"><file name="mysql4-install-0.1.0.php" hash="2ed9e5f82407c756477d7fc2d3cd20ff"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="troopid_connect.xml" hash="40661e46e044c7b154114bf7feea3a2e"/></dir><dir name="template"><dir name="troopid"><dir name="connect"><file name="order.phtml" hash="47d0a58564e02b5326a700da28496238"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="troopid_connect.xml" hash="7d1b6a846a7b26d0eac1671a5edb8096"/></dir><dir name="template"><dir name="troopid"><dir name="connect"><file name="callback.phtml" hash="71b10af7408d6f50999529c08aa75dfb"/><file name="cart.phtml" hash="1e1accd15ca8aadabd699ebb1d4cfaf9"/><file name="script.phtml" hash="d8d34c032c5a68000125008c26b84f57"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TroopID_Connect.xml" hash="c599f9e8aa2c1296fbfb08db03b0d001"/></dir></target><target name="magelocale"><dir name="en_US"><file name="TroopID_Connect.csv" hash="fd903faf1751e6b9712b055bcf93af43"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="troopid_connect"><dir name="images"><file name="logo.png" hash="b4652dab2eddd53440f36c353524beaa"/></dir><file name="troopid.css" hash="1a66f25f2b81ff569fc592de18f5ffb3"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="troopid_connect"><file name="troopid.css" hash="e5d27c03f451777841bcbe290cadb813"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/troopid_connect/images/logo.png ADDED
Binary file
skin/adminhtml/default/default/troopid_connect/troopid.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .troopid .form-list {
2
+ width: 100%;
3
+
4
+ }
5
+ .troopid-connect.first {
6
+ margin: 5px 0 0 0;
7
+ }
8
+ .troopid-connect.last {
9
+ margin: 0 0 10px 0;
10
+ }
11
+ .troopid-connect fieldset.config {
12
+ display: none;
13
+ }
14
+ .troopid-connect .heading {
15
+ display: block;
16
+ float: none;
17
+ }
18
+ .troopid-connect.first .heading {
19
+ padding: 2px 0 0 150px;
20
+ background: url("images/logo.png") no-repeat scroll 0 0 transparent;
21
+ }
22
+ .troopid-connect .steps {
23
+ margin: 0 0 0 15px;
24
+ list-style: square;
25
+ }
skin/frontend/default/default/troopid_connect/troopid.css ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .troopid-connect {
2
+ text-align: center;
3
+ }
4
+ .troopid-connect h2 {
5
+ padding: 0 !important;
6
+ background: none !important;
7
+ }
8
+ .troopid-connect .button {
9
+ margin: 10px 0 0 0;
10
+ }
11
+
12
+ .troopid-connect .about {
13
+ margin: 10px 0 0 0;
14
+ }
15
+
16
+ #troopid-modal {
17
+ position: fixed;
18
+ top: 0;
19
+ left: 0;
20
+ width: 100%;
21
+ height: 100%;
22
+ background: #000000;
23
+ opacity: 0.75;
24
+ z-index: 100;
25
+ }
26
+
27
+ #troopid-modal-content {
28
+ position: fixed;
29
+ left: 25%;
30
+ top: 25%;
31
+ background: #ffffff;
32
+ opacity: 1;
33
+ z-index: 200;
34
+ text-align: left;
35
+ padding: 20px;
36
+ max-width: 900px;
37
+ }
38
+
39
+ #troopid-modal-content h3 {
40
+ font-weight: bold;
41
+ display: inline-block;
42
+ }
43
+
44
+ #troopid-modal-content .close {
45
+ float: right;
46
+ font-weight: bold;
47
+ margin: -5px 0 0 0;
48
+ text-decoration: none;
49
+ }