Bronto_Extension - Version 2.2.0

Version Notes

For installation and configuration instructions, as well as a full list of new features and known issues, please review the Implementation Guide.

Download this release

Release Info

Developer Chris Geiss
Extension Bronto_Extension
Version 2.2.0
Comparing to
See all releases


Code changes from version 2.1.0 to 2.2.0

Files changed (310) hide show
  1. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/About.php +20 -9
  2. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron.php +31 -11
  3. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field.php +16 -5
  4. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Apitoken.php +106 -103
  5. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Debug.php +13 -4
  6. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Download.php +14 -5
  7. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Hidden.php +1 -1
  8. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Image.php +5 -3
  9. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/List.php +2 -1
  10. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support.php +2 -2
  11. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support/Site.php +10 -9
  12. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Fieldset.php +4 -2
  13. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Guide.php +109 -0
  14. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Support.php +1 -0
  15. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Suppressed.php +67 -0
  16. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Abstract.php +45 -38
  17. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Debug.php +5 -2
  18. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Download.php +10 -8
  19. app/code/community/Bronto/Common/Block/Popup.php +18 -0
  20. app/code/community/Bronto/Common/Helper/Contact.php +7 -5
  21. app/code/community/Bronto/Common/Helper/Data.php +429 -170
  22. app/code/community/Bronto/Common/Helper/DataInterface.php +5 -4
  23. app/code/community/Bronto/Common/Helper/Field.php +5 -5
  24. app/code/community/Bronto/Common/Helper/Message.php +46 -16
  25. app/code/community/Bronto/Common/Helper/Product.php +25 -13
  26. app/code/community/Bronto/Common/Helper/Salesrule.php +77 -0
  27. app/code/community/Bronto/Common/Helper/Support.php +131 -72
  28. app/code/community/Bronto/Common/Model/Api.php +7 -8
  29. app/code/community/Bronto/Common/Model/Archive.php +75 -62
  30. app/code/community/Bronto/Common/Model/Email/Template.php +80 -33
  31. app/code/community/Bronto/Common/Model/Email/Template/Filter.php +303 -28
  32. app/code/community/Bronto/Common/Model/Email/Template/Templatefilter.php +17 -5
  33. app/code/community/Bronto/Common/Model/Keysentry.php +41 -18
  34. app/code/community/Bronto/Common/Model/Observer.php +79 -51
  35. app/code/community/Bronto/Common/Model/Resource/Setup.php +3 -4
  36. app/code/community/Bronto/Common/Model/SoapClient.php +22 -0
  37. app/code/community/Bronto/Common/Model/System/Config/Backend/Cron.php +83 -29
  38. app/code/community/Bronto/Common/Model/System/Config/Backend/Enable.php +0 -1
  39. app/code/community/Bronto/Common/Model/System/Config/Backend/Token.php +64 -28
  40. app/code/community/Bronto/Common/Model/System/Config/Source/Contact/Status.php +2 -1
  41. app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Frequency.php +3 -3
  42. app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Minutes.php +2 -2
  43. app/code/community/Bronto/Common/Model/System/Config/Source/Field.php +3 -1
  44. app/code/community/Bronto/Common/Model/System/Config/Source/Image.php +2 -2
  45. app/code/community/Bronto/Common/Model/System/Config/Source/Limit.php +8 -6
  46. app/code/community/Bronto/Common/Model/System/Config/Source/List.php +1 -1
  47. app/code/community/Bronto/Common/Model/System/Config/Source/Message.php +4 -0
  48. app/code/community/Bronto/Common/Model/System/Config/Source/Role.php +3 -3
  49. app/code/community/Bronto/Common/Model/System/Config/Source/Synclimit.php +4 -5
  50. app/code/community/Bronto/Common/controllers/Adminhtml/DebugController.php +18 -8
  51. app/code/community/Bronto/Common/controllers/Adminhtml/GuidersController.php +21 -0
  52. app/code/community/Bronto/Common/controllers/LogController.php +5 -11
  53. app/code/community/Bronto/Common/etc/adminhtml.xml +4 -0
  54. app/code/community/Bronto/Common/etc/config.xml +34 -10
  55. app/code/community/Bronto/Common/etc/system.xml +155 -11
  56. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/About.php +0 -1
  57. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Cron.php +14 -3
  58. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Rewardpoints.php +44 -0
  59. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Storecredit.php +44 -0
  60. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes.php +126 -41
  61. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Address.php +0 -1
  62. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Customer.php +1 -1
  63. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Suppressed.php +19 -0
  64. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Reset.php +1 -2
  65. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Run.php +1 -1
  66. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Sync.php +3 -4
  67. app/code/community/Bronto/Customer/Helper/Data.php +115 -31
  68. app/code/community/Bronto/Customer/Model/Mysql4/Queue.php +2 -2
  69. app/code/community/Bronto/Customer/Model/Mysql4/Queue/Collection.php +7 -1
  70. app/code/community/Bronto/Customer/Model/Mysql4/Setup.php +0 -1
  71. app/code/community/Bronto/Customer/Model/Observer.php +210 -84
  72. app/code/community/Bronto/Customer/Model/Queue.php +9 -6
  73. app/code/community/Bronto/Customer/Model/System/Config/Backend/Brontofield.php +12 -3
  74. app/code/community/Bronto/Customer/Model/System/Config/Backend/Cron.php +16 -0
  75. app/code/community/Bronto/Customer/Model/System/Config/Backend/Newfield.php +11 -9
  76. app/code/community/Bronto/Customer/controllers/Adminhtml/CustomerController.php +117 -9
  77. app/code/community/Bronto/Customer/etc/config.xml +1 -0
  78. app/code/community/Bronto/Customer/etc/system.xml +128 -46
  79. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.0.php +1 -1
  80. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.3.php +2 -1
  81. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.0-1.0.1.php +1 -1
  82. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.1-1.0.2.php +1 -1
  83. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.2-1.0.3.php +14 -2
  84. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/About.php +0 -1
  85. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Settings.php +5 -4
  86. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates.php +79 -42
  87. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Field.php +2 -1
  88. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Fieldset.php +98 -63
  89. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Label.php +4 -3
  90. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Sendtype.php +2 -1
  91. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import.php +9 -8
  92. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Edit.php +2 -3
  93. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid.php +19 -16
  94. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid/Renderer/Action.php +8 -7
  95. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log.php +3 -4
  96. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid.php +37 -25
  97. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Customer.php +2 -1
  98. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Fields.php +0 -1
  99. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template.php +13 -11
  100. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit.php +23 -15
  101. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit/Form.php +88 -69
  102. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid.php +41 -38
  103. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Action.php +9 -9
  104. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Storename.php +3 -3
  105. app/code/community/Bronto/Email/Helper/Contact.php +5 -1
  106. app/code/community/Bronto/Email/Helper/Data.php +79 -54
  107. app/code/community/Bronto/Email/Helper/Field.php +0 -1
  108. app/code/community/Bronto/Email/Helper/Message.php +0 -1
  109. app/code/community/Bronto/Email/Model/Log.php +0 -1
  110. app/code/community/Bronto/Email/Model/Message.php +0 -1
  111. app/code/community/Bronto/Email/Model/Mysql4/Log.php +0 -1
  112. app/code/community/Bronto/Email/Model/Mysql4/Log/Collection.php +3 -1
  113. app/code/community/Bronto/Email/Model/Mysql4/Message.php +0 -1
  114. app/code/community/Bronto/Email/Model/Mysql4/Message/Collection.php +0 -1
  115. app/code/community/Bronto/Email/Model/Mysql4/Template.php +7 -5
  116. app/code/community/Bronto/Email/Model/Mysql4/Template/Collection.php +2 -3
  117. app/code/community/Bronto/Email/Model/Observer.php +13 -9
  118. app/code/community/Bronto/Email/Model/Resource/Setup.php +16 -3
  119. app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Field.php +7 -4
  120. app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Sendtype.php +6 -3
  121. app/code/community/Bronto/Email/Model/System/Config/Backend/Usebronto.php +0 -1
  122. app/code/community/Bronto/Email/Model/System/Config/Source/Email/Template.php +42 -36
  123. app/code/community/Bronto/Email/Model/System/Config/Source/Sendtype.php +0 -1
  124. app/code/community/Bronto/Email/Model/Template.php +22 -13
  125. app/code/community/Bronto/Email/Model/Template/Import.php +42 -30
  126. app/code/community/Bronto/Email/Model/Template/Mailer.php +13 -10
  127. app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/LogController.php +1 -1
  128. app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/TemplateController.php +95 -66
  129. app/code/community/Bronto/Email/etc/config.xml +1 -1
  130. app/code/community/Bronto/Email/etc/system.xml +1 -1
  131. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.8.php +64 -0
  132. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.7-1.1.8.php +20 -0
  133. app/code/community/Bronto/Emailcapture/Block/Emailcapture.php +41 -0
  134. app/code/community/Bronto/Emailcapture/Helper/Data.php +61 -0
  135. app/code/community/Bronto/Emailcapture/Model/Mysql4/Queue.php +36 -0
  136. app/code/community/Bronto/Emailcapture/Model/Mysql4/Queue/Collection.php +21 -0
  137. app/code/community/Bronto/Emailcapture/Model/Observer.php +66 -0
  138. app/code/community/Bronto/Emailcapture/Model/Queue.php +137 -0
  139. app/code/community/Bronto/Emailcapture/controllers/IndexController.php +39 -0
  140. app/code/community/Bronto/Emailcapture/etc/config.xml +119 -0
  141. app/code/community/Bronto/Emailcapture/etc/system.xml +41 -0
  142. app/code/community/Bronto/Emailcapture/sql/bronto_emailcapture_setup/mysql4-install-1.0.0.php +22 -0
  143. app/code/community/Bronto/News/Block/Adminhtml/ItemRender.php +1 -0
  144. app/code/community/Bronto/News/Block/Adminhtml/Redirect.php +2 -1
  145. app/code/community/Bronto/News/Block/Adminhtml/System/Config/News.php +31 -13
  146. app/code/community/Bronto/News/Helper/Data.php +30 -7
  147. app/code/community/Bronto/News/Model/Item.php +5 -1
  148. app/code/community/Bronto/News/Model/Observer.php +2 -0
  149. app/code/community/Bronto/News/Model/Resource/Setup.php +2 -1
  150. app/code/community/Bronto/News/controllers/Adminhtml/AnnouncementController.php +6 -3
  151. app/code/community/Bronto/News/controllers/RouteController.php +1 -0
  152. app/code/community/Bronto/News/etc/system.xml +1 -1
  153. app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/About.php +2 -1
  154. app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Cron.php +14 -3
  155. app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Suppressed.php +19 -0
  156. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Reset.php +1 -2
  157. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Run.php +1 -1
  158. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Sync.php +1 -2
  159. app/code/community/Bronto/Newsletter/Block/Checkout/Onepage/Newsletter.php +124 -37
  160. app/code/community/Bronto/Newsletter/Helper/Contact.php +20 -5
  161. app/code/community/Bronto/Newsletter/Helper/Data.php +96 -23
  162. app/code/community/Bronto/Newsletter/Model/Mysql4/Queue.php +4 -20
  163. app/code/community/Bronto/Newsletter/Model/Mysql4/Queue/Collection.php +33 -1
  164. app/code/community/Bronto/Newsletter/Model/Observer.php +105 -139
  165. app/code/community/Bronto/Newsletter/Model/Queue.php +10 -6
  166. app/code/community/Bronto/Newsletter/Model/System/Config/Backend/Cron.php +16 -0
  167. app/code/community/Bronto/Newsletter/controllers/Adminhtml/NewsletterController.php +123 -17
  168. app/code/community/Bronto/Newsletter/controllers/IndexController.php +71 -0
  169. app/code/community/Bronto/Newsletter/etc/config.xml +11 -9
  170. app/code/community/Bronto/Newsletter/etc/system.xml +42 -4
  171. app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.6.php +61 -0
  172. app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-upgrade-1.4.5-1.4.6.php +30 -0
  173. app/code/community/Bronto/Order/Block/Adminhtml/Sales/Order/View/Tab/Info.php +4 -5
  174. app/code/community/Bronto/Order/Block/Adminhtml/System/Config/About.php +4 -3
  175. app/code/community/Bronto/Order/Block/Adminhtml/System/Config/Cron.php +14 -3
  176. app/code/community/Bronto/Order/Block/Adminhtml/System/Config/Suppressed.php +19 -0
  177. app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Reset.php +3 -4
  178. app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Run.php +1 -1
  179. app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Sync.php +3 -4
  180. app/code/community/Bronto/Order/Block/Bta.php +6 -25
  181. app/code/community/Bronto/Order/Helper/Data.php +168 -28
  182. app/code/community/Bronto/Order/Model/Mysql4/Queue.php +2 -2
  183. app/code/community/Bronto/Order/Model/Mysql4/Queue/Collection.php +10 -1
  184. app/code/community/Bronto/Order/Model/Mysql4/Setup.php +21 -18
  185. app/code/community/Bronto/Order/Model/Observer.php +137 -86
  186. app/code/community/Bronto/Order/Model/Order/Observer.php +9 -5
  187. app/code/community/Bronto/Order/Model/Queue.php +13 -8
  188. app/code/community/Bronto/Order/Model/Quote/Observer.php +0 -1
  189. app/code/community/Bronto/Order/Model/System/Config/Backend/Cron.php +18 -3
  190. app/code/community/Bronto/Order/Model/System/Config/Source/Description.php +3 -4
  191. app/code/community/Bronto/Order/Model/System/Config/Source/Price.php +16 -0
  192. app/code/community/Bronto/Order/controllers/Adminhtml/OrderController.php +119 -10
  193. app/code/community/Bronto/Order/etc/config.xml +7 -1
  194. app/code/community/Bronto/Order/etc/system.xml +84 -10
  195. app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.0.0.php +4 -4
  196. app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.1.8.php +3 -2
  197. app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-upgrade-1.0.0-1.1.6.php +1 -1
  198. app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-upgrade-1.1.6-1.1.7.php +1 -1
  199. app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-upgrade-1.1.7-1.1.8.php +24 -2
  200. app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery.php +65 -0
  201. app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery/Grid.php +130 -0
  202. app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery/Grid/Renderer/Customer.php +28 -0
  203. app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery/Grid/Renderer/Fields.php +40 -0
  204. app/code/community/Bronto/Reminder/Block/Adminhtml/Promo/Notice.php +4 -4
  205. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder.php +40 -5
  206. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit.php +9 -8
  207. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Form.php +3 -3
  208. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Bronto.php +35 -14
  209. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Conditions.php +5 -6
  210. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Customers.php +39 -40
  211. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/General.php +76 -66
  212. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tabs.php +7 -10
  213. app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Grid.php +31 -29
  214. app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/About.php +2 -3
  215. app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/Cron.php +12 -3
  216. app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/Settings.php +7 -6
  217. app/code/community/Bronto/Reminder/Block/Adminhtml/Widget/Grid/Column/Renderer/Email.php +4 -3
  218. app/code/community/Bronto/Reminder/Block/Adminhtml/Widget/Grid/Column/Renderer/Id.php +9 -5
  219. app/code/community/Bronto/Reminder/Helper/Contact.php +7 -3
  220. app/code/community/Bronto/Reminder/Helper/Data.php +131 -40
  221. app/code/community/Bronto/Reminder/Helper/Message.php +2 -3
  222. app/code/community/Bronto/Reminder/Model/Condition/Abstract.php +11 -8
  223. app/code/community/Bronto/Reminder/Model/Condition/Combine/Abstract.php +20 -12
  224. app/code/community/Bronto/Reminder/Model/Delivery.php +14 -0
  225. app/code/community/Bronto/Reminder/Model/Email/Message.php +48 -6
  226. app/code/community/Bronto/Reminder/Model/Mysql4/Customer/Collection.php +10 -36
  227. app/code/community/Bronto/Reminder/Model/Mysql4/Delivery.php +13 -0
  228. app/code/community/Bronto/Reminder/Model/Mysql4/Delivery/Collection.php +42 -0
  229. app/code/community/Bronto/Reminder/Model/Mysql4/Rule.php +215 -94
  230. app/code/community/Bronto/Reminder/Model/Mysql4/Rule/Collection.php +17 -8
  231. app/code/community/Bronto/Reminder/Model/Observer.php +28 -16
  232. app/code/community/Bronto/Reminder/Model/Rule.php +66 -38
  233. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart.php +20 -16
  234. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Amount.php +10 -7
  235. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Attributes.php +13 -11
  236. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Combine.php +3 -6
  237. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Couponcode.php +7 -6
  238. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Itemsquantity.php +6 -6
  239. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Sku.php +9 -8
  240. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Storeview.php +9 -7
  241. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Subcombine.php +3 -6
  242. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Subselection.php +7 -6
  243. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Totalquantity.php +6 -6
  244. app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Virtual.php +6 -5
  245. app/code/community/Bronto/Reminder/Model/Rule/Condition/Combine.php +4 -6
  246. app/code/community/Bronto/Reminder/Model/Rule/Condition/Combine/Root.php +33 -48
  247. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist.php +13 -10
  248. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Attributes.php +13 -10
  249. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Combine.php +2 -3
  250. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Quantity.php +9 -8
  251. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Sharing.php +6 -5
  252. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Storeview.php +9 -7
  253. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Subcombine.php +2 -3
  254. app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Subselection.php +6 -5
  255. app/code/community/Bronto/Reminder/Model/System/Config/Backend/Allowsend.php +1 -2
  256. app/code/community/Bronto/Reminder/Model/System/Config/Backend/Cron.php +18 -3
  257. app/code/community/Bronto/Reminder/controllers/Adminhtml/DeliveryController.php +38 -0
  258. app/code/community/Bronto/Reminder/controllers/Adminhtml/RemindersController.php +40 -18
  259. app/code/community/Bronto/Reminder/controllers/LoadController.php +23 -16
  260. app/code/community/Bronto/Reminder/etc/config.xml +7 -1
  261. app/code/community/Bronto/Reminder/etc/system.xml +58 -19
  262. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.12.php +1 -1
  263. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.13.php +125 -0
  264. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.14.php +126 -0
  265. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.15.php +156 -0
  266. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.16.php +157 -0
  267. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.12-1.4.13.php +17 -0
  268. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.13-1.4.14.php +17 -0
  269. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.14-1.4.15.php +35 -0
  270. app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.15-1.4.16.php +39 -0
  271. app/code/community/Bronto/Reviews/Block/Adminhtml/System/Config/About.php +18 -0
  272. app/code/community/Bronto/Reviews/Helper/Contact.php +29 -0
  273. app/code/community/Bronto/Reviews/Helper/Data.php +179 -0
  274. app/code/community/Bronto/Reviews/Helper/Message.php +20 -0
  275. app/code/community/Bronto/Reviews/Model/Mysql4/Queue.php +27 -0
  276. app/code/community/Bronto/Reviews/Model/Mysql4/Queue/Collection.php +15 -0
  277. app/code/community/Bronto/Reviews/Model/Observer.php +398 -0
  278. app/code/community/Bronto/Reviews/Model/Queue.php +26 -0
  279. app/code/community/Bronto/Reviews/Model/System/Config/Source/Message.php +16 -0
  280. app/code/community/Bronto/Reviews/Model/System/Config/Source/Orderstatus.php +53 -0
  281. app/code/community/Bronto/Reviews/etc/adminhtml.xml +23 -0
  282. app/code/community/Bronto/Reviews/etc/config.xml +88 -0
  283. app/code/community/Bronto/Reviews/etc/system.xml +135 -0
  284. app/code/community/Bronto/Reviews/sql/bronto_reviews_setup/mysql4-install-0.0.1.php +24 -0
  285. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/About.php +2 -1
  286. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Advanced/Observersearch.php +45 -0
  287. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Conflictchecker.php +8 -7
  288. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Apitoken.php +28 -32
  289. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Button.php +3 -2
  290. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Classpath.php +104 -0
  291. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Conflict.php +4 -2
  292. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Events.php +99 -0
  293. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Roundtrip.php +6 -4
  294. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Magecron.php +39 -0
  295. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Permission.php +5 -5
  296. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Installs.php +350 -0
  297. app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Permissionchecker.php +6 -9
  298. app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Classpath.php +22 -0
  299. app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Conflict.php +0 -1
  300. app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Events.php +22 -0
  301. app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Permissions.php +0 -1
  302. app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Runroundtrip.php +0 -1
  303. app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Runtoken.php +0 -1
  304. app/code/community/Bronto/Verify/Block/Conflictprinter.php +2 -2
  305. app/code/community/Bronto/Verify/Block/Permissionprinter.php +1 -1
  306. app/code/community/Bronto/Verify/Helper/Apitoken.php +118 -10
  307. app/code/community/Bronto/Verify/Helper/Conflictchecker.php +0 -1
  308. app/code/community/Bronto/Verify/Helper/Data.php +147 -3
  309. app/code/community/Bronto/Verify/Helper/Permissionchecker.php +5 -5
  310. app/code/community/Bronto/Verify/{Helper/Roundtrip.php → Help} +0 -0
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/About.php CHANGED
@@ -3,22 +3,17 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @license http://opensource.org/licenses/OSL-3.0 Open Software License v. 3.0 (OSL-3.0)
7
  */
8
  class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
9
  {
10
  /**
11
  * Name of module
 
12
  * @var string
13
  */
14
  protected $_module = 'bronto_common';
15
 
16
- /**
17
- * Module display name
18
- * @var string
19
- */
20
- protected $_name = 'Bronto Extension for Magento';
21
-
22
  public function _construct()
23
  {
24
  parent::_construct();
@@ -27,6 +22,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
27
 
28
  /**
29
  * @param Varien_Data_Form_Element_Abstract $element
 
30
  * @return string
31
  */
32
  public function render(Varien_Data_Form_Element_Abstract $element)
@@ -36,6 +32,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
36
 
37
  /**
38
  * Get the module namespace
 
39
  * @return string
40
  */
41
  public function getModuleNamespace()
@@ -45,20 +42,33 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
45
 
46
  /**
47
  * Get the module name
 
48
  * @return string
49
  */
50
  public function getModuleName()
51
  {
52
- return $this->_name;
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
  /**
56
  * Get the module version
 
57
  * @return string
58
  */
59
  public function getModuleVersion()
60
  {
61
  $version = Mage::helper($this->_module)->getModuleVersion();
 
62
  return empty($version) ? null : "v{$version}";
63
  }
64
 
@@ -90,6 +100,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
90
  public function logFileExists()
91
  {
92
  $logFile = Mage::getBaseDir('log') . DIRECTORY_SEPARATOR . "{$this->_module}.log";
 
93
  return (bool)@file_exists($logFile);
94
  }
95
 
@@ -100,6 +111,6 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
100
  */
101
  public function isValidApiToken()
102
  {
103
- return Mage::helper('bronto_common')->validApiToken();
104
  }
105
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License v. 3.0 (OSL-3.0)
7
  */
8
  class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
9
  {
10
  /**
11
  * Name of module
12
+ *
13
  * @var string
14
  */
15
  protected $_module = 'bronto_common';
16
 
 
 
 
 
 
 
17
  public function _construct()
18
  {
19
  parent::_construct();
22
 
23
  /**
24
  * @param Varien_Data_Form_Element_Abstract $element
25
+ *
26
  * @return string
27
  */
28
  public function render(Varien_Data_Form_Element_Abstract $element)
32
 
33
  /**
34
  * Get the module namespace
35
+ *
36
  * @return string
37
  */
38
  public function getModuleNamespace()
42
 
43
  /**
44
  * Get the module name
45
+ *
46
  * @return string
47
  */
48
  public function getModuleName()
49
  {
50
+ return Mage::helper($this->_module)->getName();
51
+ }
52
+
53
+ /**
54
+ * Get Section Name
55
+ *
56
+ * @return string
57
+ */
58
+ public function getSection()
59
+ {
60
+ return Mage::app()->getRequest()->getParam('section');
61
  }
62
 
63
  /**
64
  * Get the module version
65
+ *
66
  * @return string
67
  */
68
  public function getModuleVersion()
69
  {
70
  $version = Mage::helper($this->_module)->getModuleVersion();
71
+
72
  return empty($version) ? null : "v{$version}";
73
  }
74
 
100
  public function logFileExists()
101
  {
102
  $logFile = Mage::getBaseDir('log') . DIRECTORY_SEPARATOR . "{$this->_module}.log";
103
+
104
  return (bool)@file_exists($logFile);
105
  }
106
 
111
  */
112
  public function isValidApiToken()
113
  {
114
+ return Mage::helper('bronto_verify/apitoken')->getStatus();
115
  }
116
  }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron.php CHANGED
@@ -3,24 +3,26 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
9
  {
10
  /**
11
  * Job code
 
12
  * @var string
13
  */
14
  protected $_jobCode;
15
 
16
  /**
17
  * Button widgets
 
18
  * @var array
19
  */
20
  protected $_buttons = array();
21
 
22
  /**
23
  * Progress bar
 
24
  * @var boolean
25
  */
26
  protected $_hasProgressBar = false;
@@ -49,6 +51,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
49
  * Render the block
50
  *
51
  * @param Varien_Data_Form_Element_Abstract $element
 
52
  * @return string
53
  */
54
  public function render(Varien_Data_Form_Element_Abstract $element)
@@ -75,6 +78,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
75
  * Note: Limits to 100 characters
76
  *
77
  * @param Mage_Cron_Model_Schedule $job
 
78
  * @return string
79
  */
80
  public function getTruncatedJobMessages($job)
@@ -97,7 +101,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
97
  }
98
 
99
  if (!empty($html)) {
100
- $html = "<p class=\"form-buttons\">{$html}</p>";
101
  }
102
 
103
  return $html;
@@ -105,12 +109,12 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
105
 
106
  protected function _getProgressComplete($total, $getCount = false, $getBar = true, $getLegend = false)
107
  {
108
- $html = '';
109
- $percent = 0;
110
- $pending = (int)$this->getProgressBarPending();
111
- $disabled = $this->_getProgressDisabled($total, true);
112
  $suppressed = $this->_getProgressSuppressed($total, true);
113
- $pending = $pending - $disabled;
114
 
115
  $count = $total - ($pending + $suppressed + $disabled);
116
 
@@ -142,9 +146,9 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
142
 
143
  protected function _getProgressSuppressed($total, $getCount = false, $getBar = true, $getLegend = false)
144
  {
145
- $html = '';
146
  $percent = 0;
147
- $count = (int)$this->getProgressBarSuppressed();
148
 
149
  if ($getCount) {
150
  return $count;
@@ -168,14 +172,15 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
168
  $html .= "<div class=\"bronto-progress-bar-legend-details\">Suppressed: {$percent}% ({$count}/{$total})</div>";
169
  $html .= '</div>';
170
  }
 
171
  return $html;
172
  }
173
 
174
  protected function _getProgressDisabled($total, $getCount = false, $getBar = true, $getLegend = false)
175
  {
176
- $html = '';
177
  $percent = 0;
178
- $count = (int)$this->getProgressBarDisabled();
179
 
180
  if ($getCount) {
181
  return $count;
@@ -242,6 +247,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
242
  * Color code the job status
243
  *
244
  * @param string $status
 
245
  * @return string
246
  */
247
  public function decorateJobStatus($status)
@@ -272,11 +278,13 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
272
  * Add button widget
273
  *
274
  * @param Mage_Adminhtml_Block_Widget_Button $button
 
275
  * @return Bronto_Common_Block_Adminhtml_System_Config_Cron
276
  */
277
  public function addButton(Mage_Adminhtml_Block_Widget_Button $button)
278
  {
279
  $this->_buttons[] = $button;
 
280
  return $this;
281
  }
282
 
@@ -294,11 +302,13 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
294
  * Set if we're using a progress bar
295
  *
296
  * @param bool $hasProgressBar
 
297
  * @return Bronto_Common_Block_Adminhtml_System_Config_Cron
298
  */
299
  public function setHasProgressBar($hasProgressBar)
300
  {
301
  $this->_hasProgressBar = $hasProgressBar;
 
302
  return $this;
303
  }
304
 
@@ -343,4 +353,14 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
343
  {
344
  return 0;
345
  }
 
 
 
 
 
 
 
 
 
 
346
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
8
  {
9
  /**
10
  * Job code
11
+ *
12
  * @var string
13
  */
14
  protected $_jobCode;
15
 
16
  /**
17
  * Button widgets
18
+ *
19
  * @var array
20
  */
21
  protected $_buttons = array();
22
 
23
  /**
24
  * Progress bar
25
+ *
26
  * @var boolean
27
  */
28
  protected $_hasProgressBar = false;
51
  * Render the block
52
  *
53
  * @param Varien_Data_Form_Element_Abstract $element
54
+ *
55
  * @return string
56
  */
57
  public function render(Varien_Data_Form_Element_Abstract $element)
78
  * Note: Limits to 100 characters
79
  *
80
  * @param Mage_Cron_Model_Schedule $job
81
+ *
82
  * @return string
83
  */
84
  public function getTruncatedJobMessages($job)
101
  }
102
 
103
  if (!empty($html)) {
104
+ $html = "<p class=\"form-buttons bronto-cron\">{$html}</p>";
105
  }
106
 
107
  return $html;
109
 
110
  protected function _getProgressComplete($total, $getCount = false, $getBar = true, $getLegend = false)
111
  {
112
+ $html = '';
113
+ $percent = 0;
114
+ $pending = (int)$this->getProgressBarPending();
115
+ $disabled = $this->_getProgressDisabled($total, true);
116
  $suppressed = $this->_getProgressSuppressed($total, true);
117
+ $pending = $pending - $disabled;
118
 
119
  $count = $total - ($pending + $suppressed + $disabled);
120
 
146
 
147
  protected function _getProgressSuppressed($total, $getCount = false, $getBar = true, $getLegend = false)
148
  {
149
+ $html = '';
150
  $percent = 0;
151
+ $count = (int)$this->getProgressBarSuppressed();
152
 
153
  if ($getCount) {
154
  return $count;
172
  $html .= "<div class=\"bronto-progress-bar-legend-details\">Suppressed: {$percent}% ({$count}/{$total})</div>";
173
  $html .= '</div>';
174
  }
175
+
176
  return $html;
177
  }
178
 
179
  protected function _getProgressDisabled($total, $getCount = false, $getBar = true, $getLegend = false)
180
  {
181
+ $html = '';
182
  $percent = 0;
183
+ $count = (int)$this->getProgressBarDisabled();
184
 
185
  if ($getCount) {
186
  return $count;
247
  * Color code the job status
248
  *
249
  * @param string $status
250
+ *
251
  * @return string
252
  */
253
  public function decorateJobStatus($status)
278
  * Add button widget
279
  *
280
  * @param Mage_Adminhtml_Block_Widget_Button $button
281
+ *
282
  * @return Bronto_Common_Block_Adminhtml_System_Config_Cron
283
  */
284
  public function addButton(Mage_Adminhtml_Block_Widget_Button $button)
285
  {
286
  $this->_buttons[] = $button;
287
+
288
  return $this;
289
  }
290
 
302
  * Set if we're using a progress bar
303
  *
304
  * @param bool $hasProgressBar
305
+ *
306
  * @return Bronto_Common_Block_Adminhtml_System_Config_Cron
307
  */
308
  public function setHasProgressBar($hasProgressBar)
309
  {
310
  $this->_hasProgressBar = $hasProgressBar;
311
+
312
  return $this;
313
  }
314
 
353
  {
354
  return 0;
355
  }
356
+
357
+ /**
358
+ * Determine if should show the cron table
359
+ *
360
+ * @return mixed
361
+ */
362
+ public function showCronTable()
363
+ {
364
+ return true;
365
+ }
366
  }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Block_Adminhtml_System_Config_Form_Field extends Mage_Adminhtml_Block_System_Config_Form_Field
9
  {
@@ -11,6 +10,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field extends Mage_Adminh
11
  * Override method to output our custom HTML with JavaScript
12
  *
13
  * @param Varien_Data_Form_Element_Abstract $element
 
14
  * @return String
15
  */
16
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
@@ -18,15 +18,26 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field extends Mage_Adminh
18
  if (!extension_loaded('soap') || !extension_loaded('openssl')) {
19
  $element->setDisabled('disabled')->setValue(0);
20
  } else {
21
- if (!Mage::helper('bronto_common')->validApiToken()) {
22
- $element->setDisabled('disabled')->setValue(0);
 
 
 
 
 
 
 
 
23
  if (trim($element->getLabel()) === 'Enable Module') {
24
- $element->setComment('<span style="color:red;font-weight: bold">A valid Bronto API key is required.</span>');
 
 
25
  }
26
  } else if (!Mage::helper('bronto_common/support')->isRegistered()) {
27
  if (trim($element->getLabel()) !== 'Enable Module' || !$element->getValue()) {
 
28
  $element->setDisabled('disabled');
29
- $element->setComment('<span style="color:red;font-weight:bold">Extension registration is required.</span>');
30
  }
31
  }
32
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Block_Adminhtml_System_Config_Form_Field extends Mage_Adminhtml_Block_System_Config_Form_Field
8
  {
10
  * Override method to output our custom HTML with JavaScript
11
  *
12
  * @param Varien_Data_Form_Element_Abstract $element
13
+ *
14
  * @return String
15
  */
16
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
18
  if (!extension_loaded('soap') || !extension_loaded('openssl')) {
19
  $element->setDisabled('disabled')->setValue(0);
20
  } else {
21
+ // Get Config Link
22
+ $configLink = Mage::helper('bronto_common')->getScopeUrl('/system_config/edit/section/bronto');
23
+
24
+ if (!Mage::helper('bronto_verify/apitoken')->getStatus()) {
25
+ if (trim($element->getLabel()) === 'Enable Module') {
26
+ $element->setDisabled('disabled')->setValue(0);
27
+ $link = '<a href="' . $configLink . '">Fix it Here</a>';
28
+ $element->setComment('<span style="color:red;font-weight: bold">A valid Bronto API key is required. ' . $link . '</span>');
29
+ }
30
+ } else if (!Mage::helper('bronto_common')->isEnabled()) {
31
  if (trim($element->getLabel()) === 'Enable Module') {
32
+ $element->setDisabled('disabled')->setValue(0);
33
+ $link = '<a href="' . $configLink . '">Enable It Here</a>';
34
+ $element->setComment('<span style="color:red;font-weight: bold">The Bronto Extension for Magento is not enabled. ' . $link . '</span>');
35
  }
36
  } else if (!Mage::helper('bronto_common/support')->isRegistered()) {
37
  if (trim($element->getLabel()) !== 'Enable Module' || !$element->getValue()) {
38
+ $link = '<a href="' . $configLink . '#bronto_support-head">Register Here</a>';
39
  $element->setDisabled('disabled');
40
+ $element->setComment('<span style="color:red;font-weight:bold">Extension registration is required. ' . $link . '</span>');
41
  }
42
  }
43
  }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Apitoken.php CHANGED
@@ -3,14 +3,15 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Mage_Adminhtml_Block_System_Config_Form_Field
 
9
  {
10
  /**
11
  * Get element ID of the dependent field's parent row
12
  *
13
  * @param object $element
 
14
  * @return String
15
  */
16
  protected function _getRowElementId($element)
@@ -22,121 +23,123 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
22
  * Override method to output our custom HTML with JavaScript
23
  *
24
  * @param Varien_Data_Form_Element_Abstract $element
 
25
  * @return String
26
  */
27
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
28
  {
29
- $_html = array();
30
-
31
- // Create form object to grab scope details
32
- $form = new Mage_Adminhtml_Block_System_Config_Form;
33
- $scope = $form->getScope();
34
- $scopeId = $form->getScopeId();
35
-
36
- $element->setData('onchange', "validateToken(this.form, this);");
37
- $element->setData('after_element_html', "
38
- <span id=\"loadingmask\" style=\"display: none; width: 100px;\">
39
- <span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Verifying...') . "</span>
40
- <span id=\"loading-mask\"></span>
41
- </span>
42
- <script>
43
- function toggleDisabled(form, element) {
44
- var statusText = $('bronto-validation-status');
45
- var disabled = (statusText.className == 'invalid' || statusText.className == '');
46
-
47
- for (i = 0; i < form.length; i++) {
48
- if (form.elements[i].id != '{$element->getId()}' &&
49
- form.elements[i].type != 'hidden' &&
50
- form.elements[i].name.indexOf('groups') == 0) {
51
- form.elements[i].disabled = disabled;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
- }
54
- var last = element.parentNode.lastChild;
55
- if (last.className == 'note') {
56
- last.innerHTML = '';
57
- }
58
 
59
- var buttonP = document.getElementById('verify-button');
60
- console.log(buttonP);
61
- console.log(buttonP.children[0]);
62
- for (i = 0; i < buttonP.children.length; i++) {
63
- console.log(buttonP.children[i]);
64
- console.log(i);
65
- if (disabled) {
66
- $(buttonP.children[i]).addClassName('disabled');
67
- } else {
68
- $(buttonP.children[i]).removeClassName('disabled');
69
  }
70
- buttonP.children[i].disabled = disabled;
71
  }
72
 
73
- }
74
-
75
- function trim1 (str) {
76
- return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
77
- }
 
 
 
78
 
79
- function validateToken(form, element) {
80
- var token = trim1($('{$element->getId()}').value);
81
- var statusText = $('bronto-validation-status');
82
- var reloadurl = '{$this->getUrl('*/apitoken/ajaxvalidation')}';
83
-
84
- statusText.innerHTML = $('loadingmask').innerHTML;
85
- statusText.removeClassName('valid').removeClassName('invalid');
86
-
87
- new Ajax.Request(reloadurl, {
88
- method: 'post',
89
- parameters: {token: token, scope: '{$scope}', scopeid: '{$scopeId}'},
90
- onComplete: function(transport) {
91
- Element.hide('loadingmask');
92
- if (transport.responseText == '\"Passed Verification\"') {
93
- statusText.innerHTML = 'Passed Verification';
94
- statusText.addClassName('valid');
95
- } else if (transport.responseText == '\"Failed Verification\"') {
96
- statusText.innerHTML = 'Failed Verification';
97
- statusText.addClassName('invalid');
98
- } else {
99
- statusText.innerHTML = 'No Token Provided';
100
  }
101
-
102
- toggleDisabled(form, element);
103
- }
104
- });
105
-
106
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
- </script>
109
- ");
110
-
111
- if (!$this->helper('bronto_common')->getApiToken()) {
112
- $element->setComment('<span style="color:red;font-weight:bold">Please enter your Bronto API key here.</span>');
113
- $buttonHtml = "";
114
- } else {
115
- $button = $this->getLayout()
116
- ->createBlock('bronto_verify/adminhtml_widget_button_runtoken')
117
- ->toHtml();
118
- $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
119
- }
120
 
121
- // Show Roundtrip Install Verification Status
122
- $_html[] = '<style>' .
123
- '#bronto-validation-status { color:grey; font-weight:bold; }' .
124
- '#bronto-validation-status.valid { color: green; }' .
125
- '#bronto-validation-status.invalid { color: red; }' .
126
- '</style>' . '<strong style="float: left; width: 80px">Last Status:</strong> ' .
127
- $this->helper('bronto_verify/apitoken')->getAdminScopedApitokenStatusText() . $buttonHtml;
128
-
129
- // Show everything Else
130
- if (!empty($_html)) {
131
- $elementHtml = $element->getElementHtml();
132
- if ($element->getComment()) {
133
- $elementHtml.= '<p class="note"><span>'.$element->getComment().'</span></p>';
134
- $element->setComment(null);
135
  }
136
- $elementHtml .= '<div style="margin-top:10px">';
137
- $elementHtml .= implode('<br />', $_html);
138
- $elementHtml .= '</div>';
139
- return $elementHtml;
140
  }
141
 
142
  return parent::_getElementHtml($element);
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
+ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
9
  {
10
  /**
11
  * Get element ID of the dependent field's parent row
12
  *
13
  * @param object $element
14
+ *
15
  * @return String
16
  */
17
  protected function _getRowElementId($element)
23
  * Override method to output our custom HTML with JavaScript
24
  *
25
  * @param Varien_Data_Form_Element_Abstract $element
26
+ *
27
  * @return String
28
  */
29
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
30
  {
31
+ // Only do validation if module is installed and active
32
+ if ($this->helper('bronto_common')->isModuleInstalled('Bronto_Verify')) {
33
+ $_html = array();
34
+
35
+ // Create form object to grab scope details
36
+ $form = new Mage_Adminhtml_Block_System_Config_Form;
37
+ $scope = $form->getScope();
38
+ $scopeId = $form->getScopeId();
39
+
40
+ $element->setData('onchange', "validateToken(this.form, this);");
41
+ $element->setData('after_element_html', "
42
+ <span id=\"loadingMask\" style=\"display: none; width: 100px;\">
43
+ <span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" .
44
+ $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') .
45
+ ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" .
46
+ $this->__(' Verifying...') .
47
+ "</span>
48
+ <span id=\"loading-mask\"></span>
49
+ </span>
50
+ <script>
51
+ /**
52
+ * Function to Toggle Form Elements Disabled Status Based On Token Status
53
+ */
54
+ function toggleDisabled(form, element) {
55
+ // Get Status Text Element
56
+ var statusText = $('bronto-validation-status-text');
57
+ // If Status Text Element has Class of 'invalid' or empty, set boolean disabled value
58
+ var disabled = (statusText.className == 'invalid' || statusText.className == '');
59
+
60
+ // Cycle through form elements and disable/enable elements
61
+ for (i = 0; i < form.length; i++) {
62
+ if (form.elements[i].id != '{$element->getId()}' &&
63
+ form.elements[i].id != 'bronto_settings_enabled' &&
64
+ form.elements[i].id != 'verify-button' &&
65
+ form.elements[i].type != 'hidden' &&
66
+ form.elements[i].name.indexOf('groups') == 0) {
67
+ form.elements[i].disabled = disabled;
68
+ }
69
  }
 
 
 
 
 
70
 
71
+ // Get Last Element of Form, and if the class name is 'note', empty the html value
72
+ var last = element.parentNode.lastChild;
73
+ if (last.className == 'note') {
74
+ last.innerHTML = '';
 
 
 
 
 
 
75
  }
 
76
  }
77
 
78
+ function trim1 (str) {
79
+ return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
80
+ }
81
+
82
+ function validateToken(form, element) {
83
+ var token = trim1($('{$element->getId()}').value);
84
+ var statusText = $('bronto-validation-status');
85
+ var reloadUrl = '{$this->getUrl('*/apitoken/ajaxvalidation')}';
86
 
87
+ statusText.innerHTML = $('loadingMask').innerHTML;
88
+ statusText.removeClassName('valid').removeClassName('invalid');
89
+
90
+ new Ajax.Request(reloadUrl, {
91
+ method: 'post',
92
+ parameters: {token: token, scope: '{$scope}', scopeid: '{$scopeId}'},
93
+ onComplete: function(transport) {
94
+ Element.hide('loadingMask');
95
+ statusText.innerHTML = transport.responseText;
96
+
97
+ toggleDisabled(form, element);
 
 
 
 
 
 
 
 
 
 
98
  }
99
+ });
100
+
101
+ return false;
102
+ }
103
+ </script>
104
+ ");
105
+
106
+ if (!$this->helper('bronto_common')->getApiToken()) {
107
+ $element->setComment(
108
+ '<span style="color:red;font-weight:bold">Please enter your Bronto API key here.</span>'
109
+ );
110
+ $buttonHtml = "";
111
+ } else {
112
+ $button = $this->getLayout()
113
+ ->createBlock('bronto_verify/adminhtml_widget_button_runtoken')
114
+ ->toHtml();
115
+
116
+ $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
117
+ }
118
+
119
+ // Show Roundtrip Install Verification Status
120
+ $_html[] = $buttonHtml .
121
+ '<style>' .
122
+ ' #bronto-validation-status { color:grey; font-weight:bold; }' .
123
+ ' #bronto-validation-status .valid { color: green; }' .
124
+ ' #bronto-validation-status .invalid { color: red; }' .
125
+ '</style>' . '<strong style="float: left; width: 80px">Last Status:</strong> ' .
126
+ '<span id="bronto-validation-status">' .
127
+ $this->helper('bronto_verify/apitoken')->getAdminScopedApitokenStatusText() .
128
+ '</span>';
129
+
130
+ // Show everything Else
131
+ if (!empty($_html)) {
132
+ $elementHtml = $element->getElementHtml();
133
+ if ($element->getComment()) {
134
+ $elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
135
+ $element->setComment(null);
136
  }
137
+ $elementHtml .= '<div style="margin-top:10px">';
138
+ $elementHtml .= implode('<br />', $_html);
139
+ $elementHtml .= '</div>';
 
 
 
 
 
 
 
 
 
140
 
141
+ return $elementHtml;
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
 
 
 
 
143
  }
144
 
145
  return parent::_getElementHtml($element);
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Debug.php CHANGED
@@ -1,14 +1,17 @@
1
  <?php
2
 
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Debug extends Mage_Adminhtml_Block_System_Config_Form_Field {
 
4
 
5
  /**
6
  * Generate the button and surround html
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return string
10
  */
11
- protected function _getButtonHtml(Varien_Data_Form_Element_Abstract $element) {
 
12
  $script = '
13
  <p class="note" style="margin-top: 3px; width:550px"><strong>Disclaimer:</strong> Only share with Bronto Support through an actual Bronto support case and not on any public forums.</p>
14
  <span id="debug-loadingmask" style="display:none; width: 100px;">
@@ -33,6 +36,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Debug extends Mage_
33
  ';
34
 
35
  $button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_debug');
 
36
  return $button->toHtml() . $script;
37
  }
38
 
@@ -40,9 +44,11 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Debug extends Mage_
40
  * Empty the element html
41
  *
42
  * @param Varien_Data_Form_Element_Abstract $element
 
43
  * @return string
44
  */
45
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 
46
  return '';
47
  }
48
 
@@ -50,11 +56,14 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Debug extends Mage_
50
  * Remove the "scope" value
51
  *
52
  * @param Varien_Data_Form_Element_Abstract $element
 
53
  * @return string
54
  */
55
- public function render(Varien_Data_Form_Element_Abstract $element) {
 
56
  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
57
  $element->setLabel($this->_getButtonHtml($element));
 
58
  return parent::render($element);
59
  }
60
  }
1
  <?php
2
 
3
+ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Debug extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
 
6
  /**
7
  * Generate the button and surround html
8
  *
9
  * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
  * @return string
12
  */
13
+ protected function _getButtonHtml(Varien_Data_Form_Element_Abstract $element)
14
+ {
15
  $script = '
16
  <p class="note" style="margin-top: 3px; width:550px"><strong>Disclaimer:</strong> Only share with Bronto Support through an actual Bronto support case and not on any public forums.</p>
17
  <span id="debug-loadingmask" style="display:none; width: 100px;">
36
  ';
37
 
38
  $button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_debug');
39
+
40
  return $button->toHtml() . $script;
41
  }
42
 
44
  * Empty the element html
45
  *
46
  * @param Varien_Data_Form_Element_Abstract $element
47
+ *
48
  * @return string
49
  */
50
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
51
+ {
52
  return '';
53
  }
54
 
56
  * Remove the "scope" value
57
  *
58
  * @param Varien_Data_Form_Element_Abstract $element
59
+ *
60
  * @return string
61
  */
62
+ public function render(Varien_Data_Form_Element_Abstract $element)
63
+ {
64
  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
65
  $element->setLabel($this->_getButtonHtml($element));
66
+
67
  return parent::render($element);
68
  }
69
  }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Download.php CHANGED
@@ -1,15 +1,18 @@
1
  <?php
2
 
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Download extends Mage_Adminhtml_Block_System_Config_Form_Field {
 
4
 
5
  /**
6
  * @param Varien_Data_Form_Element_Abstract $element
 
7
  * @return string
8
  */
9
- protected function _getButtonHtml(Varien_Data_Form_Element_Abstract $element) {
 
10
  $script = '
11
  <span id="archive-loadingmask" style="display:none; width: 100px;">
12
- <span class="loader" id="archive-loading-mask-loader" style="background: url(' . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ') no-repeat 0 50%; background-size: 20px; padding: 3px 0 3px 25px;">' . $this->__('Creating Archive'). '</span>
13
  </span>
14
  <div id="archive-information-result" style="display:none;margin:13px 3px 0 0"></div>
15
  <script>
@@ -31,6 +34,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Download extends Ma
31
  ';
32
 
33
  $button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_download');
 
34
  return $button->toHtml() . $script;
35
  }
36
 
@@ -38,9 +42,11 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Download extends Ma
38
  * Empty the element html
39
  *
40
  * @param Varien_Data_Form_Element_Abstract $element
 
41
  * @return string
42
  */
43
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 
44
  return '';
45
  }
46
 
@@ -48,11 +54,14 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Download extends Ma
48
  * Remove the "scope" value
49
  *
50
  * @param Varien_Data_Form_Element_Abstract $element
 
51
  * @return string
52
  */
53
- public function render(Varien_Data_Form_Element_Abstract $element) {
 
54
  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
55
  $element->setLabel($this->_getButtonHtml($element));
 
56
  return parent::render($element);
57
  }
58
  }
1
  <?php
2
 
3
+ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Download extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
 
6
  /**
7
  * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
  * @return string
10
  */
11
+ protected function _getButtonHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
  $script = '
14
  <span id="archive-loadingmask" style="display:none; width: 100px;">
15
+ <span class="loader" id="archive-loading-mask-loader" style="background: url(' . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ') no-repeat 0 50%; background-size: 20px; padding: 3px 0 3px 25px;">' . $this->__('Creating Archive') . '</span>
16
  </span>
17
  <div id="archive-information-result" style="display:none;margin:13px 3px 0 0"></div>
18
  <script>
34
  ';
35
 
36
  $button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_download');
37
+
38
  return $button->toHtml() . $script;
39
  }
40
 
42
  * Empty the element html
43
  *
44
  * @param Varien_Data_Form_Element_Abstract $element
45
+ *
46
  * @return string
47
  */
48
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
49
+ {
50
  return '';
51
  }
52
 
54
  * Remove the "scope" value
55
  *
56
  * @param Varien_Data_Form_Element_Abstract $element
57
+ *
58
  * @return string
59
  */
60
+ public function render(Varien_Data_Form_Element_Abstract $element)
61
+ {
62
  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
63
  $element->setLabel($this->_getButtonHtml($element));
64
+
65
  return parent::render($element);
66
  }
67
  }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Hidden.php CHANGED
@@ -3,12 +3,12 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Hidden extends Mage_Adminhtml_Block_System_Config_Form_Field
9
  {
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
 
12
  * @return string
13
  */
14
  public function render(Varien_Data_Form_Element_Abstract $element)
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Hidden extends Mage_Adminhtml_Block_System_Config_Form_Field
8
  {
9
  /**
10
  * @param Varien_Data_Form_Element_Abstract $element
11
+ *
12
  * @return string
13
  */
14
  public function render(Varien_Data_Form_Element_Abstract $element)
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Image.php CHANGED
@@ -4,17 +4,18 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Image extends Bront
4
  {
5
 
6
  /**
7
- * Adds some Javascript to the dropdown to place recommended defaults
8
  *
9
  * @param Varien_Data_Form_Element_Abstract $element
 
10
  * @return string
11
  */
12
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
  {
14
  $defaultSizes = array(
15
- 'image' => array('width' => '265', 'height' => ''),
16
  'small_image' => array('width' => '88', 'height' => '77'),
17
- 'thumbnail' => array('width' => '75', 'height' => '75'),
18
  );
19
 
20
  $element->setData('onchange', "defaultImageSize();");
@@ -31,6 +32,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Image extends Bront
31
  }
32
  </script>
33
  ");
 
34
  return parent::_getElementHtml($element);
35
  }
36
  }
4
  {
5
 
6
  /**
7
+ * Adds some Javascript to the drop-down to place recommended defaults
8
  *
9
  * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
  * @return string
12
  */
13
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
14
  {
15
  $defaultSizes = array(
16
+ 'image' => array('width' => '265', 'height' => ''),
17
  'small_image' => array('width' => '88', 'height' => '77'),
18
+ 'thumbnail' => array('width' => '75', 'height' => '75'),
19
  );
20
 
21
  $element->setData('onchange', "defaultImageSize();");
32
  }
33
  </script>
34
  ");
35
+
36
  return parent::_getElementHtml($element);
37
  }
38
  }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/List.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.7.0
7
  */
8
  class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_List extends Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Hidden
9
  {
@@ -11,6 +10,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_List extends Bronto
11
  * Override method to output our custom HTML with JavaScript
12
  *
13
  * @param Varien_Data_Form_Element_Abstract $element
 
14
  * @return String
15
  */
16
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
@@ -29,6 +29,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_List extends Bronto
29
 
30
  /**
31
  * @param Varien_Data_Form_Element_Abstract $element
 
32
  * @return string
33
  */
34
  public function render(Varien_Data_Form_Element_Abstract $element)
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_List extends Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Hidden
8
  {
10
  * Override method to output our custom HTML with JavaScript
11
  *
12
  * @param Varien_Data_Form_Element_Abstract $element
13
+ *
14
  * @return String
15
  */
16
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
29
 
30
  /**
31
  * @param Varien_Data_Form_Element_Abstract $element
32
+ *
33
  * @return string
34
  */
35
  public function render(Varien_Data_Form_Element_Abstract $element)
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support.php CHANGED
@@ -7,12 +7,12 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Support extends Mag
7
  * Override for disabling support information until API token is set
8
  *
9
  * @param Varien_Data_Form_Element_Abstract $element
 
10
  * @return string
11
  */
12
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
  {
14
- $helper = Mage::helper('bronto_common');
15
- if (!$helper->validApiToken()) {
16
  $element->setDisabled('disabled');
17
  }
18
 
7
  * Override for disabling support information until API token is set
8
  *
9
  * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
  * @return string
12
  */
13
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
14
  {
15
+ if (!Mage::helper('bronto_verify/apitoken')->getStatus()) {
 
16
  $element->setDisabled('disabled');
17
  }
18
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support/Site.php CHANGED
@@ -6,20 +6,21 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Support_Site extend
6
  * Override for disabling support information until API token is set
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return string
10
  */
11
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
  {
13
  $brontoLink = '<a href="http://app.bronto.com" target="_blank"'
14
- . 'title="Home Dashboard |&nbsp;Bronto Marketing Platform">Bronto</a>';
15
- $helpIcon = $this->getSkinUrl('bronto/images/site_name.png');
16
- $comment = 'Found within '
17
- . $brontoLink . ', located at:'
18
- . '<div class="bronto-with-help">'
19
- . '<strong>Home &raquo; Settings &raquo; General Settings</strong>'
20
- . '<div class="bronto-help bronto-vertical-align">'
21
- . '<div class="bronto-help-window bronto-large-image">'
22
- . '<img src="' . $helpIcon . '"/></div></div></div>';
23
 
24
  $element->setComment($comment);
25
 
6
  * Override for disabling support information until API token is set
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
  * @return string
11
  */
12
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
  {
14
  $brontoLink = '<a href="http://app.bronto.com" target="_blank"'
15
+ . 'title="Home Dashboard |&nbsp;Bronto Marketing Platform">Bronto</a>';
16
+ $helpIcon = $this->getSkinUrl('bronto/images/site_name.png');
17
+ $comment = 'Found within '
18
+ . $brontoLink . ', located at:'
19
+ . '<div class="bronto-with-help">'
20
+ . '<strong>Home &raquo; Settings &raquo; General Settings</strong>'
21
+ . '<div class="bronto-help bronto-vertical-align">'
22
+ . '<div class="bronto-help-window bronto-large-image">'
23
+ . '<img src="' . $helpIcon . '" width="640px"/></div></div></div>';
24
 
25
  $element->setComment($comment);
26
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Fieldset.php CHANGED
@@ -1,16 +1,18 @@
1
  <?php
2
 
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
 
4
 
5
  /**
6
  * Collapsed or expanded fieldset when page loaded?
7
  *
8
  * @param Varien_Data_Form_Element_Abstract $element
 
9
  * @return bool
10
  */
11
  protected function _getCollapseState($element)
12
  {
13
- $user = Mage::getSingleton('admin/session')->getUser();
14
  $extra = $user->getExtra();
15
  if (!isset($extra['configState'][$element->getId()])) {
16
  return 1;
1
  <?php
2
 
3
+ class Bronto_Common_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
 
6
  /**
7
  * Collapsed or expanded fieldset when page loaded?
8
  *
9
  * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
  * @return bool
12
  */
13
  protected function _getCollapseState($element)
14
  {
15
+ $user = Mage::getSingleton('admin/session')->getUser();
16
  $extra = $user->getExtra();
17
  if (!isset($extra['configState'][$element->getId()])) {
18
  return 1;
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Guide.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Common_Block_Adminhtml_System_Config_Guide extends Mage_Adminhtml_Block_Template
8
+ {
9
+ /**
10
+ * Array of possible sections
11
+ *
12
+ * @var array
13
+ */
14
+ private $_sections = array(
15
+ 'bronto',
16
+ 'bronto_common',
17
+ 'bronto_news',
18
+ 'bronto_newsletter',
19
+ 'bronto_customer',
20
+ 'bronto_order',
21
+ 'bronto_reminder',
22
+ 'bronto_email',
23
+ 'bronto_verify',
24
+ 'bronto_popup',
25
+ 'bronto_reviews',
26
+ );
27
+
28
+ /**
29
+ * Function to match query section against current section
30
+ *
31
+ * @param $section
32
+ *
33
+ * @return bool
34
+ */
35
+ public function isBrontoSection($section)
36
+ {
37
+ return $this->getCurrentSection() == $section;
38
+ }
39
+
40
+ /**
41
+ * Get code for child html block based on current section
42
+ *
43
+ * @return string
44
+ */
45
+ public function getSectionChildHtml()
46
+ {
47
+ $section = $this->getCurrentSection();
48
+ if (in_array($section, $this->_sections)) {
49
+ return $section . '_guide';
50
+ }
51
+
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * Get Current section from request params
57
+ *
58
+ * @return mixed
59
+ */
60
+ public function getCurrentSection()
61
+ {
62
+ $section = Mage::app()->getRequest()->getParam('section', false);
63
+ if ($section == 'bronto') {
64
+ $section = 'bronto_common';
65
+ }
66
+
67
+ return $section;
68
+ }
69
+
70
+ /**
71
+ * Get Url for Ajax call to toggle displaying guide for current section
72
+ *
73
+ * @return mixed
74
+ */
75
+ public function getToggleUrl()
76
+ {
77
+ return Mage::helper("adminhtml")->getUrl('*/guiders/toggle');
78
+ }
79
+
80
+ /**
81
+ * Determine if guide should be shown
82
+ *
83
+ * @param bool|string $section
84
+ *
85
+ * @return bool
86
+ */
87
+ public function canShowGuide($section = false)
88
+ {
89
+ if (!$section) {
90
+ $section = $this->getCurrentSection();
91
+ }
92
+
93
+ $canShow = Mage::helper('bronto_common')->getAdminScopedConfig($section . '/guide/display');
94
+
95
+ return ($canShow == '0') ? false : true;
96
+ }
97
+
98
+ /**
99
+ * Determine if Currently in Default Scope
100
+ *
101
+ * @return bool
102
+ */
103
+ public function isDefaultScope()
104
+ {
105
+ $scopeParams = Mage::helper('bronto_common')->getScopeParams();
106
+
107
+ return ($scopeParams['scope'] == 'default');
108
+ }
109
+ }
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Support.php CHANGED
@@ -21,6 +21,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Support extends Mage_Adminhtml
21
  * Collapsed or expanded fieldset when page loaded?
22
  *
23
  * @param Varien_Data_Form_Element_Abstract $element
 
24
  * @return bool
25
  */
26
  protected function _getCollapseState($element)
21
  * Collapsed or expanded fieldset when page loaded?
22
  *
23
  * @param Varien_Data_Form_Element_Abstract $element
24
+ *
25
  * @return bool
26
  */
27
  protected function _getCollapseState($element)
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Suppressed.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Common_Block_Adminhtml_System_Config_Suppressed
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
9
+ {
10
+ protected $_suppressed = array();
11
+
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->setTemplate('bronto/common/suppressed.phtml');
16
+ }
17
+
18
+ /**
19
+ * Prepare the layout
20
+ *
21
+ * @return Bronto_Common_Block_Adminhtml_System_Config_Cron
22
+ */
23
+ protected function _prepareLayout()
24
+ {
25
+ return parent::_prepareLayout();
26
+ }
27
+
28
+ /**
29
+ * Render fieldset html
30
+ *
31
+ * @param Varien_Data_Form_Element_Abstract $element
32
+ *
33
+ * @return string
34
+ */
35
+ public function render(Varien_Data_Form_Element_Abstract $element)
36
+ {
37
+ $this->setElement($element);
38
+ $html = $this->_getHeaderHtml($element);
39
+
40
+ $html .= $this->toHtml();
41
+
42
+ $html .= $this->_getFooterHtml($element);
43
+
44
+ return $html;
45
+ }
46
+
47
+ /**
48
+ * Get URL for AJAX call
49
+ *
50
+ * @return string
51
+ */
52
+ public function getAjaxUrl()
53
+ {
54
+ return '';
55
+ }
56
+
57
+ /**
58
+ * The Suppression interface is always collapsed
59
+ *
60
+ * @param Varien_Data_Form_Element_Abstract $element
61
+ * @return bool
62
+ */
63
+ protected function _getCollapseState($element)
64
+ {
65
+ return false;
66
+ }
67
+ }
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Abstract.php CHANGED
@@ -1,41 +1,48 @@
1
  <?php
2
 
3
- abstract class Bronto_Common_Block_Adminhtml_Widget_Button_Abstract extends Mage_Adminhtml_Block_Widget_Button {
4
-
5
- /**
6
- * @var Mage_Core_Helper_Data
7
- */
8
- protected $_helper;
9
-
10
- /**
11
- * @return Mage_Core_Helper_Data
12
- */
13
- protected function _getHelper() {
14
- if (is_null($this->_helper)) {
15
- $this->_helper = Mage::helper('bronto_common/support');
16
- }
17
- return $this->_helper;
18
- }
19
-
20
- /**
21
- * @param Mage_Core_Helper_Data $helper
22
- * @return Bronto_Common_Block_Adminhtml_Widget_Button_Abstract
23
- */
24
- public function setHelper(Mage_Core_Helper_Data $helper) {
25
- $this->_helper = $helper;
26
- return $this;
27
- }
28
-
29
- /**
30
- * Children override for button definition
31
- */
32
- protected abstract function _setUp();
33
-
34
- /**
35
- * Define the button
36
- */
37
- protected function _construct() {
38
- $this->setDisabled(!$this->_getHelper()->isRegistered());
39
- $this->_setup();
40
- }
 
 
 
 
 
 
 
41
  }
1
  <?php
2
 
3
+ abstract class Bronto_Common_Block_Adminhtml_Widget_Button_Abstract extends Mage_Adminhtml_Block_Widget_Button
4
+ {
5
+
6
+ /**
7
+ * @var Mage_Core_Helper_Data
8
+ */
9
+ protected $_helper;
10
+
11
+ /**
12
+ * @return Mage_Core_Helper_Data
13
+ */
14
+ protected function _getHelper()
15
+ {
16
+ if (is_null($this->_helper)) {
17
+ $this->_helper = Mage::helper('bronto_common/support');
18
+ }
19
+
20
+ return $this->_helper;
21
+ }
22
+
23
+ /**
24
+ * @param Mage_Core_Helper_Data $helper
25
+ *
26
+ * @return Bronto_Common_Block_Adminhtml_Widget_Button_Abstract
27
+ */
28
+ public function setHelper(Mage_Core_Helper_Data $helper)
29
+ {
30
+ $this->_helper = $helper;
31
+
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Children override for button definition
37
+ */
38
+ protected abstract function _setUp();
39
+
40
+ /**
41
+ * Define the button
42
+ */
43
+ protected function _construct()
44
+ {
45
+ $this->setDisabled(!$this->_getHelper()->isRegistered());
46
+ $this->_setup();
47
+ }
48
  }
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Debug.php CHANGED
@@ -1,12 +1,15 @@
1
  <?php
2
 
3
- class Bronto_Common_Block_Adminhtml_Widget_Button_Debug extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract {
 
4
 
5
  /**
6
  * Sets up the JS action for gathering debug information
 
7
  * @see parent
8
  */
9
- protected function _setUp() {
 
10
  $this->setLabel('Generate Debug Information');
11
  $this->setOnClick('collectDebugInformation(); return false;');
12
  }
1
  <?php
2
 
3
+ class Bronto_Common_Block_Adminhtml_Widget_Button_Debug extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract
4
+ {
5
 
6
  /**
7
  * Sets up the JS action for gathering debug information
8
+ *
9
  * @see parent
10
  */
11
+ protected function _setUp()
12
+ {
13
  $this->setLabel('Generate Debug Information');
14
  $this->setOnClick('collectDebugInformation(); return false;');
15
  }
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Download.php CHANGED
@@ -1,12 +1,14 @@
1
  <?php
2
 
3
- class Bronto_Common_Block_Adminhtml_Widget_Button_Download extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract {
 
4
 
5
- /**
6
- * @see parent
7
- */
8
- protected function _setUp() {
9
- $this->setLabel('Create Log Archive');
10
- $this->setOnClick('createLogArchive(); return false;');
11
- }
 
12
  }
1
  <?php
2
 
3
+ class Bronto_Common_Block_Adminhtml_Widget_Button_Download extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract
4
+ {
5
 
6
+ /**
7
+ * @see parent
8
+ */
9
+ protected function _setUp()
10
+ {
11
+ $this->setLabel('Create Log Archive');
12
+ $this->setOnClick('createLogArchive(); return false;');
13
+ }
14
  }
app/code/community/Bronto/Common/Block/Popup.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto/Common
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Common_Block_Popup extends Mage_Core_Block_Template
8
+ {
9
+ /**
10
+ * Get Pop-Up Javascript
11
+ *
12
+ * @return mixed
13
+ */
14
+ public function getPopupCode()
15
+ {
16
+ return Mage::helper('bronto_common')->getPopupCode();
17
+ }
18
+ }
app/code/community/Bronto/Common/Helper/Contact.php CHANGED
@@ -3,14 +3,14 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
9
  {
10
  /**
11
  * @param string $email
12
  * @param string $customSource
13
- * @param int $store
 
14
  * @return Bronto_Api_Contact_Row
15
  */
16
  public function getContactByEmail($email, $customSource = null, $store = null)
@@ -20,11 +20,11 @@ class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
20
  }
21
 
22
  /* @var $contactObject Bronto_Api_Contact */
23
- $api = $this->getApi(null, $store);
24
  $contactObject = $api->getContactObject();
25
 
26
  // Load Contact
27
- $contact = $contactObject->createRow(array('email' => $email));
28
  $contact->email = $email;
29
  try {
30
  $contact = $contact->read();
@@ -42,7 +42,8 @@ class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
42
 
43
  /**
44
  * @param Bronto_Api_Contact_Row $contact
45
- * @param bool $persistOnly
 
46
  * @return Bronto_Api_Contact_Row
47
  */
48
  public function saveContact(Bronto_Api_Contact_Row $contact, $persistOnly = false)
@@ -57,6 +58,7 @@ class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
57
  } else {
58
  // User doesn't exist and isn't @bronto
59
  $this->writeInfo('TEST MODE: Not updating Contact with email: ' . $contact->email);
 
60
  return $contact;
61
  }
62
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
8
  {
9
  /**
10
  * @param string $email
11
  * @param string $customSource
12
+ * @param int $store
13
+ *
14
  * @return Bronto_Api_Contact_Row
15
  */
16
  public function getContactByEmail($email, $customSource = null, $store = null)
20
  }
21
 
22
  /* @var $contactObject Bronto_Api_Contact */
23
+ $api = $this->getApi(null, 'store', $store);
24
  $contactObject = $api->getContactObject();
25
 
26
  // Load Contact
27
+ $contact = $contactObject->createRow(array('email' => $email));
28
  $contact->email = $email;
29
  try {
30
  $contact = $contact->read();
42
 
43
  /**
44
  * @param Bronto_Api_Contact_Row $contact
45
+ * @param bool $persistOnly
46
+ *
47
  * @return Bronto_Api_Contact_Row
48
  */
49
  public function saveContact(Bronto_Api_Contact_Row $contact, $persistOnly = false)
58
  } else {
59
  // User doesn't exist and isn't @bronto
60
  $this->writeInfo('TEST MODE: Not updating Contact with email: ' . $contact->email);
61
+
62
  return $contact;
63
  }
64
  }
app/code/community/Bronto/Common/Helper/Data.php CHANGED
@@ -3,12 +3,13 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Helper_Data
9
  extends Mage_Core_Helper_Abstract
10
  {
11
-
 
 
12
  const XML_PATH_GLOBAL_SETTINGS = 'bronto/settings/';
13
  const XML_PATH_API_TOKEN = 'bronto/settings/api_token';
14
  const XML_PATH_DEBUG = 'bronto/settings/debug';
@@ -17,17 +18,57 @@ class Bronto_Common_Helper_Data
17
  const XML_PATH_NOTICES = 'bronto/settings/notices';
18
  const XML_PATH_ENABLED = 'bronto/settings/enabled';
19
 
20
- const XML_PATH_IMAGE_TYPE = 'bronto/format/image_type';
21
- const XML_PATH_IMAGE_WIDTH = 'bronto/format/image_width';
22
- const XML_PATH_IMAGE_HEIGHT = 'bronto/format/image_height';
23
- const XML_PATH_USE_SYMBOL = 'bronto/format/use_symbol';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  * @return bool
27
  */
28
- public function isEnabled()
29
  {
30
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_ENABLED);
31
  }
32
 
33
  /*
@@ -41,135 +82,236 @@ class Bronto_Common_Helper_Data
41
  }
42
 
43
  /**
44
- * @param string $path
45
  *
46
- * @return bool
47
  */
48
- public function disableModule($scope = 'default', $scopeId = 0)
49
  {
50
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
51
  }
52
 
53
  /**
54
  * Determine if email can be sent through bronto
55
  *
56
  * @param Mage_Core_Model_Email_Template $template
 
57
  *
58
  * @return boolean
59
  */
60
  public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
61
  {
62
- if ($this->isEnabled($storeId)) {
63
- return TRUE;
64
  }
65
 
66
- return FALSE;
67
  }
68
 
69
  /**
 
 
 
 
70
  * @return string
71
  */
72
  public function getProductImageUrl($product)
73
  {
74
- return (string) Mage::helper('catalog/image')
75
- ->init($product, $this->getImageType($product->getStoreId()))
76
- ->resize(
77
  $this->getImageWidth($product->getStoreId()),
78
  $this->getImageHeight($product->getStoreId())
79
  );
80
  }
81
 
82
  /**
 
 
83
  * @return string
84
  */
85
  public function getImageType($storeId = null)
86
  {
87
- return $this->getAdminScopedConfig(self::XML_PATH_IMAGE_TYPE, $storeId);
88
  }
89
 
90
  /**
 
 
91
  * @return int|null
92
  */
93
  public function getImageWidth($storeId = null)
94
  {
95
- $width = (int) $this->getAdminScopedConfig(self::XML_PATH_IMAGE_WIDTH, $storeId);
96
 
97
- return empty($width) ? NULL : abs($width);
98
  }
99
 
100
  /**
 
 
101
  * @return int|null
102
  */
103
  public function getImageHeight($storeId = null)
104
  {
105
- $height = (int) $this->getAdminScopedConfig(self::XML_PATH_IMAGE_HEIGHT, $storeId);
106
 
107
- return empty($height) ? NULL : abs($height);
108
  }
109
 
110
  /**
 
 
111
  * @return bool
112
  */
113
- public function useCurrenySymbol($storeId = null)
114
  {
115
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_USE_SYMBOL, $storeId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
  /**
119
  * @param string $path
120
  * @param string $scope
121
  * @param int $scopeId
 
122
  *
123
  * @return bool
124
  */
125
- protected function _disableModule($path, $scope = 'default', $scopeId = 0)
126
- {
127
- $config = Mage::getModel('core/config');
128
- $config->saveConfig($path, 0, $scope, $scopeId);
129
-
130
- if (!$this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
131
- // Get the Module alias from the path
132
- // $path = bronto_email/settings/api_token
133
- // $module = bronto_email
134
- list($module) = explode('/', $path);
135
- // we have to physically insert the enabled path into the
136
- // core_config_data table of the DB w/ a value of 0, or the module
137
- // could inherit from its parent and not actually get disabled.
138
- // b/c the state of the checkbox is determined by whether or not
139
- // a value is set in the core_config_data table.
140
- $configData = Mage::getModel('core/config_data');
141
- $configData->setScope($scope)
142
- ->setScopeId($scopeId)
143
- ->setPath("$module/settings/enabled")
144
- ->setValue(0)
145
- ->save();
 
 
 
 
 
 
 
 
 
146
  }
147
 
 
 
 
148
  return $this;
149
  }
150
 
151
  /**
152
  * Determine if module is active
 
153
  * @return boolean
154
  */
155
  public function isModuleActive()
156
  {
157
  // If module is not enabled, return false
158
  if (!$this->isEnabled()) {
159
- return FALSE;
160
  }
161
 
162
  // If module is missing token, return false
163
  if (!$this->getApiToken()) {
164
- return FALSE;
165
  }
166
 
167
  // If requirements are not met, return false
168
  if (!$this->verifyRequirements($this->_getModuleName())) {
169
- return FALSE;
170
  }
171
 
172
- return TRUE;
173
  }
174
 
175
  /**
@@ -179,7 +321,7 @@ class Bronto_Common_Helper_Data
179
  */
180
  public function hasCustomConfig()
181
  {
182
- return FALSE;
183
  }
184
 
185
  /**
@@ -202,7 +344,7 @@ class Bronto_Common_Helper_Data
202
  public function verifyRequirements($module, $required = array())
203
  {
204
  // Check for required PHP extensions
205
- $verified = TRUE;
206
  $missing = array();
207
  $defaultRequired = array('soap', 'openssl');
208
  $required = array_merge($required, $defaultRequired);
@@ -216,12 +358,11 @@ class Bronto_Common_Helper_Data
216
  try {
217
  if (!extension_loaded($extName)) {
218
  $missing[] = $extName;
219
- $verified = FALSE;
220
  }
221
- }
222
- catch (Exception $e) {
223
  $missing[] = $extName;
224
- $verified = FALSE;
225
  }
226
  }
227
 
@@ -245,39 +386,44 @@ class Bronto_Common_Helper_Data
245
  $message->setIdentifier($module);
246
  Mage::getSingleton('adminhtml/session')->addMessage($message);
247
 
248
- return FALSE;
249
  }
250
 
251
- return TRUE;
252
  }
253
 
254
  /**
255
- * @param string $token
256
- * @param int $store
257
- * @param int $websiteId
 
 
258
  *
259
  * @return Bronto_Common_Model_Api
260
  */
261
- public function getApi($token = NULL, $store = NULL, $websiteId = NULL)
262
  {
263
  if (empty($token)) {
264
- $token = $this->getApiToken($store, $websiteId);
265
  }
266
 
267
  return Bronto_Common_Model_Api::getInstance($token);
268
  }
269
 
270
  /**
271
- * @param string $store
272
  *
273
- * @return string
 
 
 
274
  */
275
- public function getApiToken($store = NULL, $websiteId = NULL)
276
  {
277
- $token = $this->getAdminScopedConfig(self::XML_PATH_API_TOKEN, $store, $websiteId);
278
 
279
- if (!$token || empty($token)) {
280
- return FALSE;
281
  }
282
 
283
  return $token;
@@ -286,49 +432,107 @@ class Bronto_Common_Helper_Data
286
  /**
287
  * Determine if API token is valid
288
  *
289
- * @param string $token
290
- * @param int $store
291
- * @param int $websiteId
292
  *
293
- * @return boolean
294
  */
295
- public function validApiToken($token = NULL, $store = NULL, $websiteId = NULL)
296
  {
 
 
 
 
 
 
297
  if (empty($token)) {
298
- $token = $this->getApiToken($store, $websiteId);
299
  }
300
 
301
- if (strlen($token) < 36) {
302
- return FALSE;
 
303
  }
 
304
  try {
305
- $api = new Bronto_Api($token, array('debug' => TRUE));
306
  $api->login();
 
 
 
 
 
307
  }
308
- catch (Exception $e) {
309
- return FALSE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  }
311
 
312
- return TRUE;
313
  }
314
 
315
  /**
316
- * Check all API tokens are valid
 
 
 
 
 
317
  * @return boolean
318
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  public function validApiTokens($identifier = 'bronto_common')
320
  {
321
- $valid = TRUE;
322
- if (!$this->validApiToken()) {
323
  $message = Mage::getSingleton('core/message')->error(
324
  $this->__('The Bronto API Token you have entered for Default Configuration appears to be invalid.')
325
  );
326
  $message->setIdentifier($identifier);
327
  Mage::getSingleton('adminhtml/session')->addMessage($message);
328
- $valid = FALSE;
329
  }
330
  foreach (Mage::app()->getWebsites() as $website) {
331
- if (!$this->validApiToken(NULL, NULL, $website->getId())) {
332
  $message = Mage::getSingleton('core/message')->error(
333
  $this->__(
334
  sprintf(
@@ -339,13 +543,13 @@ class Bronto_Common_Helper_Data
339
  );
340
  $message->setIdentifier($identifier);
341
  Mage::getSingleton('adminhtml/session')->addMessage($message);
342
- $valid = FALSE;
343
  }
344
  foreach ($website->getGroups() as $group) {
345
  $stores = $group->getStores();
346
  if (count($stores) > 0) {
347
  foreach ($stores as $store) {
348
- if (!$this->validApiToken(NULL, $store->getId(), $website->getId())) {
349
  $message = Mage::getSingleton('core/message')->error(
350
  $this->__(
351
  sprintf(
@@ -357,7 +561,7 @@ class Bronto_Common_Helper_Data
357
  );
358
  $message->setIdentifier($identifier);
359
  Mage::getSingleton('adminhtml/session')->addMessage($message);
360
- $valid = FALSE;
361
  }
362
  }
363
  }
@@ -372,15 +576,38 @@ class Bronto_Common_Helper_Data
372
  *
373
  * @return bool
374
  */
375
- public function isModuleInstalled($moduleName = NULL)
376
  {
377
- $modules = (array) Mage::getConfig()->getNode('modules')->children();
378
 
379
- if ($moduleName === NULL) {
380
  $moduleName = $this->_getModuleName();
381
  }
382
 
383
- return isset($modules[$moduleName]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  }
385
 
386
  /**
@@ -388,15 +615,15 @@ class Bronto_Common_Helper_Data
388
  *
389
  * @return string
390
  */
391
- public function getModuleVersion($moduleName = NULL)
392
  {
393
- $modules = (array) Mage::getConfig()->getNode('modules')->children();
394
 
395
- if ($moduleName === NULL) {
396
  $moduleName = $this->_getModuleName();
397
  }
398
 
399
- return isset($modules[$moduleName]) ? (string) $modules[$moduleName]->version : NULL;
400
  }
401
 
402
  /**
@@ -405,10 +632,10 @@ class Bronto_Common_Helper_Data
405
  public function isDebugEnabled()
406
  {
407
  if (!$this->getApiToken()) {
408
- return FALSE;
409
  }
410
 
411
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_DEBUG);
412
  }
413
 
414
  /**
@@ -417,10 +644,10 @@ class Bronto_Common_Helper_Data
417
  public function isVerboseEnabled()
418
  {
419
  if (!$this->isDebugEnabled()) {
420
- return FALSE;
421
  }
422
 
423
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_VERBOSE);
424
  }
425
 
426
  /**
@@ -429,10 +656,10 @@ class Bronto_Common_Helper_Data
429
  public function isTestModeEnabled()
430
  {
431
  if (!$this->getApiToken()) {
432
- return FALSE;
433
  }
434
 
435
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_TEST);
436
  }
437
 
438
  /**
@@ -441,27 +668,32 @@ class Bronto_Common_Helper_Data
441
  public function isNoticesEnabled()
442
  {
443
  if (!$this->getApiToken()) {
444
- return FALSE;
445
  }
446
 
447
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_NOTICES);
448
  }
449
 
450
  /**
451
- * @param string $message
452
- * @param string|null $file
 
 
 
453
  *
454
  * @return bool|void
455
  */
456
- public function writeDebug($message, $file = NULL, $verbose = FALSE)
457
  {
458
  if ($verbose && !$this->isVerboseEnabled()) {
459
- return;
460
  }
461
 
462
  if ($this->isDebugEnabled()) {
463
  return $this->writeLog($message, $file, Zend_Log::DEBUG);
464
  }
 
 
465
  }
466
 
467
  /**
@@ -470,11 +702,13 @@ class Bronto_Common_Helper_Data
470
  *
471
  * @return bool|void
472
  */
473
- public function writeVerboseDebug($message, $file = NULL)
474
  {
475
  if ($this->isVerboseEnabled()) {
476
- return $this->writeDebug($message, $file, TRUE);
477
  }
 
 
478
  }
479
 
480
  /**
@@ -483,15 +717,14 @@ class Bronto_Common_Helper_Data
483
  *
484
  * @return bool|void
485
  */
486
- public function writeInfo($message, $file = NULL)
487
  {
488
  if ($this->isNoticesEnabled()) {
489
  if (Mage::getSingleton('admin/session')->isLoggedIn()) {
490
  /* @var $message Mage_Core_Model_Message_Notice */
491
  $message = Mage::getSingleton('core/message')->notice("[Bronto] {$message}");
492
  Mage::getSingleton('adminhtml/session')->addMessage($message);
493
- }
494
- else {
495
  Mage::getSingleton('core/session')->addNotice("[Bronto] {$message}");
496
  }
497
  }
@@ -505,7 +738,7 @@ class Bronto_Common_Helper_Data
505
  *
506
  * @return bool|void
507
  */
508
- public function writeError($message, $file = NULL)
509
  {
510
  if (is_object($message) && $message instanceOf Exception) {
511
  $message = $message->getMessage();
@@ -515,8 +748,7 @@ class Bronto_Common_Helper_Data
515
  /* @var $message Mage_Core_Model_Message_Error */
516
  $message = Mage::getSingleton('core/message')->error("[Bronto] {$message}");
517
  Mage::getSingleton('adminhtml/session')->addMessage($message);
518
- }
519
- else {
520
  Mage::getSingleton('core/session')->addError("[Bronto] {$message}");
521
  }
522
  }
@@ -531,7 +763,7 @@ class Bronto_Common_Helper_Data
531
  *
532
  * @return bool|void
533
  */
534
- public function writeLog($message, $file = NULL, $level = Zend_Log::DEBUG)
535
  {
536
  if (empty($file)) {
537
  $file = strtolower($this->_getModuleName()) . '.log';
@@ -539,28 +771,28 @@ class Bronto_Common_Helper_Data
539
  if (!is_string($message)) {
540
  if (method_exists($message, '__toString')) {
541
  $message = $message->__toString();
542
- }
543
- else {
544
- return FALSE;
545
  }
546
  }
547
 
548
- return Mage::log($message, $level, $this->_stampFile($file), TRUE);
549
  }
550
 
551
  /**
552
  * Add Date Stamp to log file name
553
  *
554
- * @param type $filename
 
555
  *
556
- * @return type
557
  */
558
- protected function _stampFile($filename, $withTime = TRUE)
559
  {
560
  // Ensure var/log/bronto exists
561
  $logDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
562
  if (!is_dir($logDir)) {
563
- mkdir($logDir, 0777, TRUE);
564
  }
565
 
566
  // If time stamp requested, append
@@ -575,15 +807,22 @@ class Bronto_Common_Helper_Data
575
 
576
  /**
577
  * Get list of active custom modules
 
 
 
578
  * @return array
579
  */
580
- public function getInstalledModules()
581
  {
582
  $moduleList = array();
583
  $modules = Mage::getConfig()->getNode('modules')->children();
584
 
585
  foreach ($modules as $name => $module) {
586
- if (strpos($name, 'Mage_') === FALSE && strpos($name, 'Enterprise_') === FALSE &&
 
 
 
 
587
  $module->active == 'true'
588
  ) {
589
  $moduleList[] = $name . ' [v' . $module->version . ' codePool: ' . $module->codePool . ']';
@@ -595,6 +834,7 @@ class Bronto_Common_Helper_Data
595
 
596
  /**
597
  * Get array of current scope parameters
 
598
  * @return array
599
  */
600
  public function getScopeParams()
@@ -607,11 +847,11 @@ class Bronto_Common_Helper_Data
607
  'scope' => 'default',
608
  'default' => 0,
609
  'default_id' => 0,
610
- 'store' => $request->getParam('store', FALSE),
611
  'store_id' => 0,
612
- 'website' => $request->getParam('website', FALSE),
613
  'website_id' => 0,
614
- 'group' => $request->getParam('group', FALSE),
615
  'group_id' => 0,
616
  );
617
 
@@ -622,15 +862,13 @@ class Bronto_Common_Helper_Data
622
  $scopeParams['store_id'] = $store->getId();
623
  }
624
  $scopeParams['scope'] = 'store';
625
- }
626
- elseif ($scopeParams['website']) {
627
  $website = Mage::app()->getWebsite($scopeParams['website']);
628
  if ($website->getId()) {
629
  $scopeParams['website_id'] = $website->getId();
630
  }
631
  $scopeParams['scope'] = 'website';
632
- }
633
- elseif ($scopeParams['group']) {
634
  $group = Mage::app()->getGroup($scopeParams['group']);
635
  if ($group->getId()) {
636
  $scopeParams['group_id'] = $group->getId();
@@ -645,9 +883,10 @@ class Bronto_Common_Helper_Data
645
  /**
646
  * Get Url with scope data included
647
  *
648
- * @param string $url
 
649
  *
650
- * @return string
651
  */
652
  public function getScopeUrl($url, $scopeParams = array())
653
  {
@@ -656,31 +895,41 @@ class Bronto_Common_Helper_Data
656
  'scope' => $curScopeParams['scope'],
657
  $curScopeParams['scope'] => $curScopeParams[$curScopeParams['scope']],
658
  );
659
- $scopeParams = array_merge($scopeParams, $curScope);
 
 
 
 
 
 
 
 
 
 
660
 
661
  return Mage::helper('adminhtml')->getUrl($url, $scopeParams);
662
  }
663
 
664
  /**
665
- * @param string $path
666
- * @param mixed $store
667
- * @param int $websiteId
 
 
668
  *
669
  * @return mixed
670
  */
671
- public function getAdminScopedConfig($path, $store = NULL, $websiteId = NULL)
672
  {
673
- if (!is_null($store)) {
674
- return Mage::getStoreConfig($path, $store);
675
- }
676
- elseif (!is_null($websiteId)) {
677
- $website = Mage::app()->getWebsite($websiteId);
678
 
679
  return $website->getConfig($path);
680
  }
681
 
682
  $scopeParams = $this->getScopeParams();
683
- $source = FALSE;
684
 
685
  switch ($scopeParams['scope']) {
686
  case 'store':
@@ -706,6 +955,7 @@ class Bronto_Common_Helper_Data
706
 
707
  /**
708
  * Get Array of Store Ids based on current store/website/group
 
709
  * @return boolean|array
710
  */
711
  public function getStoreIds()
@@ -726,7 +976,7 @@ class Bronto_Common_Helper_Data
726
  $storeIds = $source->getStoreIds();
727
  break;
728
  default:
729
- $storeIds = array_keys(Mage::app()->getStores(TRUE));
730
  break;
731
  }
732
 
@@ -743,6 +993,16 @@ class Bronto_Common_Helper_Data
743
  return ('Enterprise' == $this->getEdition());
744
  }
745
 
 
 
 
 
 
 
 
 
 
 
746
  /**
747
  * Get Edition from version Info
748
  *
@@ -750,7 +1010,7 @@ class Bronto_Common_Helper_Data
750
  *
751
  * @return string|boolean
752
  */
753
- public function getEdition($versionInfo = FALSE)
754
  {
755
  // Ensure we have version info
756
  if (!$versionInfo || !is_array($versionInfo)) {
@@ -768,30 +1028,30 @@ class Bronto_Common_Helper_Data
768
  if (1 == $major) {
769
  if ($minor < 9) {
770
  return 'Community';
771
- }
772
- else if ($minor >= 9 && $minor < 11) {
773
  return 'Professional';
774
- }
775
- else if ($minor >= 11) {
776
  return 'Enterprise';
777
  }
778
  }
779
  }
780
 
781
- return FALSE;
782
  }
783
 
784
  /**
785
  * Takes major and minor version info and determines if current magento install matches
786
  *
787
- * @param array $versionInfo
788
- * @param int|string|array $major
789
- * @param int|string|array $minor
790
- * @param int|string|array $revision (Optional)
791
- * @param int|string|array $patch (Optional)
792
- * @param string $edition (Optional) 'CE'|'Community'|'PE'|'Professional'|'EE'|'Enterprise'
793
  *
794
- * @return boolean
 
 
 
 
 
 
 
795
  */
796
  public function isVersionMatch()
797
  {
@@ -809,7 +1069,7 @@ class Bronto_Common_Helper_Data
809
 
810
  // At least version info and one other
811
  if (!array_key_exists('versionInfo', $parts) || count($parts) < 2) {
812
- return FALSE;
813
  }
814
 
815
  // Get Magento Version from passed arguments
@@ -833,7 +1093,7 @@ class Bronto_Common_Helper_Data
833
 
834
  // Cycle through compare value array to compare against
835
  // current Magento version element
836
- $internalMatch = FALSE;
837
  foreach ($value as $option) {
838
  $operator = '==';
839
  $compare = $option;
@@ -845,7 +1105,7 @@ class Bronto_Common_Helper_Data
845
  }
846
 
847
  if ($index == 'edition') {
848
- // handle posibility of initials being used
849
  switch (strtoupper($compare)) {
850
  case 'EE':
851
  $compare = 'Enterprise';
@@ -862,8 +1122,7 @@ class Bronto_Common_Helper_Data
862
 
863
  // If response from getEdition matches compare edition
864
  $internalMatch = ($mValue == $compare);
865
- }
866
- else {
867
  // Use version_compare to compare the Magento version to the
868
  // Current compare version using the provided operator
869
  $internalMatch = version_compare($mValue, $compare, $operator);
@@ -877,12 +1136,12 @@ class Bronto_Common_Helper_Data
877
  // If the internal Match flag hasn't been set to true,
878
  // there is no match
879
  if (!$internalMatch) {
880
- return FALSE;
881
  }
882
  }
883
 
884
  // If we haven't returned false yet, that means there is a match
885
- return TRUE;
886
  }
887
 
888
  /**
@@ -896,7 +1155,7 @@ class Bronto_Common_Helper_Data
896
  {
897
  // Parts must be array
898
  if (!is_array($parts)) {
899
- return FALSE;
900
  }
901
 
902
  // Generate index map values
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Helper_Data
8
  extends Mage_Core_Helper_Abstract
9
  {
10
+ /**
11
+ * Common Settings
12
+ */
13
  const XML_PATH_GLOBAL_SETTINGS = 'bronto/settings/';
14
  const XML_PATH_API_TOKEN = 'bronto/settings/api_token';
15
  const XML_PATH_DEBUG = 'bronto/settings/debug';
18
  const XML_PATH_NOTICES = 'bronto/settings/notices';
19
  const XML_PATH_ENABLED = 'bronto/settings/enabled';
20
 
21
+ /**
22
+ * Formatting Settings
23
+ */
24
+ const XML_PATH_IMAGE_TYPE = 'bronto/format/image_type';
25
+ const XML_PATH_IMAGE_WIDTH = 'bronto/format/image_width';
26
+ const XML_PATH_IMAGE_HEIGHT = 'bronto/format/image_height';
27
+ const XML_PATH_USE_SYMBOL = 'bronto/format/use_symbol';
28
+ const XML_PATH_INCL_TAX = 'bronto/format/incl_tax';
29
+ const XML_PATH_GREETING_FULL = 'bronto/format/default_greeting';
30
+ const XML_PATH_GREETING_PRE = 'bronto/format/default_greeting_prefix';
31
+ const XML_PATH_GREETING_FIRST = 'bronto/format/default_greeting_firstname';
32
+ const XML_PATH_GREETING_LAST = 'bronto/format/default_greeting_lastname';
33
+
34
+ /**
35
+ * Cron Settings
36
+ */
37
+ const XML_PATH_MAGE_CRON = 'bronto/settings/mage_cron';
38
+ const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_common_delete_archives/schedule/cron_expr';
39
+ const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_common_delete_archives/run/model';
40
+
41
+ /**
42
+ * Pop-up Settings
43
+ */
44
+ const XML_PATH_POPUP_CODE = 'bronto_popup/settings/code';
45
 
46
  /**
47
+ * Module Human Readable Name
48
+ */
49
+ protected $_name = 'Bronto Extension for Magento';
50
+
51
+ /**
52
+ * Get Human Readable Name
53
+ *
54
+ * @return string
55
+ */
56
+ public function getName()
57
+ {
58
+ return $this->__($this->_name);
59
+ }
60
+
61
+ /**
62
+ * Check if module is enabled
63
+ *
64
+ * @param string $scope
65
+ * @param int $scopeId
66
+ *
67
  * @return bool
68
  */
69
+ public function isEnabled($scope = 'default', $scopeId = 0)
70
  {
71
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
72
  }
73
 
74
  /*
82
  }
83
 
84
  /**
85
+ * Get Javascript for Pop-up
86
  *
87
+ * @return string
88
  */
89
+ public function getPopupCode()
90
  {
91
+ return $this->getAdminScopedConfig(self::XML_PATH_POPUP_CODE);
92
  }
93
 
94
  /**
95
  * Determine if email can be sent through bronto
96
  *
97
  * @param Mage_Core_Model_Email_Template $template
98
+ * @param string|int $storeId
99
  *
100
  * @return boolean
101
  */
102
  public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
103
  {
104
+ if ($this->isEnabled('store', $storeId)) {
105
+ return true;
106
  }
107
 
108
+ return false;
109
  }
110
 
111
  /**
112
+ * Get Image URL for Product, sized to config specs
113
+ *
114
+ * @param Mage_Catalog_Model_Product $product
115
+ *
116
  * @return string
117
  */
118
  public function getProductImageUrl($product)
119
  {
120
+ return (string)Mage::helper('catalog/image')
121
+ ->init($product, $this->getImageType($product->getStoreId()))
122
+ ->resize(
123
  $this->getImageWidth($product->getStoreId()),
124
  $this->getImageHeight($product->getStoreId())
125
  );
126
  }
127
 
128
  /**
129
+ * @param string|int $storeId
130
+ *
131
  * @return string
132
  */
133
  public function getImageType($storeId = null)
134
  {
135
+ return $this->getAdminScopedConfig(self::XML_PATH_IMAGE_TYPE, 'store', $storeId);
136
  }
137
 
138
  /**
139
+ * @param string|int $storeId
140
+ *
141
  * @return int|null
142
  */
143
  public function getImageWidth($storeId = null)
144
  {
145
+ $width = (int)$this->getAdminScopedConfig(self::XML_PATH_IMAGE_WIDTH, 'store', $storeId);
146
 
147
+ return empty($width) ? null : abs($width);
148
  }
149
 
150
  /**
151
+ * @param string|int $storeId
152
+ *
153
  * @return int|null
154
  */
155
  public function getImageHeight($storeId = null)
156
  {
157
+ $height = (int)$this->getAdminScopedConfig(self::XML_PATH_IMAGE_HEIGHT, 'store', $storeId);
158
 
159
+ return empty($height) ? null : abs($height);
160
  }
161
 
162
  /**
163
+ * @param string|int $storeId
164
+ *
165
  * @return bool
166
  */
167
+ public function useCurrencySymbol($storeId = null)
168
  {
169
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_USE_SYMBOL, 'store', $storeId);
170
+ }
171
+
172
+ /**
173
+ * @param mixed $storeId
174
+ *
175
+ * @return bool
176
+ */
177
+ public function displayPriceIncTax($storeId = null)
178
+ {
179
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_INCL_TAX, 'store', $storeId);
180
+ }
181
+
182
+ /**
183
+ * Get Default Greeting Settings
184
+ *
185
+ * @param string $piece
186
+ * @param string $scope
187
+ * @param int $scopeId
188
+ *
189
+ * @return mixed
190
+ */
191
+ public function getDefaultGreeting($piece = 'full', $scope = 'default', $scopeId = 0)
192
+ {
193
+ switch ($piece) {
194
+ case 'prefix':
195
+ return $this->getAdminScopedConfig(self::XML_PATH_GREETING_PRE, $scope, $scopeId);
196
+ case 'firstname':
197
+ return $this->getAdminScopedConfig(self::XML_PATH_GREETING_FIRST, $scope, $scopeId);
198
+ case 'lastname':
199
+ return $this->getAdminScopedConfig(self::XML_PATH_GREETING_LAST, $scope, $scopeId);
200
+ case 'full':
201
+ default:
202
+ return $this->getAdminScopedConfig(self::XML_PATH_GREETING_FULL, $scope, $scopeId);
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Check if module can use the magento cron
208
+ *
209
+ * @return bool
210
+ */
211
+ public function canUseMageCron()
212
+ {
213
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
214
+ }
215
+
216
+ /**
217
+ * @return string
218
+ */
219
+ public function getCronStringPath()
220
+ {
221
+ return self::XML_PATH_CRON_STRING;
222
+ }
223
+
224
+ /**
225
+ * @return string
226
+ */
227
+ public function getCronModelPath()
228
+ {
229
+ return self::XML_PATH_CRON_MODEL;
230
+ }
231
+
232
+ /**
233
+ * Disable Specified Module
234
+ *
235
+ * @param string $scope
236
+ * @param int $scopeId
237
+ * @param bool $deleteConfig
238
+ *
239
+ * @return bool
240
+ */
241
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
242
+ {
243
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
244
  }
245
 
246
  /**
247
  * @param string $path
248
  * @param string $scope
249
  * @param int $scopeId
250
+ * @param bool $deleteConfig
251
  *
252
  * @return bool
253
  */
254
+ protected function _disableModule($path, $scope = 'default', $scopeId = 0, $deleteConfig = false)
255
+ {
256
+ if ($scope == 'website' || $scope == 'store') {
257
+ $scope .= 's';
258
+ }
259
+
260
+ $coreConfig = Mage::getModel('core/config');
261
+ $coreConfigData = Mage::getModel('core/config_data');
262
+
263
+ // If set, we delete the config value instead of just setting it to 0
264
+ if ($deleteConfig) {
265
+ $coreConfig->deleteConfig($path, $scope, $scopeId);
266
+
267
+ $coreConfigData
268
+ ->load($path)
269
+ ->setScope($scope)
270
+ ->setScopeId($scopeId)
271
+ ->delete();
272
+ } else {
273
+ $coreConfig->saveConfig($path, 0, $scope, $scopeId);
274
+
275
+ if (!$this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
276
+ list($module) = explode('/', $path);
277
+
278
+ $coreConfigData->setScope($scope)
279
+ ->setScopeId($scopeId)
280
+ ->setPath("$module/settings/enabled")
281
+ ->setValue(0)
282
+ ->save();
283
+ }
284
  }
285
 
286
+ Mage::getConfig()->reinit();
287
+ Mage::app()->reinitStores();
288
+
289
  return $this;
290
  }
291
 
292
  /**
293
  * Determine if module is active
294
+ *
295
  * @return boolean
296
  */
297
  public function isModuleActive()
298
  {
299
  // If module is not enabled, return false
300
  if (!$this->isEnabled()) {
301
+ return false;
302
  }
303
 
304
  // If module is missing token, return false
305
  if (!$this->getApiToken()) {
306
+ return false;
307
  }
308
 
309
  // If requirements are not met, return false
310
  if (!$this->verifyRequirements($this->_getModuleName())) {
311
+ return false;
312
  }
313
 
314
+ return true;
315
  }
316
 
317
  /**
321
  */
322
  public function hasCustomConfig()
323
  {
324
+ return false;
325
  }
326
 
327
  /**
344
  public function verifyRequirements($module, $required = array())
345
  {
346
  // Check for required PHP extensions
347
+ $verified = true;
348
  $missing = array();
349
  $defaultRequired = array('soap', 'openssl');
350
  $required = array_merge($required, $defaultRequired);
358
  try {
359
  if (!extension_loaded($extName)) {
360
  $missing[] = $extName;
361
+ $verified = false;
362
  }
363
+ } catch (Exception $e) {
 
364
  $missing[] = $extName;
365
+ $verified = false;
366
  }
367
  }
368
 
386
  $message->setIdentifier($module);
387
  Mage::getSingleton('adminhtml/session')->addMessage($message);
388
 
389
+ return false;
390
  }
391
 
392
+ return true;
393
  }
394
 
395
  /**
396
+ * Get Token Instance
397
+ *
398
+ * @param null $token
399
+ * @param string $scope
400
+ * @param int $scopeId
401
  *
402
  * @return Bronto_Common_Model_Api
403
  */
404
+ public function getApi($token = null, $scope = 'default', $scopeId = 0)
405
  {
406
  if (empty($token)) {
407
+ $token = $this->getApiToken($scope, $scopeId);
408
  }
409
 
410
  return Bronto_Common_Model_Api::getInstance($token);
411
  }
412
 
413
  /**
414
+ * Get API Token from Config
415
  *
416
+ * @param string $scope
417
+ * @param int $scopeId
418
+ *
419
+ * @return bool|mixed
420
  */
421
+ public function getApiToken($scope = 'default', $scopeId = 0)
422
  {
423
+ $token = $this->getAdminScopedConfig(self::XML_PATH_API_TOKEN, $scope, $scopeId);
424
 
425
+ if (!$token || empty($token) || is_null($token) || $token == 'NULL') {
426
+ return false;
427
  }
428
 
429
  return $token;
432
  /**
433
  * Determine if API token is valid
434
  *
435
+ * @param null $token
436
+ * @param string $scope
437
+ * @param int $scopeId
438
  *
439
+ * @return bool
440
  */
441
+ public function validApiToken($token = null, $scope = 'default', $scopeId = 0)
442
  {
443
+ // If token is specifically set to false, then there is no token and is technically valid
444
+ if (false === $token) {
445
+ return true;
446
+ }
447
+
448
+ // If token is empty try to pull from config
449
  if (empty($token)) {
450
+ $token = $this->getApiToken($scope, $scopeId);
451
  }
452
 
453
+ // If token is not correct length, return false
454
+ if (strlen($token) != 36) {
455
+ return false;
456
  }
457
+
458
  try {
459
+ $api = new Bronto_Api($token, array('debug' => true));
460
  $api->login();
461
+ $tokenRow = $api->getTokenInfo();
462
+
463
+ return $tokenRow->hasPermissions(7);
464
+ } catch (Exception $e) {
465
+ return false;
466
  }
467
+ }
468
+
469
+ /**
470
+ * Determines if the last API token used is in a valid state at the current
471
+ * scope.
472
+ *
473
+ * @return bool
474
+ */
475
+ public function validApiStatus()
476
+ {
477
+ if (!Mage::helper('bronto_verify/apitoken')->getStatus()) {
478
+ $this->_addSingleSessionMessage(
479
+ 'error',
480
+ 'The Bronto API Token you have entered for this scope appears to be invalid.'
481
+ );
482
+ return false;
483
  }
484
 
485
+ return true;
486
  }
487
 
488
  /**
489
+ * Adds a single message to the session, as to not flood the
490
+ * session messages with the same content
491
+ *
492
+ * @param $type string
493
+ * @param $msg string
494
+ * @param $module string (optional)
495
  * @return boolean
496
  */
497
+ protected function _addSingleSessionMessage($type, $msg, $module = 'bronto_common')
498
+ {
499
+ $message = Mage::getSingleton('core/message')->{$type}($this->__($msg));
500
+ $message->setIdentifier($module);
501
+ $session = Mage::getSingleton('adminhtml/session');
502
+ foreach ($session->getMessages()->getItemsByType($type) as $set) {
503
+ if ($set->getIdentifier() == $message->getIdentifier()) {
504
+ $exists = true;
505
+ break;
506
+ }
507
+ }
508
+
509
+ if (empty($exists)) {
510
+ $session->addMessage($message);
511
+ }
512
+
513
+ return empty($exists);
514
+ }
515
+
516
+ /**
517
+ * Check all API tokens are valid
518
+ *
519
+ * @param string $identifier
520
+ *
521
+ * @return bool
522
+ */
523
  public function validApiTokens($identifier = 'bronto_common')
524
  {
525
+ $valid = true;
526
+ if (!$this->validApiToken($this->getApiToken())) {
527
  $message = Mage::getSingleton('core/message')->error(
528
  $this->__('The Bronto API Token you have entered for Default Configuration appears to be invalid.')
529
  );
530
  $message->setIdentifier($identifier);
531
  Mage::getSingleton('adminhtml/session')->addMessage($message);
532
+ $valid = false;
533
  }
534
  foreach (Mage::app()->getWebsites() as $website) {
535
+ if (!$this->validApiToken($this->getApiToken('website', $website->getId()), 'website', $website->getId())) {
536
  $message = Mage::getSingleton('core/message')->error(
537
  $this->__(
538
  sprintf(
543
  );
544
  $message->setIdentifier($identifier);
545
  Mage::getSingleton('adminhtml/session')->addMessage($message);
546
+ $valid = false;
547
  }
548
  foreach ($website->getGroups() as $group) {
549
  $stores = $group->getStores();
550
  if (count($stores) > 0) {
551
  foreach ($stores as $store) {
552
+ if (!$this->validApiToken($this->getApiToken('store', $store->getId()), 'store', $store->getId())) {
553
  $message = Mage::getSingleton('core/message')->error(
554
  $this->__(
555
  sprintf(
561
  );
562
  $message->setIdentifier($identifier);
563
  Mage::getSingleton('adminhtml/session')->addMessage($message);
564
+ $valid = false;
565
  }
566
  }
567
  }
576
  *
577
  * @return bool
578
  */
579
+ public function isModuleInstalled($moduleName = null)
580
  {
581
+ $modules = (array)Mage::getConfig()->getNode('modules')->children();
582
 
583
+ if ($moduleName === null) {
584
  $moduleName = $this->_getModuleName();
585
  }
586
 
587
+ if (!isset($modules[$moduleName])) {
588
+ return false;
589
+ }
590
+
591
+ return ($modules[$moduleName]->active == 'true');
592
+ }
593
+
594
+ /**
595
+ * Get SOAP Options
596
+ *
597
+ * @return array
598
+ */
599
+ public function getSoapOptions()
600
+ {
601
+ // If Verify Module is enabled, use the settings from there
602
+ if ($this->isModuleInstalled('Bronto_Verify') && $this->isModuleActive()) {
603
+ return Mage::helper('bronto_verify')->getSoapOptions();
604
+ }
605
+
606
+ // Return Default Options
607
+ return array(
608
+ 'retry_limit' => 2,
609
+ 'debug' => $this->isDebugEnabled(),
610
+ );
611
  }
612
 
613
  /**
615
  *
616
  * @return string
617
  */
618
+ public function getModuleVersion($moduleName = null)
619
  {
620
+ $modules = (array)Mage::getConfig()->getNode('modules')->children();
621
 
622
+ if ($moduleName === null) {
623
  $moduleName = $this->_getModuleName();
624
  }
625
 
626
+ return isset($modules[$moduleName]) ? (string)$modules[$moduleName]->version : null;
627
  }
628
 
629
  /**
632
  public function isDebugEnabled()
633
  {
634
  if (!$this->getApiToken()) {
635
+ return false;
636
  }
637
 
638
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_DEBUG);
639
  }
640
 
641
  /**
644
  public function isVerboseEnabled()
645
  {
646
  if (!$this->isDebugEnabled()) {
647
+ return false;
648
  }
649
 
650
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_VERBOSE);
651
  }
652
 
653
  /**
656
  public function isTestModeEnabled()
657
  {
658
  if (!$this->getApiToken()) {
659
+ return false;
660
  }
661
 
662
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_TEST);
663
  }
664
 
665
  /**
668
  public function isNoticesEnabled()
669
  {
670
  if (!$this->getApiToken()) {
671
+ return false;
672
  }
673
 
674
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_NOTICES);
675
  }
676
 
677
  /**
678
+ * Write message to Debug log
679
+ *
680
+ * @param mixed $message
681
+ * @param null $file
682
+ * @param bool $verbose
683
  *
684
  * @return bool|void
685
  */
686
+ public function writeDebug($message, $file = null, $verbose = false)
687
  {
688
  if ($verbose && !$this->isVerboseEnabled()) {
689
+ return false;
690
  }
691
 
692
  if ($this->isDebugEnabled()) {
693
  return $this->writeLog($message, $file, Zend_Log::DEBUG);
694
  }
695
+
696
+ return false;
697
  }
698
 
699
  /**
702
  *
703
  * @return bool|void
704
  */
705
+ public function writeVerboseDebug($message, $file = null)
706
  {
707
  if ($this->isVerboseEnabled()) {
708
+ return $this->writeDebug($message, $file, true);
709
  }
710
+
711
+ return false;
712
  }
713
 
714
  /**
717
  *
718
  * @return bool|void
719
  */
720
+ public function writeInfo($message, $file = null)
721
  {
722
  if ($this->isNoticesEnabled()) {
723
  if (Mage::getSingleton('admin/session')->isLoggedIn()) {
724
  /* @var $message Mage_Core_Model_Message_Notice */
725
  $message = Mage::getSingleton('core/message')->notice("[Bronto] {$message}");
726
  Mage::getSingleton('adminhtml/session')->addMessage($message);
727
+ } else {
 
728
  Mage::getSingleton('core/session')->addNotice("[Bronto] {$message}");
729
  }
730
  }
738
  *
739
  * @return bool|void
740
  */
741
+ public function writeError($message, $file = null)
742
  {
743
  if (is_object($message) && $message instanceOf Exception) {
744
  $message = $message->getMessage();
748
  /* @var $message Mage_Core_Model_Message_Error */
749
  $message = Mage::getSingleton('core/message')->error("[Bronto] {$message}");
750
  Mage::getSingleton('adminhtml/session')->addMessage($message);
751
+ } else {
 
752
  Mage::getSingleton('core/session')->addError("[Bronto] {$message}");
753
  }
754
  }
763
  *
764
  * @return bool|void
765
  */
766
+ public function writeLog($message, $file = null, $level = Zend_Log::DEBUG)
767
  {
768
  if (empty($file)) {
769
  $file = strtolower($this->_getModuleName()) . '.log';
771
  if (!is_string($message)) {
772
  if (method_exists($message, '__toString')) {
773
  $message = $message->__toString();
774
+ } else {
775
+ return false;
 
776
  }
777
  }
778
 
779
+ return Mage::log($message, $level, $this->_stampFile($file), true);
780
  }
781
 
782
  /**
783
  * Add Date Stamp to log file name
784
  *
785
+ * @param $filename
786
+ * @param bool $withTime
787
  *
788
+ * @return mixed
789
  */
790
+ protected function _stampFile($filename, $withTime = true)
791
  {
792
  // Ensure var/log/bronto exists
793
  $logDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
794
  if (!is_dir($logDir)) {
795
+ mkdir($logDir, 0777, true);
796
  }
797
 
798
  // If time stamp requested, append
807
 
808
  /**
809
  * Get list of active custom modules
810
+ *
811
+ * @param bool $brontoOnly
812
+ *
813
  * @return array
814
  */
815
+ public function getInstalledModules($brontoOnly = false)
816
  {
817
  $moduleList = array();
818
  $modules = Mage::getConfig()->getNode('modules')->children();
819
 
820
  foreach ($modules as $name => $module) {
821
+ if ($brontoOnly) {
822
+ if (strpos($name, 'Bronto_') !== false && $module->active == 'true') {
823
+ $moduleList[] = strtolower($name);
824
+ }
825
+ } else if (strpos($name, 'Mage_') === false && strpos($name, 'Enterprise_') === false &&
826
  $module->active == 'true'
827
  ) {
828
  $moduleList[] = $name . ' [v' . $module->version . ' codePool: ' . $module->codePool . ']';
834
 
835
  /**
836
  * Get array of current scope parameters
837
+ *
838
  * @return array
839
  */
840
  public function getScopeParams()
847
  'scope' => 'default',
848
  'default' => 0,
849
  'default_id' => 0,
850
+ 'store' => $request->getParam('store', false),
851
  'store_id' => 0,
852
+ 'website' => $request->getParam('website', false),
853
  'website_id' => 0,
854
+ 'group' => $request->getParam('group', false),
855
  'group_id' => 0,
856
  );
857
 
862
  $scopeParams['store_id'] = $store->getId();
863
  }
864
  $scopeParams['scope'] = 'store';
865
+ } elseif ($scopeParams['website']) {
 
866
  $website = Mage::app()->getWebsite($scopeParams['website']);
867
  if ($website->getId()) {
868
  $scopeParams['website_id'] = $website->getId();
869
  }
870
  $scopeParams['scope'] = 'website';
871
+ } elseif ($scopeParams['group']) {
 
872
  $group = Mage::app()->getGroup($scopeParams['group']);
873
  if ($group->getId()) {
874
  $scopeParams['group_id'] = $group->getId();
883
  /**
884
  * Get Url with scope data included
885
  *
886
+ * @param $url
887
+ * @param array $scopeParams
888
  *
889
+ * @return mixed
890
  */
891
  public function getScopeUrl($url, $scopeParams = array())
892
  {
895
  'scope' => $curScopeParams['scope'],
896
  $curScopeParams['scope'] => $curScopeParams[$curScopeParams['scope']],
897
  );
898
+
899
+ if (array_key_exists('scope', $scopeParams)) {
900
+ if ($scopeParams['scope'] != $curScope['scope']) {
901
+ unset($curScope[$curScope['scope']]);
902
+ }
903
+
904
+ unset($scopeParams['scope']);
905
+ }
906
+ unset($curScope['scope']);
907
+
908
+ $scopeParams = array_merge($scopeParams, $curScope);
909
 
910
  return Mage::helper('adminhtml')->getUrl($url, $scopeParams);
911
  }
912
 
913
  /**
914
+ * Get Scoped Config Data
915
+ *
916
+ * @param $path
917
+ * @param string $scope
918
+ * @param int $scopeId
919
  *
920
  * @return mixed
921
  */
922
+ public function getAdminScopedConfig($path, $scope = 'default', $scopeId = 0)
923
  {
924
+ if ('store' == $scope) {
925
+ return Mage::getStoreConfig($path, $scopeId);
926
+ } elseif ('website' == $scope) {
927
+ $website = Mage::app()->getWebsite($scopeId);
 
928
 
929
  return $website->getConfig($path);
930
  }
931
 
932
  $scopeParams = $this->getScopeParams();
 
933
 
934
  switch ($scopeParams['scope']) {
935
  case 'store':
955
 
956
  /**
957
  * Get Array of Store Ids based on current store/website/group
958
+ *
959
  * @return boolean|array
960
  */
961
  public function getStoreIds()
976
  $storeIds = $source->getStoreIds();
977
  break;
978
  default:
979
+ $storeIds = array_keys(Mage::app()->getStores(true));
980
  break;
981
  }
982
 
993
  return ('Enterprise' == $this->getEdition());
994
  }
995
 
996
+ /**
997
+ * Is this the Professional edition?
998
+ *
999
+ * @return bool
1000
+ */
1001
+ public function isProfessionalEdition()
1002
+ {
1003
+ return ('Professional' == $this->getEdition());
1004
+ }
1005
+
1006
  /**
1007
  * Get Edition from version Info
1008
  *
1010
  *
1011
  * @return string|boolean
1012
  */
1013
+ public function getEdition($versionInfo = false)
1014
  {
1015
  // Ensure we have version info
1016
  if (!$versionInfo || !is_array($versionInfo)) {
1028
  if (1 == $major) {
1029
  if ($minor < 9) {
1030
  return 'Community';
1031
+ } else if ($minor >= 9 && $minor < 11) {
 
1032
  return 'Professional';
1033
+ } else if ($minor >= 11) {
 
1034
  return 'Enterprise';
1035
  }
1036
  }
1037
  }
1038
 
1039
+ return false;
1040
  }
1041
 
1042
  /**
1043
  * Takes major and minor version info and determines if current magento install matches
1044
  *
1045
+ * Uses magic method to get Arguments
 
 
 
 
 
1046
  *
1047
+ * param array $versionInfo
1048
+ * param int|string|array $major
1049
+ * param int|string|array $minor
1050
+ * param int|string|array $revision (Optional)
1051
+ * param int|string|array $patch (Optional)
1052
+ * param string $edition (Optional) 'CE'|'Community'|'PE'|'Professional'|'EE'|'Enterprise'
1053
+ *
1054
+ * @return bool
1055
  */
1056
  public function isVersionMatch()
1057
  {
1069
 
1070
  // At least version info and one other
1071
  if (!array_key_exists('versionInfo', $parts) || count($parts) < 2) {
1072
+ return false;
1073
  }
1074
 
1075
  // Get Magento Version from passed arguments
1093
 
1094
  // Cycle through compare value array to compare against
1095
  // current Magento version element
1096
+ $internalMatch = false;
1097
  foreach ($value as $option) {
1098
  $operator = '==';
1099
  $compare = $option;
1105
  }
1106
 
1107
  if ($index == 'edition') {
1108
+ // handle possibility of initials being used
1109
  switch (strtoupper($compare)) {
1110
  case 'EE':
1111
  $compare = 'Enterprise';
1122
 
1123
  // If response from getEdition matches compare edition
1124
  $internalMatch = ($mValue == $compare);
1125
+ } else {
 
1126
  // Use version_compare to compare the Magento version to the
1127
  // Current compare version using the provided operator
1128
  $internalMatch = version_compare($mValue, $compare, $operator);
1136
  // If the internal Match flag hasn't been set to true,
1137
  // there is no match
1138
  if (!$internalMatch) {
1139
+ return false;
1140
  }
1141
  }
1142
 
1143
  // If we haven't returned false yet, that means there is a match
1144
+ return true;
1145
  }
1146
 
1147
  /**
1155
  {
1156
  // Parts must be array
1157
  if (!is_array($parts)) {
1158
+ return false;
1159
  }
1160
 
1161
  // Generate index map values
app/code/community/Bronto/Common/Helper/DataInterface.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  interface Bronto_Common_Helper_DataInterface
9
  {
@@ -11,8 +10,10 @@ interface Bronto_Common_Helper_DataInterface
11
  * Disable the module in the admin configuration
12
  *
13
  * @param string $scope
14
- * @param int $scopeId
15
- * @return bool
 
 
16
  */
17
- public function disableModule($scope = 'default', $scopeId = 0);
18
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  interface Bronto_Common_Helper_DataInterface
8
  {
10
  * Disable the module in the admin configuration
11
  *
12
  * @param string $scope
13
+ * @param int $scopeId
14
+ * @param bool $deleteConfig
15
+ *
16
+ * @return mixed
17
  */
18
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false);
19
  }
app/code/community/Bronto/Common/Helper/Field.php CHANGED
@@ -3,13 +3,13 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Helper_Field extends Bronto_Common_Helper_Data
9
  {
10
  /**
11
  * @param string $name
12
- * @param array $options
 
13
  * @return Bronto_Api_Field_Row
14
  */
15
  public function getFieldByName($name, $options)
@@ -18,10 +18,10 @@ class Bronto_Common_Helper_Field extends Bronto_Common_Helper_Data
18
  $fieldObject = $this->getApi()->getFieldObject();
19
 
20
  if (!($field = $fieldObject->getFromCache($name))) {
21
- $field = $fieldObject->createRow();
22
- $field->name = $name;
23
  $field->label = $options['label'];
24
- $field->type = $options['type'];
25
  if (!empty($options['options'])) {
26
  $field->options = $options['options'];
27
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Helper_Field extends Bronto_Common_Helper_Data
8
  {
9
  /**
10
  * @param string $name
11
+ * @param array $options
12
+ *
13
  * @return Bronto_Api_Field_Row
14
  */
15
  public function getFieldByName($name, $options)
18
  $fieldObject = $this->getApi()->getFieldObject();
19
 
20
  if (!($field = $fieldObject->getFromCache($name))) {
21
+ $field = $fieldObject->createRow();
22
+ $field->name = $name;
23
  $field->label = $options['label'];
24
+ $field->type = $options['type'];
25
  if (!empty($options['options'])) {
26
  $field->options = $options['options'];
27
  }
app/code/community/Bronto/Common/Helper/Message.php CHANGED
@@ -3,23 +3,38 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
9
  {
10
  /**
11
- * @param string $messageId
 
 
 
 
 
12
  * @return Bronto_Api_Message_Row
13
  */
14
  public function getMessageById($messageId, $storeId = null, $websiteId = null)
15
  {
 
 
 
 
 
 
 
 
 
 
 
16
  /* @var $messageObject Bronto_Api_Message */
17
- $messageObject = $this->getApi(null, $storeId, $websiteId)->getMessageObject();
18
 
19
  // Load Message
20
  try {
21
  /* @var $message Bronto_Api_Message_Row */
22
- $message = $messageObject->createRow();
23
  $message->id = $messageId;
24
  $message->read();
25
  } catch (Exception $e) {
@@ -42,12 +57,11 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
42
  continue;
43
  }
44
  foreach ($stores as $store) {
45
- if (Mage::helper('bronto_email')->isEnabled($store->getId())) {
46
- $storeMessages = Mage::helper('bronto_common/message')
47
- ->getMessagesOptionsArray(
48
- $store->getId(),
49
- $website->getId()
50
- );
51
  $messageOptions = array_merge($messageOptions, $storeMessages);
52
  }
53
  }
@@ -69,18 +83,34 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
69
  /**
70
  * Retrieve array of available Bronto Messages
71
  *
 
 
 
 
 
72
  * @return array
73
  */
74
  public function getMessagesOptionsArray($store = null, $websiteId = null, $filter = array(), $withCreateNew = false)
75
  {
 
 
 
 
 
 
 
 
 
 
 
76
  /* @var $api Bronto_Api */
77
- $api = $this->getApi(null, $store, $websiteId);
78
 
79
  if ($api) {
80
  /* @var $messageObject Bronto_Api_Message */
81
  $messageObject = $api->getMessageObject();
82
 
83
- $options = array();
84
  $pageNumber = 1;
85
 
86
  try {
@@ -106,14 +136,14 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
106
  if ($withCreateNew) {
107
  // Add Create New.. Option
108
  array_unshift($options, array(
109
- 'label' => '** Create New...',
110
- 'value' => '_new_'
111
  ));
112
  } else {
113
  // Add -- None Selected -- Option
114
  array_unshift($options, array(
115
- 'label' => '-- None Selected --',
116
- 'value' => ''
117
  ));
118
  }
119
 
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
8
  {
9
  /**
10
+ * Get Bronto Message Object by ID
11
+ *
12
+ * @param $messageId
13
+ * @param null $storeId
14
+ * @param null $websiteId
15
+ *
16
  * @return Bronto_Api_Message_Row
17
  */
18
  public function getMessageById($messageId, $storeId = null, $websiteId = null)
19
  {
20
+ if (!is_null($storeId)) {
21
+ $scope = 'store';
22
+ $scopeId = $storeId;
23
+ } elseif (!is_null($websiteId)) {
24
+ $scope = 'website';
25
+ $scopeId = $websiteId;
26
+ } else {
27
+ $scope = 'default';
28
+ $scopeId = 0;
29
+ }
30
+
31
  /* @var $messageObject Bronto_Api_Message */
32
+ $messageObject = $this->getApi(null, $scope, $scopeId)->getMessageObject();
33
 
34
  // Load Message
35
  try {
36
  /* @var $message Bronto_Api_Message_Row */
37
+ $message = $messageObject->createRow();
38
  $message->id = $messageId;
39
  $message->read();
40
  } catch (Exception $e) {
57
  continue;
58
  }
59
  foreach ($stores as $store) {
60
+ if (Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
61
+ $storeMessages = $this->getMessagesOptionsArray(
62
+ $store->getId(),
63
+ $website->getId()
64
+ );
 
65
  $messageOptions = array_merge($messageOptions, $storeMessages);
66
  }
67
  }
83
  /**
84
  * Retrieve array of available Bronto Messages
85
  *
86
+ * @param null $store
87
+ * @param null $websiteId
88
+ * @param array $filter
89
+ * @param bool $withCreateNew
90
+ *
91
  * @return array
92
  */
93
  public function getMessagesOptionsArray($store = null, $websiteId = null, $filter = array(), $withCreateNew = false)
94
  {
95
+ if (!is_null($store)) {
96
+ $scope = 'store';
97
+ $scopeId = $store;
98
+ } elseif (!is_null($websiteId)) {
99
+ $scope = 'website';
100
+ $scopeId = $websiteId;
101
+ } else {
102
+ $scope = 'default';
103
+ $scopeId = 0;
104
+ }
105
+
106
  /* @var $api Bronto_Api */
107
+ $api = $this->getApi(null, $scope, $scopeId);
108
 
109
  if ($api) {
110
  /* @var $messageObject Bronto_Api_Message */
111
  $messageObject = $api->getMessageObject();
112
 
113
+ $options = array();
114
  $pageNumber = 1;
115
 
116
  try {
136
  if ($withCreateNew) {
137
  // Add Create New.. Option
138
  array_unshift($options, array(
139
+ 'label' => '** Create New...',
140
+ 'value' => '_new_'
141
  ));
142
  } else {
143
  // Add -- None Selected -- Option
144
  array_unshift($options, array(
145
+ 'label' => '-- None Selected --',
146
+ 'value' => ''
147
  ));
148
  }
149
 
app/code/community/Bronto/Common/Helper/Product.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
9
  {
@@ -23,10 +22,12 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
23
  * template string with corresponding values
24
  *
25
  * @link https://github.com/leek/zf-components/blob/master/library/Leek/Config.php
26
- * @param string $subject Template string
27
- * @param array $map Key / value pairs to substitute with
28
- * @param string $delimiter Template parameter delimiter (must be valid without escaping in a regular expression)
29
- * @param bool $blankIfNone Set to blank if none found
 
 
30
  * @return string
31
  * @static
32
  */
@@ -47,10 +48,12 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
47
  }
48
 
49
  /**
50
- * @param string $subject
 
 
51
  * @param string $delimiter
52
- * @param mixed $index
53
- * @return array
54
  */
55
  public function getTemplateVariables($subject, $delimiter = '%')
56
  {
@@ -67,8 +70,12 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
67
  }
68
 
69
  /**
70
- * @param int $productId
71
- * @return boolean|Mage_Catalog_Model_Product
 
 
 
 
72
  */
73
  public function getProduct($productId, $storeId = false)
74
  {
@@ -91,13 +98,18 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
91
  }
92
 
93
  $this->_productCache[$storeId][$productId] = $product;
 
94
  return $product;
95
  }
96
 
97
  /**
98
- * @param Mage_Catalog_Model_Product $product
99
- * @param string $name
100
- * @return mixed
 
 
 
 
101
  */
102
  public function getProductAttribute($productId, $name, $storeId = false)
103
  {
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
8
  {
22
  * template string with corresponding values
23
  *
24
  * @link https://github.com/leek/zf-components/blob/master/library/Leek/Config.php
25
+ *
26
+ * @param string $subject Template string
27
+ * @param array $map Key / value pairs to substitute with
28
+ * @param string $delimiter Template parameter delimiter (must be valid without escaping in a regular expression)
29
+ * @param bool $blankIfNone Set to blank if none found
30
+ *
31
  * @return string
32
  * @static
33
  */
48
  }
49
 
50
  /**
51
+ * Get Variables from Template
52
+ *
53
+ * @param $subject
54
  * @param string $delimiter
55
+ *
56
+ * @return mixed
57
  */
58
  public function getTemplateVariables($subject, $delimiter = '%')
59
  {
70
  }
71
 
72
  /**
73
+ * Get Product by ID and Store ID
74
+ *
75
+ * @param $productId
76
+ * @param bool $storeId
77
+ *
78
+ * @return bool|Mage_Core_Model_Abstract
79
  */
80
  public function getProduct($productId, $storeId = false)
81
  {
98
  }
99
 
100
  $this->_productCache[$storeId][$productId] = $product;
101
+
102
  return $product;
103
  }
104
 
105
  /**
106
+ * Get Attributes for Product
107
+ *
108
+ * @param $productId
109
+ * @param $name
110
+ * @param bool $storeId
111
+ *
112
+ * @return bool|mixed|string
113
  */
114
  public function getProductAttribute($productId, $name, $storeId = false)
115
  {
app/code/community/Bronto/Common/Helper/Salesrule.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2012 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Common_Helper_Salesrule extends Bronto_Common_Helper_Data
8
+ {
9
+ /**
10
+ * Load Sales Rule by ID
11
+ *
12
+ * @param $ruleId
13
+ *
14
+ * @return bool|Mage_Core_Model_Abstract
15
+ */
16
+ public function getRuleById($ruleId)
17
+ {
18
+ try {
19
+ $rule = Mage::getModel('salesrule/rule')->load($ruleId);
20
+ } catch (Exception $e) {
21
+ $this->writeError('Failed loading Rule for ID: ' . $ruleId);
22
+
23
+ return false;
24
+ }
25
+
26
+ return $rule;
27
+ }
28
+
29
+ /**
30
+ * Retrieve Option array of Sales Rules
31
+ *
32
+ * @return array
33
+ */
34
+ public function getRuleOptionsArray()
35
+ {
36
+ $options = array();
37
+
38
+ /** @var Mage_SalesRule_Model_Resource_Rule_Collection $rules */
39
+ $rules = Mage::getModel('salesrule/rule')->getCollection();
40
+
41
+ // If there are any rules
42
+ if ($rules->count()) {
43
+ // Cycle Through Rules
44
+ foreach ($rules as $rule) {
45
+ // If rule is not active, the from date or to date are invalid, or rule doesn't have a coupon just skip this rule
46
+ if (
47
+ !$rule->getIsActive() ||
48
+ (!is_null($rule->getFromDate()) && $rule->getFromDate() > Mage::getModel('core/date')->date('Y-m-d')) ||
49
+ (!is_null($rule->getToDate()) && $rule->getToDate() < Mage::getModel('core/date')->date('Y-m-d')) ||
50
+ ($rule->getCouponType() == Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON)
51
+ ) {
52
+ continue;
53
+ }
54
+
55
+ // Handle Coupon Label
56
+ $couponLabel = '(Coupon: *Auto Generated*)';
57
+ if ($couponCode = $rule->getPrimaryCoupon()->getCode()) {
58
+ $couponLabel = "(Coupon: {$couponCode})";
59
+ }
60
+
61
+ // Build Option
62
+ $options[] = array(
63
+ 'label' => "{$rule->getName()} {$couponLabel}",
64
+ 'value' => $rule->getRuleId(),
65
+ );
66
+ }
67
+ }
68
+
69
+ // Add -- None Selected -- Option
70
+ array_unshift($options, array(
71
+ 'label' => '-- None Selected --',
72
+ 'value' => ''
73
+ ));
74
+
75
+ return $options;
76
+ }
77
+ }
app/code/community/Bronto/Common/Helper/Support.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
4
  {
5
- const XML_PATH_SUPPORT = 'bronto/support';
6
- const XML_PATH_LAST_RUN = 'bronto/support/last_run';
7
- const XML_PATH_REGISTERED = 'bronto/support/registered';
8
 
9
  // Process registration
10
  protected $_registrationUrl = 'https://brontops.com/register/magento';
@@ -30,16 +30,39 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
30
  /**
31
  * @return bool
32
  */
33
- public function isRegistered() {
34
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_REGISTERED);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
 
37
  /**
38
  * @return int
39
  */
40
- public function getLastRunTimestamp() {
 
41
  if (is_null($this->_lastRun)) {
42
- $lastRun = $this->getAdminScopedConfig(self::XML_PATH_LAST_RUN);
43
  $this->_lastRun = $lastRun ? $lastRun : 0;
44
  }
45
 
@@ -50,15 +73,18 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
50
  * Set the registration value for this extension
51
  *
52
  * @param boolean $register
 
53
  * @return Mage_Core_Helper_Data
54
  */
55
- public function setRegistered($register = true) {
 
56
  $config = Mage::getModel('core/config');
57
  $config->saveConfig(self::XML_PATH_REGISTERED, $register ? '1' : '0', 'default', 0);
58
 
59
  // Force the register to pickup immediately
60
  Mage::getConfig()->reinit();
61
  Mage::app()->reinitStores();
 
62
  return $this;
63
  }
64
 
@@ -66,9 +92,11 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
66
  * Set the last run time for this extension
67
  *
68
  * @param string $date
69
- * return Mage_Core_Helper_Data
 
70
  */
71
- public function setLastRunDate($date) {
 
72
  $this->_lastRun = Mage::getModel('core/date')->timestamp($date);
73
 
74
  $config = Mage::getModel('core/config');
@@ -82,24 +110,26 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
82
  *
83
  * @return array
84
  */
85
- public function getSupportInformation() {
 
86
  $data = array();
87
  foreach ($this->_supportFormFields as $key) {
88
  switch ($key) {
89
- case 'extension_version':
90
- $value = 'v' . $this->getModuleVersion();
91
- break;
92
- case 'magento_version':
93
- $value = 'v' . Mage::getVersion();
94
- break;
95
- case 'magento_edition':
96
- $value = $this->getEdition();
97
- break;
98
- default:
99
- $value = $this->getAdminScopedConfig(self::XML_PATH_SUPPORT . "/$key");
100
  }
101
  $data[$key] = $value ? $value : '';
102
  }
 
103
  return $data;
104
  }
105
 
@@ -107,10 +137,13 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
107
  * Determines if this last run is a day old
108
  *
109
  * @param string $currentDate
 
110
  * @return boolean
111
  */
112
- public function isLastRunDifferent($currentDate) {
 
113
  $lastRun = $this->getLastRunTimestamp();
 
114
  return $lastRun != Mage::getModel('core/date')->timestamp($currentDate);
115
  }
116
 
@@ -118,9 +151,11 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
118
  * Gets the number of the reminder rules
119
  *
120
  * @param string $currentDate
 
121
  * @return int
122
  */
123
- public function getActiveReminderRules($currentDate) {
 
124
  return Mage::getModel('bronto_reminder/rule')
125
  ->getCollection()
126
  ->addDateFilter($currentDate)
@@ -133,33 +168,34 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
133
  *
134
  * @return array
135
  */
136
- public function getDebugInformation() {
137
- $currentDate = Mage::getModel('core/date')->date('Y-m-d');
 
138
  $brontoModules = $this->getEnabledBrontoModules();
139
- $formData = $this->getSupportInformation();
140
- $request = Mage::app()->getRequest();
141
 
142
  return array_merge(
143
- // Form submission
144
  $formData,
145
  // Current Websites / Stores; Enabled Bronto Modules
146
  array(
147
  // Client / Server information
148
- 'server_name' => $request->getServer('SERVER_NAME'),
149
- 'server_address' => $request->getServer('SERVER_ADDR'),
150
- 'server_protocol' => $request->getServer('SERVER_PROTOCOL'),
151
- 'php_version' => 'v' . phpversion(),
152
- 'mysql_version' => 'v' . Mage::getResourceModel('core/config')->getReadConnection()->getServerVersion(),
153
  'number_active_rules' => $this->getActiveReminderRules($currentDate),
154
  ),
155
  array(
156
  // Installed Modules
157
- 'installed_modules' => $this->getInstalledModules(),
158
  'magento_installation' => $this->getStoreInfo(),
159
  ),
160
  array(
161
  'bronto_modules' => $brontoModules,
162
- 'bronto_config' => $this->getBrontoConfigs($brontoModules)
163
  )
164
  );
165
  }
@@ -168,17 +204,19 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
168
  * Submits the Support form information
169
  *
170
  * @param array $formData (Optional)
 
171
  * @return boolean
172
  */
173
- public function submitSupportForm($formData = array()) {
 
174
  $currentDate = Mage::getModel('core/date')->date('Y-m-d');
175
  $this->setLastRunDate($currentDate)->setRegistered();
176
 
177
  $formData['extension_version'] = 'v' . $this->getModuleVersion();
178
- $formData['magento_version'] = 'v' . Mage::getVersion();
179
- $formData['magento_edition'] = $this->getEdition();
180
 
181
- $yesNo = Mage::getModel('adminhtml/system_config_source_yesno');
182
  $selectedValue = $formData['using_solution_partner'];
183
  foreach ($yesNo->toOptionArray() as $option) {
184
  if ($option['value'] == $selectedValue) {
@@ -198,7 +236,8 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
198
  *
199
  * @return array
200
  */
201
- public function getEnabledBrontoModules() {
 
202
  $brontoModules = array();
203
 
204
  $modules = Mage::getConfig()->getNode('modules')->children();
@@ -222,16 +261,18 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
222
  * Gets the Bronto configuration settings
223
  *
224
  * @param array $brontoModules
 
225
  * @return array
226
  */
227
- public function getBrontoConfigs($brontoModules) {
228
- $configs = array();
 
229
  $processedConfigs = array();
230
 
231
  foreach ($brontoModules as $name => $module) {
232
  $helperName = strtolower($name);
233
 
234
- $helper = Mage::helper($helperName);
235
  $reflector = new ReflectionClass(get_class($helper));
236
 
237
  $moduleConfig = array();
@@ -241,7 +282,7 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
241
  }
242
 
243
  $settingNameParts = explode('/', $setting);
244
- $settingName = end($settingNameParts);
245
 
246
  $value = Mage::getStoreConfig($setting);
247
  if (empty($settingName)) {
@@ -269,19 +310,20 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
269
  *
270
  * @return array
271
  */
272
- public function getStoreInfo() {
273
- $storeInfo = array();
274
- $websites = Mage::app()->getWebsites();
 
275
  $totalWebsites = count($websites);
276
- $totalStores = 0;
277
  foreach ($websites as $website) {
278
  $websiteStores = count($website->getStores());
279
  $totalStores += $websiteStores;
280
- $s = $websiteStores == 1 ? '' : 's';
281
  $storeInfo[] = "A website with $websiteStores store$s.";
282
  }
283
  $websites = $totalWebsites == 1 ? 'website' : 'websites';
284
- $stores = $totalStores == 1 ? 'store' : 'stores';
285
 
286
  $storeInfo[] = "Total of $totalWebsites $websites and $totalStores $stores";
287
 
@@ -293,18 +335,19 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
293
  *
294
  * @return Bronto_Common_Model_Archive
295
  */
296
- public function getLogArchive() {
297
- $logDir = Mage::getBaseDir('var') . DS . 'log';
298
- $systemLog = $logDir . DS . 'system.log';
 
299
  $exceptionLog = $logDir . DS . 'exception.log';
300
 
301
  $brontoLogDir = $logDir . DS . 'bronto';
302
- $tmpDir = $this->getArchiveDirectory();
303
- $file = $tmpDir . DS . 'log.' . time() . '.zip';
304
 
305
  $archive = Mage::getModel('bronto_common/archive');
306
  if ($archive->open($file, ZipArchive::OVERWRITE)) {
307
- $now = time();
308
  $threshold = $now - (60 * 60 * 24 * 30);
309
 
310
  $archive->addEmptyDir('log');
@@ -337,18 +380,21 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
337
  /**
338
  * Tails a given log for output
339
  *
340
- * @param string $logFile
 
341
  * @return string
342
  */
343
- protected function _tailLog($logfile) {
344
- $length = filesize($logfile);
 
345
  $maxRead = (1 * 1000 * 100);
346
- $fh = fopen($logfile, 'r');
347
  if ($length > $maxRead) {
348
  fseek($fh, $length - $maxRead);
349
  }
350
  $contents = fread($fh, $maxRead);
351
  fclose($fh);
 
352
  return $contents;
353
  }
354
 
@@ -358,9 +404,11 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
358
  *
359
  * @return string
360
  */
361
- public function getPhpInfoOutput() {
 
362
  ob_start();
363
  phpinfo();
 
364
  return ob_get_clean();
365
  }
366
 
@@ -369,19 +417,22 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
369
  *
370
  * @return string
371
  */
372
- public function getArchiveDirectory() {
 
373
  $brontoLogDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
374
- $tmpDir = $brontoLogDir . DS . 'archives';
375
  if (!file_exists($tmpDir)) {
376
  mkdir($tmpDir, 0777, true);
377
  }
 
378
  return $brontoLogDir . DS . 'archives';
379
  }
380
 
381
  /**
382
  * Deletes all of the archive logs
383
  */
384
- public function clearArchiveDirectory() {
 
385
  foreach (glob($this->getArchiveDirectory() . DS . '*') as $file) {
386
  unlink($file);
387
  }
@@ -391,10 +442,13 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
391
  * Sets the internal webform submission client
392
  *
393
  * @param Mage_HTTP_Client_Curl $client
 
394
  * @return Bronto_Common_Helper_Support
395
  */
396
- public function setHttpClient(Mage_HTTP_Client_Curl $client) {
 
397
  $this->_client = $client;
 
398
  return $this;
399
  }
400
 
@@ -403,27 +457,31 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
403
  *
404
  * @return Mage_HTTP_Client_Curl
405
  */
406
- protected function _getHttpClient() {
 
407
  if (empty($this->_client)) {
408
  $this->_client = new Mage_HTTP_Client_Curl();
409
  }
 
410
  return $this->_client;
411
  }
412
 
413
  /**
414
- * Submits a webform with the registeration info
415
  *
416
  * @param array $formData
 
417
  * @return bool
418
  */
419
- protected function _submitWebform(array $formData) {
 
420
 
421
  $client = $this->_getHttpClient();
422
  $params = array();
423
  foreach ($this->_supportFormFields as $name) {
424
- $parts = explode('_', $name);
425
  $restCamel = array_map('ucfirst', array_slice($parts, 1));
426
- $camel = implode('' , array_merge(array($parts[0]), $restCamel));
427
 
428
  $params[$camel] = $formData[$name];
429
  }
@@ -433,11 +491,12 @@ class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
433
  try {
434
  $client->setOptions(array(
435
  CURLOPT_SSL_VERIFYPEER => 0,
436
- CURLOPT_POSTFIELDS => $json
437
  ));
438
  $client->post($this->_registrationUrl, $json);
439
  } catch (Exception $e) {
440
  $this->writeError('Registration submission failed: ', $e->getMessage());
 
441
  return false;
442
  }
443
 
2
 
3
  class Bronto_Common_Helper_Support extends Bronto_Common_Helper_Data
4
  {
5
+ const XML_PATH_SUPPORT = 'bronto/support';
6
+ const XML_PATH_LAST_RUN = 'bronto/support/last_run';
7
+ const XML_PATH_REGISTERED = 'bronto/support/registered';
8
 
9
  // Process registration
10
  protected $_registrationUrl = 'https://brontops.com/register/magento';
30
  /**
31
  * @return bool
32
  */
33
+ public function isRegistered()
34
+ {
35
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_REGISTERED);
36
+ }
37
+
38
+ /**
39
+ * @param $onBronto boolean (optional)
40
+ * @return boolean
41
+ */
42
+ public function verifyRegistration($onBronto = false) {
43
+ if (!$this->isRegistered()) {
44
+ $appendix = '<a href="#bronto_support-head">below</a>.';
45
+ if (!$onBronto) {
46
+ $registerUrl = Mage::getSingleton('adminhtml/url')
47
+ ->getUrl('*/system_config/edit', array('section' => 'bronto'));
48
+ $appendix = '<a href="' . $registerUrl . '">here</a>.';
49
+ }
50
+ $this->_addSingleSessionMessage(
51
+ 'warning',
52
+ 'Please register your Bronto extension ' . $appendix
53
+ );
54
+ return false;
55
+ }
56
+ return true;
57
  }
58
 
59
  /**
60
  * @return int
61
  */
62
+ public function getLastRunTimestamp()
63
+ {
64
  if (is_null($this->_lastRun)) {
65
+ $lastRun = $this->getAdminScopedConfig(self::XML_PATH_LAST_RUN);
66
  $this->_lastRun = $lastRun ? $lastRun : 0;
67
  }
68
 
73
  * Set the registration value for this extension
74
  *
75
  * @param boolean $register
76
+ *
77
  * @return Mage_Core_Helper_Data
78
  */
79
+ public function setRegistered($register = true)
80
+ {
81
  $config = Mage::getModel('core/config');
82
  $config->saveConfig(self::XML_PATH_REGISTERED, $register ? '1' : '0', 'default', 0);
83
 
84
  // Force the register to pickup immediately
85
  Mage::getConfig()->reinit();
86
  Mage::app()->reinitStores();
87
+
88
  return $this;
89
  }
90
 
92
  * Set the last run time for this extension
93
  *
94
  * @param string $date
95
+ *
96
+ * @return $this
97
  */
98
+ public function setLastRunDate($date)
99
+ {
100
  $this->_lastRun = Mage::getModel('core/date')->timestamp($date);
101
 
102
  $config = Mage::getModel('core/config');
110
  *
111
  * @return array
112
  */
113
+ public function getSupportInformation()
114
+ {
115
  $data = array();
116
  foreach ($this->_supportFormFields as $key) {
117
  switch ($key) {
118
+ case 'extension_version':
119
+ $value = 'v' . $this->getModuleVersion();
120
+ break;
121
+ case 'magento_version':
122
+ $value = 'v' . Mage::getVersion();
123
+ break;
124
+ case 'magento_edition':
125
+ $value = $this->getEdition();
126
+ break;
127
+ default:
128
+ $value = $this->getAdminScopedConfig(self::XML_PATH_SUPPORT . "/$key");
129
  }
130
  $data[$key] = $value ? $value : '';
131
  }
132
+
133
  return $data;
134
  }
135
 
137
  * Determines if this last run is a day old
138
  *
139
  * @param string $currentDate
140
+ *
141
  * @return boolean
142
  */
143
+ public function isLastRunDifferent($currentDate)
144
+ {
145
  $lastRun = $this->getLastRunTimestamp();
146
+
147
  return $lastRun != Mage::getModel('core/date')->timestamp($currentDate);
148
  }
149
 
151
  * Gets the number of the reminder rules
152
  *
153
  * @param string $currentDate
154
+ *
155
  * @return int
156
  */
157
+ public function getActiveReminderRules($currentDate)
158
+ {
159
  return Mage::getModel('bronto_reminder/rule')
160
  ->getCollection()
161
  ->addDateFilter($currentDate)
168
  *
169
  * @return array
170
  */
171
+ public function getDebugInformation()
172
+ {
173
+ $currentDate = Mage::getModel('core/date')->date('Y-m-d');
174
  $brontoModules = $this->getEnabledBrontoModules();
175
+ $formData = $this->getSupportInformation();
176
+ $request = Mage::app()->getRequest();
177
 
178
  return array_merge(
179
+ // Form submission
180
  $formData,
181
  // Current Websites / Stores; Enabled Bronto Modules
182
  array(
183
  // Client / Server information
184
+ 'server_name' => $request->getServer('SERVER_NAME'),
185
+ 'server_address' => $request->getServer('SERVER_ADDR'),
186
+ 'server_protocol' => $request->getServer('SERVER_PROTOCOL'),
187
+ 'php_version' => 'v' . phpversion(),
188
+ 'mysql_version' => 'v' . Mage::getResourceModel('core/config')->getReadConnection()->getServerVersion(),
189
  'number_active_rules' => $this->getActiveReminderRules($currentDate),
190
  ),
191
  array(
192
  // Installed Modules
193
+ 'installed_modules' => $this->getInstalledModules(),
194
  'magento_installation' => $this->getStoreInfo(),
195
  ),
196
  array(
197
  'bronto_modules' => $brontoModules,
198
+ 'bronto_config' => $this->getBrontoConfigs($brontoModules)
199
  )
200
  );
201
  }
204
  * Submits the Support form information
205
  *
206
  * @param array $formData (Optional)
207
+ *
208
  * @return boolean
209
  */
210
+ public function submitSupportForm($formData = array())
211
+ {
212
  $currentDate = Mage::getModel('core/date')->date('Y-m-d');
213
  $this->setLastRunDate($currentDate)->setRegistered();
214
 
215
  $formData['extension_version'] = 'v' . $this->getModuleVersion();
216
+ $formData['magento_version'] = 'v' . Mage::getVersion();
217
+ $formData['magento_edition'] = $this->getEdition();
218
 
219
+ $yesNo = Mage::getModel('adminhtml/system_config_source_yesno');
220
  $selectedValue = $formData['using_solution_partner'];
221
  foreach ($yesNo->toOptionArray() as $option) {
222
  if ($option['value'] == $selectedValue) {
236
  *
237
  * @return array
238
  */
239
+ public function getEnabledBrontoModules()
240
+ {
241
  $brontoModules = array();
242
 
243
  $modules = Mage::getConfig()->getNode('modules')->children();
261
  * Gets the Bronto configuration settings
262
  *
263
  * @param array $brontoModules
264
+ *
265
  * @return array
266
  */
267
+ public function getBrontoConfigs($brontoModules)
268
+ {
269
+ $configs = array();
270
  $processedConfigs = array();
271
 
272
  foreach ($brontoModules as $name => $module) {
273
  $helperName = strtolower($name);
274
 
275
+ $helper = Mage::helper($helperName);
276
  $reflector = new ReflectionClass(get_class($helper));
277
 
278
  $moduleConfig = array();
282
  }
283
 
284
  $settingNameParts = explode('/', $setting);
285
+ $settingName = end($settingNameParts);
286
 
287
  $value = Mage::getStoreConfig($setting);
288
  if (empty($settingName)) {
310
  *
311
  * @return array
312
  */
313
+ public function getStoreInfo()
314
+ {
315
+ $storeInfo = array();
316
+ $websites = Mage::app()->getWebsites();
317
  $totalWebsites = count($websites);
318
+ $totalStores = 0;
319
  foreach ($websites as $website) {
320
  $websiteStores = count($website->getStores());
321
  $totalStores += $websiteStores;
322
+ $s = $websiteStores == 1 ? '' : 's';
323
  $storeInfo[] = "A website with $websiteStores store$s.";
324
  }
325
  $websites = $totalWebsites == 1 ? 'website' : 'websites';
326
+ $stores = $totalStores == 1 ? 'store' : 'stores';
327
 
328
  $storeInfo[] = "Total of $totalWebsites $websites and $totalStores $stores";
329
 
335
  *
336
  * @return Bronto_Common_Model_Archive
337
  */
338
+ public function getLogArchive()
339
+ {
340
+ $logDir = Mage::getBaseDir('var') . DS . 'log';
341
+ $systemLog = $logDir . DS . 'system.log';
342
  $exceptionLog = $logDir . DS . 'exception.log';
343
 
344
  $brontoLogDir = $logDir . DS . 'bronto';
345
+ $tmpDir = $this->getArchiveDirectory();
346
+ $file = $tmpDir . DS . 'log.' . time() . '.zip';
347
 
348
  $archive = Mage::getModel('bronto_common/archive');
349
  if ($archive->open($file, ZipArchive::OVERWRITE)) {
350
+ $now = time();
351
  $threshold = $now - (60 * 60 * 24 * 30);
352
 
353
  $archive->addEmptyDir('log');
380
  /**
381
  * Tails a given log for output
382
  *
383
+ * @param $logfile
384
+ *
385
  * @return string
386
  */
387
+ protected function _tailLog($logfile)
388
+ {
389
+ $length = filesize($logfile);
390
  $maxRead = (1 * 1000 * 100);
391
+ $fh = fopen($logfile, 'r');
392
  if ($length > $maxRead) {
393
  fseek($fh, $length - $maxRead);
394
  }
395
  $contents = fread($fh, $maxRead);
396
  fclose($fh);
397
+
398
  return $contents;
399
  }
400
 
404
  *
405
  * @return string
406
  */
407
+ public function getPhpInfoOutput()
408
+ {
409
  ob_start();
410
  phpinfo();
411
+
412
  return ob_get_clean();
413
  }
414
 
417
  *
418
  * @return string
419
  */
420
+ public function getArchiveDirectory()
421
+ {
422
  $brontoLogDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
423
+ $tmpDir = $brontoLogDir . DS . 'archives';
424
  if (!file_exists($tmpDir)) {
425
  mkdir($tmpDir, 0777, true);
426
  }
427
+
428
  return $brontoLogDir . DS . 'archives';
429
  }
430
 
431
  /**
432
  * Deletes all of the archive logs
433
  */
434
+ public function clearArchiveDirectory()
435
+ {
436
  foreach (glob($this->getArchiveDirectory() . DS . '*') as $file) {
437
  unlink($file);
438
  }
442
  * Sets the internal webform submission client
443
  *
444
  * @param Mage_HTTP_Client_Curl $client
445
+ *
446
  * @return Bronto_Common_Helper_Support
447
  */
448
+ public function setHttpClient(Mage_HTTP_Client_Curl $client)
449
+ {
450
  $this->_client = $client;
451
+
452
  return $this;
453
  }
454
 
457
  *
458
  * @return Mage_HTTP_Client_Curl
459
  */
460
+ protected function _getHttpClient()
461
+ {
462
  if (empty($this->_client)) {
463
  $this->_client = new Mage_HTTP_Client_Curl();
464
  }
465
+
466
  return $this->_client;
467
  }
468
 
469
  /**
470
+ * Submits a webform with the registration info
471
  *
472
  * @param array $formData
473
+ *
474
  * @return bool
475
  */
476
+ protected function _submitWebform(array $formData)
477
+ {
478
 
479
  $client = $this->_getHttpClient();
480
  $params = array();
481
  foreach ($this->_supportFormFields as $name) {
482
+ $parts = explode('_', $name);
483
  $restCamel = array_map('ucfirst', array_slice($parts, 1));
484
+ $camel = implode('', array_merge(array($parts[0]), $restCamel));
485
 
486
  $params[$camel] = $formData[$name];
487
  }
491
  try {
492
  $client->setOptions(array(
493
  CURLOPT_SSL_VERIFYPEER => 0,
494
+ CURLOPT_POSTFIELDS => $json
495
  ));
496
  $client->post($this->_registrationUrl, $json);
497
  } catch (Exception $e) {
498
  $this->writeError('Registration submission failed: ', $e->getMessage());
499
+
500
  return false;
501
  }
502
 
app/code/community/Bronto/Common/Model/Api.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_Api extends Bronto_Api
8
  {
@@ -18,7 +18,7 @@ class Bronto_Common_Model_Api extends Bronto_Api
18
 
19
  /**
20
  * @param string $token
21
- * @param bool $debug
22
  *
23
  * @return Bronto_Common_Model_Api
24
  * @access public
@@ -27,12 +27,11 @@ class Bronto_Common_Model_Api extends Bronto_Api
27
  {
28
  $token = trim($token);
29
 
 
 
30
  if (!isset(self::$_instances[$token])) {
31
  Mage::helper('bronto_common')->writeDebug("Initiating API for token: {$token}");
32
- self::$_instances[$token] = new self($token, array(
33
- 'retry_limit' => 2,
34
- 'debug' => $debug,
35
- ));
36
  }
37
 
38
  return self::$_instances[$token];
@@ -43,8 +42,8 @@ class Bronto_Common_Model_Api extends Bronto_Api
43
 
44
  /**
45
  * @param string|Exception $exception
46
- * @param string $message
47
- * @param string $code
48
  *
49
  * @return void
50
  * @access public
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_Api extends Bronto_Api
8
  {
18
 
19
  /**
20
  * @param string $token
21
+ * @param bool $debug
22
  *
23
  * @return Bronto_Common_Model_Api
24
  * @access public
27
  {
28
  $token = trim($token);
29
 
30
+ $options = Mage::helper('bronto_common')->getSoapOptions();
31
+
32
  if (!isset(self::$_instances[$token])) {
33
  Mage::helper('bronto_common')->writeDebug("Initiating API for token: {$token}");
34
+ self::$_instances[$token] = new self($token, $options);
 
 
 
35
  }
36
 
37
  return self::$_instances[$token];
42
 
43
  /**
44
  * @param string|Exception $exception
45
+ * @param string $message
46
+ * @param string $code
47
  *
48
  * @return void
49
  * @access public
app/code/community/Bronto/Common/Model/Archive.php CHANGED
@@ -1,73 +1,86 @@
1
  <?php
2
 
3
- class Bronto_Common_Model_Archive {
 
4
 
5
- /**
6
- * @var string
7
- */
8
- protected $_filename;
9
 
10
- /**
11
- * @var ZipArchive
12
- */
13
- protected $_zip;
14
 
15
- /**
16
- * @var boolean
17
- */
18
- protected $_isOpen = false;
19
 
20
- /**
21
- * Get the archive filename
22
- *
23
- * @return string
24
- */
25
- public function getFilename() {
26
- return $this->_filename;
27
- }
 
28
 
29
- /**
30
- * Sets the underlying zip
31
- *
32
- * @param ZipArchive $zip
33
- * @return Bronto_Common_Model_Archive
34
- */
35
- public function setZip(ZipArchive $zip) {
36
- if ($this->_isOpen) {
37
- throw new InvalidArgumentException("Archiver is already open.");
38
- }
39
- $this->_zip = $zip;
40
- return $this;
41
- }
 
42
 
43
- /**
44
- * @return ZipArchive
45
- */
46
- public function getZip() {
47
- if (is_null($this->_zip)) {
48
- $this->setZip(new ZipArchive);
49
- }
50
- return $this->_zip;
51
- }
52
 
 
 
 
 
 
 
 
 
53
 
54
- /**
55
- * Forwards calls to proxy object
56
- * @param string $name
57
- * @param array $args
58
- * @return mixed
59
- */
60
- public function __call($name, $args) {
61
- $return = call_user_func_array(array($this->getZip(), $name), $args);
62
- switch ($name) {
63
- case 'close':
64
- $this->_isOpen = false;
65
- break;
66
- case 'open':
67
- $this->_filename = $this->getZip()->filename;
68
- $this->_isOpen = $return === true;
69
- default:
70
- return $return;
71
- }
72
- }
 
 
 
 
 
 
 
 
 
73
  }
1
  <?php
2
 
3
+ class Bronto_Common_Model_Archive
4
+ {
5
 
6
+ /**
7
+ * @var string
8
+ */
9
+ protected $_filename;
10
 
11
+ /**
12
+ * @var ZipArchive
13
+ */
14
+ protected $_zip;
15
 
16
+ /**
17
+ * @var boolean
18
+ */
19
+ protected $_isOpen = false;
20
 
21
+ /**
22
+ * Get the archive filename
23
+ *
24
+ * @return string
25
+ */
26
+ public function getFilename()
27
+ {
28
+ return $this->_filename;
29
+ }
30
 
31
+ /**
32
+ * Sets the underlying zip
33
+ *
34
+ * @param ZipArchive $zip
35
+ *
36
+ * @return $this
37
+ * @throws InvalidArgumentException
38
+ */
39
+ public function setZip(ZipArchive $zip)
40
+ {
41
+ if ($this->_isOpen) {
42
+ throw new InvalidArgumentException("Archiver is already open.");
43
+ }
44
+ $this->_zip = $zip;
45
 
46
+ return $this;
47
+ }
 
 
 
 
 
 
 
48
 
49
+ /**
50
+ * @return ZipArchive
51
+ */
52
+ public function getZip()
53
+ {
54
+ if (is_null($this->_zip)) {
55
+ $this->setZip(new ZipArchive);
56
+ }
57
 
58
+ return $this->_zip;
59
+ }
60
+
61
+
62
+ /**
63
+ * Forwards calls to proxy object
64
+ *
65
+ * @param string $name
66
+ * @param array $args
67
+ *
68
+ * @return mixed
69
+ */
70
+ public function __call($name, $args)
71
+ {
72
+ $return = call_user_func_array(array($this->getZip(), $name), $args);
73
+ switch ($name) {
74
+ case 'close':
75
+ $this->_isOpen = false;
76
+ break;
77
+ case 'open':
78
+ $this->_filename = $this->getZip()->filename;
79
+ $this->_isOpen = $return === true;
80
+ default:
81
+ return $return;
82
+ }
83
+
84
+ return $return;
85
+ }
86
  }
app/code/community/Bronto/Common/Model/Email/Template.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto/Common
5
- * @copyright (c) 2011-2012, Bronto Software, Inc.
6
- * @version 1.6.8
7
  */
8
  class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
9
  {
@@ -52,13 +51,16 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
52
  return false;
53
  }
54
  }
 
55
  return $this->_message;
56
  }
57
 
58
  /**
59
- * Get filter object for template processing logi
 
 
60
  *
61
- * @return Mage_Core_Model_Email_Template_Filter
62
  */
63
  public function getTemplateFilter($storeId = null)
64
  {
@@ -69,6 +71,7 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
69
  if (empty($this->_templateFilter)) {
70
  $this->_templateFilter = Mage::getModel('bronto_common/email_template_filter');
71
  }
 
72
  return $this->_templateFilter;
73
  }
74
 
@@ -76,7 +79,7 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
76
  * Process email template code
77
  *
78
  * @param Bronto_Api_Delivery_Row $delivery
79
- * @param array $variables
80
  *
81
  * @return Bronto_Api_Delivery_Row
82
  */
@@ -110,16 +113,19 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
110
 
111
  if (!($message instanceOf Bronto_Api_Message_Row)) {
112
  Mage::helper($this->_helper)->writeError(' Invalid Message');
 
113
  return false;
114
  }
115
 
116
  if ($message->status != 'active') {
117
  Mage::helper($this->_helper)->writeError(' Message is not active: ' . $message->name);
 
118
  return false;
119
  }
120
 
121
  if (!($this->getSenderName() && $this->getSenderEmail())) {
122
- Mage::helper($this->_helper)->writeError(' Message cannot be sent');
 
123
  return false;
124
  }
125
 
@@ -129,14 +135,15 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
129
  /**
130
  * Send mail to recipient
131
  *
132
- * @param array|string $email E-mail(s)
133
  * @param array|string|null $name receiver name(s)
134
- * @param array $variables template variables
135
  *
136
  * @return boolean
137
  */
138
  public function send($email, $name = null, array $variables = array())
139
  {
 
140
  if (!Mage::helper($this->_helper)->canSendBronto($this, $variables['store']->getId())) {
141
  return parent::send($email, $name, $variables);
142
  }
@@ -145,17 +152,20 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
145
  $message = $this->getMessage();
146
  $messageId = $this->getBrontoMessageId();
147
 
 
148
  if (empty($messageId)) {
149
  return parent::send($email, $name, $variables);
150
  }
151
 
 
152
  if (!$this->isMessageValidForSend()) {
153
  return false;
154
  }
155
 
 
156
  $emails = array_values((array)$email);
157
- $names = is_array($name) ? $name : (array)$name;
158
- $names = array_values($names);
159
  foreach ($emails as $key => $email) {
160
  if (!isset($names[$key])) {
161
  $names[$key] = substr($email, 0, strpos($email, '@'));
@@ -163,7 +173,8 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
163
  }
164
 
165
  $variables['email'] = reset($emails);
166
- $variables['name'] = reset($names);
 
167
  // Load Bronto Contact(s)
168
  $contacts = array();
169
  foreach ($emails as $key => $email) {
@@ -171,11 +182,13 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
171
  $contacts[$key] = Mage::helper('bronto_common/contact')->getContactByEmail($email, $this->_helper, $variables['store']->getId(), 2);
172
  }
173
 
174
- $deliveryCount = 0;
175
  $deliveryErrors = 0;
 
176
  /* @var $contact Bronto_Api_Contact_Row */
177
- foreach ($contacts as $key => $contact) {
178
  try {
 
179
  if (!$contact->id || empty($contact->id)) {
180
  $contact = Mage::helper('bronto_common/contact')->saveContact($contact);
181
  if (!$contact->id || empty($contact->id)) {
@@ -187,33 +200,34 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
187
  }
188
  }
189
 
 
190
  $this->_beforeSend($contact, $message);
191
 
192
  /* @var $deliveryObject Bronto_Api_Delivery */
193
  Mage::helper($this->_helper)->writeDebug(' Getting Delivery Object...');
194
  $deliveryObject = Mage::helper($this->_helper)
195
- ->getApi(null, $variables['store']->getId())
196
  ->getDeliveryObject();
197
  $deliveryCount++;
198
  Mage::helper($this->_helper)->writeDebug(' Delivery Object Created Successfully');
199
 
200
  Mage::helper($this->_helper)->writeDebug(' Creating Delivery Row...');
201
  /* @var $delivery Bronto_Api_Delivery_Row */
202
- $delivery = $deliveryObject->createRow();
203
- $delivery->start = date('c');
204
  $delivery->messageId = $message->id;
205
- // TODO: Remove once reminder get send type support
206
  $delivery->type = $this->getTemplateSendType() ? $this->getTemplateSendType() : 'transactional';
207
  if (Mage::helper($this->_helper)->isTestModeEnabled()) {
208
  $delivery->type = 'test';
209
  }
210
- $delivery->fromEmail = $this->getSenderEmail();
211
- $delivery->fromName = $this->getSenderName();
212
  $delivery->replyEmail = $this->getSenderEmail();
213
  $delivery->recipients = array(
214
  array(
215
  'type' => 'contact',
216
- 'id' => $contact->id,
217
  ),
218
  );
219
  Mage::helper($this->_helper)->writeDebug(' Processing Delivery');
@@ -252,24 +266,32 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
252
  /**
253
  * Send transactional email to recipient
254
  *
255
- * @param int $templateId
256
- * @param string|array $sender Sender information, can be declared as part of config path
257
- * @param string $email Recipient email
258
- * @param string $name Recipient name
259
- * @param array $vars Variables which can be used in template
260
- * @param int|null $storeId
261
  *
262
  * @return Mage_Core_Model_Email_Template
263
  */
264
  public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
265
  {
 
 
 
 
 
 
266
  if (!Mage::helper($this->_helper)->canSendBronto($this, $storeId)) {
267
  return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
268
  } else {
269
  // If module enabled and template ID is not an instance of the api row, see if we can pull an instance
270
  if (!($templateId instanceOf Bronto_Api_Message_Row)) {
271
- $emailTemplate = Mage::getModel('bronto_email/template');
 
272
 
 
273
  if (is_numeric($templateId)) {
274
  $emailTemplate->load($templateId);
275
  } else {
@@ -287,7 +309,7 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
287
 
288
  // Load Bronto Message
289
  /* @var $messageObject Bronto_Api_Message */
290
- $messageObject = Mage::helper('bronto_common/message')->getApi(null, $store->getId(), $store->getWebsiteId())->getMessageObject();
291
 
292
  // Load Message
293
  try {
@@ -296,12 +318,13 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
296
  $message->id = $emailTemplate->getBrontoMessageId();
297
  $message->read();
298
  } catch (Exception $e) {
299
- Mage::helper($this->_helper)->writeDebug('Falling Back to Magento Sending: ' . $e);
 
300
  return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
301
  }
302
 
303
  // Send through main template model
304
- return $emailTemplate->sendTransactional(
305
  $message,
306
  $sender,
307
  $email,
@@ -309,11 +332,14 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
309
  $vars,
310
  $storeId
311
  );
 
 
312
  } else {
313
  $message = $templateId;
314
  }
315
  }
316
 
 
317
  $this->setSentSuccess(false);
318
  if (($storeId === null) && $this->getDesignConfig()->getStore()) {
319
  $storeId = $this->getDesignConfig()->getStore();
@@ -324,6 +350,7 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
324
  $this->setBrontoMessageName($message->name);
325
  $this->setBrontoMessageApproved(1);
326
 
 
327
  if (!is_array($sender)) {
328
  $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
329
  $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
@@ -332,10 +359,29 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
332
  $this->setSenderEmail($sender['email']);
333
  }
334
 
 
335
  if (!isset($vars['store'])) {
336
  $vars['store'] = Mage::app()->getStore($storeId);
337
  }
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  $this->setSentSuccess($this->send($email, $name, $vars));
340
 
341
  return $this;
@@ -349,6 +395,7 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
349
  public function setLastDeliveryId($deliveryId)
350
  {
351
  $this->_lastDeliveryId = $deliveryId;
 
352
  return $this;
353
  }
354
 
@@ -369,8 +416,8 @@ class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
369
  }
370
 
371
  /**
372
- * @param int $success
373
- * @param string $error
374
  * @param Bronto_Api_Delivery_Row $delivery
375
  */
376
  protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
1
  <?php
2
 
3
  /**
4
+ * @package Bronto/Common
5
+ * @copyright (c) 2011-2012, Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
8
  {
51
  return false;
52
  }
53
  }
54
+
55
  return $this->_message;
56
  }
57
 
58
  /**
59
+ * Get filter object for template processing logic
60
+ *
61
+ * @param null $storeId
62
  *
63
+ * @return false|Mage_Core_Model_Abstract|Mage_Core_Model_Email_Template_Filter
64
  */
65
  public function getTemplateFilter($storeId = null)
66
  {
71
  if (empty($this->_templateFilter)) {
72
  $this->_templateFilter = Mage::getModel('bronto_common/email_template_filter');
73
  }
74
+
75
  return $this->_templateFilter;
76
  }
77
 
79
  * Process email template code
80
  *
81
  * @param Bronto_Api_Delivery_Row $delivery
82
+ * @param array $variables
83
  *
84
  * @return Bronto_Api_Delivery_Row
85
  */
113
 
114
  if (!($message instanceOf Bronto_Api_Message_Row)) {
115
  Mage::helper($this->_helper)->writeError(' Invalid Message');
116
+
117
  return false;
118
  }
119
 
120
  if ($message->status != 'active') {
121
  Mage::helper($this->_helper)->writeError(' Message is not active: ' . $message->name);
122
+
123
  return false;
124
  }
125
 
126
  if (!($this->getSenderName() && $this->getSenderEmail())) {
127
+ Mage::helper($this->_helper)->writeError(' Message cannot be sent: Sender Name or Email is not set');
128
+
129
  return false;
130
  }
131
 
135
  /**
136
  * Send mail to recipient
137
  *
138
+ * @param array|string $email E-mail(s)
139
  * @param array|string|null $name receiver name(s)
140
+ * @param array $variables template variables
141
  *
142
  * @return boolean
143
  */
144
  public function send($email, $name = null, array $variables = array())
145
  {
146
+ // If not set to go through Bronto, fall through to magento sending
147
  if (!Mage::helper($this->_helper)->canSendBronto($this, $variables['store']->getId())) {
148
  return parent::send($email, $name, $variables);
149
  }
152
  $message = $this->getMessage();
153
  $messageId = $this->getBrontoMessageId();
154
 
155
+ // If messageId is empty, send through Magento
156
  if (empty($messageId)) {
157
  return parent::send($email, $name, $variables);
158
  }
159
 
160
+ // If message is not valid for sending, return false
161
  if (!$this->isMessageValidForSend()) {
162
  return false;
163
  }
164
 
165
+ // Handle CC and BCC by simply adding as array
166
  $emails = array_values((array)$email);
167
+ $names = is_array($name) ? $name : (array)$name;
168
+ $names = array_values($names);
169
  foreach ($emails as $key => $email) {
170
  if (!isset($names[$key])) {
171
  $names[$key] = substr($email, 0, strpos($email, '@'));
173
  }
174
 
175
  $variables['email'] = reset($emails);
176
+ $variables['name'] = reset($names);
177
+
178
  // Load Bronto Contact(s)
179
  $contacts = array();
180
  foreach ($emails as $key => $email) {
182
  $contacts[$key] = Mage::helper('bronto_common/contact')->getContactByEmail($email, $this->_helper, $variables['store']->getId(), 2);
183
  }
184
 
185
+ $deliveryCount = 0;
186
  $deliveryErrors = 0;
187
+
188
  /* @var $contact Bronto_Api_Contact_Row */
189
+ foreach ($contacts as $contact) {
190
  try {
191
+ // If contact does not have id, create contact, if still no id, log it
192
  if (!$contact->id || empty($contact->id)) {
193
  $contact = Mage::helper('bronto_common/contact')->saveContact($contact);
194
  if (!$contact->id || empty($contact->id)) {
200
  }
201
  }
202
 
203
+ // Trigger _beforeSend action for logging
204
  $this->_beforeSend($contact, $message);
205
 
206
  /* @var $deliveryObject Bronto_Api_Delivery */
207
  Mage::helper($this->_helper)->writeDebug(' Getting Delivery Object...');
208
  $deliveryObject = Mage::helper($this->_helper)
209
+ ->getApi(null, 'store', $variables['store']->getId())
210
  ->getDeliveryObject();
211
  $deliveryCount++;
212
  Mage::helper($this->_helper)->writeDebug(' Delivery Object Created Successfully');
213
 
214
  Mage::helper($this->_helper)->writeDebug(' Creating Delivery Row...');
215
  /* @var $delivery Bronto_Api_Delivery_Row */
216
+ $delivery = $deliveryObject->createRow();
217
+ $delivery->start = Mage::getModel('core/date')->date('c');
218
  $delivery->messageId = $message->id;
219
+
220
  $delivery->type = $this->getTemplateSendType() ? $this->getTemplateSendType() : 'transactional';
221
  if (Mage::helper($this->_helper)->isTestModeEnabled()) {
222
  $delivery->type = 'test';
223
  }
224
+ $delivery->fromEmail = $this->getSenderEmail();
225
+ $delivery->fromName = $this->getSenderName();
226
  $delivery->replyEmail = $this->getSenderEmail();
227
  $delivery->recipients = array(
228
  array(
229
  'type' => 'contact',
230
+ 'id' => $contact->id,
231
  ),
232
  );
233
  Mage::helper($this->_helper)->writeDebug(' Processing Delivery');
266
  /**
267
  * Send transactional email to recipient
268
  *
269
+ * @param int $templateId
270
+ * @param string|array $sender Sender information, can be declared as part of config path
271
+ * @param string $email Recipient email
272
+ * @param string $name Recipient name
273
+ * @param array $vars Variables which can be used in template
274
+ * @param int|null $storeId
275
  *
276
  * @return Mage_Core_Model_Email_Template
277
  */
278
  public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
279
  {
280
+ // If Template ID is 'nosend', then simply return false
281
+ if ($templateId == 'nosend') {
282
+ return false;
283
+ }
284
+
285
+ // If not set to go through Bronto, fall through to magento sending
286
  if (!Mage::helper($this->_helper)->canSendBronto($this, $storeId)) {
287
  return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
288
  } else {
289
  // If module enabled and template ID is not an instance of the api row, see if we can pull an instance
290
  if (!($templateId instanceOf Bronto_Api_Message_Row)) {
291
+ $emailTemplate = Mage::getModel('bronto_email/template')
292
+ ->setDesignConfig($this->getDesignConfig()->getData());
293
 
294
+ // If $templateId is numeric, load template by ID, else is default and should send through Magento
295
  if (is_numeric($templateId)) {
296
  $emailTemplate->load($templateId);
297
  } else {
309
 
310
  // Load Bronto Message
311
  /* @var $messageObject Bronto_Api_Message */
312
+ $messageObject = Mage::helper('bronto_common/message')->getApi(null, 'store', $store->getId())->getMessageObject();
313
 
314
  // Load Message
315
  try {
318
  $message->id = $emailTemplate->getBrontoMessageId();
319
  $message->read();
320
  } catch (Exception $e) {
321
+ Mage::helper($this->_helper)->writeDebug('Falling Back to Magento Sending: Message Not Found.' /* . $e*/);
322
+
323
  return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
324
  }
325
 
326
  // Send through main template model
327
+ $emailTemplate->sendTransactional(
328
  $message,
329
  $sender,
330
  $email,
332
  $vars,
333
  $storeId
334
  );
335
+
336
+ return $this->setSentSuccess($emailTemplate->getSentSuccess());
337
  } else {
338
  $message = $templateId;
339
  }
340
  }
341
 
342
+ // Start the send process
343
  $this->setSentSuccess(false);
344
  if (($storeId === null) && $this->getDesignConfig()->getStore()) {
345
  $storeId = $this->getDesignConfig()->getStore();
350
  $this->setBrontoMessageName($message->name);
351
  $this->setBrontoMessageApproved(1);
352
 
353
+ // If $sender is not array, it is a reference to a config setting, otherwise it should have 'name' and 'email'
354
  if (!is_array($sender)) {
355
  $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
356
  $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
359
  $this->setSenderEmail($sender['email']);
360
  }
361
 
362
+ // If store is not set, set it
363
  if (!isset($vars['store'])) {
364
  $vars['store'] = Mage::app()->getStore($storeId);
365
  }
366
 
367
+ // Check for Sales Rules
368
+ if ($this->getSalesRule() && !isset($vars['coupon'])) {
369
+ try {
370
+ /** @var Mage_SalesRule_Model_Rule $rule */
371
+ $rule = Mage::getModel('salesrule/rule')->load($this->getSalesRule());
372
+
373
+ /** @var Mage_SalesRule_Model_Coupon $coupon */
374
+ $coupon = $rule->acquireCoupon();
375
+
376
+ if ($coupon) {
377
+ $vars['coupon'] = $coupon;
378
+ }
379
+ } catch (Exception $e) {
380
+ Mage::helper($this->_helper)->writeDebug(' Failed loading Sales Rule with ID: ' . $this->getSalesRule());
381
+ }
382
+ }
383
+
384
+ // Send
385
  $this->setSentSuccess($this->send($email, $name, $vars));
386
 
387
  return $this;
395
  public function setLastDeliveryId($deliveryId)
396
  {
397
  $this->_lastDeliveryId = $deliveryId;
398
+
399
  return $this;
400
  }
401
 
416
  }
417
 
418
  /**
419
+ * @param int $success
420
+ * @param string $error
421
  * @param Bronto_Api_Delivery_Row $delivery
422
  */
423
  protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
app/code/community/Bronto/Common/Model/Email/Template/Filter.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.6
7
  */
8
  class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Template_Filter
9
  {
@@ -79,8 +78,10 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
79
  $this->_processedAvailable = array();
80
 
81
  foreach ($this->_available as $available) {
82
-
83
  $variable = isset($available['value']) ? $available['value'] : null;
 
 
 
84
  if (preg_match('/^{{skin|store|layout|block/', $variable)) {
85
  continue;
86
  }
@@ -100,7 +101,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
100
  }
101
  }
102
 
103
- $variable = implode('_', $parts);
104
  $this->_processedAvailable[] = $this->_camelize($variable);
105
 
106
  }
@@ -132,6 +133,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
132
 
133
  /**
134
  * @param Bronto_Api_Delivery_Row $delivery
 
135
  * @return Bronto_Api_Delivery_Row
136
  */
137
  public function filter($delivery)
@@ -141,7 +143,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
141
  }
142
 
143
  $this->_filteredObjects = array();
144
- $this->_delivery = $delivery;
145
 
146
  $this->_processAvailable();
147
  $this->_processQueryParams();
@@ -179,6 +181,11 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
179
  }
180
  }
181
 
 
 
 
 
 
182
  // Store
183
  if ($value instanceOf Mage_Core_Model_Store) {
184
  $this->_filterStore($value);
@@ -245,8 +252,26 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
245
  return $this->_delivery;
246
  }
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  /**
249
  * @param Mage_Core_Model_Store $store
 
250
  * @return Bronto_Common_Model_Email_Template_Filter
251
  */
252
  protected function _filterStore(Mage_Core_Model_Store $store)
@@ -279,6 +304,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
279
 
280
  /**
281
  * @param Mage_Admin_Model_User $user
 
282
  * @return Bronto_Common_Model_Email_Template_Filter
283
  */
284
  protected function _filterAdmin(Mage_Admin_Model_User $user)
@@ -299,6 +325,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
299
 
300
  /**
301
  * @param Mage_Newsletter_Model_Subscriber $subscriber
 
302
  * @return Bronto_Common_Model_Email_Template_Filter
303
  */
304
  protected function _filterSubscriber(Mage_Newsletter_Model_Subscriber $subscriber)
@@ -315,12 +342,22 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
315
 
316
  /**
317
  * @param Mage_Customer_Model_Customer $customer
 
318
  * @return Bronto_Common_Model_Email_Template_Filter
319
  */
320
  protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
321
  {
322
  if (!in_array('customer', $this->_filteredObjects)) {
323
- $this->setField('customerName', $customer->getName());
 
 
 
 
 
 
 
 
 
324
  $this->setField('customerEmail', $customer->getEmail());
325
  $this->setField('customerPassword', $customer->getPassword());
326
  if ($store = $customer->getStore()) {
@@ -343,6 +380,8 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
343
 
344
  /**
345
  * @param Mage_Sales_Model_Order $order
 
 
346
  * @return Bronto_Common_Model_Email_Template_Filter
347
  */
348
  protected function _filterOrder(Mage_Sales_Model_Order $order, $type = 'order')
@@ -350,11 +389,19 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
350
  if (!in_array('order', $this->_filteredObjects)) {
351
  $this->setStoreId($order->getStoreId());
352
 
 
 
 
 
 
 
 
 
353
  // Order may not be a shippable order
354
- $shipAddress = 'N/A';
355
  $shipDescription = 'N/A';
356
  if ($order->getIsNotVirtual()) {
357
- $shipAddress = $order->getShippingAddress()->format('html');
358
  $shipDescription = $order->getShippingDescription();
359
  }
360
 
@@ -370,6 +417,12 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
370
  $this->setField('orderStatusLabel', $order->getStatusLabel());
371
  $this->setField('orderItems', $this->_filterOrderItems($order));
372
 
 
 
 
 
 
 
373
  $this->_filteredObjects[] = 'order';
374
  }
375
 
@@ -383,16 +436,27 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
383
  $this->setField('billingName', $address->getName());
384
  $this->_filteredObjects[] = 'address';
385
  }
 
386
  return $this;
387
  }
388
 
389
  /**
390
  * @param Mage_Sales_Model_Order_Invoice $invoice
 
391
  * @return Bronto_Common_Model_Email_Template_Filter
392
  */
393
  protected function _filterInvoice(Mage_Sales_Model_Order_Invoice $invoice)
394
  {
395
  if (!in_array('invoice', $this->_filteredObjects)) {
 
 
 
 
 
 
 
 
 
396
  $this->setField('invoiceIncrementId', $invoice->getIncrementId());
397
  $this->setField('invoiceItems', $this->_filterInvoiceItems($invoice));
398
 
@@ -404,11 +468,22 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
404
 
405
  /**
406
  * @param Mage_Sales_Model_Order_Shipment $shipment
 
407
  * @return Bronto_Common_Model_Email_Template_Filter
408
  */
409
  protected function _filterShipment(Mage_Sales_Model_Order_Shipment $shipment)
410
  {
 
411
  if (!in_array('shipment', $this->_filteredObjects)) {
 
 
 
 
 
 
 
 
 
412
  $this->setField('shipmentIncrementId', $shipment->getIncrementId());
413
  $this->setField('shipmentCreatedAt', Mage::helper('core')->formatDate($shipment->getCreatedAtStoreDate(), 'long', true)); // TODO: needed?
414
  $this->setField('shipmentItems', $this->_filterShipmentItems($shipment));
@@ -422,22 +497,34 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
422
 
423
  /**
424
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
 
425
  * @return Bronto_Common_Model_Email_Template_Filter
426
  */
427
  protected function _filterCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
428
  {
429
  if (!in_array('creditmemo', $this->_filteredObjects)) {
 
 
 
 
 
 
 
 
 
430
  $this->setField('creditmemoIncrementId', $creditmemo->getIncrementId());
431
  $this->setField('creditmemoCreatedAt', Mage::helper('core')->formatDate($creditmemo->getCreatedAtStoreDate(), 'long', true)); // TODO: needed?
432
  $this->setField('creditmemoItems', $this->_filterCreditmemoItems($creditmemo));
433
 
434
  $this->_filteredObjects[] = 'creditmemo';
435
  }
 
436
  return $this;
437
  }
438
 
439
  /**
440
- * @param Mage_Sales_Model_Quote $order
 
441
  * @return Bronto_Common_Model_Email_Template_Filter
442
  */
443
  protected function _filterQuote(Mage_Sales_Model_Quote $quote)
@@ -446,8 +533,14 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
446
  $this->setStoreId($quote->getStoreId());
447
  $currencyCode = $quote->getQuoteCurrencyCode();
448
 
449
- $this->setField('subtotal', $this->formatPrice($quote->getSubtotal(), $currencyCode));
450
- $this->setField('grandTotal', $this->formatPrice($quote->getGrandTotal(), $currencyCode));
 
 
 
 
 
 
451
 
452
  $index = 1;
453
  foreach ($quote->getAllItems() as $item/* @var $item Mage_Sales_Model_Quote_Item */) {
@@ -457,7 +550,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
457
  }
458
  }
459
 
460
- $queryParams = $this->getQueryParams();
461
  $queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
462
  if ($store = $this->getStore()) {
463
  $this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
@@ -481,11 +574,14 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
481
 
482
  $this->_filteredObjects[] = 'quote';
483
  }
 
484
  return $this;
485
  }
486
 
487
  /**
488
  * @param Mage_Sales_Model_Quote_Item $item
 
 
489
  * @return Bronto_Common_Model_Email_Template_Filter
490
  */
491
  protected function _filterQuoteItem($item, $index = null)
@@ -494,10 +590,17 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
494
  return $this;
495
  }
496
 
 
 
 
 
 
 
 
 
 
497
  $this->setField("productName_{$index}", $item->getName());
498
  $this->setField("productSku_{$index}", $item->getSku());
499
- $this->setField("productPrice_{$index}", $this->formatPrice($item->getConvertedPrice()));
500
- $this->setField("productTotal_{$index}", $this->formatPrice($item->calcRowTotal()->getRowTotal()));
501
  $this->setField("productQty_{$index}", $item->getQty());
502
  $this->setField("productUrl_{$index}", $this->_getQuoteItemUrl($item));
503
 
@@ -513,6 +616,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
513
 
514
  /**
515
  * @param Mage_Wishlist_Model_Wishlist $wishlist
 
516
  * @return Bronto_Common_Model_Email_Template_Filter
517
  */
518
  protected function _filterWishlist(Mage_Wishlist_Model_Wishlist $wishlist)
@@ -526,7 +630,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
526
  }
527
  }
528
 
529
- $queryParams = $this->getQueryParams();
530
  $queryParams['wishlist_id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($wishlist->getId())));
531
  if ($store = $this->getStore()) {
532
  $this->setField('wishlistURL', $store->getUrl('reminder/load/index', $queryParams));
@@ -550,11 +654,14 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
550
 
551
  $this->_filteredObjects[] = 'wishlist';
552
  }
 
553
  return $this;
554
  }
555
 
556
  /**
557
  * @param Mage_Wishlist_Model_Item $item
 
 
558
  * @return Bronto_Common_Model_Email_Template_Filter
559
  */
560
  protected function _filterWishlistItem(Mage_Wishlist_Model_Item $item, $index = null)
@@ -583,6 +690,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
583
 
584
  /**
585
  * @param Mage_Sales_Model_Order $order
 
586
  * @return String containing HTML for order items
587
  */
588
  protected function _filterOrderItems(Mage_Sales_Model_Order $order)
@@ -608,13 +716,71 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
608
  return $items->toHtml();
609
  }
610
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  /**
612
  * @param Mage_Sales_Model_Order_Invoice $invoice
 
613
  * @return String containing HTML for invoice items
614
  */
615
  protected function _filterInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
616
  {
617
- $order = $invoice->getOrder();
618
  $layout = Mage::getSingleton('core/layout');
619
 
620
  /* @var $items Mage_Sales_Block_Items_Abstract */
@@ -637,13 +803,71 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
637
  return $items->toHtml();
638
  }
639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  /**
641
  * @param Mage_Sales_Model_Order_Shipment $shipment
 
642
  * @return String containing HTML for shipment items and tracking numbers
643
  */
644
  protected function _filterShipmentItems(Mage_Sales_Model_Order_Shipment $shipment)
645
  {
646
- $order = $shipment->getOrder();
647
  $layout = Mage::getSingleton('core/layout');
648
 
649
  /* @var $items Mage_Sales_Block_Items_Abstract */
@@ -667,12 +891,12 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
667
  * Get the shipment tracking info.
668
  *
669
  * @param Mage_Sales_Model_Order_Shipment $shipment
670
- * @param Mage_Sales_Model_Order $order
671
  */
672
  protected function _getShipmentTrackingNumber(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order)
673
  {
674
  $layout = Mage::getSingleton('core/layout');
675
- $block = $layout->createBlock('core/template')->setTemplate('email/order/shipment/track.phtml');
676
  $block->setOrder($order);
677
  $block->setShipment($shipment);
678
  $block->setArea('frontend');
@@ -682,11 +906,12 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
682
 
683
  /**
684
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
 
685
  * @return String containing HTML for credit memo items
686
  */
687
  protected function _filterCreditmemoItems(Mage_Sales_Model_Order_Creditmemo $creditmemo)
688
  {
689
- $order = $creditmemo->getOrder();
690
  $layout = Mage::getSingleton('core/layout');
691
 
692
  /* @var $items Mage_Sales_Block_Items_Abstract */
@@ -714,8 +939,9 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
714
  *
715
  * @param Mage_Core_Model_Layout $layout
716
  * @param Mage_Sales_Model_Order $order
717
- * @param String $totals_block_type
718
- * @param String $totals_block_name
 
719
  * @return Mage_Core_Block_Template
720
  */
721
  protected function _getTotalsBlock($layout, $order, $totals_block_type, $totals_block_name)
@@ -737,7 +963,8 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
737
 
738
  /**
739
  * @param Mage_Catalog_Model_Product $product
740
- * @param int $index
 
741
  * @return Bronto_Common_Model_Email_Template_Filter
742
  */
743
  protected function _filterProduct(Mage_Catalog_Model_Product $product, $index = null)
@@ -764,6 +991,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
764
 
765
  /**
766
  * @param Mage_Sales_Model_Quote_Item $item
 
767
  * @return string
768
  */
769
  protected function _getQuoteItemUrl(Mage_Sales_Model_Quote_Item $item)
@@ -777,6 +1005,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
777
 
778
  /**
779
  * @param Mage_Wishlist_Model_Item $item
 
780
  * @return string
781
  */
782
  protected function _getWishlistItemUrl(Mage_Wishlist_Model_Item $item)
@@ -789,8 +1018,36 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
789
  }
790
 
791
  /**
792
- * @param string $key
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
793
  * @param string|array $value
 
 
794
  * @return Bronto_Common_Model_Email_Template_Filter
795
  */
796
  public function setField($key, $value, $type = 'html')
@@ -833,11 +1090,13 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
833
  * Setter
834
  *
835
  * @param integer $storeId
 
836
  * @return Bronto_Common_Model_Email_Template_Filter
837
  */
838
  public function setStoreId($storeId)
839
  {
840
  $this->_storeId = $storeId;
 
841
  return $this;
842
  }
843
 
@@ -852,17 +1111,20 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
852
  if (null === $this->_storeId) {
853
  $this->_storeId = Mage::app()->getStore()->getId();
854
  }
 
855
  return $this->_storeId;
856
  }
857
 
858
  /**
859
  * @param Mage_Core_Model_Store $store
 
860
  * @return Bronto_Common_Model_Email_Template_Filter
861
  */
862
  public function setStore(Mage_Core_Model_Store $store)
863
  {
864
  $this->_store = $store;
865
  $this->setStoreId($store->getId());
 
866
  return $this;
867
  }
868
 
@@ -879,16 +1141,19 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
879
  } else if (is_null($this->_store)) {
880
  $this->_store = Mage::app()->getStore();
881
  }
 
882
  return $this->_store;
883
  }
884
 
885
  /**
886
  * @param string $messageId
 
887
  * @return Bronto_Common_Model_Email_Template_Filter
888
  */
889
  public function setMessageId($messageId)
890
  {
891
  $this->_messageId = $messageId;
 
892
  return $this;
893
  }
894
 
@@ -902,6 +1167,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
902
 
903
  /**
904
  * @param array $variables
 
905
  * @return Bronto_Common_Model_Email_Template_Filter
906
  */
907
  public function setVariables(array $variables)
@@ -909,11 +1175,13 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
909
  foreach ($variables as $name => $value) {
910
  $this->_variables[$name] = $value;
911
  }
 
912
  return $this;
913
  }
914
 
915
  /**
916
  * @param array $variables
 
917
  * @return Bronto_Common_Model_Email_Template_Filter
918
  */
919
  public function setAvailable($variables = array())
@@ -924,23 +1192,27 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
924
  foreach ($variables as $name => $value) {
925
  $this->_available[$name] = $value;
926
  }
 
927
  return $this;
928
  }
929
 
930
  /**
931
- * Converts field names for setters and geters
932
  *
933
  * @param string $name
 
934
  * @return string
935
  */
936
  protected function _underscore($name)
937
  {
938
  $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
 
939
  return $result;
940
  }
941
 
942
  /**
943
  * @param string $name
 
944
  * @return string
945
  */
946
  protected function _camelize($name)
@@ -952,6 +1224,7 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
952
  * For PHP < 5.3
953
  *
954
  * @param string $string
 
955
  * @return string
956
  */
957
  protected function _lcfirst($string)
@@ -963,24 +1236,26 @@ class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Te
963
  $string{0} = strtolower($string{0});
964
  }
965
  }
 
966
  return $string;
967
  }
968
 
969
  /**
970
  * Convenience method for formatting currency values
971
  *
972
- * @param float $price
973
- * @param string $currency (Optional)
 
974
  * @return string
975
  */
976
  protected function formatPrice($price, $currencyCode = null)
977
  {
978
  $options = array(
979
  'precision' => 2,
980
- 'display' => Zend_Currency::NO_SYMBOL,
981
  );
982
 
983
- if (Mage::helper('bronto_common')->useCurrenySymbol($this->getStore()->getId())) {
984
  unset($options['display']);
985
  }
986
 
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Template_Filter
8
  {
78
  $this->_processedAvailable = array();
79
 
80
  foreach ($this->_available as $available) {
 
81
  $variable = isset($available['value']) ? $available['value'] : null;
82
+ if (preg_match('/^{{layout handle="[a-zA-Z_]*_order_items"/', $variable)) {
83
+ continue;
84
+ }
85
  if (preg_match('/^{{skin|store|layout|block/', $variable)) {
86
  continue;
87
  }
101
  }
102
  }
103
 
104
+ $variable = implode('_', $parts);
105
  $this->_processedAvailable[] = $this->_camelize($variable);
106
 
107
  }
133
 
134
  /**
135
  * @param Bronto_Api_Delivery_Row $delivery
136
+ *
137
  * @return Bronto_Api_Delivery_Row
138
  */
139
  public function filter($delivery)
143
  }
144
 
145
  $this->_filteredObjects = array();
146
+ $this->_delivery = $delivery;
147
 
148
  $this->_processAvailable();
149
  $this->_processQueryParams();
181
  }
182
  }
183
 
184
+ // Coupon
185
+ if ($value instanceof Mage_SalesRule_Model_Coupon) {
186
+ $this->_filterCoupon($value);
187
+ }
188
+
189
  // Store
190
  if ($value instanceOf Mage_Core_Model_Store) {
191
  $this->_filterStore($value);
252
  return $this->_delivery;
253
  }
254
 
255
+ /**
256
+ * Add Coupon Code to Email
257
+ *
258
+ * @param Mage_SalesRule_Model_Coupon $coupon
259
+ *
260
+ * @return $this
261
+ */
262
+ protected function _filterCoupon(Mage_SalesRule_Model_Coupon $coupon)
263
+ {
264
+ if (!in_array('coupon', $this->_filteredObjects)) {
265
+ $this->setField('couponCode', $coupon->getCode());
266
+ $this->_filteredObjects[] = 'coupon';
267
+ }
268
+
269
+ return $this;
270
+ }
271
+
272
  /**
273
  * @param Mage_Core_Model_Store $store
274
+ *
275
  * @return Bronto_Common_Model_Email_Template_Filter
276
  */
277
  protected function _filterStore(Mage_Core_Model_Store $store)
304
 
305
  /**
306
  * @param Mage_Admin_Model_User $user
307
+ *
308
  * @return Bronto_Common_Model_Email_Template_Filter
309
  */
310
  protected function _filterAdmin(Mage_Admin_Model_User $user)
325
 
326
  /**
327
  * @param Mage_Newsletter_Model_Subscriber $subscriber
328
+ *
329
  * @return Bronto_Common_Model_Email_Template_Filter
330
  */
331
  protected function _filterSubscriber(Mage_Newsletter_Model_Subscriber $subscriber)
342
 
343
  /**
344
  * @param Mage_Customer_Model_Customer $customer
345
+ *
346
  * @return Bronto_Common_Model_Email_Template_Filter
347
  */
348
  protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
349
  {
350
  if (!in_array('customer', $this->_filteredObjects)) {
351
+ // Handle Defaults from settings
352
+ $customerName = (trim($customer->getName()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('full', 'store', $this->getStoreId()) : $customer->getName();
353
+ $customerPrefix = (trim($customer->getPrefix()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('prefix', 'store', $this->getStoreId()) : $customer->getPrefix();
354
+ $customerFirstName = (trim($customer->getFirstname()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('firstname', 'store', $this->getStoreId()) : $customer->getFirstname();
355
+ $customerLastName = (trim($customer->getLastname()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('lastname', 'store', $this->getStoreId()) : $customer->getLastname();
356
+
357
+ $this->setField('customerName', $customerName);
358
+ $this->setField('firstName', $customerFirstName);
359
+ $this->setField('prefix', $customerPrefix);
360
+ $this->setField('lastName', $customerLastName);
361
  $this->setField('customerEmail', $customer->getEmail());
362
  $this->setField('customerPassword', $customer->getPassword());
363
  if ($store = $customer->getStore()) {
380
 
381
  /**
382
  * @param Mage_Sales_Model_Order $order
383
+ * @param string $type
384
+ *
385
  * @return Bronto_Common_Model_Email_Template_Filter
386
  */
387
  protected function _filterOrder(Mage_Sales_Model_Order $order, $type = 'order')
389
  if (!in_array('order', $this->_filteredObjects)) {
390
  $this->setStoreId($order->getStoreId());
391
 
392
+ $index = 1;
393
+ foreach ($order->getAllItems() as $item/* @var $item Mage_Sales_Model_Order_Item */) {
394
+ if (!$item->getParentItem()) {
395
+ $this->_filterOrderItem($item, $index);
396
+ $index++;
397
+ }
398
+ }
399
+
400
  // Order may not be a shippable order
401
+ $shipAddress = 'N/A';
402
  $shipDescription = 'N/A';
403
  if ($order->getIsNotVirtual()) {
404
+ $shipAddress = $order->getShippingAddress()->format('html');
405
  $shipDescription = $order->getShippingDescription();
406
  }
407
 
417
  $this->setField('orderStatusLabel', $order->getStatusLabel());
418
  $this->setField('orderItems', $this->_filterOrderItems($order));
419
 
420
+ // When emailing from the admin, we need to ensure that we're using templates from the frontend
421
+ Mage::getDesign()->setArea('frontend');
422
+
423
+ $totals = $this->_getTotalsBlock(Mage::getSingleton('core/layout'), $order, 'sales/order_totals', 'order_totals');
424
+ $this->setField('orderTotals', $totals->toHtml());
425
+
426
  $this->_filteredObjects[] = 'order';
427
  }
428
 
436
  $this->setField('billingName', $address->getName());
437
  $this->_filteredObjects[] = 'address';
438
  }
439
+
440
  return $this;
441
  }
442
 
443
  /**
444
  * @param Mage_Sales_Model_Order_Invoice $invoice
445
+ *
446
  * @return Bronto_Common_Model_Email_Template_Filter
447
  */
448
  protected function _filterInvoice(Mage_Sales_Model_Order_Invoice $invoice)
449
  {
450
  if (!in_array('invoice', $this->_filteredObjects)) {
451
+ $index = 1;
452
+ foreach ($invoice->getAllItems() as $item/* @var $item Mage_Sales_Model_Order_Invoice_Item */) {
453
+ $_item = $item->getOrderItem();
454
+ if (!$_item->getParentItem()) {
455
+ $this->_filterOrderItem($_item, $index);
456
+ $index++;
457
+ }
458
+ }
459
+
460
  $this->setField('invoiceIncrementId', $invoice->getIncrementId());
461
  $this->setField('invoiceItems', $this->_filterInvoiceItems($invoice));
462
 
468
 
469
  /**
470
  * @param Mage_Sales_Model_Order_Shipment $shipment
471
+ *
472
  * @return Bronto_Common_Model_Email_Template_Filter
473
  */
474
  protected function _filterShipment(Mage_Sales_Model_Order_Shipment $shipment)
475
  {
476
+ $this->setStoreId($shipment->getOrder()->getStoreId());
477
  if (!in_array('shipment', $this->_filteredObjects)) {
478
+ $index = 1;
479
+ foreach ($shipment->getAllItems() as $item/* @var $item Mage_Sales_Model_Order_Shipment_Item */) {
480
+ $_item = $item->getOrderItem();
481
+ if (!$_item->getParentItem()) {
482
+ $this->_filterOrderItem($_item, $index);
483
+ $index++;
484
+ }
485
+ }
486
+
487
  $this->setField('shipmentIncrementId', $shipment->getIncrementId());
488
  $this->setField('shipmentCreatedAt', Mage::helper('core')->formatDate($shipment->getCreatedAtStoreDate(), 'long', true)); // TODO: needed?
489
  $this->setField('shipmentItems', $this->_filterShipmentItems($shipment));
497
 
498
  /**
499
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
500
+ *
501
  * @return Bronto_Common_Model_Email_Template_Filter
502
  */
503
  protected function _filterCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
504
  {
505
  if (!in_array('creditmemo', $this->_filteredObjects)) {
506
+ $index = 1;
507
+ foreach ($creditmemo->getAllItems() as $item/* @var $item Mage_Sales_Model_Order_Creditmemo_Item */) {
508
+ $_item = $item->getOrderItem();
509
+ if (!$_item->getParentItem()) {
510
+ $this->_filterOrderItem($_item, $index);
511
+ $index++;
512
+ }
513
+ }
514
+
515
  $this->setField('creditmemoIncrementId', $creditmemo->getIncrementId());
516
  $this->setField('creditmemoCreatedAt', Mage::helper('core')->formatDate($creditmemo->getCreatedAtStoreDate(), 'long', true)); // TODO: needed?
517
  $this->setField('creditmemoItems', $this->_filterCreditmemoItems($creditmemo));
518
 
519
  $this->_filteredObjects[] = 'creditmemo';
520
  }
521
+
522
  return $this;
523
  }
524
 
525
  /**
526
+ * @param Mage_Sales_Model_Quote $quote
527
+ *
528
  * @return Bronto_Common_Model_Email_Template_Filter
529
  */
530
  protected function _filterQuote(Mage_Sales_Model_Quote $quote)
533
  $this->setStoreId($quote->getStoreId());
534
  $currencyCode = $quote->getQuoteCurrencyCode();
535
 
536
+ if (Mage::helper('bronto_common')->displayPriceIncTax($quote->getStoreId())) {
537
+ $totals = $quote->getTotals();
538
+ $this->setField('subtotal', $this->formatPrice($totals['subtotal']->getValue(), $currencyCode));
539
+ $this->setField('grandTotal', $this->formatPrice($totals['grand_total']->getValue(), $currencyCode));
540
+ } else {
541
+ $this->setField('subtotal', $this->formatPrice($quote->getSubtotal(), $currencyCode));
542
+ $this->setField('grandTotal', $this->formatPrice($quote->getGrandTotal(), $currencyCode));
543
+ }
544
 
545
  $index = 1;
546
  foreach ($quote->getAllItems() as $item/* @var $item Mage_Sales_Model_Quote_Item */) {
550
  }
551
  }
552
 
553
+ $queryParams = $this->getQueryParams();
554
  $queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
555
  if ($store = $this->getStore()) {
556
  $this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
574
 
575
  $this->_filteredObjects[] = 'quote';
576
  }
577
+
578
  return $this;
579
  }
580
 
581
  /**
582
  * @param Mage_Sales_Model_Quote_Item $item
583
+ * @param int $index
584
+ *
585
  * @return Bronto_Common_Model_Email_Template_Filter
586
  */
587
  protected function _filterQuoteItem($item, $index = null)
590
  return $this;
591
  }
592
 
593
+ if (Mage::helper('bronto_common')->displayPriceIncTax($item->getStore())) {
594
+ $checkout = Mage::helper('checkout');
595
+ $this->setField("productPrice_{$index}", $this->formatPrice($checkout->getPriceInclTax($item)));
596
+ $this->setField("productTotal_{$index}", $this->formatPrice($checkout->getSubtotalInclTax($item)));
597
+ } else {
598
+ $this->setField("productPrice_{$index}", $this->formatPrice($item->getConvertedPrice()));
599
+ $this->setField("productTotal_{$index}", $this->formatPrice($item->calcRowTotal()->getRowTotal()));
600
+ }
601
+
602
  $this->setField("productName_{$index}", $item->getName());
603
  $this->setField("productSku_{$index}", $item->getSku());
 
 
604
  $this->setField("productQty_{$index}", $item->getQty());
605
  $this->setField("productUrl_{$index}", $this->_getQuoteItemUrl($item));
606
 
616
 
617
  /**
618
  * @param Mage_Wishlist_Model_Wishlist $wishlist
619
+ *
620
  * @return Bronto_Common_Model_Email_Template_Filter
621
  */
622
  protected function _filterWishlist(Mage_Wishlist_Model_Wishlist $wishlist)
630
  }
631
  }
632
 
633
+ $queryParams = $this->getQueryParams();
634
  $queryParams['wishlist_id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($wishlist->getId())));
635
  if ($store = $this->getStore()) {
636
  $this->setField('wishlistURL', $store->getUrl('reminder/load/index', $queryParams));
654
 
655
  $this->_filteredObjects[] = 'wishlist';
656
  }
657
+
658
  return $this;
659
  }
660
 
661
  /**
662
  * @param Mage_Wishlist_Model_Item $item
663
+ * @param int $index
664
+ *
665
  * @return Bronto_Common_Model_Email_Template_Filter
666
  */
667
  protected function _filterWishlistItem(Mage_Wishlist_Model_Item $item, $index = null)
690
 
691
  /**
692
  * @param Mage_Sales_Model_Order $order
693
+ *
694
  * @return String containing HTML for order items
695
  */
696
  protected function _filterOrderItems(Mage_Sales_Model_Order $order)
716
  return $items->toHtml();
717
  }
718
 
719
+ /**
720
+ * @param Mage_Sales_Model_Order_Item $item
721
+ * @param int $index
722
+ *
723
+ * @return Bronto_Common_Model_Email_Template_Filter
724
+ */
725
+ protected function _filterOrderItem($item, $index = null)
726
+ {
727
+ if ($item->getParentItem()) {
728
+ return $this;
729
+ }
730
+
731
+ // Product Price Excluding Tax
732
+ if (Mage::helper('tax')->displaySalesPriceExclTax($this->getStore()) || Mage::helper('tax')->displaySalesBothPrices($this->getStore())) {
733
+ if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'email', $this->getStore())) {
734
+ $this->setField("productPriceExclTax_{$index}", $this->formatPrice($item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition()));
735
+ } else {
736
+ $this->setField("productPriceExclTax_{$index}", $this->formatPrice($item->getRowTotal()));
737
+ }
738
+ }
739
+
740
+ // Product Price Including Tax
741
+ if (Mage::helper('tax')->displaySalesPriceInclTax($this->getStore()) || Mage::helper('tax')->displaySalesBothPrices($this->getStore())) {
742
+ $_incl = Mage::helper('checkout')->getSubtotalInclTax($item);
743
+ if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'email', $this->getStore())) {
744
+ $this->setField("productPriceInclTax_{$index}", $this->formatPrice($_incl + $item->getWeeeTaxAppliedRowAmount()));
745
+ } else {
746
+ $this->setField("productPriceInclTax_{$index}", $this->formatPrice($_incl - $item->getWeeeTaxRowDisposition()));
747
+ }
748
+ }
749
+
750
+ // Set Product Detail Fields
751
+ $this->setField("productName_{$index}", $item->getName());
752
+ $this->setField("productSku_{$index}", $item->getSku());
753
+ $this->setField("productPrice_{$index}", $this->formatPrice($item->getConvertedPrice()));
754
+ $this->setField("productTotal_{$index}", $this->formatPrice($item->getRowTotal()));
755
+ $this->setField("productQty_{$index}", $item->getQtyOrdered() * 1);
756
+ $this->setField("productUrl_{$index}", $this->_getOrderItemUrl($item));
757
+ $this->setField("productDescription_{$index}", $item->getDescription());
758
+
759
+ // Handle Gift Message Details
760
+ if ($item->getGiftMessageId() && $_giftMessage = Mage::helper('giftmessage/message')->getGiftMessage($item->getGiftMessageId())) {
761
+ $this->setField("giftMessage_{$index}", $_giftMessage->getMessage());
762
+ $this->setField("giftMessageFrom_{$index}", $_giftMessage->getSender());
763
+ $this->setField("giftMessageTo_{$index}", $_giftMessage->getRecipient());
764
+ }
765
+
766
+ /* @var $product Mage_Catalog_Model_Product */
767
+ $product = $item->getProduct();
768
+ if (!$product) {
769
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
770
+ }
771
+ $this->_filterProduct($product, $index);
772
+
773
+ return $this;
774
+ }
775
+
776
  /**
777
  * @param Mage_Sales_Model_Order_Invoice $invoice
778
+ *
779
  * @return String containing HTML for invoice items
780
  */
781
  protected function _filterInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
782
  {
783
+ $order = $invoice->getOrder();
784
  $layout = Mage::getSingleton('core/layout');
785
 
786
  /* @var $items Mage_Sales_Block_Items_Abstract */
803
  return $items->toHtml();
804
  }
805
 
806
+ /**
807
+ * @param Mage_Sales_Model_Order_Item $item
808
+ * @param int $index
809
+ *
810
+ * @return Bronto_Common_Model_Email_Template_Filter
811
+ */
812
+ protected function _filterInvoiceItem($item, $index = null)
813
+ {
814
+ if ($item->getParentItem()) {
815
+ return $this;
816
+ }
817
+
818
+ // Product Price Excluding Tax
819
+ if (Mage::helper('tax')->displaySalesPriceExclTax($this->getStore()) || Mage::helper('tax')->displaySalesBothPrices($this->getStore())) {
820
+ if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'email', $this->getStore())) {
821
+ $this->setField("productPriceExclTax_{$index}", $this->formatPrice($item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition()));
822
+ } else {
823
+ $this->setField("productPriceExclTax_{$index}", $this->formatPrice($item->getRowTotal()));
824
+ }
825
+ }
826
+
827
+ // Product Price Including Tax
828
+ if (Mage::helper('tax')->displaySalesPriceInclTax($this->getStore()) || Mage::helper('tax')->displaySalesBothPrices($this->getStore())) {
829
+ $_incl = Mage::helper('checkout')->getSubtotalInclTax($item);
830
+ if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'email', $this->getStore())) {
831
+ $this->setField("productPriceInclTax_{$index}", $this->formatPrice($_incl + $item->getWeeeTaxAppliedRowAmount()));
832
+ } else {
833
+ $this->setField("productPriceInclTax_{$index}", $this->formatPrice($_incl - $item->getWeeeTaxRowDisposition()));
834
+ }
835
+ }
836
+
837
+ // Set Product Detail Fields
838
+ $this->setField("productName_{$index}", $item->getName());
839
+ $this->setField("productSku_{$index}", $item->getSku());
840
+ $this->setField("productPrice_{$index}", $this->formatPrice($item->getConvertedPrice()));
841
+ $this->setField("productTotal_{$index}", $this->formatPrice($item->getRowTotal()));
842
+ $this->setField("productQty_{$index}", $item->getQtyOrdered() * 1);
843
+ $this->setField("productUrl_{$index}", $this->_getOrderItemUrl($item));
844
+ $this->setField("productDescription_{$index}", $item->getDescription());
845
+
846
+ // Handle Gift Message Details
847
+ if ($item->getGiftMessageId() && $_giftMessage = Mage::helper('giftmessage/message')->getGiftMessage($item->getGiftMessageId())) {
848
+ $this->setField("giftMessage_{$index}", $_giftMessage->getMessage());
849
+ $this->setField("giftMessageFrom_{$index}", $_giftMessage->getSender());
850
+ $this->setField("giftMessageTo_{$index}", $_giftMessage->getRecipient());
851
+ }
852
+
853
+ /* @var $product Mage_Catalog_Model_Product */
854
+ $product = $item->getProduct();
855
+ if (!$product) {
856
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
857
+ }
858
+ $this->_filterProduct($product, $index);
859
+
860
+ return $this;
861
+ }
862
+
863
  /**
864
  * @param Mage_Sales_Model_Order_Shipment $shipment
865
+ *
866
  * @return String containing HTML for shipment items and tracking numbers
867
  */
868
  protected function _filterShipmentItems(Mage_Sales_Model_Order_Shipment $shipment)
869
  {
870
+ $order = $shipment->getOrder();
871
  $layout = Mage::getSingleton('core/layout');
872
 
873
  /* @var $items Mage_Sales_Block_Items_Abstract */
891
  * Get the shipment tracking info.
892
  *
893
  * @param Mage_Sales_Model_Order_Shipment $shipment
894
+ * @param Mage_Sales_Model_Order $order
895
  */
896
  protected function _getShipmentTrackingNumber(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order)
897
  {
898
  $layout = Mage::getSingleton('core/layout');
899
+ $block = $layout->createBlock('core/template')->setTemplate('email/order/shipment/track.phtml');
900
  $block->setOrder($order);
901
  $block->setShipment($shipment);
902
  $block->setArea('frontend');
906
 
907
  /**
908
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
909
+ *
910
  * @return String containing HTML for credit memo items
911
  */
912
  protected function _filterCreditmemoItems(Mage_Sales_Model_Order_Creditmemo $creditmemo)
913
  {
914
+ $order = $creditmemo->getOrder();
915
  $layout = Mage::getSingleton('core/layout');
916
 
917
  /* @var $items Mage_Sales_Block_Items_Abstract */
939
  *
940
  * @param Mage_Core_Model_Layout $layout
941
  * @param Mage_Sales_Model_Order $order
942
+ * @param String $totals_block_type
943
+ * @param String $totals_block_name
944
+ *
945
  * @return Mage_Core_Block_Template
946
  */
947
  protected function _getTotalsBlock($layout, $order, $totals_block_type, $totals_block_name)
963
 
964
  /**
965
  * @param Mage_Catalog_Model_Product $product
966
+ * @param int $index
967
+ *
968
  * @return Bronto_Common_Model_Email_Template_Filter
969
  */
970
  protected function _filterProduct(Mage_Catalog_Model_Product $product, $index = null)
991
 
992
  /**
993
  * @param Mage_Sales_Model_Quote_Item $item
994
+ *
995
  * @return string
996
  */
997
  protected function _getQuoteItemUrl(Mage_Sales_Model_Quote_Item $item)
1005
 
1006
  /**
1007
  * @param Mage_Wishlist_Model_Item $item
1008
+ *
1009
  * @return string
1010
  */
1011
  protected function _getWishlistItemUrl(Mage_Wishlist_Model_Item $item)
1018
  }
1019
 
1020
  /**
1021
+ * @param Mage_Sales_Model_Order_Item $item
1022
+ *
1023
+ * @return string
1024
+ */
1025
+ protected function _getOrderItemUrl(Mage_Sales_Model_Order_Item $item)
1026
+ {
1027
+ if ($item->getRedirectUrl()) {
1028
+ return $item->getRedirectUrl();
1029
+ }
1030
+
1031
+ if ($item->getProduct()) {
1032
+ return $item->getProduct()->getProductUrl();
1033
+ }
1034
+
1035
+ $product = Mage::getModel('catalog/product')
1036
+ ->setStoreId($this->getStoreId())
1037
+ ->load($item->getProductId());
1038
+
1039
+ if ($product->getId()) {
1040
+ return $product->getProductUrl();
1041
+ }
1042
+
1043
+ return '';
1044
+ }
1045
+
1046
+ /**
1047
+ * @param string $key
1048
  * @param string|array $value
1049
+ * @param string $type
1050
+ *
1051
  * @return Bronto_Common_Model_Email_Template_Filter
1052
  */
1053
  public function setField($key, $value, $type = 'html')
1090
  * Setter
1091
  *
1092
  * @param integer $storeId
1093
+ *
1094
  * @return Bronto_Common_Model_Email_Template_Filter
1095
  */
1096
  public function setStoreId($storeId)
1097
  {
1098
  $this->_storeId = $storeId;
1099
+
1100
  return $this;
1101
  }
1102
 
1111
  if (null === $this->_storeId) {
1112
  $this->_storeId = Mage::app()->getStore()->getId();
1113
  }
1114
+
1115
  return $this->_storeId;
1116
  }
1117
 
1118
  /**
1119
  * @param Mage_Core_Model_Store $store
1120
+ *
1121
  * @return Bronto_Common_Model_Email_Template_Filter
1122
  */
1123
  public function setStore(Mage_Core_Model_Store $store)
1124
  {
1125
  $this->_store = $store;
1126
  $this->setStoreId($store->getId());
1127
+
1128
  return $this;
1129
  }
1130
 
1141
  } else if (is_null($this->_store)) {
1142
  $this->_store = Mage::app()->getStore();
1143
  }
1144
+
1145
  return $this->_store;
1146
  }
1147
 
1148
  /**
1149
  * @param string $messageId
1150
+ *
1151
  * @return Bronto_Common_Model_Email_Template_Filter
1152
  */
1153
  public function setMessageId($messageId)
1154
  {
1155
  $this->_messageId = $messageId;
1156
+
1157
  return $this;
1158
  }
1159
 
1167
 
1168
  /**
1169
  * @param array $variables
1170
+ *
1171
  * @return Bronto_Common_Model_Email_Template_Filter
1172
  */
1173
  public function setVariables(array $variables)
1175
  foreach ($variables as $name => $value) {
1176
  $this->_variables[$name] = $value;
1177
  }
1178
+
1179
  return $this;
1180
  }
1181
 
1182
  /**
1183
  * @param array $variables
1184
+ *
1185
  * @return Bronto_Common_Model_Email_Template_Filter
1186
  */
1187
  public function setAvailable($variables = array())
1192
  foreach ($variables as $name => $value) {
1193
  $this->_available[$name] = $value;
1194
  }
1195
+
1196
  return $this;
1197
  }
1198
 
1199
  /**
1200
+ * Converts field names for setters and getters
1201
  *
1202
  * @param string $name
1203
+ *
1204
  * @return string
1205
  */
1206
  protected function _underscore($name)
1207
  {
1208
  $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
1209
+
1210
  return $result;
1211
  }
1212
 
1213
  /**
1214
  * @param string $name
1215
+ *
1216
  * @return string
1217
  */
1218
  protected function _camelize($name)
1224
  * For PHP < 5.3
1225
  *
1226
  * @param string $string
1227
+ *
1228
  * @return string
1229
  */
1230
  protected function _lcfirst($string)
1236
  $string{0} = strtolower($string{0});
1237
  }
1238
  }
1239
+
1240
  return $string;
1241
  }
1242
 
1243
  /**
1244
  * Convenience method for formatting currency values
1245
  *
1246
+ * @param float $price
1247
+ * @param string $currencyCode (Optional)
1248
+ *
1249
  * @return string
1250
  */
1251
  protected function formatPrice($price, $currencyCode = null)
1252
  {
1253
  $options = array(
1254
  'precision' => 2,
1255
+ 'display' => Zend_Currency::NO_SYMBOL,
1256
  );
1257
 
1258
+ if (Mage::helper('bronto_common')->useCurrencySymbol($this->getStore()->getId())) {
1259
  unset($options['display']);
1260
  }
1261
 
app/code/community/Bronto/Common/Model/Email/Template/Templatefilter.php CHANGED
@@ -19,6 +19,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
19
  /**
20
  *
21
  * @param array $construction
 
22
  * @return string
23
  */
24
  public function layoutDirective($construction)
@@ -41,6 +42,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
41
  return '';
42
  break;
43
  }
 
44
  return $this->_addBrontoStyle($return);
45
  }
46
 
@@ -48,6 +50,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
48
  * Retrieve block parameters
49
  *
50
  * @param mixed $value
 
51
  * @return array
52
  */
53
  protected function _getBlockParameters($value)
@@ -63,6 +66,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
63
  * Support url and direct_url properties
64
  *
65
  * @param array $construction
 
66
  * @return string
67
  */
68
  public function storeDirective($construction)
@@ -104,16 +108,16 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
104
  * allowed_tags - Comma separated html tags that have not to be converted
105
  *
106
  * @param array $construction
 
107
  * @return string
108
  */
109
  public function htmlescapeDirective($construction)
110
  {
111
- $params = $this->_getIncludeParameters($construction[2]);
112
-
113
- if (strstr($construction[2], 'var') === FALSE) {
114
  return '';
115
  }
116
  $returnVariable = $this->processVariable(str_replace('var=$', '', $construction[2]));
 
117
  return $this->_addBrontoStyle($returnVariable);
118
  }
119
 
@@ -121,11 +125,13 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
121
  * Var directive with modifiers support
122
  *
123
  * @param array $construction
 
124
  * @return string
125
  */
126
  public function varDirective($construction)
127
  {
128
  $returnVariable = $this->processVariable($construction[2]);
 
129
  return $this->_addBrontoStyle($returnVariable);
130
  }
131
 
@@ -160,6 +166,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
160
  unset($parts[$i]);
161
  }
162
  }
 
163
  return implode('_', $parts);
164
  }
165
 
@@ -173,6 +180,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
173
  * also allow additional parameter "store"
174
  *
175
  * @param array $construction
 
176
  * @return string
177
  */
178
  public function protocolDirective($construction)
@@ -184,11 +192,11 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
184
  * Store config directive
185
  *
186
  * @param array $construction
 
187
  * @return string
188
  */
189
  public function configDirective($construction)
190
  {
191
- $configValue = '';
192
  $params = $this->_getIncludeParameters($construction[2]);
193
 
194
  switch ($params['path']) {
@@ -205,14 +213,16 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
205
  $returnValue = str_replace('/', '_', $params['path']);
206
  break;
207
  }
 
208
  return $this->_addBrontoStyle($returnValue);
209
  }
210
 
211
  /**
212
  * Filter the string as template.
213
- * Rewrited for logging exceptions
214
  *
215
  * @param string $value
 
216
  * @return string
217
  */
218
  public function filter($value)
@@ -223,6 +233,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
223
  $value = '';
224
  Mage::logException($e);
225
  }
 
226
  return $value;
227
  }
228
 
@@ -255,6 +266,7 @@ class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_
255
  $string{0} = strtolower($string{0});
256
  }
257
  }
 
258
  return $string;
259
  }
260
 
19
  /**
20
  *
21
  * @param array $construction
22
+ *
23
  * @return string
24
  */
25
  public function layoutDirective($construction)
42
  return '';
43
  break;
44
  }
45
+
46
  return $this->_addBrontoStyle($return);
47
  }
48
 
50
  * Retrieve block parameters
51
  *
52
  * @param mixed $value
53
+ *
54
  * @return array
55
  */
56
  protected function _getBlockParameters($value)
66
  * Support url and direct_url properties
67
  *
68
  * @param array $construction
69
+ *
70
  * @return string
71
  */
72
  public function storeDirective($construction)
108
  * allowed_tags - Comma separated html tags that have not to be converted
109
  *
110
  * @param array $construction
111
+ *
112
  * @return string
113
  */
114
  public function htmlescapeDirective($construction)
115
  {
116
+ if (strstr($construction[2], 'var') === false) {
 
 
117
  return '';
118
  }
119
  $returnVariable = $this->processVariable(str_replace('var=$', '', $construction[2]));
120
+
121
  return $this->_addBrontoStyle($returnVariable);
122
  }
123
 
125
  * Var directive with modifiers support
126
  *
127
  * @param array $construction
128
+ *
129
  * @return string
130
  */
131
  public function varDirective($construction)
132
  {
133
  $returnVariable = $this->processVariable($construction[2]);
134
+
135
  return $this->_addBrontoStyle($returnVariable);
136
  }
137
 
166
  unset($parts[$i]);
167
  }
168
  }
169
+
170
  return implode('_', $parts);
171
  }
172
 
180
  * also allow additional parameter "store"
181
  *
182
  * @param array $construction
183
+ *
184
  * @return string
185
  */
186
  public function protocolDirective($construction)
192
  * Store config directive
193
  *
194
  * @param array $construction
195
+ *
196
  * @return string
197
  */
198
  public function configDirective($construction)
199
  {
 
200
  $params = $this->_getIncludeParameters($construction[2]);
201
 
202
  switch ($params['path']) {
213
  $returnValue = str_replace('/', '_', $params['path']);
214
  break;
215
  }
216
+
217
  return $this->_addBrontoStyle($returnValue);
218
  }
219
 
220
  /**
221
  * Filter the string as template.
222
+ * Rewritten for logging exceptions
223
  *
224
  * @param string $value
225
+ *
226
  * @return string
227
  */
228
  public function filter($value)
233
  $value = '';
234
  Mage::logException($e);
235
  }
236
+
237
  return $value;
238
  }
239
 
266
  $string{0} = strtolower($string{0});
267
  }
268
  }
269
+
270
  return $string;
271
  }
272
 
app/code/community/Bronto/Common/Model/Keysentry.php CHANGED
@@ -1,12 +1,16 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Common
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Model_Keysentry extends Mage_Core_Model_Abstract
9
  {
 
 
 
 
 
10
  /**
11
  * Bronto customer module alias
12
  */
@@ -17,11 +21,6 @@ class Bronto_Common_Model_Keysentry extends Mage_Core_Model_Abstract
17
  */
18
  const EMAIL = 'bronto_email';
19
 
20
- /**
21
- * Bronto newsletter module alias
22
- */
23
- const NEWS = 'bronto_news';
24
-
25
  /**
26
  * Bronto newsletter module alias
27
  */
@@ -37,30 +36,54 @@ class Bronto_Common_Model_Keysentry extends Mage_Core_Model_Abstract
37
  */
38
  const REMINDER = 'bronto_reminder';
39
 
 
 
 
 
 
40
  /**
41
  * Disable all the defined modules for the scope
42
  *
43
- * @param mixed $scope Site scope
44
- * @param integer $scopeId Site scope id
 
 
45
  */
46
- public function disableModules($scope, $scopeId)
47
  {
48
- Mage::helper(self::CUSTOMER)->disableModule($scope, $scopeId);
49
- Mage::helper(self::EMAIL)->disableModule($scope, $scopeId);
50
- Mage::helper(self::NEWS)->disableModule($scope, $scopeId);
51
- Mage::helper(self::NEWSLETTER)->disableModule($scope, $scopeId);
52
- Mage::helper(self::ORDER)->disableModule($scope, $scopeId);
53
- Mage::helper(self::REMINDER)->disableModule($scope, $scopeId);
 
 
 
 
54
 
55
  Mage::getConfig()->reinit();
56
  Mage::app()->reinitStores();
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  /**
60
  * Remove Bronto Message Connection for Template
61
  *
62
  * @param Varien_Data_Collection_Db $collection
63
- * @param $scopeId Store ID
 
64
  */
65
  public function unlinkEmails(Varien_Data_Collection_Db $collection, $scope, $scopeId)
66
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Common
5
+ * @copyright (c) 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_Keysentry extends Mage_Core_Model_Abstract
8
  {
9
+ /**
10
+ * Bronto Common module alias
11
+ */
12
+ const COMMON = 'bronto_common';
13
+
14
  /**
15
  * Bronto customer module alias
16
  */
21
  */
22
  const EMAIL = 'bronto_email';
23
 
 
 
 
 
 
24
  /**
25
  * Bronto newsletter module alias
26
  */
36
  */
37
  const REMINDER = 'bronto_reminder';
38
 
39
+ /**
40
+ * Bronto reviews module alias
41
+ */
42
+ const REVIEWS = 'bronto_reviews';
43
+
44
  /**
45
  * Disable all the defined modules for the scope
46
  *
47
+ * @param mixed $scope Site scope
48
+ * @param integer $scopeId Site scope id
49
+ * @param boolean $includeCommon switch to disable bronto_common module
50
+ * @param boolean $deleteChildren if true will delete config values for child scopes
51
  */
52
+ public function disableModules($scope, $scopeId, $includeCommon = false, $deleteChildren = false)
53
  {
54
+ if ($includeCommon) {
55
+ Mage::helper(self::COMMON)->disableModule($scope, $scopeId, $deleteChildren);
56
+ }
57
+
58
+ Mage::helper(self::CUSTOMER)->disableModule($scope, $scopeId, $deleteChildren);
59
+ Mage::helper(self::EMAIL)->disableModule($scope, $scopeId, $deleteChildren);
60
+ Mage::helper(self::NEWSLETTER)->disableModule($scope, $scopeId, $deleteChildren);
61
+ Mage::helper(self::ORDER)->disableModule($scope, $scopeId, $deleteChildren);
62
+ Mage::helper(self::REMINDER)->disableModule($scope, $scopeId, $deleteChildren);
63
+ Mage::helper(self::REVIEWS)->disableModule($scope, $scopeId, $deleteChildren);
64
 
65
  Mage::getConfig()->reinit();
66
  Mage::app()->reinitStores();
67
+
68
+ // Get Child Items
69
+ if ('website' == $scope) {
70
+ $website = Mage::app()->getWebsite($scopeId);
71
+ foreach ($website->getStoreIds() as $storeId) {
72
+ $this->disableModules('store', $storeId, $includeCommon, true);
73
+ }
74
+ } elseif ('default' == $scope) {
75
+ foreach (Mage::app()->getWebsites(false) as $website) {
76
+ $this->disableModules('website', $website->getId(), $includeCommon, true);
77
+ }
78
+ }
79
  }
80
 
81
  /**
82
  * Remove Bronto Message Connection for Template
83
  *
84
  * @param Varien_Data_Collection_Db $collection
85
+ * @param string $scope
86
+ * @param string|int $scopeId
87
  */
88
  public function unlinkEmails(Varien_Data_Collection_Db $collection, $scope, $scopeId)
89
  {
app/code/community/Bronto/Common/Model/Observer.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_Observer
8
  {
@@ -10,22 +10,52 @@ class Bronto_Common_Model_Observer
10
  private $_validatedFields = array(
11
  'site_name' => 'Bronto Site Name',
12
  'firstname' => 'First Name',
13
- 'lastname' => 'Last Name',
14
- 'number' => 'Phone Number',
15
- 'email' => 'Email',
16
- 'title' => 'Job Title',
17
  );
18
 
19
  /**
20
  * Description for const
21
  */
22
- const NOTICE_IDENTIFER = 'bronto_common';
23
 
24
  const SUPPORT_IDENTIFIER = 'bronto_common/support';
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  /**
27
  * events: controller_action_predispatch
 
28
  * @param Varien_Event_Observer $observer
 
29
  * @return mixed
30
  */
31
  public function checkBrontoRequirements(Varien_Event_Observer $observer)
@@ -38,78 +68,63 @@ class Bronto_Common_Model_Observer
38
  $action->getRequest()->isAjax() ||
39
  $action->getRequest()->isPost()
40
  ) {
41
- return;
42
  }
43
 
44
- $helper = Mage::helper(self::NOTICE_IDENTIFER);
45
 
46
  // Verify Requirements
47
- if (!$helper->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
48
- return;
49
- }
50
-
51
- // Verify API tokens are valid
52
- if ($helper->isEnabled() && !$helper->validApiTokens(self::NOTICE_IDENTIFER)) {
53
  return false;
54
  }
55
 
56
  // Bug user about registration, only once
57
- if (!Mage::helper(self::SUPPORT_IDENTIFIER)->isRegistered()) {
58
- $appendix = '<a href="#bronto_support-head">below</a>.';
59
- if ($action->getRequest()->getParam('section') != 'bronto') {
60
- $registerUrl = Mage::getSingleton('adminhtml/url')
61
- ->getUrl('*/system_config/edit', array('section' => 'bronto'));
62
- $appendix = '<a href="' . $registerUrl . '">here</a>.';
63
- }
64
-
65
- $message = Mage::getSingleton('core/message')
66
- ->warning($helper->__('Please register your Bronto extension ' . $appendix));
67
- $message->setIdentifier(self::NOTICE_IDENTIFER);
68
- $session = Mage::getSingleton('adminhtml/session');
69
- foreach ($session->getMessages()->getItemsByType('warning') as $setMessage) {
70
- if ($setMessage->getIdentifier() == $message->getIdentifier()) {
71
- $exists = true;
72
- break;
73
- }
74
- }
75
 
76
- if (empty($exists)) {
77
- $session->addMessage($message);
78
- }
79
  }
 
 
80
  }
81
 
82
  /**
83
  * Cron to clear downloaded zips
84
  */
85
- public function clearArchives($cron) {
 
86
  Mage::helper(self::SUPPORT_IDENTIFIER)->clearArchiveDirectory();
87
  }
88
 
89
  /**
90
  * Validates that certain fields are not empty
91
  *
92
- * @param array $config
93
  * @param boolean $formatWeb (Optional)
 
94
  * @throws Mage_Exception
95
  */
96
- protected function _validateSupportForm($groups, $formatWeb = true) {
97
- $helper = Mage::helper(self::NOTICE_IDENTIFER);
 
98
 
99
  $errors = array();
100
  foreach ($this->_validatedFields as $field => $label) {
101
- if ($groups['support']['fields'][$field]['inherit']) {
 
102
  continue;
103
  }
104
 
105
- if (empty($groups['support']['fields'][$field]['value'])) {
106
  $errors[] = $helper->__("Please enter your $label.");
107
  }
108
  }
109
 
110
  if (!empty($groups['support']['fields']['using_solution_partner']['value'])) {
111
- if ($groups['support']['fields']['partner']['inherit']) {
112
- continue;
113
  }
114
 
115
  if (empty($groups['support']['fields']['partner']['value'])) {
@@ -127,10 +142,12 @@ class Bronto_Common_Model_Observer
127
  * events: model_config_data_save_before
128
  *
129
  * @param Varien_Event_Observer $observer
 
130
  * @return boolean
131
  */
132
- public function registerExtension(Varien_Event_Observer $observer) {
133
- $action = $observer->getEvent()->getControllerAction();
 
134
  $session = Mage::getSingleton('admin/session');
135
  $support = Mage::helper(self::SUPPORT_IDENTIFIER);
136
 
@@ -141,19 +158,30 @@ class Bronto_Common_Model_Observer
141
  $action->getRequest()->getParam('section') == 'bronto'
142
  ) {
143
 
144
- $groups = $action->getRequest()->getParam('groups');
 
 
 
 
 
 
 
145
  $apiToken = $groups['settings']['fields']['api_token']['value'];
146
 
147
  if (empty($apiToken)) {
148
  return false;
149
  }
150
 
 
 
 
 
151
  try {
152
  $this->_validateSupportForm($groups);
153
 
154
  $postFields = array();
155
  foreach ($groups['support']['fields'] as $field => $values) {
156
- if ($groups['support']['fields'][$field]['inherit']) {
157
  continue;
158
  }
159
  $postFields[$field] = $values['value'];
@@ -163,12 +191,12 @@ class Bronto_Common_Model_Observer
163
  } catch (Exception $e) {
164
  Mage::getSingleton('adminhtml/session')
165
  ->addMessage(
166
- Mage::getSingleton('core/message')
167
- ->error($e->getMessage())
168
- ->setIdentifier(self::NOTICE_IDENTIFER)
169
  );
170
 
171
- Mage::helper(self::NOTICE_IDENTIFER)->writeError($e->getMessage());
172
  }
173
  }
174
 
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_Observer
8
  {
10
  private $_validatedFields = array(
11
  'site_name' => 'Bronto Site Name',
12
  'firstname' => 'First Name',
13
+ 'lastname' => 'Last Name',
14
+ 'number' => 'Phone Number',
15
+ 'email' => 'Email',
16
+ 'title' => 'Job Title',
17
  );
18
 
19
  /**
20
  * Description for const
21
  */
22
+ const NOTICE_IDENTIFIER = 'bronto_common';
23
 
24
  const SUPPORT_IDENTIFIER = 'bronto_common/support';
25
 
26
+ /**
27
+ * Watches for the enable switch to change to disable
28
+ *
29
+ * event: bronto_disable
30
+ *
31
+ * @param Varien_Event_Observer $observer
32
+ */
33
+ public function watchDisableAction(Varien_Event_Observer $observer)
34
+ {
35
+ // Get Scope
36
+ $scopeParams = Mage::helper('bronto_common')->getScopeParams();
37
+ $scope = $scopeParams['scope'];
38
+ $scopeId = $scopeParams[$scopeParams['scope'] . '_id'];
39
+
40
+ // Get Sentry and Disable Modules
41
+ $sentry = Mage::getModel('bronto_common/keysentry');
42
+ $sentry->disableModules($scope, $scopeId, true);
43
+
44
+ // Unlink all Emails
45
+ if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, 9)) {
46
+ $sentry->unlinkEmails(
47
+ Mage::getModel('bronto_email/message')->getCollection(),
48
+ $scope,
49
+ $scopeId
50
+ );
51
+ }
52
+ }
53
+
54
  /**
55
  * events: controller_action_predispatch
56
+ *
57
  * @param Varien_Event_Observer $observer
58
+ *
59
  * @return mixed
60
  */
61
  public function checkBrontoRequirements(Varien_Event_Observer $observer)
68
  $action->getRequest()->isAjax() ||
69
  $action->getRequest()->isPost()
70
  ) {
71
+ return false;
72
  }
73
 
74
+ $helper = Mage::helper(self::NOTICE_IDENTIFIER);
75
 
76
  // Verify Requirements
77
+ if (!$helper->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
 
 
 
 
 
78
  return false;
79
  }
80
 
81
  // Bug user about registration, only once
82
+ $onBronto = $action->getRequest()->getParam('section') == 'bronto';
83
+ !Mage::helper(self::SUPPORT_IDENTIFIER)->verifyRegistration($onBronto);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
+ // Verify API tokens are valid
86
+ if ($helper->isEnabled() && !$helper->validApiStatus()) {
87
+ return false;
88
  }
89
+
90
+ return $this;
91
  }
92
 
93
  /**
94
  * Cron to clear downloaded zips
95
  */
96
+ public function clearArchives($cron)
97
+ {
98
  Mage::helper(self::SUPPORT_IDENTIFIER)->clearArchiveDirectory();
99
  }
100
 
101
  /**
102
  * Validates that certain fields are not empty
103
  *
104
+ * @param array $groups
105
  * @param boolean $formatWeb (Optional)
106
+ *
107
  * @throws Mage_Exception
108
  */
109
+ protected function _validateSupportForm($groups, $formatWeb = true)
110
+ {
111
+ $helper = Mage::helper(self::NOTICE_IDENTIFIER);
112
 
113
  $errors = array();
114
  foreach ($this->_validatedFields as $field => $label) {
115
+ $values = $groups['support']['fields'][$field];
116
+ if (array_key_exists('inherit', $values) && $values['inherit']) {
117
  continue;
118
  }
119
 
120
+ if (empty($values['value'])) {
121
  $errors[] = $helper->__("Please enter your $label.");
122
  }
123
  }
124
 
125
  if (!empty($groups['support']['fields']['using_solution_partner']['value'])) {
126
+ if (array_key_exists('inherit', $groups['support']['fields']['partner']) && $groups['support']['fields']['partner']['inherit']) {
127
+ return;
128
  }
129
 
130
  if (empty($groups['support']['fields']['partner']['value'])) {
142
  * events: model_config_data_save_before
143
  *
144
  * @param Varien_Event_Observer $observer
145
+ *
146
  * @return boolean
147
  */
148
+ public function registerExtension(Varien_Event_Observer $observer)
149
+ {
150
+ $action = $observer->getEvent()->getControllerAction();
151
  $session = Mage::getSingleton('admin/session');
152
  $support = Mage::helper(self::SUPPORT_IDENTIFIER);
153
 
158
  $action->getRequest()->getParam('section') == 'bronto'
159
  ) {
160
 
161
+ $groups = $action->getRequest()->getParam('groups');
162
+ $enabled = $groups['settings']['fields']['enabled']['value'];
163
+
164
+ // If Module is not enabled, don't proceed
165
+ if ($enabled == '0') {
166
+ return false;
167
+ }
168
+
169
  $apiToken = $groups['settings']['fields']['api_token']['value'];
170
 
171
  if (empty($apiToken)) {
172
  return false;
173
  }
174
 
175
+ if (empty($groups['support'])) {
176
+ return false;
177
+ }
178
+
179
  try {
180
  $this->_validateSupportForm($groups);
181
 
182
  $postFields = array();
183
  foreach ($groups['support']['fields'] as $field => $values) {
184
+ if (array_key_exists('inherit', $groups['support']['fields'][$field]) && $groups['support']['fields'][$field]['inherit']) {
185
  continue;
186
  }
187
  $postFields[$field] = $values['value'];
191
  } catch (Exception $e) {
192
  Mage::getSingleton('adminhtml/session')
193
  ->addMessage(
194
+ Mage::getSingleton('core/message')
195
+ ->error($e->getMessage())
196
+ ->setIdentifier(self::NOTICE_IDENTIFIER)
197
  );
198
 
199
+ Mage::helper(self::NOTICE_IDENTIFIER)->writeError($e->getMessage());
200
  }
201
  }
202
 
app/code/community/Bronto/Common/Model/Resource/Setup.php CHANGED
@@ -3,24 +3,23 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Common_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
9
  {
10
  public function handleOld()
11
  {
12
  // Look if Bronto folder exists in local codepool and recursively remove if it is
13
- $source = Mage::getBaseDir('base') . DS . 'app' . DS . 'code' . DS . 'local' . DS . 'Bronto' . DS;
14
  $destination = Mage::getBaseDir('base') . DS . 'var' . DS . 'bronto_backup' . DS;
15
  if (file_exists($source)) {
16
  $this->rcopy($source, $destination);
17
  $this->rrmdir($source);
18
 
19
  // Add Notification so customer is sure to know
20
- $adminnotice = Mage::getSingleton('adminnotification/inbox')->add(
21
  4,
22
  'Bronto Update - Old Version Moved',
23
- 'Bronto has been updated. We have moved the files from your previous intstallation to ' . $destination
24
  );
25
  }
26
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
8
  {
9
  public function handleOld()
10
  {
11
  // Look if Bronto folder exists in local codepool and recursively remove if it is
12
+ $source = Mage::getBaseDir('base') . DS . 'app' . DS . 'code' . DS . 'local' . DS . 'Bronto' . DS;
13
  $destination = Mage::getBaseDir('base') . DS . 'var' . DS . 'bronto_backup' . DS;
14
  if (file_exists($source)) {
15
  $this->rcopy($source, $destination);
16
  $this->rrmdir($source);
17
 
18
  // Add Notification so customer is sure to know
19
+ Mage::getSingleton('adminnotification/inbox')->add(
20
  4,
21
  'Bronto Update - Old Version Moved',
22
+ 'Bronto has been updated. We have moved the files from your previous installation to ' . $destination
23
  );
24
  }
25
  }
app/code/community/Bronto/Common/Model/SoapClient.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bronto_Common_Model_SoapClient extends Bronto_SoapClient
4
+ {
5
+ /**
6
+ * Override the SoapClient for a custom SSL stream context
7
+ *
8
+ * @param $wsdl string
9
+ * @param $options array
10
+ */
11
+ public function __construct($wsdl, array $options = array())
12
+ {
13
+ if (is_array($wsdl)) {
14
+ $options = $wsdl;
15
+ $wsdl = $wsdl['wsdl'];
16
+ unset($options['wsdl']);
17
+ }
18
+ $opts = array('ciphers' => 'RC4-SHA');
19
+ $options['stream_context'] = stream_context_create('ssl', $opts);
20
+ parent::__construct($wsdl, $options);
21
+ }
22
+ }
app/code/community/Bronto/Common/Model/System/Config/Backend/Cron.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  abstract class Bronto_Common_Model_System_Config_Backend_Cron
9
  extends Mage_Core_Model_Config_Data
@@ -23,6 +22,27 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron
23
  */
24
  protected $_xml_path_enabled = 'enabled';
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  /**
27
  * Cron settings after save
28
  *
@@ -32,29 +52,36 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron
32
  {
33
  $cronExprString = '';
34
 
35
- if ($this->getFieldsetDataValue($this->_xml_path_enabled)) {
 
 
 
 
 
 
 
 
 
 
36
  $minutely = Bronto_Common_Model_System_Config_Source_Cron_Frequency::CRON_MINUTELY;
37
  $hourly = Bronto_Common_Model_System_Config_Source_Cron_Frequency::CRON_HOURLY;
38
  $daily = Bronto_Common_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
39
  $frequency = $this->getFieldsetDataValue('frequency');
40
 
41
  if ($frequency == $minutely) {
42
- $interval = (int) $this->getFieldsetDataValue('interval');
43
  $cronExprString = "*/{$interval} * * * *";
44
- }
45
- elseif ($frequency == $hourly) {
46
- $minutes = (int) $this->getFieldsetDataValue('minutes');
47
  if ($minutes >= 0 && $minutes <= 59) {
48
  $cronExprString = "{$minutes} * * * *";
49
- }
50
- else {
51
  Mage::throwException(Mage::helper('bronto_common')->__('Please, specify correct minutes of hour.'));
52
  }
53
- }
54
- elseif ($frequency == $daily) {
55
- $time = $this->getFieldsetDataValue('time');
56
- $timeMinutes = $time[1];
57
- $timeHours = $time[0];
58
  // Fix Midnight Issue
59
  if ('00' == $timeMinutes && '00' == $timeHours) {
60
  $timeMinutes = '59';
@@ -65,17 +92,24 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron
65
  }
66
 
67
  try {
68
- if (!empty($this->_cron_string_path)) {
69
- $this->_saveConfigData($this->_cron_string_path, $cronExprString);
 
 
 
 
70
  }
71
- if (!empty($this->_cron_model_path)) {
72
- $this->_saveConfigData(
73
- $this->_cron_model_path,
74
- (string) Mage::getConfig()->getNode($this->_cron_model_path)
75
- );
 
 
 
 
76
  }
77
- }
78
- catch (Exception $e) {
79
  Mage::throwException(Mage::helper('adminhtml')->__('Unable to save Cron expression'));
80
  }
81
  }
@@ -83,6 +117,8 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron
83
  /**
84
  * Get value by key for new user data from <section>/groups/<group>/fields/<field>
85
  *
 
 
86
  * @return string
87
  */
88
  public function getFieldsetDataValue($key)
@@ -109,22 +145,40 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron
109
  }
110
  }
111
 
112
- return NULL;
113
  }
114
 
115
  /**
116
- * @param type $path
117
- * @param type $value
 
 
118
  *
119
  * @return Bronto_Common_Model_System_Config_Backend_Cron
120
  */
121
  protected function _saveConfigData($path, $value)
122
  {
123
  Mage::getModel('core/config_data')
124
- ->load($path, 'path')
125
- ->setValue($value)
126
- ->setPath($path)
127
- ->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
  return $this;
130
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  abstract class Bronto_Common_Model_System_Config_Backend_Cron
8
  extends Mage_Core_Model_Config_Data
22
  */
23
  protected $_xml_path_enabled = 'enabled';
24
 
25
+ /**
26
+ * @var string
27
+ */
28
+ protected $_xml_path_mage_cron = 'mage_cron';
29
+
30
+ /**
31
+ * @return string
32
+ */
33
+ public function getCronStringPath()
34
+ {
35
+ return $this->_cron_string_path;
36
+ }
37
+
38
+ /**
39
+ * @return string
40
+ */
41
+ public function getCronModelPath()
42
+ {
43
+ return $this->_cron_model_path;
44
+ }
45
+
46
  /**
47
  * Cron settings after save
48
  *
52
  {
53
  $cronExprString = '';
54
 
55
+ $useMageCron = $this->getFieldsetDataValue($this->_xml_path_mage_cron); //bronto_verify/cron_settings/
56
+
57
+ $pathParts = explode('/', $this->getPath());
58
+ $pathValues = array_values($pathParts);
59
+ $pathPart = array_pop($pathValues);
60
+ if ($pathPart == 'mage_cron') {
61
+ $verify_path = 'bronto_verify/cron_settings/' . implode('-', $pathParts);
62
+ $this->_saveConfigData($verify_path, $useMageCron);
63
+ }
64
+
65
+ if ($this->getFieldsetDataValue($this->_xml_path_enabled) && '1' == $useMageCron) {
66
  $minutely = Bronto_Common_Model_System_Config_Source_Cron_Frequency::CRON_MINUTELY;
67
  $hourly = Bronto_Common_Model_System_Config_Source_Cron_Frequency::CRON_HOURLY;
68
  $daily = Bronto_Common_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
69
  $frequency = $this->getFieldsetDataValue('frequency');
70
 
71
  if ($frequency == $minutely) {
72
+ $interval = (int)$this->getFieldsetDataValue('interval');
73
  $cronExprString = "*/{$interval} * * * *";
74
+ } elseif ($frequency == $hourly) {
75
+ $minutes = (int)$this->getFieldsetDataValue('minutes');
 
76
  if ($minutes >= 0 && $minutes <= 59) {
77
  $cronExprString = "{$minutes} * * * *";
78
+ } else {
 
79
  Mage::throwException(Mage::helper('bronto_common')->__('Please, specify correct minutes of hour.'));
80
  }
81
+ } elseif ($frequency == $daily) {
82
+ $time = $this->getFieldsetDataValue('time');
83
+ $timeMinutes = $time[1];
84
+ $timeHours = $time[0];
 
85
  // Fix Midnight Issue
86
  if ('00' == $timeMinutes && '00' == $timeHours) {
87
  $timeMinutes = '59';
92
  }
93
 
94
  try {
95
+ if ($this->getCronStringPath()) {
96
+ if ('0' == $useMageCron) {
97
+ $this->_deleteConfigData($this->getCronStringPath());
98
+ } else {
99
+ $this->_saveConfigData($this->getCronStringPath(), $cronExprString);
100
+ }
101
  }
102
+ if ($this->getCronModelPath()) {
103
+ if ('0' == $useMageCron) {
104
+ $this->_deleteConfigData($this->getCronModelPath());
105
+ } else {
106
+ $this->_saveConfigData(
107
+ $this->getCronModelPath(),
108
+ (string)Mage::getConfig()->getNode($this->getCronModelPath())
109
+ );
110
+ }
111
  }
112
+ } catch (Exception $e) {
 
113
  Mage::throwException(Mage::helper('adminhtml')->__('Unable to save Cron expression'));
114
  }
115
  }
117
  /**
118
  * Get value by key for new user data from <section>/groups/<group>/fields/<field>
119
  *
120
+ * @param string $key
121
+ *
122
  * @return string
123
  */
124
  public function getFieldsetDataValue($key)
145
  }
146
  }
147
 
148
+ return null;
149
  }
150
 
151
  /**
152
+ * Save Config Value by Path
153
+ *
154
+ * @param string $path
155
+ * @param mixed $value
156
  *
157
  * @return Bronto_Common_Model_System_Config_Backend_Cron
158
  */
159
  protected function _saveConfigData($path, $value)
160
  {
161
  Mage::getModel('core/config_data')
162
+ ->load($path, 'path')
163
+ ->setValue($value)
164
+ ->setPath($path)
165
+ ->save();
166
+
167
+ return $this;
168
+ }
169
+
170
+ /**
171
+ * Delete Config Value by Path
172
+ *
173
+ * @param string $path
174
+ *
175
+ * @return Bronto_Common_Model_System_Config_Backend_Cron
176
+ */
177
+ protected function _deleteConfigData($path)
178
+ {
179
+ Mage::getModel('core/config_data')
180
+ ->load($path, 'path')
181
+ ->delete();
182
 
183
  return $this;
184
  }
app/code/community/Bronto/Common/Model/System/Config/Backend/Enable.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Model_System_Config_Backend_Enable
9
  extends Mage_Core_Model_Config_Data
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_System_Config_Backend_Enable
8
  extends Mage_Core_Model_Config_Data
app/code/community/Bronto/Common/Model/System/Config/Backend/Token.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Config_Data
9
  {
@@ -15,46 +14,83 @@ class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Co
15
  */
16
  protected function _beforeSave()
17
  {
18
- $value = $this->getValue();
 
19
  if (!empty($value)) {
20
- if (Mage::helper('bronto_common')->validApiToken($value) === false) {
21
- Mage::throwException(Mage::helper('bronto_common')->__('The Bronto API Token you have entered appears to be invalid.'));
22
- }
23
-
24
- // API key is new and doesn't match existing API key
25
- $currentApiKey = Mage::helper('bronto_common')->getApiToken();
26
- if ($currentApiKey !== $value) {
27
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_common')->__(
28
- 'You have changed your Bronto API Token so all Bronto modules have been disabled for this configuration scope.' .
29
- '<br />Please proceed to each module and reconfigure all available options to avoid undesired behavior.'
30
- ));
31
-
32
  // reset the verified status
33
- Mage::helper('bronto_verify/roundtrip')->setStatus(
34
- Mage::helper('bronto_verify/roundtrip')->getPath('status'),
35
  '2',
36
  $this->getScope(),
37
  $this->getScopeId()
38
  );
39
 
40
- $sentry = Mage::getModel('bronto_common/keysentry');
41
- $sentry->disableModules($this->getScope(), $this->getScopeId());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, 9)) {
44
- $sentry->unlinkEmails(
45
- Mage::getModel('bronto_email/message')->getCollection(),
46
- $this->getScope(),
47
- $this->getScopeId()
48
- );
49
- }
50
  }
51
  } else {
52
- Mage::helper('bronto_verify/roundtrip')->setStatus(
53
- Mage::helper('bronto_verify/roundtrip')->getPath('status'),
54
- '2'
 
 
 
 
 
 
 
55
  );
 
 
56
  }
57
 
58
  return parent::_beforeSave();
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Config_Data
8
  {
14
  */
15
  protected function _beforeSave()
16
  {
17
+ $commonHelper = Mage::helper('bronto_common');
18
+ $value = $this->getValue();
19
  if (!empty($value)) {
20
+ if ($commonHelper->validApiToken($value) === false) {
 
 
 
 
 
 
 
 
 
 
 
21
  // reset the verified status
22
+ Mage::helper('bronto_verify/apitoken')->setStatus(
23
+ Mage::helper('bronto_verify/apitoken')->getPath('token_status'),
24
  '2',
25
  $this->getScope(),
26
  $this->getScopeId()
27
  );
28
 
29
+ Mage::throwException($commonHelper->__('The Bronto API Token you have entered appears to be invalid.'));
30
+ }
31
+
32
+ // reset the verified status
33
+ Mage::helper('bronto_verify/apitoken')->setStatus(
34
+ Mage::helper('bronto_verify/apitoken')->getPath('token_status'),
35
+ '1',
36
+ $this->getScope(),
37
+ $this->getScopeId()
38
+ );
39
+
40
+ // Enable Common Module
41
+ Mage::getModel('core/config_data')
42
+ ->load(Bronto_Common_Helper_Data::XML_PATH_ENABLED, 'path')
43
+ ->setValue(1)
44
+ ->setPath(Bronto_Common_Helper_Data::XML_PATH_ENABLED)
45
+ ->setScope($this->getScope())
46
+ ->setScopeId($this->getScopeId())
47
+ ->save();
48
+
49
+ // API key is new and doesn't match existing API key
50
+ $currentApiKey = $commonHelper->getApiToken();
51
+ if (!empty($currentApiKey) && $currentApiKey !== $value) {
52
+ Mage::getSingleton('adminhtml/session')->addNotice($commonHelper->__(
53
+ 'You have changed your Bronto API Token so all Bronto modules have been disabled for this configuration scope.' .
54
+ '<br />Please proceed to each module and reconfigure all available options to avoid undesired behavior.'
55
+ ));
56
 
57
+ $this->_disableAndUnlink();
 
 
 
 
 
 
58
  }
59
  } else {
60
+ Mage::getSingleton('adminhtml/session')->addNotice($commonHelper->__(
61
+ 'You have removed your Bronto API Token so all Bronto modules have been disabled for this configuration scope.'
62
+ ));
63
+
64
+ // reset the verified status
65
+ Mage::helper('bronto_verify/apitoken')->setStatus(
66
+ Mage::helper('bronto_verify/apitoken')->getPath('token_status'),
67
+ '0',
68
+ $this->getScope(),
69
+ $this->getScopeId()
70
  );
71
+
72
+ $this->_disableAndUnlink(true);
73
  }
74
 
75
  return parent::_beforeSave();
76
  }
77
+
78
+ /**
79
+ * Reset Roundtrip verification status, disable all modules, and unlink all Bronto Transactional Emails
80
+ *
81
+ * @param bool $includeCommon
82
+ */
83
+ protected function _disableAndUnlink($includeCommon = false)
84
+ {
85
+ $sentry = Mage::getModel('bronto_common/keysentry');
86
+ $sentry->disableModules($this->getScope(), $this->getScopeId(), $includeCommon);
87
+
88
+ if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, 9)) {
89
+ $sentry->unlinkEmails(
90
+ Mage::getModel('bronto_email/message')->getCollection(),
91
+ $this->getScope(),
92
+ $this->getScopeId()
93
+ );
94
+ }
95
+ }
96
  }
app/code/community/Bronto/Common/Model/System/Config/Source/Contact/Status.php CHANGED
@@ -2,13 +2,14 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Contact_Status
8
  {
9
 
10
  /**
11
  * Description for protected
 
12
  * @var array
13
  * @access protected
14
  */
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Contact_Status
8
  {
9
 
10
  /**
11
  * Description for protected
12
+ *
13
  * @var array
14
  * @access protected
15
  */
app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Frequency.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Cron_Frequency
8
  {
@@ -34,8 +34,8 @@ class Bronto_Common_Model_System_Config_Source_Cron_Frequency
34
  {
35
  return array(
36
  self::CRON_MINUTELY => Mage::helper('cron')->__('Minute Intervals'),
37
- self::CRON_HOURLY => Mage::helper('cron')->__('Hourly'),
38
- self::CRON_DAILY => Mage::helper('cron')->__('Daily'),
39
  );
40
  }
41
  }
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Cron_Frequency
8
  {
34
  {
35
  return array(
36
  self::CRON_MINUTELY => Mage::helper('cron')->__('Minute Intervals'),
37
+ self::CRON_HOURLY => Mage::helper('cron')->__('Hourly'),
38
+ self::CRON_DAILY => Mage::helper('cron')->__('Daily'),
39
  );
40
  }
41
  }
app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Minutes.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Cron_Minutes
8
  {
@@ -18,7 +18,7 @@ class Bronto_Common_Model_System_Config_Source_Cron_Minutes
18
  public function toOptionArray()
19
  {
20
  return array(
21
- 5 => Mage::helper('cron')->__('5 minutes'),
22
  10 => Mage::helper('cron')->__('10 minutes'),
23
  15 => Mage::helper('cron')->__('15 minutes'),
24
  20 => Mage::helper('cron')->__('20 minutes'),
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Cron_Minutes
8
  {
18
  public function toOptionArray()
19
  {
20
  return array(
21
+ 5 => Mage::helper('cron')->__('5 minutes'),
22
  10 => Mage::helper('cron')->__('10 minutes'),
23
  15 => Mage::helper('cron')->__('15 minutes'),
24
  20 => Mage::helper('cron')->__('20 minutes'),
app/code/community/Bronto/Common/Model/System/Config/Source/Field.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Field
8
  {
@@ -50,7 +50,9 @@ class Bronto_Common_Model_System_Config_Source_Field
50
 
51
  /**
52
  * Get Field Object by ID
 
53
  * @param string $id
 
54
  * @return boolean|Bronto_Api_Field_Row
55
  */
56
  public function getFieldObjectById($id)
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Field
8
  {
50
 
51
  /**
52
  * Get Field Object by ID
53
+ *
54
  * @param string $id
55
+ *
56
  * @return boolean|Bronto_Api_Field_Row
57
  */
58
  public function getFieldObjectById($id)
app/code/community/Bronto/Common/Model/System/Config/Source/Image.php CHANGED
@@ -14,9 +14,9 @@ class Bronto_Common_Model_System_Config_Source_Image
14
  $this->_helper = Mage::helper('bronto_common');
15
 
16
  return array(
17
- 'image' => $this->_helper->__('Base Image'),
18
  'small_image' => $this->_helper->__('Small Image'),
19
- 'thumbnail' => $this->_helper->__('Thumbnail'),
20
  );
21
  }
22
  }
14
  $this->_helper = Mage::helper('bronto_common');
15
 
16
  return array(
17
+ 'image' => $this->_helper->__('Base Image'),
18
  'small_image' => $this->_helper->__('Small Image'),
19
+ 'thumbnail' => $this->_helper->__('Thumbnail'),
20
  );
21
  }
22
  }
app/code/community/Bronto/Common/Model/System/Config/Source/Limit.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Common_Model_System_Config_Source_Limit
9
  {
@@ -13,11 +12,14 @@ class Bronto_Common_Model_System_Config_Source_Limit
13
  public function toOptionArray()
14
  {
15
  return array(
16
- 50 => 50,
17
- 100 => 100,
18
- 250 => 250,
19
- 500 => 500,
20
- 1000 => 1000,
 
 
 
21
  );
22
  }
23
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Limit
8
  {
12
  public function toOptionArray()
13
  {
14
  return array(
15
+ 50 => 50,
16
+ 100 => 100,
17
+ 250 => 250,
18
+ 500 => 500,
19
+ 1000 => 1000,
20
+ 5000 => 5000,
21
+ 10000 => 10000,
22
+ 20000 => 20000,
23
  );
24
  }
25
  }
app/code/community/Bronto/Common/Model/System/Config/Source/List.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_List
8
  {
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Common
6
  */
7
  class Bronto_Common_Model_System_Config_Source_List
8
  {
app/code/community/Bronto/Common/Model/System/Config/Source/Message.php CHANGED
@@ -12,6 +12,10 @@ class Bronto_Common_Model_System_Config_Source_Message
12
  protected $_options = array();
13
 
14
  /**
 
 
 
 
15
  * @return array
16
  */
17
  public function toOptionArray($token = null)
12
  protected $_options = array();
13
 
14
  /**
15
+ * Get Messages as Array of Labels and Values for Select Fields
16
+ *
17
+ * @param null $token
18
+ *
19
  * @return array
20
  */
21
  public function toOptionArray($token = null)
app/code/community/Bronto/Common/Model/System/Config/Source/Role.php CHANGED
@@ -19,11 +19,11 @@ class Bronto_Common_Model_System_Config_Source_Role
19
  return $this->_options;
20
  }
21
 
22
- $helper = Mage::helper('bronto_common');
23
  $this->_options = array(
24
  'developer' => $helper->__('Developer'),
25
- 'market' => $helper->__('Marketer'),
26
- 'partner' => $helper->__('Solution Partner'),
27
  );
28
 
29
  return $this->_options;
19
  return $this->_options;
20
  }
21
 
22
+ $helper = Mage::helper('bronto_common');
23
  $this->_options = array(
24
  'developer' => $helper->__('Developer'),
25
+ 'market' => $helper->__('Marketer'),
26
+ 'partner' => $helper->__('Solution Partner'),
27
  );
28
 
29
  return $this->_options;
app/code/community/Bronto/Common/Model/System/Config/Source/Synclimit.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Common_Model_System_Config_Source_Synclimit
9
  {
@@ -13,10 +12,10 @@ class Bronto_Common_Model_System_Config_Source_Synclimit
13
  public function toOptionArray()
14
  {
15
  return array(
16
- 250 => 250,
17
- 500 => 500,
18
- 1000 => 1000,
19
- 5000 => 5000,
20
  10000 => 10000,
21
  );
22
  }
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_Model_System_Config_Source_Synclimit
8
  {
12
  public function toOptionArray()
13
  {
14
  return array(
15
+ 250 => 250,
16
+ 500 => 500,
17
+ 1000 => 1000,
18
+ 5000 => 5000,
19
  10000 => 10000,
20
  );
21
  }
app/code/community/Bronto/Common/controllers/Adminhtml/DebugController.php CHANGED
@@ -1,16 +1,19 @@
1
  <?php
2
 
3
- class Bronto_Common_Adminhtml_DebugController extends Mage_Adminhtml_Controller_Action {
 
4
 
5
  protected $_helper;
6
 
7
  /**
8
  * @return Mage_Core_Helper_Data
9
  */
10
- protected function _getHelper() {
 
11
  if (is_null($this->_helper)) {
12
  $this->_helper = Mage::helper('bronto_common/support');
13
  }
 
14
  return $this->_helper;
15
  }
16
 
@@ -18,17 +21,21 @@ class Bronto_Common_Adminhtml_DebugController extends Mage_Adminhtml_Controller_
18
  * Sets this helper
19
  *
20
  * @param Mage_Core_Helper_Data $helper
 
21
  * @return Bronto_Common_Adminhtml_DebugController
22
  */
23
- public function setHelper(Mage_Core_Helper_Data $helper) {
 
24
  $this->_helper = $helper;
 
25
  return $this;
26
  }
27
 
28
  /**
29
  * Retrieves the system information in JSON via ajax request
30
  */
31
- public function collectAction() {
 
32
  $debug = $this->_getHelper()->getDebugInformation();
33
 
34
  // Magento 1.4, 1.5, and 1.9 chokes on the json encoding array values
@@ -48,8 +55,9 @@ class Bronto_Common_Adminhtml_DebugController extends Mage_Adminhtml_Controller_
48
  /**
49
  * Sends an archive to the browser
50
  */
51
- public function archiveAction() {
52
- $zip = basename($this->_getHelper()->getLogArchive()->getFilename());
 
53
  $json = Mage::helper('core')->jsonEncode(array(
54
  'name' => $zip,
55
  'link' => $this->getUrl('*/*/download', array('file' => $zip)),
@@ -64,12 +72,14 @@ class Bronto_Common_Adminhtml_DebugController extends Mage_Adminhtml_Controller_
64
  /**
65
  * Sends the zip to the browser
66
  */
67
- public function downloadAction() {
68
- $file = $this->getRequest()->getParam('file');
 
69
  $baseArchiveDir = $this->_getHelper()->getArchiveDirectory();
70
 
71
  if (!file_exists($baseArchiveDir . DS . $file)) {
72
  Mage::getSingleton('adminhtml/session')->addError("Archive '$file' does not exist.");
 
73
  return $this->_redirect('*/system_config/edit', array('section' => 'bronto'));
74
  } else {
75
  $this
1
  <?php
2
 
3
+ class Bronto_Common_Adminhtml_DebugController extends Mage_Adminhtml_Controller_Action
4
+ {
5
 
6
  protected $_helper;
7
 
8
  /**
9
  * @return Mage_Core_Helper_Data
10
  */
11
+ protected function _getHelper()
12
+ {
13
  if (is_null($this->_helper)) {
14
  $this->_helper = Mage::helper('bronto_common/support');
15
  }
16
+
17
  return $this->_helper;
18
  }
19
 
21
  * Sets this helper
22
  *
23
  * @param Mage_Core_Helper_Data $helper
24
+ *
25
  * @return Bronto_Common_Adminhtml_DebugController
26
  */
27
+ public function setHelper(Mage_Core_Helper_Data $helper)
28
+ {
29
  $this->_helper = $helper;
30
+
31
  return $this;
32
  }
33
 
34
  /**
35
  * Retrieves the system information in JSON via ajax request
36
  */
37
+ public function collectAction()
38
+ {
39
  $debug = $this->_getHelper()->getDebugInformation();
40
 
41
  // Magento 1.4, 1.5, and 1.9 chokes on the json encoding array values
55
  /**
56
  * Sends an archive to the browser
57
  */
58
+ public function archiveAction()
59
+ {
60
+ $zip = basename($this->_getHelper()->getLogArchive()->getFilename());
61
  $json = Mage::helper('core')->jsonEncode(array(
62
  'name' => $zip,
63
  'link' => $this->getUrl('*/*/download', array('file' => $zip)),
72
  /**
73
  * Sends the zip to the browser
74
  */
75
+ public function downloadAction()
76
+ {
77
+ $file = $this->getRequest()->getParam('file');
78
  $baseArchiveDir = $this->_getHelper()->getArchiveDirectory();
79
 
80
  if (!file_exists($baseArchiveDir . DS . $file)) {
81
  Mage::getSingleton('adminhtml/session')->addError("Archive '$file' does not exist.");
82
+
83
  return $this->_redirect('*/system_config/edit', array('section' => 'bronto'));
84
  } else {
85
  $this
app/code/community/Bronto/Common/controllers/Adminhtml/GuidersController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bronto_Common_Adminhtml_GuidersController
4
+ extends Mage_Adminhtml_Controller_Action
5
+ {
6
+
7
+ /**
8
+ * Toggle whether or not to show the guide for this section again.
9
+ */
10
+ public function ToggleAction()
11
+ {
12
+ $section = $this->getRequest()->getParam('section', 'bronto_verify');
13
+ $value = $this->getRequest()->getParam('checkvalue', '0');
14
+
15
+ // Get config object and scope details
16
+ Mage::getModel('core/config')->saveConfig(
17
+ $section . '/guide/display',
18
+ $value
19
+ );
20
+ }
21
+ }
app/code/community/Bronto/Common/controllers/LogController.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
9
  {
@@ -50,7 +49,7 @@ class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
50
 
51
  /* @var $httpHelper Mage_Core_Helper_Http */
52
  $httpHelper = Mage::helper('core/http');
53
- $ipAddress = $httpHelper->getRemoteAddr();
54
 
55
  if (!in_array($ipAddress, $this->_allowedIps)) {
56
  if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
@@ -83,19 +82,14 @@ class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
83
  }
84
 
85
  /**
86
- * Short description for function
 
87
  *
88
- * Long description (if any) ...
89
- *
90
- * @param unknown $filePath Parameter description (if any) ...
91
- * @param boolean $returnBytes Parameter description (if any) ...
92
- * @return mixed Return description (if any) ...
93
- * @access private
94
  */
95
  private function _readfileChunked($filePath, $returnBytes = true)
96
  {
97
- $buffer = '';
98
- $cnt = 0;
99
  $handle = @fopen($filePath, 'rb');
100
  if ($handle === false) {
101
  return false;
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
8
  {
49
 
50
  /* @var $httpHelper Mage_Core_Helper_Http */
51
  $httpHelper = Mage::helper('core/http');
52
+ $ipAddress = $httpHelper->getRemoteAddr();
53
 
54
  if (!in_array($ipAddress, $this->_allowedIps)) {
55
  if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
82
  }
83
 
84
  /**
85
+ * @param $filePath
86
+ * @param bool $returnBytes
87
  *
88
+ * @return bool|int
 
 
 
 
 
89
  */
90
  private function _readfileChunked($filePath, $returnBytes = true)
91
  {
92
+ $cnt = 0;
 
93
  $handle = @fopen($filePath, 'rb');
94
  if ($handle === false) {
95
  return false;
app/code/community/Bronto/Common/etc/adminhtml.xml CHANGED
@@ -12,6 +12,10 @@
12
  <title>Bronto General Section</title>
13
  <sort_order>9993</sort_order>
14
  </bronto>
 
 
 
 
15
  </children>
16
  </config>
17
  </children>
12
  <title>Bronto General Section</title>
13
  <sort_order>9993</sort_order>
14
  </bronto>
15
+ <bronto_popup module="bronto_common">
16
+ <title>Bronto Popup Section</title>
17
+ <sort_order>9994</sort_order>
18
+ </bronto_popup>
19
  </children>
20
  </config>
21
  </children>
app/code/community/Bronto/Common/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Bronto_Common>
5
- <version>2.1.0</version>
6
  </Bronto_Common>
7
  </modules>
8
  <global>
@@ -34,6 +34,13 @@
34
  </resources>
35
  </global>
36
  <frontend>
 
 
 
 
 
 
 
37
  <routers>
38
  <bronto_common>
39
  <use>standard</use>
@@ -56,14 +63,22 @@
56
  </routers>
57
  </admin>
58
  <adminhtml>
59
- <layout>
60
- <updates>
61
- <bronto_common>
62
- <file>bronto/common.xml</file>
63
- </bronto_common>
64
- </updates>
65
- </layout>
66
  <events>
 
 
 
 
 
 
 
 
67
  <controller_action_predispatch>
68
  <observers>
69
  <bronto_common_controller_action_predispatch>
@@ -86,14 +101,19 @@
86
  <jobs>
87
  <bronto_common_delete_archives>
88
  <!-- Run once a day -->
89
- <schedule><cron_expr>0 0 * * *</cron_expr></schedule>
90
- <run><model>bronto_common/observer::clearArchives</model></run>
 
 
 
 
91
  </bronto_common_delete_archives>
92
  </jobs>
93
  </crontab>
94
  <default>
95
  <bronto>
96
  <settings>
 
97
  <debug>1</debug>
98
  <verbose>0</verbose>
99
  <test>0</test>
@@ -103,6 +123,10 @@
103
  <image_type>small_image</image_type>
104
  <image_width>88</image_width>
105
  <image_height>77</image_height>
 
 
 
 
106
  </format>
107
  <support>
108
  <registered>0</registered>
2
  <config>
3
  <modules>
4
  <Bronto_Common>
5
+ <version>2.2.0</version>
6
  </Bronto_Common>
7
  </modules>
8
  <global>
34
  </resources>
35
  </global>
36
  <frontend>
37
+ <layout>
38
+ <updates>
39
+ <bronto_common>
40
+ <file>bronto/common.xml</file>
41
+ </bronto_common>
42
+ </updates>
43
+ </layout>
44
  <routers>
45
  <bronto_common>
46
  <use>standard</use>
63
  </routers>
64
  </admin>
65
  <adminhtml>
66
+ <layout>
67
+ <updates>
68
+ <bronto_common>
69
+ <file>bronto/common.xml</file>
70
+ </bronto_common>
71
+ </updates>
72
+ </layout>
73
  <events>
74
+ <bronto_disable>
75
+ <observers>
76
+ <bronto_common_disable>
77
+ <class>bronto_common/observer</class>
78
+ <method>watchDisableAction</method>
79
+ </bronto_common_disable>
80
+ </observers>
81
+ </bronto_disable>
82
  <controller_action_predispatch>
83
  <observers>
84
  <bronto_common_controller_action_predispatch>
101
  <jobs>
102
  <bronto_common_delete_archives>
103
  <!-- Run once a day -->
104
+ <schedule>
105
+ <cron_expr>0 0 * * *</cron_expr>
106
+ </schedule>
107
+ <run>
108
+ <model>bronto_common/observer::clearArchives</model>
109
+ </run>
110
  </bronto_common_delete_archives>
111
  </jobs>
112
  </crontab>
113
  <default>
114
  <bronto>
115
  <settings>
116
+ <enabled>1</enabled>
117
  <debug>1</debug>
118
  <verbose>0</verbose>
119
  <test>0</test>
123
  <image_type>small_image</image_type>
124
  <image_width>88</image_width>
125
  <image_height>77</image_height>
126
+ <default_greeting>Valued Customer</default_greeting>
127
+ <default_greeting_prefix></default_greeting_prefix>
128
+ <default_greeting_firstname></default_greeting_firstname>
129
+ <default_greeting_lastname></default_greeting_lastname>
130
  </format>
131
  <support>
132
  <registered>0</registered>
app/code/community/Bronto/Common/etc/system.xml CHANGED
@@ -8,6 +8,55 @@
8
  </bronto>
9
  </tabs>
10
  <sections>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  <bronto module="bronto_common">
12
  <label>General</label>
13
  <tab>bronto</tab>
@@ -34,8 +83,23 @@
34
  <show_in_store>1</show_in_store>
35
  <expanded>1</expanded>
36
  <fields>
 
 
 
 
 
 
 
 
 
 
 
 
37
  <api_token>
38
  <label>API Token</label>
 
 
 
39
  <frontend_type>text</frontend_type>
40
  <frontend_model>bronto_common/adminhtml_system_config_form_field_apitoken</frontend_model>
41
  <backend_model>bronto_common/system_config_backend_token</backend_model>
@@ -44,10 +108,14 @@
44
  <show_in_website>1</show_in_website>
45
  <show_in_store>1</show_in_store>
46
  <validate>validate-length minimum-length-36</validate>
47
- <comment><![CDATA[<span style="color: red; font-weight:bold;">Warning!</span> Changing your API Token will require you to reconfigure all Bronto modules and reimport your data.]]></comment>
 
48
  </api_token>
49
  <debug>
50
  <label>Debug</label>
 
 
 
51
  <frontend_type>select</frontend_type>
52
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
53
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
@@ -55,11 +123,17 @@
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
57
  <show_in_store>1</show_in_store>
58
- <comment><![CDATA[Allow the Bronto extension to write logs in <code>var/log</code>.]]></comment>
 
59
  </debug>
60
  <verbose>
61
- <depends><debug>1</debug></depends>
62
  <label>Verbose Log Output</label>
 
 
 
 
 
 
63
  <frontend_type>select</frontend_type>
64
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
65
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
@@ -71,6 +145,9 @@
71
  </verbose>
72
  <test>
73
  <label>Test Mode</label>
 
 
 
74
  <frontend_type>select</frontend_type>
75
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
76
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
@@ -78,10 +155,14 @@
78
  <show_in_default>1</show_in_default>
79
  <show_in_website>1</show_in_website>
80
  <show_in_store>1</show_in_store>
81
- <comment><![CDATA[Email sent with <a href="http://community.bronto.com/api/v4/objects/general/deliveryobject" target="_blank"><code>type=test</code></a> only to existing Contacts.]]></comment>
 
82
  </test>
83
  <notices>
84
  <label>Error Notices</label>
 
 
 
85
  <frontend_type>select</frontend_type>
86
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
87
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
@@ -89,7 +170,8 @@
89
  <show_in_default>1</show_in_default>
90
  <show_in_website>1</show_in_website>
91
  <show_in_store>1</show_in_store>
92
- <comment><![CDATA[Show warnings/errors as site notices.<br /><strong>Note:</strong> Site notices can be customer-facing.]]></comment>
 
93
  </notices>
94
  </fields>
95
  </settings>
@@ -105,7 +187,8 @@
105
  <site_name>
106
  <label>Bronto Site Name</label>
107
  <frontend_type>text</frontend_type>
108
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support_site</frontend_model>
 
109
  <sort_order>1</sort_order>
110
  <show_in_default>1</show_in_default>
111
  <show_in_website>1</show_in_website>
@@ -174,7 +257,9 @@
174
  <show_in_store>1</show_in_store>
175
  </using_solution_partner>
176
  <partner>
177
- <depends><using_solution_partner>1</using_solution_partner></depends>
 
 
178
  <label>Name of Solution Partner or SI</label>
179
  <frontend_type>text</frontend_type>
180
  <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
@@ -186,14 +271,15 @@
186
  </fields>
187
  </support>
188
  <format>
189
- <label>Formatting Options</label>
190
  <frontend_type>text</frontend_type>
191
  <frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
192
  <sort_order>3</sort_order>
193
  <show_in_default>1</show_in_default>
194
  <show_in_website>1</show_in_website>
195
  <show_in_store>1</show_in_store>
196
- <comment><![CDATA[These formatting options apply to product images and any price variables within Reminder Emails. Leave image width <em>or</em> height blank to resize according to aspect ratio. Leave both width <em>and</em> height blank to use the full image size. You can always set width and height values within the HTML of your message too.<br/><br/><strong style="color: red">Warning!</strong>&nbsp;Changing any formatting options will immediately affect future emails. Make sure your corresponding messages are ready to accept the newly formatted content.<br/><br/>]]></comment>
 
197
  <fields>
198
  <image_type>
199
  <label>Image Type</label>
@@ -229,23 +315,81 @@
229
  <default_value>77</default_value>
230
  <comment>Product image height in pixels.</comment>
231
  </image_height>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  <use_symbol>
233
  <label>Include Currency Symbol</label>
234
  <frontend_type>select</frontend_type>
235
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
236
  <source_model>adminhtml/system_config_source_yesno</source_model>
237
- <sort_order>30</sort_order>
238
  <show_in_default>1</show_in_default>
239
  <show_in_website>1</show_in_website>
240
  <show_in_store>1</show_in_store>
241
  <comment>
242
  <![CDATA[Pass Default Display Currency symbol into email (located in "General" > "Currency Setup" > "Default Display Currency").]]></comment>
243
  </use_symbol>
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  </fields>
245
  </format>
246
  <information>
247
  <label>Support Information</label>
248
- <comment><![CDATA[Most questions can easily be answered by thoroughly reviewing the Bronto <a style="color:#ea7601" target="_blank" href="http://a.bron.to/magento" title="Magento Resource Center | Bronto Developers">Magento Resource Center</a> so please consult that first. The next best resource is the <a style="color:#ea7601" target="_blank" href="http://dev.bronto.com/questions" title="Questions | Bronto Developers">Questions</a> forum where you can post the question if it has not been asked yet.<br/><br/><strong>Disclaimer:</strong> The Bronto Extension for Magento was tested in clean Magento environments and Bronto cannot guarantee compatibility with third-party extensions or other site customizations.<br/><br/>If you believe you have encountered an actual issue with the extension itself then you may file a support case. Please note that regular Bronto Support hours are between 8am-8pm ET, Monday through Friday, excluding holidays.<br/><br/><span style="padding-left: 30px;">To contact the Bronto Support team, please perform the following steps:</span><br/><ul><li style="padding-left: 60px;"><strong>Step 1: &nbsp;</strong><a style="color: #ea7601" target="_blank" href="https://app.bronto.com/shared/support/case_add" title="Technical Support | Bronto Marketing Platform">Open a case</a> within Bronto. In your case description, please outline the issue and steps to reproduce it. Also, be sure to mention the version of Magento and the version of the Bronto extension currently running.</li><li style="padding-left: 60px;"><strong>Step 2: &nbsp;</strong>After creating a case, please add a comment and paste in all of the debug information that is generated after clicking the <em>Generate Debug Information</em> button below:<ul style="padding-left: 85px;list-style-type:lower-alpha;"><li>Click on the <a style="color:#ea7601" target="_blank" title="Tehnical Support | Bronto Marketing Platform" href="https://app.bronto.com/shared/support/index">Support</a> link located in the top right of the page.</li><li>Click on the case you want to comment on.</li><li>Paste in the debug information and click <em>Post Response</em>.</li></ul></li><li style="padding-left: 60px;"><strong>Step 3: &nbsp;</strong>Optionally, if more information is needed, your Support representative may request log files. Simply click the <em>Create Log Archive</em> button below and then click the link that is generated and displayed below the button to download an archive of log files to send to the location designated by your Support representative.</li></ul><br/>]]></comment>
 
249
  <frontend_type>text</frontend_type>
250
  <frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
251
  <sort_order>4</sort_order>
8
  </bronto>
9
  </tabs>
10
  <sections>
11
+ <bronto_popup module="bronto_common">
12
+ <label>Pop-up Manager</label>
13
+ <tab>bronto</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>899</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <about>
21
+ <frontend_type>text</frontend_type>
22
+ <frontend_model>bronto_common/adminhtml_system_config_about</frontend_model>
23
+ <sort_order>0</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ </about>
28
+ <settings>
29
+ <label>Settings</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <expanded>1</expanded>
36
+ <comment><![CDATA[The Bronto Pop-up Manager gives you more control
37
+ and flexibility to manage pop-up sign-ups throughout their
38
+ lifecycle.<br/>If interested, please contact your Account
39
+ Manager to learn more about this offering.<br/><br/>
40
+ <h2>Pop-up Manager Highlights</h2><ul>
41
+ <li style="padding-left: 60px"><strong>&bull;&nbsp;&nbsp;Simple, fast installation</strong> - Paste the single line of JavaScript provided by the Pop-up Manager below, and the rest is magic.</li>
42
+ <li style="padding-left: 60px"><strong>&bull;&nbsp;&nbsp;Visual editor</strong> - Create a pop-up sign-up in minutes and make changes to any visual element on the fly.</li>
43
+ <li style="padding-left: 60px"><strong>&bull;&nbsp;&nbsp;Customizable design</strong> - Store and manage multiple versions of pop-up sign-ups.</li>
44
+ <li style="padding-left: 60px"><strong>&bull;&nbsp;&nbsp;A/B testing</strong> - Test two different versions of a pop-up to determine which performs better.</li>
45
+ <li style="padding-left: 60px"><strong>&bull;&nbsp;&nbsp;Bronto-hosted</strong> - Fast and reliable hosting with Bronto's content distribution network.</li>
46
+ </ul><br /><br/>]]></comment>
47
+ <fields>
48
+ <code>
49
+ <label>Pop-up Manager Script</label>
50
+ <frontend_type>textarea</frontend_type>
51
+ <sort_order>0</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </code>
56
+ </fields>
57
+ </settings>
58
+ </groups>
59
+ </bronto_popup>
60
  <bronto module="bronto_common">
61
  <label>General</label>
62
  <tab>bronto</tab>
83
  <show_in_store>1</show_in_store>
84
  <expanded>1</expanded>
85
  <fields>
86
+ <enabled>
87
+ <label>Enable Module</label>
88
+ <frontend_type>select</frontend_type>
89
+ <backend_model>bronto_common/system_config_backend_enable</backend_model>
90
+ <source_model>adminhtml/system_config_source_yesno</source_model>
91
+ <sort_order>0</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ <comment><![CDATA[Changing to <em>No</em> will disable all modules
96
+ for this scope.]]></comment>
97
+ </enabled>
98
  <api_token>
99
  <label>API Token</label>
100
+ <depends>
101
+ <enabled>1</enabled>
102
+ </depends>
103
  <frontend_type>text</frontend_type>
104
  <frontend_model>bronto_common/adminhtml_system_config_form_field_apitoken</frontend_model>
105
  <backend_model>bronto_common/system_config_backend_token</backend_model>
108
  <show_in_website>1</show_in_website>
109
  <show_in_store>1</show_in_store>
110
  <validate>validate-length minimum-length-36</validate>
111
+ <comment>
112
+ <![CDATA[<span style="color: red; font-weight:bold;">Warning!</span> Changing your API Token will require you to reconfigure all Bronto modules and reimport your data.]]></comment>
113
  </api_token>
114
  <debug>
115
  <label>Debug</label>
116
+ <depends>
117
+ <enabled>1</enabled>
118
+ </depends>
119
  <frontend_type>select</frontend_type>
120
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
121
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
123
  <show_in_default>1</show_in_default>
124
  <show_in_website>1</show_in_website>
125
  <show_in_store>1</show_in_store>
126
+ <comment>
127
+ <![CDATA[Allow the Bronto extension to write logs in <code>var/log</code>.]]></comment>
128
  </debug>
129
  <verbose>
 
130
  <label>Verbose Log Output</label>
131
+ <depends>
132
+ <debug>1</debug>
133
+ </depends>
134
+ <depends>
135
+ <enabled>1</enabled>
136
+ </depends>
137
  <frontend_type>select</frontend_type>
138
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
139
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
145
  </verbose>
146
  <test>
147
  <label>Test Mode</label>
148
+ <depends>
149
+ <enabled>1</enabled>
150
+ </depends>
151
  <frontend_type>select</frontend_type>
152
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
153
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
155
  <show_in_default>1</show_in_default>
156
  <show_in_website>1</show_in_website>
157
  <show_in_store>1</show_in_store>
158
+ <comment>
159
+ <![CDATA[Email sent with <a href="http://community.bronto.com/api/v4/objects/general/deliveryobject" target="_blank"><code>type=test</code></a> only to existing Contacts.]]></comment>
160
  </test>
161
  <notices>
162
  <label>Error Notices</label>
163
+ <depends>
164
+ <enabled>1</enabled>
165
+ </depends>
166
  <frontend_type>select</frontend_type>
167
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
168
  <source_model>adminhtml/system_config_source_enabledisable</source_model>
170
  <show_in_default>1</show_in_default>
171
  <show_in_website>1</show_in_website>
172
  <show_in_store>1</show_in_store>
173
+ <comment>
174
+ <![CDATA[Show warnings/errors as site notices.<br /><strong>Note:</strong> Site notices can be customer-facing.]]></comment>
175
  </notices>
176
  </fields>
177
  </settings>
187
  <site_name>
188
  <label>Bronto Site Name</label>
189
  <frontend_type>text</frontend_type>
190
+ <frontend_model>bronto_common/adminhtml_system_config_form_field_support_site
191
+ </frontend_model>
192
  <sort_order>1</sort_order>
193
  <show_in_default>1</show_in_default>
194
  <show_in_website>1</show_in_website>
257
  <show_in_store>1</show_in_store>
258
  </using_solution_partner>
259
  <partner>
260
+ <depends>
261
+ <using_solution_partner>1</using_solution_partner>
262
+ </depends>
263
  <label>Name of Solution Partner or SI</label>
264
  <frontend_type>text</frontend_type>
265
  <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
271
  </fields>
272
  </support>
273
  <format>
274
+ <label>Email Formatting Options</label>
275
  <frontend_type>text</frontend_type>
276
  <frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
277
  <sort_order>3</sort_order>
278
  <show_in_default>1</show_in_default>
279
  <show_in_website>1</show_in_website>
280
  <show_in_store>1</show_in_store>
281
+ <comment>
282
+ <![CDATA[<strong style="color: red">Warning!</strong>&nbsp;Changing any formatting options will immediately affect future emails. Make sure your corresponding messages are ready to accept the newly formatted content.<br/><br/>Leave image width <em>or</em> height blank to resize according to aspect ratio. Leave both width <em>and</em> height blank to use the full image size. You can always set width and height values within the HTML of your message too.<br/><br/>]]></comment>
283
  <fields>
284
  <image_type>
285
  <label>Image Type</label>
315
  <default_value>77</default_value>
316
  <comment>Product image height in pixels.</comment>
317
  </image_height>
318
+ <default_greeting>
319
+ <label>Default Greeting</label>
320
+ <frontend_type>text</frontend_type>
321
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
322
+ <sort_order>40</sort_order>
323
+ <show_in_default>1</show_in_default>
324
+ <show_in_website>1</show_in_website>
325
+ <show_in_store>1</show_in_store>
326
+ <comment>
327
+ <![CDATA[If User does not have a Full Name set for their account, this value will be used in the email to populate the <em>%%%%#customerName%%%%</em> API tag.]]></comment>
328
+ </default_greeting>
329
+ <default_greeting_prefix>
330
+ <label>Default Greeting Prefix</label>
331
+ <frontend_type>text</frontend_type>
332
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
333
+ <sort_order>41</sort_order>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>1</show_in_store>
337
+ <comment>
338
+ <![CDATA[If User does not have a Prefix set for their account, this value will be used in the email to populate the <em>%%%%#prefix%%%%</em> API tag.]]></comment>
339
+ </default_greeting_prefix>
340
+ <default_greeting_firstname>
341
+ <label>Default Greeting First Name</label>
342
+ <frontend_type>text</frontend_type>
343
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
344
+ <sort_order>42</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>1</show_in_store>
348
+ <comment>
349
+ <![CDATA[If User does not have a First Name set for their account, this value will be used in the email to populate the <em>%%%%#firstName%%%%</em> API tag.]]></comment>
350
+ </default_greeting_firstname>
351
+ <default_greeting_lastname>
352
+ <label>Default Greeting Last Name</label>
353
+ <frontend_type>text</frontend_type>
354
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
355
+ <sort_order>43</sort_order>
356
+ <show_in_default>1</show_in_default>
357
+ <show_in_website>1</show_in_website>
358
+ <show_in_store>1</show_in_store>
359
+ <comment>
360
+ <![CDATA[If User does not have a Last Name set for their account, this value will be used in the email to populate the <em>%%%%#lastName%%%%</em> API tag.]]></comment>
361
+ </default_greeting_lastname>
362
  <use_symbol>
363
  <label>Include Currency Symbol</label>
364
  <frontend_type>select</frontend_type>
365
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
366
  <source_model>adminhtml/system_config_source_yesno</source_model>
367
+ <sort_order>44</sort_order>
368
  <show_in_default>1</show_in_default>
369
  <show_in_website>1</show_in_website>
370
  <show_in_store>1</show_in_store>
371
  <comment>
372
  <![CDATA[Pass Default Display Currency symbol into email (located in "General" > "Currency Setup" > "Default Display Currency").]]></comment>
373
  </use_symbol>
374
+ <incl_tax>
375
+ <label>Include Tax in Reminder Emails</label>
376
+ <frontend_type>select</frontend_type>
377
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
378
+ <source_model>adminhtml/system_config_source_yesno</source_model>
379
+ <sort_order>45</sort_order>
380
+ <show_in_default>1</show_in_default>
381
+ <show_in_website>1</show_in_website>
382
+ <show_in_store>1</show_in_store>
383
+ <comment><![CDATA[If enabled, the <em>%%%%#productPrice_#%%%%</em> for
384
+ quote items will include the tax (if available)
385
+ for the given product, subtotal, and grand total.]]></comment>
386
+ </incl_tax>
387
  </fields>
388
  </format>
389
  <information>
390
  <label>Support Information</label>
391
+ <comment>
392
+ <![CDATA[Most questions can easily be answered by thoroughly reviewing the Bronto <a style="color:#ea7601" target="_blank" href="http://a.bron.to/magento" title="Magento Resource Center | Bronto Developers">Magento Resource Center</a> so please consult that first. The next best resource is the <a style="color:#ea7601" target="_blank" href="http://dev.bronto.com/questions" title="Questions | Bronto Developers">Questions</a> forum where you can post the question if it has not been asked yet.<br/><br/><strong>Disclaimer:</strong> The Bronto Extension for Magento was tested in clean Magento environments and Bronto cannot guarantee compatibility with third-party extensions or other site customizations.<br/><br/>If you believe you have encountered an actual issue with the extension itself then you may file a support case. Please note that regular Bronto Support hours are between 8am-8pm ET, Monday through Friday, excluding holidays.<br/><br/><span style="padding-left: 30px;">To contact the Bronto Support team, please perform the following steps:</span><br/><ul><li style="padding-left: 60px;"><strong>Step 1: &nbsp;</strong><a style="color: #ea7601" target="_blank" href="https://app.bronto.com/shared/support/case_add" title="Technical Support | Bronto Marketing Platform">Open a case</a> within Bronto. In your case description, please outline the issue and steps to reproduce it. Also, be sure to mention the version of Magento and the version of the Bronto extension currently running.</li><li style="padding-left: 60px;"><strong>Step 2: &nbsp;</strong>After creating a case, please add a comment and paste in all of the debug information that is generated after clicking the <em>Generate Debug Information</em> button below:<ul style="padding-left: 85px;list-style-type:lower-alpha;"><li>Click on the <a style="color:#ea7601" target="_blank" title="Technical Support | Bronto Marketing Platform" href="https://app.bronto.com/shared/support/index">Support</a> link located in the top right of the page.</li><li>Click on the case you want to comment on.</li><li>Paste in the debug information and click <em>Post Response</em>.</li></ul></li><li style="padding-left: 60px;"><strong>Step 3: &nbsp;</strong>Optionally, if more information is needed, your Support representative may request log files. Simply click the <em>Create Log Archive</em> button below and then click the link that is generated and displayed below the button to download an archive of log files to send to the location designated by your Support representative.</li></ul><br/>]]></comment>
393
  <frontend_type>text</frontend_type>
394
  <frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
395
  <sort_order>4</sort_order>
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/About.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.0
7
  */
8
  class Bronto_Customer_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
9
  {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
8
  {
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Cron.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
9
  {
@@ -28,7 +27,7 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
28
  protected function getProgressBarTotal()
29
  {
30
  return $this->getCustomerResourceCollection()
31
- // ->addBrontoNotSuppressedFilter()
32
  ->getSize();
33
  }
34
 
@@ -56,6 +55,7 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
56
 
57
  /**
58
  * Get number of customers not imported from stores that don't have module enabled
 
59
  * @return int
60
  */
61
  protected function getProgressBarDisabled()
@@ -78,6 +78,7 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
78
  ->addBrontoNotSuppressedFilter()
79
  ->getSize();
80
  }
 
81
  return 0;
82
  }
83
 
@@ -87,7 +88,7 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
87
  protected function getCustomerResourceCollection()
88
  {
89
  $collection = Mage::getModel('bronto_customer/queue')->getCollection();
90
- $storeIds = Mage::helper('bronto_customer')->getStoreIds();
91
 
92
  if ($storeIds) {
93
  $collection->addStoreFilter($storeIds);
@@ -95,4 +96,14 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
95
 
96
  return $collection;
97
  }
 
 
 
 
 
 
 
 
 
 
98
  }
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
8
  {
27
  protected function getProgressBarTotal()
28
  {
29
  return $this->getCustomerResourceCollection()
30
+ // ->addBrontoNotSuppressedFilter()
31
  ->getSize();
32
  }
33
 
55
 
56
  /**
57
  * Get number of customers not imported from stores that don't have module enabled
58
+ *
59
  * @return int
60
  */
61
  protected function getProgressBarDisabled()
78
  ->addBrontoNotSuppressedFilter()
79
  ->getSize();
80
  }
81
+
82
  return 0;
83
  }
84
 
88
  protected function getCustomerResourceCollection()
89
  {
90
  $collection = Mage::getModel('bronto_customer/queue')->getCollection();
91
+ $storeIds = Mage::helper('bronto_customer')->getStoreIds();
92
 
93
  if ($storeIds) {
94
  $collection->addStoreFilter($storeIds);
96
 
97
  return $collection;
98
  }
99
+
100
+ /**
101
+ * Determine if should show the cron table
102
+ *
103
+ * @return mixed
104
+ */
105
+ public function showCronTable()
106
+ {
107
+ return Mage::helper('bronto_customer')->canUseMageCron();
108
+ }
109
  }
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Rewardpoints.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Customer_Block_Adminhtml_System_Config_Form_Field_Rewardpoints
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
9
+ {
10
+ /**
11
+ * Get element ID of the dependent field's parent row
12
+ *
13
+ * @param object $element
14
+ *
15
+ * @return String
16
+ */
17
+ protected function _getRowElementId($element)
18
+ {
19
+ return 'row_' . $element->getId();
20
+ }
21
+
22
+ /**
23
+ * Override method to render element only if module enabled
24
+ *
25
+ * @param Varien_Data_Form_Element_Abstract $element
26
+ *
27
+ * @return String
28
+ */
29
+ public function render(Varien_Data_Form_Element_Abstract $element)
30
+ {
31
+ // If Reward Points Module is installed
32
+ if (!Mage::helper('bronto_common')->isModuleInstalled('Enterprise_Reward')) {
33
+ return '';
34
+ }
35
+
36
+ return parent::render($element);
37
+ }
38
+ }
39
+
40
+
41
+
42
+
43
+
44
+
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Storecredit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Customer_Block_Adminhtml_System_Config_Form_Field_Storecredit
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
9
+ {
10
+ /**
11
+ * Get element ID of the dependent field's parent row
12
+ *
13
+ * @param object $element
14
+ *
15
+ * @return String
16
+ */
17
+ protected function _getRowElementId($element)
18
+ {
19
+ return 'row_' . $element->getId();
20
+ }
21
+
22
+ /**
23
+ * Override method to render element only if module enabled
24
+ *
25
+ * @param Varien_Data_Form_Element_Abstract $element
26
+ *
27
+ * @return String
28
+ */
29
+ public function render(Varien_Data_Form_Element_Abstract $element)
30
+ {
31
+ // If Reward Points Module is installed
32
+ if (!Mage::helper('bronto_common')->isModuleInstalled('Enterprise_CustomerBalance')) {
33
+ return '';
34
+ }
35
+
36
+ return parent::render($element);
37
+ }
38
+ }
39
+
40
+
41
+
42
+
43
+
44
+
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.0
7
  */
8
  abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes extends Bronto_Common_Block_Adminhtml_System_Config_Form_Fieldset
9
  {
@@ -17,13 +16,24 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
17
  public function render(Varien_Data_Form_Element_Abstract $element)
18
  {
19
  if (!$this->helper('bronto_customer')->isEnabled()) {
20
- return;
21
  }
22
 
23
  $html = $this->_getHeaderHtml($element);
 
24
 
 
 
25
  // Render Existing elements
26
  foreach ($element->getSortedElements() as $field) {
 
 
 
 
 
 
 
 
27
  $html .= $field->toHtml();
28
  }
29
 
@@ -36,7 +46,6 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
36
  if (in_array($_attributeCode, $skips)) {
37
  continue;
38
  } else {
39
-
40
  try {
41
  $order = $order + 5;
42
  $html .= $this->_getFieldHtml($element, $_attribute, $order);
@@ -45,32 +54,93 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
45
 
46
  continue;
47
  }
48
-
49
  }
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  $html .= $this->_getFooterHtml($element);
53
 
54
  return $html;
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  /**
58
  * this creates a dummy element so you can say if your config fields are available on default and website level -
59
  * you can skip this and add the scope for each element in _getFieldHtml method
60
- * @return type
 
 
 
61
  */
62
  protected function _getDummyElement($order)
63
  {
64
  if (empty($this->_dummyElement)) {
65
  $this->_dummyElement = new Varien_Object(array(
66
- 'sort_order' => $order,
67
- 'frontend_type' => 'select',
68
- 'frontend_model' => 'bronto_common/adminhtml_system_config_form_field',
69
- 'backend_model' => 'bronto_customer/system_config_backend_brontofield',
70
- 'source_model' => 'bronto_common/system_config_source_field',
71
  'show_in_default' => 1,
72
  'show_in_website' => 1,
73
- 'show_in_store' => 1,
74
  ));
75
  }
76
 
@@ -79,54 +149,61 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
79
 
80
  /**
81
  * Get Dummy Element for 'Create New...' form
82
- * @param int $order
83
- * @return type
 
 
84
  */
85
  protected function _getDummyNewElement($order)
86
  {
87
  if (empty($this->_dummyNewElement)) {
88
  $this->_dummyNewElement = new Varien_Object(array(
89
- 'sort_order' => $order,
90
- 'frontend_type' => 'text',
91
- 'backend_model' => 'bronto_customer/system_config_backend_newfield',
92
  'show_in_default' => 1,
93
  'show_in_website' => 1,
94
- 'show_in_store' => 1,
95
  ));
96
  }
 
97
  return $this->_dummyNewElement;
98
  }
99
 
100
  /**
101
  * this sets the fields renderer. If you have a custom renderer you can change this.
102
- * @return type
 
103
  */
104
  protected function _getFieldRenderer()
105
  {
106
  if (empty($this->_fieldRenderer)) {
107
  $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
108
  }
 
109
  return $this->_fieldRenderer;
110
  }
111
 
112
  /**
113
  * this actually gets the html for a field
 
114
  * @param Varien_Data_Form_Element_Abstract $fieldset
115
- * @param Mage_Eav_Model_Entity_Attribute $attribute
116
- * @param int $order
 
117
  * @return string
118
  */
119
  protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, Mage_Eav_Model_Entity_Attribute $attribute, $order)
120
  {
121
  // Create Select Field
122
- $e = $this->_getDummyElement($order);
123
  $field = $this->_createField($fieldset, $e, $attribute);
124
  if (!$field) {
125
  return '';
126
  }
127
 
128
  // Create New Field
129
- $en = $this->_getDummyNewElement($order + 1);
130
  $newField = $this->_createField($fieldset, $en, $attribute, 'newfield');
131
  if (!$newField) {
132
  return '';
@@ -143,10 +220,12 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
143
 
144
  /**
145
  * Create Field and Return it
 
146
  * @param Varien_Data_Form_Element_Abstract $fieldset
147
- * @param Varien_Object $e
148
- * @param Mage_Eav_Model_Entity_Attribute $attribute
149
- * @param string $fieldStep
 
150
  * @return Varien_Data_Form_Element_Abstract
151
  */
152
  protected function _createField(
@@ -163,15 +242,15 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
163
  }
164
  // Define Attribute Code
165
  $attributeCode = $attribute->getAttributeCode();
166
- $attributeCode = ($fieldStep == 'newfield') ? "dynamic_new_{$attributeCode}" : $attributeCode;
167
 
168
  // Get Attribute Data and Inheritance
169
  $path = $this->_configPath . $attributeCode;
170
  if (isset($configData[$path])) {
171
- $data = $configData[$path];
172
  $inherit = false;
173
  } else {
174
- $data = (string)Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
175
  $inherit = true;
176
  }
177
 
@@ -184,8 +263,8 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
184
 
185
  // Define Type, Name, and Label
186
  $fieldType = (string)$e->frontend_type ? (string)$e->frontend_type : 'text';
187
- $name = str_replace('_attrCode_', $attributeCode, $this->_fieldNameTemplate);
188
- $label = ($fieldStep == 'newfield') ? "" : $attribute->getFrontendLabel();
189
 
190
  // Pass through backend model in case it needs to modify value
191
  if ($e->backend_model) {
@@ -197,17 +276,22 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
197
  $data = $model->getValue();
198
  }
199
 
 
 
 
 
 
200
  // Select Field for Existing attributes.
201
  $field = $fieldset->addField($attributeCode, $fieldType,
202
  array(
203
- 'name' => $name,
204
- 'label' => $label,
205
- 'value' => ($data === 0) ? '' : $data,
206
- 'inherit' => ($fieldStep == 'newfield') ? false : $inherit,
207
- 'field_config' => $e,
208
- 'scope' => $this->getForm()->getScope(),
209
- 'scopeId' => $this->getForm()->getScopeId(),
210
- 'scope_label' => '[STORE VIEW]',
211
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$e->show_in_default),
212
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_website),
213
  'can_use_store_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_store),
@@ -241,10 +325,11 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
241
  abstract protected function _getAttributes();
242
 
243
  /**
244
- * @param Varien_Data_Form_Element_Fieldset $fieldset
245
- * @return array<string>
 
246
  */
247
- protected function _getUsedAttributeCodes(Varien_Data_Form_Element_Fieldset $fieldset)
248
  {
249
  $usedAttributeCodes = array();
250
  foreach ($fieldset->getSortedElements() as $_element) {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes extends Bronto_Common_Block_Adminhtml_System_Config_Form_Fieldset
8
  {
16
  public function render(Varien_Data_Form_Element_Abstract $element)
17
  {
18
  if (!$this->helper('bronto_customer')->isEnabled()) {
19
+ return '';
20
  }
21
 
22
  $html = $this->_getHeaderHtml($element);
23
+ $html .= $this->_getScopeToggleHtml($element);
24
 
25
+ // Store Labels as Values to set on Create new fields
26
+ $values = array();
27
  // Render Existing elements
28
  foreach ($element->getSortedElements() as $field) {
29
+ if ('select' == $field->getType()) {
30
+ $values[$field->getHtmlId() . '_new'] = $field->getLabel();
31
+ } else {
32
+ if (array_key_exists($field->getHtmlId(), $values)) {
33
+ $field->setValue($values[$field->getHtmlId()]);
34
+ }
35
+ }
36
+
37
  $html .= $field->toHtml();
38
  }
39
 
46
  if (in_array($_attributeCode, $skips)) {
47
  continue;
48
  } else {
 
49
  try {
50
  $order = $order + 5;
51
  $html .= $this->_getFieldHtml($element, $_attribute, $order);
54
 
55
  continue;
56
  }
 
57
  }
58
  }
59
 
60
+ $html .= '
61
+ <script type="text/javascript">
62
+ Event.observe(window, "load", function() {
63
+ $$("fieldset.config select").each(function(item) {
64
+ item.observe("change", function() {
65
+ if (item.value == "_new_") {
66
+ if ($(item.id + "_new") != undefined) {
67
+ $(item.id + "_new").focus();
68
+ }
69
+ if ($(item.id + "_dynamic_new") != undefined) {
70
+ $(item.id + "_dynamic_new").focus();
71
+ }
72
+ }
73
+ });
74
+ });
75
+ });
76
+ </script>';
77
+
78
  $html .= $this->_getFooterHtml($element);
79
 
80
  return $html;
81
  }
82
 
83
+ protected function _getScopeToggleHtml($element)
84
+ {
85
+ $scopeParams = $this->helper('bronto_common')->getScopeParams();
86
+ switch ($scopeParams['scope']) {
87
+ case 'store':
88
+ $inheritLabel = 'Use Website for All';
89
+ break;
90
+ case 'website':
91
+ $inheritLabel = 'Use Default for All';
92
+ break;
93
+ default:
94
+ case 'default':
95
+ return '';
96
+ break;
97
+ }
98
+
99
+ $html = '
100
+ <tr id="' . $element->getHtmlId() . '_unselect_all">
101
+ <td class="label"></td>
102
+ <td class="value"></td>
103
+ <td class="use-default" colspan="3">
104
+ <input id="' . $element->getHtmlId() . '_scope_toggle_checkbox" value="0" name="scope_toggle" type="checkbox" class="checkbox config-inherit-toggle" onclick="brontoToggleScope(this, \'' . $element->getHtmlId() . '\');" />
105
+ <label id="' . $element->getHtmlId() . '_scope_toggle_checkbox_label" for="' . $element->getHtmlId() . '_scope_toggle_checkbox" class="inherit" title="Toggle Scope Inheritance">' . $inheritLabel . '</label>
106
+ </td>
107
+ </tr>
108
+ <script type="text/javascript">
109
+ function brontoToggleScope(toggle, parentId)
110
+ {
111
+ var toggleValue = toggle.checked;
112
+
113
+ $$("#" + parentId + " input.checkbox.config-inherit").each(function(item){
114
+ item.checked = toggleValue;
115
+ item.value = toggleValue ? "1" : "0";
116
+ toggleValueElements(item, Element.previous(item.parentNode));
117
+ });
118
+ }
119
+ </script>';
120
+
121
+ return $html;
122
+ }
123
+
124
  /**
125
  * this creates a dummy element so you can say if your config fields are available on default and website level -
126
  * you can skip this and add the scope for each element in _getFieldHtml method
127
+ *
128
+ * @param $order
129
+ *
130
+ * @return Varien_Object
131
  */
132
  protected function _getDummyElement($order)
133
  {
134
  if (empty($this->_dummyElement)) {
135
  $this->_dummyElement = new Varien_Object(array(
136
+ 'sort_order' => $order,
137
+ 'frontend_type' => 'select',
138
+ 'frontend_model' => 'bronto_common/adminhtml_system_config_form_field',
139
+ 'backend_model' => 'bronto_customer/system_config_backend_brontofield',
140
+ 'source_model' => 'bronto_common/system_config_source_field',
141
  'show_in_default' => 1,
142
  'show_in_website' => 1,
143
+ 'show_in_store' => 1,
144
  ));
145
  }
146
 
149
 
150
  /**
151
  * Get Dummy Element for 'Create New...' form
152
+ *
153
+ * @param $order
154
+ *
155
+ * @return Varien_Object
156
  */
157
  protected function _getDummyNewElement($order)
158
  {
159
  if (empty($this->_dummyNewElement)) {
160
  $this->_dummyNewElement = new Varien_Object(array(
161
+ 'sort_order' => $order,
162
+ 'frontend_type' => 'text',
163
+ 'backend_model' => 'bronto_customer/system_config_backend_newfield',
164
  'show_in_default' => 1,
165
  'show_in_website' => 1,
166
+ 'show_in_store' => 1,
167
  ));
168
  }
169
+
170
  return $this->_dummyNewElement;
171
  }
172
 
173
  /**
174
  * this sets the fields renderer. If you have a custom renderer you can change this.
175
+ *
176
+ * @return object
177
  */
178
  protected function _getFieldRenderer()
179
  {
180
  if (empty($this->_fieldRenderer)) {
181
  $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
182
  }
183
+
184
  return $this->_fieldRenderer;
185
  }
186
 
187
  /**
188
  * this actually gets the html for a field
189
+ *
190
  * @param Varien_Data_Form_Element_Abstract $fieldset
191
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
192
+ * @param int $order
193
+ *
194
  * @return string
195
  */
196
  protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, Mage_Eav_Model_Entity_Attribute $attribute, $order)
197
  {
198
  // Create Select Field
199
+ $e = $this->_getDummyElement($order);
200
  $field = $this->_createField($fieldset, $e, $attribute);
201
  if (!$field) {
202
  return '';
203
  }
204
 
205
  // Create New Field
206
+ $en = $this->_getDummyNewElement($order + 1);
207
  $newField = $this->_createField($fieldset, $en, $attribute, 'newfield');
208
  if (!$newField) {
209
  return '';
220
 
221
  /**
222
  * Create Field and Return it
223
+ *
224
  * @param Varien_Data_Form_Element_Abstract $fieldset
225
+ * @param Varien_Object $e
226
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
227
+ * @param string $fieldStep
228
+ *
229
  * @return Varien_Data_Form_Element_Abstract
230
  */
231
  protected function _createField(
242
  }
243
  // Define Attribute Code
244
  $attributeCode = $attribute->getAttributeCode();
245
+ $attributeCode = ($fieldStep == 'newfield') ? "{$attributeCode}_dynamic_new" : $attributeCode;
246
 
247
  // Get Attribute Data and Inheritance
248
  $path = $this->_configPath . $attributeCode;
249
  if (isset($configData[$path])) {
250
+ $data = $configData[$path];
251
  $inherit = false;
252
  } else {
253
+ $data = (string)Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
254
  $inherit = true;
255
  }
256
 
263
 
264
  // Define Type, Name, and Label
265
  $fieldType = (string)$e->frontend_type ? (string)$e->frontend_type : 'text';
266
+ $name = str_replace('_attrCode_', $attributeCode, $this->_fieldNameTemplate);
267
+ $label = ($fieldStep == 'newfield') ? "" : $attribute->getFrontendLabel();
268
 
269
  // Pass through backend model in case it needs to modify value
270
  if ($e->backend_model) {
276
  $data = $model->getValue();
277
  }
278
 
279
+ // Pre-populate New field with label text
280
+ if ('newfield' == $fieldStep && '' == $data) {
281
+ $data = $attribute->getFrontendLabel();
282
+ }
283
+
284
  // Select Field for Existing attributes.
285
  $field = $fieldset->addField($attributeCode, $fieldType,
286
  array(
287
+ 'name' => $name,
288
+ 'label' => $label,
289
+ 'value' => ($data === 0) ? '' : $data,
290
+ 'inherit' => ($fieldStep == 'newfield') ? false : $inherit,
291
+ 'field_config' => $e,
292
+ 'scope' => $this->getForm()->getScope(),
293
+ 'scopeId' => $this->getForm()->getScopeId(),
294
+ 'scope_label' => '[STORE VIEW]',
295
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$e->show_in_default),
296
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_website),
297
  'can_use_store_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_store),
325
  abstract protected function _getAttributes();
326
 
327
  /**
328
+ * @param Varien_Data_Form_Element_Abstract $fieldset
329
+ *
330
+ * @return array
331
  */
332
+ protected function _getUsedAttributeCodes(Varien_Data_Form_Element_Abstract $fieldset)
333
  {
334
  $usedAttributeCodes = array();
335
  foreach ($fieldset->getSortedElements() as $_element) {
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Address.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.0
7
  */
8
  class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Address extends Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes
9
  {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Address extends Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes
8
  {
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Customer.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.0
7
  */
8
  class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Customer extends Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes
9
  {
@@ -18,6 +17,7 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Cus
18
  protected $_ignoreAttributes = array(
19
  'increment_id',
20
  'updated_at',
 
21
  'entity_id',
22
  'attribute_set_id',
23
  'entity_type_id',
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Customer extends Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes
8
  {
17
  protected $_ignoreAttributes = array(
18
  'increment_id',
19
  'updated_at',
20
+ 'store_id',
21
  'entity_id',
22
  'attribute_set_id',
23
  'entity_type_id',
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Suppressed.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Customer
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Customer_Block_Adminhtml_System_Config_Suppressed
8
+ extends Bronto_Common_Block_Adminhtml_System_Config_Suppressed
9
+ {
10
+ /**
11
+ * Get URL for AJAX call
12
+ *
13
+ * @return string
14
+ */
15
+ public function getAjaxUrl()
16
+ {
17
+ return Mage::helper('bronto_common')->getScopeUrl('adminhtml/customer/suppression');
18
+ }
19
+ }
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Reset.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Customer_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -15,7 +14,7 @@ class Bronto_Customer_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml
15
  $this->setLabel('Reset All Customers');
16
 
17
  $this->setOnClick("deleteConfirm('This will mark all customers as not-imported and will cause the importer to re-process each customer again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/reset') . "'); return false;");
18
- $this->setClass('delete');
19
 
20
  if (!Mage::helper('bronto_customer')->isModuleActive() || (!Mage::helper('bronto_customer')->isDebugEnabled() && !Mage::helper('bronto_customer')->isTestModeEnabled())) {
21
  $this->setDisabled(true)->setClass('disabled');
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Block_Widget_Button
8
  {
14
  $this->setLabel('Reset All Customers');
15
 
16
  $this->setOnClick("deleteConfirm('This will mark all customers as not-imported and will cause the importer to re-process each customer again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/reset') . "'); return false;");
17
+ $this->setClass('delete bronto-cron-reset');
18
 
19
  if (!Mage::helper('bronto_customer')->isModuleActive() || (!Mage::helper('bronto_customer')->isDebugEnabled() && !Mage::helper('bronto_customer')->isTestModeEnabled())) {
20
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Run.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Customer_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -14,6 +13,7 @@ class Bronto_Customer_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml_B
14
  {
15
  $this->setLabel('Run Now');
16
  $this->setOnClick("setLocation('" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/run') . "'); return false;");
 
17
 
18
  if (!Mage::helper('bronto_customer')->isModuleActive()) {
19
  $this->setDisabled(true)->setClass('disabled');
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml_Block_Widget_Button
8
  {
13
  {
14
  $this->setLabel('Run Now');
15
  $this->setOnClick("setLocation('" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/run') . "'); return false;");
16
+ $this->setClass('bronto-cron-run');
17
 
18
  if (!Mage::helper('bronto_customer')->isModuleActive()) {
19
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Sync.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Customer_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -12,9 +11,9 @@ class Bronto_Customer_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_
12
  */
13
  protected function _construct()
14
  {
15
- $this->setLabel($this->__('Sync Contacts to Queue'));
16
- $this->setOnClick("deleteConfirm('This will ensure all Magento contacts are in the queue to import into Bronto\\n\\nThis is meant to be used when the customer count does not match the total number of customers in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/sync') . "'); return false;");
17
- $this->setClass('save');
18
 
19
  if (!Mage::helper('bronto_customer')->isModuleActive()) {
20
  $this->setDisabled(true)->setClass('disabled');
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
8
  {
11
  */
12
  protected function _construct()
13
  {
14
+ $this->setLabel($this->__('Sync Customers to Queue'));
15
+ $this->setOnClick("deleteConfirm('This will ensure all Magento customers are in the queue to import into Bronto\\n\\nThis is meant to be used when the customer count does not match the total number of customers in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/sync') . "'); return false;");
16
+ $this->setClass('save bronto-cron-sync');
17
 
18
  if (!Mage::helper('bronto_customer')->isModuleActive()) {
19
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Customer/Helper/Data.php CHANGED
@@ -3,25 +3,54 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.0
7
  */
8
  class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
9
  {
10
- const XML_PATH_ENABLED = 'bronto_customer/settings/enabled';
11
- const XML_PATH_LIMIT = 'bronto_customer/settings/limit';
12
- const XML_PATH_SYNC_LIMIT = 'bronto_customer/settings/sync_limit';
13
- const XML_PATH_INSTALL_DATE = 'bronto_customer/settings/install_date';
14
- const XML_PATH_UPGRADE_DATE = 'bronto_customer/settings/upgrade_date';
 
15
 
16
- const XML_PREFIX_CUSTOMER_ATTR = 'bronto_customer/attributes/';
17
- const XML_PREFIX_ADDRESS_ATTR = 'bronto_customer/address_attributes/';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  /**
 
 
 
 
 
20
  * @return bool
21
  */
22
- public function isEnabled()
23
  {
24
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED);
 
 
 
 
 
 
25
  }
26
 
27
  /*
@@ -31,7 +60,7 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
31
  */
32
  public function getModuleEnabledText()
33
  {
34
- $message = parent::getModuleEnabledText();
35
  $scopeData = $this->getScopeParams();
36
  if ($scopeData['scope'] != 'default') {
37
  $message = $this->__(
@@ -40,28 +69,40 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
40
  'and <em>Address Attributes</em> on this page and select the desired fields.'
41
  );
42
  }
 
43
  return $message;
44
  }
45
 
46
  /**
47
- * @param string $path
 
 
 
 
 
48
  * @return bool
49
  */
50
- public function disableModule($scope = 'default', $scopeId = 0)
51
  {
52
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
53
  }
54
 
55
  /**
56
- * @param $storeId int (Optional)
 
 
 
 
57
  * @return int
58
  */
59
- public function getLimit($storeId = null)
60
  {
61
- return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $storeId);
62
  }
63
 
64
  /**
 
 
65
  * @return int
66
  */
67
  public function getSyncLimit()
@@ -69,13 +110,39 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
69
  return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  /**
73
  * @return array
74
  */
75
  public function getSystemAttributes()
76
  {
77
  return array(
78
- 'attributes' => array(
79
  'prefix',
80
  'new_prefix',
81
  'firstname',
@@ -123,27 +190,36 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
123
  }
124
 
125
  /**
126
- * @param string $attribute
127
- * @param int|string $store
 
 
 
 
128
  * @return mixed
129
  */
130
- public function getCustomerAttributeField($attribute, $store = null)
131
  {
132
- return $this->getAdminScopedConfig(self::XML_PREFIX_CUSTOMER_ATTR . $attribute, $store);
133
  }
134
 
135
  /**
136
- * @param string $attribute
137
- * @param int|string $store
 
 
 
 
138
  * @return mixed
139
  */
140
- public function getAddressAttributeField($attribute, $store = null)
141
  {
142
- return $this->getAdminScopedConfig(self::XML_PREFIX_ADDRESS_ATTR . $attribute, $store);
143
  }
144
 
145
  /**
146
  * Retrieve helper module name
 
147
  * @return string
148
  */
149
  protected function _getModuleName()
@@ -153,8 +229,10 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
153
 
154
  /**
155
  * Get Human Readable label for attribute value option
 
156
  * @param Mage_Eav_Model_Entity_Attribute $attribute
157
- * @param int|string $attributeValueId
 
158
  * @return string|boolean
159
  */
160
  public function getAttributeAdminLabel($attribute, $attributeValueId)
@@ -170,11 +248,13 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
170
  }
171
 
172
  }
 
173
  return false;
174
  }
175
 
176
  /**
177
  * Get Count of customers not in queue
 
178
  * @return int
179
  */
180
  public function getMissingCustomersCount()
@@ -185,6 +265,7 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
185
 
186
  /**
187
  * Get Customers which aren't in contact queue
 
188
  * @return array
189
  */
190
  public function getMissingCustomers()
@@ -198,7 +279,8 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
198
  *
199
  * @return boolean
200
  */
201
- public function hasCustomConfig() {
 
202
  return true;
203
  }
204
 
@@ -206,14 +288,16 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
206
  * Gets the bronto customer field attributes
207
  *
208
  * @param object $store (Optional)
 
209
  * @return array
210
  */
211
- public function getCustomConfig($store = null) {
 
212
  $customerAttributes = Mage::getModel('customer/entity_attribute_collection');
213
- $addressAttributes = Mage::getModel('customer/entity_address_attribute_collection');
214
 
215
  $attributes = array();
216
- $data = array();
217
  foreach ($customerAttributes as $attribute) {
218
  $config = $this->getCustomerAttributeField($attribute->getAttributeCode(), $store);
219
  if ($config && $attribute->getFrontendLabel()) {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
8
  {
9
+ const XML_PATH_ENABLED = 'bronto_customer/settings/enabled';
10
+ const XML_PATH_MAGE_CRON = 'bronto_customer/settings/mage_cron';
11
+ const XML_PATH_LIMIT = 'bronto_customer/settings/limit';
12
+ const XML_PATH_SYNC_LIMIT = 'bronto_customer/settings/sync_limit';
13
+ const XML_PATH_INSTALL_DATE = 'bronto_customer/settings/install_date';
14
+ const XML_PATH_UPGRADE_DATE = 'bronto_customer/settings/upgrade_date';
15
 
16
+ const XML_PREFIX_CUSTOMER_ATTR = 'bronto_customer/attributes/';
17
+ const XML_PREFIX_ADDRESS_ATTR = 'bronto_customer/address_attributes/';
18
+
19
+ const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_customer_import/schedule/cron_expr';
20
+ const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_customer_import/run/model';
21
+
22
+ /**
23
+ * Module Human Readable Name
24
+ */
25
+ protected $_name = 'Bronto Customer Import';
26
+
27
+ /**
28
+ * Get Human Readable Name
29
+ *
30
+ * @return string
31
+ */
32
+ public function getName()
33
+ {
34
+ return $this->__($this->_name);
35
+ }
36
 
37
  /**
38
+ * Check if module is enabled
39
+ *
40
+ * @param string $scope
41
+ * @param int $scopeId
42
+ *
43
  * @return bool
44
  */
45
+ public function isEnabled($scope = 'default', $scopeId = 0)
46
  {
47
+ // Check if valid token is present
48
+ if (!$this->validApiToken(null, $scope, $scopeId)) {
49
+ return false;
50
+ }
51
+
52
+ // Get Enabled Scope
53
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
54
  }
55
 
56
  /*
60
  */
61
  public function getModuleEnabledText()
62
  {
63
+ $message = parent::getModuleEnabledText();
64
  $scopeData = $this->getScopeParams();
65
  if ($scopeData['scope'] != 'default') {
66
  $message = $this->__(
69
  'and <em>Address Attributes</em> on this page and select the desired fields.'
70
  );
71
  }
72
+
73
  return $message;
74
  }
75
 
76
  /**
77
+ * Disable Module for Specified Scope
78
+ *
79
+ * @param string $scope
80
+ * @param int $scopeId
81
+ * @param bool $deleteConfig
82
+ *
83
  * @return bool
84
  */
85
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
86
  {
87
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
88
  }
89
 
90
  /**
91
+ * Get Send Limit
92
+ *
93
+ * @param string $scope
94
+ * @param int $scopeId
95
+ *
96
  * @return int
97
  */
98
+ public function getLimit($scope = 'default', $scopeId = 0)
99
  {
100
+ return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $scope, $scopeId);
101
  }
102
 
103
  /**
104
+ * Get Sync Limit
105
+ *
106
  * @return int
107
  */
108
  public function getSyncLimit()
110
  return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
111
  }
112
 
113
+ /**
114
+ * Check if module can use the magento cron
115
+ *
116
+ * @return bool
117
+ */
118
+ public function canUseMageCron()
119
+ {
120
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
121
+ }
122
+
123
+ /**
124
+ * @return string
125
+ */
126
+ public function getCronStringPath()
127
+ {
128
+ return self::XML_PATH_CRON_STRING;
129
+ }
130
+
131
+ /**
132
+ * @return string
133
+ */
134
+ public function getCronModelPath()
135
+ {
136
+ return self::XML_PATH_CRON_MODEL;
137
+ }
138
+
139
  /**
140
  * @return array
141
  */
142
  public function getSystemAttributes()
143
  {
144
  return array(
145
+ 'attributes' => array(
146
  'prefix',
147
  'new_prefix',
148
  'firstname',
190
  }
191
 
192
  /**
193
+ * Get Customer Attribute Field for scope
194
+ *
195
+ * @param $attribute
196
+ * @param string $scope
197
+ * @param int $scopeId
198
+ *
199
  * @return mixed
200
  */
201
+ public function getCustomerAttributeField($attribute, $scope = 'default', $scopeId = 0)
202
  {
203
+ return $this->getAdminScopedConfig(self::XML_PREFIX_CUSTOMER_ATTR . $attribute, $scope, $scopeId);
204
  }
205
 
206
  /**
207
+ * Get Address Attribute Field for scope
208
+ *
209
+ * @param $attribute
210
+ * @param string $scope
211
+ * @param int $scopeId
212
+ *
213
  * @return mixed
214
  */
215
+ public function getAddressAttributeField($attribute, $scope = 'default', $scopeId = 0)
216
  {
217
+ return $this->getAdminScopedConfig(self::XML_PREFIX_ADDRESS_ATTR . $attribute, $scope, $scopeId);
218
  }
219
 
220
  /**
221
  * Retrieve helper module name
222
+ *
223
  * @return string
224
  */
225
  protected function _getModuleName()
229
 
230
  /**
231
  * Get Human Readable label for attribute value option
232
+ *
233
  * @param Mage_Eav_Model_Entity_Attribute $attribute
234
+ * @param int|string $attributeValueId
235
+ *
236
  * @return string|boolean
237
  */
238
  public function getAttributeAdminLabel($attribute, $attributeValueId)
248
  }
249
 
250
  }
251
+
252
  return false;
253
  }
254
 
255
  /**
256
  * Get Count of customers not in queue
257
+ *
258
  * @return int
259
  */
260
  public function getMissingCustomersCount()
265
 
266
  /**
267
  * Get Customers which aren't in contact queue
268
+ *
269
  * @return array
270
  */
271
  public function getMissingCustomers()
279
  *
280
  * @return boolean
281
  */
282
+ public function hasCustomConfig()
283
+ {
284
  return true;
285
  }
286
 
288
  * Gets the bronto customer field attributes
289
  *
290
  * @param object $store (Optional)
291
+ *
292
  * @return array
293
  */
294
+ public function getCustomConfig($store = null)
295
+ {
296
  $customerAttributes = Mage::getModel('customer/entity_attribute_collection');
297
+ $addressAttributes = Mage::getModel('customer/entity_address_attribute_collection');
298
 
299
  $attributes = array();
300
+ $data = array();
301
  foreach ($customerAttributes as $attribute) {
302
  $config = $this->getCustomerAttributeField($attribute->getAttributeCode(), $store);
303
  if ($config && $attribute->getFrontendLabel()) {
app/code/community/Bronto/Customer/Model/Mysql4/Queue.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.0.2
7
  */
8
  class Bronto_Customer_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
9
  {
@@ -27,7 +26,8 @@ class Bronto_Customer_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
27
 
28
  /**
29
  * Get Write adapter instance
30
- * @return type
 
31
  */
32
  public function getWriteAdapter()
33
  {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
8
  {
26
 
27
  /**
28
  * Get Write adapter instance
29
+ *
30
+ * @return Varien_Db_Adapter_Interface
31
  */
32
  public function getWriteAdapter()
33
  {
app/code/community/Bronto/Customer/Model/Mysql4/Queue/Collection.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.0.2
7
  */
8
  class Bronto_Customer_Model_Mysql4_Queue_Collection
9
  extends Mage_Core_Model_Mysql4_Collection_Abstract
@@ -26,6 +25,7 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
26
  public function addBrontoImportedFilter()
27
  {
28
  $this->addFieldToFilter('bronto_imported', array('notnull' => true));
 
29
  return $this;
30
  }
31
 
@@ -35,6 +35,7 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
35
  public function addBrontoSuppressedFilter()
36
  {
37
  $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
 
38
  return $this;
39
  }
40
 
@@ -44,6 +45,7 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
44
  public function addBrontoNotImportedFilter()
45
  {
46
  $this->addFieldToFilter('bronto_imported', array('null' => true));
 
47
  return $this;
48
  }
49
 
@@ -53,11 +55,13 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
53
  public function addBrontoNotSuppressedFilter()
54
  {
55
  $this->addFieldToFilter('bronto_suppressed', array('null' => true));
 
56
  return $this;
57
  }
58
 
59
  /**
60
  * @param mixed $storeIds (null, int|string, array, array may contain null)
 
61
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
62
  */
63
  public function addStoreFilter($storeIds)
@@ -88,6 +92,7 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
88
  * Sort order by order created_at date
89
  *
90
  * @param string $dir
 
91
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
92
  */
93
  public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
@@ -101,6 +106,7 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
101
  * Sort order by order updated_at date
102
  *
103
  * @param string $dir
 
104
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
105
  */
106
  public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Model_Mysql4_Queue_Collection
8
  extends Mage_Core_Model_Mysql4_Collection_Abstract
25
  public function addBrontoImportedFilter()
26
  {
27
  $this->addFieldToFilter('bronto_imported', array('notnull' => true));
28
+
29
  return $this;
30
  }
31
 
35
  public function addBrontoSuppressedFilter()
36
  {
37
  $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
38
+
39
  return $this;
40
  }
41
 
45
  public function addBrontoNotImportedFilter()
46
  {
47
  $this->addFieldToFilter('bronto_imported', array('null' => true));
48
+
49
  return $this;
50
  }
51
 
55
  public function addBrontoNotSuppressedFilter()
56
  {
57
  $this->addFieldToFilter('bronto_suppressed', array('null' => true));
58
+
59
  return $this;
60
  }
61
 
62
  /**
63
  * @param mixed $storeIds (null, int|string, array, array may contain null)
64
+ *
65
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
66
  */
67
  public function addStoreFilter($storeIds)
92
  * Sort order by order created_at date
93
  *
94
  * @param string $dir
95
+ *
96
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
97
  */
98
  public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
106
  * Sort order by order updated_at date
107
  *
108
  * @param string $dir
109
+ *
110
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
111
  */
112
  public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
app/code/community/Bronto/Customer/Model/Mysql4/Setup.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.2
7
  */
8
  class Bronto_Customer_Model_Mysql4_Setup extends Mage_Customer_Model_Entity_Setup
9
  {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Model_Mysql4_Setup extends Mage_Customer_Model_Entity_Setup
8
  {
app/code/community/Bronto/Customer/Model/Observer.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.0.2
7
  */
8
  class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
9
  {
@@ -11,6 +10,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
11
 
12
  /**
13
  * Observes module becoming enabled and displays message warning user to configure settings
 
14
  * @param Varien_Event_Observer $observer
15
  */
16
  public function watchEnableAction(Varien_Event_Observer $observer)
@@ -20,6 +20,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
20
 
21
  /**
22
  * @param mixed $storeId
 
23
  *
24
  * @return array
25
  */
@@ -27,10 +28,12 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
27
  {
28
  if (!$limit) {
29
  Mage::helper('bronto_customer')->writeDebug(' Limit empty. Skipping...');
 
30
  return false;
31
  }
32
 
33
- $store = Mage::app()->getStore($storeId);
 
34
  $storeId = $store->getId();
35
 
36
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
@@ -38,16 +41,17 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
38
 
39
  if (!$store->getConfig(Bronto_Customer_Helper_Data::XML_PATH_ENABLED)) {
40
  Mage::helper('bronto_customer')->writeDebug(' Module disabled for this store. Skipping...');
 
41
  return false;
42
  }
43
 
44
  // Retrieve Store's configured API Token
45
  $token = $store->getConfig(Bronto_Common_Helper_Data::XML_PATH_API_TOKEN);
46
 
47
- /* @var $api Bronto_Common_Model_Api */
48
  $api = Mage::helper('bronto_customer')->getApi($token);
49
 
50
- /* @var $contactObject Bronto_Api_Contact */
51
  $contactObject = $api->getContactObject();
52
 
53
  // Get all customers in queue who haven't been imported into bronto
@@ -62,12 +66,15 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
62
 
63
  if (empty($customerRows)) {
64
  Mage::helper('bronto_customer')->writeVerboseDebug(' No Customers to process. Skipping...');
 
65
  return $result;
66
  }
67
 
 
68
  $customerAttributes = Mage::getModel('customer/entity_attribute_collection');
 
69
  $addressAttributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
70
- $customerCache = array();
71
 
72
  // For each Customer...
73
  foreach ($customerRows as $customerRow) {
@@ -76,13 +83,15 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
76
  Mage::helper('bronto_customer')->writeDebug(" Processing Customer ID: {$customerId} for Store ID: {$storeId}");
77
  $customerCache[] = array('customerId' => $customerId, 'storeId' => $storeId);
78
 
79
- /* @var $brontoContact Bronto_Api_Contact_Row */
80
- $brontoContact = $contactObject->createRow(array());
81
  $brontoContact->email = $customer->getEmail();
82
 
83
  /* Process Customer Attributes */
84
  try {
85
  $brontoContact = $this->_processAttributes($brontoContact, $customer, $customerAttributes, $store, 'customer');
 
 
86
 
87
  /* Process Address Attributes */
88
  $primaryAddress = $customer->getPrimaryShippingAddress();
@@ -92,36 +101,32 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
92
 
93
  $brontoContact->persist();
94
  } catch (Exception $e) {
95
-
96
  }
97
 
 
98
  try {
99
- // Mark Customer as imported
100
- $customerRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
101
- $customerRow->save();
102
-
103
- // Flush every 10 Customers
104
  if ($result['total'] % 100 === 0) {
105
- $result = $this->_flushCustomers($contactObject, $customerCache, $result);
106
  $customerCache = array();
107
  }
108
  } catch (Exception $e) {
109
  Mage::helper('bronto_customer')->writeError($e);
110
 
111
  // Mark Customer as *not* imported
112
- $customerRow->setBrontoImported(null);
113
-
114
- $customerRow->save();
115
 
116
  $result['error']++;
117
  }
118
-
119
- $result['total']++;
120
  }
121
  }
122
 
123
  // Final flush (for any we miss)
124
- $results = $this->_flushCustomers($contactObject, $customerCache, $result);
 
 
125
 
126
  Mage::helper('bronto_customer')->writeDebug(' Success: ' . $results['success']);
127
  Mage::helper('bronto_customer')->writeDebug(' Error: ' . $results['error']);
@@ -130,13 +135,88 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
130
  return $results;
131
  }
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  /**
134
  * Cycle through attributes and validate against Bronto Field type
 
135
  * @param Bronto_Api_Contact_Row $brontoContact
136
- * @param $source
137
- * @param $attributes
138
- * @param Mage_Core_Model_Store $store
139
- * @param string $type 'customer' or 'address'
 
140
  * @return Bronto_Api_Contact_Row
141
  */
142
  protected function _processAttributes(Bronto_Api_Contact_Row $brontoContact, $source, $attributes, Mage_Core_Model_Store $store, $type = 'customer')
@@ -151,10 +231,10 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
151
  // Get Attribute Field
152
  switch ($type) {
153
  case 'address':
154
- $_fieldName = Mage::helper('bronto_customer')->getAddressAttributeField($_attributeCode, $store);
155
  break;
156
  default:
157
- $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, $store);
158
  break;
159
  }
160
 
@@ -179,9 +259,11 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
179
 
180
  /**
181
  * Based on attribute type, pull the value or the label
182
- * @param type $attribute
183
- * @param type $value
184
- * @return type
 
 
185
  */
186
  protected function _getReadableValue($attribute, $value)
187
  {
@@ -196,18 +278,22 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
196
  switch ($_attributeCode) {
197
  case 'website_id':
198
  $websiteModel = Mage::getModel('core/website')->load($value);
 
199
  return $websiteModel->getName();
200
  break;
201
  case 'store_id':
202
  $storeModel = Mage::getModel('core/store')->load($value);
 
203
  return $storeModel->getName();
204
  break;
205
  case 'group_id':
206
  $groupModel = Mage::getModel('customer/group')->load($value);
 
207
  return $groupModel->getCode();
208
  break;
209
  case 'country_id':
210
  $countryModel = Mage::getModel('directory/country')->load($value);
 
211
  return $countryModel->getName();
212
  break;
213
  default:
@@ -222,10 +308,18 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
222
  break;
223
  case 'multiselect':
224
  $values = array();
 
 
 
 
 
 
 
225
  foreach ($value as $val) {
226
  $values[] = strtolower(Mage::helper('bronto_customer')->getAttributeAdminLabel($attribute, $val));
227
  }
228
- return $values;
 
229
  break;
230
  case 'date':
231
  $dates = explode(' ', $value);
@@ -244,9 +338,9 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
244
  }
245
 
246
  /**
247
- * @param Bronto_Api_Customer $customerObject
248
- * @param array $customerCache
249
- * @param array $result
250
  *
251
  * @return array
252
  */
@@ -254,16 +348,41 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
254
  {
255
  $fieldModel = Mage::getModel('bronto_common/system_config_source_field');
256
  $flushResult = $customerObject->flush();
257
-
 
258
  Mage::helper('bronto_customer')->writeVerboseDebug('===== FLUSH =====', 'bronto_customer_api.log');
259
  Mage::helper('bronto_customer')->writeVerboseDebug(var_export($customerObject->getApi()->getLastRequest(), true), 'bronto_customer_api.log');
260
  Mage::helper('bronto_customer')->writeVerboseDebug(var_export($customerObject->getApi()->getLastResponse(), true), 'bronto_customer_api.log');
261
-
262
  foreach ($flushResult as $i => $flushResultRow) {
263
  if ($flushResultRow->hasError()) {
264
- $errorCode = $flushResultRow->getErrorCode();
 
265
  $errorMessage = $flushResultRow->getErrorMessage();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
 
 
 
 
 
267
  // Catch Error and Replace Field ID with Field Name
268
  if (preg_match_all("/([a-zA-Z0-9\-]){36}/", $errorMessage, $matches)) { // Grab field id if exists
269
  foreach ($matches[0] as $match) {
@@ -271,36 +390,29 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
271
  if ($fieldObject) {
272
  $errorMessage = str_replace($match, $fieldObject->name, $errorMessage);
273
  } elseif (array_key_exists($match, $this->_fieldMap)) {
274
- $mageLabel = $this->_fieldMap[$match];
275
  $errorMessage = "Bronto field mapped for {$mageLabel} no longer exists in your bronto account";
276
  }
277
  }
278
  }
279
 
280
- if (isset($customerCache[$i])) {
281
- // Get Customer Object
282
- $customer = Mage::getModel('customer/customer')->load($customerCache[$i]['customerId']);
283
- $store = Mage::getModel('core/store')->load($customerCache[$i]['storeId']);
284
- $website = Mage::getModel('core/website')->load($store->getWebsiteId());
285
- $storeMessage = "For `{$website->getName()}`:`{$store->getName()}`: ";
286
-
287
- $customerObject = Mage::getModel('bronto_customer/queue')
288
- ->getCustomerRow($customerCache[$i]['customerId'], $customerCache[$i]['storeId'])
289
- ->setBrontoImported(null);
290
-
291
- // If Error Code In specified Array, suppress contact
292
- if (in_array($errorCode, array(302, 303, 314, 315, 317))) {
293
- $customerObject->setBrontoSuppressed($errorMessage);
294
- }
295
 
296
- $customerObject->save();
297
 
298
- Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$storeMessage}{$errorMessage} ({$customer->getEmail()})");
299
- } else {
300
- Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$errorMessage}");
301
- }
302
  $result['error']++;
303
  } else {
 
 
 
 
 
304
  $result['success']++;
305
  }
306
  }
@@ -309,28 +421,33 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
309
  }
310
 
311
  /**
 
 
312
  * @return array
313
  */
314
- public function processCustomers()
315
  {
316
  $result = array(
317
- 'total' => 0,
318
  'success' => 0,
319
- 'error' => 0,
320
  );
321
 
322
- $limit = Mage::helper('bronto_customer')->getLimit();
 
 
323
 
324
- $stores = Mage::app()->getStores(true);
325
- foreach ($stores as $_store) {
326
- if ($limit <= 0) {
327
- continue;
 
 
 
 
 
 
328
  }
329
- $storeResult = $this->processCustomersForStore($_store, $limit);
330
- $result['total'] += $storeResult['total'];
331
- $result['success'] += $storeResult['success'];
332
- $result['error'] += $storeResult['error'];
333
- $limit = $limit - $storeResult['total'];
334
  }
335
 
336
  return $result;
@@ -357,7 +474,9 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
357
  /**
358
  * Grab Config Data Object before save and handle the 'Create New...' value for
359
  * fields that were generated dynamically
 
360
  * @param Varien_Event_Observer $observer
 
361
  * @return Varien_Event_Observer
362
  */
363
  public function saveDynamicField(Varien_Event_Observer $observer)
@@ -380,21 +499,23 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
380
 
381
  /**
382
  * Process customer and address attributes and save back to observer
 
383
  * @param array $groups
384
  * @param string $section
 
385
  * @return array
386
  */
387
  protected function _handleDynamicAttributes($groups, $section)
388
  {
389
  // Process Dynamic Customer Attribute Fields
390
  if (array_key_exists('attributes', $groups)) {
391
- $attrFieldsCustomer = $this->_processDynamicAttributes($groups['attributes']['fields'], $section, 'attributes');
392
  $groups['attributes']['fields'] = $attrFieldsCustomer;
393
  }
394
 
395
  // Process Dynamic Address Attribute Fields
396
  if (array_key_exists('address_attributes', $groups)) {
397
- $attrFieldsAddress = $this->_processDynamicAttributes($groups['address_attributes']['fields'], $section, 'address_attributes');
398
  $groups['address_attributes']['fields'] = $attrFieldsAddress;
399
  }
400
 
@@ -404,9 +525,11 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
404
 
405
  /**
406
  * Capture "Create New..." attributes, create field in Bronto, and save field id
 
407
  * @param array $attributesFields
408
  * @param string $section
409
  * @param string $group
 
410
  * @return array
411
  */
412
  protected function _processDynamicAttributes($attributesFields = array(), $section, $group)
@@ -423,10 +546,15 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
423
  // Cycle Through Attribute Fields to Find and Save Dynamic Fields
424
  foreach ($attributesFields as $fieldId => $field) {
425
  // Save Dynamic 'Create New...' Fields
426
- if (preg_match('/dynamic_new_/', $fieldId)) {
427
- // Strip off 'dynamic_new_' from Field ID to Get real Field ID
428
- $realField = str_replace('dynamic_new_', '', $fieldId);
429
- $value = $field['value'];
 
 
 
 
 
430
 
431
  if (is_null($value)) {
432
  continue;
@@ -434,7 +562,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
434
 
435
  try {
436
  /* @var $fieldObject Bronto_Api_Field */
437
- $fieldObject = Mage::helper('bronto_common')->getApi()->getFieldObject();
438
  $brontoField = $fieldObject->createRow();
439
  $brontoField->name = $fieldObject->normalize($value);
440
  $brontoField->label = $value;
@@ -450,10 +578,10 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
450
 
451
  // Save Field To Config
452
  $config->saveConfig(
453
- $section.'/'.$group.'/'.$realField,
454
  $brontoField->id,
455
  $scope,
456
- $scopeParams[$scopeParams['scope'].'_id']
457
  );
458
 
459
  // Unset Dynamic Fields
@@ -463,9 +591,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
463
  } catch (Exception $e) {
464
  Mage::helper('bronto_customer')->writeError("Unable to save new field: {$value}");
465
  }
466
- }
467
-
468
- // Save Dynamic Fields
469
  elseif (!in_array($fieldId, $ignore[$group])) {
470
  $scope = $scopeParams['scope'];
471
  if ($scope != 'default') {
@@ -474,10 +600,10 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
474
 
475
  // Save Field To Config
476
  $config->saveConfig(
477
- $section.'/'.$group.'/'.$fieldId,
478
  $field['value'],
479
  $scope,
480
- $scopeParams[$scopeParams['scope'].'_id']
481
  );
482
 
483
  // Unset Dynamic Field
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
8
  {
10
 
11
  /**
12
  * Observes module becoming enabled and displays message warning user to configure settings
13
+ *
14
  * @param Varien_Event_Observer $observer
15
  */
16
  public function watchEnableAction(Varien_Event_Observer $observer)
20
 
21
  /**
22
  * @param mixed $storeId
23
+ * @param int $limit
24
  *
25
  * @return array
26
  */
28
  {
29
  if (!$limit) {
30
  Mage::helper('bronto_customer')->writeDebug(' Limit empty. Skipping...');
31
+
32
  return false;
33
  }
34
 
35
+ /** @var Mage_Core_Model_Store $store */
36
+ $store = Mage::app()->getStore($storeId);
37
  $storeId = $store->getId();
38
 
39
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
41
 
42
  if (!$store->getConfig(Bronto_Customer_Helper_Data::XML_PATH_ENABLED)) {
43
  Mage::helper('bronto_customer')->writeDebug(' Module disabled for this store. Skipping...');
44
+
45
  return false;
46
  }
47
 
48
  // Retrieve Store's configured API Token
49
  $token = $store->getConfig(Bronto_Common_Helper_Data::XML_PATH_API_TOKEN);
50
 
51
+ /** @var Bronto_Common_Model_Api $api */
52
  $api = Mage::helper('bronto_customer')->getApi($token);
53
 
54
+ /** @var Bronto_Api_Contact $contactObject */
55
  $contactObject = $api->getContactObject();
56
 
57
  // Get all customers in queue who haven't been imported into bronto
66
 
67
  if (empty($customerRows)) {
68
  Mage::helper('bronto_customer')->writeVerboseDebug(' No Customers to process. Skipping...');
69
+
70
  return $result;
71
  }
72
 
73
+ /** @var Mage_Customer_Model_Entity_Attribute_Collection $customerAttributes */
74
  $customerAttributes = Mage::getModel('customer/entity_attribute_collection');
75
+ /** @var Mage_Customer_Model_Entity_Address_Attribute_Collection $addressAttributes */
76
  $addressAttributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
77
+ $customerCache = array();
78
 
79
  // For each Customer...
80
  foreach ($customerRows as $customerRow) {
83
  Mage::helper('bronto_customer')->writeDebug(" Processing Customer ID: {$customerId} for Store ID: {$storeId}");
84
  $customerCache[] = array('customerId' => $customerId, 'storeId' => $storeId);
85
 
86
+ /** @var Bronto_Api_Contact_Row $brontoContact */
87
+ $brontoContact = $contactObject->createRow(array());
88
  $brontoContact->email = $customer->getEmail();
89
 
90
  /* Process Customer Attributes */
91
  try {
92
  $brontoContact = $this->_processAttributes($brontoContact, $customer, $customerAttributes, $store, 'customer');
93
+ $brontoContact = $this->_processRewardPoints($brontoContact, $customer, $store);
94
+ $brontoContact = $this->_processStoreCredit($brontoContact, $customer, $store);
95
 
96
  /* Process Address Attributes */
97
  $primaryAddress = $customer->getPrimaryShippingAddress();
101
 
102
  $brontoContact->persist();
103
  } catch (Exception $e) {
104
+ Mage::helper('bronto_customer')->writeError($e);
105
  }
106
 
107
+ $result['total']++;
108
  try {
109
+ // Flush every 100 Customers
 
 
 
 
110
  if ($result['total'] % 100 === 0) {
111
+ $result = $this->_flushCustomers($contactObject, $customerCache, $result);
112
  $customerCache = array();
113
  }
114
  } catch (Exception $e) {
115
  Mage::helper('bronto_customer')->writeError($e);
116
 
117
  // Mark Customer as *not* imported
118
+ $customerRow->setBrontoImported(null)
119
+ ->save();
 
120
 
121
  $result['error']++;
122
  }
 
 
123
  }
124
  }
125
 
126
  // Final flush (for any we miss)
127
+ if (!empty($customerCache)) {
128
+ $results = $this->_flushCustomers($contactObject, $customerCache, $result);
129
+ }
130
 
131
  Mage::helper('bronto_customer')->writeDebug(' Success: ' . $results['success']);
132
  Mage::helper('bronto_customer')->writeDebug(' Error: ' . $results['error']);
135
  return $results;
136
  }
137
 
138
+ /**
139
+ * @param Bronto_Api_Contact_Row $brontoContact
140
+ * @param Mage_Customer_Model_Customer $customer
141
+ * @param Mage_Core_Model_Store $store
142
+ *
143
+ * @return Bronto_Api_Contact_Row
144
+ */
145
+ protected function _processRewardPoints(Bronto_Api_Contact_Row $brontoContact, Mage_Customer_Model_Customer $customer, Mage_Core_Model_Store $store)
146
+ {
147
+ // If Reward Points is installed
148
+ if (Mage::helper('bronto_common')->isModuleInstalled('Enterprise_Reward')) {
149
+ $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField('reward_points', 'store', $store->getId());
150
+
151
+ /** @var Enterprise_Reward_Model_Reward $reward */
152
+ $reward = Mage::getModel('enterprise_reward/reward')->setCustomerId($customer->getId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
153
+ $_attributeValue = $reward->getPointsBalance();
154
+
155
+ // Skip un-mapped or empty attributes
156
+ if (empty($_fieldName) || '_none_' == $_fieldName || !$_attributeValue || '' == $_attributeValue) {
157
+ return $brontoContact;
158
+ }
159
+
160
+ // Add Formatted Currency Amount to value
161
+ if ($reward->getCurrencyAmount() > 0) {
162
+ $formattedValue = $reward->getFormatedCurrencyAmount();
163
+ $_attributeValue .= " ({$formattedValue})";
164
+ }
165
+
166
+ // Store Bronto Key => Magento field label for errors
167
+ if (!array_key_exists($_fieldName, $this->_fieldMap)) {
168
+ $this->_fieldMap[$_fieldName] = 'Reward Points';
169
+ }
170
+
171
+ $brontoContact->setField($_fieldName, $_attributeValue);
172
+ }
173
+
174
+ return $brontoContact;
175
+ }
176
+
177
+ /**
178
+ * @param Bronto_Api_Contact_Row $brontoContact
179
+ * @param Mage_Customer_Model_Customer $customer
180
+ * @param Mage_Core_Model_Store $store
181
+ *
182
+ * @return Bronto_Api_Contact_Row
183
+ */
184
+ protected function _processStoreCredit(Bronto_Api_Contact_Row $brontoContact, Mage_Customer_Model_Customer $customer, Mage_Core_Model_Store $store)
185
+ {
186
+ // If Store Credit is installed
187
+ if (Mage::helper('bronto_common')->isModuleInstalled('Enterprise_CustomerBalance')) {
188
+ $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField('store_credit', 'store', $store->getId());
189
+
190
+ /** @var Enterprise_CustomerBalance_Model_Balance $balance */
191
+ $balance = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($customer->getId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
192
+ $_attributeValue = Mage::app()->getLocale()->currency($balance->getWebsiteCurrencyCode())
193
+ ->toCurrency($balance->getAmount());
194
+
195
+ // Skip un-mapped or empty attributes
196
+ if (empty($_fieldName) || '_none_' == $_fieldName || !$_attributeValue || '' == $_attributeValue) {
197
+ return $brontoContact;
198
+ }
199
+
200
+ // Store Bronto Key => Magento field label for errors
201
+ if (!array_key_exists($_fieldName, $this->_fieldMap)) {
202
+ $this->_fieldMap[$_fieldName] = 'Store Credit';
203
+ }
204
+
205
+ $brontoContact->setField($_fieldName, $_attributeValue);
206
+ }
207
+
208
+ return $brontoContact;
209
+ }
210
+
211
  /**
212
  * Cycle through attributes and validate against Bronto Field type
213
+ *
214
  * @param Bronto_Api_Contact_Row $brontoContact
215
+ * @param $source
216
+ * @param $attributes
217
+ * @param Mage_Core_Model_Store $store
218
+ * @param string $type 'customer' or 'address'
219
+ *
220
  * @return Bronto_Api_Contact_Row
221
  */
222
  protected function _processAttributes(Bronto_Api_Contact_Row $brontoContact, $source, $attributes, Mage_Core_Model_Store $store, $type = 'customer')
231
  // Get Attribute Field
232
  switch ($type) {
233
  case 'address':
234
+ $_fieldName = Mage::helper('bronto_customer')->getAddressAttributeField($_attributeCode, 'store', $store->getId());
235
  break;
236
  default:
237
+ $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, 'store', $store->getId());
238
  break;
239
  }
240
 
259
 
260
  /**
261
  * Based on attribute type, pull the value or the label
262
+ *
263
+ * @param string $attribute
264
+ * @param mixed $value
265
+ *
266
+ * @return mixed
267
  */
268
  protected function _getReadableValue($attribute, $value)
269
  {
278
  switch ($_attributeCode) {
279
  case 'website_id':
280
  $websiteModel = Mage::getModel('core/website')->load($value);
281
+
282
  return $websiteModel->getName();
283
  break;
284
  case 'store_id':
285
  $storeModel = Mage::getModel('core/store')->load($value);
286
+
287
  return $storeModel->getName();
288
  break;
289
  case 'group_id':
290
  $groupModel = Mage::getModel('customer/group')->load($value);
291
+
292
  return $groupModel->getCode();
293
  break;
294
  case 'country_id':
295
  $countryModel = Mage::getModel('directory/country')->load($value);
296
+
297
  return $countryModel->getName();
298
  break;
299
  default:
308
  break;
309
  case 'multiselect':
310
  $values = array();
311
+ if (!is_array($value)) {
312
+ $value = explode(',', $value);
313
+ }
314
+ if (!is_array($value)) {
315
+ $value = array($value);
316
+ }
317
+
318
  foreach ($value as $val) {
319
  $values[] = strtolower(Mage::helper('bronto_customer')->getAttributeAdminLabel($attribute, $val));
320
  }
321
+
322
+ return implode(', ', $values);
323
  break;
324
  case 'date':
325
  $dates = explode(' ', $value);
338
  }
339
 
340
  /**
341
+ * @param Bronto_Api_Contact $customerObject
342
+ * @param array $customerCache
343
+ * @param array $result
344
  *
345
  * @return array
346
  */
348
  {
349
  $fieldModel = Mage::getModel('bronto_common/system_config_source_field');
350
  $flushResult = $customerObject->flush();
351
+ $flushCount = count($flushResult);
352
+ Mage::helper('bronto_customer')->writeDebug(" Flush resulted in {$flushCount} customers processed");
353
  Mage::helper('bronto_customer')->writeVerboseDebug('===== FLUSH =====', 'bronto_customer_api.log');
354
  Mage::helper('bronto_customer')->writeVerboseDebug(var_export($customerObject->getApi()->getLastRequest(), true), 'bronto_customer_api.log');
355
  Mage::helper('bronto_customer')->writeVerboseDebug(var_export($customerObject->getApi()->getLastResponse(), true), 'bronto_customer_api.log');
 
356
  foreach ($flushResult as $i => $flushResultRow) {
357
  if ($flushResultRow->hasError()) {
358
+ $hasError = true;
359
+ $errorCode = $flushResultRow->getErrorCode();
360
  $errorMessage = $flushResultRow->getErrorMessage();
361
+ } else {
362
+ $hasError = false;
363
+ $errorCode = false;
364
+ $errorMessage = false;
365
+ }
366
+
367
+ if (isset($customerCache[$i])) {
368
+ // Get Customer Object
369
+ $customer = Mage::getModel('customer/customer')->load($customerCache[$i]['customerId']);
370
+ $store = Mage::getModel('core/store')->load($customerCache[$i]['storeId']);
371
+ $website = Mage::getModel('core/website')->load($store->getWebsiteId());
372
+ $storeMessage = "For `{$website->getName()}`:`{$store->getName()}`: ";
373
+
374
+ $customerRow = Mage::getModel('bronto_customer/queue')
375
+ ->getCustomerRow($customerCache[$i]['customerId'], $customerCache[$i]['storeId']);
376
+ } else {
377
+ if ($hasError) {
378
+ Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$errorMessage}");
379
+ $result['error']++;
380
+ }
381
 
382
+ continue;
383
+ }
384
+
385
+ if ($hasError) {
386
  // Catch Error and Replace Field ID with Field Name
387
  if (preg_match_all("/([a-zA-Z0-9\-]){36}/", $errorMessage, $matches)) { // Grab field id if exists
388
  foreach ($matches[0] as $match) {
390
  if ($fieldObject) {
391
  $errorMessage = str_replace($match, $fieldObject->name, $errorMessage);
392
  } elseif (array_key_exists($match, $this->_fieldMap)) {
393
+ $mageLabel = $this->_fieldMap[$match];
394
  $errorMessage = "Bronto field mapped for {$mageLabel} no longer exists in your bronto account";
395
  }
396
  }
397
  }
398
 
399
+ // If Error Code In specified Array, suppress contact
400
+ if (in_array($errorCode, array(302, 303, 314, 315, 317))) {
401
+ $customerRow->setBrontoSuppressed($errorMessage);
402
+ }
 
 
 
 
 
 
 
 
 
 
 
403
 
404
+ Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$storeMessage}{$errorMessage} ({$customer->getEmail()})");
405
 
406
+ // Mark Customer as not imported
407
+ $customerRow->setBrontoImported(null);
408
+ $customerRow->save();
 
409
  $result['error']++;
410
  } else {
411
+ Mage::helper('bronto_customer')->writeDebug(" {$customerCache[$i]['customerId']} = SUCCESS");
412
+
413
+ // Mark Customer as imported
414
+ $customerRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
415
+ $customerRow->save();
416
  $result['success']++;
417
  }
418
  }
421
  }
422
 
423
  /**
424
+ * @param bool $brontoCron
425
+ *
426
  * @return array
427
  */
428
+ public function processCustomers($brontoCron = false)
429
  {
430
  $result = array(
431
+ 'total' => 0,
432
  'success' => 0,
433
+ 'error' => 0,
434
  );
435
 
436
+ // Only allow cron to run if isset to use mage cron or is coming from bronto cron
437
+ if (Mage::helper('bronto_customer')->canUseMageCron() || $brontoCron) {
438
+ $limit = Mage::helper('bronto_customer')->getLimit();
439
 
440
+ $stores = Mage::app()->getStores(true);
441
+ foreach ($stores as $_store) {
442
+ if ($limit <= 0) {
443
+ continue;
444
+ }
445
+ $storeResult = $this->processCustomersForStore($_store, $limit);
446
+ $result['total'] += $storeResult['total'];
447
+ $result['success'] += $storeResult['success'];
448
+ $result['error'] += $storeResult['error'];
449
+ $limit = $limit - $storeResult['total'];
450
  }
 
 
 
 
 
451
  }
452
 
453
  return $result;
474
  /**
475
  * Grab Config Data Object before save and handle the 'Create New...' value for
476
  * fields that were generated dynamically
477
+ *
478
  * @param Varien_Event_Observer $observer
479
+ *
480
  * @return Varien_Event_Observer
481
  */
482
  public function saveDynamicField(Varien_Event_Observer $observer)
499
 
500
  /**
501
  * Process customer and address attributes and save back to observer
502
+ *
503
  * @param array $groups
504
  * @param string $section
505
+ *
506
  * @return array
507
  */
508
  protected function _handleDynamicAttributes($groups, $section)
509
  {
510
  // Process Dynamic Customer Attribute Fields
511
  if (array_key_exists('attributes', $groups)) {
512
+ $attrFieldsCustomer = $this->_processDynamicAttributes($groups['attributes']['fields'], $section, 'attributes');
513
  $groups['attributes']['fields'] = $attrFieldsCustomer;
514
  }
515
 
516
  // Process Dynamic Address Attribute Fields
517
  if (array_key_exists('address_attributes', $groups)) {
518
+ $attrFieldsAddress = $this->_processDynamicAttributes($groups['address_attributes']['fields'], $section, 'address_attributes');
519
  $groups['address_attributes']['fields'] = $attrFieldsAddress;
520
  }
521
 
525
 
526
  /**
527
  * Capture "Create New..." attributes, create field in Bronto, and save field id
528
+ *
529
  * @param array $attributesFields
530
  * @param string $section
531
  * @param string $group
532
+ *
533
  * @return array
534
  */
535
  protected function _processDynamicAttributes($attributesFields = array(), $section, $group)
546
  // Cycle Through Attribute Fields to Find and Save Dynamic Fields
547
  foreach ($attributesFields as $fieldId => $field) {
548
  // Save Dynamic 'Create New...' Fields
549
+ if (preg_match('/_dynamic_new/', $fieldId) || preg_match('/_new/', $fieldId)) {
550
+ // Strip off '_dynamic_new' or '_new' from Field ID to Get real Field ID
551
+ $realField = preg_replace('/_dynamic_new|_new$/', '', $fieldId);
552
+
553
+ if (!is_array($field)) {
554
+ $value = $field;
555
+ } else {
556
+ $value = $field['value'];
557
+ }
558
 
559
  if (is_null($value)) {
560
  continue;
562
 
563
  try {
564
  /* @var $fieldObject Bronto_Api_Field */
565
+ $fieldObject = Mage::helper('bronto_common')->getApi()->getFieldObject();
566
  $brontoField = $fieldObject->createRow();
567
  $brontoField->name = $fieldObject->normalize($value);
568
  $brontoField->label = $value;
578
 
579
  // Save Field To Config
580
  $config->saveConfig(
581
+ $section . '/' . $group . '/' . $realField,
582
  $brontoField->id,
583
  $scope,
584
+ $scopeParams[$scopeParams['scope'] . '_id']
585
  );
586
 
587
  // Unset Dynamic Fields
591
  } catch (Exception $e) {
592
  Mage::helper('bronto_customer')->writeError("Unable to save new field: {$value}");
593
  }
594
+ } // Save Dynamic Fields
 
 
595
  elseif (!in_array($fieldId, $ignore[$group])) {
596
  $scope = $scopeParams['scope'];
597
  if ($scope != 'default') {
600
 
601
  // Save Field To Config
602
  $config->saveConfig(
603
+ $section . '/' . $group . '/' . $fieldId,
604
  $field['value'],
605
  $scope,
606
+ $scopeParams[$scopeParams['scope'] . '_id']
607
  );
608
 
609
  // Unset Dynamic Field
app/code/community/Bronto/Customer/Model/Queue.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.0.2
7
  */
8
  class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
9
  {
@@ -15,8 +14,10 @@ class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
15
 
16
  /**
17
  * Retrieve Customer Queue Row
 
18
  * @param int $customerId
19
  * @param int $storeId
 
20
  * @return Bronto_Customer_Model_Queue
21
  */
22
  public function getCustomerRow($customerId, $storeId)
@@ -39,13 +40,14 @@ class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
39
 
40
  /**
41
  * Get Count of missing customers
 
42
  * @return int
43
  */
44
  public function getMissingCustomersCount()
45
  {
46
  // Get Resources
47
  $resource = $this->getResource();
48
- $adapter = $resource->getWriteAdapter();
49
 
50
  // Build Select Statement
51
  $select = $adapter->select();
@@ -59,16 +61,16 @@ class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
59
  $result = $adapter->query($select)->fetch();
60
 
61
  if (array_key_exists('count', $result)) {
62
- return (int) $result['count'];
63
  } else {
64
  return 0;
65
  }
66
  }
67
 
68
  /**
69
- * Get Sub-Select Statement that limits results
70
  * @param Bronto_Customer_Model_Mysql4_Queue $resource
71
- * @param type $adapter
 
72
  * @return Varien_Db_Select
73
  */
74
  private function _getSubselect($resource, $adapter)
@@ -86,13 +88,14 @@ class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
86
 
87
  /**
88
  * Get collection of customers which aren't already in the queue, but should be
 
89
  * @return array
90
  */
91
  public function getMissingCustomers()
92
  {
93
  // Get Resources
94
  $resource = $this->getResource();
95
- $adapter = $resource->getWriteAdapter();
96
 
97
  // Get Sync Limit Value
98
  $count = Mage::helper('bronto_customer')->getSyncLimit();
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
8
  {
14
 
15
  /**
16
  * Retrieve Customer Queue Row
17
+ *
18
  * @param int $customerId
19
  * @param int $storeId
20
+ *
21
  * @return Bronto_Customer_Model_Queue
22
  */
23
  public function getCustomerRow($customerId, $storeId)
40
 
41
  /**
42
  * Get Count of missing customers
43
+ *
44
  * @return int
45
  */
46
  public function getMissingCustomersCount()
47
  {
48
  // Get Resources
49
  $resource = $this->getResource();
50
+ $adapter = $resource->getWriteAdapter();
51
 
52
  // Build Select Statement
53
  $select = $adapter->select();
61
  $result = $adapter->query($select)->fetch();
62
 
63
  if (array_key_exists('count', $result)) {
64
+ return (int)$result['count'];
65
  } else {
66
  return 0;
67
  }
68
  }
69
 
70
  /**
 
71
  * @param Bronto_Customer_Model_Mysql4_Queue $resource
72
+ * @param $adapter
73
+ *
74
  * @return Varien_Db_Select
75
  */
76
  private function _getSubselect($resource, $adapter)
88
 
89
  /**
90
  * Get collection of customers which aren't already in the queue, but should be
91
+ *
92
  * @return array
93
  */
94
  public function getMissingCustomers()
95
  {
96
  // Get Resources
97
  $resource = $this->getResource();
98
+ $adapter = $resource->getWriteAdapter();
99
 
100
  // Get Sync Limit Value
101
  $count = Mage::helper('bronto_customer')->getSyncLimit();
app/code/community/Bronto/Customer/Model/System/Config/Backend/Brontofield.php CHANGED
@@ -13,6 +13,11 @@ class Bronto_Customer_Model_System_Config_Backend_Brontofield extends Mage_Core_
13
  */
14
  protected function _beforeSave()
15
  {
 
 
 
 
 
16
  /* @var $fieldObject Bronto_Api_Field */
17
  $fieldObject = Mage::getModel('bronto_common/system_config_source_field')->getFieldObjectById($this->getValue());
18
 
@@ -23,6 +28,7 @@ class Bronto_Customer_Model_System_Config_Backend_Brontofield extends Mage_Core_
23
  $attributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
24
  }
25
 
 
26
  if ($attributes) {
27
  foreach ($attributes as $attribute) {
28
  if ($this->field == $attribute->attribute_code) {
@@ -39,13 +45,16 @@ class Bronto_Customer_Model_System_Config_Backend_Brontofield extends Mage_Core_
39
  }
40
  }
41
 
 
 
42
  return parent::_beforeSave();
43
  }
44
 
45
  /**
46
- * @param type $path
47
- * @param type $value
48
- * @return Bronto_Customer_Model_System_Config_Backend_Brontofield
 
49
  */
50
  protected function _saveConfigData($path, $value)
51
  {
13
  */
14
  protected function _beforeSave()
15
  {
16
+ //if ($this->isValueChanged()) {
17
+ if ($this->field == 'reward_points' || $this->field == 'store_credit') {
18
+ Mage::throwException($this->getValue());
19
+ }
20
+
21
  /* @var $fieldObject Bronto_Api_Field */
22
  $fieldObject = Mage::getModel('bronto_common/system_config_source_field')->getFieldObjectById($this->getValue());
23
 
28
  $attributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
29
  }
30
 
31
+
32
  if ($attributes) {
33
  foreach ($attributes as $attribute) {
34
  if ($this->field == $attribute->attribute_code) {
45
  }
46
  }
47
 
48
+ //}
49
+
50
  return parent::_beforeSave();
51
  }
52
 
53
  /**
54
+ * @param $path
55
+ * @param $value
56
+ *
57
+ * @return $this
58
  */
59
  protected function _saveConfigData($path, $value)
60
  {
app/code/community/Bronto/Customer/Model/System/Config/Backend/Cron.php CHANGED
@@ -8,4 +8,20 @@ class Bronto_Customer_Model_System_Config_Backend_Cron extends Bronto_Common_Mod
8
  {
9
  protected $_cron_string_path = 'crontab/jobs/bronto_customer_import/schedule/cron_expr';
10
  protected $_cron_model_path = 'crontab/jobs/bronto_customer_import/run/model';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
8
  {
9
  protected $_cron_string_path = 'crontab/jobs/bronto_customer_import/schedule/cron_expr';
10
  protected $_cron_model_path = 'crontab/jobs/bronto_customer_import/run/model';
11
+
12
+ /**
13
+ * @return string
14
+ */
15
+ public function getCronStringPath()
16
+ {
17
+ return Mage::helper('bronto_customer')->getCronStringPath();
18
+ }
19
+
20
+ /**
21
+ * @return string
22
+ */
23
+ public function getCronModelPath()
24
+ {
25
+ return Mage::helper('bronto_customer')->getCronModelPath();
26
+ }
27
  }
app/code/community/Bronto/Customer/Model/System/Config/Backend/Newfield.php CHANGED
@@ -18,15 +18,14 @@ class Bronto_Customer_Model_System_Config_Backend_Newfield extends Mage_Core_Mod
18
  /* @var $fieldObject Bronto_Api_Field */
19
  $fieldObject = Mage::helper('bronto_common')->getApi()->getFieldObject();
20
 
21
- $field = $fieldObject->createRow();
22
- $field->name = $fieldObject->normalize($this->getValue());
23
  $field->label = $this->getValue();
24
- $field->type = Bronto_Api_Field::TYPE_TEXT;
25
 
26
  $field->save();
27
  $fieldObject->addToCache($field->name, $field);
28
-
29
- $this->_saveConfigData(str_replace('new_', '', $this->getPath()), $field->id);
30
  $this->setValue(null);
31
  } catch (Exception $e) {
32
  Mage::throwException(Mage::helper('adminhtml')->__('Unable to save new field: ') . $e->getMessage());
@@ -37,9 +36,12 @@ class Bronto_Customer_Model_System_Config_Backend_Newfield extends Mage_Core_Mod
37
  }
38
 
39
  /**
40
- * @param type $path
41
- * @param type $value
42
- * @return Bronto_Customer_Model_System_Config_Backend_Newfield
 
 
 
43
  */
44
  protected function _saveConfigData($path, $value)
45
  {
@@ -55,7 +57,7 @@ class Bronto_Customer_Model_System_Config_Backend_Newfield extends Mage_Core_Mod
55
  ->setValue($value)
56
  ->setPath($path)
57
  ->setScope($scope)
58
- ->setScopeId($scopeParams[$scopeParams['scope'].'_id'])
59
  ->save();
60
 
61
  return $this;
18
  /* @var $fieldObject Bronto_Api_Field */
19
  $fieldObject = Mage::helper('bronto_common')->getApi()->getFieldObject();
20
 
21
+ $field = $fieldObject->createRow();
22
+ $field->name = $fieldObject->normalize($this->getValue());
23
  $field->label = $this->getValue();
24
+ $field->type = Bronto_Api_Field::TYPE_TEXT;
25
 
26
  $field->save();
27
  $fieldObject->addToCache($field->name, $field);
28
+ $this->_saveConfigData(str_replace('_new', '', $this->getPath()), $field->id);
 
29
  $this->setValue(null);
30
  } catch (Exception $e) {
31
  Mage::throwException(Mage::helper('adminhtml')->__('Unable to save new field: ') . $e->getMessage());
36
  }
37
 
38
  /**
39
+ * Save Configuration Data
40
+ *
41
+ * @param $path
42
+ * @param $value
43
+ *
44
+ * @return $this
45
  */
46
  protected function _saveConfigData($path, $value)
47
  {
57
  ->setValue($value)
58
  ->setPath($path)
59
  ->setScope($scope)
60
+ ->setScopeId($scopeParams[$scopeParams['scope'] . '_id'])
61
  ->save();
62
 
63
  return $this;
app/code/community/Bronto/Customer/controllers/Adminhtml/CustomerController.php CHANGED
@@ -12,9 +12,9 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
12
  public function runAction()
13
  {
14
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
15
- $model = Mage::getModel('bronto_customer/observer');
16
  $helper = Mage::helper('bronto_customer');
17
- $limit = $helper->getLimit();
18
 
19
  try {
20
  if ($storeIds = $helper->getStoreIds()) {
@@ -32,7 +32,7 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
32
  $limit = $limit - $storeResult['total'];
33
  }
34
  } else {
35
- $result = $model->processCustomers();
36
  }
37
 
38
  if (is_array($result)) {
@@ -56,21 +56,27 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
56
  */
57
  public function resetAction()
58
  {
59
- $helper = Mage::helper('bronto_customer');
60
  $storeIds = $helper->getStoreIds();
61
  $resource = Mage::getResourceModel('bronto_customer/queue');
62
- $adapter = $resource->getWriteAdapter();
 
 
63
 
64
  $where = array();
65
  if ($storeIds) {
66
  $where = array('store_id IN (?)' => $storeIds);
67
  }
68
 
 
 
 
 
69
  try {
70
  $adapter->update(
71
  $resource->getTable('bronto_customer/queue'),
72
  array(
73
- 'bronto_imported' => null,
74
  'bronto_suppressed' => null,
75
  ),
76
  $where
@@ -90,12 +96,12 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
90
  */
91
  public function syncAction()
92
  {
93
- $helper = Mage::helper('bronto_customer');
94
  $imported = 0;
95
 
96
  try {
97
  $customers = Mage::helper('bronto_customer')->getMissingCustomers();
98
- $waiting = count($customers);
99
 
100
  if ($waiting > 0) {
101
  foreach ($customers as $customer) {
@@ -119,6 +125,102 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
119
  $this->_redirect('*/system_config/edit', $returnParams);
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  /**
123
  * @return bool
124
  */
@@ -133,28 +235,34 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
133
  * Will forward to deniedAction(), if not allowed.
134
  *
135
  * @param string $section
 
136
  * @return bool
137
  */
138
  protected function _isSectionAllowed($section)
139
  {
140
  try {
141
- $session = Mage::getSingleton('admin/session');
142
  $resourceLookup = "admin/system/config/{$section}";
143
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
144
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
145
  if (!$session->isAllowed($resourceId)) {
146
  throw new Exception('');
147
  }
 
148
  return true;
149
  }
150
  } catch (Zend_Acl_Exception $e) {
151
  $this->norouteAction();
152
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
153
  return false;
154
  } catch (Exception $e) {
155
  $this->deniedAction();
156
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
157
  return false;
158
  }
 
 
159
  }
160
  }
12
  public function runAction()
13
  {
14
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
15
+ $model = Mage::getModel('bronto_customer/observer');
16
  $helper = Mage::helper('bronto_customer');
17
+ $limit = $helper->getLimit();
18
 
19
  try {
20
  if ($storeIds = $helper->getStoreIds()) {
32
  $limit = $limit - $storeResult['total'];
33
  }
34
  } else {
35
+ $result = $model->processCustomers(true);
36
  }
37
 
38
  if (is_array($result)) {
56
  */
57
  public function resetAction()
58
  {
59
+ $helper = Mage::helper('bronto_customer');
60
  $storeIds = $helper->getStoreIds();
61
  $resource = Mage::getResourceModel('bronto_customer/queue');
62
+ $adapter = $resource->getWriteAdapter();
63
+
64
+ $queue_id = $this->getRequest()->getParam('queue_id', false);
65
 
66
  $where = array();
67
  if ($storeIds) {
68
  $where = array('store_id IN (?)' => $storeIds);
69
  }
70
 
71
+ if ($queue_id) {
72
+ $where['queue_id = ?'] = $queue_id;
73
+ }
74
+
75
  try {
76
  $adapter->update(
77
  $resource->getTable('bronto_customer/queue'),
78
  array(
79
+ 'bronto_imported' => null,
80
  'bronto_suppressed' => null,
81
  ),
82
  $where
96
  */
97
  public function syncAction()
98
  {
99
+ $helper = Mage::helper('bronto_customer');
100
  $imported = 0;
101
 
102
  try {
103
  $customers = Mage::helper('bronto_customer')->getMissingCustomers();
104
+ $waiting = count($customers);
105
 
106
  if ($waiting > 0) {
107
  foreach ($customers as $customer) {
125
  $this->_redirect('*/system_config/edit', $returnParams);
126
  }
127
 
128
+ /**
129
+ * Action to handle providing suppression table in config page
130
+ */
131
+ public function suppressionAction()
132
+ {
133
+ $request = $this->getRequest();
134
+ $page = $request->getParam('page', 1);
135
+ $limit = 10;
136
+
137
+ // Get Suppressed Items
138
+ $suppressed = array();
139
+ $collection = Mage::getModel('bronto_customer/queue')->getCollection()
140
+ ->addBrontoSuppressedFilter()
141
+ ->addStoreFilter(Mage::helper('bronto_common')->getStoreIds())
142
+ ->orderByUpdatedAt()
143
+ ->setPageSize($limit)
144
+ ->setCurPage($page);
145
+
146
+ $items = $collection->getItems();
147
+ foreach ($items as $item) {
148
+ $customerName = Mage::getModel('customer/customer')->load($item->getCustomerId())->getName();
149
+ $customerEmail = Mage::getModel('customer/customer')->load($item->getCustomerId())->getEmail();
150
+ $customerLink = Mage::helper('bronto_common')->getScopeUrl('/customer/edit/', array('id' => $item->getCustomerId()));
151
+ $storeName = Mage::getModel('core/store')->load($item->getStoreId())->getName();
152
+ $resetLink = Mage::helper('bronto_common')->getScopeUrl('adminhtml/customer/reset', array('queue_id' => $item->getId()));
153
+ $suppressed[] = array(
154
+ 'updated_at' => $item->getUpdatedAt(),
155
+ 'customer' => "<a href=\"{$customerLink}\">{$customerName}</a>",
156
+ 'email' => $customerEmail,
157
+ 'store_id' => $storeName,
158
+ 'reason' => $item->getBrontoSuppressed(),
159
+ 'action' => "<a href=\"{$resetLink}\">Reset</a>",
160
+ );
161
+ }
162
+
163
+ $prevPage = ($page > 1) ? $page - 1 : false;
164
+
165
+ $remaining = $collection->getSize() - ($limit * $page);
166
+ $nextPage = ($remaining > 0) ? $page + 1 : false;
167
+
168
+ $html = $this->_getSuppressionTableHtml($suppressed, $prevPage, $nextPage);
169
+
170
+ $this->getResponse()->setBody($html);
171
+ }
172
+
173
+ /**
174
+ * Get HTML table for suppression items
175
+ *
176
+ * @param $suppressedItems
177
+ * @param $prevPage
178
+ * @param $nextPage
179
+ *
180
+ * @return string
181
+ */
182
+ protected function _getSuppressionTableHtml($suppressedItems, $prevPage, $nextPage)
183
+ {
184
+ $html = '';
185
+ if ($prevPage) {
186
+ $html .= '<div class="bronto-suppression-interface-control previous" onclick="loadSuppressionTable(' . $prevPage . ')">Load Newer</div>';
187
+ }
188
+ $html .= '
189
+ <table class="border">
190
+ <thead>
191
+ <tr class="headings">
192
+ <th style="white-space: nowrap">Date Suppressed</th>
193
+ <th style="white-space: nowrap">Customer</th>
194
+ <th style="white-space: nowrap">Customer Email</th>
195
+ <th style="white-space: nowrap">Store</th>
196
+ <th width="100%">Reason for Suppression</th>
197
+ <th style="white-space: nowrap">Action</th>
198
+ </tr>
199
+ </thead>
200
+ <tbody>';
201
+
202
+ if (count($suppressedItems)) {
203
+ foreach ($suppressedItems as $suppressed) {
204
+ $html .= '<tr>';
205
+ foreach ($suppressed as $value) {
206
+ $html .= "<td style=\"white-space: nowrap\">{$value}</td>";
207
+ }
208
+ $html .= '</tr>';
209
+ }
210
+ } else {
211
+ $html .= '<tr><td colspan="6"><strong>No Suppressed Items</strong></td></tr>';
212
+ }
213
+
214
+ $html .= '
215
+ </tbody>
216
+ </table>';
217
+ if ($nextPage) {
218
+ $html .= '<div class="bronto-suppression-interface-control next" onclick="loadSuppressionTable(' . $nextPage . ')">Load Older</div>';
219
+ }
220
+
221
+ return $html;
222
+ }
223
+
224
  /**
225
  * @return bool
226
  */
235
  * Will forward to deniedAction(), if not allowed.
236
  *
237
  * @param string $section
238
+ *
239
  * @return bool
240
  */
241
  protected function _isSectionAllowed($section)
242
  {
243
  try {
244
+ $session = Mage::getSingleton('admin/session');
245
  $resourceLookup = "admin/system/config/{$section}";
246
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
247
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
248
  if (!$session->isAllowed($resourceId)) {
249
  throw new Exception('');
250
  }
251
+
252
  return true;
253
  }
254
  } catch (Zend_Acl_Exception $e) {
255
  $this->norouteAction();
256
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
257
+
258
  return false;
259
  } catch (Exception $e) {
260
  $this->deniedAction();
261
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
262
+
263
  return false;
264
  }
265
+
266
+ return false;
267
  }
268
  }
app/code/community/Bronto/Customer/etc/config.xml CHANGED
@@ -105,6 +105,7 @@
105
  <bronto_customer>
106
  <settings>
107
  <enabled>0</enabled>
 
108
  <frequency>D</frequency>
109
  <interval>15</interval>
110
  <minutes>0</minutes>
105
  <bronto_customer>
106
  <settings>
107
  <enabled>0</enabled>
108
+ <mage_cron>1</mage_cron>
109
  <frequency>D</frequency>
110
  <interval>15</interval>
111
  <minutes>0</minutes>
app/code/community/Bronto/Customer/etc/system.xml CHANGED
@@ -38,10 +38,27 @@
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </enabled>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  <frequency>
42
  <label>Frequency</label>
43
  <depends>
44
  <enabled>1</enabled>
 
45
  </depends>
46
  <frontend_type>select</frontend_type>
47
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
@@ -55,6 +72,7 @@
55
  <label>Interval</label>
56
  <depends>
57
  <frequency>I</frequency>
 
58
  </depends>
59
  <frontend_type>select</frontend_type>
60
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
@@ -68,6 +86,7 @@
68
  <label>Minute of the Hour</label>
69
  <depends>
70
  <frequency>H</frequency>
 
71
  </depends>
72
  <frontend_type>text</frontend_type>
73
  <sort_order>40</sort_order>
@@ -80,13 +99,13 @@
80
  <label>Start Time</label>
81
  <depends>
82
  <enabled>1</enabled>
 
83
  </depends>
84
  <frontend_type>time</frontend_type>
85
  <sort_order>50</sort_order>
86
  <show_in_default>1</show_in_default>
87
  <show_in_website>1</show_in_website>
88
  <show_in_store>1</show_in_store>
89
- <comment>H:m:s (*note: seconds are not used)</comment>
90
  </time>
91
  <limit>
92
  <label>Limit</label>
@@ -99,7 +118,7 @@
99
  <show_in_default>1</show_in_default>
100
  <show_in_website>1</show_in_website>
101
  <show_in_store>1</show_in_store>
102
- <comment>Total Customers to process every cron run.</comment>
103
  </limit>
104
  <sync_limit>
105
  <label>Sync Limit</label>
@@ -124,10 +143,21 @@
124
  <show_in_website>1</show_in_website>
125
  <show_in_store>1</show_in_store>
126
  </cron_list>
 
 
 
 
 
 
 
 
 
 
127
  <attributes>
128
  <label>Customer Attributes</label>
129
  <frontend_type>text</frontend_type>
130
- <frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_customer</frontend_model>
 
131
  <sort_order>10</sort_order>
132
  <show_in_default>1</show_in_default>
133
  <show_in_website>1</show_in_website>
@@ -145,15 +175,17 @@
145
  <show_in_website>1</show_in_website>
146
  <show_in_store>1</show_in_store>
147
  </prefix>
148
- <new_prefix>
149
  <sort_order>2</sort_order>
150
  <frontend_type>text</frontend_type>
151
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
152
  <show_in_default>1</show_in_default>
153
  <show_in_website>1</show_in_website>
154
  <show_in_store>1</show_in_store>
155
- <depends><prefix>_new_</prefix></depends>
156
- </new_prefix>
 
 
157
  <!-- firstname -->
158
  <firstname>
159
  <sort_order>5</sort_order>
@@ -166,15 +198,17 @@
166
  <show_in_website>1</show_in_website>
167
  <show_in_store>1</show_in_store>
168
  </firstname>
169
- <new_firstname>
170
  <sort_order>6</sort_order>
171
  <frontend_type>text</frontend_type>
172
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
173
  <show_in_default>1</show_in_default>
174
  <show_in_website>1</show_in_website>
175
  <show_in_store>1</show_in_store>
176
- <depends><firstname>_new_</firstname></depends>
177
- </new_firstname>
 
 
178
  <!-- middlename -->
179
  <middlename>
180
  <sort_order>10</sort_order>
@@ -187,15 +221,17 @@
187
  <show_in_website>1</show_in_website>
188
  <show_in_store>1</show_in_store>
189
  </middlename>
190
- <new_middlename>
191
  <sort_order>11</sort_order>
192
  <frontend_type>text</frontend_type>
193
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
194
  <show_in_default>1</show_in_default>
195
  <show_in_website>1</show_in_website>
196
  <show_in_store>1</show_in_store>
197
- <depends><middlename>_new_</middlename></depends>
198
- </new_middlename>
 
 
199
  <!-- lastname -->
200
  <lastname>
201
  <sort_order>15</sort_order>
@@ -208,7 +244,7 @@
208
  <show_in_website>1</show_in_website>
209
  <show_in_store>1</show_in_store>
210
  </lastname>
211
- <new_lastname>
212
  <sort_order>16</sort_order>
213
  <frontend_type>text</frontend_type>
214
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -218,7 +254,7 @@
218
  <depends>
219
  <lastname>_new_</lastname>
220
  </depends>
221
- </new_lastname>
222
  <!-- suffix -->
223
  <suffix>
224
  <sort_order>20</sort_order>
@@ -231,7 +267,7 @@
231
  <show_in_website>1</show_in_website>
232
  <show_in_store>1</show_in_store>
233
  </suffix>
234
- <new_suffix>
235
  <sort_order>21</sort_order>
236
  <frontend_type>text</frontend_type>
237
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -241,7 +277,7 @@
241
  <depends>
242
  <suffix>_new_</suffix>
243
  </depends>
244
- </new_suffix>
245
  <!-- gender -->
246
  <gender>
247
  <sort_order>25</sort_order>
@@ -254,7 +290,7 @@
254
  <show_in_website>1</show_in_website>
255
  <show_in_store>1</show_in_store>
256
  </gender>
257
- <new_gender>
258
  <sort_order>26</sort_order>
259
  <frontend_type>text</frontend_type>
260
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -264,7 +300,7 @@
264
  <depends>
265
  <gender>_new_</gender>
266
  </depends>
267
- </new_gender>
268
  <!-- dob -->
269
  <dob>
270
  <sort_order>30</sort_order>
@@ -277,7 +313,7 @@
277
  <show_in_website>1</show_in_website>
278
  <show_in_store>1</show_in_store>
279
  </dob>
280
- <new_dob>
281
  <sort_order>31</sort_order>
282
  <frontend_type>text</frontend_type>
283
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -287,7 +323,7 @@
287
  <depends>
288
  <dob>_new_</dob>
289
  </depends>
290
- </new_dob>
291
  <!-- taxvat -->
292
  <taxvat>
293
  <sort_order>35</sort_order>
@@ -300,7 +336,7 @@
300
  <show_in_website>1</show_in_website>
301
  <show_in_store>1</show_in_store>
302
  </taxvat>
303
- <new_taxvat>
304
  <sort_order>36</sort_order>
305
  <frontend_type>text</frontend_type>
306
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -310,7 +346,7 @@
310
  <depends>
311
  <taxvat>_new_</taxvat>
312
  </depends>
313
- </new_taxvat>
314
  <!-- website_id -->
315
  <website_id>
316
  <sort_order>40</sort_order>
@@ -323,7 +359,7 @@
323
  <show_in_website>1</show_in_website>
324
  <show_in_store>1</show_in_store>
325
  </website_id>
326
- <new_website_id>
327
  <sort_order>41</sort_order>
328
  <frontend_type>text</frontend_type>
329
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -333,7 +369,7 @@
333
  <depends>
334
  <website_id>_new_</website_id>
335
  </depends>
336
- </new_website_id>
337
  <!-- group_id -->
338
  <group_id>
339
  <sort_order>45</sort_order>
@@ -346,7 +382,7 @@
346
  <show_in_website>1</show_in_website>
347
  <show_in_store>1</show_in_store>
348
  </group_id>
349
- <new_group_id>
350
  <sort_order>46</sort_order>
351
  <frontend_type>text</frontend_type>
352
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -356,7 +392,7 @@
356
  <depends>
357
  <group_id>_new_</group_id>
358
  </depends>
359
- </new_group_id>
360
  <!-- created_at -->
361
  <created_at>
362
  <sort_order>50</sort_order>
@@ -369,7 +405,7 @@
369
  <show_in_website>1</show_in_website>
370
  <show_in_store>1</show_in_store>
371
  </created_at>
372
- <new_created_at>
373
  <sort_order>51</sort_order>
374
  <frontend_type>text</frontend_type>
375
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -379,7 +415,7 @@
379
  <depends>
380
  <created_at>_new_</created_at>
381
  </depends>
382
- </new_created_at>
383
  <!-- created_in -->
384
  <created_in>
385
  <sort_order>55</sort_order>
@@ -392,7 +428,7 @@
392
  <show_in_website>1</show_in_website>
393
  <show_in_store>1</show_in_store>
394
  </created_in>
395
- <new_created_in>
396
  <sort_order>56</sort_order>
397
  <frontend_type>text</frontend_type>
398
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -402,7 +438,53 @@
402
  <depends>
403
  <created_in>_new_</created_in>
404
  </depends>
405
- </new_created_in>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  </fields>
407
  </attributes>
408
  <address_attributes>
@@ -427,7 +509,7 @@
427
  <show_in_website>1</show_in_website>
428
  <show_in_store>1</show_in_store>
429
  </street>
430
- <new_street>
431
  <sort_order>2</sort_order>
432
  <frontend_type>text</frontend_type>
433
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -437,7 +519,7 @@
437
  <depends>
438
  <street>_new_</street>
439
  </depends>
440
- </new_street>
441
  <!-- city -->
442
  <city>
443
  <sort_order>5</sort_order>
@@ -450,7 +532,7 @@
450
  <show_in_website>1</show_in_website>
451
  <show_in_store>1</show_in_store>
452
  </city>
453
- <new_city>
454
  <sort_order>6</sort_order>
455
  <frontend_type>text</frontend_type>
456
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -460,7 +542,7 @@
460
  <depends>
461
  <city>_new_</city>
462
  </depends>
463
- </new_city>
464
  <!-- region -->
465
  <region>
466
  <sort_order>10</sort_order>
@@ -473,7 +555,7 @@
473
  <show_in_website>1</show_in_website>
474
  <show_in_store>1</show_in_store>
475
  </region>
476
- <new_region>
477
  <sort_order>11</sort_order>
478
  <frontend_type>text</frontend_type>
479
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -483,7 +565,7 @@
483
  <depends>
484
  <region>_new_</region>
485
  </depends>
486
- </new_region>
487
  <!-- postcode -->
488
  <postcode>
489
  <sort_order>15</sort_order>
@@ -496,7 +578,7 @@
496
  <show_in_website>1</show_in_website>
497
  <show_in_store>1</show_in_store>
498
  </postcode>
499
- <new_postcode>
500
  <sort_order>16</sort_order>
501
  <frontend_type>text</frontend_type>
502
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -506,7 +588,7 @@
506
  <depends>
507
  <postcode>_new_</postcode>
508
  </depends>
509
- </new_postcode>
510
  <!-- country_id -->
511
  <country_id>
512
  <sort_order>20</sort_order>
@@ -519,7 +601,7 @@
519
  <show_in_website>1</show_in_website>
520
  <show_in_store>1</show_in_store>
521
  </country_id>
522
- <new_country_id>
523
  <sort_order>21</sort_order>
524
  <frontend_type>text</frontend_type>
525
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -529,7 +611,7 @@
529
  <depends>
530
  <country_id>_new_</country_id>
531
  </depends>
532
- </new_country_id>
533
  <!-- company -->
534
  <company>
535
  <sort_order>25</sort_order>
@@ -542,7 +624,7 @@
542
  <show_in_website>1</show_in_website>
543
  <show_in_store>1</show_in_store>
544
  </company>
545
- <new_company>
546
  <sort_order>26</sort_order>
547
  <frontend_type>text</frontend_type>
548
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -552,7 +634,7 @@
552
  <depends>
553
  <company>_new_</company>
554
  </depends>
555
- </new_company>
556
  <!-- telephone -->
557
  <telephone>
558
  <sort_order>30</sort_order>
@@ -565,7 +647,7 @@
565
  <show_in_website>1</show_in_website>
566
  <show_in_store>1</show_in_store>
567
  </telephone>
568
- <new_telephone>
569
  <sort_order>31</sort_order>
570
  <frontend_type>text</frontend_type>
571
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -575,7 +657,7 @@
575
  <depends>
576
  <telephone>_new_</telephone>
577
  </depends>
578
- </new_telephone>
579
  <!-- fax -->
580
  <fax>
581
  <sort_order>35</sort_order>
@@ -588,7 +670,7 @@
588
  <show_in_website>1</show_in_website>
589
  <show_in_store>1</show_in_store>
590
  </fax>
591
- <new_fax>
592
  <sort_order>36</sort_order>
593
  <frontend_type>text</frontend_type>
594
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
@@ -598,7 +680,7 @@
598
  <depends>
599
  <fax>_new_</fax>
600
  </depends>
601
- </new_fax>
602
  </fields>
603
  </address_attributes>
604
  </groups>
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </enabled>
41
+ <mage_cron>
42
+ <label>Use Magento Cron</label>
43
+ <depends>
44
+ <enabled>1</enabled>
45
+ </depends>
46
+ <frontend_type>select</frontend_type>
47
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <backend_model>bronto_customer/system_config_backend_cron</backend_model>
50
+ <sort_order>1</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>0</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ <comment>
55
+ <![CDATA[Setting to <em>No</em> will prevent the Magento Cron from triggering the import process for this module.<br />For more details, check the <em>Cron Settings</em> section in the <strong>Bronto &raquo; Advanced</strong> tab.]]></comment>
56
+ </mage_cron>
57
  <frequency>
58
  <label>Frequency</label>
59
  <depends>
60
  <enabled>1</enabled>
61
+ <mage_cron>1</mage_cron>
62
  </depends>
63
  <frontend_type>select</frontend_type>
64
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
72
  <label>Interval</label>
73
  <depends>
74
  <frequency>I</frequency>
75
+ <mage_cron>1</mage_cron>
76
  </depends>
77
  <frontend_type>select</frontend_type>
78
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
86
  <label>Minute of the Hour</label>
87
  <depends>
88
  <frequency>H</frequency>
89
+ <mage_cron>1</mage_cron>
90
  </depends>
91
  <frontend_type>text</frontend_type>
92
  <sort_order>40</sort_order>
99
  <label>Start Time</label>
100
  <depends>
101
  <enabled>1</enabled>
102
+ <mage_cron>1</mage_cron>
103
  </depends>
104
  <frontend_type>time</frontend_type>
105
  <sort_order>50</sort_order>
106
  <show_in_default>1</show_in_default>
107
  <show_in_website>1</show_in_website>
108
  <show_in_store>1</show_in_store>
 
109
  </time>
110
  <limit>
111
  <label>Limit</label>
118
  <show_in_default>1</show_in_default>
119
  <show_in_website>1</show_in_website>
120
  <show_in_store>1</show_in_store>
121
+ <comment>Total Customers to process every run.</comment>
122
  </limit>
123
  <sync_limit>
124
  <label>Sync Limit</label>
143
  <show_in_website>1</show_in_website>
144
  <show_in_store>1</show_in_store>
145
  </cron_list>
146
+ <suppressed>
147
+ <label>Suppressed Customers</label>
148
+ <frontend_type>text</frontend_type>
149
+ <frontend_model>bronto_customer/adminhtml_system_config_suppressed</frontend_model>
150
+ <sort_order>7</sort_order>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>1</show_in_store>
154
+ <expanded>0</expanded>
155
+ </suppressed>
156
  <attributes>
157
  <label>Customer Attributes</label>
158
  <frontend_type>text</frontend_type>
159
+ <frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_customer
160
+ </frontend_model>
161
  <sort_order>10</sort_order>
162
  <show_in_default>1</show_in_default>
163
  <show_in_website>1</show_in_website>
175
  <show_in_website>1</show_in_website>
176
  <show_in_store>1</show_in_store>
177
  </prefix>
178
+ <prefix_new>
179
  <sort_order>2</sort_order>
180
  <frontend_type>text</frontend_type>
181
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
182
  <show_in_default>1</show_in_default>
183
  <show_in_website>1</show_in_website>
184
  <show_in_store>1</show_in_store>
185
+ <depends>
186
+ <prefix>_new_</prefix>
187
+ </depends>
188
+ </prefix_new>
189
  <!-- firstname -->
190
  <firstname>
191
  <sort_order>5</sort_order>
198
  <show_in_website>1</show_in_website>
199
  <show_in_store>1</show_in_store>
200
  </firstname>
201
+ <firstname_new>
202
  <sort_order>6</sort_order>
203
  <frontend_type>text</frontend_type>
204
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
205
  <show_in_default>1</show_in_default>
206
  <show_in_website>1</show_in_website>
207
  <show_in_store>1</show_in_store>
208
+ <depends>
209
+ <firstname>_new_</firstname>
210
+ </depends>
211
+ </firstname_new>
212
  <!-- middlename -->
213
  <middlename>
214
  <sort_order>10</sort_order>
221
  <show_in_website>1</show_in_website>
222
  <show_in_store>1</show_in_store>
223
  </middlename>
224
+ <middlename_new>
225
  <sort_order>11</sort_order>
226
  <frontend_type>text</frontend_type>
227
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
228
  <show_in_default>1</show_in_default>
229
  <show_in_website>1</show_in_website>
230
  <show_in_store>1</show_in_store>
231
+ <depends>
232
+ <middlename>_new_</middlename>
233
+ </depends>
234
+ </middlename_new>
235
  <!-- lastname -->
236
  <lastname>
237
  <sort_order>15</sort_order>
244
  <show_in_website>1</show_in_website>
245
  <show_in_store>1</show_in_store>
246
  </lastname>
247
+ <lastname_new>
248
  <sort_order>16</sort_order>
249
  <frontend_type>text</frontend_type>
250
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
254
  <depends>
255
  <lastname>_new_</lastname>
256
  </depends>
257
+ </lastname_new>
258
  <!-- suffix -->
259
  <suffix>
260
  <sort_order>20</sort_order>
267
  <show_in_website>1</show_in_website>
268
  <show_in_store>1</show_in_store>
269
  </suffix>
270
+ <suffix_new>
271
  <sort_order>21</sort_order>
272
  <frontend_type>text</frontend_type>
273
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
277
  <depends>
278
  <suffix>_new_</suffix>
279
  </depends>
280
+ </suffix_new>
281
  <!-- gender -->
282
  <gender>
283
  <sort_order>25</sort_order>
290
  <show_in_website>1</show_in_website>
291
  <show_in_store>1</show_in_store>
292
  </gender>
293
+ <gender_new>
294
  <sort_order>26</sort_order>
295
  <frontend_type>text</frontend_type>
296
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
300
  <depends>
301
  <gender>_new_</gender>
302
  </depends>
303
+ </gender_new>
304
  <!-- dob -->
305
  <dob>
306
  <sort_order>30</sort_order>
313
  <show_in_website>1</show_in_website>
314
  <show_in_store>1</show_in_store>
315
  </dob>
316
+ <dob_new>
317
  <sort_order>31</sort_order>
318
  <frontend_type>text</frontend_type>
319
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
323
  <depends>
324
  <dob>_new_</dob>
325
  </depends>
326
+ </dob_new>
327
  <!-- taxvat -->
328
  <taxvat>
329
  <sort_order>35</sort_order>
336
  <show_in_website>1</show_in_website>
337
  <show_in_store>1</show_in_store>
338
  </taxvat>
339
+ <taxvat_new>
340
  <sort_order>36</sort_order>
341
  <frontend_type>text</frontend_type>
342
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
346
  <depends>
347
  <taxvat>_new_</taxvat>
348
  </depends>
349
+ </taxvat_new>
350
  <!-- website_id -->
351
  <website_id>
352
  <sort_order>40</sort_order>
359
  <show_in_website>1</show_in_website>
360
  <show_in_store>1</show_in_store>
361
  </website_id>
362
+ <website_id_new>
363
  <sort_order>41</sort_order>
364
  <frontend_type>text</frontend_type>
365
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
369
  <depends>
370
  <website_id>_new_</website_id>
371
  </depends>
372
+ </website_id_new>
373
  <!-- group_id -->
374
  <group_id>
375
  <sort_order>45</sort_order>
382
  <show_in_website>1</show_in_website>
383
  <show_in_store>1</show_in_store>
384
  </group_id>
385
+ <group_id_new>
386
  <sort_order>46</sort_order>
387
  <frontend_type>text</frontend_type>
388
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
392
  <depends>
393
  <group_id>_new_</group_id>
394
  </depends>
395
+ </group_id_new>
396
  <!-- created_at -->
397
  <created_at>
398
  <sort_order>50</sort_order>
405
  <show_in_website>1</show_in_website>
406
  <show_in_store>1</show_in_store>
407
  </created_at>
408
+ <created_at_new>
409
  <sort_order>51</sort_order>
410
  <frontend_type>text</frontend_type>
411
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
415
  <depends>
416
  <created_at>_new_</created_at>
417
  </depends>
418
+ </created_at_new>
419
  <!-- created_in -->
420
  <created_in>
421
  <sort_order>55</sort_order>
428
  <show_in_website>1</show_in_website>
429
  <show_in_store>1</show_in_store>
430
  </created_in>
431
+ <created_in_new>
432
  <sort_order>56</sort_order>
433
  <frontend_type>text</frontend_type>
434
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
438
  <depends>
439
  <created_in>_new_</created_in>
440
  </depends>
441
+ </created_in_new>
442
+ <store_credit>
443
+ <sort_order>60</sort_order>
444
+ <label>Store Credit</label>
445
+ <frontend_type>select</frontend_type>
446
+ <frontend_model>bronto_customer/adminhtml_system_config_form_field_storecredit
447
+ </frontend_model>
448
+ <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
449
+ <source_model>bronto_common/system_config_source_field</source_model>
450
+ <show_in_default>1</show_in_default>
451
+ <show_in_website>1</show_in_website>
452
+ <show_in_store>1</show_in_store>
453
+ </store_credit>
454
+ <store_credit_new>
455
+ <sort_order>61</sort_order>
456
+ <frontend_type>text</frontend_type>
457
+ <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
458
+ <show_in_default>1</show_in_default>
459
+ <show_in_website>1</show_in_website>
460
+ <show_in_store>1</show_in_store>
461
+ <depends>
462
+ <store_credit>_new_</store_credit>
463
+ </depends>
464
+ </store_credit_new>
465
+ <reward_points>
466
+ <sort_order>65</sort_order>
467
+ <label>Reward Points</label>
468
+ <frontend_type>select</frontend_type>
469
+ <frontend_model>bronto_customer/adminhtml_system_config_form_field_rewardpoints
470
+ </frontend_model>
471
+ <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
472
+ <source_model>bronto_common/system_config_source_field</source_model>
473
+ <show_in_default>1</show_in_default>
474
+ <show_in_website>1</show_in_website>
475
+ <show_in_store>1</show_in_store>
476
+ </reward_points>
477
+ <reward_points_new>
478
+ <sort_order>66</sort_order>
479
+ <frontend_type>text</frontend_type>
480
+ <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
481
+ <show_in_default>1</show_in_default>
482
+ <show_in_website>1</show_in_website>
483
+ <show_in_store>1</show_in_store>
484
+ <depends>
485
+ <reward_points>_new_</reward_points>
486
+ </depends>
487
+ </reward_points_new>
488
  </fields>
489
  </attributes>
490
  <address_attributes>
509
  <show_in_website>1</show_in_website>
510
  <show_in_store>1</show_in_store>
511
  </street>
512
+ <street_new>
513
  <sort_order>2</sort_order>
514
  <frontend_type>text</frontend_type>
515
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
519
  <depends>
520
  <street>_new_</street>
521
  </depends>
522
+ </street_new>
523
  <!-- city -->
524
  <city>
525
  <sort_order>5</sort_order>
532
  <show_in_website>1</show_in_website>
533
  <show_in_store>1</show_in_store>
534
  </city>
535
+ <city_new>
536
  <sort_order>6</sort_order>
537
  <frontend_type>text</frontend_type>
538
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
542
  <depends>
543
  <city>_new_</city>
544
  </depends>
545
+ </city_new>
546
  <!-- region -->
547
  <region>
548
  <sort_order>10</sort_order>
555
  <show_in_website>1</show_in_website>
556
  <show_in_store>1</show_in_store>
557
  </region>
558
+ <region_new>
559
  <sort_order>11</sort_order>
560
  <frontend_type>text</frontend_type>
561
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
565
  <depends>
566
  <region>_new_</region>
567
  </depends>
568
+ </region_new>
569
  <!-- postcode -->
570
  <postcode>
571
  <sort_order>15</sort_order>
578
  <show_in_website>1</show_in_website>
579
  <show_in_store>1</show_in_store>
580
  </postcode>
581
+ <postcode_new>
582
  <sort_order>16</sort_order>
583
  <frontend_type>text</frontend_type>
584
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
588
  <depends>
589
  <postcode>_new_</postcode>
590
  </depends>
591
+ </postcode_new>
592
  <!-- country_id -->
593
  <country_id>
594
  <sort_order>20</sort_order>
601
  <show_in_website>1</show_in_website>
602
  <show_in_store>1</show_in_store>
603
  </country_id>
604
+ <country_id_new>
605
  <sort_order>21</sort_order>
606
  <frontend_type>text</frontend_type>
607
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
611
  <depends>
612
  <country_id>_new_</country_id>
613
  </depends>
614
+ </country_id_new>
615
  <!-- company -->
616
  <company>
617
  <sort_order>25</sort_order>
624
  <show_in_website>1</show_in_website>
625
  <show_in_store>1</show_in_store>
626
  </company>
627
+ <company_new>
628
  <sort_order>26</sort_order>
629
  <frontend_type>text</frontend_type>
630
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
634
  <depends>
635
  <company>_new_</company>
636
  </depends>
637
+ </company_new>
638
  <!-- telephone -->
639
  <telephone>
640
  <sort_order>30</sort_order>
647
  <show_in_website>1</show_in_website>
648
  <show_in_store>1</show_in_store>
649
  </telephone>
650
+ <telephone_new>
651
  <sort_order>31</sort_order>
652
  <frontend_type>text</frontend_type>
653
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
657
  <depends>
658
  <telephone>_new_</telephone>
659
  </depends>
660
+ </telephone_new>
661
  <!-- fax -->
662
  <fax>
663
  <sort_order>35</sort_order>
670
  <show_in_website>1</show_in_website>
671
  <show_in_store>1</show_in_store>
672
  </fax>
673
+ <fax_new>
674
  <sort_order>36</sort_order>
675
  <frontend_type>text</frontend_type>
676
  <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
680
  <depends>
681
  <fax>_new_</fax>
682
  </depends>
683
+ </fax_new>
684
  </fields>
685
  </address_attributes>
686
  </groups>
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.0.php CHANGED
@@ -8,7 +8,7 @@ $installer->startSetup();
8
  //
9
  // Customer Attributes
10
  $installer->addAttribute('customer', 'bronto_imported', array(
11
- 'type' => 'datetime',
12
  'required' => false,
13
  ));
14
 
8
  //
9
  // Customer Attributes
10
  $installer->addAttribute('customer', 'bronto_imported', array(
11
+ 'type' => 'datetime',
12
  'required' => false,
13
  ));
14
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.3.php CHANGED
@@ -18,7 +18,8 @@ try {
18
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
19
  `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
20
  `bronto_suppressed` varchar(255) DEFAULT NULL,
21
- PRIMARY KEY (`queue_id`,`customer_id`,`store_id`),
 
22
  KEY `IDX_BRONTO_CUSTOMER_QUEUE_STORE_ID` (`store_id`),
23
  KEY `IDX_BRONTO_CUSTOMER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
24
  KEY `IDX_BRONTO_CUSTOMER_QUEUE_CREATED_AT` (`created_at`),
18
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
19
  `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
20
  `bronto_suppressed` varchar(255) DEFAULT NULL,
21
+ PRIMARY KEY (`customer_id`,`store_id`),
22
+ KEY `IDX_BRONTO_CUSTOMER_QUEUE_QUEUE_ID` (`queue_id`),
23
  KEY `IDX_BRONTO_CUSTOMER_QUEUE_STORE_ID` (`store_id`),
24
  KEY `IDX_BRONTO_CUSTOMER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
25
  KEY `IDX_BRONTO_CUSTOMER_QUEUE_CREATED_AT` (`created_at`),
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.0-1.0.1.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.1-1.0.2.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.2-1.0.3.php CHANGED
@@ -4,14 +4,26 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
11
  try {
12
  // Update Table
13
  $installer->run("
14
- ALTER TABLE `{$this->getTable('bronto_customer_queue')}` ADD COLUMN `bronto_suppressed` VARCHAR(255) NULL DEFAULT NULL;
 
 
 
 
 
 
 
 
 
 
 
 
15
  ");
16
  } catch (Exception $e) {
17
  throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
11
  try {
12
  // Update Table
13
  $installer->run("
14
+ ALTER IGNORE TABLE `{$this->getTable('bronto_customer_queue')}`
15
+ DROP PRIMARY KEY, ADD PRIMARY KEY(`customer_id`, `store_id`),
16
+ ADD KEY `IDX_BRONTO_CUSTOMER_QUEUE_QUEUE_ID` (`queue_id`);
17
+ ");
18
+ } catch (Exception $e) {
19
+ throw new RuntimeException('Failed Updating Keys for Table: ' . $e->getMessage());
20
+ }
21
+
22
+ try {
23
+ // Update Table
24
+ $installer->run("
25
+ ALTER TABLE `{$this->getTable('bronto_customer_queue')}`
26
+ ADD COLUMN `bronto_suppressed` VARCHAR(255) NULL DEFAULT NULL;
27
  ");
28
  } catch (Exception $e) {
29
  throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/About.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
8
  {
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Settings.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Reminder
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Config_Settings
9
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
@@ -12,12 +11,14 @@ class Bronto_Email_Block_Adminhtml_System_Config_Settings
12
  * Return header comment part of html for fieldset
13
  *
14
  * @param Varien_Data_Form_Element_Abstract $element
 
15
  * @return string
16
  */
17
- protected function _getHeaderCommentHtml($element)
18
  {
19
- $url = Mage::helper('adminhtml')->getUrl('/system_email_template');
20
  $element->setComment("Additional configuration located at: <strong>System &rsaquo; <a href=\"{$url}\">Transactional Emails</a></strong><br/><br/>");
21
- return parent::_getHeaderCommentHtml($element);
 
22
  }
23
  }
3
  /**
4
  * @package Bronto\Reminder
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Config_Settings
8
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
11
  * Return header comment part of html for fieldset
12
  *
13
  * @param Varien_Data_Form_Element_Abstract $element
14
+ *
15
  * @return string
16
  */
17
+ public function render(Varien_Data_Form_Element_Abstract $element)
18
  {
19
+ $url = Mage::helper('adminhtml')->getUrl('*/system_email_template');
20
  $element->setComment("Additional configuration located at: <strong>System &rsaquo; <a href=\"{$url}\">Transactional Emails</a></strong><br/><br/>");
21
+
22
+ return parent::render($element);
23
  }
24
  }
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Reminder
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Config_Templates
9
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
@@ -13,26 +12,17 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
13
  protected $_dummySubset;
14
  protected $_fieldRenderer;
15
 
16
- /**
17
- * Return header comment part of html for fieldset
18
- *
19
- * @param Varien_Data_Form_Element_Abstract $element
20
- * @return string
21
- */
22
- protected function _getHeaderCommentHtml($element)
23
  {
24
  $element->setComment("<strong>This form is provided as a centralized location for assigning all Magento email templates.<br />Each section contains a link to where this action would normally be performed.</strong><br /><br />");
25
- return parent::_getHeaderCommentHtml($element);
26
- }
27
 
28
- public function render(Varien_Data_Form_Element_Abstract $element)
29
- {
30
  // Only show template mapping if module is enabled
31
  if (!$this->helper('bronto_email')->isEnabled()) {
32
  return '';
33
  }
34
 
35
  $html = $this->_getHeaderHtml($element);
 
36
 
37
  $fields = $this->_getSystemConfigPathsParts();
38
 
@@ -47,14 +37,57 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
47
  return $html;
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  /**
51
  * Adds fields to the child fieldset
52
  *
53
  * @param Varien_Data_Form_Element_Abstract $fieldset
54
- * @param Varien_Object $element
 
55
  * @return Varien_Data_Form_Element_Abstract
56
  */
57
- protected function _addSubFields($fieldset, $element) {
 
58
  $configCode = 'bronto_email_templates_label_' . $element->getSection();
59
 
60
  if ($element->frontend_model) {
@@ -64,7 +97,7 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
64
  }
65
 
66
  $labelLink = $element->getLabel();
67
- $label = sprintf('<a href="%s" title="%s">%s</a>',
68
  $labelLink['url'],
69
  $labelLink['title'],
70
  $labelLink['title']
@@ -73,11 +106,11 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
73
  try {
74
  $field = $fieldset->addFieldSet($configCode,
75
  array(
76
- 'label' => $label,
77
- 'inherit' => false,
78
- 'field_config' => $element,
79
- 'scope' => $this->getForm()->getScope(),
80
- 'scopeId' => $this->getForm()->getScopeId(),
81
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
82
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
83
  )
@@ -87,6 +120,7 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
87
  $field->setRenderer($fieldRenderer);
88
  } catch (Exception $e) {
89
  Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
 
90
  return '';
91
  }
92
 
@@ -97,13 +131,15 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
97
  * Gets the subfieldset HTML
98
  *
99
  * @param Varien_Data_Form_Element_Abstract $fieldset
100
- * @param string $section
101
- * @param array $groups
102
- * @param int $order
 
103
  * @return string
104
  */
105
- protected function _getSubsetHtml($fieldset, $section, $groups, $order) {
106
- $data = current($groups);
 
107
  $element = $this->_getDummySubset($order);
108
  $element
109
  ->setLabel($data['parts'][1])
@@ -120,13 +156,15 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
120
 
121
  /**
122
  * this sets the fields renderer. If you have a custom renderer you can change this.
123
- * @return type
 
124
  */
125
  protected function _getFieldRenderer()
126
  {
127
  if (empty($this->_fieldRenderer)) {
128
  $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
129
  }
 
130
  return $this->_fieldRenderer;
131
  }
132
 
@@ -134,15 +172,17 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
134
  * Gets the dummy fieldset config
135
  *
136
  * @param int $order
 
137
  * @return Varien_Object
138
  */
139
- protected function _getDummySubset($order) {
 
140
  if (empty($this->_dummySubset)) {
141
  $this->_dummySubset = new Varien_Object(array(
142
- 'sort_order' => $order,
143
- 'frontend_type' => 'text',
144
- 'frontend_model' => 'bronto_email/adminhtml_system_config_templates_fieldset',
145
- 'show_in_store' => 1,
146
  'show_in_default' => 1,
147
  'show_in_website' => 1,
148
  ));
@@ -153,14 +193,13 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
153
 
154
  /**
155
  * Get Array of all config path details
156
- * @param type $paths
157
- * @return type
158
  */
159
  protected function _getSystemConfigPathsParts()
160
  {
161
  $result = $urlParams = $prefixParts = array();
162
- $scopeLabel = Mage::helper('adminhtml')->__('GLOBAL');
163
- $paths = Mage::helper('bronto_email')->getTemplatePaths();
164
 
165
  if ($paths) {
166
  $prefixParts[] = array(
@@ -170,21 +209,19 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
170
  $pathParts = $prefixParts;
171
  foreach ($paths as $pathData) {
172
  list($sectionName, $groupName, $fieldName) = explode('/', $pathData);
173
- $urlParams = array('section' => $sectionName);
174
  $scopeParams = Mage::helper('bronto_email')->getScopeParams();
175
 
176
  if (isset($scopeParams['store'])) {
177
  $store = Mage::app()->getStore($scopeParams['store']);
178
  if ($store) {
179
  $urlParams['website'] = $store->getWebsite()->getCode();
180
- $urlParams['store'] = $store->getCode();
181
- $scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName();
182
  }
183
  } else if (isset($scopeParams['website'])) {
184
  $website = Mage::app()->getWebsite($scopeParams['website']);
185
  if ($website) {
186
  $urlParams['website'] = $website->getCode();
187
- $scopeLabel = $website->getName();
188
  }
189
  }
190
 
@@ -193,15 +230,15 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates
193
 
194
  $pathParts[] = array(
195
  'title' => $adminhtmlConfig->getSystemConfigNodeLabel($sectionName),
196
- 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams),
197
  );
198
  $pathParts[] = array(
199
  'title' => $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName),
200
  );
201
 
202
- $result[$sectionName][$groupName]['parts'] = $pathParts;
203
  $result[$sectionName][$groupName]['fields'][$fieldName]['path'] = $pathData;
204
- $pathParts = $prefixParts;
205
  }
206
  }
207
 
3
  /**
4
  * @package Bronto\Reminder
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Config_Templates
8
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
12
  protected $_dummySubset;
13
  protected $_fieldRenderer;
14
 
15
+ public function render(Varien_Data_Form_Element_Abstract $element)
 
 
 
 
 
 
16
  {
17
  $element->setComment("<strong>This form is provided as a centralized location for assigning all Magento email templates.<br />Each section contains a link to where this action would normally be performed.</strong><br /><br />");
 
 
18
 
 
 
19
  // Only show template mapping if module is enabled
20
  if (!$this->helper('bronto_email')->isEnabled()) {
21
  return '';
22
  }
23
 
24
  $html = $this->_getHeaderHtml($element);
25
+ $html .= $this->_getScopeToggleHtml($element);
26
 
27
  $fields = $this->_getSystemConfigPathsParts();
28
 
37
  return $html;
38
  }
39
 
40
+ protected function _getScopeToggleHtml($element)
41
+ {
42
+ $scopeParams = $this->helper('bronto_common')->getScopeParams();
43
+ switch ($scopeParams['scope']) {
44
+ case 'store':
45
+ $inheritLabel = 'Use Website for All';
46
+ break;
47
+ case 'website':
48
+ $inheritLabel = 'Use Default for All';
49
+ break;
50
+ default:
51
+ case 'default':
52
+ return '';
53
+ break;
54
+ }
55
+
56
+ $html = '
57
+ <tr id="' . $element->getHtmlId() . '_unselect_all">
58
+ <td class="label"></td>
59
+ <td class="value"></td>
60
+ <td class="use-default" colspan="3">
61
+ <input id="' . $element->getHtmlId() . '_scope_toggle_checkbox" value="0" name="scope_toggle" type="checkbox" class="checkbox config-inherit-toggle" onclick="brontoToggleScope(this, \'' . $element->getHtmlId() . '\');" />
62
+ <label id="' . $element->getHtmlId() . '_scope_toggle_checkbox_label" for="' . $element->getHtmlId() . '_scope_toggle_checkbox" class="inherit" title="Toggle Scope Inheritance">' . $inheritLabel . '</label>
63
+ </td>
64
+ </tr>
65
+ <script type="text/javascript">
66
+ function brontoToggleScope(toggle, parentId)
67
+ {
68
+ var toggleValue = toggle.checked;
69
+
70
+ $$("#" + parentId + " input.checkbox.config-inherit").each(function(item){
71
+ item.checked = toggleValue;
72
+ item.value = toggleValue ? "1" : "0";
73
+ toggleValueElements(item, Element.previous(item.parentNode));
74
+ });
75
+ }
76
+ </script>';
77
+
78
+ return $html;
79
+ }
80
+
81
  /**
82
  * Adds fields to the child fieldset
83
  *
84
  * @param Varien_Data_Form_Element_Abstract $fieldset
85
+ * @param Varien_Object $element
86
+ *
87
  * @return Varien_Data_Form_Element_Abstract
88
  */
89
+ protected function _addSubFields($fieldset, $element)
90
+ {
91
  $configCode = 'bronto_email_templates_label_' . $element->getSection();
92
 
93
  if ($element->frontend_model) {
97
  }
98
 
99
  $labelLink = $element->getLabel();
100
+ $label = sprintf('<a href="%s" title="%s">%s</a>',
101
  $labelLink['url'],
102
  $labelLink['title'],
103
  $labelLink['title']
106
  try {
107
  $field = $fieldset->addFieldSet($configCode,
108
  array(
109
+ 'label' => $label,
110
+ 'inherit' => false,
111
+ 'field_config' => $element,
112
+ 'scope' => $this->getForm()->getScope(),
113
+ 'scopeId' => $this->getForm()->getScopeId(),
114
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
115
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
116
  )
120
  $field->setRenderer($fieldRenderer);
121
  } catch (Exception $e) {
122
  Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
123
+
124
  return '';
125
  }
126
 
131
  * Gets the subfieldset HTML
132
  *
133
  * @param Varien_Data_Form_Element_Abstract $fieldset
134
+ * @param string $section
135
+ * @param array $groups
136
+ * @param int $order
137
+ *
138
  * @return string
139
  */
140
+ protected function _getSubsetHtml($fieldset, $section, $groups, $order)
141
+ {
142
+ $data = current($groups);
143
  $element = $this->_getDummySubset($order);
144
  $element
145
  ->setLabel($data['parts'][1])
156
 
157
  /**
158
  * this sets the fields renderer. If you have a custom renderer you can change this.
159
+ *
160
+ * @return object
161
  */
162
  protected function _getFieldRenderer()
163
  {
164
  if (empty($this->_fieldRenderer)) {
165
  $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
166
  }
167
+
168
  return $this->_fieldRenderer;
169
  }
170
 
172
  * Gets the dummy fieldset config
173
  *
174
  * @param int $order
175
+ *
176
  * @return Varien_Object
177
  */
178
+ protected function _getDummySubset($order)
179
+ {
180
  if (empty($this->_dummySubset)) {
181
  $this->_dummySubset = new Varien_Object(array(
182
+ 'sort_order' => $order,
183
+ 'frontend_type' => 'text',
184
+ 'frontend_model' => 'bronto_email/adminhtml_system_config_templates_fieldset',
185
+ 'show_in_store' => 1,
186
  'show_in_default' => 1,
187
  'show_in_website' => 1,
188
  ));
193
 
194
  /**
195
  * Get Array of all config path details
196
+ *
197
+ * @return array
198
  */
199
  protected function _getSystemConfigPathsParts()
200
  {
201
  $result = $urlParams = $prefixParts = array();
202
+ $paths = Mage::helper('bronto_email')->getTemplatePaths();
 
203
 
204
  if ($paths) {
205
  $prefixParts[] = array(
209
  $pathParts = $prefixParts;
210
  foreach ($paths as $pathData) {
211
  list($sectionName, $groupName, $fieldName) = explode('/', $pathData);
212
+ $urlParams = array('section' => $sectionName);
213
  $scopeParams = Mage::helper('bronto_email')->getScopeParams();
214
 
215
  if (isset($scopeParams['store'])) {
216
  $store = Mage::app()->getStore($scopeParams['store']);
217
  if ($store) {
218
  $urlParams['website'] = $store->getWebsite()->getCode();
219
+ $urlParams['store'] = $store->getCode();
 
220
  }
221
  } else if (isset($scopeParams['website'])) {
222
  $website = Mage::app()->getWebsite($scopeParams['website']);
223
  if ($website) {
224
  $urlParams['website'] = $website->getCode();
 
225
  }
226
  }
227
 
230
 
231
  $pathParts[] = array(
232
  'title' => $adminhtmlConfig->getSystemConfigNodeLabel($sectionName),
233
+ 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams),
234
  );
235
  $pathParts[] = array(
236
  'title' => $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName),
237
  );
238
 
239
+ $result[$sectionName][$groupName]['parts'] = $pathParts;
240
  $result[$sectionName][$groupName]['fields'][$fieldName]['path'] = $pathData;
241
+ $pathParts = $prefixParts;
242
  }
243
  }
244
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Field.php CHANGED
@@ -9,11 +9,12 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Field extends Mage_Ad
9
 
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
 
12
  * @return string
13
  */
14
  public function render(Varien_Data_Form_Element_Abstract $element)
15
  {
16
- $realpath = str_replace('-', '/', str_replace('bronto_email_templates_', '', $element->getId()));
17
  $realValue = Mage::helper('bronto_email')->getAdminScopedConfig($realpath);
18
  $element->setValue($realValue);
19
  $element->setPath($realpath);
9
 
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
12
+ *
13
  * @return string
14
  */
15
  public function render(Varien_Data_Form_Element_Abstract $element)
16
  {
17
+ $realpath = str_replace('-', '/', str_replace('bronto_email_templates_', '', $element->getId()));
18
  $realValue = Mage::helper('bronto_email')->getAdminScopedConfig($realpath);
19
  $element->setValue($realValue);
20
  $element->setPath($realpath);
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Fieldset.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
- class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
 
4
 
5
  protected $_dummyElement;
6
  protected $_dummyLabel;
@@ -8,31 +9,40 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
8
 
9
  /**
10
  * @see parent
 
11
  * @param Varien_Data_Form_Element_Abstract $element
 
12
  * @return string
13
  */
14
- protected function _getHeaderHtml($element) {
15
- return '<tr id="' . $element->getId() . '"><td cellspan="5">
 
16
  <fieldset><legend style="font-weight:bold; visibility:inherit; font-size:16px; width:inherit; height:inherit; line-height:inherit;">' . $element->getLabel() . '</legend>
17
  <table class="form-list" cellspacing="0">';
18
  }
19
 
20
  /**
21
  * @see parent
 
22
  * @param Varien_Data_Form_Element_Abstract $element
 
23
  * @return string
24
  */
25
- protected function _getFooterHtml($element) {
 
26
  return '</table></fieldset></td></tr>';
27
  }
28
 
29
  /**
30
  * @see parent
 
31
  * @param Varien_Data_Form_Element_Abstract $element
 
32
  * @return string
33
  */
34
- public function render(Varien_Data_Form_Element_Abstract $element) {
35
- $html = $this->_getHeaderHtml($element);
 
36
  $order = 0;
37
  foreach ($element->getFieldConfig()->getGroups() as $group => $groupData) {
38
  $order = $order + 5;
@@ -48,32 +58,37 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
48
  }
49
 
50
  $html .= $this->_getFooterHtml($element);
 
51
  return $html;
52
  }
53
 
54
  /**
55
  * this sets the fields renderer. If you have a custom renderer you can change this.
56
- * @return type
 
57
  */
58
  protected function _getFieldRenderer()
59
  {
60
  if (empty($this->_fieldRenderer)) {
61
  $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
62
  }
 
63
  return $this->_fieldRenderer;
64
  }
65
 
66
  /**
67
  * Get HTML for field element
 
68
  * @param Varien_Data_Form_Element_Abstract $fieldset
69
- * @param array $field
70
- * @param int $order
 
71
  * @return string
72
  */
73
  protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, array $field, $order)
74
  {
75
  // Create Select Field
76
- $element = $this->_getDummyElement($order);
77
  $tempField = $this->_createField($fieldset, $element, $field);
78
  if (!$tempField) {
79
  return '';
@@ -84,17 +99,19 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
84
 
85
  /**
86
  * Get HTML for label element
 
87
  * @param Varien_Data_Form_Element_Abstract $fieldset
88
- * @param string $section
89
- * @param string $group
90
- * @param array $groupData
91
- * @param int $order
 
92
  * @return string
93
  */
94
  protected function _getLabelHtml(Varien_Data_Form_Element_Abstract $fieldset, $section, $group, array $groupData, $order)
95
  {
96
  $element = $this->_getDummyLabel($order);
97
- $label = $this->_createLabel($fieldset, $element, $groupData, $section, $group);
98
  if (!$label) {
99
  return '';
100
  }
@@ -104,21 +121,23 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
104
 
105
  /**
106
  * Get dummy field element to set specific configurations
 
107
  * @param int $order
 
108
  * @return Varien_Object
109
  */
110
  protected function _getDummyElement($order)
111
  {
112
  if (empty($this->_dummyElement)) {
113
  $this->_dummyElement = new Varien_Object(array(
114
- 'sort_order' => $order,
115
- 'frontend_type' => 'select',
116
- 'frontend_model' => 'bronto_email/adminhtml_system_config_templates_field',
117
- 'backend_model' => 'bronto_email/system_config_backend_templates_field',
118
- 'source_model' => 'bronto_email/system_config_source_email_template',
119
  'show_in_default' => 1,
120
  'show_in_website' => 1,
121
- 'show_in_store' => 1,
122
  ));
123
  }
124
 
@@ -127,19 +146,21 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
127
 
128
  /**
129
  * Get dummy label element to set specific configurations
 
130
  * @param int $order
 
131
  * @return Varien_Object
132
  */
133
  protected function _getDummyLabel($order)
134
  {
135
  if (empty($this->_dummyLabel)) {
136
  $this->_dummyLabel = new Varien_Object(array(
137
- 'sort_order' => $order,
138
- 'frontend_type' => 'label',
139
- 'frontend_model' => 'bronto_email/adminhtml_system_config_templates_label',
140
  'show_in_default' => 1,
141
  'show_in_website' => 1,
142
- 'show_in_store' => 1,
143
  ));
144
  }
145
 
@@ -148,9 +169,11 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
148
 
149
  /**
150
  * Create Field and Return it
 
151
  * @param Varien_Data_Form_Element_Abstract $fieldset
152
- * @param Varien_Object $element
153
- * @param array $field
 
154
  * @return Varien_Data_Form_Element_Abstract
155
  */
156
  protected function _createField(
@@ -166,18 +189,18 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
166
  $configData = $this->getConfigData($path);
167
 
168
  // Build Id and Code from Path
169
- $fieldId = implode('-', explode('/', $field['path']));
170
  $fieldCode = 'bronto_email_templates_' . $fieldId;
171
 
172
- $data = false;
173
  $inherit = true;
174
  if (array_key_exists($path, $configData)) {
175
- $data = $configData[$path]['data'];
176
  $inherit = $configData[$path]['inherit'];
177
  }
178
 
179
  if (!$data) {
180
- $data = (string)Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
181
  $inherit = true;
182
  }
183
 
@@ -190,12 +213,12 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
190
 
191
  // Define Type, Name, and Label
192
  $fieldType = (string)$element->frontend_type ? (string)$element->frontend_type : 'text';
193
- $name = 'groups[templates][fields][' . $fieldId . '][value]';
194
 
195
  // Build Field Label from path
196
  $pathParts = explode('/', $path);
197
  $labelPart = array_pop($pathParts);
198
- $label = str_replace('_', ' ', uc_words($labelPart));
199
 
200
  // Pass through backend model in case it needs to modify value
201
  if ($element->backend_model) {
@@ -210,14 +233,14 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
210
  // Select Field for Existing attributes.
211
  $field = $fieldset->addField($fieldCode, $fieldType,
212
  array(
213
- 'name' => $name,
214
- 'label' => $label,
215
- 'value' => $data,
216
- 'inherit' => $inherit,
217
- 'field_config' => $element,
218
- 'scope' => $this->getForm()->getScope(),
219
- 'scopeId' => $this->getForm()->getScopeId(),
220
- 'scope_label' => $this->getForm()->getScopeLabel($element),
221
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
222
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
223
  )
@@ -251,10 +274,14 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
251
 
252
  /**
253
  * Create Label and Return it
 
254
  * @param Varien_Data_Form_Element_Abstract $fieldset
255
- * @param Varien_Object $e
256
- * @param array $field
257
- * @return Varien_Data_Form_Element_Abstract
 
 
 
258
  */
259
  protected function _createLabel(
260
  Varien_Data_Form_Element_Abstract $fieldset,
@@ -266,7 +293,7 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
266
  {
267
  $configCode = 'bronto_email_templates_label_' . $section . '_' . $group;
268
 
269
- $data = $groupData['parts'][2]['title'];
270
  $inherit = false;
271
 
272
  // Get field Renderer
@@ -278,17 +305,17 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
278
 
279
  // Define Type, Name, and Label
280
  $fieldType = 'label';
281
- $label = $data;
282
 
283
  try {
284
  // Select Field for Existing attributes.
285
  $field = $fieldset->addField($configCode, $fieldType,
286
  array(
287
- 'label' => $label,
288
- 'inherit' => $inherit,
289
- 'field_config' => $element,
290
- 'scope' => $this->getForm()->getScope(),
291
- 'scopeId' => $this->getForm()->getScopeId(),
292
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
293
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
294
  )
@@ -298,6 +325,7 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
298
  $field->setRenderer($fieldRenderer);
299
  } catch (Exception $e) {
300
  Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
 
301
  return '';
302
  }
303
 
@@ -306,8 +334,10 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
306
 
307
  /**
308
  * Override getConfigData to handle us altering the path
309
- * @param type $path
310
- * @return type
 
 
311
  */
312
  public function getConfigData($path)
313
  {
@@ -316,7 +346,7 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
316
  $configDataCollection = $this->_getConfigCollection($path);
317
 
318
  // Get Scope
319
- $scope = $this->getForm()->getScope();
320
  $scopeId = $this->getForm()->getScopeId();
321
 
322
  $inherit = false;
@@ -328,15 +358,16 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
328
  ($scopeId == $config->getScopeId()) &&
329
  (!is_null($config->getValue()))
330
  ) {
331
- $configData[$path]['data'] = $config->getValue();
332
  $configData[$path]['inherit'] = $inherit;
 
333
  return $configData;
334
  }
335
  }
336
  $scopeParent = $this->_getScopeParent($scope, $scopeId);
337
- $scope = $scopeParent['scope'];
338
- $scopeId = $scopeParent['scope_id'];
339
- $inherit = true;
340
  }
341
  }
342
 
@@ -345,7 +376,9 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
345
 
346
  /**
347
  * Get Config Data Collection for Path
348
- * @param type $path
 
 
349
  * @return Mage_Core_Model_Resource_Config_Data_Collection
350
  */
351
  protected function _getConfigCollection($path)
@@ -359,8 +392,10 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
359
 
360
  /**
361
  * Get Parent Scope
362
- * @param string $scope
 
363
  * @param string|int $scopeId
 
364
  * @return array
365
  */
366
  protected function _getScopeParent($scope, $scopeId)
@@ -371,16 +406,16 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage
371
 
372
  switch ($scope) {
373
  case 'stores':
374
- $scope = 'websites';
375
  $scopeId = Mage::app()->getStore($scopeId)->getWebsiteId();
376
  break;
377
  case 'websites':
378
- $scope = 'default';
379
  $scopeId = 0;
380
  break;
381
  case 'default':
382
  default:
383
- $scope = false;
384
  $scopeId = false;
385
  break;
386
  }
1
  <?php
2
 
3
+ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
 
6
  protected $_dummyElement;
7
  protected $_dummyLabel;
9
 
10
  /**
11
  * @see parent
12
+ *
13
  * @param Varien_Data_Form_Element_Abstract $element
14
+ *
15
  * @return string
16
  */
17
+ protected function _getHeaderHtml($element)
18
+ {
19
+ return '<tr id="' . $element->getId() . '"><td colspan="5">
20
  <fieldset><legend style="font-weight:bold; visibility:inherit; font-size:16px; width:inherit; height:inherit; line-height:inherit;">' . $element->getLabel() . '</legend>
21
  <table class="form-list" cellspacing="0">';
22
  }
23
 
24
  /**
25
  * @see parent
26
+ *
27
  * @param Varien_Data_Form_Element_Abstract $element
28
+ *
29
  * @return string
30
  */
31
+ protected function _getFooterHtml($element)
32
+ {
33
  return '</table></fieldset></td></tr>';
34
  }
35
 
36
  /**
37
  * @see parent
38
+ *
39
  * @param Varien_Data_Form_Element_Abstract $element
40
+ *
41
  * @return string
42
  */
43
+ public function render(Varien_Data_Form_Element_Abstract $element)
44
+ {
45
+ $html = $this->_getHeaderHtml($element);
46
  $order = 0;
47
  foreach ($element->getFieldConfig()->getGroups() as $group => $groupData) {
48
  $order = $order + 5;
58
  }
59
 
60
  $html .= $this->_getFooterHtml($element);
61
+
62
  return $html;
63
  }
64
 
65
  /**
66
  * this sets the fields renderer. If you have a custom renderer you can change this.
67
+ *
68
+ * @return object
69
  */
70
  protected function _getFieldRenderer()
71
  {
72
  if (empty($this->_fieldRenderer)) {
73
  $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
74
  }
75
+
76
  return $this->_fieldRenderer;
77
  }
78
 
79
  /**
80
  * Get HTML for field element
81
+ *
82
  * @param Varien_Data_Form_Element_Abstract $fieldset
83
+ * @param array $field
84
+ * @param int $order
85
+ *
86
  * @return string
87
  */
88
  protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, array $field, $order)
89
  {
90
  // Create Select Field
91
+ $element = $this->_getDummyElement($order);
92
  $tempField = $this->_createField($fieldset, $element, $field);
93
  if (!$tempField) {
94
  return '';
99
 
100
  /**
101
  * Get HTML for label element
102
+ *
103
  * @param Varien_Data_Form_Element_Abstract $fieldset
104
+ * @param string $section
105
+ * @param string $group
106
+ * @param array $groupData
107
+ * @param int $order
108
+ *
109
  * @return string
110
  */
111
  protected function _getLabelHtml(Varien_Data_Form_Element_Abstract $fieldset, $section, $group, array $groupData, $order)
112
  {
113
  $element = $this->_getDummyLabel($order);
114
+ $label = $this->_createLabel($fieldset, $element, $groupData, $section, $group);
115
  if (!$label) {
116
  return '';
117
  }
121
 
122
  /**
123
  * Get dummy field element to set specific configurations
124
+ *
125
  * @param int $order
126
+ *
127
  * @return Varien_Object
128
  */
129
  protected function _getDummyElement($order)
130
  {
131
  if (empty($this->_dummyElement)) {
132
  $this->_dummyElement = new Varien_Object(array(
133
+ 'sort_order' => $order,
134
+ 'frontend_type' => 'select',
135
+ 'frontend_model' => 'bronto_email/adminhtml_system_config_templates_field',
136
+ 'backend_model' => 'bronto_email/system_config_backend_templates_field',
137
+ 'source_model' => 'bronto_email/system_config_source_email_template',
138
  'show_in_default' => 1,
139
  'show_in_website' => 1,
140
+ 'show_in_store' => 1,
141
  ));
142
  }
143
 
146
 
147
  /**
148
  * Get dummy label element to set specific configurations
149
+ *
150
  * @param int $order
151
+ *
152
  * @return Varien_Object
153
  */
154
  protected function _getDummyLabel($order)
155
  {
156
  if (empty($this->_dummyLabel)) {
157
  $this->_dummyLabel = new Varien_Object(array(
158
+ 'sort_order' => $order,
159
+ 'frontend_type' => 'label',
160
+ 'frontend_model' => 'bronto_email/adminhtml_system_config_templates_label',
161
  'show_in_default' => 1,
162
  'show_in_website' => 1,
163
+ 'show_in_store' => 1,
164
  ));
165
  }
166
 
169
 
170
  /**
171
  * Create Field and Return it
172
+ *
173
  * @param Varien_Data_Form_Element_Abstract $fieldset
174
+ * @param Varien_Object $element
175
+ * @param array $field
176
+ *
177
  * @return Varien_Data_Form_Element_Abstract
178
  */
179
  protected function _createField(
189
  $configData = $this->getConfigData($path);
190
 
191
  // Build Id and Code from Path
192
+ $fieldId = implode('-', explode('/', $field['path']));
193
  $fieldCode = 'bronto_email_templates_' . $fieldId;
194
 
195
+ $data = false;
196
  $inherit = true;
197
  if (array_key_exists($path, $configData)) {
198
+ $data = $configData[$path]['data'];
199
  $inherit = $configData[$path]['inherit'];
200
  }
201
 
202
  if (!$data) {
203
+ $data = (string)Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
204
  $inherit = true;
205
  }
206
 
213
 
214
  // Define Type, Name, and Label
215
  $fieldType = (string)$element->frontend_type ? (string)$element->frontend_type : 'text';
216
+ $name = 'groups[templates][fields][' . $fieldId . '][value]';
217
 
218
  // Build Field Label from path
219
  $pathParts = explode('/', $path);
220
  $labelPart = array_pop($pathParts);
221
+ $label = str_replace('_', ' ', uc_words($labelPart));
222
 
223
  // Pass through backend model in case it needs to modify value
224
  if ($element->backend_model) {
233
  // Select Field for Existing attributes.
234
  $field = $fieldset->addField($fieldCode, $fieldType,
235
  array(
236
+ 'name' => $name,
237
+ 'label' => $label,
238
+ 'value' => $data,
239
+ 'inherit' => $inherit,
240
+ 'field_config' => $element,
241
+ 'scope' => $this->getForm()->getScope(),
242
+ 'scopeId' => $this->getForm()->getScopeId(),
243
+ 'scope_label' => $this->getForm()->getScopeLabel($element),
244
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
245
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
246
  )
274
 
275
  /**
276
  * Create Label and Return it
277
+ *
278
  * @param Varien_Data_Form_Element_Abstract $fieldset
279
+ * @param Varien_Object $element
280
+ * @param array $groupData
281
+ * @param $section
282
+ * @param $group
283
+ *
284
+ * @return string|Varien_Data_Form_Element_Abstract
285
  */
286
  protected function _createLabel(
287
  Varien_Data_Form_Element_Abstract $fieldset,
293
  {
294
  $configCode = 'bronto_email_templates_label_' . $section . '_' . $group;
295
 
296
+ $data = $groupData['parts'][2]['title'];
297
  $inherit = false;
298
 
299
  // Get field Renderer
305
 
306
  // Define Type, Name, and Label
307
  $fieldType = 'label';
308
+ $label = $data;
309
 
310
  try {
311
  // Select Field for Existing attributes.
312
  $field = $fieldset->addField($configCode, $fieldType,
313
  array(
314
+ 'label' => $label,
315
+ 'inherit' => $inherit,
316
+ 'field_config' => $element,
317
+ 'scope' => $this->getForm()->getScope(),
318
+ 'scopeId' => $this->getForm()->getScopeId(),
319
  'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
320
  'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
321
  )
325
  $field->setRenderer($fieldRenderer);
326
  } catch (Exception $e) {
327
  Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
328
+
329
  return '';
330
  }
331
 
334
 
335
  /**
336
  * Override getConfigData to handle us altering the path
337
+ *
338
+ * @param $path
339
+ *
340
+ * @return array
341
  */
342
  public function getConfigData($path)
343
  {
346
  $configDataCollection = $this->_getConfigCollection($path);
347
 
348
  // Get Scope
349
+ $scope = $this->getForm()->getScope();
350
  $scopeId = $this->getForm()->getScopeId();
351
 
352
  $inherit = false;
358
  ($scopeId == $config->getScopeId()) &&
359
  (!is_null($config->getValue()))
360
  ) {
361
+ $configData[$path]['data'] = $config->getValue();
362
  $configData[$path]['inherit'] = $inherit;
363
+
364
  return $configData;
365
  }
366
  }
367
  $scopeParent = $this->_getScopeParent($scope, $scopeId);
368
+ $scope = $scopeParent['scope'];
369
+ $scopeId = $scopeParent['scope_id'];
370
+ $inherit = true;
371
  }
372
  }
373
 
376
 
377
  /**
378
  * Get Config Data Collection for Path
379
+ *
380
+ * @param $path
381
+ *
382
  * @return Mage_Core_Model_Resource_Config_Data_Collection
383
  */
384
  protected function _getConfigCollection($path)
392
 
393
  /**
394
  * Get Parent Scope
395
+ *
396
+ * @param string $scope
397
  * @param string|int $scopeId
398
+ *
399
  * @return array
400
  */
401
  protected function _getScopeParent($scope, $scopeId)
406
 
407
  switch ($scope) {
408
  case 'stores':
409
+ $scope = 'websites';
410
  $scopeId = Mage::app()->getStore($scopeId)->getWebsiteId();
411
  break;
412
  case 'websites':
413
+ $scope = 'default';
414
  $scopeId = 0;
415
  break;
416
  case 'default':
417
  default:
418
+ $scope = false;
419
  $scopeId = false;
420
  break;
421
  }
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Label.php CHANGED
@@ -9,6 +9,7 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Label
9
  {
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
 
12
  * @return string
13
  */
14
  public function render(Varien_Data_Form_Element_Abstract $element)
@@ -17,13 +18,13 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Label
17
 
18
  preg_match('/##[a-zA-Z-_]*##/', $label, $matches);
19
  if (isset($matches[0])) {
20
- $match = $matches[0];
21
  $section = str_replace('#', '', $match);
22
- $label = str_replace($match, '', $label);
23
 
24
  $sectionUrl = Mage::helper('bronto_email')->getScopeUrl('/system_config/edit/section/' . $section);
25
  $labelParts = explode('&raquo;', $label);
26
- $newLabel = trim($labelParts[0]) .
27
  " &raquo; <a href=\"{$sectionUrl}\" title=\"{$label}\"><strong>" .
28
  trim($labelParts[1]) .
29
  "</strong></a> &raquo; " .
9
  {
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
12
+ *
13
  * @return string
14
  */
15
  public function render(Varien_Data_Form_Element_Abstract $element)
18
 
19
  preg_match('/##[a-zA-Z-_]*##/', $label, $matches);
20
  if (isset($matches[0])) {
21
+ $match = $matches[0];
22
  $section = str_replace('#', '', $match);
23
+ $label = str_replace($match, '', $label);
24
 
25
  $sectionUrl = Mage::helper('bronto_email')->getScopeUrl('/system_config/edit/section/' . $section);
26
  $labelParts = explode('&raquo;', $label);
27
+ $newLabel = trim($labelParts[0]) .
28
  " &raquo; <a href=\"{$sectionUrl}\" title=\"{$label}\"><strong>" .
29
  trim($labelParts[1]) .
30
  "</strong></a> &raquo; " .
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Sendtype.php CHANGED
@@ -9,11 +9,12 @@ class Bronto_Email_Block_Adminhtml_System_Config_Templates_Sendtype
9
  {
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
 
12
  * @return string
13
  */
14
  public function render(Varien_Data_Form_Element_Abstract $element)
15
  {
16
- $realpath = str_replace('-', '/', str_replace('bronto_email_templates_', '', $element->getId()));
17
  $realValue = Mage::helper('bronto_email')->getAdminScopedConfig($realpath);
18
  if ('' == $realValue) {
19
  $realValue = 'marketing';
9
  {
10
  /**
11
  * @param Varien_Data_Form_Element_Abstract $element
12
+ *
13
  * @return string
14
  */
15
  public function render(Varien_Data_Form_Element_Abstract $element)
16
  {
17
+ $realpath = str_replace('-', '/', str_replace('bronto_email_templates_', '', $element->getId()));
18
  $realValue = Mage::helper('bronto_email')->getAdminScopedConfig($realpath);
19
  if ('' == $realValue) {
20
  $realValue = 'marketing';
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Import extends Mage_Adminhtml_Block_System_Email_Template
9
  {
@@ -28,18 +27,18 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import extends Mage_Adminhtml_Bl
28
  $this->setChild('back_button',
29
  $this->getLayout()->createBlock('adminhtml/widget_button')
30
  ->setData(array(
31
- 'label' => Mage::helper('adminhtml')->__('Back'),
32
- 'onclick' => "window.location='" . $this->getBackUrl() . "'",
33
- 'class' => 'scalable back',
34
  ))
35
  );
36
 
37
  $this->setChild('import_button',
38
  $this->getLayout()->createBlock('adminhtml/widget_button')
39
  ->setData(array(
40
- 'label' => Mage::helper('adminhtml')->__('Load Default Magento Templates'),
41
- 'onclick' => "window.location='" . $this->getLoadDefaultsUrl() . "'",
42
- 'class' => 'go'
43
  ))
44
  );
45
 
@@ -84,11 +83,13 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import extends Mage_Adminhtml_Bl
84
 
85
  /**
86
  * Get link to transactional email configuration
87
- * @return type
 
88
  */
89
  public function getConfigLink()
90
  {
91
  $url = $this->getUrl('/system_config/edit/section/bronto_email');
 
92
  return '<strong>System &rsaquo; Configuration &rsaquo; Bronto &raquo; <a href="' . $url . '" title="Transactional Emails">Transactional Emails</a></strong>';
93
  }
94
  }
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Import extends Mage_Adminhtml_Block_System_Email_Template
8
  {
27
  $this->setChild('back_button',
28
  $this->getLayout()->createBlock('adminhtml/widget_button')
29
  ->setData(array(
30
+ 'label' => Mage::helper('adminhtml')->__('Back'),
31
+ 'onclick' => "window.location='{$this->getBackUrl()}'",
32
+ 'class' => 'scalable back',
33
  ))
34
  );
35
 
36
  $this->setChild('import_button',
37
  $this->getLayout()->createBlock('adminhtml/widget_button')
38
  ->setData(array(
39
+ 'label' => Mage::helper('adminhtml')->__('Load Default Magento Templates'),
40
+ 'onclick' => "window.location='{$this->getLoadDefaultsUrl()}'",
41
+ 'class' => 'go'
42
  ))
43
  );
44
 
83
 
84
  /**
85
  * Get link to transactional email configuration
86
+ *
87
+ * @return string
88
  */
89
  public function getConfigLink()
90
  {
91
  $url = $this->getUrl('/system_config/edit/section/bronto_email');
92
+
93
  return '<strong>System &rsaquo; Configuration &rsaquo; Bronto &raquo; <a href="' . $url . '" title="Transactional Emails">Transactional Emails</a></strong>';
94
  }
95
  }
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Edit.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Import_Edit
9
  extends Mage_Adminhtml_Block_System_Email_Template_Edit
@@ -16,9 +15,9 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Edit
16
  $this->getLayout()->createBlock('adminhtml/widget_button')
17
  ->setData(
18
  array(
19
- 'label' => Mage::helper('adminhtml')->__('Back'),
20
  'onclick' => "window.location.href = '" . $this->getUrl('*/*/import') . "'",
21
- 'class' => 'back'
22
  )
23
  )
24
  );
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Import_Edit
8
  extends Mage_Adminhtml_Block_System_Email_Template_Edit
15
  $this->getLayout()->createBlock('adminhtml/widget_button')
16
  ->setData(
17
  array(
18
+ 'label' => Mage::helper('adminhtml')->__('Back'),
19
  'onclick' => "window.location.href = '" . $this->getUrl('*/*/import') . "'",
20
+ 'class' => 'back'
21
  )
22
  )
23
  );
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
9
  {
@@ -13,10 +12,11 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminht
13
  /* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
14
  $collection = Mage::getModel('bronto_email/template')->getCollection();
15
 
 
 
 
16
  // Apply conditional logic to handle 1.9 overriding collection _construct
17
  if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
18
- $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
19
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
20
  $collection->getSelect()->joinLeft(
21
  $brontoTable,
22
  "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
@@ -24,7 +24,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminht
24
  }
25
 
26
  // Limit grid to show only those templates without message id assigned
27
- $collection->addFieldToFilter('bronto_message_id', array('null' => true));
28
 
29
  $this->setCollection($collection);
30
 
@@ -43,11 +43,11 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminht
43
 
44
  if (Mage::helper('bronto_email')->isEnabledForAny()) {
45
  $this->addColumn('action', array(
46
- 'header' => Mage::helper('adminhtml')->__('Action'),
47
- 'index' => 'template_id',
48
  'sortable' => false,
49
- 'filter' => false,
50
- 'width' => '100px',
51
  'renderer' => 'bronto_email/adminhtml_system_email_import_grid_renderer_action'
52
  ));
53
  }
@@ -63,27 +63,30 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminht
63
  $stores = Mage::app()->getStores();
64
  if (is_array($stores) && count($stores) >= 1) {
65
  foreach ($stores as $store) {
66
- if (Mage::helper('bronto_email')->isEnabled($store->getId())) {
67
  $this->getMassactionBlock()->addItem('import|' . $store->getCode(), array(
68
- 'url' => $this->getUrl('*/*/massImport', array('template_id' => '', 'store_id' => $store->getId())),
69
- 'label' => Mage::helper('bronto_email')->__('Import For Store: ' . $store->getName()),
70
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will import the selected template(s) to Bronto for the specified store.'),
71
- ));
72
  }
73
  }
74
  }
75
 
76
  $this->getMassactionBlock()->addItem('delete', array(
77
- 'label' => Mage::helper('bronto_email')->__('Delete'),
78
- 'url' => $this->getUrl('*/*/massDelete', array('delete_level' => 'full')),
79
  'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will permanently delete the selected template(s). Please note: default templates can be re-loaded, but custom templates will be lost.')
80
  ));
 
81
  return $this;
82
  }
83
 
84
  /**
85
  * get Row Url for editing template on row click
86
- * @param type $row
 
 
87
  * @return string
88
  */
89
  public function getRowUrl($row)
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
8
  {
12
  /* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
13
  $collection = Mage::getModel('bronto_email/template')->getCollection();
14
 
15
+ $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
16
+ $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
17
+
18
  // Apply conditional logic to handle 1.9 overriding collection _construct
19
  if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
 
 
20
  $collection->getSelect()->joinLeft(
21
  $brontoTable,
22
  "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
24
  }
25
 
26
  // Limit grid to show only those templates without message id assigned
27
+ $collection->addFieldToFilter("`{$brontoTable}`.`bronto_message_id`", array('null' => true));
28
 
29
  $this->setCollection($collection);
30
 
43
 
44
  if (Mage::helper('bronto_email')->isEnabledForAny()) {
45
  $this->addColumn('action', array(
46
+ 'header' => Mage::helper('adminhtml')->__('Action'),
47
+ 'index' => 'template_id',
48
  'sortable' => false,
49
+ 'filter' => false,
50
+ 'width' => '100px',
51
  'renderer' => 'bronto_email/adminhtml_system_email_import_grid_renderer_action'
52
  ));
53
  }
63
  $stores = Mage::app()->getStores();
64
  if (is_array($stores) && count($stores) >= 1) {
65
  foreach ($stores as $store) {
66
+ if (Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
67
  $this->getMassactionBlock()->addItem('import|' . $store->getCode(), array(
68
+ 'url' => $this->getUrl('*/*/massImport', array('template_id' => '', 'store_id' => $store->getId())),
69
+ 'label' => Mage::helper('bronto_email')->__('Import For Store: ' . $store->getName()),
70
+ 'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will import the selected template(s) to Bronto for the specified store.'),
71
+ ));
72
  }
73
  }
74
  }
75
 
76
  $this->getMassactionBlock()->addItem('delete', array(
77
+ 'label' => Mage::helper('bronto_email')->__('Delete'),
78
+ 'url' => $this->getUrl('*/*/massDelete', array('delete_level' => 'full')),
79
  'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will permanently delete the selected template(s). Please note: default templates can be re-loaded, but custom templates will be lost.')
80
  ));
81
+
82
  return $this;
83
  }
84
 
85
  /**
86
  * get Row Url for editing template on row click
87
+ *
88
+ * @param $row
89
+ *
90
  * @return string
91
  */
92
  public function getRowUrl($row)
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid/Renderer/Action.php CHANGED
@@ -27,8 +27,8 @@
27
  /**
28
  * Adminhtml newsletter templates grid block action item renderer
29
  *
30
- * @category Mage
31
- * @package Mage_Adminhtml
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
 
@@ -39,16 +39,16 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid_Renderer_Action exte
39
  $actions = array();
40
 
41
  $actions[] = array(
42
- 'url' => $this->getUrl('*/*/edit', array('id' => $row->getId())),
43
  'caption' => $this->__('Edit'),
44
  );
45
 
46
  $stores = Mage::app()->getStores();
47
  if (is_array($stores) && count($stores) >= 1) {
48
  foreach ($stores as $store) {
49
- if (Mage::helper('bronto_email')->isEnabled($store->getId())) {
50
  $actions[] = array(
51
- 'url' => $this->getUrl('*/*/massImport', array('template_id' => $row->getId(), 'store_id' => $store->getId())),
52
  'caption' => $this->__('Import For Store: ' . $store->getName()),
53
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to import the selected template?'),
54
  );
@@ -56,7 +56,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid_Renderer_Action exte
56
  }
57
  }
58
  $actions[] = array(
59
- 'url' => $this->getUrl('*/*/massDelete', array('template_id' => $row->getId(), 'delete_level' => 'full')),
60
  'caption' => $this->__('Delete'),
61
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template?'),
62
  );
@@ -73,12 +73,13 @@ class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid_Renderer_Action exte
73
 
74
  protected function _actionsToHtml(array $actions)
75
  {
76
- $html = array();
77
  $attributesObject = new Varien_Object();
78
  foreach ($actions as $action) {
79
  $attributesObject->setData($action['@']);
80
  $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
81
  }
 
82
  return implode(' <span class="separator">&nbsp;|&nbsp;</span> ', $html);
83
  }
84
  }
27
  /**
28
  * Adminhtml newsletter templates grid block action item renderer
29
  *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
 
39
  $actions = array();
40
 
41
  $actions[] = array(
42
+ 'url' => $this->getUrl('*/*/edit', array('id' => $row->getId())),
43
  'caption' => $this->__('Edit'),
44
  );
45
 
46
  $stores = Mage::app()->getStores();
47
  if (is_array($stores) && count($stores) >= 1) {
48
  foreach ($stores as $store) {
49
+ if (Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
50
  $actions[] = array(
51
+ 'url' => $this->getUrl('*/*/massImport', array('template_id' => $row->getId(), 'store_id' => $store->getId())),
52
  'caption' => $this->__('Import For Store: ' . $store->getName()),
53
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to import the selected template?'),
54
  );
56
  }
57
  }
58
  $actions[] = array(
59
+ 'url' => $this->getUrl('*/*/massDelete', array('template_id' => $row->getId(), 'delete_level' => 'full')),
60
  'caption' => $this->__('Delete'),
61
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template?'),
62
  );
73
 
74
  protected function _actionsToHtml(array $actions)
75
  {
76
+ $html = array();
77
  $attributesObject = new Varien_Object();
78
  foreach ($actions as $action) {
79
  $attributesObject->setData($action['@']);
80
  $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
81
  }
82
+
83
  return implode(' <span class="separator">&nbsp;|&nbsp;</span> ', $html);
84
  }
85
  }
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
9
  {
@@ -24,15 +23,15 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block
24
 
25
  public function __construct()
26
  {
27
- $this->_headerText = Mage::helper('bronto_email')->__('Bronto Delivery Log');
28
 
29
  parent::__construct();
30
 
31
  $this->_addBackButton();
32
  $this->_addButton('clear', array(
33
- 'label' => $this->getClearButtonLabel(),
34
  'onclick' => 'setLocation(\'' . $this->getClearUrl() . '\')',
35
- 'class' => 'delete'
36
  ));
37
 
38
  $this->_removeButton('add');
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
8
  {
23
 
24
  public function __construct()
25
  {
26
+ $this->_headerText = Mage::helper('bronto_email')->__('Bronto Transactional Email Delivery Log');
27
 
28
  parent::__construct();
29
 
30
  $this->_addBackButton();
31
  $this->_addButton('clear', array(
32
+ 'label' => $this->getClearButtonLabel(),
33
  'onclick' => 'setLocation(\'' . $this->getClearUrl() . '\')',
34
+ 'class' => 'delete'
35
  ));
36
 
37
  $this->_removeButton('add');
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid.php CHANGED
@@ -3,13 +3,13 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
  {
10
  /**
 
 
11
  * @param array $attributes
12
- * @return void
13
  */
14
  public function __construct($attributes = array())
15
  {
@@ -20,70 +20,81 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid extends Mage_Adminhtml_
20
  $this->setSaveParametersInSession(true);
21
  }
22
 
 
 
 
 
 
23
  protected function _prepareCollection()
24
  {
25
  $collection = Mage::getModel('bronto_email/log')->getCollection();
26
  $this->setCollection($collection);
 
27
  return parent::_prepareCollection();
28
  }
29
 
 
 
 
 
 
30
  protected function _prepareColumns()
31
  {
32
  $this->addColumn('log_id', array(
33
  'header' => Mage::helper('bronto_email')->__('ID'),
34
- 'align' => 'left',
35
- 'index' => 'log_id',
36
- 'type' => 'number',
37
  'filter' => false,
38
  ));
39
 
40
  $this->addColumn('message_name', array(
41
  'header' => Mage::helper('bronto_email')->__('Message Name'),
42
- 'align' => 'left',
43
- 'index' => 'message_name',
44
  'filter' => false,
45
  ));
46
 
47
  $this->addColumn('sent_at', array(
48
  'header' => Mage::helper('bronto_email')->__('Sent At'),
49
- 'align' => 'left',
50
- 'index' => 'sent_at',
51
- 'type' => 'datetime'
52
  ));
53
 
54
  $this->addColumn('customer_email', array(
55
  'header' => Mage::helper('customer')->__('Email'),
56
- 'index' => 'customer_email',
57
- 'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_customer',
58
  ));
59
 
60
  $this->addColumn('success', array(
61
- 'header' => Mage::helper('bronto_email')->__('Success'),
62
- 'align' => 'left',
63
- 'index' => 'success',
64
  'sortable' => false,
65
- 'type' => 'options',
66
- 'options' => array(
67
  0 => 'No',
68
  1 => 'Yes',
69
  ),
70
  ));
71
 
72
  $this->addColumn('error', array(
73
- 'header' => Mage::helper('bronto_email')->__('Error'),
74
- 'align' => 'left',
75
- 'index' => 'error',
76
  'sortable' => false,
77
- 'filter' => false,
78
  ));
79
 
80
  $this->addColumn('data', array(
81
- 'header' => Mage::helper('bronto_email')->__('Fields'),
82
- 'align' => 'left',
83
- 'index' => 'data',
84
  'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_fields',
85
  'sortable' => false,
86
- 'filter' => false,
87
  ));
88
 
89
  return parent::_prepareColumns();
@@ -93,6 +104,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid extends Mage_Adminhtml_
93
  * Return row url for js event handlers
94
  *
95
  * @param Bronto_Email_Model_Log|Varien_Object
 
96
  * @return string
97
  */
98
  public function getRowUrl($log)
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
  {
9
  /**
10
+ * Constructor
11
+ *
12
  * @param array $attributes
 
13
  */
14
  public function __construct($attributes = array())
15
  {
20
  $this->setSaveParametersInSession(true);
21
  }
22
 
23
+ /**
24
+ * Prepare the collection
25
+ *
26
+ * @return this
27
+ */
28
  protected function _prepareCollection()
29
  {
30
  $collection = Mage::getModel('bronto_email/log')->getCollection();
31
  $this->setCollection($collection);
32
+
33
  return parent::_prepareCollection();
34
  }
35
 
36
+ /**
37
+ * Prepare the Columns
38
+ *
39
+ * @return $this
40
+ */
41
  protected function _prepareColumns()
42
  {
43
  $this->addColumn('log_id', array(
44
  'header' => Mage::helper('bronto_email')->__('ID'),
45
+ 'align' => 'left',
46
+ 'index' => 'log_id',
47
+ 'type' => 'number',
48
  'filter' => false,
49
  ));
50
 
51
  $this->addColumn('message_name', array(
52
  'header' => Mage::helper('bronto_email')->__('Message Name'),
53
+ 'align' => 'left',
54
+ 'index' => 'message_name',
55
  'filter' => false,
56
  ));
57
 
58
  $this->addColumn('sent_at', array(
59
  'header' => Mage::helper('bronto_email')->__('Sent At'),
60
+ 'align' => 'left',
61
+ 'index' => 'sent_at',
62
+ 'type' => 'datetime'
63
  ));
64
 
65
  $this->addColumn('customer_email', array(
66
  'header' => Mage::helper('customer')->__('Email'),
67
+ 'index' => 'customer_email',
68
+ // 'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_customer',
69
  ));
70
 
71
  $this->addColumn('success', array(
72
+ 'header' => Mage::helper('bronto_email')->__('Success'),
73
+ 'align' => 'left',
74
+ 'index' => 'success',
75
  'sortable' => false,
76
+ 'type' => 'options',
77
+ 'options' => array(
78
  0 => 'No',
79
  1 => 'Yes',
80
  ),
81
  ));
82
 
83
  $this->addColumn('error', array(
84
+ 'header' => Mage::helper('bronto_email')->__('Error'),
85
+ 'align' => 'left',
86
+ 'index' => 'error',
87
  'sortable' => false,
88
+ 'filter' => false,
89
  ));
90
 
91
  $this->addColumn('data', array(
92
+ 'header' => Mage::helper('bronto_email')->__('Fields'),
93
+ 'align' => 'left',
94
+ 'index' => 'data',
95
  'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_fields',
96
  'sortable' => false,
97
+ 'filter' => false,
98
  ));
99
 
100
  return parent::_prepareColumns();
104
  * Return row url for js event handlers
105
  *
106
  * @param Bronto_Email_Model_Log|Varien_Object
107
+ *
108
  * @return string
109
  */
110
  public function getRowUrl($log)
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Customer.php CHANGED
@@ -3,18 +3,19 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Customer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
  {
10
  /**
11
  * @param Varien_Object $row
 
12
  * @return mixed
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
  if ($row->getCustomerId() && Mage::getSingleton('admin/session')->isAllowed('customer/manage')) {
17
  $customerEditUrl = $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
 
18
  return sprintf(
19
  '<a href="%s">%s</a>',
20
  $customerEditUrl,
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Customer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
  {
9
  /**
10
  * @param Varien_Object $row
11
+ *
12
  * @return mixed
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
  if ($row->getCustomerId() && Mage::getSingleton('admin/session')->isAllowed('customer/manage')) {
17
  $customerEditUrl = $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
18
+
19
  return sprintf(
20
  '<a href="%s">%s</a>',
21
  $customerEditUrl,
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Fields.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Fields extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Fields extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
  {
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_Block_System_Email_Template
9
  {
@@ -28,18 +27,18 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
28
  $this->setChild('add_button',
29
  $this->getLayout()->createBlock('adminhtml/widget_button')
30
  ->setData(array(
31
- 'label' => Mage::helper('adminhtml')->__('Add Bronto Message'),
32
  'onclick' => "window.location='" . $this->getCreateUrl() . "'",
33
- 'class' => 'add'
34
  ))
35
  );
36
 
37
  $this->setChild('import_button',
38
  $this->getLayout()->createBlock('adminhtml/widget_button')
39
  ->setData(array(
40
- 'label' => Mage::helper('adminhtml')->__('Import Existing Templates'),
41
  'onclick' => "window.location='" . $this->getImportUrl() . "'",
42
- 'class' => 'go'
43
  ))
44
  );
45
 
@@ -47,9 +46,9 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
47
  $this->setChild('log_button',
48
  $this->getLayout()->createBlock('adminhtml/widget_button')
49
  ->setData(array(
50
- 'label' => Mage::helper('adminhtml')->__('Delivery Log'),
51
  'onclick' => "window.location='" . $this->getLogUrl() . "'",
52
- 'class' => 'go'
53
  ))
54
  );
55
  }
@@ -76,7 +75,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
76
  /**
77
  * Get URL for create new email template
78
  *
79
- * @return type
80
  */
81
  public function getCreateUrl()
82
  {
@@ -105,11 +104,13 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
105
 
106
  /**
107
  * Get link to transactional email configuration
108
- * @return type
 
109
  */
110
  public function getConfigLink()
111
  {
112
- $url = $this->getUrl('/system_config/edit/section/bronto_email');
 
113
  return '<strong>System &rsaquo; Configuration &raquo; Bronto &rsaquo; <a href="' . $url . '" title="Transactional Emails">Transactional Emails</a></strong>';
114
  }
115
 
@@ -117,7 +118,8 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
117
  * Generate url by route and parameters
118
  *
119
  * @param string $route
120
- * @param array $params
 
121
  * @return string
122
  */
123
  public function getUrl($route = '', $params = array())
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_Block_System_Email_Template
8
  {
27
  $this->setChild('add_button',
28
  $this->getLayout()->createBlock('adminhtml/widget_button')
29
  ->setData(array(
30
+ 'label' => Mage::helper('adminhtml')->__('Add Bronto Message'),
31
  'onclick' => "window.location='" . $this->getCreateUrl() . "'",
32
+ 'class' => 'add'
33
  ))
34
  );
35
 
36
  $this->setChild('import_button',
37
  $this->getLayout()->createBlock('adminhtml/widget_button')
38
  ->setData(array(
39
+ 'label' => Mage::helper('adminhtml')->__('Import Existing Templates'),
40
  'onclick' => "window.location='" . $this->getImportUrl() . "'",
41
+ 'class' => 'go'
42
  ))
43
  );
44
 
46
  $this->setChild('log_button',
47
  $this->getLayout()->createBlock('adminhtml/widget_button')
48
  ->setData(array(
49
+ 'label' => Mage::helper('adminhtml')->__('Delivery Log'),
50
  'onclick' => "window.location='" . $this->getLogUrl() . "'",
51
+ 'class' => 'go'
52
  ))
53
  );
54
  }
75
  /**
76
  * Get URL for create new email template
77
  *
78
+ * @return string
79
  */
80
  public function getCreateUrl()
81
  {
104
 
105
  /**
106
  * Get link to transactional email configuration
107
+ *
108
+ * @return string
109
  */
110
  public function getConfigLink()
111
  {
112
+ $url = $this->getUrl('*/system_config/edit', array('section' => 'bronto_email'));
113
+
114
  return '<strong>System &rsaquo; Configuration &raquo; Bronto &rsaquo; <a href="' . $url . '" title="Transactional Emails">Transactional Emails</a></strong>';
115
  }
116
 
118
  * Generate url by route and parameters
119
  *
120
  * @param string $route
121
+ * @param array $params
122
+ *
123
  * @return string
124
  */
125
  public function getUrl($route = '', $params = array())
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.4
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Adminhtml_Block_System_Email_Template_Edit
9
  {
@@ -15,10 +14,13 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
15
 
16
  Mage_Adminhtml_Block_Widget::__construct();
17
  $this->setTemplate('bronto/email/template/edit.phtml');
 
 
18
  }
19
 
20
  /**
21
  * Prepare the layout, removing unneeded elements and changing button/form
 
22
  * @return null
23
  */
24
  protected function _prepareLayout()
@@ -35,14 +37,16 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
35
  $this->unsetChild('form');
36
 
37
  $this->setChild('save_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
38
- 'label' => Mage::helper('adminhtml')->__('Save Message'),
39
  'onclick' => 'templateControl.save();',
40
- 'class' => 'save'
41
  )));
42
 
43
  $this->setChild('form',
44
  $this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_edit_form')
45
  );
 
 
46
  }
47
 
48
  /**
@@ -66,8 +70,9 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
66
  /**
67
  * Get array or Json of path data
68
  *
69
- * @param boolean $asJSON
70
- * @return array|json
 
71
  */
72
  public function getUsedDefaultForPaths($asJSON = true)
73
  {
@@ -75,7 +80,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
75
  if (Mage::helper('bronto_email')->isEnabledForAny()) {
76
  if ($this->getEmailTemplate()->hasData('store_id')) {
77
  $paths[0]['scope_id'] = $this->getEmailTemplate()->getData('store_id');
78
- $paths[0]['scope'] = 'stores';
79
  }
80
  }
81
 
@@ -92,27 +97,30 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
92
  * Get paths of where current template is currently used
93
  *
94
  * @param bool $asJSON
 
95
  * @return string
96
  */
97
  public function getUsedCurrentlyForPaths($asJSON = true)
98
  {
99
- $paths = $this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently();
100
  $pathsParts = $this->_getSystemConfigPathsParts($paths);
101
  if ($asJSON) {
102
  return Mage::helper('core')->jsonEncode($pathsParts);
103
  }
 
104
  return $pathsParts;
105
  }
106
 
107
  /**
108
- * Convert xml config pathes to decorated names
109
  *
110
  * @param array $paths
 
111
  * @return array
112
  */
113
  protected function _getSystemConfigPathsParts($paths)
114
  {
115
- $result = $urlParams = $prefixParts = array();
116
  $scopeLabel = Mage::helper('adminhtml')->__('GLOBAL');
117
  if ($paths) {
118
  // create prefix path parts
@@ -123,7 +131,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
123
  // Add "Configuration" to path
124
  $prefixParts[] = array(
125
  'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system/config'),
126
- 'url' => $this->getUrl('adminhtml/system_config/'),
127
  );
128
 
129
  // Cycle through paths to add them to the path details
@@ -141,15 +149,15 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
141
  $store = Mage::app()->getStore($pathData['scope_id']);
142
  if ($store) {
143
  $urlParams['website'] = $store->getWebsite()->getCode();
144
- $urlParams['store'] = $store->getCode();
145
- $scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName();
146
  }
147
  break;
148
  case 'websites':
149
  $website = Mage::app()->getWebsite($pathData['scope_id']);
150
  if ($website) {
151
  $urlParams['website'] = $website->getCode();
152
- $scopeLabel = $website->getName();
153
  }
154
  break;
155
  default:
@@ -164,7 +172,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
164
  if ($sectionTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName)) {
165
  $pathParts[] = array(
166
  'title' => $sectionTitle,
167
- 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams),
168
  );
169
  }
170
  // If Group Name is set, add it to path
@@ -181,7 +189,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
181
  );
182
  }
183
 
184
- $result[] = $pathParts;
185
  $pathParts = $prefixParts;
186
  }
187
  }
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Adminhtml_Block_System_Email_Template_Edit
8
  {
14
 
15
  Mage_Adminhtml_Block_Widget::__construct();
16
  $this->setTemplate('bronto/email/template/edit.phtml');
17
+
18
+ return $this;
19
  }
20
 
21
  /**
22
  * Prepare the layout, removing unneeded elements and changing button/form
23
+ *
24
  * @return null
25
  */
26
  protected function _prepareLayout()
37
  $this->unsetChild('form');
38
 
39
  $this->setChild('save_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
40
+ 'label' => Mage::helper('adminhtml')->__('Save Message'),
41
  'onclick' => 'templateControl.save();',
42
+ 'class' => 'save'
43
  )));
44
 
45
  $this->setChild('form',
46
  $this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_edit_form')
47
  );
48
+
49
+ return $this;
50
  }
51
 
52
  /**
70
  /**
71
  * Get array or Json of path data
72
  *
73
+ * @param bool $asJSON
74
+ *
75
+ * @return array|string
76
  */
77
  public function getUsedDefaultForPaths($asJSON = true)
78
  {
80
  if (Mage::helper('bronto_email')->isEnabledForAny()) {
81
  if ($this->getEmailTemplate()->hasData('store_id')) {
82
  $paths[0]['scope_id'] = $this->getEmailTemplate()->getData('store_id');
83
+ $paths[0]['scope'] = 'stores';
84
  }
85
  }
86
 
97
  * Get paths of where current template is currently used
98
  *
99
  * @param bool $asJSON
100
+ *
101
  * @return string
102
  */
103
  public function getUsedCurrentlyForPaths($asJSON = true)
104
  {
105
+ $paths = $this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently();
106
  $pathsParts = $this->_getSystemConfigPathsParts($paths);
107
  if ($asJSON) {
108
  return Mage::helper('core')->jsonEncode($pathsParts);
109
  }
110
+
111
  return $pathsParts;
112
  }
113
 
114
  /**
115
+ * Convert xml config paths to decorated names
116
  *
117
  * @param array $paths
118
+ *
119
  * @return array
120
  */
121
  protected function _getSystemConfigPathsParts($paths)
122
  {
123
+ $result = $urlParams = $prefixParts = array();
124
  $scopeLabel = Mage::helper('adminhtml')->__('GLOBAL');
125
  if ($paths) {
126
  // create prefix path parts
131
  // Add "Configuration" to path
132
  $prefixParts[] = array(
133
  'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system/config'),
134
+ 'url' => $this->getUrl('adminhtml/system_config/'),
135
  );
136
 
137
  // Cycle through paths to add them to the path details
149
  $store = Mage::app()->getStore($pathData['scope_id']);
150
  if ($store) {
151
  $urlParams['website'] = $store->getWebsite()->getCode();
152
+ $urlParams['store'] = $store->getCode();
153
+ $scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName();
154
  }
155
  break;
156
  case 'websites':
157
  $website = Mage::app()->getWebsite($pathData['scope_id']);
158
  if ($website) {
159
  $urlParams['website'] = $website->getCode();
160
+ $scopeLabel = $website->getName();
161
  }
162
  break;
163
  default:
172
  if ($sectionTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName)) {
173
  $pathParts[] = array(
174
  'title' => $sectionTitle,
175
+ 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams),
176
  );
177
  }
178
  // If Group Name is set, add it to path
189
  );
190
  }
191
 
192
+ $result[] = $pathParts;
193
  $pathParts = $prefixParts;
194
  }
195
  }
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit/Form.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
9
  {
@@ -22,6 +21,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
22
  ->addCss('lib/prototype/windows/themes/magento.css')
23
  ->addItem('js', 'mage/adminhtml/variables.js');
24
  }
 
25
  return parent::_prepareLayout();
26
  }
27
 
@@ -33,6 +33,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
33
  // If Bronto Email module not enabled, use Mage
34
  if (!Mage::helper('bronto_email')->isEnabledForAny()) {
35
  $parent = new Mage_Adminhtml_Block_System_Email_Template_Edit_Form();
 
36
  return $parent->_prepareForm();
37
  }
38
 
@@ -42,7 +43,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
42
  // Create New Form Fieldset Element
43
  $fieldset = $form->addFieldset('base_fieldset', array(
44
  'legend' => Mage::helper('adminhtml')->__('Template Information'),
45
- 'class' => 'fieldset-wide'
46
  ));
47
 
48
  // Get the TemplateID
@@ -51,37 +52,37 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
51
  // Build "Used Current/Default For"
52
  if ($templateId) {
53
  $fieldset->addField('used_currently_for', 'label', array(
54
- 'label' => Mage::helper('adminhtml')->__('Used Currently For'),
55
- 'container_id' => 'used_currently_for',
56
  'after_element_html' =>
57
- '<script type="text/javascript">' .
58
- (!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently() ? '$(\'' . 'used_currently_for' . '\').hide(); ' : '') .
59
- '</script>',
60
  ));
61
  if (!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently()) {
62
  $fieldset->addField('used_default_for', 'label', array(
63
- 'label' => Mage::helper('adminhtml')->__('Used as Default For'),
64
- 'container_id' => 'used_default_for',
65
  'after_element_html' =>
66
- '<script type="text/javascript">' .
67
- (!(bool)$this->getEmailTemplate()->getOrigTemplateCode() ? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
68
- '</script>',
69
  ));
70
 
71
  $fieldset->addField('note_used_currently', 'label', array(
72
- 'label' => '',
73
- 'container_id' => 'note_used_currently',
74
  'after_element_html' => '<div style="color:red;"><strong>Note:</strong> This Email Message is currently not used.</div>',
75
  ));
76
  }
77
  } else {
78
  $fieldset->addField('used_default_for', 'label', array(
79
- 'label' => Mage::helper('adminhtml')->__('Used as Default For'),
80
- 'container_id' => 'used_default_for',
81
  'after_element_html' =>
82
- '<script type="text/javascript">' .
83
- (!(bool)$this->getEmailTemplate()->getOrigTemplateCode() ? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
84
- '</script>',
85
  ));
86
  }
87
 
@@ -89,28 +90,28 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
89
  // Otherwise set hidden field with single store Id
90
  if (!Mage::app()->isSingleStoreMode()) {
91
  $fieldset->addField('store_id', 'select', array(
92
- 'name' => 'store_id',
93
- 'label' => Mage::helper('adminhtml')->__('Store View'),
94
- 'title' => Mage::helper('adminhtml')->__('Store View'),
95
  'onchange' => "updateMessages();",
96
  'required' => true,
97
- 'values' => $this->_getActiveStoreValuesForForm(false, false),
98
  ));
99
  } else {
100
  $fieldset->addField('store_id', 'hidden', array(
101
- 'name' => 'store_id',
102
- 'value' => Mage::app()->getStore(true)->getId()
103
  ));
104
  }
105
 
106
  // Create field for selecting How the template will be sent
107
  $sendtype = $fieldset->addField('template_send_type', 'select', array(
108
- 'name' => 'template_send_type',
109
- 'label' => Mage::helper('adminhtml')->__('Send Type'),
110
- 'title' => Mage::helper('adminhtml')->__('Send Type'),
111
  'onchange' => "updateMessages();",
112
  'required' => true,
113
- 'values' => array('magento' => 'Magento Email', 'marketing' => 'Bronto Marketing', 'transactional' => 'Bronto Transactional'),
114
  ));
115
 
116
  // Add Script after send type field to handle updating form
@@ -124,8 +125,10 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
124
  if (sendType == 'magento') {
125
  // Disable Some
126
  $('bronto_message_id').disable();
 
127
  $('orig_template_text').disable();
128
  $('container_bronto_message_id').hide();
 
129
  $('container_orig_template_text').hide();
130
 
131
  // Enable Others
@@ -142,8 +145,10 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
142
  } else {
143
  // Enable Some
144
  $('bronto_message_id').enable();
 
145
  $('orig_template_text').enable();
146
  $('container_bronto_message_id').show();
 
147
  $('container_orig_template_text').show();
148
 
149
  // Disable Others
@@ -192,53 +197,65 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
192
 
193
  // Template Name/Code
194
  $fieldset->addField('template_code', 'text', array(
195
- 'name' => 'template_code',
196
- 'label' => Mage::helper('adminhtml')->__('Name'),
197
  'required' => true
198
  ));
199
 
200
  // Add hidden fields to hold backups of the necessary values
201
  $fieldset->addField('bronto_message_id_hidden', 'hidden', array('name' => 'bronto_message_id_hidden'));
 
202
  $fieldset->addField('template_subject_hidden', 'hidden', array('name' => 'template_subject_hidden'));
203
  $fieldset->addField('template_text_hidden', 'hidden', array('name' => 'template_text_hidden'));
204
  $fieldset->addField('template_styles_hidden', 'hidden', array('name' => 'template_styles_hidden'));
205
 
206
  // Used for magento send type
207
  $fieldset->addField('template_subject', 'text', array(
208
- 'name' => 'template_subject',
209
- 'label' => Mage::helper('adminhtml')->__('Template Subject'),
210
- 'onchange' => "syncHiddenValue(this);",
211
  'container_id' => 'container_template_subject',
212
- 'required' => true,
213
  ));
214
 
215
  // Create field to allow selecting Bronto Message to bind to template
216
  $fieldset->addField('bronto_message_id', 'select', array(
217
- 'name' => 'bronto_message_id',
218
- 'label' => Mage::helper('adminhtml')->__('Bronto Message'),
219
  'container_id' => 'container_bronto_message_id',
220
- 'onchange' => "syncHiddenValue(this);",
221
- 'values' => Mage::helper('bronto_email/message')->getAllMessageOptions(),
222
- 'required' => true,
 
 
 
 
 
 
 
 
 
 
 
223
  ));
224
 
225
  // Display Variables that are available for the original template
226
  $fieldset->addField('template_variables_key', 'label', array(
227
- 'container_id' => 'template_variables_key_row',
228
- 'label' => Mage::helper('adminhtml')->__('Variables'),
229
  'after_element_html' => '<div id="template_variables_key_list"></div>' .
230
- ($templateId ? '' : '<script>$("template_variables_key_row").hide();</script>')
231
  ));
232
 
233
  // Display template text that was imported into Bronto
234
  $fieldset->addField('orig_template_text', 'textarea', array(
235
- 'name' => 'orig_template_text',
236
- 'label' => Mage::helper('adminhtml')->__('Original Template Content'),
237
- 'note' => $this->__('<strong>For Reference Only</strong>'),
238
  'container_id' => 'container_orig_template_text',
239
- 'onchange' => "syncHiddenValue(this);",
240
- 'readonly' => true,
241
- 'style' => 'height:24em;background-color:#efefef;',
242
  ));
243
 
244
  $fieldset->addField('orig_template_variables', 'hidden', array(
@@ -246,7 +263,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
246
  ));
247
 
248
  $fieldset->addField('variables', 'hidden', array(
249
- 'name' => 'variables',
250
  'value' => Zend_Json::encode($this->getVariables())
251
  ));
252
 
@@ -257,10 +274,10 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
257
  // Used for magento send type
258
  $insertVariableButton = $this->getLayout()
259
  ->createBlock('adminhtml/widget_button', '', array(
260
- 'type' => 'button',
261
- 'label' => Mage::helper('adminhtml')->__('Insert Variable...'),
262
  'container_id' => 'container_widget_button',
263
- 'onclick' => 'templateControl.openVariableChooser();return false;',
264
  ));
265
 
266
  $fieldset->addField('insert_variable', 'note', array(
@@ -268,33 +285,34 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
268
  ));
269
 
270
  $fieldset->addField('template_text', 'textarea', array(
271
- 'name' => 'template_text',
272
- 'label' => Mage::helper('adminhtml')->__('Template Content'),
273
- 'title' => Mage::helper('adminhtml')->__('Template Content'),
274
  'container_id' => 'container_template_text',
275
- 'onchange' => "syncHiddenValue(this);",
276
- 'required' => true,
277
- 'style' => 'height:24em',
278
  ));
279
 
280
  if (!$this->getEmailTemplate()->isPlain()) {
281
  $fieldset->addField('template_styles', 'textarea', array(
282
- 'name' => 'template_styles',
283
- 'label' => Mage::helper('adminhtml')->__('Template Styles'),
284
  'container_id' => 'field_template_styles',
285
- 'onchange' => "syncHiddenValue(this);",
286
  ));
287
  }
288
 
289
  if ($templateId) {
290
  $form->addValues($this->getEmailTemplate()->getData());
291
  $form->addValues(array(
292
- 'template_variables' => Zend_Json::encode($this->getEmailTemplate()->getVariablesOptionArray(true)),
293
  // Populate hidden fields
294
  'bronto_message_id_hidden' => $this->getEmailTemplate()->getBrontoMessageId(),
295
- 'template_subject_hidden' => $this->getEmailTemplate()->getTemplateSubject(),
296
- 'template_text_hidden' => $this->getEmailTemplate()->getTemplateText(),
297
- 'template_styles_hidden' => $this->getEmailTemplate()->getTemplateStyles(),
 
298
  ));
299
  }
300
 
@@ -319,6 +337,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
319
 
320
  /**
321
  * Filter Store Options by stores where module is enabled
 
322
  * @param bool $empty
323
  * @param bool $all
324
  *
@@ -351,7 +370,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
351
  // If Sub-Option value is a string and is numeric
352
  if (is_string($subOption['value']) && is_numeric($subOption['value'])) {
353
  // If Sub-Option Value is a store id and that store is not enabled, unset it's value
354
- if (!Mage::helper('bronto_email')->isEnabled($subOption['value'])) {
355
  unset($storeOptions[$optionId]['value'][$subId]);
356
  // If Option no longer has any values, remove Option
357
  if (count($storeOptions[$optionId]['value']) < 1) {
@@ -381,8 +400,8 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
381
  */
382
  public function getVariables()
383
  {
384
- $variables = array();
385
- $variables[] = Mage::getModel('core/source_email_variables')
386
  ->toOptionArray(true);
387
  $customVariables = Mage::getModel('core/variable')
388
  ->getVariablesOptionArray(true);
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
8
  {
21
  ->addCss('lib/prototype/windows/themes/magento.css')
22
  ->addItem('js', 'mage/adminhtml/variables.js');
23
  }
24
+
25
  return parent::_prepareLayout();
26
  }
27
 
33
  // If Bronto Email module not enabled, use Mage
34
  if (!Mage::helper('bronto_email')->isEnabledForAny()) {
35
  $parent = new Mage_Adminhtml_Block_System_Email_Template_Edit_Form();
36
+
37
  return $parent->_prepareForm();
38
  }
39
 
43
  // Create New Form Fieldset Element
44
  $fieldset = $form->addFieldset('base_fieldset', array(
45
  'legend' => Mage::helper('adminhtml')->__('Template Information'),
46
+ 'class' => 'fieldset-wide'
47
  ));
48
 
49
  // Get the TemplateID
52
  // Build "Used Current/Default For"
53
  if ($templateId) {
54
  $fieldset->addField('used_currently_for', 'label', array(
55
+ 'label' => Mage::helper('adminhtml')->__('Used Currently For'),
56
+ 'container_id' => 'used_currently_for',
57
  'after_element_html' =>
58
+ '<script type="text/javascript">' .
59
+ (!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently() ? '$(\'' . 'used_currently_for' . '\').hide(); ' : '') .
60
+ '</script>',
61
  ));
62
  if (!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently()) {
63
  $fieldset->addField('used_default_for', 'label', array(
64
+ 'label' => Mage::helper('adminhtml')->__('Used as Default For'),
65
+ 'container_id' => 'used_default_for',
66
  'after_element_html' =>
67
+ '<script type="text/javascript">' .
68
+ (!(bool)$this->getEmailTemplate()->getOrigTemplateCode() ? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
69
+ '</script>',
70
  ));
71
 
72
  $fieldset->addField('note_used_currently', 'label', array(
73
+ 'label' => '',
74
+ 'container_id' => 'note_used_currently',
75
  'after_element_html' => '<div style="color:red;"><strong>Note:</strong> This Email Message is currently not used.</div>',
76
  ));
77
  }
78
  } else {
79
  $fieldset->addField('used_default_for', 'label', array(
80
+ 'label' => Mage::helper('adminhtml')->__('Used as Default For'),
81
+ 'container_id' => 'used_default_for',
82
  'after_element_html' =>
83
+ '<script type="text/javascript">' .
84
+ (!(bool)$this->getEmailTemplate()->getOrigTemplateCode() ? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
85
+ '</script>',
86
  ));
87
  }
88
 
90
  // Otherwise set hidden field with single store Id
91
  if (!Mage::app()->isSingleStoreMode()) {
92
  $fieldset->addField('store_id', 'select', array(
93
+ 'name' => 'store_id',
94
+ 'label' => Mage::helper('adminhtml')->__('Store View'),
95
+ 'title' => Mage::helper('adminhtml')->__('Store View'),
96
  'onchange' => "updateMessages();",
97
  'required' => true,
98
+ 'values' => $this->_getActiveStoreValuesForForm(false, false),
99
  ));
100
  } else {
101
  $fieldset->addField('store_id', 'hidden', array(
102
+ 'name' => 'store_id',
103
+ 'value' => Mage::app()->getStore(true)->getId(),
104
  ));
105
  }
106
 
107
  // Create field for selecting How the template will be sent
108
  $sendtype = $fieldset->addField('template_send_type', 'select', array(
109
+ 'name' => 'template_send_type',
110
+ 'label' => Mage::helper('adminhtml')->__('Send Type'),
111
+ 'title' => Mage::helper('adminhtml')->__('Send Type'),
112
  'onchange' => "updateMessages();",
113
  'required' => true,
114
+ 'values' => array('magento' => 'Magento Email', 'marketing' => 'Bronto Marketing', 'transactional' => 'Bronto Transactional'),
115
  ));
116
 
117
  // Add Script after send type field to handle updating form
125
  if (sendType == 'magento') {
126
  // Disable Some
127
  $('bronto_message_id').disable();
128
+ $('sales_rule').disable();
129
  $('orig_template_text').disable();
130
  $('container_bronto_message_id').hide();
131
+ $('container_sales_rule').hide();
132
  $('container_orig_template_text').hide();
133
 
134
  // Enable Others
145
  } else {
146
  // Enable Some
147
  $('bronto_message_id').enable();
148
+ $('sales_rule').enable();
149
  $('orig_template_text').enable();
150
  $('container_bronto_message_id').show();
151
+ $('container_sales_rule').show();
152
  $('container_orig_template_text').show();
153
 
154
  // Disable Others
197
 
198
  // Template Name/Code
199
  $fieldset->addField('template_code', 'text', array(
200
+ 'name' => 'template_code',
201
+ 'label' => Mage::helper('adminhtml')->__('Name'),
202
  'required' => true
203
  ));
204
 
205
  // Add hidden fields to hold backups of the necessary values
206
  $fieldset->addField('bronto_message_id_hidden', 'hidden', array('name' => 'bronto_message_id_hidden'));
207
+ $fieldset->addField('sales_rule_hidden', 'hidden', array('name' => 'sales_rule_hidden'));
208
  $fieldset->addField('template_subject_hidden', 'hidden', array('name' => 'template_subject_hidden'));
209
  $fieldset->addField('template_text_hidden', 'hidden', array('name' => 'template_text_hidden'));
210
  $fieldset->addField('template_styles_hidden', 'hidden', array('name' => 'template_styles_hidden'));
211
 
212
  // Used for magento send type
213
  $fieldset->addField('template_subject', 'text', array(
214
+ 'name' => 'template_subject',
215
+ 'label' => Mage::helper('adminhtml')->__('Template Subject'),
216
+ 'onchange' => "syncHiddenValue(this);",
217
  'container_id' => 'container_template_subject',
218
+ 'required' => true,
219
  ));
220
 
221
  // Create field to allow selecting Bronto Message to bind to template
222
  $fieldset->addField('bronto_message_id', 'select', array(
223
+ 'name' => 'bronto_message_id',
224
+ 'label' => Mage::helper('adminhtml')->__('Bronto Message'),
225
  'container_id' => 'container_bronto_message_id',
226
+ 'onchange' => "syncHiddenValue(this);",
227
+ 'values' => Mage::helper('bronto_email/message')->getAllMessageOptions(),
228
+ 'required' => true,
229
+ ));
230
+
231
+ // Create field to allow selecting a sales rule to pull a coupon code from
232
+ $fieldset->addField('sales_rule', 'select', array(
233
+ 'name' => 'sales_rule',
234
+ 'label' => Mage::helper('adminhtml')->__('Shopping Cart Price Rule Coupon Code'),
235
+ 'note' => $this->__('Use API tag <em>%%%%#couponCode%%%%</em> within your message in Bronto. You are responsible for ensuring the shopping cart price rule is active and valid, or else it may appear blank.'),
236
+ 'container_id' => 'container_sales_rule',
237
+ 'onchange' => "syncHiddenValue(this);",
238
+ 'values' => Mage::helper('bronto_common/salesrule')->getRuleOptionsArray(),
239
+ 'required' => false,
240
  ));
241
 
242
  // Display Variables that are available for the original template
243
  $fieldset->addField('template_variables_key', 'label', array(
244
+ 'container_id' => 'template_variables_key_row',
245
+ 'label' => Mage::helper('adminhtml')->__('Variables'),
246
  'after_element_html' => '<div id="template_variables_key_list"></div>' .
247
+ ($templateId ? '' : '<script>$("template_variables_key_row").hide();</script>')
248
  ));
249
 
250
  // Display template text that was imported into Bronto
251
  $fieldset->addField('orig_template_text', 'textarea', array(
252
+ 'name' => 'orig_template_text',
253
+ 'label' => Mage::helper('adminhtml')->__('Original Template Content'),
254
+ 'note' => $this->__('For Reference Only'),
255
  'container_id' => 'container_orig_template_text',
256
+ 'onchange' => "syncHiddenValue(this);",
257
+ 'readonly' => true,
258
+ 'style' => 'height:24em;background-color:#efefef;',
259
  ));
260
 
261
  $fieldset->addField('orig_template_variables', 'hidden', array(
263
  ));
264
 
265
  $fieldset->addField('variables', 'hidden', array(
266
+ 'name' => 'variables',
267
  'value' => Zend_Json::encode($this->getVariables())
268
  ));
269
 
274
  // Used for magento send type
275
  $insertVariableButton = $this->getLayout()
276
  ->createBlock('adminhtml/widget_button', '', array(
277
+ 'type' => 'button',
278
+ 'label' => Mage::helper('adminhtml')->__('Insert Variable...'),
279
  'container_id' => 'container_widget_button',
280
+ 'onclick' => 'templateControl.openVariableChooser();return false;',
281
  ));
282
 
283
  $fieldset->addField('insert_variable', 'note', array(
285
  ));
286
 
287
  $fieldset->addField('template_text', 'textarea', array(
288
+ 'name' => 'template_text',
289
+ 'label' => Mage::helper('adminhtml')->__('Template Content'),
290
+ 'title' => Mage::helper('adminhtml')->__('Template Content'),
291
  'container_id' => 'container_template_text',
292
+ 'onchange' => "syncHiddenValue(this);",
293
+ 'required' => true,
294
+ 'style' => 'height:24em',
295
  ));
296
 
297
  if (!$this->getEmailTemplate()->isPlain()) {
298
  $fieldset->addField('template_styles', 'textarea', array(
299
+ 'name' => 'template_styles',
300
+ 'label' => Mage::helper('adminhtml')->__('Template Styles'),
301
  'container_id' => 'field_template_styles',
302
+ 'onchange' => "syncHiddenValue(this);",
303
  ));
304
  }
305
 
306
  if ($templateId) {
307
  $form->addValues($this->getEmailTemplate()->getData());
308
  $form->addValues(array(
309
+ 'template_variables' => Zend_Json::encode($this->getEmailTemplate()->getVariablesOptionArray(true)),
310
  // Populate hidden fields
311
  'bronto_message_id_hidden' => $this->getEmailTemplate()->getBrontoMessageId(),
312
+ 'sales_rule_hidden' => $this->getEmailTemplate()->getSalesRule(),
313
+ 'template_subject_hidden' => $this->getEmailTemplate()->getTemplateSubject(),
314
+ 'template_text_hidden' => $this->getEmailTemplate()->getTemplateText(),
315
+ 'template_styles_hidden' => $this->getEmailTemplate()->getTemplateStyles(),
316
  ));
317
  }
318
 
337
 
338
  /**
339
  * Filter Store Options by stores where module is enabled
340
+ *
341
  * @param bool $empty
342
  * @param bool $all
343
  *
370
  // If Sub-Option value is a string and is numeric
371
  if (is_string($subOption['value']) && is_numeric($subOption['value'])) {
372
  // If Sub-Option Value is a store id and that store is not enabled, unset it's value
373
+ if (!Mage::helper('bronto_email')->isEnabled('store', $subOption['value'])) {
374
  unset($storeOptions[$optionId]['value'][$subId]);
375
  // If Option no longer has any values, remove Option
376
  if (count($storeOptions[$optionId]['value']) < 1) {
400
  */
401
  public function getVariables()
402
  {
403
+ $variables = array();
404
+ $variables[] = Mage::getModel('core/source_email_variables')
405
  ->toOptionArray(true);
406
  $customVariables = Mage::getModel('core/variable')
407
  ->getVariablesOptionArray(true);
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
9
  {
@@ -19,10 +18,11 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
19
  /* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
20
  $collection = Mage::getModel('bronto_email/template')->getCollection();
21
 
 
 
 
22
  // Apply conditional logic to handle 1.9 overriding collection _construct
23
  if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
24
- $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
25
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
26
  $collection->getSelect()->joinLeft(
27
  $brontoTable,
28
  "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
@@ -30,7 +30,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
30
  }
31
 
32
  // Limit grid to show only those templates with message id assigned
33
- $collection->addFieldToFilter('bronto_message_id', array('notnull' => true));
34
 
35
  $this->setCollection($collection);
36
 
@@ -51,47 +51,47 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
51
  $this->addColumn(
52
  'template_id', array(
53
  'header' => Mage::helper('adminhtml')->__('ID'),
54
- 'index' => 'template_id',
55
- 'width' => '30px',
56
  )
57
  );
58
 
59
  $this->addColumn(
60
  'added_at', array(
61
- 'header' => Mage::helper('adminhtml')->__('Date Added'),
62
- 'index' => 'added_at',
63
  'gmtoffset' => true,
64
- 'type' => 'datetime'
65
  )
66
  );
67
 
68
  $this->addColumn(
69
  'modified_at', array(
70
- 'header' => Mage::helper('adminhtml')->__('Date Updated'),
71
- 'index' => 'modified_at',
72
  'gmtoffset' => true,
73
- 'type' => 'datetime'
74
  )
75
  );
76
 
77
  $this->addColumn(
78
- 'temlate_code', array(
79
  'header' => Mage::helper('adminhtml')->__('Name'),
80
- 'index' => 'template_code'
81
  )
82
  );
83
 
84
  $this->addColumn(
85
  'message_name', array(
86
  'header' => Mage::helper('adminhtml')->__('Bronto Message'),
87
- 'index' => 'bronto_message_name',
88
  )
89
  );
90
 
91
  $storeCodes = array();
92
  foreach (Mage::app()->getStores() as $id => $store) {
93
  $storeName = $store->getName();
94
- if (!Mage::helper('bronto_email')->isEnabled($store->getId())) {
95
  $storeName .= ' (Disabled)';
96
  }
97
  $storeCodes[$id] = $storeName;
@@ -99,10 +99,10 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
99
 
100
  $this->addColumn(
101
  'store', array(
102
- 'header' => Mage::helper('adminhtml')->__('Store'),
103
- 'index' => 'store_id',
104
- 'type' => 'options',
105
- 'options' => $storeCodes,
106
  'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_storename',
107
  )
108
  );
@@ -110,23 +110,23 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
110
  $this->addColumn(
111
  'template_send_type',
112
  array(
113
- 'header' => Mage::helper('adminhtml')->__('Send Type'),
114
- 'index' => 'template_send_type',
115
- 'type' => 'options',
116
  'options' => array(
117
- 'marketing' => 'Bronto Marketing',
118
  'transactional' => 'Bronto Transactional',
119
- 'magento' => 'Magento Email',
120
  ),
121
  )
122
  );
123
 
124
  $this->addColumn('action', array(
125
- 'header' => Mage::helper('adminhtml')->__('Action'),
126
- 'index' => 'template_id',
127
  'sortable' => false,
128
- 'filter' => false,
129
- 'width' => '130px',
130
  'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_action'
131
  ));
132
 
@@ -138,31 +138,34 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
138
  $this->setMassactionIdField('template_id');
139
  $this->getMassactionBlock()->setFormFieldName('template_id');
140
  $this->getMassactionBlock()->addItem('marketing', array(
141
- 'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Marketing'),
142
- 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'marketing')),
143
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a marketing message?')
144
  ));
145
  $this->getMassactionBlock()->addItem('transactional', array(
146
- 'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Transactional'),
147
- 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'transactional')),
148
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a transactional message?')
149
  ));
150
  $this->getMassactionBlock()->addItem('magento', array(
151
- 'label' => Mage::helper('bronto_email')->__('Set to send as Magento Email'),
152
- 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'magento')),
153
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Magento?')
154
  ));
155
  $this->getMassactionBlock()->addItem('delete', array(
156
- 'label' => Mage::helper('bronto_email')->__('Delete'),
157
- 'url' => $this->getUrl('*/*/massDelete', array('' => '')),
158
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template(s)? If any of the selected template(s) are currently assigned to be used, those will automatically be reassigned to the default Magento template(s).')
159
  ));
 
160
  return $this;
161
  }
162
 
163
  /**
164
  * get Row Url for editing template on row click
165
- * @param type $row
 
 
166
  * @return string
167
  */
168
  public function getRowUrl($row)
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
8
  {
18
  /* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
19
  $collection = Mage::getModel('bronto_email/template')->getCollection();
20
 
21
+ $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
22
+ $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
23
+
24
  // Apply conditional logic to handle 1.9 overriding collection _construct
25
  if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
 
 
26
  $collection->getSelect()->joinLeft(
27
  $brontoTable,
28
  "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
30
  }
31
 
32
  // Limit grid to show only those templates with message id assigned
33
+ $collection->addFieldToFilter("`{$brontoTable}`.`bronto_message_id`", array('notnull' => true));
34
 
35
  $this->setCollection($collection);
36
 
51
  $this->addColumn(
52
  'template_id', array(
53
  'header' => Mage::helper('adminhtml')->__('ID'),
54
+ 'index' => 'template_id',
55
+ 'width' => '30px',
56
  )
57
  );
58
 
59
  $this->addColumn(
60
  'added_at', array(
61
+ 'header' => Mage::helper('adminhtml')->__('Date Added'),
62
+ 'index' => 'added_at',
63
  'gmtoffset' => true,
64
+ 'type' => 'datetime'
65
  )
66
  );
67
 
68
  $this->addColumn(
69
  'modified_at', array(
70
+ 'header' => Mage::helper('adminhtml')->__('Date Updated'),
71
+ 'index' => 'modified_at',
72
  'gmtoffset' => true,
73
+ 'type' => 'datetime'
74
  )
75
  );
76
 
77
  $this->addColumn(
78
+ 'template_code', array(
79
  'header' => Mage::helper('adminhtml')->__('Name'),
80
+ 'index' => 'template_code'
81
  )
82
  );
83
 
84
  $this->addColumn(
85
  'message_name', array(
86
  'header' => Mage::helper('adminhtml')->__('Bronto Message'),
87
+ 'index' => 'bronto_message_name',
88
  )
89
  );
90
 
91
  $storeCodes = array();
92
  foreach (Mage::app()->getStores() as $id => $store) {
93
  $storeName = $store->getName();
94
+ if (!Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
95
  $storeName .= ' (Disabled)';
96
  }
97
  $storeCodes[$id] = $storeName;
99
 
100
  $this->addColumn(
101
  'store', array(
102
+ 'header' => Mage::helper('adminhtml')->__('Store'),
103
+ 'index' => 'store_id',
104
+ 'type' => 'options',
105
+ 'options' => $storeCodes,
106
  'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_storename',
107
  )
108
  );
110
  $this->addColumn(
111
  'template_send_type',
112
  array(
113
+ 'header' => Mage::helper('adminhtml')->__('Send Type'),
114
+ 'index' => 'template_send_type',
115
+ 'type' => 'options',
116
  'options' => array(
117
+ 'marketing' => 'Bronto Marketing',
118
  'transactional' => 'Bronto Transactional',
119
+ 'magento' => 'Magento Email',
120
  ),
121
  )
122
  );
123
 
124
  $this->addColumn('action', array(
125
+ 'header' => Mage::helper('adminhtml')->__('Action'),
126
+ 'index' => 'template_id',
127
  'sortable' => false,
128
+ 'filter' => false,
129
+ 'width' => '130px',
130
  'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_action'
131
  ));
132
 
138
  $this->setMassactionIdField('template_id');
139
  $this->getMassactionBlock()->setFormFieldName('template_id');
140
  $this->getMassactionBlock()->addItem('marketing', array(
141
+ 'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Marketing'),
142
+ 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'marketing')),
143
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a marketing message?')
144
  ));
145
  $this->getMassactionBlock()->addItem('transactional', array(
146
+ 'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Transactional'),
147
+ 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'transactional')),
148
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a transactional message?')
149
  ));
150
  $this->getMassactionBlock()->addItem('magento', array(
151
+ 'label' => Mage::helper('bronto_email')->__('Set to send as Magento Email'),
152
+ 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'magento')),
153
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Magento?')
154
  ));
155
  $this->getMassactionBlock()->addItem('delete', array(
156
+ 'label' => Mage::helper('bronto_email')->__('Delete'),
157
+ 'url' => $this->getUrl('*/*/massDelete', array('' => '')),
158
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template(s)? If any of the selected template(s) are currently assigned to be used, those will automatically be reassigned to the default Magento template(s).')
159
  ));
160
+
161
  return $this;
162
  }
163
 
164
  /**
165
  * get Row Url for editing template on row click
166
+ *
167
+ * @param $row
168
+ *
169
  * @return string
170
  */
171
  public function getRowUrl($row)
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Action.php CHANGED
@@ -5,17 +5,17 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Action ex
5
  public function render(Varien_Object $row)
6
  {
7
  $sendType = $row->getTemplateSendType();
8
- $actions = array();
9
 
10
  // Edit Action
11
  $actions[] = array(
12
- 'url' => $this->getUrl('*/*/brontoEdit', array('id' => $row->getId())),
13
  'caption' => $this->__('Edit'),
14
  );
15
 
16
  // Delete Action
17
  $actions[] = array(
18
- 'url' => $this->getUrl('*/*/massDelete', array('template_id' => $row->getId())),
19
  'caption' => $this->__('Delete'),
20
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template? If this template is currently assigned to be used, it will automatically be reassigned to the default Magento template.')
21
  );
@@ -23,36 +23,36 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Action ex
23
  switch ($sendType) {
24
  case 'transactional':
25
  $actions[] = array(
26
- 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'marketing')),
27
  'caption' => $this->__('Set to Bronto Marketing'),
28
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a marketing message?'),
29
  );
30
  $actions[] = array(
31
- 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'magento')),
32
  'caption' => $this->__('Set to Magento Email'),
33
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Magento?'),
34
  );
35
  break;
36
  case 'magento':
37
  $actions[] = array(
38
- 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'transactional')),
39
  'caption' => $this->__('Set to Bronto Transactional'),
40
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a transactional message?'),
41
  );
42
  $actions[] = array(
43
- 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'marketing')),
44
  'caption' => $this->__('Set to Bronto Marketing'),
45
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a marketing message?'),
46
  );
47
  break;
48
  default:
49
  $actions[] = array(
50
- 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'transactional')),
51
  'caption' => $this->__('Set to Bronto Transactional'),
52
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a transactional message?'),
53
  );
54
  $actions[] = array(
55
- 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'magento')),
56
  'caption' => $this->__('Set to Magento Email'),
57
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Magento?'),
58
  );
5
  public function render(Varien_Object $row)
6
  {
7
  $sendType = $row->getTemplateSendType();
8
+ $actions = array();
9
 
10
  // Edit Action
11
  $actions[] = array(
12
+ 'url' => $this->getUrl('*/*/brontoEdit', array('id' => $row->getId())),
13
  'caption' => $this->__('Edit'),
14
  );
15
 
16
  // Delete Action
17
  $actions[] = array(
18
+ 'url' => $this->getUrl('*/*/massDelete', array('template_id' => $row->getId())),
19
  'caption' => $this->__('Delete'),
20
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template? If this template is currently assigned to be used, it will automatically be reassigned to the default Magento template.')
21
  );
23
  switch ($sendType) {
24
  case 'transactional':
25
  $actions[] = array(
26
+ 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'marketing')),
27
  'caption' => $this->__('Set to Bronto Marketing'),
28
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a marketing message?'),
29
  );
30
  $actions[] = array(
31
+ 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'magento')),
32
  'caption' => $this->__('Set to Magento Email'),
33
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Magento?'),
34
  );
35
  break;
36
  case 'magento':
37
  $actions[] = array(
38
+ 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'transactional')),
39
  'caption' => $this->__('Set to Bronto Transactional'),
40
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a transactional message?'),
41
  );
42
  $actions[] = array(
43
+ 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'marketing')),
44
  'caption' => $this->__('Set to Bronto Marketing'),
45
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a marketing message?'),
46
  );
47
  break;
48
  default:
49
  $actions[] = array(
50
+ 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'transactional')),
51
  'caption' => $this->__('Set to Bronto Transactional'),
52
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Bronto as a transactional message?'),
53
  );
54
  $actions[] = array(
55
+ 'url' => $this->getUrl('*/*/updateSendType', array('template_id' => $row->getId(), 'send_type' => 'magento')),
56
  'caption' => $this->__('Set to Magento Email'),
57
  'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set this template to send through Magento?'),
58
  );
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Storename.php CHANGED
@@ -3,19 +3,19 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Storename extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
  {
10
  /**
11
  * @param Varien_Object $row
 
12
  * @return string
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
- $store = Mage::getModel('core/store')->load($row->getStoreId());
17
  $storeName = $store->getName();
18
- if (!Mage::helper('bronto_email')->isEnabled($store->getId())) {
19
  $storeName .= ' (Disabled)';
20
  }
21
 
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Storename extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
  {
9
  /**
10
  * @param Varien_Object $row
11
+ *
12
  * @return string
13
  */
14
  public function render(Varien_Object $row)
15
  {
16
+ $store = Mage::getModel('core/store')->load($row->getStoreId());
17
  $storeName = $store->getName();
18
+ if (!Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
19
  $storeName .= ' (Disabled)';
20
  }
21
 
app/code/community/Bronto/Email/Helper/Contact.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Helper_Contact extends Bronto_Common_Helper_Contact
9
  {
@@ -18,7 +17,12 @@ class Bronto_Email_Helper_Contact extends Bronto_Common_Helper_Contact
18
  }
19
 
20
  /**
 
 
21
  * @param string $email
 
 
 
22
  * @return Bronto_Api_Contact_Row
23
  */
24
  public function getContactByEmail($email, $customSource = 'bronto_email', $store = null)
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Helper_Contact extends Bronto_Common_Helper_Contact
8
  {
17
  }
18
 
19
  /**
20
+ * Load Contact Object by Email Address
21
+ *
22
  * @param string $email
23
+ * @param string $customSource
24
+ * @param null $store
25
+ *
26
  * @return Bronto_Api_Contact_Row
27
  */
28
  public function getContactByEmail($email, $customSource = 'bronto_email', $store = null)
app/code/community/Bronto/Email/Helper/Data.php CHANGED
@@ -3,28 +3,49 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
- class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
 
 
9
  {
10
- const XML_PATH_ENABLED = 'bronto_email/settings/enabled';
11
- const XML_PATH_USE_BRONTO = 'bronto_email/settings/use_bronto';
12
- const XML_PATH_LOG_ENABLED = 'bronto_email/settings/log_enabled';
13
  const XML_PATH_LOG_FIELDS_ENABLED = 'bronto_email/settings/log_fields_enabled';
14
 
15
  /**
16
- * @param string $path
17
- * @return bool
18
  */
19
- public function disableModule($scope = 'default', $scopeId = 0)
 
 
 
 
 
 
 
 
 
 
 
 
20
  {
21
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
22
  }
23
 
24
  /**
25
- * Xml path to email template nodes
 
 
 
 
 
 
26
  */
27
- const XML_PATH_TEMPLATE_EMAIL = '//sections/*/groups/*/fields/*[source_model="adminhtml/system_config_source_email_template"]';
 
 
 
28
 
29
  /**
30
  * Retrieve helper module name
@@ -46,26 +67,32 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
46
  $stores = Mage::app()->getStores();
47
  if (is_array($stores) && count($stores) >= 1) {
48
  foreach ($stores as $store) {
49
- if ($this->isEnabled($store->getId())) {
50
  return true;
51
  }
52
  }
53
  }
 
54
  return false;
55
  }
56
 
57
  /**
58
- * @param string|int $store
59
- * @param string|int $website
 
 
 
60
  * @return bool
61
  */
62
- public function isEnabled($store = null, $website = null)
63
  {
64
- if (!$this->getApiToken($store, $website)) {
 
65
  return false;
66
  }
67
 
68
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $store, $website);
 
69
  }
70
 
71
  /*
@@ -75,7 +102,7 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
75
  */
76
  public function getModuleEnabledText()
77
  {
78
- $message = parent::getModuleEnabledText();
79
  $scopeData = $this->getScopeParams();
80
  if ($scopeData['scope'] != 'default') {
81
  $message = $this->__(
@@ -84,48 +111,41 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
84
  'and select the desired templates.'
85
  );
86
  }
 
87
  return $message;
88
  }
89
 
90
  /**
91
  * Get Config setting for sending through bronto
92
  *
93
- * @param string|int $store
94
- * @param string|int $website
95
- * @return boolean
 
96
  */
97
- public function canUseBronto($store = null, $website = null)
98
  {
99
- if (!$this->getApiToken($store, $website)) {
100
  return false;
101
  }
102
 
103
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_USE_BRONTO, $store, $website);
104
  }
105
 
106
  /**
107
  * Sets the "Send through Bronto" option for any config scope
108
  *
109
- * @param boolean $brontoSend
110
- * @param int $storeId
111
- * @param int $websiteId
112
- * @return Bronto_Email_Helper_Data
 
113
  */
114
- public function setUseBronto($brontoSend, $storeId = null, $websiteId = null)
115
  {
116
- if (!is_null($storeId)) {
117
- $scope = 'stores';
118
- $scopeId = $storeId;
119
- } else if (!is_null($websiteId)) {
120
- $scope = 'websites';
121
- $scopeId = $websiteId;
122
- } else {
123
- $scope = 'default';
124
- $scopeId = '0';
125
- }
126
-
127
  $config = Mage::getModel('core/config');
128
  $config->saveConfig(self::XML_PATH_USE_BRONTO, $brontoSend ? '1' : '0', $scope, $scopeId);
 
129
  return $this;
130
  }
131
 
@@ -133,11 +153,13 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
133
  * Determine if email can be sent through bronto
134
  *
135
  * @param Mage_Core_Model_Email_Template $template
136
- * @return boolean
 
 
137
  */
138
  public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
139
  {
140
- if ($this->isEnabled($storeId) && $this->canUseBronto($storeId) && $template->getTemplateSendType() != 'magento') {
141
  return true;
142
  }
143
 
@@ -164,7 +186,8 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
164
  * @see parent
165
  * @return bool
166
  */
167
- public function hasCustomConfig() {
 
168
  return true;
169
  }
170
 
@@ -173,13 +196,14 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
173
  *
174
  * @return array
175
  */
176
- public function getCustomConfig() {
177
- $emails = array();
 
178
  $templates = Mage::getModel('bronto_email/template')->getCollection();
179
 
180
  if ($this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
181
  $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
182
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
183
  $templates->getSelect()->joinLeft(
184
  $brontoTable,
185
  "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
@@ -190,11 +214,11 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
190
 
191
  foreach ($templates as $template) {
192
  $emails[] = array(
193
- 'template_id' => $template->getTemplateId(),
194
- 'template_code' => $template->getTemplateCode(),
195
- 'bronto_message_id' => $template->getBrontoMessageId(),
196
  'bronto_message_name' => $template->getBrontoMessageName(),
197
- 'send_type' => $template->getTemplateSendType(),
198
  );
199
  }
200
 
@@ -209,12 +233,13 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
209
 
210
  return array(
211
  'templates' => $emails,
212
- 'settings' => $settings,
213
  );
214
  }
215
 
216
  /**
217
  * Get array of all template config paths
 
218
  * @return array
219
  */
220
  public function getTemplatePaths()
@@ -232,13 +257,13 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
232
 
233
  foreach ($sysCfgNodes as $fieldNode) {
234
 
235
- $groupNode = $fieldNode->getParent()->getParent();
236
  $sectionNode = $groupNode->getParent()->getParent();
237
 
238
  // create email template path in system.xml
239
  $sectionName = $sectionNode->getName();
240
- $groupName = $groupNode->getName();
241
- $fieldName = $fieldNode->getName();
242
 
243
  $templatePaths[] = implode('/', array($sectionName, $groupName, $fieldName));
244
  }
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
+ class Bronto_Email_Helper_Data
8
+ extends Bronto_Common_Helper_Data
9
+ implements Bronto_Common_Helper_DataInterface
10
  {
11
+ const XML_PATH_ENABLED = 'bronto_email/settings/enabled';
12
+ const XML_PATH_USE_BRONTO = 'bronto_email/settings/use_bronto';
13
+ const XML_PATH_LOG_ENABLED = 'bronto_email/settings/log_enabled';
14
  const XML_PATH_LOG_FIELDS_ENABLED = 'bronto_email/settings/log_fields_enabled';
15
 
16
  /**
17
+ * Xml path to email template nodes
 
18
  */
19
+ const XML_PATH_TEMPLATE_EMAIL = '//sections/*/groups/*/fields/*[source_model="adminhtml/system_config_source_email_template"]';
20
+
21
+ /**
22
+ * Module Human Readable Name
23
+ */
24
+ protected $_name = 'Bronto Transactional Emails';
25
+
26
+ /**
27
+ * Get Human Readable Name
28
+ *
29
+ * @return string
30
+ */
31
+ public function getName()
32
  {
33
+ return $this->__($this->_name);
34
  }
35
 
36
  /**
37
+ * Disable Module for specified Scope
38
+ *
39
+ * @param string $scope
40
+ * @param int $scopeId
41
+ * @param bool $deleteConfig
42
+ *
43
+ * @return bool
44
  */
45
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
46
+ {
47
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
48
+ }
49
 
50
  /**
51
  * Retrieve helper module name
67
  $stores = Mage::app()->getStores();
68
  if (is_array($stores) && count($stores) >= 1) {
69
  foreach ($stores as $store) {
70
+ if ($this->isEnabled('store', $store->getId())) {
71
  return true;
72
  }
73
  }
74
  }
75
+
76
  return false;
77
  }
78
 
79
  /**
80
+ * Check if module is enabled
81
+ *
82
+ * @param string $scope
83
+ * @param int $scopeId
84
+ *
85
  * @return bool
86
  */
87
+ public function isEnabled($scope = 'default', $scopeId = 0)
88
  {
89
+ // Check if valid token is present
90
+ if (!$this->validApiToken(null, $scope, $scopeId)) {
91
  return false;
92
  }
93
 
94
+ // Get Enabled Scope
95
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
96
  }
97
 
98
  /*
102
  */
103
  public function getModuleEnabledText()
104
  {
105
+ $message = parent::getModuleEnabledText();
106
  $scopeData = $this->getScopeParams();
107
  if ($scopeData['scope'] != 'default') {
108
  $message = $this->__(
111
  'and select the desired templates.'
112
  );
113
  }
114
+
115
  return $message;
116
  }
117
 
118
  /**
119
  * Get Config setting for sending through bronto
120
  *
121
+ * @param string $scope
122
+ * @param int $scopeId
123
+ *
124
+ * @return bool
125
  */
126
+ public function canUseBronto($scope = 'default', $scopeId = 0)
127
  {
128
+ if (!$this->getApiToken($scope, $scopeId)) {
129
  return false;
130
  }
131
 
132
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_USE_BRONTO, $scope, $scopeId);
133
  }
134
 
135
  /**
136
  * Sets the "Send through Bronto" option for any config scope
137
  *
138
+ * @param $brontoSend
139
+ * @param string $scope
140
+ * @param int $scopeId
141
+ *
142
+ * @return $this
143
  */
144
+ public function setUseBronto($brontoSend, $scope = 'default', $scopeId = 0)
145
  {
 
 
 
 
 
 
 
 
 
 
 
146
  $config = Mage::getModel('core/config');
147
  $config->saveConfig(self::XML_PATH_USE_BRONTO, $brontoSend ? '1' : '0', $scope, $scopeId);
148
+
149
  return $this;
150
  }
151
 
153
  * Determine if email can be sent through bronto
154
  *
155
  * @param Mage_Core_Model_Email_Template $template
156
+ * @param null $storeId
157
+ *
158
+ * @return bool
159
  */
160
  public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
161
  {
162
+ if ($this->isEnabled('store', $storeId) && $this->canUseBronto('store', $storeId) && $template->getTemplateSendType() != 'magento') {
163
  return true;
164
  }
165
 
186
  * @see parent
187
  * @return bool
188
  */
189
+ public function hasCustomConfig()
190
+ {
191
  return true;
192
  }
193
 
196
  *
197
  * @return array
198
  */
199
+ public function getCustomConfig()
200
+ {
201
+ $emails = array();
202
  $templates = Mage::getModel('bronto_email/template')->getCollection();
203
 
204
  if ($this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
205
  $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
206
+ $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
207
  $templates->getSelect()->joinLeft(
208
  $brontoTable,
209
  "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
214
 
215
  foreach ($templates as $template) {
216
  $emails[] = array(
217
+ 'template_id' => $template->getTemplateId(),
218
+ 'template_code' => $template->getTemplateCode(),
219
+ 'bronto_message_id' => $template->getBrontoMessageId(),
220
  'bronto_message_name' => $template->getBrontoMessageName(),
221
+ 'send_type' => $template->getTemplateSendType(),
222
  );
223
  }
224
 
233
 
234
  return array(
235
  'templates' => $emails,
236
+ 'settings' => $settings,
237
  );
238
  }
239
 
240
  /**
241
  * Get array of all template config paths
242
+ *
243
  * @return array
244
  */
245
  public function getTemplatePaths()
257
 
258
  foreach ($sysCfgNodes as $fieldNode) {
259
 
260
+ $groupNode = $fieldNode->getParent()->getParent();
261
  $sectionNode = $groupNode->getParent()->getParent();
262
 
263
  // create email template path in system.xml
264
  $sectionName = $sectionNode->getName();
265
+ $groupName = $groupNode->getName();
266
+ $fieldName = $fieldNode->getName();
267
 
268
  $templatePaths[] = implode('/', array($sectionName, $groupName, $fieldName));
269
  }
app/code/community/Bronto/Email/Helper/Field.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Helper_Field extends Bronto_Common_Helper_Field
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Helper_Field extends Bronto_Common_Helper_Field
8
  {
app/code/community/Bronto/Email/Helper/Message.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Helper_Message extends Bronto_Common_Helper_Message
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Helper_Message extends Bronto_Common_Helper_Message
8
  {
app/code/community/Bronto/Email/Model/Log.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Log extends Mage_Core_Model_Abstract
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Log extends Mage_Core_Model_Abstract
8
  {
app/code/community/Bronto/Email/Model/Message.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.6
7
  */
8
  class Bronto_Email_Model_Message extends Mage_Core_Model_Abstract
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Message extends Mage_Core_Model_Abstract
8
  {
app/code/community/Bronto/Email/Model/Mysql4/Log.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
8
  {
app/code/community/Bronto/Email/Model/Mysql4/Log/Collection.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
  {
@@ -19,11 +18,13 @@ class Bronto_Email_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Co
19
  *
20
  * @param string $attribute
21
  * @param string $dir
 
22
  * @return Bronto_Email_Model_Mysql4_Log_Collection
23
  */
24
  public function addAttributeToSort($attribute, $dir = 'asc')
25
  {
26
  $this->addOrder($attribute, $dir);
 
27
  return $this;
28
  }
29
 
@@ -35,6 +36,7 @@ class Bronto_Email_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Co
35
  foreach ($this->getItems() as $item) {
36
  $item->delete($item);
37
  }
 
38
  return $this;
39
  }
40
  }
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
  {
18
  *
19
  * @param string $attribute
20
  * @param string $dir
21
+ *
22
  * @return Bronto_Email_Model_Mysql4_Log_Collection
23
  */
24
  public function addAttributeToSort($attribute, $dir = 'asc')
25
  {
26
  $this->addOrder($attribute, $dir);
27
+
28
  return $this;
29
  }
30
 
36
  foreach ($this->getItems() as $item) {
37
  $item->delete($item);
38
  }
39
+
40
  return $this;
41
  }
42
  }
app/code/community/Bronto/Email/Model/Mysql4/Message.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.6
7
  */
8
  class Bronto_Email_Model_Mysql4_Message extends Mage_Core_Model_Mysql4_Abstract
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Mysql4_Message extends Mage_Core_Model_Mysql4_Abstract
8
  {
app/code/community/Bronto/Email/Model/Mysql4/Message/Collection.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Mysql4_Message_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Mysql4_Message_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
  {
app/code/community/Bronto/Email/Model/Mysql4/Template.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Mysql4_Template extends Mage_Core_Model_Mysql4_Email_Template
9
  {
@@ -20,8 +19,10 @@ class Bronto_Email_Model_Mysql4_Template extends Mage_Core_Model_Mysql4_Email_Te
20
 
21
  /**
22
  * Get Template from original template code and store Id
23
- * @param string $templateCode
 
24
  * @param int|bool $storeId
 
25
  * @return array
26
  */
27
  public function loadByOriginalCode($templateCode, $storeId = false)
@@ -51,14 +52,15 @@ class Bronto_Email_Model_Mysql4_Template extends Mage_Core_Model_Mysql4_Email_Te
51
  /**
52
  * Retrieve select object for load object data
53
  *
54
- * @param string $field
55
- * @param mixed $value
56
  * @param Mage_Core_Model_Abstract $object
 
57
  * @return Zend_Db_Select
58
  */
59
  protected function _getLoadSelect($field, $value, $object)
60
  {
61
- $field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field));
62
  $select = $this->_getReadAdapter()->select()
63
  ->from($this->getMainTable())
64
  ->where($field . '=?', $value)
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Mysql4_Template extends Mage_Core_Model_Mysql4_Email_Template
8
  {
19
 
20
  /**
21
  * Get Template from original template code and store Id
22
+ *
23
+ * @param string $templateCode
24
  * @param int|bool $storeId
25
+ *
26
  * @return array
27
  */
28
  public function loadByOriginalCode($templateCode, $storeId = false)
52
  /**
53
  * Retrieve select object for load object data
54
  *
55
+ * @param string $field
56
+ * @param mixed $value
57
  * @param Mage_Core_Model_Abstract $object
58
+ *
59
  * @return Zend_Db_Select
60
  */
61
  protected function _getLoadSelect($field, $value, $object)
62
  {
63
+ $field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field));
64
  $select = $this->_getReadAdapter()->select()
65
  ->from($this->getMainTable())
66
  ->where($field . '=?', $value)
app/code/community/Bronto/Email/Model/Mysql4/Template/Collection.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Mysql4_Template_Collection extends Mage_Core_Model_Mysql4_Email_Template_Collection
9
  {
@@ -12,8 +11,8 @@ class Bronto_Email_Model_Mysql4_Template_Collection extends Mage_Core_Model_Mysq
12
  public function _construct()
13
  {
14
  parent::_construct();
15
- $this->_templateTable = $this->getResource()->getTable('bronto_email/template');
16
- $this->_brontoTable = $this->getResource()->getTable('bronto_email/message');
17
  if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
18
  $this->_select->joinLeft(
19
  array($this->_brontoTable),
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Mysql4_Template_Collection extends Mage_Core_Model_Mysql4_Email_Template_Collection
8
  {
11
  public function _construct()
12
  {
13
  parent::_construct();
14
+ $this->_templateTable = $this->getResource()->getTable('bronto_email/template');
15
+ $this->_brontoTable = $this->getResource()->getTable('bronto_email/message');
16
  if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
17
  $this->_select->joinLeft(
18
  array($this->_brontoTable),
app/code/community/Bronto/Email/Model/Observer.php CHANGED
@@ -3,14 +3,14 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Model_Observer
9
  {
10
- const NOTICE_IDENTIFER = 'bronto_email';
11
 
12
  /**
13
  * @param Varien_Event_Observer $observer
 
14
  * @return mixed
15
  */
16
  public function checkBrontoRequirements(Varien_Event_Observer $observer)
@@ -20,13 +20,14 @@ class Bronto_Email_Model_Observer
20
  }
21
 
22
  // Verify Requirements
23
- if (!Mage::helper(self::NOTICE_IDENTIFER)->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
24
  return;
25
  }
26
  }
27
 
28
  /**
29
  * Observes module becoming enabled and displays message warning user to configure settings
 
30
  * @param Varien_Event_Observer $observer
31
  */
32
  public function watchEnableAction(Varien_Event_Observer $observer)
@@ -37,12 +38,14 @@ class Bronto_Email_Model_Observer
37
  /**
38
  * Grab Config Data Object before save and handle the 'Create New...' value for
39
  * fields that were generated dynamically
 
40
  * @param Varien_Event_Observer $observer
 
41
  * @return Varien_Event_Observer
42
  */
43
  public function saveDynamicField(Varien_Event_Observer $observer)
44
  {
45
- if (!Mage::helper(self::NOTICE_IDENTIFER)->isEnabled()) {
46
  return $observer;
47
  }
48
 
@@ -71,9 +74,10 @@ class Bronto_Email_Model_Observer
71
 
72
  /**
73
  * Get Section, Group, and field from field path and save to "real" path
74
- * @param type $website
75
- * @param type $store
76
- * @param type $groups
 
77
  */
78
  protected function _handleAttributes($website, $store, $groups)
79
  {
@@ -99,10 +103,10 @@ class Bronto_Email_Model_Observer
99
  }
100
 
101
  $config->saveConfig(
102
- $sectionName.'/'.$groupName.'/'.$fieldName,
103
  $value,
104
  $scope,
105
- $scopeParams[$scopeParams['scope'].'_id']
106
  );
107
  }
108
  }
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_Observer
8
  {
9
+ const NOTICE_IDENTIFIER = 'bronto_email';
10
 
11
  /**
12
  * @param Varien_Event_Observer $observer
13
+ *
14
  * @return mixed
15
  */
16
  public function checkBrontoRequirements(Varien_Event_Observer $observer)
20
  }
21
 
22
  // Verify Requirements
23
+ if (!Mage::helper(self::NOTICE_IDENTIFIER)->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
24
  return;
25
  }
26
  }
27
 
28
  /**
29
  * Observes module becoming enabled and displays message warning user to configure settings
30
+ *
31
  * @param Varien_Event_Observer $observer
32
  */
33
  public function watchEnableAction(Varien_Event_Observer $observer)
38
  /**
39
  * Grab Config Data Object before save and handle the 'Create New...' value for
40
  * fields that were generated dynamically
41
+ *
42
  * @param Varien_Event_Observer $observer
43
+ *
44
  * @return Varien_Event_Observer
45
  */
46
  public function saveDynamicField(Varien_Event_Observer $observer)
47
  {
48
+ if (!Mage::helper(self::NOTICE_IDENTIFIER)->isEnabled()) {
49
  return $observer;
50
  }
51
 
74
 
75
  /**
76
  * Get Section, Group, and field from field path and save to "real" path
77
+ *
78
+ * @param $website
79
+ * @param $store
80
+ * @param $groups
81
  */
82
  protected function _handleAttributes($website, $store, $groups)
83
  {
103
  }
104
 
105
  $config->saveConfig(
106
+ $sectionName . '/' . $groupName . '/' . $fieldName,
107
  $value,
108
  $scope,
109
+ $scopeParams[$scopeParams['scope'] . '_id']
110
  );
111
  }
112
  }
app/code/community/Bronto/Email/Model/Resource/Setup.php CHANGED
@@ -29,6 +29,7 @@ class Bronto_Email_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
29
  {
30
  Mage::getConfig()->reinit();
31
  Mage::app()->reinitStores();
 
32
  return $this;
33
  }
34
 
@@ -37,17 +38,29 @@ class Bronto_Email_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
37
  *
38
  * @param string|int $storeId
39
  * @param string|int $websiteId
 
40
  * @return Bronto_Email_Model_Resource_Setup
41
  */
42
  protected function _setDefaultSending($storeId = null, $websiteId = null)
43
  {
 
 
 
 
 
 
 
 
 
 
44
  $helper = Mage::helper('bronto_email');
45
  if (
46
- $helper->isEnabled($storeId, $websiteId) &&
47
- !$helper->canUseBronto($storeId, $websiteId)
48
  ) {
49
- $helper->setUseBronto(true, $storeId, $websiteId);
50
  }
 
51
  return $this;
52
  }
53
  }
29
  {
30
  Mage::getConfig()->reinit();
31
  Mage::app()->reinitStores();
32
+
33
  return $this;
34
  }
35
 
38
  *
39
  * @param string|int $storeId
40
  * @param string|int $websiteId
41
+ *
42
  * @return Bronto_Email_Model_Resource_Setup
43
  */
44
  protected function _setDefaultSending($storeId = null, $websiteId = null)
45
  {
46
+ if (!is_null($storeId)) {
47
+ $scope = 'store';
48
+ $scopeId = $storeId;
49
+ } elseif (!is_null($websiteId)) {
50
+ $scope = 'website';
51
+ $scopeId = $websiteId;
52
+ } else {
53
+ $scope = 'default';
54
+ $scopeId = 0;
55
+ }
56
  $helper = Mage::helper('bronto_email');
57
  if (
58
+ $helper->isEnabled($scope, $scopeId) &&
59
+ !$helper->canUseBronto($scope, $scopeId)
60
  ) {
61
+ $helper->setUseBronto(true, $scope, $scopeId);
62
  }
63
+
64
  return $this;
65
  }
66
  }
app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Field.php CHANGED
@@ -14,7 +14,7 @@ class Bronto_Email_Model_System_Config_Backend_Templates_Field extends Mage_Core
14
  */
15
  protected function _beforeSave()
16
  {
17
- $path = $this->getPath();
18
  $realpath = str_replace('-', '/', array_pop(explode('/', $path)));
19
  $this->_saveConfigData($realpath, $this->getValue());
20
 
@@ -22,9 +22,12 @@ class Bronto_Email_Model_System_Config_Backend_Templates_Field extends Mage_Core
22
  }
23
 
24
  /**
25
- * @param type $path
26
- * @param type $value
27
- * @return Bronto_Email_Model_System_Config_Backend_Templates_Field
 
 
 
28
  */
29
  protected function _saveConfigData($path, $value)
30
  {
14
  */
15
  protected function _beforeSave()
16
  {
17
+ $path = $this->getPath();
18
  $realpath = str_replace('-', '/', array_pop(explode('/', $path)));
19
  $this->_saveConfigData($realpath, $this->getValue());
20
 
22
  }
23
 
24
  /**
25
+ * Save Configuration Data
26
+ *
27
+ * @param $path
28
+ * @param $value
29
+ *
30
+ * @return $this
31
  */
32
  protected function _saveConfigData($path, $value)
33
  {
app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Sendtype.php CHANGED
@@ -20,9 +20,12 @@ class Bronto_Email_Model_System_Config_Backend_Templates_Sendtype extends Mage_C
20
  }
21
 
22
  /**
23
- * @param type $path
24
- * @param type $value
25
- * @return Bronto_Email_Model_System_Config_Backend_Templates_Field
 
 
 
26
  */
27
  protected function _saveConfigData($path, $value)
28
  {
20
  }
21
 
22
  /**
23
+ * Save Configuration Data
24
+ *
25
+ * @param $path
26
+ * @param $value
27
+ *
28
+ * @return $this
29
  */
30
  protected function _saveConfigData($path, $value)
31
  {
app/code/community/Bronto/Email/Model/System/Config/Backend/Usebronto.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.6
7
  */
8
  class Bronto_Email_Model_System_Config_Backend_Usebronto extends Mage_Core_Model_Config_Data
9
  {
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_System_Config_Backend_Usebronto extends Mage_Core_Model_Config_Data
8
  {
app/code/community/Bronto/Email/Model/System/Config/Source/Email/Template.php CHANGED
@@ -10,51 +10,49 @@ class Bronto_Email_Model_System_Config_Source_Email_Template extends Mage_Adminh
10
  */
11
  public function toOptionArray()
12
  {
 
13
  if (!$collection = Mage::registry('config_system_email_template')) {
14
- if (Mage::helper('bronto_email')->isEnabled() && Mage::app()->getRequest()->getParam('store')) {
15
- $collection = Mage::getModel('bronto_email/template')->getCollection();
16
-
17
- // Apply conditional logic to handle 1.9 overriding collection _construct
18
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
19
- $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
20
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
21
- $collection->getSelect()->joinLeft(
22
- $brontoTable,
23
- "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
24
- );
25
- }
26
-
27
- // if Store ID Specified, filter collection
28
- if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
29
- $store = Mage::app()->getStore($storeCode);
30
- $storeId = $store->getId();
31
-
32
- $collection->addFieldToFilter('store_id', $storeId);
33
- }
34
 
35
- $collection->addOrder('template_code', 'asc')->load();
36
-
37
- Mage::register('config_system_email_template', $collection);
38
- } else {
39
- $collection = Mage::getModel('bronto_email/template')->getCollection()
40
- ->addOrder('template_code', 'asc')->load();
41
-
42
- // Apply conditional logic to handle 1.9 overriding collection _construct
43
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
44
- $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
45
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
46
- $collection->getSelect()->joinLeft(
47
- $brontoTable,
48
- "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
49
- );
50
  }
51
 
52
- Mage::register('config_system_email_template', $collection);
 
53
  }
 
 
 
 
54
  }
55
 
 
56
  $options = $collection->toOptionArray();
57
 
 
58
  $templateName = Mage::helper('adminhtml')->__('Default Template from Locale');
59
 
60
  // Add support for Template configuration page
@@ -66,6 +64,14 @@ class Bronto_Email_Model_System_Config_Source_Email_Template extends Mage_Adminh
66
  $path = $this->getPath();
67
  }
68
 
 
 
 
 
 
 
 
 
69
  $nodeName = str_replace('/', '_', $path);
70
 
71
  $templateLabelNode = Mage::app()->getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL . $nodeName . '/label');
10
  */
11
  public function toOptionArray()
12
  {
13
+ // If Collection isn't already in registry, create it
14
  if (!$collection = Mage::registry('config_system_email_template')) {
15
+ // Define Tables
16
+ $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
17
+ $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
18
+
19
+ // Load Collection
20
+ $collection = Mage::getModel('bronto_email/template')->getCollection();
21
+
22
+ // Apply conditional logic to handle 1.9 overriding collection _construct
23
+ if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
24
+ $collection->getSelect()->joinLeft(
25
+ $brontoTable,
26
+ "`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
27
+ );
28
+ }
 
 
 
 
 
 
29
 
30
+ // If module is enabled
31
+ if (Mage::helper('bronto_email')->isEnabled()) {
32
+ // If Store Scope
33
+ if (Mage::app()->getRequest()->getParam('store')) {
34
+ // if Store ID Specified, filter collection
35
+ if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
36
+ $store = Mage::app()->getStore($storeCode);
37
+ $storeId = $store->getId();
38
+
39
+ $collection->addFieldToFilter('store_id', $storeId);
40
+ }
 
 
 
 
41
  }
42
 
43
+ // Add Where statement to prevent loading templates without core_template_id
44
+ $collection->getSelect()->where("`{$brontoTable}`.`core_template_id` IS NOT NULL");
45
  }
46
+
47
+ $collection->addOrder('template_code', 'asc')->load();
48
+
49
+ Mage::register('config_system_email_template', $collection);
50
  }
51
 
52
+ // Get Array of Template Options
53
  $options = $collection->toOptionArray();
54
 
55
+ // Set up Default Template Name
56
  $templateName = Mage::helper('adminhtml')->__('Default Template from Locale');
57
 
58
  // Add support for Template configuration page
64
  $path = $this->getPath();
65
  }
66
 
67
+ // Add a 'Do Not Send' option
68
+ array_unshift(
69
+ $options, array(
70
+ 'value' => 'nosend',
71
+ 'label' => 'Do Not Send',
72
+ )
73
+ );
74
+
75
  $nodeName = str_replace('/', '_', $path);
76
 
77
  $templateLabelNode = Mage::app()->getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL . $nodeName . '/label');
app/code/community/Bronto/Email/Model/System/Config/Source/Sendtype.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Email_Model_System_Config_Source_Sendtype
9
  {
3
  /**
4
  * @package Bronto\Customer
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Model_System_Config_Source_Sendtype
8
  {
app/code/community/Bronto/Email/Model/Template.php CHANGED
@@ -6,6 +6,9 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
6
  */
7
  protected $_helper = 'bronto_email';
8
 
 
 
 
9
  public function _construct()
10
  {
11
  $this->_init('bronto_email/template');
@@ -13,9 +16,12 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
13
 
14
  /**
15
  * Get Template from original template code and store Id
16
- * @param string $templateCode
17
- * @param int|bool $storeId
18
- * @return array
 
 
 
19
  */
20
  public function loadByOriginalCode($templateCode, $storeId = false, $locale = null)
21
  {
@@ -33,6 +39,7 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
33
 
34
  /**
35
  * Handle loading Existing and Default Magento templates
 
36
  * @return boolean
37
  */
38
  public function handleDefaultTemplates()
@@ -54,13 +61,15 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
54
  * Load default email template from locale translate
55
  *
56
  * @param string $templateId
57
- * @param string $locale
 
 
58
  */
59
  public function loadDefault($templateId, $locale = null)
60
  {
61
  $defaultTemplates = self::getDefaultTemplates();
62
 
63
- if (!is_string($templateId) || !array_key_exists($templateId, $defaultTemplates)) {
64
  return $this;
65
  }
66
 
@@ -99,7 +108,7 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
99
  }
100
 
101
  /**
102
- * Collect all system config pathes where current template is used as default
103
  *
104
  * @return array
105
  */
@@ -111,7 +120,7 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
111
  }
112
 
113
  $templatePaths = Mage::helper($this->_helper)->getTemplatePaths();
114
- $paths = array();
115
 
116
  // find nodes which are using $templateCode value
117
  $defaultCfgNodes = Mage::getConfig()->getXpath('default/*/*[*="' . $templateCode . '"]');
@@ -123,9 +132,9 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
123
  foreach ($defaultCfgNodes as $node) {
124
  // create email template path in system.xml
125
  $sectionName = $node->getParent()->getName();
126
- $groupName = $node->getName();
127
- $fieldName = substr($templateCode, strlen($sectionName . '_' . $groupName . '_'));
128
- $path = implode('/', array($sectionName, $groupName, $fieldName));
129
 
130
  if (in_array($path, $templatePaths)) {
131
  $paths[] = array('path' => $path);
@@ -136,7 +145,7 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
136
  }
137
 
138
  /**
139
- * Collect all system config pathes where current template is currently used
140
  *
141
  * @return array
142
  */
@@ -184,8 +193,8 @@ class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
184
  /**
185
  * Log data on sending message
186
  *
187
- * @param bool $success
188
- * @param string $error
189
  * @param Bronto_Api_Delivery_Row $delivery
190
  *
191
  * @return void
6
  */
7
  protected $_helper = 'bronto_email';
8
 
9
+ /**
10
+ * Constructor
11
+ */
12
  public function _construct()
13
  {
14
  $this->_init('bronto_email/template');
16
 
17
  /**
18
  * Get Template from original template code and store Id
19
+ *
20
+ * @param $templateCode
21
+ * @param bool $storeId
22
+ * @param null $locale
23
+ *
24
+ * @return $this
25
  */
26
  public function loadByOriginalCode($templateCode, $storeId = false, $locale = null)
27
  {
39
 
40
  /**
41
  * Handle loading Existing and Default Magento templates
42
+ *
43
  * @return boolean
44
  */
45
  public function handleDefaultTemplates()
61
  * Load default email template from locale translate
62
  *
63
  * @param string $templateId
64
+ * @param mixed $locale
65
+ *
66
+ * @return $this
67
  */
68
  public function loadDefault($templateId, $locale = null)
69
  {
70
  $defaultTemplates = self::getDefaultTemplates();
71
 
72
+ if (!is_string($templateId) || !array_key_exists($templateId, $defaultTemplates) || $templateId == 'nosend') {
73
  return $this;
74
  }
75
 
108
  }
109
 
110
  /**
111
+ * Collect all system config paths where current template is used as default
112
  *
113
  * @return array
114
  */
120
  }
121
 
122
  $templatePaths = Mage::helper($this->_helper)->getTemplatePaths();
123
+ $paths = array();
124
 
125
  // find nodes which are using $templateCode value
126
  $defaultCfgNodes = Mage::getConfig()->getXpath('default/*/*[*="' . $templateCode . '"]');
132
  foreach ($defaultCfgNodes as $node) {
133
  // create email template path in system.xml
134
  $sectionName = $node->getParent()->getName();
135
+ $groupName = $node->getName();
136
+ $fieldName = substr($templateCode, strlen($sectionName . '_' . $groupName . '_'));
137
+ $path = implode('/', array($sectionName, $groupName, $fieldName));
138
 
139
  if (in_array($path, $templatePaths)) {
140
  $paths[] = array('path' => $path);
145
  }
146
 
147
  /**
148
+ * Collect all system config paths where current template is currently used
149
  *
150
  * @return array
151
  */
193
  /**
194
  * Log data on sending message
195
  *
196
+ * @param bool $success
197
+ * @param string $error
198
  * @param Bronto_Api_Delivery_Row $delivery
199
  *
200
  * @return void
app/code/community/Bronto/Email/Model/Template/Import.php CHANGED
@@ -2,7 +2,6 @@
2
  /**
3
  * @package Bronto\Email
4
  * @copyright 2011-2013 Bronto Software, Inc.
5
- * @version 1.1.6
6
  */
7
  class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
8
  {
@@ -13,8 +12,11 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
13
 
14
  /**
15
  * Load Template to import into Bronto
16
- * @param int $templateId
17
- * @param string|int $storeId
 
 
 
18
  * @throws Exception
19
  */
20
  public function importTemplate($templateId, $storeId = false)
@@ -31,8 +33,11 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
31
 
32
  /**
33
  * Import template into Bronto
 
34
  * @param Bronto_Email_Model_Template $template
35
- * @return type
 
 
36
  */
37
  protected function processMessage(Bronto_Email_Model_Template $template, $storeId = false)
38
  {
@@ -49,12 +54,12 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
49
  }
50
 
51
  // If module is not enabled for this store, don't proceed
52
- if (!Mage::helper('bronto_email')->isEnabled($store->getId())) {
53
  return false;
54
  }
55
 
56
  // Get Token
57
- $token = Mage::helper('bronto_common')->getApiToken($store->getId());
58
  if ($token) {
59
  $this->_apiObject = new Bronto_Api_Message(array(
60
  'api' => new Bronto_Api($token)
@@ -70,6 +75,7 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
70
  ));
71
  } catch (Exception $e) {
72
  Mage::log('Bronto Failed creating apiObject:' . $e->getMessage());
 
73
  return false;
74
  }
75
 
@@ -112,23 +118,25 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
112
 
113
  if ($message->hasError()) {
114
  Mage::throwException($message->getErrorCode() . ' ' . $message->getErrorMessage());
 
115
  return false;
116
  }
117
  } catch (Exception $e) {
118
  Mage::throwException("Failed Importing Template `{$data['template_code']}` : [Bronto] " . $e->getMessage());
 
119
  return false;
120
  }
121
 
122
  // Create Bronto Template Entry
123
  $brontoTemplate = Mage::getModel('bronto_email/message')
124
- ->load($template->getId())
125
- ->setCoreTemplateId($template->getId())
126
- ->setOrigTemplateText($templateText)
127
- ->setBrontoMessageId($message->id)
128
- ->setBrontoMessageName($message->name)
129
- ->setBrontoMessageApproved(1)
130
- ->setStoreId($store->getId())
131
- ->save();
132
 
133
  // Clean Up
134
  unset($brontoTemplate);
@@ -162,8 +170,8 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
162
 
163
  /**
164
  * Load Existing templates into Bronto Email Template table
165
- * @param Bronto_Email_Model_Template $messageModel
166
- * @return boolean
167
  */
168
  protected function _processExisting()
169
  {
@@ -182,11 +190,11 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
182
  // If message does not already exist, then proceed
183
  if (!$template->getBrontoMessageId() || is_null($template->getBrontoMessageId())) {
184
  $template->setTemplateSendType('magento')
185
- ->setOrigTemplateText($customTemplate->getTemplateText())
186
- ->setBrontoMessageId(null)
187
- ->setBrontoMessageName(null)
188
- ->setBrontoMessageApproved(0)
189
- ->save();
190
  }
191
 
192
  // Clean up
@@ -201,9 +209,10 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
201
 
202
  /**
203
  * Load Default templates into Bronto Email Template table
204
- * @param Bronto_Email_Model_Template $messageModel
205
  * @param array $allStores
206
- * @return boolean
 
207
  */
208
  protected function _processDefaults(array $allStores)
209
  {
@@ -243,7 +252,7 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
243
  // Build Bronto Template
244
  /** @var $brontoTemplate Bronto_Email_Model_Message */
245
  $brontoTemplate = Mage::getModel('bronto_email/message')
246
- ->load($templateId);
247
 
248
  // If we didn't get a template match, set the Id
249
  if (is_null($brontoTemplate->getId())) {
@@ -253,12 +262,12 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
253
  // If message does not already exist, then proceed
254
  if (!$brontoTemplate->getBrontoMessageId() || is_null($brontoTemplate->getBrontoMessageId())) {
255
  $brontoTemplate->setTemplateSendType('magento')
256
- ->setOrigTemplateText($templateText)
257
- ->setBrontoMessageId(null)
258
- ->setBrontoMessageName(null)
259
- ->setBrontoMessageApproved(0)
260
- ->setStoreId($_storeId)
261
- ->save();
262
  }
263
 
264
  // Clean up
@@ -276,7 +285,9 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
276
 
277
  /**
278
  * Remove HTML and multiple spaces
 
279
  * @param string $string
 
280
  * @return string
281
  */
282
  protected function ripTags($string)
@@ -284,6 +295,7 @@ class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
284
  $string = preg_replace('/<[^>]*>/', ' ', $string);
285
  // ----- remove multiple spaces -----
286
  $string = trim(preg_replace('/ {2,}/', ' ', $string));
 
287
  return $string;
288
  }
289
 
2
  /**
3
  * @package Bronto\Email
4
  * @copyright 2011-2013 Bronto Software, Inc.
 
5
  */
6
  class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
7
  {
12
 
13
  /**
14
  * Load Template to import into Bronto
15
+ *
16
+ * @param int $templateId
17
+ * @param mixed $storeId
18
+ *
19
+ * @return string
20
  * @throws Exception
21
  */
22
  public function importTemplate($templateId, $storeId = false)
33
 
34
  /**
35
  * Import template into Bronto
36
+ *
37
  * @param Bronto_Email_Model_Template $template
38
+ * @param bool $storeId
39
+ *
40
+ * @return bool
41
  */
42
  protected function processMessage(Bronto_Email_Model_Template $template, $storeId = false)
43
  {
54
  }
55
 
56
  // If module is not enabled for this store, don't proceed
57
+ if (!Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
58
  return false;
59
  }
60
 
61
  // Get Token
62
+ $token = Mage::helper('bronto_common')->getApiToken('store', $store->getId());
63
  if ($token) {
64
  $this->_apiObject = new Bronto_Api_Message(array(
65
  'api' => new Bronto_Api($token)
75
  ));
76
  } catch (Exception $e) {
77
  Mage::log('Bronto Failed creating apiObject:' . $e->getMessage());
78
+
79
  return false;
80
  }
81
 
118
 
119
  if ($message->hasError()) {
120
  Mage::throwException($message->getErrorCode() . ' ' . $message->getErrorMessage());
121
+
122
  return false;
123
  }
124
  } catch (Exception $e) {
125
  Mage::throwException("Failed Importing Template `{$data['template_code']}` : [Bronto] " . $e->getMessage());
126
+
127
  return false;
128
  }
129
 
130
  // Create Bronto Template Entry
131
  $brontoTemplate = Mage::getModel('bronto_email/message')
132
+ ->load($template->getId())
133
+ ->setCoreTemplateId($template->getId())
134
+ ->setOrigTemplateText($templateText)
135
+ ->setBrontoMessageId($message->id)
136
+ ->setBrontoMessageName($message->name)
137
+ ->setBrontoMessageApproved(1)
138
+ ->setStoreId($store->getId())
139
+ ->save();
140
 
141
  // Clean Up
142
  unset($brontoTemplate);
170
 
171
  /**
172
  * Load Existing templates into Bronto Email Template table
173
+ *
174
+ * @return bool
175
  */
176
  protected function _processExisting()
177
  {
190
  // If message does not already exist, then proceed
191
  if (!$template->getBrontoMessageId() || is_null($template->getBrontoMessageId())) {
192
  $template->setTemplateSendType('magento')
193
+ ->setOrigTemplateText($customTemplate->getTemplateText())
194
+ ->setBrontoMessageId(null)
195
+ ->setBrontoMessageName(null)
196
+ ->setBrontoMessageApproved(0)
197
+ ->save();
198
  }
199
 
200
  // Clean up
209
 
210
  /**
211
  * Load Default templates into Bronto Email Template table
212
+ *
213
  * @param array $allStores
214
+ *
215
+ * @return bool
216
  */
217
  protected function _processDefaults(array $allStores)
218
  {
252
  // Build Bronto Template
253
  /** @var $brontoTemplate Bronto_Email_Model_Message */
254
  $brontoTemplate = Mage::getModel('bronto_email/message')
255
+ ->load($templateId);
256
 
257
  // If we didn't get a template match, set the Id
258
  if (is_null($brontoTemplate->getId())) {
262
  // If message does not already exist, then proceed
263
  if (!$brontoTemplate->getBrontoMessageId() || is_null($brontoTemplate->getBrontoMessageId())) {
264
  $brontoTemplate->setTemplateSendType('magento')
265
+ ->setOrigTemplateText($templateText)
266
+ ->setBrontoMessageId(null)
267
+ ->setBrontoMessageName(null)
268
+ ->setBrontoMessageApproved(0)
269
+ ->setStoreId($_storeId)
270
+ ->save();
271
  }
272
 
273
  // Clean up
285
 
286
  /**
287
  * Remove HTML and multiple spaces
288
+ *
289
  * @param string $string
290
+ *
291
  * @return string
292
  */
293
  protected function ripTags($string)
295
  $string = preg_replace('/<[^>]*>/', ' ', $string);
296
  // ----- remove multiple spaces -----
297
  $string = trim(preg_replace('/ {2,}/', ' ', $string));
298
+
299
  return $string;
300
  }
301
 
app/code/community/Bronto/Email/Model/Template/Mailer.php CHANGED
@@ -2,19 +2,24 @@
2
  /**
3
  * @package Bronto\Email
4
  * @copyright 2011-2013 Bronto Software, Inc.
5
- * @version 1.1.6
6
  */
7
  class Bronto_Email_Model_Template_Mailer
8
  extends Mage_Core_Model_Email_Template_Mailer
9
  {
10
  /**
11
  * Send all emails from email list
 
12
  * @see self::$_emailInfos
13
  *
14
  * @return Bronto_Email_Model_Template_Mailer
15
  */
16
  public function send()
17
  {
 
 
 
 
 
18
  // Try loading template
19
  $emailTemplate = Mage::getModel('bronto_email/template');
20
  $emailTemplate->load($this->getTemplateId());
@@ -30,19 +35,18 @@ class Bronto_Email_Model_Template_Mailer
30
  // Load Bronto Message
31
  /* @var $messageObject Bronto_Api_Message */
32
  $messageObject = Mage::helper('bronto_email/message')->getApi(
33
- NULL,
34
- $store->getId(),
35
- $store->getWebsiteId()
36
  )->getMessageObject();
37
 
38
  // Load Message
39
  try {
40
  /* @var $message Bronto_Api_Message_Row */
41
- $message = $messageObject->createRow();
42
  $message->id = $emailTemplate->getBrontoMessageId();
43
  $message->read();
44
- }
45
- catch (Exception $e) {
46
  Mage::helper('bronto_email')->writeDebug('Falling Back to Magento Sending: ' . $e);
47
 
48
  return parent::send();
@@ -55,8 +59,7 @@ class Bronto_Email_Model_Template_Mailer
55
  // Handle "Bcc" recepients of the current email
56
  if ($emailTemplate->getTemplateSendType() == 'magento') {
57
  $emailTemplate->addBcc($emailInfo->getBccEmails());
58
- }
59
- else {
60
  foreach ($emailInfo->getBccEmails() as $bcc) {
61
  $emailInfo->addTo($bcc);
62
  }
@@ -64,7 +67,7 @@ class Bronto_Email_Model_Template_Mailer
64
 
65
  // Set required design parameters and delegate email sending to Mage_Core_Model_Email_Template
66
  $emailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))
67
- ->sendTransactional(
68
  $message,
69
  $this->getSender(),
70
  $emailInfo->getToEmails(),
2
  /**
3
  * @package Bronto\Email
4
  * @copyright 2011-2013 Bronto Software, Inc.
 
5
  */
6
  class Bronto_Email_Model_Template_Mailer
7
  extends Mage_Core_Model_Email_Template_Mailer
8
  {
9
  /**
10
  * Send all emails from email list
11
+ *
12
  * @see self::$_emailInfos
13
  *
14
  * @return Bronto_Email_Model_Template_Mailer
15
  */
16
  public function send()
17
  {
18
+ // If using the 'Do Not Send' option, just return $this and be done.
19
+ if ($this->getTemplateId() == 'nosend') {
20
+ return $this;
21
+ }
22
+
23
  // Try loading template
24
  $emailTemplate = Mage::getModel('bronto_email/template');
25
  $emailTemplate->load($this->getTemplateId());
35
  // Load Bronto Message
36
  /* @var $messageObject Bronto_Api_Message */
37
  $messageObject = Mage::helper('bronto_email/message')->getApi(
38
+ null,
39
+ 'store',
40
+ $store->getId()
41
  )->getMessageObject();
42
 
43
  // Load Message
44
  try {
45
  /* @var $message Bronto_Api_Message_Row */
46
+ $message = $messageObject->createRow();
47
  $message->id = $emailTemplate->getBrontoMessageId();
48
  $message->read();
49
+ } catch (Exception $e) {
 
50
  Mage::helper('bronto_email')->writeDebug('Falling Back to Magento Sending: ' . $e);
51
 
52
  return parent::send();
59
  // Handle "Bcc" recepients of the current email
60
  if ($emailTemplate->getTemplateSendType() == 'magento') {
61
  $emailTemplate->addBcc($emailInfo->getBccEmails());
62
+ } else {
 
63
  foreach ($emailInfo->getBccEmails() as $bcc) {
64
  $emailInfo->addTo($bcc);
65
  }
67
 
68
  // Set required design parameters and delegate email sending to Mage_Core_Model_Email_Template
69
  $emailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))
70
+ ->sendTransactional(
71
  $message,
72
  $this->getSender(),
73
  $emailInfo->getToEmails(),
app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/LogController.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.1
7
  */
8
  class Bronto_Email_Adminhtml_System_Email_LogController extends Mage_Adminhtml_Controller_Action
9
  {
@@ -16,6 +15,7 @@ class Bronto_Email_Adminhtml_System_Email_LogController extends Mage_Adminhtml_C
16
  Mage::helper('bronto_email')->__('Bronto Delivery Log'),
17
  Mage::helper('bronto_email')->__('Bronto Delivery Log')
18
  );
 
19
  return $this;
20
  }
21
 
3
  /**
4
  * @package Bronto\Email
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Email_Adminhtml_System_Email_LogController extends Mage_Adminhtml_Controller_Action
8
  {
15
  Mage::helper('bronto_email')->__('Bronto Delivery Log'),
16
  Mage::helper('bronto_email')->__('Bronto Delivery Log')
17
  );
18
+
19
  return $this;
20
  }
21
 
app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/TemplateController.php CHANGED
@@ -1,14 +1,10 @@
1
  <?php
2
 
3
- /**
4
- * @var Mage_Adminhtml_System_Email_TemplateController
5
- */
6
  require_once 'Mage/Adminhtml/controllers/System/Email/TemplateController.php';
7
 
8
  /**
9
  * @package Bronto\Email
10
  * @copyright 2011-2013 Bronto Software, Inc.
11
- * @version 1.1.4
12
  */
13
  class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_System_Email_TemplateController
14
  {
@@ -18,6 +14,7 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
18
  /**
19
  * Main Grid view for Transactional Email Templates
20
  * Overwritten to show Bronto Templates
 
21
  * @return null
22
  */
23
  public function indexAction()
@@ -31,7 +28,8 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
31
 
32
  if ($this->getRequest()->getQuery('ajax')) {
33
  $this->_forward('brontoGrid');
34
- return;
 
35
  }
36
 
37
  $this->loadLayout();
@@ -40,10 +38,13 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
40
 
41
  $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template', 'template'));
42
  $this->renderLayout();
 
 
43
  }
44
 
45
  /**
46
  * Main Grid view for Importing Transactional Email Templates into Bronto
 
47
  * @return null
48
  */
49
  public function importAction()
@@ -53,6 +54,7 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
53
 
54
  if ($this->getRequest()->getQuery('ajax')) {
55
  $this->_forward('grid');
 
56
  return;
57
  }
58
 
@@ -66,7 +68,8 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
66
 
67
  /**
68
  * Override Ajax grid for import to show custom grid for Magento Templates
69
- * @return type
 
70
  */
71
  public function gridAction()
72
  {
@@ -75,11 +78,14 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
75
  }
76
 
77
  $this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_grid')->toHtml());
 
 
78
  }
79
 
80
  /**
81
  * Override Ajax grid for index to show Bronto Templates
82
- * @return type
 
83
  */
84
  public function brontoGridAction()
85
  {
@@ -88,6 +94,8 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
88
  }
89
 
90
  $this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_grid')->toHtml());
 
 
91
  }
92
 
93
  /**
@@ -96,9 +104,9 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
96
  public function ajaxlistAction()
97
  {
98
  $template = $this->_initTemplate();
99
- $request = $this->getRequest();
100
- $filter = array();
101
- $storeId = $request->getParam('id', null);
102
  $sendType = $request->getParam('type', false);
103
  if ('transactional' == $sendType) {
104
  $filter = array('transactional_approval' => 'accepted');
@@ -166,7 +174,8 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
166
 
167
  /**
168
  * Override Save Action for Bronto Templates
169
- * @return type
 
170
  */
171
  public function brontoSaveAction()
172
  {
@@ -181,62 +190,72 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
181
  if (!$template->getId() && $id) {
182
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('This Email template no longer exists.'));
183
  $this->_redirect('*/*/');
184
- return;
 
185
  }
186
 
187
  try {
 
 
 
 
 
 
 
 
 
 
 
188
  // Add Template Settings
189
  $template->setTemplateCode($request->getParam('template_code'))
190
  ->setModifiedAt(Mage::getSingleton('core/date')->gmtDate())
191
- ->setTemplateText($request->getParam('template_text'))
192
- ->setTemplateSubject($request->getParam('template_subject'))
193
- ->setTemplateStyles($request->getParam('template_styles'))
194
  ->setOrigTemplateCode($request->getParam('orig_template_code'))
195
  ->setOrigTemplateVariables($request->getParam('orig_template_variables'));
196
 
197
- // Get Bronto Template and Add Template Settings
198
- $brontoTemplate = Mage::getModel('bronto_email/message')
199
- ->setTemplateSendType($request->getParam('template_send_type'))
200
- ->setStoreId($request->getParam('store_id'));
201
-
202
  // Handle Template Type Settings
203
  if (!$template->getId()) {
204
  $template->setTemplateType(Mage_Core_Model_Email_Template::TYPE_HTML);
205
  }
206
-
207
  if ($request->getParam('_change_type_flag')) {
208
  $template->setTemplateType(Mage_Core_Model_Email_Template::TYPE_TEXT);
209
  $template->setTemplateStyles('');
210
  }
211
 
212
- // Add appropriate values based on send type
213
- switch ($request->getParam('template_send_type')) {
214
- case 'magento':
215
- $brontoTemplate
216
- ->setBrontoMessageId($request->getParam('bronto_message_id_hidden'))
217
- ->setOrigTemplateText($request->getParam('template_text'))
218
- ->setBrontoMessageName($this->_getMessageName($request->getParam('bronto_message_id_hidden')));
219
- break;
220
-
221
- default:
222
- $template->setTemplateText($request->getParam('template_text_hidden'))
223
- ->setTemplateSubject($request->getParam('template_subject_hidden'))
224
- ->setTemplateStyles($request->getParam('template_styles_hidden'));
225
-
226
- if ('_new_' == $request->getParam('bronto_message_id')) {
227
- $template->save();
228
 
229
- $importModel = Mage::getModel('bronto_email/template_import');
230
- $importModel->importTemplate($template->getId(), $request->getParam('store_id'));
231
- } else {
232
- $brontoTemplate->setBrontoMessageId($request->getParam('bronto_message_id'))
233
- ->setBrontoMessageName($this->_getMessageName($request->getParam('bronto_message_id')))
234
- ->setOrigTemplateText($request->getParam('orig_template_text', null));
235
- }
236
 
237
- break;
 
 
 
 
 
 
 
 
 
 
238
  }
239
 
 
 
 
 
 
240
  if (!$template->getId() || !$template->getAddedAt()) {
241
  $template->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
242
  }
@@ -245,8 +264,10 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
245
  $template->save();
246
 
247
  // Set Bronto Template ID to match newly saved Template and then save
248
- $brontoTemplate->setId($template->getId());
249
- $brontoTemplate->save();
 
 
250
 
251
  Mage::getSingleton('adminhtml/session')->setFormData(false);
252
  Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The email template has been saved.'));
@@ -256,12 +277,16 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
256
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
257
  $this->_forward('brontoNew');
258
  }
 
 
259
  }
260
 
261
  /**
262
  * Get Message Name from Message ID
263
- * @param type $messageId
264
- * @return type
 
 
265
  */
266
  private function _getMessageName($messageId)
267
  {
@@ -271,10 +296,14 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
271
  return $message['label'];
272
  }
273
  }
 
 
274
  }
275
 
276
  /**
277
  * Edit Default Templates
 
 
278
  */
279
  public function importEditAction()
280
  {
@@ -294,10 +323,12 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
294
  $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_edit', 'template_edit')
295
  ->setEditMode((bool)$this->getRequest()->getParam('id')));
296
  $this->renderLayout();
 
 
297
  }
298
 
299
  /**
300
- * Edit transactioanl email action
301
  */
302
  public function brontoEditAction()
303
  {
@@ -336,7 +367,7 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
336
  return parent::defaultTemplateAction();
337
  }
338
 
339
- $template = $this->_initTemplate('id');
340
  $templateCode = $this->getRequest()->getParam('code');
341
 
342
  $template->loadDefault($templateCode, $this->getRequest()->getParam('locale'));
@@ -347,6 +378,8 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
347
  $template->setData('orig_template_used_default_for', $templateBlock->getUsedDefaultForPaths(false));
348
 
349
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($template->getData()));
 
 
350
  }
351
 
352
  /**
@@ -392,7 +425,7 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
392
  {
393
  $templateIds = $this->getRequest()->getParam('template_id', array());
394
  $deleteLevel = $this->getRequest()->getParam('delete_level', 'message');
395
- $deleted = 0;
396
 
397
  // If single ID, set as array
398
  if (is_numeric($templateIds)) {
@@ -430,8 +463,8 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
430
  public function updateSendTypeAction()
431
  {
432
  $templateIds = $this->getRequest()->getParam('template_id', array());
433
- $sendType = $this->getRequest()->getParam('send_type', 'marketing');
434
- $updated = 0;
435
 
436
  // If single ID, set as array
437
  if (is_numeric($templateIds)) {
@@ -444,11 +477,11 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
444
  $template = Mage::getModel('bronto_email/message')->load($templateId);
445
 
446
  // TODO: When approval status is available from api, implement this check
447
- // if ('transactional' == $sendType && 0 === $template->getBrontoMessageApproved()) {
448
- // Mage::helper('bronto_email')->writeError(
449
- // Mage::helper('bronto_email')->__($template->getTemplateCode() . ' has not been approved for transactional sending')
450
- // );
451
- // }
452
 
453
  if ($template->getId()) {
454
  try {
@@ -500,13 +533,14 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
500
  * Load email template from request
501
  *
502
  * @param string $idFieldName
 
503
  * @return Mage_Adminhtml_Model_Email_Template $model
504
  */
505
  protected function _initTemplate($idFieldName = 'template_id')
506
  {
507
  $this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
508
 
509
- $id = (int)$this->getRequest()->getParam($idFieldName);
510
  $model = Mage::getModel('bronto_email/template');
511
 
512
  if ($id) {
@@ -519,12 +553,7 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
519
  if (!Mage::registry('current_email_template')) {
520
  Mage::register('current_email_template', $model);
521
  }
522
- return $model;
523
- }
524
 
525
- protected function _isAllowed()
526
- {
527
- return Mage::getSingleton('admin/session')->isAllowed('bronto_email/email_template');
528
  }
529
-
530
  }
1
  <?php
2
 
 
 
 
3
  require_once 'Mage/Adminhtml/controllers/System/Email/TemplateController.php';
4
 
5
  /**
6
  * @package Bronto\Email
7
  * @copyright 2011-2013 Bronto Software, Inc.
 
8
  */
9
  class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_System_Email_TemplateController
10
  {
14
  /**
15
  * Main Grid view for Transactional Email Templates
16
  * Overwritten to show Bronto Templates
17
+ *
18
  * @return null
19
  */
20
  public function indexAction()
28
 
29
  if ($this->getRequest()->getQuery('ajax')) {
30
  $this->_forward('brontoGrid');
31
+
32
+ return false;
33
  }
34
 
35
  $this->loadLayout();
38
 
39
  $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template', 'template'));
40
  $this->renderLayout();
41
+
42
+ return $this;
43
  }
44
 
45
  /**
46
  * Main Grid view for Importing Transactional Email Templates into Bronto
47
+ *
48
  * @return null
49
  */
50
  public function importAction()
54
 
55
  if ($this->getRequest()->getQuery('ajax')) {
56
  $this->_forward('grid');
57
+
58
  return;
59
  }
60
 
68
 
69
  /**
70
  * Override Ajax grid for import to show custom grid for Magento Templates
71
+ *
72
+ * @return $this|void
73
  */
74
  public function gridAction()
75
  {
78
  }
79
 
80
  $this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_grid')->toHtml());
81
+
82
+ return $this;
83
  }
84
 
85
  /**
86
  * Override Ajax grid for index to show Bronto Templates
87
+ *
88
+ * @return $this|void
89
  */
90
  public function brontoGridAction()
91
  {
94
  }
95
 
96
  $this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_grid')->toHtml());
97
+
98
+ return $this;
99
  }
100
 
101
  /**
104
  public function ajaxlistAction()
105
  {
106
  $template = $this->_initTemplate();
107
+ $request = $this->getRequest();
108
+ $filter = array();
109
+ $storeId = $request->getParam('id', null);
110
  $sendType = $request->getParam('type', false);
111
  if ('transactional' == $sendType) {
112
  $filter = array('transactional_approval' => 'accepted');
174
 
175
  /**
176
  * Override Save Action for Bronto Templates
177
+ *
178
+ * @return $this|void
179
  */
180
  public function brontoSaveAction()
181
  {
190
  if (!$template->getId() && $id) {
191
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('This Email template no longer exists.'));
192
  $this->_redirect('*/*/');
193
+
194
+ return $this;
195
  }
196
 
197
  try {
198
+ // Get Send Type
199
+ $sendType = $request->getParam('template_send_type');
200
+
201
+ // Get Store ID
202
+ $storeId = (Mage::app()->isSingleStoreMode()) ? Mage::app()->getDefaultStoreView()->getId() : $request->getParam('store_id');
203
+
204
+ // Core Template Details
205
+ $templateText = ($sendType == 'magento') ? $request->getParam('template_text') : $request->getParam('template_text_hidden');
206
+ $templateSubject = ($sendType == 'magento') ? $request->getParam('template_subject') : $request->getParam('template_subject_hidden');
207
+ $templateStyles = ($sendType == 'magento') ? $request->getParam('template_styles') : $request->getParam('template_styles_hidden');
208
+
209
  // Add Template Settings
210
  $template->setTemplateCode($request->getParam('template_code'))
211
  ->setModifiedAt(Mage::getSingleton('core/date')->gmtDate())
212
+ ->setTemplateText($templateText)
213
+ ->setTemplateSubject($templateSubject)
214
+ ->setTemplateStyles($templateStyles)
215
  ->setOrigTemplateCode($request->getParam('orig_template_code'))
216
  ->setOrigTemplateVariables($request->getParam('orig_template_variables'));
217
 
 
 
 
 
 
218
  // Handle Template Type Settings
219
  if (!$template->getId()) {
220
  $template->setTemplateType(Mage_Core_Model_Email_Template::TYPE_HTML);
221
  }
 
222
  if ($request->getParam('_change_type_flag')) {
223
  $template->setTemplateType(Mage_Core_Model_Email_Template::TYPE_TEXT);
224
  $template->setTemplateStyles('');
225
  }
226
 
227
+ // Bronto Template Details
228
+ $brontoMessageId = ($sendType == 'magento') ? $request->getParam('bronto_message_id_hidden') : $request->getParam('bronto_message_id');
229
+ $brontoMessageName = $this->_getMessageName($brontoMessageId);
230
+ $origTemplateText = ($sendType == 'magento') ? $request->getParam('template_text') : $request->getParam('orig_template_text', null);
231
+ // If Original Template Text value is empty, pull from the hidden field that should have a value
232
+ if ('' == $origTemplateText || is_null($origTemplateText)) {
233
+ $origTemplateText = $request->getParam('template_text_hidden');
234
+ }
 
 
 
 
 
 
 
 
235
 
236
+ // If Bronto Message ID == '_new_' the importTemplate function will create the message
237
+ // in Bronto and add the details to the template entry
238
+ if ('_new_' == $brontoMessageId && 'magento' != $sendType) {
239
+ $template->save();
 
 
 
240
 
241
+ $importModel = Mage::getModel('bronto_email/template_import');
242
+ $importModel->importTemplate($template->getId(), $storeId);
243
+ $brontoTemplate = Mage::getModel('bronto_email/message')
244
+ ->load($template->getId());
245
+ } else {
246
+ // Get Bronto Template and Add Template Settings
247
+ $brontoTemplate = Mage::getModel('bronto_email/message')
248
+ ->setStoreId($storeId)
249
+ ->setBrontoMessageId($brontoMessageId)
250
+ ->setBrontoMessageName($brontoMessageName)
251
+ ->setOrigTemplateText($origTemplateText);
252
  }
253
 
254
+ $brontoTemplate
255
+ ->setTemplateSendType($sendType)
256
+ ->setSalesRule($request->getParam('sales_rule', null));
257
+
258
+ // If Template doesn't exist or added_at is not set, set it
259
  if (!$template->getId() || !$template->getAddedAt()) {
260
  $template->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
261
  }
264
  $template->save();
265
 
266
  // Set Bronto Template ID to match newly saved Template and then save
267
+ if ($brontoTemplate) {
268
+ $brontoTemplate->setId($template->getId());
269
+ $brontoTemplate->save();
270
+ }
271
 
272
  Mage::getSingleton('adminhtml/session')->setFormData(false);
273
  Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The email template has been saved.'));
277
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
278
  $this->_forward('brontoNew');
279
  }
280
+
281
+ return $this;
282
  }
283
 
284
  /**
285
  * Get Message Name from Message ID
286
+ *
287
+ * @param string|int $messageId
288
+ *
289
+ * @return string
290
  */
291
  private function _getMessageName($messageId)
292
  {
296
  return $message['label'];
297
  }
298
  }
299
+
300
+ return false;
301
  }
302
 
303
  /**
304
  * Edit Default Templates
305
+ *
306
+ * @return $this
307
  */
308
  public function importEditAction()
309
  {
323
  $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_edit', 'template_edit')
324
  ->setEditMode((bool)$this->getRequest()->getParam('id')));
325
  $this->renderLayout();
326
+
327
+ return $this;
328
  }
329
 
330
  /**
331
+ * Edit transactional email action
332
  */
333
  public function brontoEditAction()
334
  {
367
  return parent::defaultTemplateAction();
368
  }
369
 
370
+ $template = $this->_initTemplate('id');
371
  $templateCode = $this->getRequest()->getParam('code');
372
 
373
  $template->loadDefault($templateCode, $this->getRequest()->getParam('locale'));
378
  $template->setData('orig_template_used_default_for', $templateBlock->getUsedDefaultForPaths(false));
379
 
380
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($template->getData()));
381
+
382
+ return $this;
383
  }
384
 
385
  /**
425
  {
426
  $templateIds = $this->getRequest()->getParam('template_id', array());
427
  $deleteLevel = $this->getRequest()->getParam('delete_level', 'message');
428
+ $deleted = 0;
429
 
430
  // If single ID, set as array
431
  if (is_numeric($templateIds)) {
463
  public function updateSendTypeAction()
464
  {
465
  $templateIds = $this->getRequest()->getParam('template_id', array());
466
+ $sendType = $this->getRequest()->getParam('send_type', 'marketing');
467
+ $updated = 0;
468
 
469
  // If single ID, set as array
470
  if (is_numeric($templateIds)) {
477
  $template = Mage::getModel('bronto_email/message')->load($templateId);
478
 
479
  // TODO: When approval status is available from api, implement this check
480
+ // if ('transactional' == $sendType && 0 === $template->getBrontoMessageApproved()) {
481
+ // Mage::helper('bronto_email')->writeError(
482
+ // Mage::helper('bronto_email')->__($template->getTemplateCode() . ' has not been approved for transactional sending')
483
+ // );
484
+ // }
485
 
486
  if ($template->getId()) {
487
  try {
533
  * Load email template from request
534
  *
535
  * @param string $idFieldName
536
+ *
537
  * @return Mage_Adminhtml_Model_Email_Template $model
538
  */
539
  protected function _initTemplate($idFieldName = 'template_id')
540
  {
541
  $this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
542
 
543
+ $id = (int)$this->getRequest()->getParam($idFieldName);
544
  $model = Mage::getModel('bronto_email/template');
545
 
546
  if ($id) {
553
  if (!Mage::registry('current_email_template')) {
554
  Mage::register('current_email_template', $model);
555
  }
 
 
556
 
557
+ return $model;
 
 
558
  }
 
559
  }
app/code/community/Bronto/Email/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Bronto_Email>
5
- <version>1.1.7</version>
6
  </Bronto_Email>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Bronto_Email>
5
+ <version>1.1.8</version>
6
  </Bronto_Email>
7
  </modules>
8
  <global>
app/code/community/Bronto/Email/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <sections>
4
  <bronto_email translate="label" module="bronto_email">
5
- <label>Transactional Emails</label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>600</sort_order>
2
  <config>
3
  <sections>
4
  <bronto_email translate="label" module="bronto_email">
5
+ <label><![CDATA[<div id="bronto_email_icon_block">Transactional Emails</div>]]></label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>600</sort_order>
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.8.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ /**
9
+ * Create new table to hold bronto templates
10
+ */
11
+ try {
12
+ $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_email/message')}`;");
13
+
14
+ $installer->run("
15
+ CREATE TABLE `{$installer->getTable('bronto_email/message')}` (
16
+ `core_template_id` int(10) unsigned NOT NULL COMMENT 'Magento Template ID',
17
+ `template_send_type` varchar(255) NOT NULL DEFAULT 'magento' COMMENT 'Type of message to send as',
18
+ `orig_template_text` text COMMENT 'Original Template Text',
19
+ `bronto_message_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Message ID',
20
+ `bronto_message_name` varchar(255) DEFAULT NULL COMMENT 'Bronto Message Name',
21
+ `bronto_message_approved` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Bronto Message Transactional Approval Status',
22
+ `store_id` int(11) NOT NULL DEFAULT '1' COMMENT 'Store ID for Template',
23
+ `sales_rule` int(10) NULL COMMENT 'Sales Rule for Coupon Codes',
24
+ PRIMARY KEY (`core_template_id`),
25
+ CONSTRAINT `FK_BRONTO_EMAIL_TEMPLATE_ID_CORE_EMAIL_TEMPLATE_ID` FOREIGN KEY (`core_template_id`)
26
+ REFERENCES `{$installer->getTable('core/email_template')}` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
27
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Template Attributes'
28
+ ");
29
+
30
+ } catch (Exception $e) {
31
+ Mage::helper('bronto_email')->writeError($e->getMessage());
32
+ }
33
+
34
+ /**
35
+ * Email Log table
36
+ */
37
+ try {
38
+
39
+ $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_email/log')}`;");
40
+
41
+ $installer->run("
42
+ CREATE TABLE `{$installer->getTable('bronto_email/log')}` (
43
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
44
+ `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
45
+ `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
46
+ `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
47
+ `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
48
+ `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
49
+ `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
50
+ `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
51
+ `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
52
+ `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
53
+ `fields` text COMMENT 'Fields',
54
+ PRIMARY KEY (`log_id`),
55
+ KEY `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`),
56
+ KEY `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`)
57
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Delivery Logs'
58
+ ");
59
+
60
+ } catch (Exception $e) {
61
+ Mage::helper('bronto_email')->writeError($e->getMessage());
62
+ }
63
+
64
+ $installer->endSetup();
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.7-1.1.8.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ /**
9
+ * Create new table to hold bronto templates
10
+ */
11
+ try {
12
+ $installer->run("
13
+ ALTER TABLE `{$installer->getTable('bronto_email/message')}`
14
+ ADD COLUMN `sales_rule` int(10) NULL;
15
+ ");
16
+ } catch (Exception $e) {
17
+ Mage::helper('bronto_email')->writeError($e->getMessage());
18
+ }
19
+
20
+ $installer->endSetup();
app/code/community/Bronto/Emailcapture/Block/Emailcapture.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto/Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Emailcapture_Block_Emailcapture extends Mage_Core_Block_Template
8
+ {
9
+ /**
10
+ * Get URL to post AJAX calls to
11
+ *
12
+ * @return string url to controller action for handling email capture
13
+ */
14
+ public function getTargetUrl()
15
+ {
16
+ return Mage::getUrl('emailcapture/index/capture', array('_secure' => true));
17
+ }
18
+
19
+ /**
20
+ * Check if module is enabled
21
+ *
22
+ * @param string $scope
23
+ * @param int $scopeId
24
+ *
25
+ * @return bool
26
+ */
27
+ public function isEnabled($scope = 'default', $scopeId = 0)
28
+ {
29
+ return Mage::helper('bronto_emailcapture')->isEnabled($scope, $scopeId);
30
+ }
31
+
32
+ /**
33
+ * Get CSS Selector for Email Capture Fields
34
+ *
35
+ * @return mixed
36
+ */
37
+ public function getFieldSelector()
38
+ {
39
+ return Mage::helper('bronto_emailcapture')->getFieldSelector();
40
+ }
41
+ }
app/code/community/Bronto/Emailcapture/Helper/Data.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto_Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Emailcapture_Helper_Data extends Bronto_Reminder_Helper_Data
8
+ {
9
+ const XML_PATH_COOKIE_TTL = 'bronto_reminder/settings/cookie_ttl';
10
+ const XML_PATH_FIELD_SELECTOR = 'bronto_reminder/settings/field_selector';
11
+
12
+ /**
13
+ * Module Human Readable Name
14
+ */
15
+ protected $_name = 'Bronto Email Capture';
16
+
17
+ /**
18
+ * Get Human Readable Name
19
+ *
20
+ * @return string
21
+ */
22
+ public function getName()
23
+ {
24
+ return $this->__($this->_name);
25
+ }
26
+
27
+ /**
28
+ * Get Cookie TTL Config Value
29
+ *
30
+ * @param boolean $converted
31
+ *
32
+ * @return mixed
33
+ */
34
+ public function getCookieTtl($converted = true)
35
+ {
36
+ $days = $this->getAdminScopedConfig(self::XML_PATH_COOKIE_TTL);
37
+
38
+ // Convert never expire to ~10 years worth of days
39
+ if ('-1' == $days) {
40
+ $days = 3650;
41
+ }
42
+
43
+ // Convert days to seconds if desired
44
+ if ($converted) {
45
+ $days = $days * 86400;
46
+ }
47
+
48
+ // Return ttl
49
+ return $days;
50
+ }
51
+
52
+ /**
53
+ * Get CSS Selector for Email Capture Fields
54
+ *
55
+ * @return mixed
56
+ */
57
+ public function getFieldSelector()
58
+ {
59
+ return $this->getAdminScopedConfig(self::XML_PATH_FIELD_SELECTOR);
60
+ }
61
+ }
app/code/community/Bronto/Emailcapture/Model/Mysql4/Queue.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Emailcapture_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ /**
10
+ * Primery key auto increment flag
11
+ *
12
+ * @var bool
13
+ */
14
+ protected $_isPkAutoIncrement = false;
15
+
16
+ /**
17
+ * Initialize Model
18
+ *
19
+ * @return void
20
+ * @access public
21
+ */
22
+ public function _construct()
23
+ {
24
+ $this->_init('bronto_emailcapture/queue', 'queue_id');
25
+ }
26
+
27
+ /**
28
+ * Get Write adapter instance
29
+ *
30
+ * @return Varien_Db_Adapter_Interface
31
+ */
32
+ public function getWriteAdapter()
33
+ {
34
+ return $this->_getWriteAdapter();
35
+ }
36
+ }
app/code/community/Bronto/Emailcapture/Model/Mysql4/Queue/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_EmailCapture_Model_Mysql4_Queue_Collection
8
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+ /**
11
+ * Initialize Model
12
+ *
13
+ * @return void
14
+ * @access public
15
+ */
16
+ public function _construct()
17
+ {
18
+ parent::_construct();
19
+ $this->_init('bronto_emailcapture/queue');
20
+ }
21
+ }
app/code/community/Bronto/Emailcapture/Model/Observer.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto/Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Emailcapture_Model_Observer extends Mage_Core_Model_Abstract
8
+ {
9
+ /**
10
+ * Observe Newsletter Save and add Subscriber Details to Queue Entry
11
+ *
12
+ * @param Varien_Event_Observer $observer
13
+ *
14
+ * @return Varien_Event_Observer
15
+ */
16
+ public function newsletterSubscriberSaveAfter(Varien_Event_Observer $observer)
17
+ {
18
+ if (!$subscriber = $observer->getEvent()->getSubscriber()) {
19
+ return $observer;
20
+ }
21
+
22
+ try {
23
+ Mage::getModel('bronto_emailcapture/queue')->updateEmail($subscriber->getSubscriberEmail());
24
+ } catch (Exception $e) {
25
+ Mage::helper('bronto_emailcapture')->writeDebug($e->getMessage());
26
+ }
27
+
28
+ return $observer;
29
+ }
30
+
31
+ /**
32
+ * Add Current Email to Quote if Email not already set
33
+ *
34
+ * @param Varien_Event_Observer $observer
35
+ */
36
+ public function addEmailToQuote(Varien_Event_Observer $observer)
37
+ {
38
+ $object = $observer->getEvent()->getDataObject();
39
+
40
+ if ($object instanceof Mage_Sales_Model_Quote) {
41
+ $this->updateQuote($object);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Update Quote Email Address if is guest and current email address assigned doesn't match new email
47
+ *
48
+ * @param Mage_Sales_Model_Quote $quote
49
+ */
50
+ public function updateQuote(Mage_Sales_Model_Quote $quote)
51
+ {
52
+ $queue = Mage::getModel('bronto_emailcapture/queue');
53
+ $currentEmail = $queue->getCurrentEmail();
54
+ if (is_null($quote->getCustomerId()) && $queue->isValidEmail($currentEmail) && $quote->getCustomerEmail() !== $currentEmail) {
55
+ $quote->setCustomerEmail(Mage::getModel('bronto_emailcapture/queue')->getCurrentEmail())->save();
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Function to trigger flushing all old captured emails from queue
61
+ */
62
+ public function flushQueue()
63
+ {
64
+ Mage::getModel('bronto_emailcapture/queue')->flushQueue();
65
+ }
66
+ }
app/code/community/Bronto/Emailcapture/Model/Queue.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Emailcapture_Model_Queue extends Mage_Core_Model_Abstract
8
+ {
9
+ protected $_tid;
10
+ protected $_queueId;
11
+ protected $_cookie;
12
+ protected $_cookieName = 'bmec';
13
+
14
+ public function _construct()
15
+ {
16
+ parent::_construct();
17
+ $this->_init('bronto_emailcapture/queue');
18
+
19
+ $this->_cookie = Mage::getModel('core/cookie');
20
+ }
21
+
22
+ /**
23
+ * Set Cookie Object to be used
24
+ *
25
+ * @param Mage_Core_Model_Cookie $cookie
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setCookie(Mage_Core_Model_Cookie $cookie)
30
+ {
31
+ $this->_cookie = $cookie;
32
+
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Get Cookie to use
38
+ *
39
+ * @return mixed
40
+ */
41
+ public function getCookie()
42
+ {
43
+ return $this->_cookie;
44
+ }
45
+
46
+ /**
47
+ * Build QueueId
48
+ *
49
+ * @return string
50
+ */
51
+ protected function _getQueueId()
52
+ {
53
+ if (!$this->_queueId) {
54
+ $this->_queueId = $this->_getTid() . '_' . Mage::app()->getStore()->getStoreId();
55
+ }
56
+
57
+ return $this->_queueId;
58
+ }
59
+
60
+ /**
61
+ * Get TID from cookie and update cookie
62
+ *
63
+ * @return string
64
+ */
65
+ protected function _getTid()
66
+ {
67
+ if (!$this->_tid) {
68
+ // Get TID and Ensure cookie has current tid
69
+ $this->_tid = $this->getCookie()->get($this->_cookieName, false);
70
+
71
+ if (!$this->_tid) {
72
+ $this->_tid = md5(time() . mt_rand(1, 1000000));
73
+ Mage::getModel('core/cookie')->set($this->_cookieName, $this->_tid, Mage::helper('bronto_emailcapture')->getCookieTtl());
74
+ }
75
+ }
76
+
77
+ return $this->_tid;
78
+ }
79
+
80
+ /**
81
+ * Public call to validate the email
82
+ *
83
+ * @param string $email
84
+ * @return bool
85
+ */
86
+ public function isValidEmail($email)
87
+ {
88
+ try {
89
+ return (bool) Zend_Validate::is($email, 'EmailAddress');
90
+ } catch (Exception $e) {
91
+ return false;
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Update Email Address based on TID and current Store ID
97
+ *
98
+ * @param $email
99
+ *
100
+ * @return $this
101
+ */
102
+ public function updateEmail($email)
103
+ {
104
+ // Validate Email Address
105
+ if ($this->isValidEmail($email)) {
106
+ // Build Collection Select
107
+ $this->load($this->_getQueueId())
108
+ ->setId($this->_getQueueId())
109
+ ->setEmailAddress($email)
110
+ ->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
111
+ ->save();
112
+ }
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Get Email Address for Current TID and Store ID
119
+ *
120
+ * @return Mage_Core_Model_Abstract
121
+ */
122
+ public function getCurrentEmail()
123
+ {
124
+ return $this->load($this->_getQueueId())->getEmailAddress();
125
+ }
126
+
127
+ /**
128
+ * Flush all items from Queue that are older than the ttl of the cookie
129
+ */
130
+ public function flushQueue()
131
+ {
132
+ $ttl = Mage::helper('bronto_emailcapture')->getCookieTtl(false);
133
+
134
+ $where = array('updated_at <' => date(strtotime('-' . $ttl . 'days')));
135
+ $this->_getResource()->getWriteAdapter()->delete($this->getTable('bronto_emailcapture/queue'), $where);
136
+ }
137
+ }
app/code/community/Bronto/Emailcapture/controllers/IndexController.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Emailcapture
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Emailcapture_IndexController extends Mage_Core_Controller_Front_Action
8
+ {
9
+ /**
10
+ * Capture email address provided from input field
11
+ */
12
+ public function captureAction()
13
+ {
14
+ $emailAddress = $this->getRequest()->getParam('emailAddress', null);
15
+
16
+ // If Email Address isn't valid, don't worry
17
+ if (Zend_Validate::is($emailAddress, 'EmailAddress')) {
18
+ try {
19
+ Mage::getModel('bronto_emailcapture/queue')->updateEmail($emailAddress);
20
+ $this->updateQuote();
21
+ } catch (Exception $e) {
22
+ Mage::helper('bronto_emailcapture')->writeDebug($e->getMessage());
23
+ }
24
+ }
25
+
26
+ return;
27
+ }
28
+
29
+ /**
30
+ * Update any attached Quote with email address
31
+ */
32
+ public function updateQuote()
33
+ {
34
+ $quote = Mage::getModel('checkout/cart')->getQuote();
35
+ if ($quote->getId()) {
36
+ Mage::getModel('bronto_emailcapture/observer')->updateQuote($quote);
37
+ }
38
+ }
39
+ }
app/code/community/Bronto/Emailcapture/etc/config.xml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bronto_Emailcapture>
5
+ <version>1.0.0</version>
6
+ </Bronto_Emailcapture>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <bronto_emailcapture>
11
+ <class>Bronto_Emailcapture_Helper</class>
12
+ </bronto_emailcapture>
13
+ </helpers>
14
+ <blocks>
15
+ <bronto_emailcapture>
16
+ <class>Bronto_Emailcapture_Block</class>
17
+ </bronto_emailcapture>
18
+ </blocks>
19
+ <models>
20
+ <bronto_emailcapture>
21
+ <class>Bronto_Emailcapture_Model</class>
22
+ <resourceModel>bronto_emailcapture_mysql4</resourceModel>
23
+ </bronto_emailcapture>
24
+ <bronto_emailcapture_mysql4>
25
+ <class>Bronto_Emailcapture_Model_Mysql4</class>
26
+ <entities>
27
+ <queue>
28
+ <table>bronto_emailcapture_queue</table>
29
+ </queue>
30
+ </entities>
31
+ </bronto_emailcapture_mysql4>
32
+ </models>
33
+ <resources>
34
+ <bronto_emailcapture_setup>
35
+ <setup>
36
+ <module>Bronto_Emailcapture</module>
37
+ </setup>
38
+ <connection>
39
+ <use>core_setup</use>
40
+ </connection>
41
+ </bronto_emailcapture_setup>
42
+ <bronto_emailcapture_write>
43
+ <connection>
44
+ <use>core_write</use>
45
+ </connection>
46
+ </bronto_emailcapture_write>
47
+ <bronto_emailcapture_read>
48
+ <connection>
49
+ <use>core_read</use>
50
+ </connection>
51
+ </bronto_emailcapture_read>
52
+ </resources>
53
+ </global>
54
+ <frontend>
55
+ <layout>
56
+ <updates>
57
+ <bronto_emailcapture>
58
+ <file>bronto/emailcapture.xml</file>
59
+ </bronto_emailcapture>
60
+ </updates>
61
+ </layout>
62
+ <routers>
63
+ <bronto_emailcapture>
64
+ <use>standard</use>
65
+ <args>
66
+ <module>Bronto_Emailcapture</module>
67
+ <frontName>emailcapture</frontName>
68
+ </args>
69
+ </bronto_emailcapture>
70
+ </routers>
71
+ <events>
72
+ <newsletter_subscriber_save_after>
73
+ <observers>
74
+ <bronto_emailcapture_newsletter_subscriber_save_after>
75
+ <class>bronto_emailcapture/observer</class>
76
+ <method>newsletterSubscriberSaveAfter</method>
77
+ </bronto_emailcapture_newsletter_subscriber_save_after>
78
+ </observers>
79
+ </newsletter_subscriber_save_after>
80
+ <sales_quote_save_after>
81
+ <observers>
82
+ <bronto_emailcapture_quote_save_after>
83
+ <class>bronto_emailcapture/observer</class>
84
+ <method>addEmailToQuote</method>
85
+ </bronto_emailcapture_quote_save_after>
86
+ </observers>
87
+ </sales_quote_save_after>
88
+ </events>
89
+ </frontend>
90
+ <default>
91
+ <bronto_reminder>
92
+ <settings>
93
+ <cookie_ttl>365</cookie_ttl>
94
+ <field_selector>input.validate-email</field_selector>
95
+ </settings>
96
+ </bronto_reminder>
97
+ </default>
98
+ <crontab>
99
+ <jobs>
100
+ <bronto_emailcapture_flush_queue>
101
+ <!-- Run once a day -->
102
+ <schedule>
103
+ <cron_expr>0 0 * * *</cron_expr>
104
+ </schedule>
105
+ <run>
106
+ <model>bronto_emailcapture/observer::flushQueue</model>
107
+ </run>
108
+ </bronto_emailcapture_flush_queue>
109
+ </jobs>
110
+ </crontab>
111
+
112
+ <phpunit>
113
+ <suite>
114
+ <modules>
115
+ <Bronto_Emailcapture/>
116
+ </modules>
117
+ </suite>
118
+ </phpunit>
119
+ </config>
app/code/community/Bronto/Emailcapture/etc/system.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <bronto_reminder translate="label" module="bronto_reminder">
5
+ <groups>
6
+ <settings translate="label">
7
+ <fields>
8
+ <field_selector>
9
+ <label>Email Capture Input Field CSS Selector(s)</label>
10
+ <depends>
11
+ <enabled>1</enabled>
12
+ </depends>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>110</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <validate>validate-required</validate>
19
+ <comment>
20
+ <![CDATA[Comma-separated CSS Class Name(s) and/or ID(s) used to identify input fields to capture email addresses for the sake of guest abandonment triggering.<br />Default: "input.validate-email"]]></comment>
21
+ </field_selector>
22
+ <cookie_ttl>
23
+ <label>Email Capture Cookie Lifetime</label>
24
+ <depends>
25
+ <enabled>1</enabled>
26
+ </depends>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>111</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <validate>validate-required validate-digits-range digits-range--1-3650</validate>
33
+ <comment>
34
+ <![CDATA[Number of days for email capture cookie to persist. Must be between 0 to 3650.<br />Default: 365]]></comment>
35
+ </cookie_ttl>
36
+ </fields>
37
+ </settings>
38
+ </groups>
39
+ </bronto_reminder>
40
+ </sections>
41
+ </config>
app/code/community/Bronto/Emailcapture/sql/bronto_emailcapture_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ try {
8
+ $installer->run("
9
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_emailcapture/queue')}`;
10
+
11
+ CREATE TABLE `{$installer->getTable('bronto_emailcapture/queue')}` (
12
+ `queue_id` varchar(50) NOT NULL PRIMARY KEY COMMENT 'Tracking ID and Store ID',
13
+ `email_address` varchar(255) NOT NULL COMMENT 'Email Address',
14
+ `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Updated At'
15
+ );
16
+ ");
17
+
18
+ } catch (Exception $e) {
19
+ throw new RuntimeException('Failed Creating Emailcapture Queue Table: ' . $e->getMessage());
20
+ }
21
+
22
+ $installer->endSetup();
app/code/community/Bronto/News/Block/Adminhtml/ItemRender.php CHANGED
@@ -18,6 +18,7 @@ class Bronto_News_Block_Adminhtml_ItemRender extends Mage_Adminhtml_Block_Abstra
18
  public function render(Varien_Data_Form_Element_Abstract $element)
19
  {
20
  $vars = array('date' => Mage::getModel('core/date'), 'element' => $element);
 
21
  return $this->assign($vars)->toHtml();
22
  }
23
  }
18
  public function render(Varien_Data_Form_Element_Abstract $element)
19
  {
20
  $vars = array('date' => Mage::getModel('core/date'), 'element' => $element);
21
+
22
  return $this->assign($vars)->toHtml();
23
  }
24
  }
app/code/community/Bronto/News/Block/Adminhtml/Redirect.php CHANGED
@@ -7,7 +7,7 @@ class Bronto_News_Block_Adminhtml_Redirect
7
 
8
  protected function _toHtml()
9
  {
10
- $html .= "You are about to be redirected off site to:<br /><br />";
11
  $html .= "<a href=\"{$this->_url}\">{$this->_url}</a>";
12
 
13
  return $html;
@@ -16,6 +16,7 @@ class Bronto_News_Block_Adminhtml_Redirect
16
  public function setRedirectUrl($url)
17
  {
18
  $this->_url = $url;
 
19
  return $this;
20
  }
21
 
7
 
8
  protected function _toHtml()
9
  {
10
+ $html = "You are about to be redirected off site to:<br /><br />";
11
  $html .= "<a href=\"{$this->_url}\">{$this->_url}</a>";
12
 
13
  return $html;
16
  public function setRedirectUrl($url)
17
  {
18
  $this->_url = $url;
19
+
20
  return $this;
21
  }
22
 
app/code/community/Bronto/News/Block/Adminhtml/System/Config/News.php CHANGED
@@ -9,7 +9,7 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
9
  protected $_helper;
10
 
11
  /**
12
- * @var type
13
  */
14
  protected $_renderer;
15
 
@@ -19,7 +19,7 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
19
  protected $_itemDefinition;
20
 
21
  /**
22
- * @return Bronto_News_Model_Resource_Item_Collection
23
  */
24
  protected abstract function _pullRssItems();
25
 
@@ -31,27 +31,31 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
31
  if (is_null($this->_helper)) {
32
  $this->setHelper(Mage::helper('bronto_news'));
33
  }
 
34
  return $this->_helper;
35
  }
36
 
37
  /**
38
  * @param Mage_Core_Helper_Abstract $helper
 
39
  * @return Bronto_News_Block_Adminhtml_System_Config_News
40
  */
41
  public function setHelper(Mage_Core_Helper_Abstract $helper)
42
  {
43
  $this->_helper = $helper;
 
44
  return $this;
45
  }
46
 
47
  /**
48
- * @return type
49
  */
50
  protected function _getRenderer()
51
  {
52
  if (is_null($this->_renderer)) {
53
  $this->_renderer = Mage::getBlockSingleton('bronto_news/adminhtml_itemRender');
54
  }
 
55
  return $this->_renderer;
56
  }
57
 
@@ -62,10 +66,10 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
62
  {
63
  if (is_null($this->_item)) {
64
  $this->_itemDefinition = new Varien_Object(array(
65
- 'frontend_type' => 'link',
66
  'show_in_default' => 1,
67
  'show_in_website' => 1,
68
- 'show_in_store' => 1,
69
  ));
70
  }
71
 
@@ -74,17 +78,18 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
74
 
75
  /**
76
  * @param Varien_Data_Form_Element_Fieldset $fieldset
77
- * @param Bronto_News_Model_Item $item
 
78
  * @return Varien_Data_Form_Element_Abstract
79
  */
80
  protected function addItemToFieldset($fieldset, $item)
81
  {
82
  $field = $fieldset->addField($item->getId(), 'link', array(
83
- 'value' => $item->getTitle(),
84
- 'title' => $item->getTitle(),
85
- 'href' => $item->getLink(),
86
- 'news_item' => $item,
87
- 'target' => '_blank',
88
  'field_config' => $this->_getItemDefinition(),
89
  ));
90
 
@@ -93,6 +98,7 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
93
 
94
  /**
95
  * @param Varien_Data_Form_Element_Abstract $element
 
96
  * @return string
97
  */
98
  public function render(Varien_Data_Form_Element_Abstract $element)
@@ -118,24 +124,36 @@ abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Admin
118
  }
119
 
120
  /**
 
 
121
  * @see parent
 
 
 
122
  * @return string
123
  */
124
  protected function _getHeaderHtml($element)
125
  {
126
- $html = parent::_getHeaderHtml($element);
127
  $tableIndex = strpos($html, '<table');
 
128
  return substr($html, 0, $tableIndex);
129
  }
130
 
131
  /**
 
 
132
  * @see parent
 
 
 
133
  * @return string
134
  */
135
  protected function _getFooterHtml($element)
136
  {
137
- $html = parent::_getFooterHtml($element);
138
  $fieldsetIndex = strpos($html, '</fieldset');
 
139
  return substr($html, $fieldsetIndex);
140
  }
141
  }
9
  protected $_helper;
10
 
11
  /**
12
+ * @var
13
  */
14
  protected $_renderer;
15
 
19
  protected $_itemDefinition;
20
 
21
  /**
22
+ * @return Bronto_News_Model_Mysql4_Item_Collection
23
  */
24
  protected abstract function _pullRssItems();
25
 
31
  if (is_null($this->_helper)) {
32
  $this->setHelper(Mage::helper('bronto_news'));
33
  }
34
+
35
  return $this->_helper;
36
  }
37
 
38
  /**
39
  * @param Mage_Core_Helper_Abstract $helper
40
+ *
41
  * @return Bronto_News_Block_Adminhtml_System_Config_News
42
  */
43
  public function setHelper(Mage_Core_Helper_Abstract $helper)
44
  {
45
  $this->_helper = $helper;
46
+
47
  return $this;
48
  }
49
 
50
  /**
51
+ * @return object
52
  */
53
  protected function _getRenderer()
54
  {
55
  if (is_null($this->_renderer)) {
56
  $this->_renderer = Mage::getBlockSingleton('bronto_news/adminhtml_itemRender');
57
  }
58
+
59
  return $this->_renderer;
60
  }
61
 
66
  {
67
  if (is_null($this->_item)) {
68
  $this->_itemDefinition = new Varien_Object(array(
69
+ 'frontend_type' => 'link',
70
  'show_in_default' => 1,
71
  'show_in_website' => 1,
72
+ 'show_in_store' => 1,
73
  ));
74
  }
75
 
78
 
79
  /**
80
  * @param Varien_Data_Form_Element_Fieldset $fieldset
81
+ * @param Bronto_News_Model_Item $item
82
+ *
83
  * @return Varien_Data_Form_Element_Abstract
84
  */
85
  protected function addItemToFieldset($fieldset, $item)
86
  {
87
  $field = $fieldset->addField($item->getId(), 'link', array(
88
+ 'value' => $item->getTitle(),
89
+ 'title' => $item->getTitle(),
90
+ 'href' => $item->getLink(),
91
+ 'news_item' => $item,
92
+ 'target' => '_blank',
93
  'field_config' => $this->_getItemDefinition(),
94
  ));
95
 
98
 
99
  /**
100
  * @param Varien_Data_Form_Element_Abstract $element
101
+ *
102
  * @return string
103
  */
104
  public function render(Varien_Data_Form_Element_Abstract $element)
124
  }
125
 
126
  /**
127
+ * Get Header HTML
128
+ *
129
  * @see parent
130
+ *
131
+ * @param Varien_Data_Form_Element_Abstract $element
132
+ *
133
  * @return string
134
  */
135
  protected function _getHeaderHtml($element)
136
  {
137
+ $html = parent::_getHeaderHtml($element);
138
  $tableIndex = strpos($html, '<table');
139
+
140
  return substr($html, 0, $tableIndex);
141
  }
142
 
143
  /**
144
+ * Get Footer HTML
145
+ *
146
  * @see parent
147
+ *
148
+ * @param Varien_Data_Form_Element_Abstract $element
149
+ *
150
  * @return string
151
  */
152
  protected function _getFooterHtml($element)
153
  {
154
+ $html = parent::_getFooterHtml($element);
155
  $fieldsetIndex = strpos($html, '</fieldset');
156
+
157
  return substr($html, $fieldsetIndex);
158
  }
159
  }
app/code/community/Bronto/News/Helper/Data.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
4
  {
5
-
6
  const XML_PATH_FEEDS = 'bronto_news/feeds';
7
 
8
  /**
@@ -15,6 +14,21 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
15
  */
16
  protected $_client;
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Gets the RSS item threshold
20
  *
@@ -33,6 +47,7 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
33
  public function getReleaseUrl()
34
  {
35
  $path = self::XML_PATH_FEEDS . '/' . Bronto_News_Model_Item::TYPE_RELEASE;
 
36
  return $this->getAdminScopedConfig($path);
37
  }
38
 
@@ -44,13 +59,15 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
44
  public function getGeneralUrl()
45
  {
46
  $path = self::XML_PATH_FEEDS . '/' . Bronto_News_Model_Item::TYPE_GENERAL;
 
47
  return $this->getAdminScopedConfig($path);
48
  }
49
 
50
  /**
51
- * Sets the XML provider to be used in conjuction with SimpleXMLElement
52
  *
53
  * @param Varien_Http_Adapter_Curl $provider
 
54
  * @return Bronto_Common_Helper_Data
55
  */
56
  public function setXmlProvider(Varien_Http_Adapter_Curl $provider)
@@ -61,12 +78,15 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
61
 
62
  $this->_xmlProvider = $provider;
63
  $this->_client->setAdapter($provider);
 
64
  return $this;
65
  }
66
 
67
  /**
68
  * Given a url, use the provider to pull from the url
69
  *
 
 
70
  * @return string
71
  */
72
  protected function _getXml($url)
@@ -77,6 +97,7 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
77
 
78
  $this->_client->setUri($url ? $url : 'http');
79
  $response = $this->_client->request(Zend_Http_Client::GET);
 
80
  return $response->getBody();
81
  }
82
 
@@ -93,9 +114,10 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
93
  /**
94
  * Processes the RSS feed based on type and url
95
  *
96
- * @param string $type
97
- * @param string $url
98
  * @param boolean $silence
 
99
  * @throws RuntimeException
100
  */
101
  protected function _processItems($type, $url, $silence)
@@ -105,11 +127,11 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
105
 
106
  try {
107
  $date = Mage::getModel('core/date');
108
- $xml = new SimpleXMLElement($this->_getXml($url));
109
 
110
  foreach ($xml->channel->item as $item) {
111
- $guid = (string)$item->guid;
112
- $description = (string)$item->description;
113
  $formattedDate = strtotime((string)$item->pubDate);
114
 
115
  // Attempts to load the RSS feed
@@ -176,6 +198,7 @@ class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
176
  * mark the notification as read
177
  *
178
  * @param Bronto_News_Model_Item $item
 
179
  * @return string
180
  */
181
  protected function wrapNotificationUrl(Bronto_News_Model_Item $item)
2
 
3
  class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
4
  {
 
5
  const XML_PATH_FEEDS = 'bronto_news/feeds';
6
 
7
  /**
14
  */
15
  protected $_client;
16
 
17
+ /**
18
+ * Module Human Readable Name
19
+ */
20
+ protected $_name = 'Bronto News & Announcements';
21
+
22
+ /**
23
+ * Get Human Readable Name
24
+ *
25
+ * @return string
26
+ */
27
+ public function getName()
28
+ {
29
+ return $this->__($this->_name);
30
+ }
31
+
32
  /**
33
  * Gets the RSS item threshold
34
  *
47
  public function getReleaseUrl()
48
  {
49
  $path = self::XML_PATH_FEEDS . '/' . Bronto_News_Model_Item::TYPE_RELEASE;
50
+
51
  return $this->getAdminScopedConfig($path);
52
  }
53
 
59
  public function getGeneralUrl()
60
  {
61
  $path = self::XML_PATH_FEEDS . '/' . Bronto_News_Model_Item::TYPE_GENERAL;
62
+
63
  return $this->getAdminScopedConfig($path);
64
  }
65
 
66
  /**
67
+ * Sets the XML provider to be used in conjunction with SimpleXMLElement
68
  *
69
  * @param Varien_Http_Adapter_Curl $provider
70
+ *
71
  * @return Bronto_Common_Helper_Data
72
  */
73
  public function setXmlProvider(Varien_Http_Adapter_Curl $provider)
78
 
79
  $this->_xmlProvider = $provider;
80
  $this->_client->setAdapter($provider);
81
+
82
  return $this;
83
  }
84
 
85
  /**
86
  * Given a url, use the provider to pull from the url
87
  *
88
+ * @param $url
89
+ *
90
  * @return string
91
  */
92
  protected function _getXml($url)
97
 
98
  $this->_client->setUri($url ? $url : 'http');
99
  $response = $this->_client->request(Zend_Http_Client::GET);
100
+
101
  return $response->getBody();
102
  }
103
 
114
  /**
115
  * Processes the RSS feed based on type and url
116
  *
117
+ * @param string $type
118
+ * @param string $url
119
  * @param boolean $silence
120
+ *
121
  * @throws RuntimeException
122
  */
123
  protected function _processItems($type, $url, $silence)
127
 
128
  try {
129
  $date = Mage::getModel('core/date');
130
+ $xml = new SimpleXMLElement($this->_getXml($url));
131
 
132
  foreach ($xml->channel->item as $item) {
133
+ $guid = (string)$item->guid;
134
+ $description = (string)$item->description;
135
  $formattedDate = strtotime((string)$item->pubDate);
136
 
137
  // Attempts to load the RSS feed
198
  * mark the notification as read
199
  *
200
  * @param Bronto_News_Model_Item $item
201
+ *
202
  * @return string
203
  */
204
  protected function wrapNotificationUrl(Bronto_News_Model_Item $item)
app/code/community/Bronto/News/Model/Item.php CHANGED
@@ -5,7 +5,7 @@ class Bronto_News_Model_Item extends Mage_Core_Model_Abstract
5
 
6
  const TYPE_GENERAL = 'general';
7
  const TYPE_RELEASE = 'releases';
8
- const TYPE_OTHER = 'other';
9
 
10
  /**
11
  * @var Mage_Core_Helper_Abstract
@@ -16,11 +16,13 @@ class Bronto_News_Model_Item extends Mage_Core_Model_Abstract
16
  * Sets the helper to be used with config data
17
  *
18
  * @param Mage_Core_Helper_Abstract $helper
 
19
  * @return Bronto_News_Model_Item
20
  */
21
  public function setHelper(Mage_Core_Helper_Abstract $helper)
22
  {
23
  $this->_helper = $helper;
 
24
  return $this;
25
  }
26
 
@@ -56,6 +58,7 @@ class Bronto_News_Model_Item extends Mage_Core_Model_Abstract
56
  if (!$this->getSilence()) {
57
  $this->_getHelper()->createAnnouncement($this);
58
  }
 
59
  return $this;
60
  }
61
 
@@ -103,6 +106,7 @@ class Bronto_News_Model_Item extends Mage_Core_Model_Abstract
103
  * Returns a collection of RSS items based on type
104
  *
105
  * @param string $type
 
106
  * @return Mage_Core_Model_Resource_Db_Collection_Abstract
107
  */
108
  public function getItemsOfType($type)
5
 
6
  const TYPE_GENERAL = 'general';
7
  const TYPE_RELEASE = 'releases';
8
+ const TYPE_OTHER = 'other';
9
 
10
  /**
11
  * @var Mage_Core_Helper_Abstract
16
  * Sets the helper to be used with config data
17
  *
18
  * @param Mage_Core_Helper_Abstract $helper
19
+ *
20
  * @return Bronto_News_Model_Item
21
  */
22
  public function setHelper(Mage_Core_Helper_Abstract $helper)
23
  {
24
  $this->_helper = $helper;
25
+
26
  return $this;
27
  }
28
 
58
  if (!$this->getSilence()) {
59
  $this->_getHelper()->createAnnouncement($this);
60
  }
61
+
62
  return $this;
63
  }
64
 
106
  * Returns a collection of RSS items based on type
107
  *
108
  * @param string $type
109
+ *
110
  * @return Mage_Core_Model_Resource_Db_Collection_Abstract
111
  */
112
  public function getItemsOfType($type)
app/code/community/Bronto/News/Model/Observer.php CHANGED
@@ -12,11 +12,13 @@ class Bronto_News_Model_Observer
12
  * Sets the helper to be used with this observer
13
  *
14
  * @param Mage_Core_Helper_Abstract $helper
 
15
  * @return Bronto_News_Model_Observer
16
  */
17
  public function setHelper(Mage_Core_Helper_Abstract $helper)
18
  {
19
  $this->_helper = $helper;
 
20
  return $this;
21
  }
22
 
12
  * Sets the helper to be used with this observer
13
  *
14
  * @param Mage_Core_Helper_Abstract $helper
15
+ *
16
  * @return Bronto_News_Model_Observer
17
  */
18
  public function setHelper(Mage_Core_Helper_Abstract $helper)
19
  {
20
  $this->_helper = $helper;
21
+
22
  return $this;
23
  }
24
 
app/code/community/Bronto/News/Model/Resource/Setup.php CHANGED
@@ -19,6 +19,7 @@ class Bronto_News_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
19
  $helper->pullNewItems();
20
  } catch (Exception $e) {
21
  $helper->writeError('Failed to pull items on install.');
 
22
  return false;
23
  }
24
 
@@ -26,7 +27,7 @@ class Bronto_News_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
26
  }
27
 
28
  /**
29
- * Load the inital config data for the module
30
  */
31
  public function loadInitialSettings()
32
  {
19
  $helper->pullNewItems();
20
  } catch (Exception $e) {
21
  $helper->writeError('Failed to pull items on install.');
22
+
23
  return false;
24
  }
25
 
27
  }
28
 
29
  /**
30
+ * Load the initial config data for the module
31
  */
32
  public function loadInitialSettings()
33
  {
app/code/community/Bronto/News/controllers/Adminhtml/AnnouncementController.php CHANGED
@@ -16,26 +16,29 @@ class Bronto_News_Adminhtml_AnnouncementController extends Mage_Adminhtml_Contro
16
  if (is_null($this->_helper)) {
17
  $this->setHelper(Mage::helper('bronto_news'));
18
  }
 
19
  return $this->_helper;
20
  }
21
 
22
  /**
23
  * @param Mage_Core_Helper_Abstract $helper
24
- * @return Bronto_News_Adminhtml_RefreshController
 
25
  */
26
  public function setHelper(Mage_Core_Helper_Abstract $helper)
27
  {
28
  $this->_helper = $helper;
 
29
  return $this;
30
  }
31
 
32
  /**
33
- * Refresh Feeds and send back to resquestUri
34
  * Example: admin/announcement/refresh
35
  */
36
  public function refreshAction()
37
  {
38
- $helper = $this->_getHelper();
39
  $session = Mage::getSingleton('adminhtml/session');
40
 
41
  try {
16
  if (is_null($this->_helper)) {
17
  $this->setHelper(Mage::helper('bronto_news'));
18
  }
19
+
20
  return $this->_helper;
21
  }
22
 
23
  /**
24
  * @param Mage_Core_Helper_Abstract $helper
25
+ *
26
+ * @return $this
27
  */
28
  public function setHelper(Mage_Core_Helper_Abstract $helper)
29
  {
30
  $this->_helper = $helper;
31
+
32
  return $this;
33
  }
34
 
35
  /**
36
+ * Refresh Feeds and send back to requestUri
37
  * Example: admin/announcement/refresh
38
  */
39
  public function refreshAction()
40
  {
41
+ $helper = $this->_getHelper();
42
  $session = Mage::getSingleton('adminhtml/session');
43
 
44
  try {
app/code/community/Bronto/News/controllers/RouteController.php CHANGED
@@ -15,6 +15,7 @@ class Bronto_News_RouteController extends Mage_Core_Controller_Front_Action
15
  $item = Mage::getModel('bronto_news/item')->load($id, 'item_id');
16
  if ($item->hasTitle()) {
17
  $link = $item->markAlertAsRead()->getLink();
 
18
  return $this->_redirectUrl($link);
19
  }
20
  }
15
  $item = Mage::getModel('bronto_news/item')->load($id, 'item_id');
16
  if ($item->hasTitle()) {
17
  $link = $item->markAlertAsRead()->getLink();
18
+
19
  return $this->_redirectUrl($link);
20
  }
21
  }
app/code/community/Bronto/News/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <sections>
4
  <bronto_news module="bronto_news">
5
- <label><![CDATA[Announcements &amp; News]]></label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <frontend_model>bronto_news/adminhtml_system_config_form</frontend_model>
2
  <config>
3
  <sections>
4
  <bronto_news module="bronto_news">
5
+ <label><![CDATA[<div id="bronto_news_icon_block">Announcements &amp; News</div>]]></label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <frontend_model>bronto_news/adminhtml_system_config_form</frontend_model>
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/About.php CHANGED
@@ -3,13 +3,13 @@
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
9
  {
10
 
11
  /**
12
  * Description for protected
 
13
  * @var string
14
  * @access protected
15
  */
@@ -17,6 +17,7 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_About extends Bronto_Commo
17
 
18
  /**
19
  * Description for protected
 
20
  * @var string
21
  * @access protected
22
  */
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
8
  {
9
 
10
  /**
11
  * Description for protected
12
+ *
13
  * @var string
14
  * @access protected
15
  */
17
 
18
  /**
19
  * Description for protected
20
+ *
21
  * @var string
22
  * @access protected
23
  */
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Cron.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
9
  {
@@ -55,12 +54,13 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
55
 
56
  /**
57
  * Get number of customers not imported from stores that don't have module enabled
 
58
  * @return int
59
  */
60
  protected function getProgressBarDisabled()
61
  {
62
  $collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
63
- $storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
64
 
65
  if ($storeIds) {
66
  if (!is_array($storeIds)) {
@@ -79,6 +79,7 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
79
  ->getSize();
80
  }
81
  }
 
82
  return 0;
83
  }
84
 
@@ -88,7 +89,7 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
88
  protected function getNewsletterResourceCollection()
89
  {
90
  $collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
91
- $storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
92
 
93
  if ($storeIds) {
94
  $collection->addStoreFilter($storeIds);
@@ -96,4 +97,14 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
96
 
97
  return $collection;
98
  }
 
 
 
 
 
 
 
 
 
 
99
  }
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
8
  {
54
 
55
  /**
56
  * Get number of customers not imported from stores that don't have module enabled
57
+ *
58
  * @return int
59
  */
60
  protected function getProgressBarDisabled()
61
  {
62
  $collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
63
+ $storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
64
 
65
  if ($storeIds) {
66
  if (!is_array($storeIds)) {
79
  ->getSize();
80
  }
81
  }
82
+
83
  return 0;
84
  }
85
 
89
  protected function getNewsletterResourceCollection()
90
  {
91
  $collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
92
+ $storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
93
 
94
  if ($storeIds) {
95
  $collection->addStoreFilter($storeIds);
97
 
98
  return $collection;
99
  }
100
+
101
+ /**
102
+ * Determine if should show the cron table
103
+ *
104
+ * @return mixed
105
+ */
106
+ public function showCronTable()
107
+ {
108
+ return Mage::helper('bronto_newsletter')->canUseMageCron();
109
+ }
110
  }
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Suppressed.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Newsletter
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Newsletter_Block_Adminhtml_System_Config_Suppressed
8
+ extends Bronto_Common_Block_Adminhtml_System_Config_Suppressed
9
+ {
10
+ /**
11
+ * Get URL for AJAX call
12
+ *
13
+ * @return string
14
+ */
15
+ public function getAjaxUrl()
16
+ {
17
+ return Mage::helper('bronto_common')->getScopeUrl('adminhtml/newsletter/suppression');
18
+ }
19
+ }
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Reset.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -14,7 +13,7 @@ class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminht
14
  {
15
  $this->setLabel('Reset All Subscribers');
16
  $this->setOnClick("deleteConfirm('This will mark all subscribers as not-imported and will cause the importer to re-process each subscriber again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/reset') . "'); return false;");
17
- $this->setClass('delete');
18
 
19
  if (!Mage::helper('bronto_newsletter')->isModuleActive() || (!Mage::helper('bronto_newsletter')->isDebugEnabled() && !Mage::helper('bronto_newsletter')->isTestModeEnabled())) {
20
  $this->setDisabled(true)->setClass('disabled');
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Block_Widget_Button
8
  {
13
  {
14
  $this->setLabel('Reset All Subscribers');
15
  $this->setOnClick("deleteConfirm('This will mark all subscribers as not-imported and will cause the importer to re-process each subscriber again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/reset') . "'); return false;");
16
+ $this->setClass('delete bronto-cron-reset');
17
 
18
  if (!Mage::helper('bronto_newsletter')->isModuleActive() || (!Mage::helper('bronto_newsletter')->isDebugEnabled() && !Mage::helper('bronto_newsletter')->isTestModeEnabled())) {
19
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Run.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -14,6 +13,7 @@ class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml
14
  {
15
  $this->setLabel('Run Now');
16
  $this->setOnClick("setLocation('" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/run') . "'); return false;");
 
17
 
18
  // Check to see if this module meets requirements
19
  if (!Mage::helper('bronto_newsletter')->isModuleActive()) {
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml_Block_Widget_Button
8
  {
13
  {
14
  $this->setLabel('Run Now');
15
  $this->setOnClick("setLocation('" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/run') . "'); return false;");
16
+ $this->setClass('bronto-cron-run');
17
 
18
  // Check to see if this module meets requirements
19
  if (!Mage::helper('bronto_newsletter')->isModuleActive()) {
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Sync.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -14,7 +13,7 @@ class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtm
14
  {
15
  $this->setLabel($this->__('Sync Subscribers to Queue'));
16
  $this->setOnClick("deleteConfirm('This will ensure all Magento subscribers are in the queue to import into Bronto\\n\\nThis is meant to be used when the subscriber count does not match the total number of subscriber in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/sync') . "'); return false;");
17
- $this->setClass('save');
18
 
19
  if (!Mage::helper('bronto_newsletter')->isModuleActive()) {
20
  $this->setDisabled(true)->setClass('disabled');
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
8
  {
13
  {
14
  $this->setLabel($this->__('Sync Subscribers to Queue'));
15
  $this->setOnClick("deleteConfirm('This will ensure all Magento subscribers are in the queue to import into Bronto\\n\\nThis is meant to be used when the subscriber count does not match the total number of subscriber in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/sync') . "'); return false;");
16
+ $this->setClass('save bronto-cron-sync');
17
 
18
  if (!Mage::helper('bronto_newsletter')->isModuleActive()) {
19
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Newsletter/Block/Checkout/Onepage/Newsletter.php CHANGED
@@ -3,10 +3,13 @@
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_Block_Onepage_Abstract
9
  {
 
 
 
 
10
  /**
11
  * @return bool
12
  */
@@ -52,7 +55,16 @@ class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_
52
  */
53
  public function isEnabledForLoggedinCheckout()
54
  {
55
- // TODO: This can be replaced when fourth case is added
 
 
 
 
 
 
 
 
 
56
  return true;
57
  }
58
 
@@ -65,53 +77,128 @@ class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_
65
  }
66
 
67
  /**
68
- * @return bool
 
 
69
  */
70
- public function getCheckboxLabelText()
71
  {
72
- return addslashes(Mage::helper('bronto_newsletter')->getCheckboxLabelText());
73
  }
74
 
75
  /**
 
76
  *
77
- * @param string $method
78
  * @return string
79
  */
80
- public function getJsCheckedCode($method)
81
- {
82
- $js = "";
83
- $methodName = 'isEnabledFor' . ucfirst($method) . 'Checkout';
84
-
85
- // Default Values
86
- $action = 'hide';
87
- $checked = 'false';
88
- $value = 'null';
89
-
90
- // If function exists, use it, otherwise we hide and disable values
91
- if (method_exists($this, $methodName)) {
92
- if ($this->$methodName()) {
93
- $action = 'show';
94
- if ($this->isSubscribed() || $this->isEnabledCheckedByDefault()) {
95
- $checked = 'true';
96
- $value = '1';
97
- }
98
- }
99
  }
100
 
101
- // If user is subscribed and enabled if already subscribed is not allowed,
102
- // Hide it, but set the values to true
103
- if ($this->isSubscribed() && !$this->isEnabledIfAlreadySubscribed()) {
104
- $action = 'hide';
105
- $checked = 'true';
106
- $value = '1';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
 
109
- // Create JS
110
- $js .= "Element.{$action}('register-customer-newsletter');\r\n";
111
- $js .= "$('billing:is_subscribed_box').checked = {$checked};\r\n";
112
- $js .= "$('billing:is_subscribed').value = {$value};\r\n";
113
- $js .= "$('billing:is_subscribed').value = {$value};\r\n";
114
 
115
- return $js;
 
 
 
116
  }
117
  }
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_Block_Onepage_Abstract
8
  {
9
+ private $_mode = 'loggedin';
10
+ private $_show = true;
11
+ private $_checked = false;
12
+
13
  /**
14
  * @return bool
15
  */
55
  */
56
  public function isEnabledForLoggedinCheckout()
57
  {
58
+ return Mage::helper('bronto_newsletter')->isEnabledForLoggedinCheckout();
59
+ }
60
+
61
+ /**
62
+ * This allows checkbox field to pre-load
63
+ *
64
+ * @return boolean
65
+ */
66
+ public function isEnabledForLoadingCheckout()
67
+ {
68
  return true;
69
  }
70
 
77
  }
78
 
79
  /**
80
+ * Get Url for Ajax call
81
+ *
82
+ * @return string
83
  */
84
+ public function getRequestUrl()
85
  {
86
+ return Mage::getSingleton('core/url')->getUrl('btnewsletter/index/checkbox', array('_secure' => true));
87
  }
88
 
89
  /**
90
+ * Get Url for Updating Subscription Status
91
  *
 
92
  * @return string
93
  */
94
+ public function getSubscribeUrl()
95
+ {
96
+ return Mage::getSingleton('core/url')->getUrl('btnewsletter/index/subscribe', array('_secure' => true));
97
+ }
98
+
99
+ /**
100
+ * Set checkout mode
101
+ *
102
+ * @param string $mode 'guest', 'register', 'loggedin'
103
+ *
104
+ * @return Bronto_Newsletter_Block_Checkout_Onepage_Newsletter
105
+ */
106
+ public function setMode($mode)
107
+ {
108
+ if ($this->isCustomerLoggedIn()) {
109
+ $mode = 'loggedin';
110
+ } elseif (!in_array($mode, array('loggedin', 'guest', 'register'))) {
111
+ $mode = 'loading';
 
112
  }
113
 
114
+ $this->_mode = $mode;
115
+
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * Get value of Checked parameter
121
+ *
122
+ * @param bool $asInt
123
+ *
124
+ * @return bool|int
125
+ */
126
+ public function getChecked($asInt = false)
127
+ {
128
+ if ($asInt) {
129
+ return ($this->_checked) ? 1 : 0;
130
+ }
131
+
132
+ return $this->_checked;
133
+ }
134
+
135
+ /**
136
+ * Get Checkbox Checked status
137
+ *
138
+ * @return string
139
+ */
140
+ public function getCheckboxChecked()
141
+ {
142
+ return ($this->_checked) ? ' checked="checked"' : '';
143
+ }
144
+
145
+ /**
146
+ * Get Checkbox visibility
147
+ *
148
+ * @return string
149
+ */
150
+ public function getCheckboxShow()
151
+ {
152
+ return ($this->_show) ? '' : ' style="display:none;"';
153
+ }
154
+
155
+ /**
156
+ * Get Checkbox Checked value
157
+ *
158
+ * @return string
159
+ */
160
+ public function getCheckboxValue()
161
+ {
162
+ return ($this->_checked) ? '1' : '0';
163
+ }
164
+
165
+ /**
166
+ * Get the text to display for the checkbox label
167
+ *
168
+ * @return bool
169
+ */
170
+ public function getCheckboxLabelText()
171
+ {
172
+ return Mage::helper('bronto_newsletter')->getCheckboxLabelText();
173
+ }
174
+
175
+ /**
176
+ * Calculate checkbox display settings
177
+ */
178
+ protected function _setCheckboxStatus()
179
+ {
180
+ // If customer subscribed, or checked by default is enabled, set checked
181
+ if ($this->isSubscribed() || $this->isEnabledCheckedByDefault()) {
182
+ $this->_checked = true;
183
+
184
+ // Set Initial subscription status to active
185
+ Mage::getSingleton('checkout/session')
186
+ ->setIsSubscribed(Bronto_Api_Contact::STATUS_ACTIVE);
187
+ } else {
188
+ // Set Initial subscription status to transactional
189
+ Mage::getSingleton('checkout/session')
190
+ ->setIsSubscribed(Bronto_Api_Contact::STATUS_TRANSACTIONAL);
191
  }
192
 
193
+ // If module enabled and checkbox enabled for checkout method, show it
194
+ $methodName = 'isEnabledFor' . ucfirst($this->_mode) . 'Checkout';
195
+ if (!$this->isEnabled() || (!method_exists($this, $methodName) || !$this->$methodName())) {
196
+ $this->_show = false;
197
+ }
198
 
199
+ // If customer subscribed, but checkbox not enabled if subscribed, hide
200
+ if ($this->isSubscribed() && !$this->isEnabledIfAlreadySubscribed()) {
201
+ $this->_show = false;
202
+ }
203
  }
204
  }
app/code/community/Bronto/Newsletter/Helper/Contact.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
9
  {
@@ -27,7 +26,11 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
27
  }
28
 
29
  /**
30
- * @return array
 
 
 
 
31
  */
32
  public function getListIds($store = null)
33
  {
@@ -45,12 +48,22 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
45
 
46
  /**
47
  * Get the list object from list id
48
- * @param int $listId
 
 
 
49
  * @return boolean|Bronto_Api_List_Row
50
  */
51
- public function getListData($listId)
52
  {
53
- if ($api = $this->getApi()) {
 
 
 
 
 
 
 
54
  /* @var $listObject Bronto_Api_List */
55
  $listObject = $api->getListObject();
56
  foreach ($listObject->readAll()->iterate() as $list/* @var $list Bronto_Api_List_Row */) {
@@ -75,7 +88,9 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
75
 
76
  /**
77
  * Convert Magento Newsletter Subscriber Status to Bronto API Contact Status
 
78
  * @param Mage_Newsletter_Model_Subscriber $subscriber
 
79
  * @return boolean
80
  */
81
  public function getQueueStatus(Mage_Newsletter_Model_Subscriber $subscriber)
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
8
  {
26
  }
27
 
28
  /**
29
+ * Get Array of Bronto Subscriber List IDs
30
+ *
31
+ * @param null $store
32
+ *
33
+ * @return array|mixed
34
  */
35
  public function getListIds($store = null)
36
  {
48
 
49
  /**
50
  * Get the list object from list id
51
+ *
52
+ * @param int $listId
53
+ * @param mixed $store (Optional)
54
+ *
55
  * @return boolean|Bronto_Api_List_Row
56
  */
57
+ public function getListData($listId, $store = null)
58
  {
59
+ if (is_null($store)) {
60
+ $scope = 'default';
61
+ $scopeId = 0;
62
+ } else {
63
+ $scope = 'store';
64
+ $scopeId = $store;
65
+ }
66
+ if ($api = $this->getApi(null, $scope, $scopeId)) {
67
  /* @var $listObject Bronto_Api_List */
68
  $listObject = $api->getListObject();
69
  foreach ($listObject->readAll()->iterate() as $list/* @var $list Bronto_Api_List_Row */) {
88
 
89
  /**
90
  * Convert Magento Newsletter Subscriber Status to Bronto API Contact Status
91
+ *
92
  * @param Mage_Newsletter_Model_Subscriber $subscriber
93
+ *
94
  * @return boolean
95
  */
96
  public function getQueueStatus(Mage_Newsletter_Model_Subscriber $subscriber)
app/code/community/Bronto/Newsletter/Helper/Data.php CHANGED
@@ -3,29 +3,57 @@
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
9
  {
10
- const XML_PATH_ENABLED = 'bronto_newsletter/settings/enabled';
11
- const XML_PATH_LIMIT = 'bronto_newsletter/settings/limit';
12
- const XML_PATH_SYNC_LIMIT = 'bronto_newsletter/settings/sync_limit';
13
- const XML_PATH_DEFAULT = 'bronto_newsletter/checkout/default_checked';
14
- const XML_PATH_SHOW_GUEST = 'bronto_newsletter/checkout/show_to_guests';
15
- const XML_PATH_SHOW_REGISTRAR = 'bronto_newsletter/checkout/show_to_registrars';
 
 
16
  const XML_PATH_SHOW_SUBSCRIBED = 'bronto_newsletter/checkout/show_if_subscribed';
17
- const XML_PATH_LABEL_TEXT = 'bronto_newsletter/checkout/label_text';
18
- const XML_PATH_USE_CUSTOM_TEMPLATE = 'bronto_newsletter/checkout/use_custom_template';
19
- const XML_PATH_BILLING_TEMPLATE = 'bronto_newsletter/checkout/billing_template';
20
- const XML_PATH_INSTALL_DATE = 'bronto_newsletter/settings/install_date';
21
- const XML_PATH_UPGRADE_DATE = 'bronto_newsletter/settings/upgrade_date';
 
 
 
 
 
 
22
 
23
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  * @return bool
25
  */
26
- public function isEnabled()
27
  {
28
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED);
 
 
 
 
 
 
29
  }
30
 
31
  /*
@@ -35,7 +63,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
35
  */
36
  public function getModuleEnabledText()
37
  {
38
- $message = parent::getModuleEnabledText();
39
  $scopeData = $this->getScopeParams();
40
  if ($scopeData['scope'] != 'default') {
41
  $message = $this->__(
@@ -44,16 +72,22 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
44
  'group on this page and select the desired list(s).'
45
  );
46
  }
 
47
  return $message;
48
  }
49
 
50
  /**
51
- * @param string $path
 
 
 
 
 
52
  * @return bool
53
  */
54
- public function disableModule($scope = 'default', $scopeId = 0)
55
  {
56
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
57
  }
58
 
59
  /**
@@ -65,15 +99,42 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
65
  }
66
 
67
  /**
 
 
 
 
 
68
  * @return int
69
  */
70
- public function getLimit($storeId = null)
71
  {
72
- if (!$this->isEnabled()) {
73
- return false;
74
- }
75
 
76
- return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $storeId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
  /**
@@ -84,6 +145,14 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
84
  return (bool)$this->getAdminScopedConfig(self::XML_PATH_DEFAULT);
85
  }
86
 
 
 
 
 
 
 
 
 
87
  /**
88
  * @return bool
89
  */
@@ -118,6 +187,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
118
 
119
  /**
120
  * @param Mage_Customer_Model_Customer $customer
 
121
  * @return boolean
122
  */
123
  public function isCustomerSubscribed(Mage_Customer_Model_Customer $customer = null)
@@ -128,6 +198,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
128
 
129
  /* @var $subscriber Mage_Newsletter_Model_Subscriber */
130
  $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
 
131
  return (bool)$subscriber->isSubscribed();
132
  }
133
 
@@ -143,6 +214,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
143
 
144
  /**
145
  * Get Count of Subscribers not in queue
 
146
  * @return int
147
  */
148
  public function getMissingSubscribersCount()
@@ -153,6 +225,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
153
 
154
  /**
155
  * Get Subscribers which aren't in queue
 
156
  * @return array
157
  */
158
  public function getMissingSubscribers()
3
  /**
4
  * @package Newsletter
5
  * @copyright 2011-2012 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
8
  {
9
+ const XML_PATH_ENABLED = 'bronto_newsletter/settings/enabled';
10
+ const XML_PATH_MAGE_CRON = 'bronto_newsletter/settings/mage_cron';
11
+ const XML_PATH_LIMIT = 'bronto_newsletter/settings/limit';
12
+ const XML_PATH_SYNC_LIMIT = 'bronto_newsletter/settings/sync_limit';
13
+ const XML_PATH_DEFAULT = 'bronto_newsletter/checkout/default_checked';
14
+ const XML_PATH_SHOW_LOGGEDIN = 'bronto_newsletter/checkout/show_to_loggedin';
15
+ const XML_PATH_SHOW_GUEST = 'bronto_newsletter/checkout/show_to_guests';
16
+ const XML_PATH_SHOW_REGISTRAR = 'bronto_newsletter/checkout/show_to_registrars';
17
  const XML_PATH_SHOW_SUBSCRIBED = 'bronto_newsletter/checkout/show_if_subscribed';
18
+ const XML_PATH_LABEL_TEXT = 'bronto_newsletter/checkout/label_text';
19
+ const XML_PATH_INSTALL_DATE = 'bronto_newsletter/settings/install_date';
20
+ const XML_PATH_UPGRADE_DATE = 'bronto_newsletter/settings/upgrade_date';
21
+
22
+ const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_newsletter_import/schedule/cron_expr';
23
+ const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_newsletter_import/run/model';
24
+
25
+ /**
26
+ * Module Human Readable Name
27
+ */
28
+ protected $_name = 'Bronto Newsletter Subscription';
29
 
30
  /**
31
+ * Get Human Readable Name
32
+ *
33
+ * @return string
34
+ */
35
+ public function getName()
36
+ {
37
+ return $this->__($this->_name);
38
+ }
39
+
40
+ /**
41
+ * Check if module is enabled
42
+ *
43
+ * @param string $scope
44
+ * @param int $scopeId
45
+ *
46
  * @return bool
47
  */
48
+ public function isEnabled($scope = 'default', $scopeId = 0)
49
  {
50
+ // Check if valid token is present
51
+ if (!$this->validApiToken(null, $scope, $scopeId)) {
52
+ return false;
53
+ }
54
+
55
+ // Get Enabled Scope
56
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
57
  }
58
 
59
  /*
63
  */
64
  public function getModuleEnabledText()
65
  {
66
+ $message = parent::getModuleEnabledText();
67
  $scopeData = $this->getScopeParams();
68
  if ($scopeData['scope'] != 'default') {
69
  $message = $this->__(
72
  'group on this page and select the desired list(s).'
73
  );
74
  }
75
+
76
  return $message;
77
  }
78
 
79
  /**
80
+ * Disable Specified Module
81
+ *
82
+ * @param string $scope
83
+ * @param int $scopeId
84
+ * @param bool $deleteConfig
85
+ *
86
  * @return bool
87
  */
88
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
89
  {
90
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
91
  }
92
 
93
  /**
99
  }
100
 
101
  /**
102
+ * Get import limit from config
103
+ *
104
+ * @param string $scope
105
+ * @param int $scopeId
106
+ *
107
  * @return int
108
  */
109
+ public function getLimit($scope = 'default', $scopeId = 0)
110
  {
111
+ return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $scope, $scopeId);
112
+ }
 
113
 
114
+ /**
115
+ * Check if module can use the magento cron
116
+ *
117
+ * @return bool
118
+ */
119
+ public function canUseMageCron()
120
+ {
121
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
122
+ }
123
+
124
+ /**
125
+ * @return string
126
+ */
127
+ public function getCronStringPath()
128
+ {
129
+ return self::XML_PATH_CRON_STRING;
130
+ }
131
+
132
+ /**
133
+ * @return string
134
+ */
135
+ public function getCronModelPath()
136
+ {
137
+ return self::XML_PATH_CRON_MODEL;
138
  }
139
 
140
  /**
145
  return (bool)$this->getAdminScopedConfig(self::XML_PATH_DEFAULT);
146
  }
147
 
148
+ /**
149
+ * @return bool
150
+ */
151
+ public function isEnabledForLoggedinCheckout()
152
+ {
153
+ return (bool)Mage::getStoreConfig(self::XML_PATH_SHOW_LOGGEDIN);
154
+ }
155
+
156
  /**
157
  * @return bool
158
  */
187
 
188
  /**
189
  * @param Mage_Customer_Model_Customer $customer
190
+ *
191
  * @return boolean
192
  */
193
  public function isCustomerSubscribed(Mage_Customer_Model_Customer $customer = null)
198
 
199
  /* @var $subscriber Mage_Newsletter_Model_Subscriber */
200
  $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
201
+
202
  return (bool)$subscriber->isSubscribed();
203
  }
204
 
214
 
215
  /**
216
  * Get Count of Subscribers not in queue
217
+ *
218
  * @return int
219
  */
220
  public function getMissingSubscribersCount()
225
 
226
  /**
227
  * Get Subscribers which aren't in queue
228
+ *
229
  * @return array
230
  */
231
  public function getMissingSubscribers()
app/code/community/Bronto/Newsletter/Model/Mysql4/Queue.php CHANGED
@@ -1,25 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * Short description for file
5
- *
6
- * Long description (if any) ...
7
- *
8
- * PHP version 5
9
- *
10
- * The license text...
11
- *
12
- * @category Bronto
13
- * @package Newsletter
14
- * @author Jeff Lambert <jeff.lambert@atlanticbt.com>
15
- * @copyright 2012 Atlantic BT
16
- * @license http://www.atlanticbt.com/ Atlantic BT
17
- * @version CVS: $Id:$
18
- * @link <>
19
- * @see References to other sections (if any)...
20
- */
21
- /**
22
- * @author Jeff Lambert <jeff.lambert@atlanticbt.com>
23
  */
24
  class Bronto_Newsletter_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
25
  {
@@ -45,7 +28,8 @@ class Bronto_Newsletter_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstra
45
 
46
  /**
47
  * Get Write adapter instance
48
- * @return type
 
49
  */
50
  public function getWriteAdapter()
51
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Newsletter
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  */
7
  class Bronto_Newsletter_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
8
  {
28
 
29
  /**
30
  * Get Write adapter instance
31
+ *
32
+ * @return Varien_Db_Adapter_Interface
33
  */
34
  public function getWriteAdapter()
35
  {
app/code/community/Bronto/Newsletter/Model/Mysql4/Queue/Collection.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Model_Mysql4_Queue_Collection
9
  extends Mage_Core_Model_Mysql4_Collection_Abstract
@@ -29,6 +28,7 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
29
  public function addBrontoImportedFilter()
30
  {
31
  $this->addFieldToFilter('imported', array('eq' => '1'));
 
32
  return $this;
33
  }
34
 
@@ -38,6 +38,7 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
38
  public function addBrontoSuppressedFilter()
39
  {
40
  $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
 
41
  return $this;
42
  }
43
 
@@ -47,6 +48,7 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
47
  public function addBrontoNotSuppressedFilter()
48
  {
49
  $this->addFieldToFilter('bronto_suppressed', array('null' => true));
 
50
  return $this;
51
  }
52
 
@@ -56,11 +58,13 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
56
  public function addBrontoNotImportedFilter()
57
  {
58
  $this->addFieldToFilter('imported', array('neq' => '1'));
 
59
  return $this;
60
  }
61
 
62
  /**
63
  * @param mixed $storeIds (null, int|string, array, array may contain null)
 
64
  * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
65
  */
66
  public function addStoreFilter($storeIds)
@@ -86,4 +90,32 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
86
 
87
  return $this;
88
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Model_Mysql4_Queue_Collection
8
  extends Mage_Core_Model_Mysql4_Collection_Abstract
28
  public function addBrontoImportedFilter()
29
  {
30
  $this->addFieldToFilter('imported', array('eq' => '1'));
31
+
32
  return $this;
33
  }
34
 
38
  public function addBrontoSuppressedFilter()
39
  {
40
  $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
41
+
42
  return $this;
43
  }
44
 
48
  public function addBrontoNotSuppressedFilter()
49
  {
50
  $this->addFieldToFilter('bronto_suppressed', array('null' => true));
51
+
52
  return $this;
53
  }
54
 
58
  public function addBrontoNotImportedFilter()
59
  {
60
  $this->addFieldToFilter('imported', array('neq' => '1'));
61
+
62
  return $this;
63
  }
64
 
65
  /**
66
  * @param mixed $storeIds (null, int|string, array, array may contain null)
67
+ *
68
  * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
69
  */
70
  public function addStoreFilter($storeIds)
90
 
91
  return $this;
92
  }
93
+
94
+ /**
95
+ * Sort order by order created_at date
96
+ *
97
+ * @param string $dir
98
+ *
99
+ * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
100
+ */
101
+ public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
102
+ {
103
+ $this->getSelect()->order("created_at $dir");
104
+
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * Sort order by order updated_at date
110
+ *
111
+ * @param string $dir
112
+ *
113
+ * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
114
+ */
115
+ public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
116
+ {
117
+ $this->getSelect()->order("updated_at $dir");
118
+
119
+ return $this;
120
+ }
121
  }
app/code/community/Bronto/Newsletter/Model/Observer.php CHANGED
@@ -3,23 +3,22 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Model_Observer
9
  extends Mage_Core_Model_Abstract
10
  {
11
 
12
- const NOTICE_IDENTIFER = 'bronto_newsletter';
13
- const BOX_UNCHECKED = 0;
14
- const BOX_CHECKED = 1;
15
- const BOX_NOT_CHANGED = 2;
16
 
17
  private $_helper;
18
 
19
  public function __construct()
20
  {
21
  /* @var $_helper Bronto_Newsletter_Helper_Data */
22
- $this->_helper = Mage::helper(self::NOTICE_IDENTIFER);
23
  }
24
 
25
  /**
@@ -34,54 +33,11 @@ class Bronto_Newsletter_Model_Observer
34
  }
35
 
36
  // Verify Requirements
37
- if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
38
  return;
39
  }
40
  }
41
 
42
- /**
43
- * Observes module becoming enabled and displays message warning user to configure settings
44
- * @param Varien_Event_Observer $observer
45
- */
46
- public function watchEnableAction(Varien_Event_Observer $observer)
47
- {
48
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_newsletter')->__(Mage::helper('bronto_newsletter')->getModuleEnabledText()));
49
- }
50
-
51
- /**
52
- * This event fires when customer continues past the Billing Info step
53
- * on the onepage checkout. We set a flag here in the session to avoid
54
- * actually doing anything until checkout is complete.
55
- *
56
- * @param Varien_Event_Observer $observer
57
- */
58
- public function setSubscriptionAtBillingStep(Varien_Event_Observer $observer)
59
- {
60
- if (!$this->_helper->isEnabled()) {
61
- return;
62
- }
63
-
64
- $controllerAction = $observer->getControllerAction();
65
- if ($controllerAction instanceof Mage_Checkout_OnepageController) {
66
- Mage::getSingleton('checkout/session')->unsIsSubscribed();
67
- $params = Mage::app()->getRequest()->getParams();
68
-
69
- if (
70
- isset($params['billing']['is_subscribed']) &&
71
- ($params['billing']['is_subscribed'] === '1' ||
72
- $params['billing']['is_subscribed'] === '0')
73
- ) {
74
- $isSubscribed = (int) $params['billing']['is_subscribed'];
75
- Mage::getSingleton('checkout/session')->setIsSubscribed($isSubscribed);
76
- }
77
- else {
78
- Mage::getSingleton('checkout/session')->setIsSubscribed(self::BOX_NOT_CHANGED);
79
- }
80
- }
81
-
82
- return $observer;
83
- }
84
-
85
  /**
86
  * Get Bronto Contact Row via Email address
87
  *
@@ -95,16 +51,15 @@ class Bronto_Newsletter_Model_Observer
95
  /* @var $contact Bronto_Api_Contact_Row */
96
  $contact = Mage::helper('bronto_newsletter/contact')->getContactByEmail(
97
  $email,
98
- NULL,
99
  Mage::app()->getStore()->getId()
100
  );
101
 
102
  return $contact;
103
- }
104
- catch (Exception $e) {
105
  $this->_helper->writeError($e);
106
 
107
- return FALSE;
108
  }
109
  }
110
 
@@ -118,15 +73,14 @@ class Bronto_Newsletter_Model_Observer
118
  public function handleSubscriptionAtCheckout(Varien_Event_Observer $observer)
119
  {
120
  if (!$this->_helper->isEnabled()) {
121
- return;
122
  }
123
 
124
  // Get Subscription status from session
125
  $isSubscribed = Mage::getSingleton('checkout/session')->getIsSubscribed();
126
-
127
- // If Subscription status isn't set, we do nothing
128
- if (!is_int($isSubscribed)) {
129
- return $observer;
130
  }
131
 
132
  try {
@@ -134,54 +88,40 @@ class Bronto_Newsletter_Model_Observer
134
  $email = $observer->getEvent()->getOrder()->getData('customer_email');
135
 
136
  if (empty($email)) {
137
- $this->_helper->writeError('No customer_email was provided.');
138
 
139
- return FALSE;
140
  }
141
 
142
  /* @var $subscriber Mage_Newsletter_Model_Subscriber */
143
  if (!$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email)) {
144
  $this->_helper->writeError('Unable to create subscriber object');
145
 
146
- return FALSE;
147
  }
148
 
149
  /* @var $contact Bronto_Api_Contact_Row */
150
  if (!$contact = $this->_getBrontoContact($email)) {
151
  $this->_helper->writeError('Unable to create contact object');
152
 
153
- return FALSE;
154
  }
155
 
156
  // Determine action
157
  switch ($isSubscribed) {
158
- case self::BOX_CHECKED:
159
- // Subscribe the Customer
160
- if (!$subscriber->isSubscribed()) {
161
- return $subscriber->subscribe($email);
162
- }
163
  break;
164
- case self::BOX_UNCHECKED:
165
- // Unsubscribe the Customer if subscribed, Make Transactional if not in bronto
166
- if ($subscriber->isSubscribed()) {
167
- return $subscriber->unsubscribe();
168
- }
169
- elseif (!$contact->id && !$subscriber->isSubscribed()) {
170
- $this->_makeTransactional($subscriber, $email);
171
- }
172
- break;
173
- case self::BOX_NOT_CHANGED:
174
- // Make Customer Transactional if not in bronto
175
- if (!$contact->id && !$subscriber->isSubscribed()) {
176
- $this->_makeTransactional($subscriber, $email);
177
- }
178
  break;
 
179
  default:
180
- // Intentionally blank
181
  break;
182
  }
183
- }
184
- catch (Exception $e) {
185
  $this->_helper->writeError($e);
186
  }
187
 
@@ -203,27 +143,29 @@ class Bronto_Newsletter_Model_Observer
203
  if (!$contact = $this->_getBrontoContact($email)) {
204
  $this->_helper->writeError('Unable to create contact object');
205
 
206
- return FALSE;
207
  }
208
 
209
  // Get Customer using the email provided
210
- $ownerId = Mage::getModel('customer/customer')
211
- ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
212
- ->loadByEmail($email)
213
- ->getId();
214
 
215
- if (!$ownerId) {
216
- $ownerId = Mage::getSingleton('customer/session')->getId();
217
  }
218
 
219
  // Set Magento Subscriber and Status
220
- $subscriber->setCustomerId($ownerId);
221
- $subscriber->setSubscriberEmail($email);
222
- $subscriber->setStoreId(Mage::app()->getStore()->getId());
 
 
 
223
  if ($contact->status == Bronto_Api_Contact::STATUS_UNSUBSCRIBED) {
224
  $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
225
- }
226
- else {
227
  $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
228
  }
229
 
@@ -233,12 +175,16 @@ class Bronto_Newsletter_Model_Observer
233
  }
234
 
235
  /**
 
 
236
  * @param Varien_Event_Observer $observer
 
 
237
  */
238
  public function updateBrontoFromNewsletterStatus(Varien_Event_Observer $observer)
239
  {
240
  if (!$this->_helper->isEnabled()) {
241
- return;
242
  }
243
 
244
  // Insert contact email into queuing table. Cron will
@@ -248,15 +194,16 @@ class Bronto_Newsletter_Model_Observer
248
  if (!$subscriber = $observer->getEvent()->getSubscriber()) {
249
  $this->_helper->writeError('Unable to create subscriber object');
250
 
251
- return FALSE;
252
  }
253
 
254
  // Send to queue
255
  $this->_saveToQueue($subscriber, Mage::app()->getStore()->getId());
256
- }
257
- catch (Exception $e) {
258
  $this->_helper->writeError($e);
259
  }
 
 
260
  }
261
 
262
  /**
@@ -265,16 +212,16 @@ class Bronto_Newsletter_Model_Observer
265
  * @param Mage_Newsletter_Model_Subscriber $subscriber
266
  * @param int $storeId
267
  *
268
- * @return void
269
  */
270
- private function _saveToQueue($subscriber, $storeId)
271
  {
272
  // Get e-mail address we are working with
273
  $email = $subscriber->getEmail();
274
  if (empty($email)) {
275
  $this->_helper->writeError('Subscriber does not have an email address.');
276
 
277
- return FALSE;
278
  }
279
 
280
  // Get Calculated Status
@@ -282,23 +229,29 @@ class Bronto_Newsletter_Model_Observer
282
 
283
  /* @var $contactQueue Bronto_Newsletter_Model_Queue */
284
  $contactQueue = Mage::getModel('bronto_newsletter/queue')
285
- ->getContactRow($subscriber->getId(), $storeId);
286
 
287
  // If ContactQueue status doesn't match subscriber status, replace it
288
  if ($status != $contactQueue->getStatus()) {
289
  $contactQueue->setSubscriberEmail($subscriber->getEmail())
290
- ->setStatus($status)
291
- ->setMessagePreference('html')
292
- ->setSource('api')
293
- ->setImported(0)
294
- ->save();
 
295
  }
 
 
296
  }
297
 
298
  /**
299
- * @param int $storeId
300
  *
301
- * @return array
 
 
 
302
  */
303
  public function processSubscribersForStore($storeId, $limit)
304
  {
@@ -312,11 +265,11 @@ class Bronto_Newsletter_Model_Observer
312
  return $result;
313
  }
314
 
315
- if (is_object($storeId)) {
 
316
  $store = $storeId;
317
  $storeId = $store->getId();
318
- }
319
- else {
320
  $store = Mage::app()->getStore($storeId);
321
  $storeId = $store->getId();
322
  }
@@ -326,7 +279,7 @@ class Bronto_Newsletter_Model_Observer
326
  if (!$store->getConfig(Bronto_Newsletter_Helper_Data::XML_PATH_ENABLED)) {
327
  $this->_helper->writeDebug(' Module disabled for this store. Skipping...');
328
 
329
- return FALSE;
330
  }
331
 
332
  $helper = Mage::helper('bronto_newsletter/contact');
@@ -336,24 +289,31 @@ class Bronto_Newsletter_Model_Observer
336
  // Get Subscriber Queue for store
337
  /* var $subscribers Bronto_Newsletter_Model_Mysql4_Queue_Collection */
338
  $subscribers = Mage::getModel('bronto_newsletter/queue')
339
- ->getCollection()
340
- ->addBrontoNotImportedFilter()
341
- ->addBrontoNotSuppressedFilter()
342
- ->addStoreFilter($storeId)
343
- ->setPageSize($limit)
344
- ->getItems();
 
345
 
346
  foreach ($subscribers as $subscriber) {
347
  try {
348
  /* @var $contact Bronto_Api_Contact_Row */
349
- $contact = $helper->getContactByEmail($subscriber->getSubscriberEmail(), NULL, $storeId);
 
 
 
 
 
 
 
350
 
351
  // Get List Details
352
  foreach ($lists as $listId) {
353
- if ($list = $helper->getListData($listId)) {
354
  $listName = $list->label;
355
- }
356
- else {
357
  Mage::throwException(
358
  "The list ({$listId}) was not found. This may indicate that it does not exist. Try re-saving the config"
359
  );
@@ -411,8 +371,7 @@ class Bronto_Newsletter_Model_Observer
411
  $subscriber->setImported(1)->save();
412
 
413
  $result['success']++;
414
- }
415
- catch (Exception $e) {
416
  // 315 means contact on suppression list, so suppress
417
  if (315 == $e->getCode()) {
418
  $subscriber->setBrontoSuppressed($e->getMessage());
@@ -431,9 +390,13 @@ class Bronto_Newsletter_Model_Observer
431
  }
432
 
433
  /**
 
 
 
 
434
  * @return array
435
  */
436
- public function processSubscribers()
437
  {
438
  $result = array(
439
  'total' => 0,
@@ -441,18 +404,21 @@ class Bronto_Newsletter_Model_Observer
441
  'error' => 0,
442
  );
443
 
444
- $limit = $this->_helper->getLimit();
 
 
445
 
446
- $stores = Mage::app()->getStores(TRUE);
447
- foreach ($stores as $_store) {
448
- if ($limit <= 0) {
449
- continue;
 
 
 
 
 
 
450
  }
451
- $storeResult = $this->processSubscribersForStore($_store, $limit);
452
- $result['total'] += $storeResult['total'];
453
- $result['success'] += $storeResult['success'];
454
- $result['error'] += $storeResult['error'];
455
- $limit = $limit - $storeResult['total'];
456
  }
457
 
458
  return $result;
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Model_Observer
8
  extends Mage_Core_Model_Abstract
9
  {
10
 
11
+ const NOTICE_IDENTIFIER = 'bronto_newsletter';
12
+ const BOX_UNCHECKED = 0;
13
+ const BOX_CHECKED = 1;
14
+ const BOX_NOT_CHANGED = 2;
15
 
16
  private $_helper;
17
 
18
  public function __construct()
19
  {
20
  /* @var $_helper Bronto_Newsletter_Helper_Data */
21
+ $this->_helper = Mage::helper(self::NOTICE_IDENTIFIER);
22
  }
23
 
24
  /**
33
  }
34
 
35
  // Verify Requirements
36
+ if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
37
  return;
38
  }
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  /**
42
  * Get Bronto Contact Row via Email address
43
  *
51
  /* @var $contact Bronto_Api_Contact_Row */
52
  $contact = Mage::helper('bronto_newsletter/contact')->getContactByEmail(
53
  $email,
54
+ null,
55
  Mage::app()->getStore()->getId()
56
  );
57
 
58
  return $contact;
59
+ } catch (Exception $e) {
 
60
  $this->_helper->writeError($e);
61
 
62
+ return false;
63
  }
64
  }
65
 
73
  public function handleSubscriptionAtCheckout(Varien_Event_Observer $observer)
74
  {
75
  if (!$this->_helper->isEnabled()) {
76
+ return false;
77
  }
78
 
79
  // Get Subscription status from session
80
  $isSubscribed = Mage::getSingleton('checkout/session')->getIsSubscribed();
81
+ if (empty($isSubscribed)) {
82
+ $this->_helper->writeDebug('No subscription status found in session.');
83
+ return false;
 
84
  }
85
 
86
  try {
88
  $email = $observer->getEvent()->getOrder()->getData('customer_email');
89
 
90
  if (empty($email)) {
91
+ $this->_helper->writeError('No customer email was provided.');
92
 
93
+ return false;
94
  }
95
 
96
  /* @var $subscriber Mage_Newsletter_Model_Subscriber */
97
  if (!$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email)) {
98
  $this->_helper->writeError('Unable to create subscriber object');
99
 
100
+ return false;
101
  }
102
 
103
  /* @var $contact Bronto_Api_Contact_Row */
104
  if (!$contact = $this->_getBrontoContact($email)) {
105
  $this->_helper->writeError('Unable to create contact object');
106
 
107
+ return false;
108
  }
109
 
110
  // Determine action
111
  switch ($isSubscribed) {
112
+ case Bronto_Api_Contact::STATUS_ACTIVE:
113
+ case Bronto_Api_Contact::STATUS_ONBOARDING:
114
+ return $subscriber->subscribe($email);
 
 
115
  break;
116
+ case Bronto_Api_Contact::STATUS_UNSUBSCRIBED:
117
+ return $subscriber->unsubscribe();
 
 
 
 
 
 
 
 
 
 
 
 
118
  break;
119
+ case Bronto_Api_Contact::STATUS_TRANSACTIONAL:
120
  default:
121
+ $this->_makeTransactional($subscriber, $email);
122
  break;
123
  }
124
+ } catch (Exception $e) {
 
125
  $this->_helper->writeError($e);
126
  }
127
 
143
  if (!$contact = $this->_getBrontoContact($email)) {
144
  $this->_helper->writeError('Unable to create contact object');
145
 
146
+ return false;
147
  }
148
 
149
  // Get Customer using the email provided
150
+ $customerId = Mage::getModel('customer/customer')
151
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
152
+ ->loadByEmail($email)
153
+ ->getId();
154
 
155
+ if (!$customerId) {
156
+ $customerId = Mage::getSingleton('customer/session')->getId();
157
  }
158
 
159
  // Set Magento Subscriber and Status
160
+ $subscriber->setCustomerId($customerId)
161
+ ->setSubscriberEmail($email)
162
+ ->setStoreId(Mage::app()->getStore()->getId())
163
+ ->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE)
164
+ ->save();
165
+
166
  if ($contact->status == Bronto_Api_Contact::STATUS_UNSUBSCRIBED) {
167
  $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
168
+ } else {
 
169
  $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
170
  }
171
 
175
  }
176
 
177
  /**
178
+ * Update Bronto from Magento Subscriber Status
179
+ *
180
  * @param Varien_Event_Observer $observer
181
+ *
182
+ * @return $this|bool
183
  */
184
  public function updateBrontoFromNewsletterStatus(Varien_Event_Observer $observer)
185
  {
186
  if (!$this->_helper->isEnabled()) {
187
+ return false;
188
  }
189
 
190
  // Insert contact email into queuing table. Cron will
194
  if (!$subscriber = $observer->getEvent()->getSubscriber()) {
195
  $this->_helper->writeError('Unable to create subscriber object');
196
 
197
+ return false;
198
  }
199
 
200
  // Send to queue
201
  $this->_saveToQueue($subscriber, Mage::app()->getStore()->getId());
202
+ } catch (Exception $e) {
 
203
  $this->_helper->writeError($e);
204
  }
205
+
206
+ return $this;
207
  }
208
 
209
  /**
212
  * @param Mage_Newsletter_Model_Subscriber $subscriber
213
  * @param int $storeId
214
  *
215
+ * @return $this|bool
216
  */
217
+ private function _saveToQueue(Mage_Newsletter_Model_Subscriber $subscriber, $storeId)
218
  {
219
  // Get e-mail address we are working with
220
  $email = $subscriber->getEmail();
221
  if (empty($email)) {
222
  $this->_helper->writeError('Subscriber does not have an email address.');
223
 
224
+ return false;
225
  }
226
 
227
  // Get Calculated Status
229
 
230
  /* @var $contactQueue Bronto_Newsletter_Model_Queue */
231
  $contactQueue = Mage::getModel('bronto_newsletter/queue')
232
+ ->getContactRow($subscriber->getId(), $storeId);
233
 
234
  // If ContactQueue status doesn't match subscriber status, replace it
235
  if ($status != $contactQueue->getStatus()) {
236
  $contactQueue->setSubscriberEmail($subscriber->getEmail())
237
+ ->setStatus($status)
238
+ ->setMessagePreference('html')
239
+ ->setSource('api')
240
+ ->setImported(0)
241
+ ->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
242
+ ->save();
243
  }
244
+
245
+ return $this;
246
  }
247
 
248
  /**
249
+ * Process all queued subscribers for the specified store and import them into Bronto
250
  *
251
+ * @param string|int $storeId
252
+ * @param int $limit
253
+ *
254
+ * @return array|bool
255
  */
256
  public function processSubscribersForStore($storeId, $limit)
257
  {
265
  return $result;
266
  }
267
 
268
+ // Set Store and StoreId
269
+ if ($storeId instanceof Mage_Core_Model_Store) {
270
  $store = $storeId;
271
  $storeId = $store->getId();
272
+ } else {
 
273
  $store = Mage::app()->getStore($storeId);
274
  $storeId = $store->getId();
275
  }
279
  if (!$store->getConfig(Bronto_Newsletter_Helper_Data::XML_PATH_ENABLED)) {
280
  $this->_helper->writeDebug(' Module disabled for this store. Skipping...');
281
 
282
+ return false;
283
  }
284
 
285
  $helper = Mage::helper('bronto_newsletter/contact');
289
  // Get Subscriber Queue for store
290
  /* var $subscribers Bronto_Newsletter_Model_Mysql4_Queue_Collection */
291
  $subscribers = Mage::getModel('bronto_newsletter/queue')
292
+ ->getCollection()
293
+ ->addBrontoNotImportedFilter()
294
+ ->addBrontoNotSuppressedFilter()
295
+ ->orderByUpdatedAt()
296
+ ->addStoreFilter($storeId)
297
+ ->setPageSize($limit)
298
+ ->getItems();
299
 
300
  foreach ($subscribers as $subscriber) {
301
  try {
302
  /* @var $contact Bronto_Api_Contact_Row */
303
+ $contact = $helper->getContactByEmail($subscriber->getSubscriberEmail(), null, $storeId);
304
+
305
+ // If Contact returns false, handle it.
306
+ if (!$contact) {
307
+ $noContactMessage = 'Could not load contact because email address was empty: ' . var_export($subscriber->getData(), true);
308
+ $subscriber->setBrontoSuppressed($noContactMessage)->save();
309
+ Mage::throwException($noContactMessage);
310
+ }
311
 
312
  // Get List Details
313
  foreach ($lists as $listId) {
314
+ if ($list = $helper->getListData($listId, $storeId)) {
315
  $listName = $list->label;
316
+ } else {
 
317
  Mage::throwException(
318
  "The list ({$listId}) was not found. This may indicate that it does not exist. Try re-saving the config"
319
  );
371
  $subscriber->setImported(1)->save();
372
 
373
  $result['success']++;
374
+ } catch (Exception $e) {
 
375
  // 315 means contact on suppression list, so suppress
376
  if (315 == $e->getCode()) {
377
  $subscriber->setBrontoSuppressed($e->getMessage());
390
  }
391
 
392
  /**
393
+ * Process queued subscribers
394
+ *
395
+ * @param bool $brontoCron
396
+ *
397
  * @return array
398
  */
399
+ public function processSubscribers($brontoCron = false)
400
  {
401
  $result = array(
402
  'total' => 0,
404
  'error' => 0,
405
  );
406
 
407
+ // Only allow cron to run if isset to use mage cron or is coming from bronto cron
408
+ if (Mage::helper('bronto_newsletter')->canUseMageCron() || $brontoCron) {
409
+ $limit = $this->_helper->getLimit();
410
 
411
+ $stores = Mage::app()->getStores(true);
412
+ foreach ($stores as $_store) {
413
+ if ($limit <= 0) {
414
+ continue;
415
+ }
416
+ $storeResult = $this->processSubscribersForStore($_store, $limit);
417
+ $result['total'] += $storeResult['total'];
418
+ $result['success'] += $storeResult['success'];
419
+ $result['error'] += $storeResult['error'];
420
+ $limit = $limit - $storeResult['total'];
421
  }
 
 
 
 
 
422
  }
423
 
424
  return $result;
app/code/community/Bronto/Newsletter/Model/Queue.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.3.5
7
  */
8
  class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
9
  {
@@ -32,6 +31,7 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
32
  return $collection->getFirstItem();
33
  } else {
34
  $this->setSubscriberId($subscriber_id)
 
35
  ->setStore($store_id);
36
  }
37
 
@@ -40,13 +40,14 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
40
 
41
  /**
42
  * Get Count of missing subscribers
 
43
  * @return int
44
  */
45
  public function getMissingSubscribersCount()
46
  {
47
  // Get Resources
48
  $resource = $this->getResource();
49
- $adapter = $resource->getWriteAdapter();
50
 
51
  // Build Select Statement
52
  $select = $adapter->select();
@@ -59,7 +60,7 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
59
  $result = $adapter->query($select)->fetch();
60
 
61
  if (array_key_exists('count', $result)) {
62
- return (int) $result['count'];
63
  } else {
64
  return 0;
65
  }
@@ -67,8 +68,10 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
67
 
68
  /**
69
  * Get Sub-Select Statement that limits results
 
70
  * @param Bronto_Newsletter_Model_Mysql4_Queue $resource
71
- * @param type $adapter
 
72
  * @return Varien_Db_Select
73
  */
74
  private function _getSubselect($resource, $adapter)
@@ -85,13 +88,14 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
85
 
86
  /**
87
  * Get collection of subscribers which aren't already in the queue, but should be
 
88
  * @return array
89
  */
90
  public function getMissingSubscribers()
91
  {
92
  // Get Resources
93
  $resource = $this->getResource();
94
- $adapter = $resource->getWriteAdapter();
95
 
96
  // Get Sync Limit Value
97
  $count = Mage::helper('bronto_newsletter')->getSyncLimit();
@@ -111,4 +115,4 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
111
  return $result;
112
  }
113
 
114
- }
3
  /**
4
  * @package Bronto\Newsletter
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
8
  {
31
  return $collection->getFirstItem();
32
  } else {
33
  $this->setSubscriberId($subscriber_id)
34
+ ->setCreatedAt(Mage::getSingleton('core/date')->gmtDate())
35
  ->setStore($store_id);
36
  }
37
 
40
 
41
  /**
42
  * Get Count of missing subscribers
43
+ *
44
  * @return int
45
  */
46
  public function getMissingSubscribersCount()
47
  {
48
  // Get Resources
49
  $resource = $this->getResource();
50
+ $adapter = $resource->getWriteAdapter();
51
 
52
  // Build Select Statement
53
  $select = $adapter->select();
60
  $result = $adapter->query($select)->fetch();
61
 
62
  if (array_key_exists('count', $result)) {
63
+ return (int)$result['count'];
64
  } else {
65
  return 0;
66
  }
68
 
69
  /**
70
  * Get Sub-Select Statement that limits results
71
+ *
72
  * @param Bronto_Newsletter_Model_Mysql4_Queue $resource
73
+ * @param $adapter
74
+ *
75
  * @return Varien_Db_Select
76
  */
77
  private function _getSubselect($resource, $adapter)
88
 
89
  /**
90
  * Get collection of subscribers which aren't already in the queue, but should be
91
+ *
92
  * @return array
93
  */
94
  public function getMissingSubscribers()
95
  {
96
  // Get Resources
97
  $resource = $this->getResource();
98
+ $adapter = $resource->getWriteAdapter();
99
 
100
  // Get Sync Limit Value
101
  $count = Mage::helper('bronto_newsletter')->getSyncLimit();
115
  return $result;
116
  }
117
 
118
+ }
app/code/community/Bronto/Newsletter/Model/System/Config/Backend/Cron.php CHANGED
@@ -8,4 +8,20 @@ class Bronto_Newsletter_Model_System_Config_Backend_Cron extends Bronto_Common_M
8
  {
9
  protected $_cron_string_path = 'crontab/jobs/bronto_newsletter_import/schedule/cron_expr';
10
  protected $_cron_model_path = 'crontab/jobs/bronto_newsletter_import/run/model';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
8
  {
9
  protected $_cron_string_path = 'crontab/jobs/bronto_newsletter_import/schedule/cron_expr';
10
  protected $_cron_model_path = 'crontab/jobs/bronto_newsletter_import/run/model';
11
+
12
+ /**
13
+ * @return string
14
+ */
15
+ public function getCronStringPath()
16
+ {
17
+ return Mage::helper('bronto_newsletter')->getCronStringPath();
18
+ }
19
+
20
+ /**
21
+ * @return string
22
+ */
23
+ public function getCronModelPath()
24
+ {
25
+ return Mage::helper('bronto_newsletter')->getCronModelPath();
26
+ }
27
  }
app/code/community/Bronto/Newsletter/controllers/Adminhtml/NewsletterController.php CHANGED
@@ -13,9 +13,9 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
13
  public function runAction()
14
  {
15
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
16
- $model = Mage::getModel('bronto_newsletter/observer');
17
  $helper = Mage::helper('bronto_newsletter');
18
- $limit = $helper->getLimit();
19
 
20
  try {
21
  if ($storeIds = $helper->getStoreIds()) {
@@ -33,7 +33,7 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
33
  $limit = $limit - $storeResult['total'];
34
  }
35
  } else {
36
- $result = $model->processSubscribers();
37
  }
38
 
39
  if (is_array($result)) {
@@ -56,19 +56,32 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
56
  */
57
  public function resetAction()
58
  {
59
- $helper = Mage::helper('bronto_newsletter');
60
  $resource = Mage::getResourceModel('bronto_newsletter/queue');
61
- $adapter = $resource->getWriteAdapter();
 
 
62
 
63
  try {
64
- $adapter->update(
65
- $resource->getTable('bronto_newsletter/queue'),
66
- array(
67
- 'imported' => 2,
68
- 'bronto_suppressed' => null,
69
- ),
70
- array('imported' => 1)
71
- );
 
 
 
 
 
 
 
 
 
 
 
72
  } catch (Exception $e) {
73
  $helper->writeError($e);
74
  $this->_getSession()->addError('Reset failed: ' . $e->getMessage());
@@ -84,12 +97,12 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
84
  */
85
  public function syncAction()
86
  {
87
- $helper = Mage::helper('bronto_newsletter');
88
  $imported = 0;
89
 
90
  try {
91
  $subscribers = $helper->getMissingSubscribers();
92
- $waiting = count($subscribers);
93
 
94
  if ($waiting > 0) {
95
  foreach ($subscribers as $subscriber) {
@@ -120,7 +133,7 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
120
  ->setMessagePreference('html')
121
  ->setSource('api')
122
  ->setImported(0)
123
- ->setBrontoSuppressed(NULL)
124
  ->save();
125
 
126
  $imported++;
@@ -138,6 +151,93 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
138
  $this->_redirect('*/system_config/edit', $returnParams);
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  /**
142
  * @return bool
143
  */
@@ -152,29 +252,35 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
152
  * Will forward to deniedAction(), if not allowed.
153
  *
154
  * @param string $section
 
155
  * @return bool
156
  */
157
  protected function _isSectionAllowed($section)
158
  {
159
  try {
160
- $session = Mage::getSingleton('admin/session');
161
  $resourceLookup = "admin/system/config/{$section}";
162
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
163
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
164
  if (!$session->isAllowed($resourceId)) {
165
  throw new Exception('');
166
  }
 
167
  return true;
168
  }
169
  } catch (Zend_Acl_Exception $e) {
170
  $this->norouteAction();
171
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
172
  return false;
173
  } catch (Exception $e) {
174
  $this->deniedAction();
175
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
176
  return false;
177
  }
 
 
178
  }
179
 
180
  }
13
  public function runAction()
14
  {
15
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
16
+ $model = Mage::getModel('bronto_newsletter/observer');
17
  $helper = Mage::helper('bronto_newsletter');
18
+ $limit = $helper->getLimit();
19
 
20
  try {
21
  if ($storeIds = $helper->getStoreIds()) {
33
  $limit = $limit - $storeResult['total'];
34
  }
35
  } else {
36
+ $result = $model->processSubscribers(true);
37
  }
38
 
39
  if (is_array($result)) {
56
  */
57
  public function resetAction()
58
  {
59
+ $helper = Mage::helper('bronto_newsletter');
60
  $resource = Mage::getResourceModel('bronto_newsletter/queue');
61
+ $adapter = $resource->getWriteAdapter();
62
+
63
+ $queue_id = $this->getRequest()->getParam('queue_id', false);
64
 
65
  try {
66
+ if ($queue_id) {
67
+ $adapter->update(
68
+ $resource->getTable('bronto_newsletter/queue'),
69
+ array(
70
+ 'imported' => null,
71
+ 'bronto_suppressed' => null,
72
+ ),
73
+ array('queue_id = ?' => $queue_id)
74
+ );
75
+ } else {
76
+ $adapter->update(
77
+ $resource->getTable('bronto_newsletter/queue'),
78
+ array(
79
+ 'imported' => 2,
80
+ 'bronto_suppressed' => null,
81
+ ),
82
+ array('imported' => 1)
83
+ );
84
+ }
85
  } catch (Exception $e) {
86
  $helper->writeError($e);
87
  $this->_getSession()->addError('Reset failed: ' . $e->getMessage());
97
  */
98
  public function syncAction()
99
  {
100
+ $helper = Mage::helper('bronto_newsletter');
101
  $imported = 0;
102
 
103
  try {
104
  $subscribers = $helper->getMissingSubscribers();
105
+ $waiting = count($subscribers);
106
 
107
  if ($waiting > 0) {
108
  foreach ($subscribers as $subscriber) {
133
  ->setMessagePreference('html')
134
  ->setSource('api')
135
  ->setImported(0)
136
+ ->setBrontoSuppressed(null)
137
  ->save();
138
 
139
  $imported++;
151
  $this->_redirect('*/system_config/edit', $returnParams);
152
  }
153
 
154
+ /**
155
+ * Action to handle providing suppression table in config page
156
+ */
157
+ public function suppressionAction()
158
+ {
159
+ $request = $this->getRequest();
160
+ $page = $request->getParam('page', 1);
161
+ $limit = 10;
162
+
163
+ // Get Suppressed Items
164
+ $suppressed = array();
165
+ $collection = Mage::getModel('bronto_newsletter/queue')->getCollection()
166
+ ->addBrontoSuppressedFilter()
167
+ ->addStoreFilter(Mage::helper('bronto_common')->getStoreIds())
168
+ ->setPageSize($limit)
169
+ ->setCurPage($page);
170
+
171
+ $items = $collection->getItems();
172
+ foreach ($items as $item) {
173
+ $subscriber = Mage::getModel('newsletter/subscriber')->load($item->getSubscriberId());
174
+ $email = $subscriber->getEmail();
175
+ $resetLink = Mage::helper('bronto_common')->getScopeUrl('adminhtml/newsletter/reset', array('queue_id' => $item->getId()));
176
+ $suppressed[] = array(
177
+ 'subscriber' => $email,
178
+ 'reason' => $item->getBrontoSuppressed(),
179
+ 'action' => "<a href=\"{$resetLink}\">Reset</a>",
180
+ );
181
+ }
182
+
183
+ $prevPage = ($page > 1) ? $page - 1 : false;
184
+
185
+ $remaining = $collection->getSize() - ($limit * $page);
186
+ $nextPage = ($remaining > 0) ? $page + 1 : false;
187
+
188
+ $html = $this->_getSuppressionTableHtml($suppressed, $prevPage, $nextPage);
189
+
190
+ $this->getResponse()->setBody($html);
191
+ }
192
+
193
+ /**
194
+ * Get HTML table for suppression items
195
+ *
196
+ * @param $suppressedItems
197
+ * @param $prevPage
198
+ * @param $nextPage
199
+ *
200
+ * @return string
201
+ */
202
+ protected function _getSuppressionTableHtml($suppressedItems, $prevPage, $nextPage)
203
+ {
204
+ $html = '';
205
+ if ($prevPage) {
206
+ $html .= '<div class="bronto-suppression-interface-control previous" onclick="loadSuppressionTable(' . $prevPage . ')">Load Newer</div>';
207
+ }
208
+ $html .= '
209
+ <table class="border">
210
+ <thead>
211
+ <tr class="headings">
212
+ <th style="white-space: nowrap">Subscriber Email</th>
213
+ <th width="100%">Reason for Suppression</th>
214
+ <th style="white-space: nowrap">Action</th>
215
+ </tr>
216
+ </thead>
217
+ <tbody>';
218
+
219
+ if (count($suppressedItems)) {
220
+ foreach ($suppressedItems as $suppressed) {
221
+ $html .= '<tr>';
222
+ foreach ($suppressed as $value) {
223
+ $html .= "<td style=\"white-space: nowrap\">{$value}</td>";
224
+ }
225
+ $html .= '</tr>';
226
+ }
227
+ } else {
228
+ $html .= '<tr><td colspan="3"><strong>No Suppressed Items</strong></td></tr>';
229
+ }
230
+
231
+ $html .= '
232
+ </tbody>
233
+ </table>';
234
+ if ($nextPage) {
235
+ $html .= '<div class="bronto-suppression-interface-control next" onclick="loadSuppressionTable(' . $nextPage . ')">Load Older</div>';
236
+ }
237
+
238
+ return $html;
239
+ }
240
+
241
  /**
242
  * @return bool
243
  */
252
  * Will forward to deniedAction(), if not allowed.
253
  *
254
  * @param string $section
255
+ *
256
  * @return bool
257
  */
258
  protected function _isSectionAllowed($section)
259
  {
260
  try {
261
+ $session = Mage::getSingleton('admin/session');
262
  $resourceLookup = "admin/system/config/{$section}";
263
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
264
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
265
  if (!$session->isAllowed($resourceId)) {
266
  throw new Exception('');
267
  }
268
+
269
  return true;
270
  }
271
  } catch (Zend_Acl_Exception $e) {
272
  $this->norouteAction();
273
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
274
+
275
  return false;
276
  } catch (Exception $e) {
277
  $this->deniedAction();
278
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
279
+
280
  return false;
281
  }
282
+
283
+ return false;
284
  }
285
 
286
  }
app/code/community/Bronto/Newsletter/controllers/IndexController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2012 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Newsletter_IndexController extends Mage_Core_Controller_Front_Action
8
+ {
9
+ /**
10
+ * Retrieve Checkbox HTML
11
+ */
12
+ public function CheckboxAction()
13
+ {
14
+ $mode = $this->getRequest()->getParam('checkoutMode');
15
+
16
+ $this->loadLayout();
17
+ $block = $this->getLayout()
18
+ ->createBlock('bronto_newsletter/checkout_onepage_newsletter')
19
+ ->setTemplate('bronto/newsletter/checkbox.phtml');
20
+
21
+ $block->setMode($mode);
22
+
23
+ $this->getResponse()->setBody($block->toHtml());
24
+ }
25
+
26
+ /**
27
+ * Capture Subscription Action and set session value to store status
28
+ */
29
+ public function SubscribeAction()
30
+ {
31
+ // Get Passed Params
32
+ $starting = (int)$this->getRequest()->getPost('starting', 1);
33
+ $checked = (int)$this->getRequest()->getPost('checked', 0);
34
+ $email = (string)$this->getRequest()->getPost('email', false);
35
+
36
+ // Pre-define subscribed as null
37
+ $subscribed = null;
38
+
39
+ // Get Customer Object from Session
40
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
41
+ $customerId = $customer->getId();
42
+
43
+ // If Customer Get isCustomerSubscribed, otherwise get Subscriber from email and get status
44
+ if ($customerId && !is_null($customerId)) {
45
+ $subscribed = Mage::helper('bronto_newsletter')->isCustomerSubscribed($customer);
46
+ } else if ((!$customerId || is_null($customerId)) && $email) {
47
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
48
+ if ($subscriber->getId() && !is_null($subscriber->getId())) {
49
+ $subscribed = ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) ? 1 : 0;
50
+ }
51
+ }
52
+
53
+ // If customer is logged in, and subscribed, and checkbox is unchecked, and starting is not unchecked
54
+ if ($subscribed && 0 == $checked && 0 != $starting) {
55
+ $status = Bronto_Api_Contact::STATUS_UNSUBSCRIBED;
56
+ } elseif (1 == $checked || 1 == $subscribed) {
57
+ $status = Bronto_Api_Contact::STATUS_ACTIVE;
58
+ } else {
59
+ $status = Bronto_Api_Contact::STATUS_TRANSACTIONAL;
60
+ }
61
+
62
+ // Get Previous status from session
63
+ $oldStatus = Mage::getSingleton('checkout/session')->getIsSubscribed();
64
+
65
+ // Set Session to store subscription status
66
+ Mage::getSingleton('checkout/session')->setIsSubscribed($status);
67
+
68
+ // Return subscription status
69
+ $this->getResponse()->setBody($oldStatus . '=>' . $status);
70
+ }
71
+ }
app/code/community/Bronto/Newsletter/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Bronto_Newsletter>
5
- <version>1.4.5</version>
6
  </Bronto_Newsletter>
7
  </modules>
8
  <global>
@@ -62,6 +62,15 @@
62
  </events>
63
  </global>
64
  <frontend>
 
 
 
 
 
 
 
 
 
65
  <layout>
66
  <updates>
67
  <bronto_newsletter>
@@ -78,20 +87,13 @@
78
  </bronto_newsletter_checkout_type_onepage_save_order_after>
79
  </observers>
80
  </checkout_type_onepage_save_order_after>
81
- <controller_action_postdispatch_checkout_onepage_saveBilling>
82
- <observers>
83
- <bronto_newsletter_controller_action_postdispatch_checkout_onepage_saveBilling>
84
- <class>bronto_newsletter/observer</class>
85
- <method>setSubscriptionAtBillingStep</method>
86
- </bronto_newsletter_controller_action_postdispatch_checkout_onepage_saveBilling>
87
- </observers>
88
- </controller_action_postdispatch_checkout_onepage_saveBilling>
89
  </events>
90
  </frontend>
91
  <default>
92
  <bronto_newsletter>
93
  <settings>
94
  <enabled>1</enabled>
 
95
  <frequency>D</frequency>
96
  <interval>15</interval>
97
  <minutes>0</minutes>
2
  <config>
3
  <modules>
4
  <Bronto_Newsletter>
5
+ <version>1.4.6</version>
6
  </Bronto_Newsletter>
7
  </modules>
8
  <global>
62
  </events>
63
  </global>
64
  <frontend>
65
+ <routers>
66
+ <bronto_newsletter>
67
+ <use>standard</use>
68
+ <args>
69
+ <module>Bronto_Newsletter</module>
70
+ <frontName>btnewsletter</frontName>
71
+ </args>
72
+ </bronto_newsletter>
73
+ </routers>
74
  <layout>
75
  <updates>
76
  <bronto_newsletter>
87
  </bronto_newsletter_checkout_type_onepage_save_order_after>
88
  </observers>
89
  </checkout_type_onepage_save_order_after>
 
 
 
 
 
 
 
 
90
  </events>
91
  </frontend>
92
  <default>
93
  <bronto_newsletter>
94
  <settings>
95
  <enabled>1</enabled>
96
+ <mage_cron>1</mage_cron>
97
  <frequency>D</frequency>
98
  <interval>15</interval>
99
  <minutes>0</minutes>
app/code/community/Bronto/Newsletter/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <sections>
4
  <bronto_newsletter module="bronto_newsletter">
5
- <label>Newsletter Opt-In</label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>175</sort_order>
@@ -38,10 +38,26 @@
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </enabled>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  <frequency>
42
  <label>Frequency</label>
43
  <depends>
44
  <enabled>1</enabled>
 
45
  </depends>
46
  <frontend_type>select</frontend_type>
47
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
@@ -55,6 +71,7 @@
55
  <label>Interval</label>
56
  <depends>
57
  <frequency>I</frequency>
 
58
  </depends>
59
  <frontend_type>select</frontend_type>
60
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
@@ -68,6 +85,7 @@
68
  <label>Minute of the Hour</label>
69
  <depends>
70
  <frequency>H</frequency>
 
71
  </depends>
72
  <frontend_type>text</frontend_type>
73
  <sort_order>40</sort_order>
@@ -80,6 +98,7 @@
80
  <label>Start Time</label>
81
  <depends>
82
  <enabled>1</enabled>
 
83
  </depends>
84
  <frontend_type>time</frontend_type>
85
  <sort_order>50</sort_order>
@@ -98,7 +117,7 @@
98
  <show_in_default>1</show_in_default>
99
  <show_in_website>0</show_in_website>
100
  <show_in_store>0</show_in_store>
101
- <comment>Total Subscribers to process every cron run.</comment>
102
  </limit>
103
  <sync_limit>
104
  <label>Sync Limit</label>
@@ -124,6 +143,15 @@
124
  <show_in_website>1</show_in_website>
125
  <show_in_store>1</show_in_store>
126
  <fields>
 
 
 
 
 
 
 
 
 
127
  <show_to_guests>
128
  <label>Show on Guest Checkout</label>
129
  <frontend_type>select</frontend_type>
@@ -180,7 +208,7 @@
180
  <show_in_website>1</show_in_website>
181
  <show_in_store>1</show_in_store>
182
  <comment>
183
- <![CDATA[<strong style="color: red">Warning!</strong> If <strong>Yes</strong>, the Magento subscriber status will overwrite the contact status in Bronto. See <a href="http://a.bron.to/magento" target="_blank">documentation</a> for more details.]]></comment>
184
  <fields>
185
  <update_status>
186
  <label>Update Status</label>
@@ -191,7 +219,7 @@
191
  <show_in_default>1</show_in_default>
192
  <show_in_website>1</show_in_website>
193
  <show_in_store>1</show_in_store>
194
- <comment>If Yes, contacts receive Magento's Subscriber status.</comment>
195
  </update_status>
196
  <lists>
197
  <label>Add to List(s)</label>
@@ -214,6 +242,16 @@
214
  <show_in_website>0</show_in_website>
215
  <show_in_store>1</show_in_store>
216
  </cron_list>
 
 
 
 
 
 
 
 
 
 
217
  </groups>
218
  </bronto_newsletter>
219
  </sections>
2
  <config>
3
  <sections>
4
  <bronto_newsletter module="bronto_newsletter">
5
+ <label><![CDATA[<div id="bronto_newsletter_icon_block">Newsletter Opt-In</div>]]></label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>175</sort_order>
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </enabled>
41
+ <mage_cron>
42
+ <label>Use Magento Cron</label>
43
+ <depends>
44
+ <enabled>1</enabled>
45
+ </depends>
46
+ <frontend_type>select</frontend_type>
47
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>1</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>0</show_in_website>
52
+ <show_in_store>0</show_in_store>
53
+ <comment>
54
+ <![CDATA[Setting to <em>No</em> will prevent the Magento Cron from triggering the import process for this module.<br />For more details, check the <em>Cron Settings</em> section in the <strong>Bronto &raquo; Advanced</strong> tab.]]></comment>
55
+ </mage_cron>
56
  <frequency>
57
  <label>Frequency</label>
58
  <depends>
59
  <enabled>1</enabled>
60
+ <mage_cron>1</mage_cron>
61
  </depends>
62
  <frontend_type>select</frontend_type>
63
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
71
  <label>Interval</label>
72
  <depends>
73
  <frequency>I</frequency>
74
+ <mage_cron>1</mage_cron>
75
  </depends>
76
  <frontend_type>select</frontend_type>
77
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
85
  <label>Minute of the Hour</label>
86
  <depends>
87
  <frequency>H</frequency>
88
+ <mage_cron>1</mage_cron>
89
  </depends>
90
  <frontend_type>text</frontend_type>
91
  <sort_order>40</sort_order>
98
  <label>Start Time</label>
99
  <depends>
100
  <enabled>1</enabled>
101
+ <mage_cron>1</mage_cron>
102
  </depends>
103
  <frontend_type>time</frontend_type>
104
  <sort_order>50</sort_order>
117
  <show_in_default>1</show_in_default>
118
  <show_in_website>0</show_in_website>
119
  <show_in_store>0</show_in_store>
120
+ <comment>Total Subscribers to process every run.</comment>
121
  </limit>
122
  <sync_limit>
123
  <label>Sync Limit</label>
143
  <show_in_website>1</show_in_website>
144
  <show_in_store>1</show_in_store>
145
  <fields>
146
+ <show_to_loggedin>
147
+ <label>Show on Logged-In Checkout</label>
148
+ <frontend_type>select</frontend_type>
149
+ <source_model>adminhtml/system_config_source_yesno</source_model>
150
+ <sort_order>4</sort_order>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>1</show_in_store>
154
+ </show_to_loggedin>
155
  <show_to_guests>
156
  <label>Show on Guest Checkout</label>
157
  <frontend_type>select</frontend_type>
208
  <show_in_website>1</show_in_website>
209
  <show_in_store>1</show_in_store>
210
  <comment>
211
+ <![CDATA[Please proceed to the Website and/or Store configuration scopes to select which list(s) to add subscribers to within Bronto.]]></comment>
212
  <fields>
213
  <update_status>
214
  <label>Update Status</label>
219
  <show_in_default>1</show_in_default>
220
  <show_in_website>1</show_in_website>
221
  <show_in_store>1</show_in_store>
222
+ <comment><![CDATA[If <em>Yes</em>, the contact status within Bronto will be set based on the Magento subscriber status.]]></comment>
223
  </update_status>
224
  <lists>
225
  <label>Add to List(s)</label>
242
  <show_in_website>0</show_in_website>
243
  <show_in_store>1</show_in_store>
244
  </cron_list>
245
+ <suppressed>
246
+ <label>Suppressed Subscribers</label>
247
+ <frontend_type>text</frontend_type>
248
+ <frontend_model>bronto_newsletter/adminhtml_system_config_suppressed</frontend_model>
249
+ <sort_order>5</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>1</show_in_store>
253
+ <expanded>0</expanded>
254
+ </suppressed>
255
  </groups>
256
  </bronto_newsletter>
257
  </sections>
app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.6.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ try {
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `{$this->getTable('bronto_newsletter_queue')}`;
11
+
12
+ CREATE TABLE `{$this->getTable('bronto_newsletter_queue')}` (
13
+ `queue_id` int(11) NOT NULL AUTO_INCREMENT,
14
+ `subscriber_id` int(11) NOT NULL,
15
+ `store` tinyint(4) NOT NULL,
16
+ `status` varchar(32) CHARACTER SET utf8 NOT NULL,
17
+ `message_preference` varchar(16) CHARACTER SET utf8 NOT NULL,
18
+ `source` varchar(16) CHARACTER SET utf8 NOT NULL,
19
+ `imported` tinyint(4) NOT NULL DEFAULT '0',
20
+ `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
21
+ `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
22
+ `subscriber_email` varchar(255) CHARACTER SET utf8 NOT NULL,
23
+ `bronto_suppressed` varchar(255) DEFAULT NULL,
24
+ PRIMARY KEY (`subscriber_id`,`store`),
25
+ KEY `IDX_BRONTO_NEWSLETTER_QUEUE_QUEUE_ID` (`queue_id`)
26
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
27
+ ");
28
+
29
+ } catch (Exception $e) {
30
+ throw new RuntimeException('Failed Creating Newsletter Queue Table: ' . $e->getMessage());
31
+ }
32
+
33
+ try {
34
+ // Populate New Table
35
+ $installer->run("
36
+ INSERT IGNORE INTO `{$this->getTable('bronto_newsletter_queue')}`
37
+ (
38
+ SELECT
39
+ NULL,
40
+ `newsletter`.`subscriber_id`,
41
+ `newsletter`.`store_id`,
42
+ IF(`newsletter`.`subscriber_status` = 1, 'active', IF(`newsletter`.`subscriber_status` = 2, 'transactional', 'unsub')),
43
+ 'html',
44
+ 'api',
45
+ 0,
46
+ `newsletter`.`change_status_at`,
47
+ `newsletter`.`change_status_at`,
48
+ `newsletter`.`subscriber_email`,
49
+ null
50
+ FROM `{$this->getTable('newsletter_subscriber')}` `newsletter`
51
+ WHERE NOT EXISTS(
52
+ SELECT 1 FROM `{$this->getTable('bronto_newsletter_queue')}` `queue` WHERE
53
+ `queue`.`subscriber_id`=`newsletter`.`subscriber_id` OR
54
+ `queue`.`subscriber_email`=`newsletter`.`subscriber_email`
55
+ ));
56
+ ");
57
+ } catch (Exception $e) {
58
+ throw new RuntimeException('Failed Populating Newsletter Queue Table: ' . $e->getMessage());
59
+ }
60
+
61
+ $installer->endSetup();
app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-upgrade-1.4.5-1.4.6.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ try {
9
+ $installer->run("
10
+ ALTER IGNORE TABLE `{$this->getTable('bronto_newsletter_queue')}`
11
+ DROP PRIMARY KEY, ADD PRIMARY KEY(`subscriber_id`, `store`),
12
+ ADD KEY `IDX_BRONTO_NEWSLETTER_QUEUE_QUEUE_ID` (`queue_id`);
13
+ ");
14
+
15
+ } catch (Exception $e) {
16
+ throw new RuntimeException('Failed Updating Keys for Table: ' . $e->getMessage());
17
+ }
18
+
19
+ try {
20
+ $installer->run("
21
+ ALTER TABLE `{$this->getTable('bronto_newsletter_queue')}`
22
+ ADD COLUMN `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
23
+ ADD COLUMN `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At';
24
+ ");
25
+
26
+ } catch (Exception $e) {
27
+ throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
28
+ }
29
+
30
+ $installer->endSetup();
app/code/community/Bronto/Order/Block/Adminhtml/Sales/Order/View/Tab/Info.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Order_Block_Adminhtml_Sales_Order_View_Tab_Info extends Mage_Adminhtml_Block_Sales_Order_View_Tab_Info
9
  {
@@ -14,10 +13,10 @@ class Bronto_Order_Block_Adminhtml_Sales_Order_View_Tab_Info extends Mage_Adminh
14
  */
15
  protected function _toHtml()
16
  {
17
- $order = $this->getOrder();
18
  $orderRow = Mage::getModel('bronto_order/queue')->load($order->getId());
19
 
20
- $tid = $orderRow->getBrontoTid();
21
  $imported = $orderRow->getBrontoImported();
22
 
23
  $deliveryHtml = empty($tid) ? $this->_getNoHtml() : $this->_getYesHtml();
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Block_Adminhtml_Sales_Order_View_Tab_Info extends Mage_Adminhtml_Block_Sales_Order_View_Tab_Info
8
  {
13
  */
14
  protected function _toHtml()
15
  {
16
+ $order = $this->getOrder();
17
  $orderRow = Mage::getModel('bronto_order/queue')->load($order->getId());
18
 
19
+ $tid = $orderRow->getBrontoTid();
20
  $imported = $orderRow->getBrontoImported();
21
 
22
  $deliveryHtml = empty($tid) ? $this->_getNoHtml() : $this->_getYesHtml();
app/code/community/Bronto/Order/Block/Adminhtml/System/Config/About.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
 
3
  /**
4
- * @package Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Order_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
9
  {
10
 
11
  /**
12
  * Description for protected
 
13
  * @var string
14
  * @access protected
15
  */
@@ -17,6 +17,7 @@ class Bronto_Order_Block_Adminhtml_System_Config_About extends Bronto_Common_Blo
17
 
18
  /**
19
  * Description for protected
 
20
  * @var string
21
  * @access protected
22
  */
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
8
  {
9
 
10
  /**
11
  * Description for protected
12
+ *
13
  * @var string
14
  * @access protected
15
  */
17
 
18
  /**
19
  * Description for protected
20
+ *
21
  * @var string
22
  * @access protected
23
  */
app/code/community/Bronto/Order/Block/Adminhtml/System/Config/Cron.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 2.0.0
7
  */
8
  class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
9
  {
@@ -64,12 +63,13 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
64
 
65
  /**
66
  * Get number of customers not imported from stores that don't have module enabled
 
67
  * @return int
68
  */
69
  protected function getProgressBarDisabled()
70
  {
71
  $collection = Mage::getModel('bronto_order/queue')->getCollection();
72
- $storeIds = Mage::helper('bronto_order')->getStoreIds();
73
 
74
  if ($storeIds) {
75
  if (!is_array($storeIds)) {
@@ -87,6 +87,7 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
87
  ->getSize();
88
 
89
  }
 
90
  return 0;
91
  }
92
 
@@ -96,7 +97,7 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
96
  protected function getOrderResourceCollection()
97
  {
98
  $collection = Mage::getModel('bronto_order/queue')->getCollection();
99
- $storeIds = Mage::helper('bronto_order')->getStoreIds();
100
 
101
  if ($storeIds) {
102
  $collection->addStoreFilter($storeIds);
@@ -104,4 +105,14 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
104
 
105
  return $collection;
106
  }
 
 
 
 
 
 
 
 
 
 
107
  }
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
8
  {
63
 
64
  /**
65
  * Get number of customers not imported from stores that don't have module enabled
66
+ *
67
  * @return int
68
  */
69
  protected function getProgressBarDisabled()
70
  {
71
  $collection = Mage::getModel('bronto_order/queue')->getCollection();
72
+ $storeIds = Mage::helper('bronto_order')->getStoreIds();
73
 
74
  if ($storeIds) {
75
  if (!is_array($storeIds)) {
87
  ->getSize();
88
 
89
  }
90
+
91
  return 0;
92
  }
93
 
97
  protected function getOrderResourceCollection()
98
  {
99
  $collection = Mage::getModel('bronto_order/queue')->getCollection();
100
+ $storeIds = Mage::helper('bronto_order')->getStoreIds();
101
 
102
  if ($storeIds) {
103
  $collection->addStoreFilter($storeIds);
105
 
106
  return $collection;
107
  }
108
+
109
+ /**
110
+ * Determine if should show the cron table
111
+ *
112
+ * @return mixed
113
+ */
114
+ public function showCronTable()
115
+ {
116
+ return Mage::helper('bronto_order')->canUseMageCron();
117
+ }
118
  }
app/code/community/Bronto/Order/Block/Adminhtml/System/Config/Suppressed.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Order_Block_Adminhtml_System_Config_Suppressed
8
+ extends Bronto_Common_Block_Adminhtml_System_Config_Suppressed
9
+ {
10
+ /**
11
+ * Get URL for AJAX call
12
+ *
13
+ * @return string
14
+ */
15
+ public function getAjaxUrl()
16
+ {
17
+ return Mage::helper('bronto_common')->getScopeUrl('adminhtml/order/suppression');
18
+ }
19
+ }
app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Reset.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Order_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -14,7 +13,7 @@ class Bronto_Order_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Bl
14
  {
15
  $this->setLabel('Reset All Orders');
16
  $this->setOnClick("deleteConfirm('This will mark all orders as not-imported and will cause the importer to re-process each order again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_order')->getScopeUrl('*/order/reset') . "'); return false;");
17
- $this->setClass('delete');
18
 
19
  if (!Mage::helper('bronto_order')->isModuleActive() || (!Mage::helper('bronto_order')->isDebugEnabled() && !Mage::helper('bronto_order')->isTestModeEnabled())) {
20
  $this->setDisabled(true)->setClass('disabled');
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Block_Widget_Button
8
  {
13
  {
14
  $this->setLabel('Reset All Orders');
15
  $this->setOnClick("deleteConfirm('This will mark all orders as not-imported and will cause the importer to re-process each order again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_order')->getScopeUrl('*/order/reset') . "'); return false;");
16
+ $this->setClass('delete bronto-cron-reset');
17
 
18
  if (!Mage::helper('bronto_order')->isModuleActive() || (!Mage::helper('bronto_order')->isDebugEnabled() && !Mage::helper('bronto_order')->isTestModeEnabled())) {
19
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Run.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 2.0.0
7
  */
8
  class Bronto_Order_Block_Adminhtml_Widget_Button_Run
9
  extends Mage_Adminhtml_Block_Widget_Button
@@ -17,6 +16,7 @@ class Bronto_Order_Block_Adminhtml_Widget_Button_Run
17
  $this->setOnClick(
18
  "setLocation('" . Mage::helper('bronto_order')->getScopeUrl('*/order/run') . "'); return false;"
19
  );
 
20
 
21
  // Check to see if this module meets requirements
22
  if (!Mage::helper('bronto_order')->isModuleActive()) {
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Block_Adminhtml_Widget_Button_Run
8
  extends Mage_Adminhtml_Block_Widget_Button
16
  $this->setOnClick(
17
  "setLocation('" . Mage::helper('bronto_order')->getScopeUrl('*/order/run') . "'); return false;"
18
  );
19
+ $this->setClass('bronto-cron-run');
20
 
21
  // Check to see if this module meets requirements
22
  if (!Mage::helper('bronto_order')->isModuleActive()) {
app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Sync.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.8
7
  */
8
  class Bronto_Order_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
9
  {
@@ -14,7 +13,7 @@ class Bronto_Order_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Blo
14
  {
15
  $this->setLabel($this->__('Sync Orders to Queue'));
16
  $this->setOnClick("deleteConfirm('This will ensure all Magento orders are in the queue to import into Bronto\\n\\nThis is meant to be used when the order count does not match the total number of orders in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_order')->getScopeUrl('*/order/sync') . "'); return false;");
17
- $this->setClass('save');
18
 
19
  if (!Mage::helper('bronto_order')->isModuleActive()) {
20
  $this->setDisabled(true)->setClass('disabled');
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
8
  {
13
  {
14
  $this->setLabel($this->__('Sync Orders to Queue'));
15
  $this->setOnClick("deleteConfirm('This will ensure all Magento orders are in the queue to import into Bronto\\n\\nThis is meant to be used when the order count does not match the total number of orders in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_order')->getScopeUrl('*/order/sync') . "'); return false;");
16
+ $this->setClass('save bronto-cron-sync');
17
 
18
  if (!Mage::helper('bronto_order')->isModuleActive()) {
19
  $this->setDisabled(true)->setClass('disabled');
app/code/community/Bronto/Order/Block/Bta.php CHANGED
@@ -1,38 +1,19 @@
1
  <?php
2
 
3
  /**
4
- * @package Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  * @deprecated
8
  */
9
- class Bronto_Order_Block_Bta extends Mage_Core_Block_Text
10
  {
11
  /**
12
- * Render Bronto tracking script
13
  *
14
  * @return string
15
  */
16
- protected function _toHtml()
17
  {
18
- if (!Mage::helper('bronto_order')->isModuleEnabled()) {
19
- return;
20
- }
21
-
22
- $key = md5(
23
- Mage::app()->getStore()->getWebsiteId() .
24
- Mage::getConfig()->getNode(Mage_Core_Model_App::XML_PATH_INSTALL_DATE)
25
- );
26
-
27
- return "
28
- <script type=\"text/javascript\">
29
- document.write(unescape(\"%3Cscript src='\"
30
- + ((document.location.protocol == \"https:\") ? \"https:\" : \"http:\")
31
- + \"//p.bm23.com/bta.js' type='text/javascript'%3E%3C/script%3E\"));
32
- </script>
33
- <script type=\"text/javascript\">
34
- var bta = new __bta('$key');
35
- </script>
36
- ";
37
  }
38
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Newsletter
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  * @deprecated
7
  */
8
+ class Bronto_Order_Block_Bta extends Mage_Core_Block_Template
9
  {
10
  /**
11
+ * Generate BTA Key For Script
12
  *
13
  * @return string
14
  */
15
+ public function getKey()
16
  {
17
+ return Mage::helper('bronto_order')->getTidKey();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
  }
app/code/community/Bronto/Order/Helper/Data.php CHANGED
@@ -3,32 +3,69 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
9
  {
10
- const XML_PATH_ENABLED = 'bronto_order/settings/enabled';
11
- const XML_PATH_LIMIT = 'bronto_order/settings/limit';
12
- const XML_PATH_SYNC_LIMIT = 'bronto_order/settings/sync_limit';
13
- const XML_PATH_DESCRIPTION = 'bronto_order/settings/description_attribute';
14
- const XML_PATH_INSTALL_DATE = 'bronto_order/settings/install_date';
15
- const XML_PATH_UPGRADE_DATE = 'bronto_order/settings/upgrade_date';
 
 
 
 
 
 
 
 
16
 
17
  /**
18
- * @return bool
 
 
 
 
 
 
 
19
  */
20
- public function isEnabled()
21
  {
22
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED);
23
  }
24
 
25
  /**
26
- * @param string $path
 
 
 
 
27
  * @return bool
28
  */
29
- public function disableModule($scope = 'default', $scopeId = 0)
30
  {
31
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  /**
@@ -40,15 +77,42 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
40
  }
41
 
42
  /**
 
 
 
 
 
43
  * @return int
44
  */
45
- public function getLimit()
46
  {
47
- if (!$this->isEnabled()) {
48
- return false;
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT);
 
 
 
 
 
52
  }
53
 
54
  /**
@@ -59,6 +123,66 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
59
  return $this->getAdminScopedConfig(self::XML_PATH_DESCRIPTION);
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Retrieve helper module name
64
  *
@@ -71,37 +195,48 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
71
 
72
  /**
73
  * Get Item Product Url
 
74
  * @param Mage_Sales_Model_Order_Item $item
75
- * @param Mage_Catalog_Model_Product $itemProduct
76
- * @return string
 
 
77
  */
78
  public function getItemUrl(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $storeId = false)
79
  {
80
  $productId = $this->_getIdToUse($item, $itemProduct);
 
81
  return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'url', $storeId);
82
  }
83
 
84
  /**
85
  * Get Item image
 
86
  * @param Mage_Sales_Model_Order_Item $item
87
- * @param Mage_Catalog_Model_Product $itemProduct
88
- * @return string
 
 
89
  */
90
  public function getItemImg(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $storeId = false)
91
  {
92
- if (Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image', $storeId)) {
93
- return Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image', $storeId);
 
94
  }
95
 
96
  $productId = $this->_getIdToUse($item, $itemProduct, false);
 
97
  return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'image', $storeId);
98
  }
99
 
100
  /**
101
  * Get the product ID to use based on Item visibility
 
102
  * @param Mage_Sales_Model_Order_Item $item
103
- * @param Mage_Catalog_Model_Product $itemProduct
104
- * @param boolean $checkVisible
 
105
  * @return int
106
  */
107
  protected function _getIdToUse(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $checkVisible = true)
@@ -123,7 +258,9 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
123
  /**
124
  * This function gets the order item's info_buyRequest super_product_config values
125
  * if they exist
 
126
  * @param Mage_Sales_Model_Order_Item $item
 
127
  * @return boolean|array
128
  * @access protected
129
  */
@@ -134,12 +271,11 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
134
  } elseif (method_exists($item, 'getProductOptionByCode')) {
135
  $buyRequest = $item->getProductOptionByCode('info_buyRequest');
136
  } elseif (method_exists($item, 'getProductOptions')) {
137
- $options = $item->getProductOptions();
138
  $buyRequest = $options['info_buyRequest'];
139
  } elseif (method_exists($item, 'getOptionByCode')) {
140
  $buyRequest = $item->getOptionByCode('info_buyRequest');
141
  } else {
142
-
143
  return false;
144
  }
145
 
@@ -148,10 +284,13 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
148
  } elseif ($buyRequest && array_key_exists('product', $buyRequest)) {
149
  return array('product_id' => $buyRequest['product']);
150
  }
 
 
151
  }
152
 
153
  /**
154
  * Get Count of orders not in queue
 
155
  * @return int
156
  */
157
  public function getMissingOrdersCount()
@@ -162,6 +301,7 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
162
 
163
  /**
164
  * Get Orders which aren't in contact queue
 
165
  * @return array
166
  */
167
  public function getMissingOrders()
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
8
  {
9
+ const XML_PATH_ENABLED = 'bronto_order/settings/enabled';
10
+ const XML_PATH_MAGE_CRON = 'bronto_order/settings/mage_cron';
11
+ const XML_PATH_LIMIT = 'bronto_order/settings/limit';
12
+ const XML_PATH_SYNC_LIMIT = 'bronto_order/settings/sync_limit';
13
+ const XML_PATH_INSTALL_DATE = 'bronto_order/settings/install_date';
14
+ const XML_PATH_UPGRADE_DATE = 'bronto_order/settings/upgrade_date';
15
+
16
+ const XML_PATH_PRICE = 'bronto_order/import/price';
17
+ const XML_PATH_DESCRIPTION = 'bronto_order/import/description';
18
+ const XML_PATH_INCL_DISCOUNT = 'bronto_order/import/incl_discount';
19
+ const XML_PATH_INCL_TAX = 'bronto_order/import/incl_tax';
20
+
21
+ const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_order_import/schedule/cron_expr';
22
+ const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_order_import/run/model';
23
 
24
  /**
25
+ * Module Human Readable Name
26
+ */
27
+ protected $_name = 'Bronto Order Import';
28
+
29
+ /**
30
+ * Get Human Readable Name
31
+ *
32
+ * @return string
33
  */
34
+ public function getName()
35
  {
36
+ return $this->__($this->_name);
37
  }
38
 
39
  /**
40
+ * Check if module is enabled
41
+ *
42
+ * @param string $scope
43
+ * @param int $scopeId
44
+ *
45
  * @return bool
46
  */
47
+ public function isEnabled($scope = 'default', $scopeId = 0)
48
  {
49
+ // Check if valid token is present
50
+ if (!$this->validApiToken(null, $scope, $scopeId)) {
51
+ return false;
52
+ }
53
+
54
+ // Get Enabled Scope
55
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
56
+ }
57
+ /**
58
+ * Disable Specified Module
59
+ *
60
+ * @param string $scope
61
+ * @param int $scopeId
62
+ * @param bool $deleteConfig
63
+ *
64
+ * @return bool
65
+ */
66
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
67
+ {
68
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
69
  }
70
 
71
  /**
77
  }
78
 
79
  /**
80
+ * Get Send Limit
81
+ *
82
+ * @param string $scope
83
+ * @param int $scopeId
84
+ *
85
  * @return int
86
  */
87
+ public function getLimit($scope = 'default', $scopeId = 0)
88
  {
89
+ return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $scope, $scopeId);
90
+ }
91
+
92
+ /**
93
+ * Check if module can use the magento cron
94
+ *
95
+ * @return bool
96
+ */
97
+ public function canUseMageCron()
98
+ {
99
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
100
+ }
101
+
102
+ /**
103
+ * @return string
104
+ */
105
+ public function getCronStringPath()
106
+ {
107
+ return self::XML_PATH_CRON_STRING;
108
+ }
109
 
110
+ /**
111
+ * @return string
112
+ */
113
+ public function getCronModelPath()
114
+ {
115
+ return self::XML_PATH_CRON_MODEL;
116
  }
117
 
118
  /**
123
  return $this->getAdminScopedConfig(self::XML_PATH_DESCRIPTION);
124
  }
125
 
126
+ /**
127
+ * @return string
128
+ */
129
+ public function getPriceAttribute($scope = 'default', $scopeId = 0)
130
+ {
131
+ return $this->getAdminScopedConfig(self::XML_PATH_PRICE, $scope, $scopeId);
132
+ }
133
+
134
+ /**
135
+ * @return boolean
136
+ */
137
+ public function isTaxIncluded($scope = 'default', $scopeId = 0)
138
+ {
139
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_INCL_TAX, $scope, $scopeId);
140
+ }
141
+
142
+ /**
143
+ * @return boolean
144
+ */
145
+ public function isDiscountIncluded($scope = 'default', $scopeId = 0)
146
+ {
147
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_INCL_DISCOUNT, $scope, $scopeId);
148
+ }
149
+
150
+ /**
151
+ * Gets the tid hash for the managed tid
152
+ *
153
+ * @return string
154
+ */
155
+ public function getTidKey()
156
+ {
157
+ return md5(
158
+ Mage::app()->getStore()->getWebsiteId() .
159
+ Mage::getConfig()->getNode(Mage_Core_Model_App::XML_PATH_INSTALL_DATE)
160
+ );
161
+ }
162
+
163
+ /**
164
+ * Gets the item price
165
+ *
166
+ * @param Mage_Sales_Model_Order_Item $item
167
+ * @param string $priceAttr
168
+ * @param boolean $inclTaxes
169
+ * @param boolean $inclDiscounts
170
+ * @return float
171
+ */
172
+ public function getItemPrice($item, $priceAttr, $inclTaxes, $inclDiscounts)
173
+ {
174
+ $base = $priceAttr == 'base' ? 'base_' : '';
175
+ $rowTotal = $item->getData("{$base}row_total");
176
+ $quantity = $item->getQtyOrdered();
177
+ if ($inclTaxes) {
178
+ $rowTotal += $item->getData("{$base}tax_amount");
179
+ }
180
+ if ($inclDiscounts) {
181
+ $rowTotal -= $item->getData("{$base}discount_amount");
182
+ }
183
+ return !empty($quantity) ? max((float)($rowTotal / $quantity), 0.00) : 0.00;
184
+ }
185
+
186
  /**
187
  * Retrieve helper module name
188
  *
195
 
196
  /**
197
  * Get Item Product Url
198
+ *
199
  * @param Mage_Sales_Model_Order_Item $item
200
+ * @param Mage_Catalog_Model_Product $itemProduct
201
+ * @param bool $storeId
202
+ *
203
+ * @return mixed
204
  */
205
  public function getItemUrl(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $storeId = false)
206
  {
207
  $productId = $this->_getIdToUse($item, $itemProduct);
208
+
209
  return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'url', $storeId);
210
  }
211
 
212
  /**
213
  * Get Item image
214
+ *
215
  * @param Mage_Sales_Model_Order_Item $item
216
+ * @param Mage_Catalog_Model_Product $itemProduct
217
+ * @param bool $storeId
218
+ *
219
+ * @return mixed]
220
  */
221
  public function getItemImg(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $storeId = false)
222
  {
223
+ $attribute = Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image', $storeId);
224
+ if ($attribute) {
225
+ return $attribute;
226
  }
227
 
228
  $productId = $this->_getIdToUse($item, $itemProduct, false);
229
+
230
  return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'image', $storeId);
231
  }
232
 
233
  /**
234
  * Get the product ID to use based on Item visibility
235
+ *
236
  * @param Mage_Sales_Model_Order_Item $item
237
+ * @param Mage_Catalog_Model_Product $itemProduct
238
+ * @param boolean $checkVisible
239
+ *
240
  * @return int
241
  */
242
  protected function _getIdToUse(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $checkVisible = true)
258
  /**
259
  * This function gets the order item's info_buyRequest super_product_config values
260
  * if they exist
261
+ *
262
  * @param Mage_Sales_Model_Order_Item $item
263
+ *
264
  * @return boolean|array
265
  * @access protected
266
  */
271
  } elseif (method_exists($item, 'getProductOptionByCode')) {
272
  $buyRequest = $item->getProductOptionByCode('info_buyRequest');
273
  } elseif (method_exists($item, 'getProductOptions')) {
274
+ $options = $item->getProductOptions();
275
  $buyRequest = $options['info_buyRequest'];
276
  } elseif (method_exists($item, 'getOptionByCode')) {
277
  $buyRequest = $item->getOptionByCode('info_buyRequest');
278
  } else {
 
279
  return false;
280
  }
281
 
284
  } elseif ($buyRequest && array_key_exists('product', $buyRequest)) {
285
  return array('product_id' => $buyRequest['product']);
286
  }
287
+
288
+ return false;
289
  }
290
 
291
  /**
292
  * Get Count of orders not in queue
293
+ *
294
  * @return int
295
  */
296
  public function getMissingOrdersCount()
301
 
302
  /**
303
  * Get Orders which aren't in contact queue
304
+ *
305
  * @return array
306
  */
307
  public function getMissingOrders()
app/code/community/Bronto/Order/Model/Mysql4/Queue.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
9
  {
@@ -27,7 +26,8 @@ class Bronto_Order_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
27
 
28
  /**
29
  * Get Write adapter instance
30
- * @return type
 
31
  */
32
  public function getWriteAdapter()
33
  {
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
8
  {
26
 
27
  /**
28
  * Get Write adapter instance
29
+ *
30
+ * @return Varien_Db_Adapter_Interface
31
  */
32
  public function getWriteAdapter()
33
  {
app/code/community/Bronto/Order/Model/Mysql4/Queue/Collection.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Mysql4_Queue_Collection
9
  extends Mage_Core_Model_Mysql4_Collection_Abstract
@@ -26,6 +25,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
26
  public function addBrontoImportedFilter()
27
  {
28
  $this->addFieldToFilter('bronto_imported', array('notnull' => true));
 
29
  return $this;
30
  }
31
 
@@ -35,6 +35,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
35
  public function addBrontoSuppressedFilter()
36
  {
37
  $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
 
38
  return $this;
39
  }
40
 
@@ -44,6 +45,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
44
  public function addBrontoNotImportedFilter()
45
  {
46
  $this->addFieldToFilter('bronto_imported', array('null' => true));
 
47
  return $this;
48
  }
49
 
@@ -53,17 +55,20 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
53
  public function addBrontoNotSuppressedFilter()
54
  {
55
  $this->addFieldToFilter('bronto_suppressed', array('null' => true));
 
56
  return $this;
57
  }
58
 
59
  public function addBrontoHasOrderFilter()
60
  {
61
  $this->addFieldToFilter('order_id', array('neq' => 0));
 
62
  return $this;
63
  }
64
 
65
  /**
66
  * @param mixed $storeIds (null, int|string, array, array may contain null)
 
67
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
68
  */
69
  public function addStoreFilter($storeIds)
@@ -94,11 +99,13 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
94
  * Sort order by order created_at date
95
  *
96
  * @param string $dir
 
97
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
98
  */
99
  public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
100
  {
101
  $this->getSelect()->order("created_at $dir");
 
102
  return $this;
103
  }
104
 
@@ -106,11 +113,13 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
106
  * Sort order by order updated_at date
107
  *
108
  * @param string $dir
 
109
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
110
  */
111
  public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
112
  {
113
  $this->getSelect()->order("updated_at $dir");
 
114
  return $this;
115
  }
116
  }
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Mysql4_Queue_Collection
8
  extends Mage_Core_Model_Mysql4_Collection_Abstract
25
  public function addBrontoImportedFilter()
26
  {
27
  $this->addFieldToFilter('bronto_imported', array('notnull' => true));
28
+
29
  return $this;
30
  }
31
 
35
  public function addBrontoSuppressedFilter()
36
  {
37
  $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
38
+
39
  return $this;
40
  }
41
 
45
  public function addBrontoNotImportedFilter()
46
  {
47
  $this->addFieldToFilter('bronto_imported', array('null' => true));
48
+
49
  return $this;
50
  }
51
 
55
  public function addBrontoNotSuppressedFilter()
56
  {
57
  $this->addFieldToFilter('bronto_suppressed', array('null' => true));
58
+
59
  return $this;
60
  }
61
 
62
  public function addBrontoHasOrderFilter()
63
  {
64
  $this->addFieldToFilter('order_id', array('neq' => 0));
65
+
66
  return $this;
67
  }
68
 
69
  /**
70
  * @param mixed $storeIds (null, int|string, array, array may contain null)
71
+ *
72
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
73
  */
74
  public function addStoreFilter($storeIds)
99
  * Sort order by order created_at date
100
  *
101
  * @param string $dir
102
+ *
103
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
104
  */
105
  public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
106
  {
107
  $this->getSelect()->order("created_at $dir");
108
+
109
  return $this;
110
  }
111
 
113
  * Sort order by order updated_at date
114
  *
115
  * @param string $dir
116
+ *
117
  * @return Bronto_Order_Model_Mysql4_Queue_Collection
118
  */
119
  public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
120
  {
121
  $this->getSelect()->order("updated_at $dir");
122
+
123
  return $this;
124
  }
125
  }
app/code/community/Bronto/Order/Model/Mysql4/Setup.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
9
  {
@@ -12,7 +11,8 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
12
  * Get column definition for attribute
13
  *
14
  * @param string $code Parameter description (if any) ...
15
- * @param unknown $data Parameter description (if any) ...
 
16
  * @return string Return description (if any) ...
17
  * @access protected
18
  */
@@ -30,10 +30,10 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
30
  /**
31
  * Remove entity attribute. Overwritten for flat entities support
32
  *
33
- * @param int|string $entityTypeId
34
- * @param string $code
35
- * @param array $attr
36
- * @return Mage_Sales_Model_Mysql4_Setup
37
  */
38
  public function removeAttribute($entityTypeId, $code)
39
  {
@@ -45,38 +45,41 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
45
  } else {
46
  parent::removeAttribute($entityTypeId, $code);
47
  }
 
48
  return $this;
49
  }
50
 
51
  /**
52
  * Remove an attribute as separate column in the table
53
- * The sales setup class doesn't support it by default
 
 
 
54
  *
55
- * @param string $table
56
- * @param string $attribute
57
- * @param array $attr
58
- * @return Mage_Sales_Model_Mysql4_Setup
59
  */
60
  protected function _removeFlatAttribute($table, $attribute)
61
  {
62
  $this->getConnection()->dropColumn($this->getTable($table), $attribute);
 
63
  return $this;
64
  }
65
 
66
  /**
67
  * Remove attribute from grid
68
  *
69
- * @param string $table
70
- * @param string $attribute
71
- * @param array $attr
72
- * @param string $entityTypeId
73
- * @return Mage_Sales_Model_Mysql4_Setup
74
  */
75
  protected function _removeGridAttribute($table, $attribute, $entityTypeId)
76
  {
77
  if (in_array($entityTypeId, $this->_flatEntitiesGrid)) {
78
  $this->getConnection()->dropColumn($this->getTable($table . '_grid'), $attribute);
79
  }
 
80
  return $this;
81
  }
82
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
8
  {
11
  * Get column definition for attribute
12
  *
13
  * @param string $code Parameter description (if any) ...
14
+ * @param mixed $data Parameter description (if any) ...
15
+ *
16
  * @return string Return description (if any) ...
17
  * @access protected
18
  */
30
  /**
31
  * Remove entity attribute. Overwritten for flat entities support
32
  *
33
+ * @param mixed $entityTypeId
34
+ * @param mixed $code
35
+ *
36
+ * @return $this|Mage_Eav_Model_Entity_Setup
37
  */
38
  public function removeAttribute($entityTypeId, $code)
39
  {
45
  } else {
46
  parent::removeAttribute($entityTypeId, $code);
47
  }
48
+
49
  return $this;
50
  }
51
 
52
  /**
53
  * Remove an attribute as separate column in the table
54
+ * The sales setup class does not support it by default
55
+ *
56
+ * @param $table
57
+ * @param $attribute
58
  *
59
+ * @return $this
 
 
 
60
  */
61
  protected function _removeFlatAttribute($table, $attribute)
62
  {
63
  $this->getConnection()->dropColumn($this->getTable($table), $attribute);
64
+
65
  return $this;
66
  }
67
 
68
  /**
69
  * Remove attribute from grid
70
  *
71
+ * @param $table
72
+ * @param $attribute
73
+ * @param $entityTypeId
74
+ *
75
+ * @return $this
76
  */
77
  protected function _removeGridAttribute($table, $attribute, $entityTypeId)
78
  {
79
  if (in_array($entityTypeId, $this->_flatEntitiesGrid)) {
80
  $this->getConnection()->dropColumn($this->getTable($table . '_grid'), $attribute);
81
  }
82
+
83
  return $this;
84
  }
85
  }
app/code/community/Bronto/Order/Model/Observer.php CHANGED
@@ -3,24 +3,30 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Observer
9
  {
10
 
11
- const NOTICE_IDENTIFER = 'bronto_order';
12
 
13
  private $_helper;
14
 
15
  public function __construct()
16
  {
17
- /* @var $_helper Bronto_Order_Helper_Data */
18
- $this->_helper = Mage::helper(self::NOTICE_IDENTIFER);
 
 
 
 
 
19
  }
20
 
21
  /**
22
  * Verify that all requirements are met for this module
 
23
  * @param Varien_Event_Observer $observer
 
24
  * @return null
25
  * @access public
26
  */
@@ -31,15 +37,17 @@ class Bronto_Order_Model_Observer
31
  }
32
 
33
  // Verify Requirements
34
- if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
35
  return;
36
  }
37
  }
38
 
39
  /**
40
  * Process specified number of items for specified store
41
- * @param mixed $storeId can be store object or id
42
- * @param int $limit must be greater than 0
 
 
43
  * @return array
44
  * @access public
45
  */
@@ -51,11 +59,12 @@ class Bronto_Order_Model_Observer
51
  // If limit is false or 0, return
52
  if (!$limit) {
53
  $this->_helper->writeDebug(' Limit empty. Skipping...');
 
54
  return $result;
55
  }
56
 
57
  // Get Store object and ID
58
- $store = Mage::app()->getStore($storeId);
59
  $storeId = $store->getId();
60
 
61
  // Log that we have begun importing for this store
@@ -64,6 +73,7 @@ class Bronto_Order_Model_Observer
64
  // If module is not enabled for this store, log that fact and return
65
  if (!$store->getConfig(Bronto_Order_Helper_Data::XML_PATH_ENABLED)) {
66
  $this->_helper->writeDebug(' Module disabled for this store. Skipping...');
 
67
  return $result;
68
  }
69
 
@@ -91,28 +101,33 @@ class Bronto_Order_Model_Observer
91
  // If we didn't get any order queue rows with this pull, log and return
92
  if (empty($orderRows)) {
93
  $this->_helper->writeVerboseDebug(' No Orders to process. Skipping...');
 
94
  return $result;
95
  }
96
 
97
  /* @var $productHelper Bronto_Common_Helper_Product */
98
- $productHelper = Mage::helper('bronto_common/product');
99
  $descriptionAttr = $store->getConfig(Bronto_Order_Helper_Data::XML_PATH_DESCRIPTION);
100
- $orderCache = array();
 
 
 
101
 
102
  // Cycle through each order queue row
103
  foreach ($orderRows as $orderRow/* @var $orderRow Bronto_Order_Model_Queue */) {
104
  $orderId = $orderRow->getOrderId();
 
105
 
106
  // Check if the order id is still attached to an order in magento
107
  if ($order = Mage::getModel('sales/order')->load($orderId)/* @var $order Mage_Sales_Model_Order */) {
108
  // Log that we are processing the current order
109
  $this->_helper->writeDebug(" Processing Order ID: {$orderId}");
110
- $orderCache[] = $orderId;
111
 
112
  /* @var $brontoOrder Bronto_Api_Order_Row */
113
- $brontoOrder = $orderObject->createRow();
114
- $brontoOrder->email = $order->getCustomerEmail();
115
- $brontoOrder->id = $order->getIncrementId();
116
  $brontoOrder->orderDate = date('c', strtotime($order->getCreatedAt()));
117
 
118
  // If there is a conversion tracking id attached to this order, add it to the row
@@ -147,10 +162,15 @@ class Bronto_Order_Model_Observer
147
  // Bundled products need child items
148
  case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
149
  if (count($item->getChildrenItems()) > 0) {
150
- foreach ($item->getChildrenItems() as $child_item) {
151
- $fullItems[] = $child_item;
 
 
 
152
  }
153
  }
 
 
154
  break;
155
 
156
  // Configurable products just need simple config item
@@ -165,7 +185,7 @@ class Bronto_Order_Model_Observer
165
  // Build Selected Options Name
166
  $nameWithOptions = array();
167
  foreach ($productAttributeOptions as $productAttribute) {
168
- $itemValue = $productHelper->getProductAttribute($childItem->getProductId(), $productAttribute['attribute_code'], $storeId);
169
  $nameWithOptions[] = $productAttribute['label'] . ': ' . $itemValue;
170
  }
171
 
@@ -215,8 +235,8 @@ class Bronto_Order_Model_Observer
215
  $categories = array();
216
  foreach ($categoryIds as $categoryId) {
217
  /* @var $category Mage_Catalog_Model_Category */
218
- $category = Mage::getModel('catalog/category')->load($categoryId);
219
- $parent = $category->getParentCategory();
220
  $categories[] = $parent->getUrlKey() ? $parent->getUrlKey() : $parent->formatUrlKey($parent->getName());
221
  $categories[] = $category->getUrlKey() ? $category->getUrlKey() : $category->formatUrlKey($category->getName());
222
  }
@@ -226,15 +246,15 @@ class Bronto_Order_Model_Observer
226
 
227
  // Write orderItem
228
  $brontoOrderItems[] = array(
229
- 'id' => $item->getId(),
230
- 'sku' => $item->getSku(),
231
- 'name' => $item->getName(),
232
  'description' => $productHelper->getProductAttribute($item->getProductId(), $descriptionAttr),
233
- 'category' => implode(' ', $categories),
234
- 'image' => $this->_helper->getItemImg($item, $product, $storeId),
235
- 'url' => $this->_helper->getItemUrl($item, $product, $storeId),
236
- 'quantity' => (int)$item->getQtyOrdered(),
237
- 'price' => (float)$item->getPrice(),
238
  );
239
  }
240
  $brontoOrder->products = $brontoOrderItems;
@@ -242,14 +262,17 @@ class Bronto_Order_Model_Observer
242
  break;
243
  }
244
 
 
 
 
245
  try {
246
  // Mark order as imported
247
- $orderRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
248
- $orderRow->save();
249
 
250
  // Flush every 10 orders
251
  if ($result['total'] % 100 === 0) {
252
- $result = $this->_flushOrders($orderObject, $orderCache, $result);
253
  $orderCache = array();
254
  }
255
  } catch (Exception $e) {
@@ -262,14 +285,13 @@ class Bronto_Order_Model_Observer
262
  // increment number of errors
263
  $result['error']++;
264
  }
265
-
266
- // increment total number of items processed
267
- $result['total']++;
268
  }
269
  }
270
 
271
  // Final flush (for any we miss)
272
- $results = $this->_flushOrders($orderObject, $orderCache, $result);
 
 
273
 
274
  // Log results
275
  $this->_helper->writeDebug(' Success: ' . $results['success']);
@@ -281,8 +303,9 @@ class Bronto_Order_Model_Observer
281
 
282
  /**
283
  * @param Bronto_Api_Order $orderObject
284
- * @param array $orderCache
285
- * @param array $result
 
286
  * @return array
287
  * @access protected
288
  */
@@ -290,54 +313,77 @@ class Bronto_Order_Model_Observer
290
  {
291
  // Get delivery results from order object
292
  $flushResult = $orderObject->flush();
 
293
 
294
  // Log Order import flush process starting
 
295
  $this->_helper->writeVerboseDebug('===== FLUSH =====', 'bronto_order_api.log');
296
  $this->_helper->writeVerboseDebug(var_export($orderObject->getApi()->getLastRequest(), true), 'bronto_order_api.log');
297
  $this->_helper->writeVerboseDebug(var_export($orderObject->getApi()->getLastResponse(), true), 'bronto_order_api.log');
298
 
299
  // Cycle through flush results and handle any errors that were returned
300
  foreach ($flushResult as $i => $flushResultRow) {
301
- $order = Mage::getModel('sales/order')->load($orderCache[$i]);
302
-
303
  if ($flushResultRow->hasError()) {
304
- // Get error code from result
305
- $errorCode = $flushResultRow->getErrorCode();
306
-
307
- // Get error message from result
308
  $errorMessage = $flushResultRow->getErrorMessage();
 
 
 
 
 
309
 
310
- // Check to see if this item exists in the order cache
311
- if (isset($orderCache[$i])) {
312
- /* @var $order Mage_Sales_Model_Order */
313
- $order = Mage::getModel('sales/order')->load($orderCache[$i]);
314
-
315
- // If error code is 915, try to pull customer email address
316
- if (915 == $errorCode) {
317
- if ($customerEmail = $order->getCustomerEmail()) {
318
- $errorMessage = "Invalid Email Address: `{$customerEmail}`";
319
- } else {
320
- $errorMessage = "Email Address is empty for this order";
321
- }
322
- }
323
 
324
- // Append order id to message to assiste troubleshooting
325
- $errorMessage .= " (Order #: {$order->getIncrementId()})";
 
 
 
 
 
 
 
 
 
326
 
327
- // Reset Bronto Import status
328
- Mage::getModel('bronto_order/queue')
329
- ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
330
- ->setBrontoImported(null)
331
- ->setBrontoSuppressed($errorMessage)
332
- ->save();
 
 
333
  }
334
 
 
 
 
335
  // Log and Display error message
336
- $this->_helper->writeError("[{$errorCode}] {$errorMessage}");
 
 
 
 
 
337
 
338
  // Increment number of errors
339
  $result['error']++;
340
  } else {
 
 
 
341
  // Increment number of successes
342
  $result['success']++;
343
  }
@@ -348,41 +394,46 @@ class Bronto_Order_Model_Observer
348
 
349
  /**
350
  * Process Orders for all stores
 
 
 
351
  * @return array
352
- * @access public
353
  */
354
- public function processOrders()
355
  {
356
  // Set default result values
357
  $result = array(
358
- 'total' => 0,
359
  'success' => 0,
360
- 'error' => 0,
361
  );
362
 
363
- // Get limit value from config
364
- $limit = $this->_helper->getLimit();
 
 
365
 
366
- // Pull array of stores to cycle through
367
- $stores = Mage::app()->getStores(true);
368
 
369
- // Cycle through stores
370
- foreach ($stores as $_store) {
371
- // If limit is spent, don't process
372
- if ($limit <= 0) {
373
- continue;
374
- }
375
 
376
- // Process Orders for store and collect results
377
- $storeResult = $this->processOrdersForStore($_store, $limit);
378
 
379
- // Append results to totals
380
- $result['total'] += $storeResult['total'];
381
- $result['success'] += $storeResult['success'];
382
- $result['error'] += $storeResult['error'];
383
 
384
- // Decrement limit by resultant total
385
- $limit = $limit - $storeResult['total'];
 
386
  }
387
 
388
  return $result;
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Observer
8
  {
9
 
10
+ const NOTICE_IDENTIFIER = 'bronto_order';
11
 
12
  private $_helper;
13
 
14
  public function __construct()
15
  {
16
+ /* @var Bronto_Order_Helper_Data $_helper */
17
+ $this->_helper = Mage::helper(self::NOTICE_IDENTIFIER);
18
+ }
19
+
20
+ public function setHelper($helper)
21
+ {
22
+ $this->_helper = $helper;
23
  }
24
 
25
  /**
26
  * Verify that all requirements are met for this module
27
+ *
28
  * @param Varien_Event_Observer $observer
29
+ *
30
  * @return null
31
  * @access public
32
  */
37
  }
38
 
39
  // Verify Requirements
40
+ if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
41
  return;
42
  }
43
  }
44
 
45
  /**
46
  * Process specified number of items for specified store
47
+ *
48
+ * @param mixed $storeId can be store object or id
49
+ * @param int $limit must be greater than 0
50
+ *
51
  * @return array
52
  * @access public
53
  */
59
  // If limit is false or 0, return
60
  if (!$limit) {
61
  $this->_helper->writeDebug(' Limit empty. Skipping...');
62
+
63
  return $result;
64
  }
65
 
66
  // Get Store object and ID
67
+ $store = Mage::app()->getStore($storeId);
68
  $storeId = $store->getId();
69
 
70
  // Log that we have begun importing for this store
73
  // If module is not enabled for this store, log that fact and return
74
  if (!$store->getConfig(Bronto_Order_Helper_Data::XML_PATH_ENABLED)) {
75
  $this->_helper->writeDebug(' Module disabled for this store. Skipping...');
76
+
77
  return $result;
78
  }
79
 
101
  // If we didn't get any order queue rows with this pull, log and return
102
  if (empty($orderRows)) {
103
  $this->_helper->writeVerboseDebug(' No Orders to process. Skipping...');
104
+
105
  return $result;
106
  }
107
 
108
  /* @var $productHelper Bronto_Common_Helper_Product */
109
+ $productHelper = Mage::helper('bronto_common/product');
110
  $descriptionAttr = $store->getConfig(Bronto_Order_Helper_Data::XML_PATH_DESCRIPTION);
111
+ $basePrefix = $this->_helper->getPriceAttribute('store', $store->getId());
112
+ $inclTaxes = $this->_helper->isTaxIncluded('store', $store->getId());
113
+ $inclDiscounts = $this->_helper->isDiscountIncluded('store', $store->getId());
114
+ $orderCache = array();
115
 
116
  // Cycle through each order queue row
117
  foreach ($orderRows as $orderRow/* @var $orderRow Bronto_Order_Model_Queue */) {
118
  $orderId = $orderRow->getOrderId();
119
+ $quoteId = $orderRow->getQuoteId();
120
 
121
  // Check if the order id is still attached to an order in magento
122
  if ($order = Mage::getModel('sales/order')->load($orderId)/* @var $order Mage_Sales_Model_Order */) {
123
  // Log that we are processing the current order
124
  $this->_helper->writeDebug(" Processing Order ID: {$orderId}");
125
+ $orderCache[] = array('orderId' => $orderId, 'quoteId' => $quoteId, 'storeId' => $storeId);
126
 
127
  /* @var $brontoOrder Bronto_Api_Order_Row */
128
+ $brontoOrder = $orderObject->createRow();
129
+ $brontoOrder->email = $order->getCustomerEmail();
130
+ $brontoOrder->id = $order->getIncrementId();
131
  $brontoOrder->orderDate = date('c', strtotime($order->getCreatedAt()));
132
 
133
  // If there is a conversion tracking id attached to this order, add it to the row
162
  // Bundled products need child items
163
  case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
164
  if (count($item->getChildrenItems()) > 0) {
165
+ foreach ($item->getChildrenItems() as $childItem) {
166
+ if ($childItem->getPrice() != 0) {
167
+ $item->setPrice(0);
168
+ }
169
+ $fullItems[] = $childItem;
170
  }
171
  }
172
+ $fullItems[] = $item;
173
+
174
  break;
175
 
176
  // Configurable products just need simple config item
185
  // Build Selected Options Name
186
  $nameWithOptions = array();
187
  foreach ($productAttributeOptions as $productAttribute) {
188
+ $itemValue = $productHelper->getProductAttribute($childItem->getProductId(), $productAttribute['attribute_code'], $storeId);
189
  $nameWithOptions[] = $productAttribute['label'] . ': ' . $itemValue;
190
  }
191
 
235
  $categories = array();
236
  foreach ($categoryIds as $categoryId) {
237
  /* @var $category Mage_Catalog_Model_Category */
238
+ $category = Mage::getModel('catalog/category')->load($categoryId);
239
+ $parent = $category->getParentCategory();
240
  $categories[] = $parent->getUrlKey() ? $parent->getUrlKey() : $parent->formatUrlKey($parent->getName());
241
  $categories[] = $category->getUrlKey() ? $category->getUrlKey() : $category->formatUrlKey($category->getName());
242
  }
246
 
247
  // Write orderItem
248
  $brontoOrderItems[] = array(
249
+ 'id' => $item->getId(),
250
+ 'sku' => $item->getSku(),
251
+ 'name' => $item->getName(),
252
  'description' => $productHelper->getProductAttribute($item->getProductId(), $descriptionAttr),
253
+ 'category' => implode(' ', $categories),
254
+ 'image' => $this->_helper->getItemImg($item, $product, $storeId),
255
+ 'url' => $this->_helper->getItemUrl($item, $product, $storeId),
256
+ 'quantity' => (int)$item->getQtyOrdered(),
257
+ 'price' => $this->_helper->getItemPrice($item, $basePrefix, $inclTaxes, $inclDiscounts)
258
  );
259
  }
260
  $brontoOrder->products = $brontoOrderItems;
262
  break;
263
  }
264
 
265
+ // increment total number of items processed
266
+ $result['total']++;
267
+
268
  try {
269
  // Mark order as imported
270
+ // $orderRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
271
+ // $orderRow->save();
272
 
273
  // Flush every 10 orders
274
  if ($result['total'] % 100 === 0) {
275
+ $result = $this->_flushOrders($orderObject, $orderCache, $result);
276
  $orderCache = array();
277
  }
278
  } catch (Exception $e) {
285
  // increment number of errors
286
  $result['error']++;
287
  }
 
 
 
288
  }
289
  }
290
 
291
  // Final flush (for any we miss)
292
+ if (!empty($orderCache)) {
293
+ $results = $this->_flushOrders($orderObject, $orderCache, $result);
294
+ }
295
 
296
  // Log results
297
  $this->_helper->writeDebug(' Success: ' . $results['success']);
303
 
304
  /**
305
  * @param Bronto_Api_Order $orderObject
306
+ * @param array $orderCache
307
+ * @param array $result
308
+ *
309
  * @return array
310
  * @access protected
311
  */
313
  {
314
  // Get delivery results from order object
315
  $flushResult = $orderObject->flush();
316
+ $flushCount = count($flushResult);
317
 
318
  // Log Order import flush process starting
319
+ $this->_helper->writeDebug(" Flush resulted in {$flushCount} orders processed");
320
  $this->_helper->writeVerboseDebug('===== FLUSH =====', 'bronto_order_api.log');
321
  $this->_helper->writeVerboseDebug(var_export($orderObject->getApi()->getLastRequest(), true), 'bronto_order_api.log');
322
  $this->_helper->writeVerboseDebug(var_export($orderObject->getApi()->getLastResponse(), true), 'bronto_order_api.log');
323
 
324
  // Cycle through flush results and handle any errors that were returned
325
  foreach ($flushResult as $i => $flushResultRow) {
 
 
326
  if ($flushResultRow->hasError()) {
327
+ $hasError = true;
328
+ $errorCode = $flushResultRow->getErrorCode();
 
 
329
  $errorMessage = $flushResultRow->getErrorMessage();
330
+ } else {
331
+ $hasError = false;
332
+ $errorCode = false;
333
+ $errorMessage = false;
334
+ }
335
 
336
+ if (isset($orderCache[$i])) {
337
+ /** @var Mage_Sales_Model_Order $order */
338
+ $order = Mage::getModel('sales/order')->load($orderCache[$i]['orderId']);
339
+
340
+ /** @var Mage_Core_Model_Store $store */
341
+ $store = Mage::getModel('core/store')->load($orderCache[$i]['storeId']);
342
+
343
+ /** @var Mage_Core_Model_Website $website */
344
+ $website = Mage::getModel('core/website')->load($store->getWebsiteId());
345
+
346
+ $storeMessage = "For `{$website->getName()}`:`{$store->getName()}`: ";
 
 
347
 
348
+ /** @var Bronto_Order_Model_Queue $orderRow */
349
+ $orderRow = Mage::getModel('bronto_order/queue')
350
+ ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId());
351
+ } else {
352
+ if ($hasError) {
353
+ Mage::helper('bronto_order')->writeError("[{$errorCode}] {$errorMessage}");
354
+ $result['error']++;
355
+ }
356
+
357
+ continue;
358
+ }
359
 
360
+ if ($hasError) {
361
+ // If error code is 915, try to pull customer email address
362
+ if (915 == $errorCode) {
363
+ if ($customerEmail = $order->getCustomerEmail()) {
364
+ $errorMessage = "Invalid Email Address: `{$customerEmail}`";
365
+ } else {
366
+ $errorMessage = "Email Address is empty for this order";
367
+ }
368
  }
369
 
370
+ // Append order id to message to assist troubleshooting
371
+ $errorMessage .= " (Order #: {$order->getIncrementId()})";
372
+
373
  // Log and Display error message
374
+ $this->_helper->writeError("[{$errorCode}] {$storeMessage}{$errorMessage}");
375
+
376
+ // Reset Bronto Import status
377
+ $orderRow->setBrontoImported(null)
378
+ ->setBrontoSuppressed($errorMessage)
379
+ ->save();
380
 
381
  // Increment number of errors
382
  $result['error']++;
383
  } else {
384
+ $orderRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
385
+ $orderRow->save();
386
+
387
  // Increment number of successes
388
  $result['success']++;
389
  }
394
 
395
  /**
396
  * Process Orders for all stores
397
+ *
398
+ * @param bool $brontoCron
399
+ *
400
  * @return array
 
401
  */
402
+ public function processOrders($brontoCron = false)
403
  {
404
  // Set default result values
405
  $result = array(
406
+ 'total' => 0,
407
  'success' => 0,
408
+ 'error' => 0,
409
  );
410
 
411
+ // Only allow cron to run if isset to use mage cron or is coming from bronto cron
412
+ if (Mage::helper('bronto_order')->canUseMageCron() || $brontoCron) {
413
+ // Get limit value from config
414
+ $limit = $this->_helper->getLimit();
415
 
416
+ // Pull array of stores to cycle through
417
+ $stores = Mage::app()->getStores(true);
418
 
419
+ // Cycle through stores
420
+ foreach ($stores as $_store) {
421
+ // If limit is spent, don't process
422
+ if ($limit <= 0) {
423
+ continue;
424
+ }
425
 
426
+ // Process Orders for store and collect results
427
+ $storeResult = $this->processOrdersForStore($_store, $limit);
428
 
429
+ // Append results to totals
430
+ $result['total'] += $storeResult['total'];
431
+ $result['success'] += $storeResult['success'];
432
+ $result['error'] += $storeResult['error'];
433
 
434
+ // Decrement limit by resultant total
435
+ $limit = $limit - $storeResult['total'];
436
+ }
437
  }
438
 
439
  return $result;
app/code/community/Bronto/Order/Model/Order/Observer.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Order_Observer
9
  {
@@ -18,7 +17,7 @@ class Bronto_Order_Model_Order_Observer
18
  $order = $observer->getCreditmemo()->getOrder();
19
 
20
  /* @var $contactQueue Bronto_Order_Model_Queue */
21
- $orderRow = Mage::getModel('bronto_order/queue')
22
  ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
23
  ->setBrontoImported(null)
24
  ->save();
@@ -35,7 +34,7 @@ class Bronto_Order_Model_Order_Observer
35
  $order = $observer->getPayment()->getOrder();
36
 
37
  /* @var $contactQueue Bronto_Order_Model_Queue */
38
- $orderRow = Mage::getModel('bronto_order/queue')
39
  ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
40
  ->setBrontoImported(null)
41
  ->save();
@@ -56,11 +55,16 @@ class Bronto_Order_Model_Order_Observer
56
  $orderRow = Mage::getModel('bronto_order/queue')
57
  ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId());
58
 
 
 
59
  foreach (Mage::getModel('core/cookie')->get() as $key => $value) {
60
- if (stripos($key, "tid") !== false) {
 
 
61
  $orderRow->setBrontoTid($value);
62
-
63
  break;
 
 
64
  }
65
  }
66
 
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Order_Observer
8
  {
17
  $order = $observer->getCreditmemo()->getOrder();
18
 
19
  /* @var $contactQueue Bronto_Order_Model_Queue */
20
+ Mage::getModel('bronto_order/queue')
21
  ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
22
  ->setBrontoImported(null)
23
  ->save();
34
  $order = $observer->getPayment()->getOrder();
35
 
36
  /* @var $contactQueue Bronto_Order_Model_Queue */
37
+ Mage::getModel('bronto_order/queue')
38
  ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
39
  ->setBrontoImported(null)
40
  ->save();
55
  $orderRow = Mage::getModel('bronto_order/queue')
56
  ->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId());
57
 
58
+ $managedKey = Mage::helper('bronto_order')->getTidKey();
59
+
60
  foreach (Mage::getModel('core/cookie')->get() as $key => $value) {
61
+ // If managed key was found, use it; otherwise
62
+ // If an original key was found, use that instead
63
+ if ($key == 'tid_' . $managedKey) {
64
  $orderRow->setBrontoTid($value);
 
65
  break;
66
+ } else if (preg_match('/^tid_/', $key)) {
67
+ $orderRow->setBrontoTid($value);
68
  }
69
  }
70
 
app/code/community/Bronto/Order/Model/Queue.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
9
  {
@@ -16,10 +15,12 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
16
 
17
  /**
18
  * Retrieve Order Queue Row
19
- * @param int $orderId
20
- * @param int $quoteId
21
- * @param int $storeId
22
- * @return Bronto_Order_Model_Queue
 
 
23
  */
24
  public function getOrderRow($orderId = false, $quoteId = false, $storeId = false)
25
  {
@@ -73,13 +74,14 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
73
 
74
  /**
75
  * Get Count of missing orders
 
76
  * @return int
77
  */
78
  public function getMissingOrdersCount()
79
  {
80
  // Get Resources
81
  $resource = $this->getResource();
82
- $adapter = $resource->getWriteAdapter();
83
 
84
  // Build Select Statement
85
  $select = $adapter->select();
@@ -100,8 +102,10 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
100
 
101
  /**
102
  * Get Sub-Select Statement that limits results
 
103
  * @param Bronto_Order_Model_Mysql4_Queue $resource
104
- * @param type $adapter
 
105
  * @return Varien_Db_Select
106
  */
107
  private function _getSubselect($resource, $adapter)
@@ -118,13 +122,14 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
118
 
119
  /**
120
  * Get collection of orders which aren't already in the queue, but should be
 
121
  * @return array
122
  */
123
  public function getMissingOrders()
124
  {
125
  // Get Resources
126
  $resource = $this->getResource();
127
- $adapter = $resource->getWriteAdapter();
128
 
129
  // Get Sync Limit Value
130
  $count = Mage::helper('bronto_order')->getSyncLimit();
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
8
  {
15
 
16
  /**
17
  * Retrieve Order Queue Row
18
+ *
19
+ * @param bool $orderId
20
+ * @param bool $quoteId
21
+ * @param bool $storeId
22
+ *
23
+ * @return $this
24
  */
25
  public function getOrderRow($orderId = false, $quoteId = false, $storeId = false)
26
  {
74
 
75
  /**
76
  * Get Count of missing orders
77
+ *
78
  * @return int
79
  */
80
  public function getMissingOrdersCount()
81
  {
82
  // Get Resources
83
  $resource = $this->getResource();
84
+ $adapter = $resource->getWriteAdapter();
85
 
86
  // Build Select Statement
87
  $select = $adapter->select();
102
 
103
  /**
104
  * Get Sub-Select Statement that limits results
105
+ *
106
  * @param Bronto_Order_Model_Mysql4_Queue $resource
107
+ * @param $adapter
108
+ *
109
  * @return Varien_Db_Select
110
  */
111
  private function _getSubselect($resource, $adapter)
122
 
123
  /**
124
  * Get collection of orders which aren't already in the queue, but should be
125
+ *
126
  * @return array
127
  */
128
  public function getMissingOrders()
129
  {
130
  // Get Resources
131
  $resource = $this->getResource();
132
+ $adapter = $resource->getWriteAdapter();
133
 
134
  // Get Sync Limit Value
135
  $count = Mage::helper('bronto_order')->getSyncLimit();
app/code/community/Bronto/Order/Model/Quote/Observer.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.1.7
7
  */
8
  class Bronto_Order_Model_Quote_Observer
9
  {
3
  /**
4
  * @package Bronto\Order
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_Quote_Observer
8
  {
app/code/community/Bronto/Order/Model/System/Config/Backend/Cron.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Order_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
9
  {
@@ -16,4 +15,20 @@ class Bronto_Order_Model_System_Config_Backend_Cron extends Bronto_Common_Model_
16
  * @var string
17
  */
18
  protected $_cron_model_path = 'crontab/jobs/bronto_order_import/run/model';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
8
  {
15
  * @var string
16
  */
17
  protected $_cron_model_path = 'crontab/jobs/bronto_order_import/run/model';
18
+
19
+ /**
20
+ * @return string
21
+ */
22
+ public function getCronStringPath()
23
+ {
24
+ return Mage::helper('bronto_order')->getCronStringPath();
25
+ }
26
+
27
+ /**
28
+ * @return string
29
+ */
30
+ public function getCronModelPath()
31
+ {
32
+ return Mage::helper('bronto_order')->getCronModelPath();
33
+ }
34
  }
app/code/community/Bronto/Order/Model/System/Config/Source/Description.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Order
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.1.5
7
  */
8
  class Bronto_Order_Model_System_Config_Source_Description
9
  {
@@ -14,7 +13,7 @@ class Bronto_Order_Model_System_Config_Source_Description
14
  {
15
  return array(
16
  'short_description' => 'short_description',
17
- 'description' => 'description',
18
  );
19
  }
20
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Order
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Order_Model_System_Config_Source_Description
8
  {
13
  {
14
  return array(
15
  'short_description' => 'short_description',
16
+ 'description' => 'description',
17
  );
18
  }
19
  }
app/code/community/Bronto/Order/Model/System/Config/Source/Price.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bronto_Order_Model_System_Config_Source_Price
4
+ {
5
+ /**
6
+ * @return array
7
+ */
8
+ public function toOptionArray()
9
+ {
10
+ $helper = Mage::helper('bronto_order');
11
+ return array(
12
+ 'base' => $helper->__('Base Price'),
13
+ 'display' => $helper->__('Display Price'),
14
+ );
15
+ }
16
+ }
app/code/community/Bronto/Order/controllers/Adminhtml/OrderController.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @category Bronto
5
- * @package Order
6
  */
7
  class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action
8
  {
@@ -13,9 +13,9 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
13
  public function runAction()
14
  {
15
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
16
- $model = Mage::getModel('bronto_order/observer');
17
  $helper = Mage::helper('bronto_order');
18
- $limit = $helper->getLimit();
19
 
20
  try {
21
  if ($storeIds = $helper->getStoreIds()) {
@@ -33,7 +33,7 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
33
  $limit = $limit - $storeResult['total'];
34
  }
35
  } else {
36
- $result = $model->processOrders();
37
  }
38
 
39
  if (is_array($result)) {
@@ -56,20 +56,26 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
56
  */
57
  public function resetAction()
58
  {
59
- $helper = Mage::helper('bronto_order');
60
  $storeIds = $helper->getStoreIds();
61
  $resource = Mage::getResourceModel('bronto_order/queue');
62
- $adapter = $resource->getWriteAdapter();
 
 
63
 
64
  $where = array();
65
  if ($storeIds) {
66
  $where = array('store_id IN (?)' => $storeIds);
67
  }
68
 
 
 
 
 
69
  try {
70
  $adapter->update(
71
  $resource->getTable('bronto_order/queue'), array(
72
- 'bronto_imported' => null,
73
  'bronto_suppressed' => null,
74
  ), $where
75
  );
@@ -88,11 +94,11 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
88
  */
89
  public function syncAction()
90
  {
91
- $helper = Mage::helper('bronto_order');
92
  $imported = 0;
93
 
94
  try {
95
- $orders = $helper->getMissingOrders();
96
  $waiting = count($orders);
97
 
98
  if ($waiting > 0) {
@@ -119,6 +125,103 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
119
  $this->_redirect('*/system_config/edit', $returnParams);
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  /**
123
  * @return bool
124
  */
@@ -133,29 +236,35 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
133
  * Will forward to deniedAction(), if not allowed.
134
  *
135
  * @param string $section
 
136
  * @return bool
137
  */
138
  protected function _isSectionAllowed($section)
139
  {
140
  try {
141
- $session = Mage::getSingleton('admin/session');
142
  $resourceLookup = "admin/system/config/{$section}";
143
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
144
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
145
  if (!$session->isAllowed($resourceId)) {
146
  throw new Exception('');
147
  }
 
148
  return true;
149
  }
150
  } catch (Zend_Acl_Exception $e) {
151
  $this->norouteAction();
152
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
153
  return false;
154
  } catch (Exception $e) {
155
  $this->deniedAction();
156
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
157
  return false;
158
  }
 
 
159
  }
160
 
161
  }
2
 
3
  /**
4
  * @category Bronto
5
+ * @package Order
6
  */
7
  class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action
8
  {
13
  public function runAction()
14
  {
15
  $result = array('total' => 0, 'success' => 0, 'error' => 0);
16
+ $model = Mage::getModel('bronto_order/observer');
17
  $helper = Mage::helper('bronto_order');
18
+ $limit = $helper->getLimit();
19
 
20
  try {
21
  if ($storeIds = $helper->getStoreIds()) {
33
  $limit = $limit - $storeResult['total'];
34
  }
35
  } else {
36
+ $result = $model->processOrders(true);
37
  }
38
 
39
  if (is_array($result)) {
56
  */
57
  public function resetAction()
58
  {
59
+ $helper = Mage::helper('bronto_order');
60
  $storeIds = $helper->getStoreIds();
61
  $resource = Mage::getResourceModel('bronto_order/queue');
62
+ $adapter = $resource->getWriteAdapter();
63
+
64
+ $queue_id = $this->getRequest()->getParam('queue_id', false);
65
 
66
  $where = array();
67
  if ($storeIds) {
68
  $where = array('store_id IN (?)' => $storeIds);
69
  }
70
 
71
+ if ($queue_id) {
72
+ $where['queue_id = ?'] = $queue_id;
73
+ }
74
+
75
  try {
76
  $adapter->update(
77
  $resource->getTable('bronto_order/queue'), array(
78
+ 'bronto_imported' => null,
79
  'bronto_suppressed' => null,
80
  ), $where
81
  );
94
  */
95
  public function syncAction()
96
  {
97
+ $helper = Mage::helper('bronto_order');
98
  $imported = 0;
99
 
100
  try {
101
+ $orders = $helper->getMissingOrders();
102
  $waiting = count($orders);
103
 
104
  if ($waiting > 0) {
125
  $this->_redirect('*/system_config/edit', $returnParams);
126
  }
127
 
128
+ /**
129
+ * Action to handle providing suppression table in config page
130
+ */
131
+ public function suppressionAction()
132
+ {
133
+ $request = $this->getRequest();
134
+ $page = $request->getParam('page', 1);
135
+ $limit = 10;
136
+
137
+ // Get Suppressed Items
138
+ $suppressed = array();
139
+ $collection = Mage::getModel('bronto_order/queue')->getCollection()
140
+ ->addBrontoSuppressedFilter()
141
+ ->addStoreFilter(Mage::helper('bronto_common')->getStoreIds())
142
+ ->orderByUpdatedAt()
143
+ ->setPageSize($limit)
144
+ ->setCurPage($page);
145
+
146
+ $items = $collection->getItems();
147
+ foreach ($items as $item) {
148
+ $order = Mage::getModel('sales/order')->load($item->getOrderId());
149
+ $orderLink = Mage::helper('bronto_common')->getScopeUrl('/sales_order/view/', array('order_id' => $item->getOrderId()));
150
+ $customerName = Mage::getModel('customer/customer')->load($order->getCustomerId())->getName();
151
+ $customerLink = Mage::helper('bronto_common')->getScopeUrl('/customer/edit/', array('id' => $item->getCustomerId()));
152
+ $storeName = Mage::getModel('core/store')->load($item->getStoreId())->getName();
153
+ $resetLink = Mage::helper('bronto_common')->getScopeUrl('adminhtml/order/reset', array('queue_id' => $item->getId()));
154
+ $suppressed[] = array(
155
+ 'updated_at' => $item->getUpdatedAt(),
156
+ 'order' => "<a href=\"{$orderLink}\">{$order->getIncrementId()}</a>",
157
+ 'customer' => "<a href=\"{$customerLink}\">{$customerName}</a>",
158
+ 'store_id' => $storeName,
159
+ 'reason' => $item->getBrontoSuppressed(),
160
+ 'action' => "<a href=\"{$resetLink}\">Reset</a>",
161
+ );
162
+ }
163
+
164
+ $prevPage = ($page > 1) ? $page - 1 : false;
165
+
166
+ $remaining = $collection->getSize() - ($limit * $page);
167
+ $nextPage = ($remaining > 0) ? $page + 1 : false;
168
+
169
+ $html = $this->_getSuppressionTableHtml($suppressed, $prevPage, $nextPage);
170
+
171
+ $this->getResponse()->setBody($html);
172
+ }
173
+
174
+ /**
175
+ * Get HTML table for suppression items
176
+ *
177
+ * @param $suppressedItems
178
+ * @param $prevPage
179
+ * @param $nextPage
180
+ *
181
+ * @return string
182
+ */
183
+ protected function _getSuppressionTableHtml($suppressedItems, $prevPage, $nextPage)
184
+ {
185
+ $html = '';
186
+ if ($prevPage) {
187
+ $html .= '<div class="bronto-suppression-interface-control previous" onclick="loadSuppressionTable(' . $prevPage . ')">Load Newer</div>';
188
+ }
189
+ $html .= '
190
+ <table class="border">
191
+ <thead>
192
+ <tr class="headings">
193
+ <th style="white-space: nowrap">Date Suppressed</th>
194
+ <th style="white-space: nowrap">Order</th>
195
+ <th style="white-space: nowrap">Customer</th>
196
+ <th style="white-space: nowrap">Store</th>
197
+ <th width="100%">Reason for Suppression</th>
198
+ <th style="white-space: nowrap">Action</th>
199
+ </tr>
200
+ </thead>
201
+ <tbody>';
202
+
203
+ if (count($suppressedItems)) {
204
+ foreach ($suppressedItems as $suppressed) {
205
+ $html .= '<tr>';
206
+ foreach ($suppressed as $value) {
207
+ $html .= "<td style=\"white-space: nowrap\">{$value}</td>";
208
+ }
209
+ $html .= '</tr>';
210
+ }
211
+ } else {
212
+ $html .= '<tr><td colspan="6"><strong>No Suppressed Items</strong></td></tr>';
213
+ }
214
+
215
+ $html .= '
216
+ </tbody>
217
+ </table>';
218
+ if ($nextPage) {
219
+ $html .= '<div class="bronto-suppression-interface-control next" onclick="loadSuppressionTable(' . $nextPage . ')">Load Older</div>';
220
+ }
221
+
222
+ return $html;
223
+ }
224
+
225
  /**
226
  * @return bool
227
  */
236
  * Will forward to deniedAction(), if not allowed.
237
  *
238
  * @param string $section
239
+ *
240
  * @return bool
241
  */
242
  protected function _isSectionAllowed($section)
243
  {
244
  try {
245
+ $session = Mage::getSingleton('admin/session');
246
  $resourceLookup = "admin/system/config/{$section}";
247
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
248
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
249
  if (!$session->isAllowed($resourceId)) {
250
  throw new Exception('');
251
  }
252
+
253
  return true;
254
  }
255
  } catch (Zend_Acl_Exception $e) {
256
  $this->norouteAction();
257
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
258
+
259
  return false;
260
  } catch (Exception $e) {
261
  $this->deniedAction();
262
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
263
+
264
  return false;
265
  }
266
+
267
+ return false;
268
  }
269
 
270
  }
app/code/community/Bronto/Order/etc/config.xml CHANGED
@@ -124,13 +124,19 @@
124
  <bronto_order>
125
  <settings>
126
  <enabled>0</enabled>
 
127
  <frequency>D</frequency>
128
  <interval>15</interval>
129
  <minutes>0</minutes>
130
  <limit>250</limit>
131
  <sync_limit>1000</sync_limit>
132
- <description_attribute>short_description</description_attribute>
133
  </settings>
 
 
 
 
 
 
134
  </bronto_order>
135
  </default>
136
  <crontab>
124
  <bronto_order>
125
  <settings>
126
  <enabled>0</enabled>
127
+ <mage_cron>1</mage_cron>
128
  <frequency>D</frequency>
129
  <interval>15</interval>
130
  <minutes>0</minutes>
131
  <limit>250</limit>
132
  <sync_limit>1000</sync_limit>
 
133
  </settings>
134
+ <import>
135
+ <description>short_description</description>
136
+ <price>display</price>
137
+ <incl_discount>0</incl_discount>
138
+ <incl_tax>0</incl_tax>
139
+ </import>
140
  </bronto_order>
141
  </default>
142
  <crontab>
app/code/community/Bronto/Order/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <sections>
4
  <bronto_order module="bronto_order">
5
- <label>Order Import</label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>300</sort_order>
@@ -38,10 +38,26 @@
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </enabled>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  <frequency>
42
  <label>Frequency</label>
43
  <depends>
44
  <enabled>1</enabled>
 
45
  </depends>
46
  <frontend_type>select</frontend_type>
47
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
@@ -55,6 +71,7 @@
55
  <label>Interval</label>
56
  <depends>
57
  <frequency>I</frequency>
 
58
  </depends>
59
  <frontend_type>select</frontend_type>
60
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
@@ -68,6 +85,7 @@
68
  <label>Minute of the Hour</label>
69
  <depends>
70
  <frequency>H</frequency>
 
71
  </depends>
72
  <frontend_type>text</frontend_type>
73
  <sort_order>40</sort_order>
@@ -80,6 +98,7 @@
80
  <label>Start Time</label>
81
  <depends>
82
  <enabled>1</enabled>
 
83
  </depends>
84
  <frontend_type>time</frontend_type>
85
  <sort_order>50</sort_order>
@@ -113,29 +132,84 @@
113
  <show_in_store>1</show_in_store>
114
  <comment>Total Orders to sync to queue at a time.</comment>
115
  </sync_limit>
116
- <description_attribute>
117
- <label>Product Description Attribute</label>
118
- <depends>
119
- <enabled>1</enabled>
120
- </depends>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  <frontend_type>select</frontend_type>
122
  <source_model>bronto_order/system_config_source_description</source_model>
123
- <sort_order>70</sort_order>
124
  <show_in_default>1</show_in_default>
125
  <show_in_website>1</show_in_website>
126
  <show_in_store>1</show_in_store>
127
  <comment>Product attribute used for description field.</comment>
128
- </description_attribute>
129
  </fields>
130
- </settings>
131
  <cron_list>
132
  <frontend_type>text</frontend_type>
133
  <frontend_model>bronto_order/adminhtml_system_config_cron</frontend_model>
134
- <sort_order>2</sort_order>
135
  <show_in_default>1</show_in_default>
136
  <show_in_website>1</show_in_website>
137
  <show_in_store>1</show_in_store>
138
  </cron_list>
 
 
 
 
 
 
 
 
 
 
139
  </groups>
140
  </bronto_order>
141
  </sections>
2
  <config>
3
  <sections>
4
  <bronto_order module="bronto_order">
5
+ <label><![CDATA[<div id="bronto_order_icon_block">Order Import</div>]]></label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>300</sort_order>
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </enabled>
41
+ <mage_cron>
42
+ <label>Use Magento Cron</label>
43
+ <depends>
44
+ <enabled>1</enabled>
45
+ </depends>
46
+ <frontend_type>select</frontend_type>
47
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>1</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>0</show_in_website>
52
+ <show_in_store>0</show_in_store>
53
+ <comment>
54
+ <![CDATA[Setting to <em>No</em> will prevent the Magento Cron from triggering the import process for this module.<br />For more details check the <em>Cron Settings</em> section in the <strong>Bronto &raquo; Advanced</strong> tab.]]></comment>
55
+ </mage_cron>
56
  <frequency>
57
  <label>Frequency</label>
58
  <depends>
59
  <enabled>1</enabled>
60
+ <mage_cron>1</mage_cron>
61
  </depends>
62
  <frontend_type>select</frontend_type>
63
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
71
  <label>Interval</label>
72
  <depends>
73
  <frequency>I</frequency>
74
+ <mage_cron>1</mage_cron>
75
  </depends>
76
  <frontend_type>select</frontend_type>
77
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
85
  <label>Minute of the Hour</label>
86
  <depends>
87
  <frequency>H</frequency>
88
+ <mage_cron>1</mage_cron>
89
  </depends>
90
  <frontend_type>text</frontend_type>
91
  <sort_order>40</sort_order>
98
  <label>Start Time</label>
99
  <depends>
100
  <enabled>1</enabled>
101
+ <mage_cron>1</mage_cron>
102
  </depends>
103
  <frontend_type>time</frontend_type>
104
  <sort_order>50</sort_order>
132
  <show_in_store>1</show_in_store>
133
  <comment>Total Orders to sync to queue at a time.</comment>
134
  </sync_limit>
135
+ </fields>
136
+ </settings>
137
+ <import>
138
+ <label>Product Attributes</label>
139
+ <frontend_type>text</frontend_type>
140
+ <sort_order>2</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ <expanded>1</expanded>
145
+ <fields>
146
+ <price>
147
+ <label>Product Price</label>
148
+ <frontend_type>select</frontend_type>
149
+ <source_model>bronto_order/system_config_source_price</source_model>
150
+ <sort_order>5</sort_order>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>1</show_in_store>
154
+ <comment><![CDATA[The imported unit price of products will be
155
+ based on the corresponding currency settings
156
+ (&quot;Curreny Setup&quot; &gt; &quot;Curreny
157
+ Options&quot;).]]></comment>
158
+ </price>
159
+ <incl_discount>
160
+ <label>Include Discounts</label>
161
+ <frontend_type>select</frontend_type>
162
+ <source_model>adminhtml/system_config_source_yesno</source_model>
163
+ <sort_order>10</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ <comment><![CDATA[If <em>Yes</em>, the imported unit price
168
+ will include discounts, adhering to configured tax
169
+ rules (&quot;Sales&quot; &gt; &quot;Tax&quot; &gt;
170
+ &quot;Calucation Settings&quot;).]]></comment>
171
+ </incl_discount>
172
+ <incl_tax>
173
+ <label>Include Taxes</label>
174
+ <frontend_type>select</frontend_type>
175
+ <source_model>adminhtml/system_config_source_yesno</source_model>
176
+ <sort_order>20</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ <comment><![CDATA[If <em>Yes</em>, the imported price will include taxes, adhering to the configured tax rules (&quot;Sales&quot; &gt; &quot;Tax&quot; &gt;
181
+ &quot;Calucation Settings&quot;).]]></comment>
182
+ </incl_tax>
183
+ <description>
184
+ <label>Product Description</label>
185
  <frontend_type>select</frontend_type>
186
  <source_model>bronto_order/system_config_source_description</source_model>
187
+ <sort_order>0</sort_order>
188
  <show_in_default>1</show_in_default>
189
  <show_in_website>1</show_in_website>
190
  <show_in_store>1</show_in_store>
191
  <comment>Product attribute used for description field.</comment>
192
+ </description>
193
  </fields>
194
+ </import>
195
  <cron_list>
196
  <frontend_type>text</frontend_type>
197
  <frontend_model>bronto_order/adminhtml_system_config_cron</frontend_model>
198
+ <sort_order>3</sort_order>
199
  <show_in_default>1</show_in_default>
200
  <show_in_website>1</show_in_website>
201
  <show_in_store>1</show_in_store>
202
  </cron_list>
203
+ <suppressed>
204
+ <label>Suppressed Orders</label>
205
+ <frontend_type>text</frontend_type>
206
+ <frontend_model>bronto_order/adminhtml_system_config_suppressed</frontend_model>
207
+ <sort_order>4</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ <expanded>0</expanded>
212
+ </suppressed>
213
  </groups>
214
  </bronto_order>
215
  </sections>
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.0.0.php CHANGED
@@ -1,26 +1,26 @@
1
  <?php
2
 
3
  $installer = $this;
4
- /* @var $installer Bronto_Order_Model_Resource_Setup */
5
 
6
  $installer->startSetup();
7
 
8
  //
9
  // Quote Attributes
10
  $installer->addAttribute('quote', 'bronto_tid', array(
11
- 'type' => 'varchar',
12
  'required' => false,
13
  ));
14
 
15
  //
16
  // Order Attributes
17
  $installer->addAttribute('order', 'bronto_tid', array(
18
- 'type' => 'varchar',
19
  'required' => false,
20
  ));
21
 
22
  $installer->addAttribute('order', 'bronto_imported', array(
23
- 'type' => 'datetime',
24
  'required' => false,
25
  ));
26
 
1
  <?php
2
 
3
  $installer = $this;
4
+ /* @var $installer Bronto_Order_Model_Mysql4_Setup */
5
 
6
  $installer->startSetup();
7
 
8
  //
9
  // Quote Attributes
10
  $installer->addAttribute('quote', 'bronto_tid', array(
11
+ 'type' => 'varchar',
12
  'required' => false,
13
  ));
14
 
15
  //
16
  // Order Attributes
17
  $installer->addAttribute('order', 'bronto_tid', array(
18
+ 'type' => 'varchar',
19
  'required' => false,
20
  ));
21
 
22
  $installer->addAttribute('order', 'bronto_imported', array(
23
+ 'type' => 'datetime',
24
  'required' => false,
25
  ));
26
 
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.1.8.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
@@ -23,7 +23,8 @@ try {
23
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
24
  `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
25
  `bronto_suppressed` varchar(255) DEFAULT NULL,
26
- PRIMARY KEY (`queue_id`,`order_id`,`store_id`,`quote_id`),
 
27
  KEY `IDX_BRONTO_ORDER_QUEUE_STORE_ID` (`store_id`),
28
  KEY `IDX_BRONTO_ORDER_QUEUE_QUOTE_ID` (`quote_id`),
29
  KEY `IDX_BRONTO_ORDER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
23
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
24
  `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
25
  `bronto_suppressed` varchar(255) DEFAULT NULL,
26
+ PRIMARY KEY (`order_id`,`store_id`,`quote_id`),
27
+ KEY `IDX_BRONTO_ORDER_QUEUE_QUEUE_ID` (`queue_id`),
28
  KEY `IDX_BRONTO_ORDER_QUEUE_STORE_ID` (`store_id`),
29
  KEY `IDX_BRONTO_ORDER_QUEUE_QUOTE_ID` (`quote_id`),
30
  KEY `IDX_BRONTO_ORDER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-upgrade-1.0.0-1.1.6.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-upgrade-1.1.6-1.1.7.php CHANGED
@@ -4,7 +4,7 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-upgrade-1.1.7-1.1.8.php CHANGED
@@ -4,17 +4,39 @@
4
  */
5
 
6
  $installer = $this;
7
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  try {
12
  // Update Table
13
  $installer->run("
14
- ALTER TABLE `{$this->getTable('bronto_order_queue')}` ADD COLUMN `bronto_suppressed` VARCHAR(255) NULL DEFAULT NULL;
 
15
  ");
16
  } catch (Exception $e) {
17
  throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
20
  $installer->endSetup();
4
  */
5
 
6
  $installer = $this;
7
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
8
 
9
  $installer->startSetup();
10
 
11
+ try {
12
+ // Update Table Keys
13
+ $installer->run("
14
+ ALTER IGNORE TABLE `{$this->getTable('bronto_order_queue')}`
15
+ DROP PRIMARY KEY, ADD PRIMARY KEY (`order_id`,`store_id`,`quote_id`),
16
+ ADD KEY `IDX_BRONTO_ORDER_QUEUE_QUEUE_ID` (`queue_id`);
17
+ ");
18
+ } catch (Exception $e) {
19
+ throw new RuntimeException('Failed Updating Keys for Table: ' . $e->getMessage());
20
+ }
21
+
22
  try {
23
  // Update Table
24
  $installer->run("
25
+ ALTER TABLE `{$this->getTable('bronto_order_queue')}`
26
+ ADD COLUMN `bronto_suppressed` VARCHAR(255) NULL DEFAULT NULL;
27
  ");
28
  } catch (Exception $e) {
29
  throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
30
  }
31
 
32
+ try {
33
+ $installer->run("
34
+ UPDATE `{$this->getTable('core/config_data')}`
35
+ SET `path` = 'bronto_order/import/description'
36
+ WHERE `path` = 'bronto_order/settings/description_attribute';
37
+ ");
38
+ } catch (Exception $e) {
39
+ throw new RuntimeException('Failed migrating settings: ' . $e->getMessage());
40
+ }
41
+
42
  $installer->endSetup();
app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Block_Adminhtml_Delivery extends Mage_Adminhtml_Block_Widget_Grid_Container
8
+ {
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $_controller = 'adminhtml_delivery';
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_clearButtonLabel = 'Clear Log History';
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $_blockGroup = 'bronto_reminder';
23
+
24
+ public function __construct()
25
+ {
26
+ $this->_headerText = Mage::helper('bronto_reminder')->__('Bronto Reminder Delivery Log');
27
+
28
+ parent::__construct();
29
+
30
+ $this->_addBackButton();
31
+ $this->_addButton('clear', array(
32
+ 'label' => $this->getClearButtonLabel(),
33
+ 'onclick' => "setLocation('{$this->getClearUrl()}')",
34
+ 'class' => 'delete'
35
+ ));
36
+
37
+ $this->_removeButton('add');
38
+ }
39
+
40
+ /**
41
+ * @return string
42
+ */
43
+ public function getClearUrl()
44
+ {
45
+ return $this->getUrl('*/*/clear');
46
+ }
47
+
48
+ /**
49
+ * @return string
50
+ */
51
+ protected function getClearButtonLabel()
52
+ {
53
+ return $this->_clearButtonLabel;
54
+ }
55
+
56
+ /**
57
+ * Get URL to go back
58
+ *
59
+ * @return string
60
+ */
61
+ public function getBackUrl()
62
+ {
63
+ return $this->getUrl('*/reminders/index');
64
+ }
65
+ }
app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery/Grid.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Block_Adminhtml_Delivery_Grid
8
+ extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+ /**
11
+ * @param array $attributes
12
+ */
13
+ public function __construct($attributes = array())
14
+ {
15
+ parent::__construct($attributes);
16
+ $this->setId('deliveryGrid');
17
+ $this->setIdFieldName('log_id');
18
+ $this->setDefaultSort('sent_at', 'desc');
19
+ $this->setSaveParametersInSession(true);
20
+ }
21
+
22
+ /**
23
+ * @return this
24
+ */
25
+ protected function _prepareCollection()
26
+ {
27
+ $collection = Mage::getModel('bronto_reminder/delivery')->getCollection();
28
+ $this->setCollection($collection);
29
+
30
+ return parent::_prepareCollection();
31
+ }
32
+
33
+ /**
34
+ * @return $this
35
+ */
36
+ protected function _prepareColumns()
37
+ {
38
+ $this->addColumn(
39
+ 'log_id',
40
+ array(
41
+ 'header' => Mage::helper('bronto_reminder')->__('ID'),
42
+ 'align' => 'left',
43
+ 'index' => 'log_id',
44
+ 'type' => 'number',
45
+ 'filter' => false,
46
+ )
47
+ );
48
+
49
+ $this->addColumn(
50
+ 'message_name',
51
+ array(
52
+ 'header' => Mage::helper('bronto_reminder')->__('Message Name'),
53
+ 'align' => 'left',
54
+ 'index' => 'message_name',
55
+ 'filter' => false,
56
+ )
57
+ );
58
+
59
+ $this->addColumn(
60
+ 'sent_at',
61
+ array(
62
+ 'header' => Mage::helper('bronto_reminder')->__('Sent At'),
63
+ 'align' => 'left',
64
+ 'index' => 'sent_at',
65
+ 'type' => 'datetime'
66
+ )
67
+ );
68
+
69
+ $this->addColumn(
70
+ 'customer_email',
71
+ array(
72
+ 'header' => Mage::helper('customer')->__('Email'),
73
+ 'index' => 'customer_email',
74
+ 'renderer' => 'bronto_reminder/adminhtml_delivery_grid_renderer_customer',
75
+ )
76
+ );
77
+
78
+ $this->addColumn(
79
+ 'success',
80
+ array(
81
+ 'header' => Mage::helper('bronto_reminder')->__('Success'),
82
+ 'align' => 'left',
83
+ 'index' => 'success',
84
+ 'sortable' => false,
85
+ 'type' => 'options',
86
+ 'options' => array(
87
+ 0 => 'No',
88
+ 1 => 'Yes',
89
+ ),
90
+ )
91
+ );
92
+
93
+ $this->addColumn(
94
+ 'error',
95
+ array(
96
+ 'header' => Mage::helper('bronto_reminder')->__('Error'),
97
+ 'align' => 'left',
98
+ 'index' => 'error',
99
+ 'sortable' => false,
100
+ 'filter' => false,
101
+ )
102
+ );
103
+
104
+ $this->addColumn(
105
+ 'data',
106
+ array(
107
+ 'header' => Mage::helper('bronto_reminder')->__('Fields'),
108
+ 'align' => 'left',
109
+ 'index' => 'data',
110
+ 'renderer' => 'bronto_reminder/adminhtml_delivery_grid_renderer_fields',
111
+ 'sortable' => false,
112
+ 'filter' => false,
113
+ )
114
+ );
115
+
116
+ return parent::_prepareColumns();
117
+ }
118
+
119
+ /**
120
+ * Return row url for js event handlers
121
+ *
122
+ * @param Bronto_Reminder_Model_Log|Varien_Object
123
+ *
124
+ * @return string
125
+ */
126
+ public function getRowUrl($log)
127
+ {
128
+ return null;
129
+ }
130
+ }
app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery/Grid/Renderer/Customer.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Block_Adminhtml_Delivery_Grid_Renderer_Customer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ /**
10
+ * @param Varien_Object $row
11
+ *
12
+ * @return mixed
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ if ($row->getCustomerId() && Mage::getSingleton('admin/session')->isAllowed('customer/manage')) {
17
+ $customerEditUrl = $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
18
+
19
+ return sprintf(
20
+ '<a href="%s">%s</a>',
21
+ $customerEditUrl,
22
+ parent::render($row)
23
+ );
24
+ }
25
+
26
+ return parent::render($row);
27
+ }
28
+ }
app/code/community/Bronto/Reminder/Block/Adminhtml/Delivery/Grid/Renderer/Fields.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Block_Adminhtml_Delivery_Grid_Renderer_Fields extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $fields = array();
12
+ try {
13
+ $fields = unserialize($row->getFields());
14
+ } catch (Exception $e) {
15
+ //
16
+ }
17
+
18
+ if (empty($fields)) {
19
+ return '';
20
+ }
21
+
22
+ $fieldsHtml = '<dl style="margin-top: 10px">';
23
+ foreach ($fields as $field) {
24
+ $fieldsHtml .= '<dt><strong>' . $field['name'] . '</strong></dt>';
25
+ $fieldsHtml .= '
26
+ <dd style="padding-left: 15px; padding-bottom: 10px">
27
+ <pre>' . htmlspecialchars($field['content']) . '</pre>
28
+ </dd>
29
+ ';
30
+ }
31
+ $fieldsHtml .= '</dl>';
32
+
33
+ return '
34
+ <a href="#" onclick="javascript:document.getElementById(\'fields-' . $row->getId() . '\').style.display = \'block\';">Show</a>
35
+ <span style="color:#666">|</span>
36
+ <a href="#" onclick="javascript:document.getElementById(\'fields-' . $row->getId() . '\').style.display = \'none\';">Hide</a>
37
+ <div id="fields-' . $row->getId() . '" style="display: none">' . $fieldsHtml . '</div>
38
+ ';
39
+ }
40
+ }
app/code/community/Bronto/Reminder/Block/Adminhtml/Promo/Notice.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Promo_Notice extends Mage_Adminhtml_Block_Template
9
  {
@@ -18,12 +17,13 @@ class Bronto_Reminder_Block_Adminhtml_Promo_Notice extends Mage_Adminhtml_Block_
18
  $resource = Mage::getResourceModel('bronto_reminder/rule');
19
  if ($count = $resource->getAssignedRulesCount($salesRule->getId())) {
20
  $confirm = Mage::helper('bronto_reminder')->__('This rule is assigned to %s automated reminder rule(s). Deleting this rule will automatically unassign it.', $count);
21
- $block = $this->getLayout()->getBlock('promo_quote_edit');
22
  if ($block instanceof Mage_Adminhtml_Block_Promo_Quote_Edit) {
23
  $block->updateButton('delete', 'onclick', 'deleteConfirm(\'' . $confirm . '\', \'' . $block->getDeleteUrl() . '\')');
24
  }
25
  }
26
  }
 
27
  return $this;
28
  }
29
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Promo_Notice extends Mage_Adminhtml_Block_Template
8
  {
17
  $resource = Mage::getResourceModel('bronto_reminder/rule');
18
  if ($count = $resource->getAssignedRulesCount($salesRule->getId())) {
19
  $confirm = Mage::helper('bronto_reminder')->__('This rule is assigned to %s automated reminder rule(s). Deleting this rule will automatically unassign it.', $count);
20
+ $block = $this->getLayout()->getBlock('promo_quote_edit');
21
  if ($block instanceof Mage_Adminhtml_Block_Promo_Quote_Edit) {
22
  $block->updateButton('delete', 'onclick', 'deleteConfirm(\'' . $confirm . '\', \'' . $block->getDeleteUrl() . '\')');
23
  }
24
  }
25
  }
26
+
27
  return $this;
28
  }
29
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder extends Mage_Adminhtml_Block_Widget_Grid_Container
9
  {
@@ -19,15 +18,51 @@ class Bronto_Reminder_Block_Adminhtml_Reminder extends Mage_Adminhtml_Block_Widg
19
 
20
  public function __construct()
21
  {
22
- $this->_headerText = Mage::helper('bronto_reminder')->__('Bronto Reminder Email Rules');
23
  $this->_addButtonLabel = Mage::helper('bronto_reminder')->__('Add New Rule');
24
  parent::__construct();
25
  $this->setTemplate('bronto/reminder/grid/container.phtml');
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Get link to transactional email configuration
30
- * @return type
 
31
  */
32
  public function getConfigLink()
33
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder extends Mage_Adminhtml_Block_Widget_Grid_Container
8
  {
18
 
19
  public function __construct()
20
  {
21
+ $this->_headerText = Mage::helper('bronto_reminder')->__('Bronto Reminder Email Rules');
22
  $this->_addButtonLabel = Mage::helper('bronto_reminder')->__('Add New Rule');
23
  parent::__construct();
24
  $this->setTemplate('bronto/reminder/grid/container.phtml');
25
  }
26
 
27
+ /**
28
+ * @return Mage_Core_Block_Abstract
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ if (!Mage::helper('bronto_reminder')->isEnabledForAny()) {
33
+ return parent::_prepareLayout();
34
+ }
35
+
36
+ if (Mage::helper('bronto_reminder')->isLogEnabled()) {
37
+ $this->_addButton(
38
+ 'log_button',
39
+ array(
40
+ 'label' => Mage::helper('adminhtml')->__('Delivery Log'),
41
+ 'onclick' => "setLocation('{$this->getLogUrl()}')",
42
+ 'class' => 'go',
43
+ ),
44
+ 0,
45
+ 1
46
+ );
47
+ }
48
+
49
+ return parent::_prepareLayout();
50
+ }
51
+
52
+ /**
53
+ * Get URL for transactional email log
54
+ *
55
+ * @return string
56
+ */
57
+ public function getLogUrl()
58
+ {
59
+ return $this->getUrl('*/delivery/index');
60
+ }
61
+
62
  /**
63
  * Get link to transactional email configuration
64
+ *
65
+ * @return mixed
66
  */
67
  public function getConfigLink()
68
  {
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
9
  {
@@ -36,7 +35,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
36
  if ($rule->getId()) {
37
  $confirm = Mage::helper('bronto_reminder')->__('Are you sure you want to match this rule now?');
38
  $this->_addButton('match_now', array(
39
- 'label' => Mage::helper('bronto_reminder')->__('Match Now'),
40
  'onclick' => "confirmSetLocation('{$confirm}', '{$this->getMatchUrl()}')"
41
  ), -1);
42
  if ($limit = Mage::helper('bronto_reminder')->getOneRunLimit()) {
@@ -57,8 +56,8 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
57
  }
58
 
59
  $this->_addButton('save_and_continue_edit', array(
60
- 'class' => 'save',
61
- 'label' => Mage::helper('bronto_reminder')->__('Save and Continue Edit'),
62
  'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
63
  ), 3);
64
  }
@@ -75,24 +74,26 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
75
  }
76
 
77
  /**
78
- * Get url for immidiately run sending process
79
  *
80
  * @return string
81
  */
82
  public function getRunUrl()
83
  {
84
  $rule = Mage::registry('current_reminder_rule');
 
85
  return $this->getUrl('*/*/run', array('id' => $rule->getRuleId()));
86
  }
87
 
88
  /**
89
- * Get url for immidiately matching customers
90
  *
91
  * @return string
92
  */
93
  public function getMatchUrl()
94
  {
95
  $rule = Mage::registry('current_reminder_rule');
 
96
  return $this->getUrl('*/*/match', array('id' => $rule->getRuleId()));
97
  }
98
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
8
  {
35
  if ($rule->getId()) {
36
  $confirm = Mage::helper('bronto_reminder')->__('Are you sure you want to match this rule now?');
37
  $this->_addButton('match_now', array(
38
+ 'label' => Mage::helper('bronto_reminder')->__('Match Now'),
39
  'onclick' => "confirmSetLocation('{$confirm}', '{$this->getMatchUrl()}')"
40
  ), -1);
41
  if ($limit = Mage::helper('bronto_reminder')->getOneRunLimit()) {
56
  }
57
 
58
  $this->_addButton('save_and_continue_edit', array(
59
+ 'class' => 'save',
60
+ 'label' => Mage::helper('bronto_reminder')->__('Save and Continue Edit'),
61
  'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
62
  ), 3);
63
  }
74
  }
75
 
76
  /**
77
+ * Get url for immediately run sending process
78
  *
79
  * @return string
80
  */
81
  public function getRunUrl()
82
  {
83
  $rule = Mage::registry('current_reminder_rule');
84
+
85
  return $this->getUrl('*/*/run', array('id' => $rule->getRuleId()));
86
  }
87
 
88
  /**
89
+ * Get url for immediately matching customers
90
  *
91
  * @return string
92
  */
93
  public function getMatchUrl()
94
  {
95
  $rule = Mage::registry('current_reminder_rule');
96
+
97
  return $this->getUrl('*/*/match', array('id' => $rule->getRuleId()));
98
  }
99
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Form.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
9
  {
@@ -19,6 +18,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Form extends Mage_Adminhtml_
19
  $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
20
  $form->setUseContainer(true);
21
  $this->setForm($form);
 
22
  return parent::_prepareForm();
23
  }
24
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
8
  {
18
  $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
19
  $form->setUseContainer(true);
20
  $this->setForm($form);
21
+
22
  return parent::_prepareForm();
23
  }
24
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Bronto.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Bronto extends Mage_Adminhtml_Block_Widget_Form
9
  {
@@ -18,9 +17,9 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Bronto extends Mage_Admi
18
  $model = Mage::registry('current_reminder_rule');
19
 
20
  $fieldset = $form->addFieldset('message_fieldset', array(
21
- 'legend' => Mage::helper('bronto_reminder')->__('Bronto Messages'),
22
  'table_class' => 'form-list stores-tree',
23
- 'comment' => Mage::helper('bronto_reminder')->__('Messages will be sent only for specified store views. Message store view matches the store view customer was registered on.'),
24
  ));
25
 
26
  foreach (Mage::app()->getWebsites() as $website) {
@@ -30,7 +29,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Bronto extends Mage_Admi
30
  continue;
31
  }
32
  $fieldset->addField("website_message_{$website->getId()}", 'note', array(
33
- 'label' => $website->getName(),
34
  'fieldset_html_class' => 'website',
35
  ));
36
  foreach ($website->getGroups() as $gkey => $group) {
@@ -40,21 +39,43 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Bronto extends Mage_Admi
40
  continue;
41
  }
42
  $fieldset->addField("group_message_{$group->getId()}", 'note', array(
43
- 'label' => $group->getName(),
44
  'fieldset_html_class' => 'store-group',
45
  ));
46
  foreach ($stores as $key => $store) {
47
- if (Mage::helper('bronto_reminder')->isEnabled($store->getId())) {
48
  $values = Mage::helper('bronto_reminder/message')->getMessagesOptionsArray($store->getId(), $website->getId());
49
 
50
  $fieldset->addField("store_message_{$store->getId()}", 'select', array(
51
- 'name' => "store_messages[{$store->getId()}]",
52
- 'required' => false,
53
- 'label' => $store->getName(),
54
- 'values' => $values,
55
- 'fieldset_html_class' => 'store',
56
- 'disabled' => count($values) == 1 ? true : false,
57
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  } else {
59
  unset($stores[$key]);
60
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Bronto extends Mage_Adminhtml_Block_Widget_Form
8
  {
17
  $model = Mage::registry('current_reminder_rule');
18
 
19
  $fieldset = $form->addFieldset('message_fieldset', array(
20
+ 'legend' => Mage::helper('bronto_reminder')->__('Bronto Messages'),
21
  'table_class' => 'form-list stores-tree',
22
+ 'comment' => Mage::helper('bronto_reminder')->__('Messages will be sent only for specified store views.'),
23
  ));
24
 
25
  foreach (Mage::app()->getWebsites() as $website) {
29
  continue;
30
  }
31
  $fieldset->addField("website_message_{$website->getId()}", 'note', array(
32
+ 'label' => $website->getName(),
33
  'fieldset_html_class' => 'website',
34
  ));
35
  foreach ($website->getGroups() as $gkey => $group) {
39
  continue;
40
  }
41
  $fieldset->addField("group_message_{$group->getId()}", 'note', array(
42
+ 'label' => $group->getName(),
43
  'fieldset_html_class' => 'store-group',
44
  ));
45
  foreach ($stores as $key => $store) {
46
+ if (Mage::helper('bronto_reminder')->isEnabled('store', $store->getId())) {
47
  $values = Mage::helper('bronto_reminder/message')->getMessagesOptionsArray($store->getId(), $website->getId());
48
 
49
  $fieldset->addField("store_message_{$store->getId()}", 'select', array(
50
+ 'name' => "store_messages[{$store->getId()}]",
51
+ 'required' => false,
52
+ 'label' => $store->getName(),
53
+ 'values' => $values,
54
+ 'fieldset_html_class' => 'store',
55
+ 'disabled' => count($values) == 1 ? true : false,
56
  ));
57
+
58
+ $fieldset->addField("store_message_sendtype_{$store->getId()}", 'radios', array(
59
+ 'name' => "store_message_sendtypes[{$store->getId()}]",
60
+ 'required' => false,
61
+ 'label' => '',
62
+ 'value' => 'transactional',
63
+ 'values' => array(
64
+ array('value' => 'transactional', 'label' => ' Send as Transactional'),
65
+ array('value' => 'marketing', 'label' => ' Send as Marketing'),
66
+ ),
67
+ 'fieldset_html_class' => 'store',
68
+ 'disabled' => count($values) == 1 ? true : false,
69
+ ));
70
+
71
+ // $fieldset->addField("store_message_salesrule_id_{$store->getId()}", 'select', array(
72
+ // 'name' => "store_message_salesrule_ids[{$store->getId()}]",
73
+ // 'required' => false,
74
+ // 'label' => 'Sales Rule Coupon',
75
+ // 'values' => Mage::helper('bronto_common/salesrule')->getRuleOptionsArray(),
76
+ // 'fieldset_html_class' => 'store_child',
77
+ // 'disabled' => count($values) == 1 ? true : false,
78
+ // ));
79
  } else {
80
  unset($stores[$key]);
81
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Conditions.php CHANGED
@@ -1,27 +1,26 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Conditions extends Mage_Adminhtml_Block_Widget_Form
9
  {
10
  protected function _prepareForm()
11
  {
12
- $form = new Varien_Data_Form();
13
  $model = Mage::registry('current_reminder_rule');
14
 
15
  $renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')
16
  ->setTemplate('promo/fieldset.phtml')
17
  ->setNewChildUrl($this->getUrl('*/*/newConditionHtml/form/rule_conditions_fieldset'));
18
  $fieldset = $form->addFieldset('rule_conditions_fieldset', array(
19
- 'legend' => Mage::helper('bronto_reminder')->__('Conditions'),
20
  'comment' => Mage::helper('bronto_reminder')->__('Rule will work only if at least one condition is specified.'),
21
  ))->setRenderer($renderer);
22
 
23
  $fieldset->addField('conditions', 'text', array(
24
- 'name' => 'conditions',
25
  'required' => true,
26
  ))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
27
 
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Conditions extends Mage_Adminhtml_Block_Widget_Form
8
  {
9
  protected function _prepareForm()
10
  {
11
+ $form = new Varien_Data_Form();
12
  $model = Mage::registry('current_reminder_rule');
13
 
14
  $renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')
15
  ->setTemplate('promo/fieldset.phtml')
16
  ->setNewChildUrl($this->getUrl('*/*/newConditionHtml/form/rule_conditions_fieldset'));
17
  $fieldset = $form->addFieldset('rule_conditions_fieldset', array(
18
+ 'legend' => Mage::helper('bronto_reminder')->__('Conditions'),
19
  'comment' => Mage::helper('bronto_reminder')->__('Rule will work only if at least one condition is specified.'),
20
  ))->setRenderer($renderer);
21
 
22
  $fieldset->addField('conditions', 'text', array(
23
+ 'name' => 'conditions',
24
  'required' => true,
25
  ))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
26
 
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Customers.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_Adminhtml_Block_Widget_Grid
9
  {
@@ -15,7 +14,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_A
15
  parent::__construct();
16
  $this->setId('customerGrid');
17
  $this->setUseAjax(true);
18
- $this->setDefaultSort('email');
19
  $this->setDefaultDir('ASC');
20
  $this->setDefaultFilter(array('grid_is_active' => 1));
21
  }
@@ -42,35 +41,35 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_A
42
  protected function _prepareColumns()
43
  {
44
  $this->addColumn('grid_entity_id', array(
45
- 'header' => Mage::helper('bronto_reminder')->__('ID'),
46
- 'align' => 'center',
47
- 'width' => 50,
48
- 'index' => 'entity_id',
49
  'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_id'
50
  ));
51
 
52
  $this->addColumn('grid_email', array(
53
- 'header' => Mage::helper('bronto_reminder')->__('Email'),
54
- 'type' => 'text',
55
- 'align' => 'left',
56
- 'index' => 'email',
57
  'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_email'
58
  ));
59
 
60
  $this->addColumn('grid_associated_at', array(
61
- 'header' => Mage::helper('bronto_reminder')->__('Matched At'),
62
- 'align' => 'left',
63
- 'width' => 150,
64
- 'type' => 'datetime',
65
  'default' => '--',
66
- 'index' => 'associated_at'
67
  ));
68
 
69
  $this->addColumn('grid_is_active', array(
70
- 'header' => Mage::helper('bronto_reminder')->__('Thread Active'),
71
- 'align' => 'left',
72
- 'type' => 'options',
73
- 'index' => 'is_active',
74
  'options' => array(
75
  '0' => Mage::helper('bronto_reminder')->__('No'),
76
  '1' => Mage::helper('bronto_reminder')->__('Yes')
@@ -80,48 +79,48 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_A
80
  if (class_exists('Mage_SalesRule_Model_Coupon', false)) {
81
 
82
  $this->addColumn('grid_code', array(
83
- 'header' => Mage::helper('bronto_reminder')->__('Coupon'),
84
- 'align' => 'left',
85
  'default' => Mage::helper('bronto_reminder')->__('N/A'),
86
- 'index' => 'code'
87
  ));
88
 
89
  $this->addColumn('grid_usage_limit', array(
90
- 'header' => Mage::helper('bronto_reminder')->__('Coupon Usage Limit'),
91
- 'align' => 'left',
92
  'default' => '0',
93
- 'index' => 'usage_limit'
94
  ));
95
 
96
  $this->addColumn('grid_usage_per_customer', array(
97
- 'header' => Mage::helper('bronto_reminder')->__('Coupon Usage per Customer'),
98
- 'align' => 'left',
99
  'default' => '0',
100
- 'index' => 'usage_per_customer'
101
  ));
102
 
103
  }
104
 
105
  $this->addColumn('grid_emails_sent', array(
106
- 'header' => Mage::helper('bronto_reminder')->__('Emails Sent'),
107
- 'align' => 'left',
108
  'default' => '0',
109
- 'index' => 'emails_sent'
110
  ));
111
 
112
  $this->addColumn('grid_emails_failed', array(
113
  'header' => Mage::helper('bronto_reminder')->__('Emails Failed'),
114
- 'align' => 'left',
115
- 'index' => 'emails_failed'
116
  ));
117
 
118
  $this->addColumn('grid_last_sent', array(
119
- 'header' => Mage::helper('bronto_reminder')->__('Last Sent At'),
120
- 'align' => 'left',
121
- 'width' => 150,
122
- 'type' => 'datetime',
123
  'default' => '--',
124
- 'index' => 'last_sent'
125
  ));
126
 
127
  return parent::_prepareColumns();
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_Adminhtml_Block_Widget_Grid
8
  {
14
  parent::__construct();
15
  $this->setId('customerGrid');
16
  $this->setUseAjax(true);
17
+ $this->setDefaultSort('customer_email');
18
  $this->setDefaultDir('ASC');
19
  $this->setDefaultFilter(array('grid_is_active' => 1));
20
  }
41
  protected function _prepareColumns()
42
  {
43
  $this->addColumn('grid_entity_id', array(
44
+ 'header' => Mage::helper('bronto_reminder')->__('ID'),
45
+ 'align' => 'center',
46
+ 'width' => 50,
47
+ 'index' => 'customer_id',
48
  'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_id'
49
  ));
50
 
51
  $this->addColumn('grid_email', array(
52
+ 'header' => Mage::helper('bronto_reminder')->__('Email'),
53
+ 'type' => 'text',
54
+ 'align' => 'left',
55
+ 'index' => 'customer_email',
56
  'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_email'
57
  ));
58
 
59
  $this->addColumn('grid_associated_at', array(
60
+ 'header' => Mage::helper('bronto_reminder')->__('Matched At'),
61
+ 'align' => 'left',
62
+ 'width' => 150,
63
+ 'type' => 'datetime',
64
  'default' => '--',
65
+ 'index' => 'associated_at'
66
  ));
67
 
68
  $this->addColumn('grid_is_active', array(
69
+ 'header' => Mage::helper('bronto_reminder')->__('Thread Active'),
70
+ 'align' => 'left',
71
+ 'type' => 'options',
72
+ 'index' => 'is_active',
73
  'options' => array(
74
  '0' => Mage::helper('bronto_reminder')->__('No'),
75
  '1' => Mage::helper('bronto_reminder')->__('Yes')
79
  if (class_exists('Mage_SalesRule_Model_Coupon', false)) {
80
 
81
  $this->addColumn('grid_code', array(
82
+ 'header' => Mage::helper('bronto_reminder')->__('Coupon'),
83
+ 'align' => 'left',
84
  'default' => Mage::helper('bronto_reminder')->__('N/A'),
85
+ 'index' => 'code'
86
  ));
87
 
88
  $this->addColumn('grid_usage_limit', array(
89
+ 'header' => Mage::helper('bronto_reminder')->__('Coupon Usage Limit'),
90
+ 'align' => 'left',
91
  'default' => '0',
92
+ 'index' => 'usage_limit'
93
  ));
94
 
95
  $this->addColumn('grid_usage_per_customer', array(
96
+ 'header' => Mage::helper('bronto_reminder')->__('Coupon Usage per Customer'),
97
+ 'align' => 'left',
98
  'default' => '0',
99
+ 'index' => 'usage_per_customer'
100
  ));
101
 
102
  }
103
 
104
  $this->addColumn('grid_emails_sent', array(
105
+ 'header' => Mage::helper('bronto_reminder')->__('Emails Sent'),
106
+ 'align' => 'left',
107
  'default' => '0',
108
+ 'index' => 'emails_sent'
109
  ));
110
 
111
  $this->addColumn('grid_emails_failed', array(
112
  'header' => Mage::helper('bronto_reminder')->__('Emails Failed'),
113
+ 'align' => 'left',
114
+ 'index' => 'emails_failed'
115
  ));
116
 
117
  $this->addColumn('grid_last_sent', array(
118
+ 'header' => Mage::helper('bronto_reminder')->__('Last Sent At'),
119
+ 'align' => 'left',
120
+ 'width' => 150,
121
+ 'type' => 'datetime',
122
  'default' => '--',
123
+ 'index' => 'last_sent'
124
  ));
125
 
126
  return parent::_prepareColumns();
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/General.php CHANGED
@@ -1,20 +1,18 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adminhtml_Block_Widget_Form
9
  {
10
  protected function _prepareForm()
11
  {
12
- $form = new Varien_Data_Form();
13
  $model = Mage::registry('current_reminder_rule');
14
 
15
  $fieldset = $form->addFieldset('base_fieldset', array(
16
- 'legend' => Mage::helper('bronto_reminder')->__('General'),
17
- 'comment' => Mage::helper('bronto_reminder')->__('Reminder emails may promote a shopping cart price rule with or without coupon. If a shopping cart price rule defines an auto-generated coupon, this reminder rule will generate a random coupon code for each customer.'),
18
  ));
19
 
20
  if ($model->getId()) {
@@ -24,54 +22,40 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
24
  }
25
 
26
  $fieldset->addField('name', 'text', array(
27
- 'name' => 'name',
28
- 'label' => Mage::helper('bronto_reminder')->__('Rule Name'),
29
  'required' => true,
30
  ));
31
 
32
  $fieldset->addField('description', 'textarea', array(
33
- 'name' => 'description',
34
  'label' => Mage::helper('bronto_reminder')->__('Description'),
35
  'style' => 'width: 98%; height: 100px;',
36
  ));
37
 
38
- if (class_exists('Mage_Adminhtml_Block_Promo_Widget_Chooser', false)) {
39
-
40
- $field = $fieldset->addField('salesrule_id', 'note', array(
41
- 'name' => 'salesrule_id',
42
- 'label' => Mage::helper('bronto_reminder')->__('Shopping Cart Price Rule'),
43
- 'class' => 'widget-option',
44
- 'value' => $model->getSalesruleId(),
45
- 'note' => Mage::helper('bronto_reminder')->__('Promotion rule this reminder will advertise.'),
46
- ));
47
-
48
- $model->unsSalesruleId();
49
- $helperBlock = $this->getLayout()->createBlock('adminhtml/promo_widget_chooser');
50
-
51
- if ($helperBlock instanceof Varien_Object) {
52
- $helperBlock->setConfig($this->getChooserConfig())
53
- ->setFieldsetId($fieldset->getId())
54
- ->setTranslationHelper(Mage::helper('salesrule'))
55
- ->prepareElementHtml($field);
56
- }
57
-
58
- }
59
 
60
  if (!Mage::app()->isSingleStoreMode()) {
61
  $fieldset->addField('website_ids', 'multiselect', array(
62
- 'name' => 'website_ids',
63
  'required' => true,
64
- 'label' => Mage::helper('newsletter')->__('Assigned to Websites'),
65
- 'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(),
66
- 'value' => $model->getWebsiteIds()
67
  ));
68
  }
69
 
70
  $fieldset->addField('is_active', 'select', array(
71
- 'label' => Mage::helper('bronto_reminder')->__('Status'),
72
- 'name' => 'is_active',
73
  'required' => true,
74
- 'options' => array(
75
  '1' => Mage::helper('bronto_reminder')->__('Active'),
76
  '0' => Mage::helper('bronto_reminder')->__('Inactive'),
77
  ),
@@ -84,41 +68,67 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
84
  $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
85
 
86
  $fieldset->addField('active_from', 'date', array(
87
- 'name' => 'active_from',
88
- 'label' => Mage::helper('bronto_reminder')->__('Active From'),
89
- 'title' => Mage::helper('bronto_reminder')->__('Active From'),
90
- 'image' => $this->getSkinUrl('images/grid-cal.gif'),
91
  'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
92
- 'format' => $dateFormatIso
93
  ));
94
 
95
  $fieldset->addField('active_to', 'date', array(
96
- 'name' => 'active_to',
97
- 'label' => Mage::helper('bronto_reminder')->__('Active To'),
98
- 'title' => Mage::helper('bronto_reminder')->__('Active To'),
99
- 'image' => $this->getSkinUrl('images/grid-cal.gif'),
100
  'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
101
- 'format' => $dateFormatIso
102
  ));
103
 
104
- // $subfieldset = $form->addFieldset('sub_fieldset', array(
105
- // 'legend' => Mage::helper('bronto_reminder')->__('Repeat Schedule'),
106
- // 'comment' => '
107
- // By default, a rule will only send a Reminder Email to a customer once.
108
- // To allow a rule to re-send a message (as long as the conditions still match) to a customer, you must configure the Repeat Schedule.
109
- // ',
110
- // ));
111
- //
112
- // $subfieldset->addField('schedule', 'text', array(
113
- // 'name' => 'schedule',
114
- // 'label' => Mage::helper('bronto_reminder')->__('Schedule (Days)'),
115
- // 'note' => '
116
- // In what number of days to repeat reminder email, if the rule condition still matches. Enter days, comma-separated.<br/>
117
- // <strong>Examples:</strong><br/>
118
- // "<span style="font-family:monospace">0</span>": Message to be sent again the same day.<br/>
119
- // "<span style="font-family:monospace">1</span>": Message to be sent again the next day.<br/>
120
- // ',
121
- // ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  $form->setValues($model->getData());
124
  $this->setForm($form);
@@ -130,7 +140,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
130
  {
131
  return array(
132
  'button' => array('open' => 'Select Rule...'),
133
- 'type' => 'adminhtml/promo_widget_chooser_rule'
134
  );
135
  }
136
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adminhtml_Block_Widget_Form
8
  {
9
  protected function _prepareForm()
10
  {
11
+ $form = new Varien_Data_Form();
12
  $model = Mage::registry('current_reminder_rule');
13
 
14
  $fieldset = $form->addFieldset('base_fieldset', array(
15
+ 'legend' => Mage::helper('bronto_reminder')->__('General'),
 
16
  ));
17
 
18
  if ($model->getId()) {
22
  }
23
 
24
  $fieldset->addField('name', 'text', array(
25
+ 'name' => 'name',
26
+ 'label' => Mage::helper('bronto_reminder')->__('Rule Name'),
27
  'required' => true,
28
  ));
29
 
30
  $fieldset->addField('description', 'textarea', array(
31
+ 'name' => 'description',
32
  'label' => Mage::helper('bronto_reminder')->__('Description'),
33
  'style' => 'width: 98%; height: 100px;',
34
  ));
35
 
36
+ $fieldset->addField("salesrule_id", 'select', array(
37
+ 'name' => "salesrule_id",
38
+ 'required' => false,
39
+ 'label' => $this->__('Shopping Cart Price Rule Coupon Code'),
40
+ 'note' => $this->__('Use API tag <em>%%%%#couponCode%%%%</em> within your message in Bronto. You are responsible for ensuring the Shopping Cart Price Rule is active and valid, or else it may appear blank.'),
41
+ 'values' => Mage::helper('bronto_common/salesrule')->getRuleOptionsArray(),
42
+ ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  if (!Mage::app()->isSingleStoreMode()) {
45
  $fieldset->addField('website_ids', 'multiselect', array(
46
+ 'name' => 'website_ids',
47
  'required' => true,
48
+ 'label' => Mage::helper('newsletter')->__('Assigned to Websites'),
49
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(),
50
+ 'value' => $model->getWebsiteIds()
51
  ));
52
  }
53
 
54
  $fieldset->addField('is_active', 'select', array(
55
+ 'label' => Mage::helper('bronto_reminder')->__('Status'),
56
+ 'name' => 'is_active',
57
  'required' => true,
58
+ 'options' => array(
59
  '1' => Mage::helper('bronto_reminder')->__('Active'),
60
  '0' => Mage::helper('bronto_reminder')->__('Inactive'),
61
  ),
68
  $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
69
 
70
  $fieldset->addField('active_from', 'date', array(
71
+ 'name' => 'active_from',
72
+ 'label' => Mage::helper('bronto_reminder')->__('Active From'),
73
+ 'title' => Mage::helper('bronto_reminder')->__('Active From'),
74
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
75
  'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
76
+ 'format' => $dateFormatIso
77
  ));
78
 
79
  $fieldset->addField('active_to', 'date', array(
80
+ 'name' => 'active_to',
81
+ 'label' => Mage::helper('bronto_reminder')->__('Active To'),
82
+ 'title' => Mage::helper('bronto_reminder')->__('Active To'),
83
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
84
  'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
85
+ 'format' => $dateFormatIso
86
  ));
87
 
88
+ $fieldset->addField('send_to', 'select', array(
89
+ 'name' => 'send_to',
90
+ 'label' => Mage::helper('bronto_reminder')->__('Send To'),
91
+ 'title' => Mage::helper('bronto_reminder')->__('Send To'),
92
+ 'values' => array(
93
+ 'both' => Mage::helper('bronto_reminder')->__('Registered and Guest Users'),
94
+ 'user' => Mage::helper('bronto_reminder')->__('Registered Users'),
95
+ 'guest' => Mage::helper('bronto_reminder')->__('Guests'),
96
+ ),
97
+ 'value' => 'both',
98
+ 'note' => Mage::helper('bronto_reminder')->__('<strong>Note:</strong> Set to `Registered Users` or `Registered and Guest Users` if conditions will be applied to Wishlists, as only Registered Users can have Wishlists.'),
99
+ ));
100
+
101
+ $fieldset->addField('send_limit', 'text', array(
102
+ 'name' => 'send_limit',
103
+ 'label' => Mage::helper('bronto_reminder')->__('Send Limit'),
104
+ 'title' => Mage::helper('bronto_reminder')->__('Send Limit'),
105
+ 'value' => '1',
106
+ 'class' => 'validate-digits validate-digits-range digits-range-0-',
107
+ 'note' => Mage::helper('bronto_reminder')->__('This setting limits the number of times a single user will be sent this reminder email. 0 = unlimited.<br /><em>Default: 1</em>'),
108
+ ));
109
+
110
+ if (!$model->getId()) {
111
+ $model->setData('send_limit', '1');
112
+ }
113
+
114
+ // $subfieldset = $form->addFieldset('sub_fieldset', array(
115
+ // 'legend' => Mage::helper('bronto_reminder')->__('Repeat Schedule'),
116
+ // 'comment' => '
117
+ // By default, a rule will only send a Reminder Email to a customer once.
118
+ // To allow a rule to re-send a message (as long as the conditions still match) to a customer, you must configure the Repeat Schedule.
119
+ // ',
120
+ // ));
121
+ //
122
+ // $subfieldset->addField('schedule', 'text', array(
123
+ // 'name' => 'schedule',
124
+ // 'label' => Mage::helper('bronto_reminder')->__('Schedule (Days)'),
125
+ // 'note' => '
126
+ // In what number of days to repeat reminder email, if the rule condition still matches. Enter days, comma-separated.<br/>
127
+ // <strong>Examples:</strong><br/>
128
+ // "<span style="font-family:monospace">0</span>": Message to be sent again the same day.<br/>
129
+ // "<span style="font-family:monospace">1</span>": Message to be sent again the next day.<br/>
130
+ // ',
131
+ // ));
132
 
133
  $form->setValues($model->getData());
134
  $this->setForm($form);
140
  {
141
  return array(
142
  'button' => array('open' => 'Select Rule...'),
143
+ 'type' => 'adminhtml/promo_widget_chooser_rule'
144
  );
145
  }
146
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tabs.php CHANGED
@@ -1,16 +1,13 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
9
  {
10
  /**
11
- * Intialize form
12
- *
13
- * @return void
14
  */
15
  public function __construct()
16
  {
@@ -28,17 +25,17 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tabs extends Mage_Adminhtml_
28
  protected function _beforeToHtml()
29
  {
30
  $this->addTab('general_section', array(
31
- 'label' => Mage::helper('bronto_reminder')->__('Rule Information'),
32
  'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_general')->toHtml(),
33
  ));
34
 
35
  $this->addTab('conditions_section', array(
36
- 'label' => Mage::helper('bronto_reminder')->__('Conditions'),
37
  'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_conditions')->toHtml()
38
  ));
39
 
40
  $this->addTab('bronto_section', array(
41
- 'label' => Mage::helper('bronto_reminder')->__('Bronto Settings'),
42
  'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_bronto')->toHtml()
43
  ));
44
 
@@ -46,7 +43,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tabs extends Mage_Adminhtml_
46
  if ($rule && $rule->getId()) {
47
  $this->addTab('matched_customers', array(
48
  'label' => Mage::helper('bronto_reminder')->__('Matched Customers'),
49
- 'url' => $this->getUrl('*/*/customerGrid', array('rule_id' => $rule->getId())),
50
  'class' => 'ajax'
51
  ));
52
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
8
  {
9
  /**
10
+ * Initialize form
 
 
11
  */
12
  public function __construct()
13
  {
25
  protected function _beforeToHtml()
26
  {
27
  $this->addTab('general_section', array(
28
+ 'label' => Mage::helper('bronto_reminder')->__('Rule Information'),
29
  'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_general')->toHtml(),
30
  ));
31
 
32
  $this->addTab('conditions_section', array(
33
+ 'label' => Mage::helper('bronto_reminder')->__('Conditions'),
34
  'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_conditions')->toHtml()
35
  ));
36
 
37
  $this->addTab('bronto_section', array(
38
+ 'label' => Mage::helper('bronto_reminder')->__('Bronto Settings'),
39
  'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_bronto')->toHtml()
40
  ));
41
 
43
  if ($rule && $rule->getId()) {
44
  $this->addTab('matched_customers', array(
45
  'label' => Mage::helper('bronto_reminder')->__('Matched Customers'),
46
+ 'url' => $this->getUrl('*/*/customerGrid', array('rule_id' => $rule->getId())),
47
  'class' => 'ajax'
48
  ));
49
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Grid.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
  {
@@ -21,6 +20,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block
21
  $collection = Mage::getModel('bronto_reminder/rule')->getCollection();
22
  $collection->addWebsitesToResult();
23
  $this->setCollection($collection);
 
24
  return parent::_prepareCollection();
25
  }
26
 
@@ -28,41 +28,41 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block
28
  {
29
  $this->addColumn('rule_id', array(
30
  'header' => Mage::helper('bronto_reminder')->__('ID'),
31
- 'align' => 'right',
32
- 'width' => '50px',
33
- 'index' => 'rule_id',
34
  ));
35
 
36
  $this->addColumn('name', array(
37
  'header' => Mage::helper('bronto_reminder')->__('Rule Name'),
38
- 'align' => 'left',
39
- 'index' => 'name',
40
  ));
41
 
42
  $this->addColumn('from_date', array(
43
- 'header' => Mage::helper('bronto_reminder')->__('Active From'),
44
- 'align' => 'left',
45
- 'width' => '120px',
46
- 'type' => 'date',
47
  'default' => '--',
48
- 'index' => 'active_from',
49
  ));
50
 
51
  $this->addColumn('to_date', array(
52
- 'header' => Mage::helper('bronto_reminder')->__('Active To'),
53
- 'align' => 'left',
54
- 'width' => '120px',
55
- 'type' => 'date',
56
  'default' => '--',
57
- 'index' => 'active_to',
58
  ));
59
 
60
  $this->addColumn('is_active', array(
61
- 'header' => Mage::helper('bronto_reminder')->__('Status'),
62
- 'align' => 'left',
63
- 'width' => '80px',
64
- 'index' => 'is_active',
65
- 'type' => 'options',
66
  'options' => array(
67
  1 => 'Active',
68
  0 => 'Inactive',
@@ -71,15 +71,16 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block
71
 
72
  if (!Mage::app()->isSingleStoreMode()) {
73
  $this->addColumn('rule_website', array(
74
- 'header' => Mage::helper('bronto_reminder')->__('Website'),
75
- 'align' => 'left',
76
- 'index' => 'website_ids',
77
- 'type' => 'options',
78
  'sortable' => false,
79
- 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(),
80
- 'width' => 200,
81
  ));
82
  }
 
83
  return parent::_prepareColumns();
84
  }
85
 
@@ -87,6 +88,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block
87
  * Return url for current row
88
  *
89
  * @param Bronto_Reminder_Model_Rule $row
 
90
  * @return string
91
  */
92
  public function getRowUrl($row)
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
  {
20
  $collection = Mage::getModel('bronto_reminder/rule')->getCollection();
21
  $collection->addWebsitesToResult();
22
  $this->setCollection($collection);
23
+
24
  return parent::_prepareCollection();
25
  }
26
 
28
  {
29
  $this->addColumn('rule_id', array(
30
  'header' => Mage::helper('bronto_reminder')->__('ID'),
31
+ 'align' => 'right',
32
+ 'width' => '50px',
33
+ 'index' => 'rule_id',
34
  ));
35
 
36
  $this->addColumn('name', array(
37
  'header' => Mage::helper('bronto_reminder')->__('Rule Name'),
38
+ 'align' => 'left',
39
+ 'index' => 'name',
40
  ));
41
 
42
  $this->addColumn('from_date', array(
43
+ 'header' => Mage::helper('bronto_reminder')->__('Active From'),
44
+ 'align' => 'left',
45
+ 'width' => '120px',
46
+ 'type' => 'date',
47
  'default' => '--',
48
+ 'index' => 'active_from',
49
  ));
50
 
51
  $this->addColumn('to_date', array(
52
+ 'header' => Mage::helper('bronto_reminder')->__('Active To'),
53
+ 'align' => 'left',
54
+ 'width' => '120px',
55
+ 'type' => 'date',
56
  'default' => '--',
57
+ 'index' => 'active_to',
58
  ));
59
 
60
  $this->addColumn('is_active', array(
61
+ 'header' => Mage::helper('bronto_reminder')->__('Status'),
62
+ 'align' => 'left',
63
+ 'width' => '80px',
64
+ 'index' => 'is_active',
65
+ 'type' => 'options',
66
  'options' => array(
67
  1 => 'Active',
68
  0 => 'Inactive',
71
 
72
  if (!Mage::app()->isSingleStoreMode()) {
73
  $this->addColumn('rule_website', array(
74
+ 'header' => Mage::helper('bronto_reminder')->__('Website'),
75
+ 'align' => 'left',
76
+ 'index' => 'website_ids',
77
+ 'type' => 'options',
78
  'sortable' => false,
79
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(),
80
+ 'width' => 200,
81
  ));
82
  }
83
+
84
  return parent::_prepareColumns();
85
  }
86
 
88
  * Return url for current row
89
  *
90
  * @param Bronto_Reminder_Model_Rule $row
91
+ *
92
  * @return string
93
  */
94
  public function getRowUrl($row)
app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/About.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
9
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
8
  {
app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/Cron.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
9
  {
@@ -11,4 +10,14 @@ class Bronto_Reminder_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
11
  * @var string
12
  */
13
  protected $_jobCode = 'bronto_reminder_send_notification';
 
 
 
 
 
 
 
 
 
 
14
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
8
  {
10
  * @var string
11
  */
12
  protected $_jobCode = 'bronto_reminder_send_notification';
13
+
14
+ /**
15
+ * Determine if should show the cron table
16
+ *
17
+ * @return mixed
18
+ */
19
+ public function showCronTable()
20
+ {
21
+ return Mage::helper('bronto_reminder')->canUseMageCron();
22
+ }
23
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/Settings.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_System_Config_Settings
9
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
@@ -12,12 +11,14 @@ class Bronto_Reminder_Block_Adminhtml_System_Config_Settings
12
  * Return header comment part of html for fieldset
13
  *
14
  * @param Varien_Data_Form_Element_Abstract $element
 
15
  * @return string
16
  */
17
- protected function _getHeaderCommentHtml($element)
18
  {
19
- $url = Mage::helper('adminhtml')->getUrl('/reminders');
20
  $element->setComment("Additional configuration located at: <strong>Promotions &rsaquo; <a href=\"{$url}\">Bronto Reminder Emails</a></strong><br/><br/>");
21
- return parent::_getHeaderCommentHtml($element);
 
22
  }
23
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_System_Config_Settings
8
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
11
  * Return header comment part of html for fieldset
12
  *
13
  * @param Varien_Data_Form_Element_Abstract $element
14
+ *
15
  * @return string
16
  */
17
+ public function render(Varien_Data_Form_Element_Abstract $element)
18
  {
19
+ $url = Mage::helper('adminhtml')->getUrl('*/reminders');
20
  $element->setComment("Additional configuration located at: <strong>Promotions &rsaquo; <a href=\"{$url}\">Bronto Reminder Emails</a></strong><br/><br/>");
21
+
22
+ return parent::render($element);
23
  }
24
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Widget/Grid/Column/Renderer/Email.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Widget_Grid_Column_Renderer_Email extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
  {
@@ -11,11 +10,13 @@ class Bronto_Reminder_Block_Adminhtml_Widget_Grid_Column_Renderer_Email extends
11
  * Render customer email as mailto link
12
  *
13
  * @param Varien_Object $row
 
14
  * @return string
15
  */
16
  protected function _getValue(Varien_Object $row)
17
  {
18
  $customerEmail = $this->htmlEscape($row->getData($this->getColumn()->getIndex()));
 
19
  return $this->htmlEscape($customerEmail);
20
  }
21
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Widget_Grid_Column_Renderer_Email extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
  {
10
  * Render customer email as mailto link
11
  *
12
  * @param Varien_Object $row
13
+ *
14
  * @return string
15
  */
16
  protected function _getValue(Varien_Object $row)
17
  {
18
  $customerEmail = $this->htmlEscape($row->getData($this->getColumn()->getIndex()));
19
+
20
  return $this->htmlEscape($customerEmail);
21
  }
22
  }
app/code/community/Bronto/Reminder/Block/Adminhtml/Widget/Grid/Column/Renderer/Id.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Block_Adminhtml_Widget_Grid_Column_Renderer_Id extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
  {
@@ -11,14 +10,19 @@ class Bronto_Reminder_Block_Adminhtml_Widget_Grid_Column_Renderer_Id extends Mag
11
  * Render customer id linked to its account edit page
12
  *
13
  * @param Varien_Object $row
 
14
  * @return string
15
  */
16
  protected function _getValue(Varien_Object $row)
17
  {
18
- $customerId = $this->htmlEscape($row->getData($this->getColumn()->getIndex()));
19
- if (is_null($customerId)) {
 
 
20
  return 'Guest';
21
  }
 
 
22
  return '<a href="' . Mage::getSingleton('adminhtml/url')->getUrl('*/customer/edit',
23
  array('id' => $customerId)) . '">' . $customerId . '</a>';
24
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Block_Adminhtml_Widget_Grid_Column_Renderer_Id extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
  {
10
  * Render customer id linked to its account edit page
11
  *
12
  * @param Varien_Object $row
13
+ *
14
  * @return string
15
  */
16
  protected function _getValue(Varien_Object $row)
17
  {
18
+ $customerId = (int)$row->getData($this->getColumn()->getIndex());
19
+
20
+ // If We don't have a customer ID, label as Guest
21
+ if (!$customerId) {
22
  return 'Guest';
23
  }
24
+
25
+ // Create link to edit customer for customer ID
26
  return '<a href="' . Mage::getSingleton('adminhtml/url')->getUrl('*/customer/edit',
27
  array('id' => $customerId)) . '">' . $customerId . '</a>';
28
  }
app/code/community/Bronto/Reminder/Helper/Contact.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Helper_Contact extends Bronto_Common_Helper_Contact
9
  {
@@ -18,7 +17,12 @@ class Bronto_Reminder_Helper_Contact extends Bronto_Common_Helper_Contact
18
  }
19
 
20
  /**
 
 
21
  * @param string $email
 
 
 
22
  * @return Bronto_Api_Contact_Row
23
  */
24
  public function getContactByEmail($email, $customSource = 'bronto_reminder', $store = null)
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Helper_Contact extends Bronto_Common_Helper_Contact
8
  {
17
  }
18
 
19
  /**
20
+ * Get Bronto Contact Object by Email Address
21
+ *
22
  * @param string $email
23
+ * @param string $customSource
24
+ * @param null $store
25
+ *
26
  * @return Bronto_Api_Contact_Row
27
  */
28
  public function getContactByEmail($email, $customSource = 'bronto_reminder', $store = null)
app/code/community/Bronto/Reminder/Helper/Data.php CHANGED
@@ -1,21 +1,41 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
9
  {
10
- const XML_PATH_ENABLED = 'bronto_reminder/settings/enabled';
11
- const XML_PATH_ALLOW_SEND = 'bronto_reminder/settings/allow_send';
12
- const XML_PATH_TIME = 'bronto_reminder/settings/time';
13
- const XML_PATH_INTERVAL = 'bronto_reminder/settings/interval';
14
- const XML_PATH_FREQUENCY = 'bronto_reminder/settings/frequency';
15
- const XML_PATH_FREQUENCY_MIN = 'bronto_reminder/settings/minutes';
16
- const XML_PATH_SEND_LIMIT = 'bronto_reminder/settings/limit';
17
- const XML_PATH_EMAIL_IDENTITY = 'bronto_reminder/settings/identity';
18
- const XML_PATH_EMAIL_THRESHOLD = 'bronto_reminder/settings/threshold';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  /**
21
  * Retrieve helper module name
@@ -29,24 +49,33 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
29
 
30
  /**
31
  * Get link to transactional email configuration
32
- * @return type
 
33
  */
34
  public function getConfigLink()
35
  {
36
- $url = $this->getScopeUrl('/system_config/edit/section/bronto_reminder');
 
37
  return '<strong>System &rsaquo; Configuration &raquo; Bronto &rsaquo; <a href="' . $url . '" title="Reminder Emails">Reminder Emails</a></strong>';
38
  }
39
 
40
  /**
 
 
 
 
 
41
  * @return bool
42
  */
43
- public function isEnabled($store = null)
44
  {
45
- if (!$this->getApiToken($store)) {
 
46
  return false;
47
  }
48
 
49
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $store);
 
50
  }
51
 
52
  /*
@@ -56,7 +85,7 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
56
  */
57
  public function getModuleEnabledText()
58
  {
59
- $message = parent::getModuleEnabledText();
60
  $scopeData = $this->getScopeParams();
61
  if ($scopeData['scope'] != 'default') {
62
  $url = Mage::helper('adminhtml')->getUrl('/reminders');
@@ -67,6 +96,7 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
67
  'to use a message from the corresponding Bronto account.'
68
  );
69
  }
 
70
  return $message;
71
  }
72
 
@@ -80,25 +110,73 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
80
  $stores = Mage::app()->getStores();
81
  if (is_array($stores) && count($stores) >= 1) {
82
  foreach ($stores as $store) {
83
- if ($this->isEnabled($store->getId())) {
84
  return true;
85
  }
86
  }
87
  }
 
88
  return false;
89
  }
90
 
91
  /**
92
- * @param null|string|bool|int|Mage_Core_Model_Store $store
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  * @return bool
94
  */
95
- public function isAllowSend($store = null)
96
  {
97
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ALLOW_SEND, $store);
98
  }
99
 
100
  /**
101
  * Determine if any stores are allowed to send
 
102
  * @return bool
103
  */
104
  public function isAllowSendForAny()
@@ -106,22 +184,26 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
106
  $stores = Mage::app()->getStores();
107
  if (is_array($stores) && count($stores) >= 1) {
108
  foreach ($stores as $store) {
109
- if ($this->isAllowSend($store->getId())) {
110
  return true;
111
  }
112
  }
113
  }
 
 
114
  }
115
 
116
  /**
117
  * Determine if email can be sent through bronto
118
  *
119
  * @param Mage_Core_Model_Email_Template $template
120
- * @return boolean
 
 
121
  */
122
  public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
123
  {
124
- if ($this->isEnabled($storeId)) {
125
  return true;
126
  }
127
 
@@ -130,11 +212,12 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
130
 
131
  /**
132
  * Text to display when reminder module not allowed to send emails
133
- * @return type
 
134
  */
135
  public function getNotAllowedText()
136
  {
137
- $url = $this->getScopeUrl('/system_config/edit/section/bronto_reminder');
138
  $messageText = $this->__('Rules are currently unable to send emails.
139
  You can enable this function in the System Configuration <a href="' . $url . '">Reminder Emails</a>');
140
 
@@ -142,13 +225,17 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
142
  }
143
 
144
  /**
145
- * @param string $path
 
 
 
 
146
  *
147
  * @return bool
148
  */
149
- public function disableModule($scope = 'default', $scopeId = 0)
150
  {
151
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
152
  }
153
 
154
  /**
@@ -212,7 +299,8 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
212
  * @see parent
213
  * @return boolean
214
  */
215
- public function hasCustomConfig() {
 
216
  return true;
217
  }
218
 
@@ -221,9 +309,10 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
221
  *
222
  * @return array
223
  */
224
- public function getCustomConfig() {
 
225
  $ruleMeta = Mage::getModel('bronto_reminder/rule');
226
- $rules = $ruleMeta->getCollection()->getItems();
227
 
228
  $data = array();
229
  if (empty($rules)) {
@@ -235,12 +324,12 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
235
  $root = $rule->getConditions();
236
 
237
  $reminders[] = array(
238
- 'name' => $rule->getName(),
239
- 'active' => $rule->getIsActive(),
240
- 'from' => $rule->getFromDate(),
241
- 'to' => $rule->getToDate(),
242
  'conditions' => array(
243
- 'label' => $root->asString(),
244
  'conditions' => $this->_recursiveConditionLog($root),
245
  ),
246
  );
@@ -254,9 +343,11 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
254
  * Formats the conditions for the root condition
255
  *
256
  * @param mixed $condition
 
257
  * @return string
258
  */
259
- protected function _recursiveConditionLog($condition) {
 
260
  $conditions = array();
261
 
262
  foreach ($condition->getConditions() as $childCondition) {
@@ -265,7 +356,7 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
265
  $html = preg_replace('|\s+|s', ' ', strip_tags($html));
266
 
267
  $conditions[] = array(
268
- 'label' => trim($html),
269
  'conditions' => $this->_recursiveConditionLog($childCondition),
270
  );
271
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
8
  {
9
+ const XML_PATH_ENABLED = 'bronto_reminder/settings/enabled';
10
+ const XML_PATH_MAGE_CRON = 'bronto_reminder/settings/mage_cron';
11
+ const XML_PATH_LOG_ENABLED = 'bronto_reminder/settings/log_enabled';
12
+ const XML_PATH_LOG_FIELDS_ENABLED = 'bronto_reminder/settings/log_fields_enabled';
13
+ const XML_PATH_ALLOW_SEND = 'bronto_reminder/settings/allow_send';
14
+ const XML_PATH_TIME = 'bronto_reminder/settings/time';
15
+ const XML_PATH_INTERVAL = 'bronto_reminder/settings/interval';
16
+ const XML_PATH_FREQUENCY = 'bronto_reminder/settings/frequency';
17
+ const XML_PATH_FREQUENCY_MIN = 'bronto_reminder/settings/minutes';
18
+ const XML_PATH_SEND_LIMIT = 'bronto_reminder/settings/limit';
19
+ const XML_PATH_EMAIL_IDENTITY = 'bronto_reminder/settings/identity';
20
+ const XML_PATH_EMAIL_THRESHOLD = 'bronto_reminder/settings/threshold';
21
+
22
+ const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_reminder_send_notification/schedule/cron_expr';
23
+ const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_reminder_send_notification/run/model';
24
+
25
+ /**
26
+ * Module Human Readable Name
27
+ */
28
+ protected $_name = 'Bronto Reminder Emails';
29
+
30
+ /**
31
+ * Get Human Readable Name
32
+ *
33
+ * @return string
34
+ */
35
+ public function getName()
36
+ {
37
+ return $this->__($this->_name);
38
+ }
39
 
40
  /**
41
  * Retrieve helper module name
49
 
50
  /**
51
  * Get link to transactional email configuration
52
+ *
53
+ * @return string
54
  */
55
  public function getConfigLink()
56
  {
57
+ $url = $this->getScopeUrl('*/system_config/edit', array('section' => 'bronto_reminder'));
58
+
59
  return '<strong>System &rsaquo; Configuration &raquo; Bronto &rsaquo; <a href="' . $url . '" title="Reminder Emails">Reminder Emails</a></strong>';
60
  }
61
 
62
  /**
63
+ * Check if module is enabled
64
+ *
65
+ * @param string $scope
66
+ * @param int $scopeId
67
+ *
68
  * @return bool
69
  */
70
+ public function isEnabled($scope = 'default', $scopeId = 0)
71
  {
72
+ // Check if valid token is present
73
+ if (!$this->validApiToken(null, $scope, $scopeId)) {
74
  return false;
75
  }
76
 
77
+ // Get Enabled Scope
78
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
79
  }
80
 
81
  /*
85
  */
86
  public function getModuleEnabledText()
87
  {
88
+ $message = parent::getModuleEnabledText();
89
  $scopeData = $this->getScopeParams();
90
  if ($scopeData['scope'] != 'default') {
91
  $url = Mage::helper('adminhtml')->getUrl('/reminders');
96
  'to use a message from the corresponding Bronto account.'
97
  );
98
  }
99
+
100
  return $message;
101
  }
102
 
110
  $stores = Mage::app()->getStores();
111
  if (is_array($stores) && count($stores) >= 1) {
112
  foreach ($stores as $store) {
113
+ if ($this->isEnabled('store', $store->getId())) {
114
  return true;
115
  }
116
  }
117
  }
118
+
119
  return false;
120
  }
121
 
122
  /**
123
+ * Check if module can use the magento cron
124
+ *
125
+ * @return bool
126
+ */
127
+ public function canUseMageCron()
128
+ {
129
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
130
+ }
131
+
132
+ /**
133
+ * @return string
134
+ */
135
+ public function getCronStringPath()
136
+ {
137
+ return self::XML_PATH_CRON_STRING;
138
+ }
139
+
140
+ /**
141
+ * @return string
142
+ */
143
+ public function getCronModelPath()
144
+ {
145
+ return self::XML_PATH_CRON_MODEL;
146
+ }
147
+
148
+ /**
149
+ * @return bool
150
+ */
151
+ public function isLogEnabled()
152
+ {
153
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_LOG_ENABLED);
154
+ }
155
+
156
+ /**
157
+ * @return bool
158
+ */
159
+ public function isLogFieldsEnabled()
160
+ {
161
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_LOG_FIELDS_ENABLED);
162
+ }
163
+
164
+ /**
165
+ * Determine if Allowed to send
166
+ *
167
+ * @param string $scope
168
+ * @param int $scopeId
169
+ *
170
  * @return bool
171
  */
172
+ public function isAllowSend($scope = 'default', $scopeId = 0)
173
  {
174
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ALLOW_SEND, $scope, $scopeId);
175
  }
176
 
177
  /**
178
  * Determine if any stores are allowed to send
179
+ *
180
  * @return bool
181
  */
182
  public function isAllowSendForAny()
184
  $stores = Mage::app()->getStores();
185
  if (is_array($stores) && count($stores) >= 1) {
186
  foreach ($stores as $store) {
187
+ if ($this->isAllowSend('store', $store->getId())) {
188
  return true;
189
  }
190
  }
191
  }
192
+
193
+ return false;
194
  }
195
 
196
  /**
197
  * Determine if email can be sent through bronto
198
  *
199
  * @param Mage_Core_Model_Email_Template $template
200
+ * @param null $storeId
201
+ *
202
+ * @return bool
203
  */
204
  public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
205
  {
206
+ if ($this->isEnabled('store', $storeId)) {
207
  return true;
208
  }
209
 
212
 
213
  /**
214
  * Text to display when reminder module not allowed to send emails
215
+ *
216
+ * @return string
217
  */
218
  public function getNotAllowedText()
219
  {
220
+ $url = $this->getScopeUrl('/system_config/edit/section/bronto_reminder');
221
  $messageText = $this->__('Rules are currently unable to send emails.
222
  You can enable this function in the System Configuration <a href="' . $url . '">Reminder Emails</a>');
223
 
225
  }
226
 
227
  /**
228
+ * Disable Specified Module
229
+ *
230
+ * @param string $scope
231
+ * @param int $scopeId
232
+ * @param bool $deleteConfig
233
  *
234
  * @return bool
235
  */
236
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
237
  {
238
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
239
  }
240
 
241
  /**
299
  * @see parent
300
  * @return boolean
301
  */
302
+ public function hasCustomConfig()
303
+ {
304
  return true;
305
  }
306
 
309
  *
310
  * @return array
311
  */
312
+ public function getCustomConfig()
313
+ {
314
  $ruleMeta = Mage::getModel('bronto_reminder/rule');
315
+ $rules = $ruleMeta->getCollection()->getItems();
316
 
317
  $data = array();
318
  if (empty($rules)) {
324
  $root = $rule->getConditions();
325
 
326
  $reminders[] = array(
327
+ 'name' => $rule->getName(),
328
+ 'active' => $rule->getIsActive(),
329
+ 'from' => $rule->getFromDate(),
330
+ 'to' => $rule->getToDate(),
331
  'conditions' => array(
332
+ 'label' => $root->asString(),
333
  'conditions' => $this->_recursiveConditionLog($root),
334
  ),
335
  );
343
  * Formats the conditions for the root condition
344
  *
345
  * @param mixed $condition
346
+ *
347
  * @return string
348
  */
349
+ protected function _recursiveConditionLog($condition)
350
+ {
351
  $conditions = array();
352
 
353
  foreach ($condition->getConditions() as $childCondition) {
356
  $html = preg_replace('|\s+|s', ' ', strip_tags($html));
357
 
358
  $conditions[] = array(
359
+ 'label' => trim($html),
360
  'conditions' => $this->_recursiveConditionLog($childCondition),
361
  );
362
  }
app/code/community/Bronto/Reminder/Helper/Message.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Helper_Message extends Bronto_Common_Helper_Message
9
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Helper_Message extends Bronto_Common_Helper_Message
8
  {
app/code/community/Bronto/Reminder/Model/Condition/Abstract.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition_Abstract
9
  {
10
  /**
11
  * Customize default operator input by type mapper for some types
 
12
  * @return array
13
  */
14
  public function getDefaultOperatorInputByType()
@@ -16,8 +16,9 @@ class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition
16
  if (null === $this->_defaultOperatorInputByType) {
17
  parent::getDefaultOperatorInputByType();
18
  $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
19
- $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
20
  }
 
21
  return $this->_defaultOperatorInputByType;
22
  }
23
 
@@ -34,8 +35,8 @@ class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition
34
  /**
35
  * Generate customer condition string
36
  *
37
- * @param $customer
38
- * @param string $fieldName
39
  * @return string
40
  */
41
  protected function _createCustomerFilter($fieldName)
@@ -46,9 +47,10 @@ class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition
46
  /**
47
  * Limit select by website with joining to store table
48
  *
49
- * @param Zend_Db_Select $select
50
  * @param int | Zend_Db_Expr $website
51
- * @param string $storeIdField
 
52
  * @return Bronto_Reminder_Model_Condition_Abstract
53
  */
54
  protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
@@ -56,6 +58,7 @@ class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition
56
  $storeTable = $this->getResource()->getTable('core/store');
57
  $select->join(array('store' => $storeTable), $storeIdField . '=store.store_id', array())
58
  ->where('store.website_id=?', $website);
 
59
  return $this;
60
  }
61
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition_Abstract
8
  {
9
  /**
10
  * Customize default operator input by type mapper for some types
11
+ *
12
  * @return array
13
  */
14
  public function getDefaultOperatorInputByType()
16
  if (null === $this->_defaultOperatorInputByType) {
17
  parent::getDefaultOperatorInputByType();
18
  $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
19
+ $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
20
  }
21
+
22
  return $this->_defaultOperatorInputByType;
23
  }
24
 
35
  /**
36
  * Generate customer condition string
37
  *
38
+ * @param $fieldName
39
+ *
40
  * @return string
41
  */
42
  protected function _createCustomerFilter($fieldName)
47
  /**
48
  * Limit select by website with joining to store table
49
  *
50
+ * @param Zend_Db_Select $select
51
  * @param int | Zend_Db_Expr $website
52
+ * @param string $storeIdField
53
+ *
54
  * @return Bronto_Reminder_Model_Condition_Abstract
55
  */
56
  protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
58
  $storeTable = $this->getResource()->getTable('core/store');
59
  $select->join(array('store' => $storeTable), $storeIdField . '=store.store_id', array())
60
  ->where('store.website_id=?', $website);
61
+
62
  return $this;
63
  }
64
  }
app/code/community/Bronto/Reminder/Model/Condition/Combine/Abstract.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rule_Model_Condition_Combine
9
  {
@@ -17,16 +16,18 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
17
  if (null === $this->_defaultOperatorInputByType) {
18
  parent::getDefaultOperatorInputByType();
19
  $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
20
- $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
21
  }
 
22
  return $this->_defaultOperatorInputByType;
23
  }
24
 
25
  /**
26
  * Add operator when loading array
27
  *
28
- * @param array $arr
29
  * @param string $key
 
30
  * @return Bronto_Reminder_Model_Rule_Condition_Combine
31
  */
32
  public function loadArray($arr, $key = 'conditions')
@@ -56,6 +57,7 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
56
  * Get filter by customer condition for rule matching sql
57
  *
58
  * @param string $fieldName
 
59
  * @return string
60
  */
61
  protected function _createCustomerFilter($fieldName)
@@ -68,14 +70,16 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
68
  *
69
  * @param $rule
70
  * @param $website
 
71
  * @return Varien_Db_Select
72
  */
73
  protected function _prepareConditionsSql($rule, $website)
74
  {
75
  $select = $this->getResource()->createSelect();
76
- $table = $this->getResource()->getTable('customer/entity');
77
  $select->from($table, array(new Zend_Db_Expr(1)));
78
  $select->where($this->_createCustomerFilter('entity_id'));
 
79
  return $select;
80
  }
81
 
@@ -94,6 +98,7 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
94
  *
95
  * @param $rule
96
  * @param $website
 
97
  * @return Varien_Db_Select
98
  */
99
  public function getConditionsSql($rule, $website)
@@ -101,10 +106,10 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
101
  /**
102
  * Build base SQL
103
  */
104
- $select = $this->_prepareConditionsSql($rule, $website);
105
- $required = $this->_getRequiredValidation();
106
  $whereFunction = ($this->getAggregator() == 'all') ? 'where' : 'orWhere';
107
- $operator = $required ? '=' : '<>';
108
  //$operator = '=';
109
 
110
  $gotConditions = false;
@@ -145,7 +150,7 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
145
  }
146
 
147
  /**
148
- * Get infromation about subfilters map. Map contain children condition type and associated
149
  * column name from itself select.
150
  * Example: array('my_subtype'=>'my_table.my_column')
151
  * In practice - date range can be as subfilter for different types of condition combines.
@@ -161,9 +166,10 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
161
  /**
162
  * Limit select by website with joining to store table
163
  *
164
- * @param Zend_Db_Select $select
165
  * @param int|Zend_Db_Expr $website
166
- * @param string $storeIdField
 
167
  * @return Bronto_Reminder_Model_Condition_Abstract
168
  */
169
  protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
@@ -171,6 +177,7 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
171
  $storeTable = $this->getResource()->getTable('core/store');
172
  $select->join(array('store' => $storeTable), $storeIdField . '=store.store_id', array())
173
  ->where('store.website_id=?', $website);
 
174
  return $this;
175
  }
176
 
@@ -182,6 +189,7 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
182
  if (method_exists('Mage_Rule_Model_Condition_Combine', '_getRecursiveChildSelectOption')) {
183
  return parent::_getRecursiveChildSelectOption();
184
  }
 
185
  return array('value' => $this->getType(), 'label' => Mage::helper('rule')->__('Conditions Combination'));
186
  }
187
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rule_Model_Condition_Combine
8
  {
16
  if (null === $this->_defaultOperatorInputByType) {
17
  parent::getDefaultOperatorInputByType();
18
  $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
19
+ $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
20
  }
21
+
22
  return $this->_defaultOperatorInputByType;
23
  }
24
 
25
  /**
26
  * Add operator when loading array
27
  *
28
+ * @param array $arr
29
  * @param string $key
30
+ *
31
  * @return Bronto_Reminder_Model_Rule_Condition_Combine
32
  */
33
  public function loadArray($arr, $key = 'conditions')
57
  * Get filter by customer condition for rule matching sql
58
  *
59
  * @param string $fieldName
60
+ *
61
  * @return string
62
  */
63
  protected function _createCustomerFilter($fieldName)
70
  *
71
  * @param $rule
72
  * @param $website
73
+ *
74
  * @return Varien_Db_Select
75
  */
76
  protected function _prepareConditionsSql($rule, $website)
77
  {
78
  $select = $this->getResource()->createSelect();
79
+ $table = $this->getResource()->getTable('customer/entity');
80
  $select->from($table, array(new Zend_Db_Expr(1)));
81
  $select->where($this->_createCustomerFilter('entity_id'));
82
+
83
  return $select;
84
  }
85
 
98
  *
99
  * @param $rule
100
  * @param $website
101
+ *
102
  * @return Varien_Db_Select
103
  */
104
  public function getConditionsSql($rule, $website)
106
  /**
107
  * Build base SQL
108
  */
109
+ $select = $this->_prepareConditionsSql($rule, $website);
110
+ $required = $this->_getRequiredValidation();
111
  $whereFunction = ($this->getAggregator() == 'all') ? 'where' : 'orWhere';
112
+ $operator = $required ? '=' : '<>';
113
  //$operator = '=';
114
 
115
  $gotConditions = false;
150
  }
151
 
152
  /**
153
+ * Get information about subfilters map. Map contain children condition type and associated
154
  * column name from itself select.
155
  * Example: array('my_subtype'=>'my_table.my_column')
156
  * In practice - date range can be as subfilter for different types of condition combines.
166
  /**
167
  * Limit select by website with joining to store table
168
  *
169
+ * @param Zend_Db_Select $select
170
  * @param int|Zend_Db_Expr $website
171
+ * @param string $storeIdField
172
+ *
173
  * @return Bronto_Reminder_Model_Condition_Abstract
174
  */
175
  protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
177
  $storeTable = $this->getResource()->getTable('core/store');
178
  $select->join(array('store' => $storeTable), $storeIdField . '=store.store_id', array())
179
  ->where('store.website_id=?', $website);
180
+
181
  return $this;
182
  }
183
 
189
  if (method_exists('Mage_Rule_Model_Condition_Combine', '_getRecursiveChildSelectOption')) {
190
  return parent::_getRecursiveChildSelectOption();
191
  }
192
+
193
  return array('value' => $this->getType(), 'label' => Mage::helper('rule')->__('Conditions Combination'));
194
  }
195
  }
app/code/community/Bronto/Reminder/Model/Delivery.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Model_Delivery extends Mage_Core_Model_Abstract
8
+ {
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->_init('bronto_reminder/delivery');
13
+ }
14
+ }
app/code/community/Bronto/Reminder/Model/Email/Message.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Email_Message extends Bronto_Common_Model_Email_Template
9
  {
@@ -17,15 +16,43 @@ class Bronto_Reminder_Model_Email_Message extends Bronto_Common_Model_Email_Temp
17
  */
18
  protected $_apiLogFile = 'bronto_reminder_api.log';
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Log the Delivery API call
22
  *
23
- * @param boolean $success
24
- * @param string $error (Optional)
25
- * @param Bronto_Api_Delivery_Row $delivery (Optional)
 
 
26
  */
27
  protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
28
  {
 
 
29
  if (!is_null($delivery)) {
30
  $helper = Mage::helper($this->_helper);
31
  $status = $success ? "Successful" : "Failed";
@@ -34,5 +61,20 @@ class Bronto_Reminder_Model_Email_Message extends Bronto_Common_Model_Email_Temp
34
  $helper->writeVerboseDebug(var_export($delivery->getApi()->getLastRequest(), true), $this->_apiLogFile);
35
  $helper->writeVerboseDebug(var_export($delivery->getApi()->getLastResponse(), true), $this->_apiLogFile);
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Email_Message extends Bronto_Common_Model_Email_Template
8
  {
16
  */
17
  protected $_apiLogFile = 'bronto_reminder_api.log';
18
 
19
+ /**
20
+ * Log about the functionality of sending the email before it goes out
21
+ *
22
+ * @param Bronto_Api_Contact_Row $contact
23
+ * @param Bronto_Api_Message_Row $message
24
+ *
25
+ * @return void
26
+ */
27
+ protected function _beforeSend(Bronto_Api_Contact_Row $contact, Bronto_Api_Message_Row $message)
28
+ {
29
+ Mage::dispatchEvent('bronto_reminder_send_before');
30
+
31
+ if (Mage::helper('bronto_reminder')->isLogEnabled()) {
32
+ $this->_log = Mage::getModel('bronto_reminder/delivery');
33
+ $this->_log->setCustomerEmail($contact->email);
34
+ $this->_log->setContactId($contact->id);
35
+ $this->_log->setMessageId($message->id);
36
+ $this->_log->setMessageName($message->name);
37
+ $this->_log->setSuccess(0);
38
+ $this->_log->setSentAt(new Zend_Db_Expr('NOW()'));
39
+ $this->_log->save();
40
+ }
41
+ }
42
+
43
  /**
44
  * Log the Delivery API call
45
  *
46
+ * @param bool $success
47
+ * @param string $error (optional)
48
+ * @param Bronto_Api_Delivery_Row $delivery (optional)
49
+ *
50
+ * @return void
51
  */
52
  protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
53
  {
54
+ Mage::dispatchEvent('bronto_reminder_send_after');
55
+
56
  if (!is_null($delivery)) {
57
  $helper = Mage::helper($this->_helper);
58
  $status = $success ? "Successful" : "Failed";
61
  $helper->writeVerboseDebug(var_export($delivery->getApi()->getLastRequest(), true), $this->_apiLogFile);
62
  $helper->writeVerboseDebug(var_export($delivery->getApi()->getLastResponse(), true), $this->_apiLogFile);
63
  }
64
+
65
+ if (Mage::helper('bronto_reminder')->isLogEnabled()) {
66
+ $this->_log->setSuccess((int)$success);
67
+ if (!empty($error)) {
68
+ $this->_log->setError($error);
69
+ }
70
+ if ($delivery) {
71
+ $this->_log->setDeliveryId($delivery->id);
72
+ if (Mage::helper('bronto_reminder')->isLogFieldsEnabled()) {
73
+ $this->_log->setFields(serialize($delivery->getFields()));
74
+ }
75
+ }
76
+ $this->_log->save();
77
+ $this->_log = null;
78
+ }
79
  }
80
  }
app/code/community/Bronto/Reminder/Model/Mysql4/Customer/Collection.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Model_Entity_Customer_Collection
9
  {
@@ -17,12 +16,8 @@ class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Mod
17
  $rule = Mage::registry('current_reminder_rule');
18
  $select = $this->getSelect();
19
 
20
- $customerTable = $this->getTable('customer/entity');
21
- $couponTable = $this->getTable('bronto_reminder/coupon');
22
- $logTable = $this->getTable('bronto_reminder/log');
23
- // Used for gathering guest data
24
- $quoteTable = $this->getResource()->getTable('sales/quote');
25
- $logQuoteTable = Mage::getResourceSingleton('log/log')->getTable('log/quote_table');
26
 
27
  try {
28
  $salesRuleCouponTable = $this->getTable('salesrule/coupon');
@@ -30,36 +25,15 @@ class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Mod
30
  $salesRuleCouponTable = false;
31
  }
32
 
33
- $select->from(array('c' => $couponTable), array('store_id', 'unique_id', 'customer_id', 'visitor_id', 'associated_at', 'emails_failed', 'is_active'));
34
  $select->where('c.rule_id = ?', $rule->getId());
35
 
36
- // Select Guest Data
37
- $guestSelect = $this->getConnection()->select();
38
- $guestSelect->from(
39
- array('q' => $quoteTable),
40
- array('email' => 'q.customer_email')
41
- )->where('lq.visitor_id = c.visitor_id');
42
- $guestSelect->joinInner(
43
- array('lq' => $logQuoteTable),
44
- 'q.entity_id = lq.quote_id',
45
- array()
46
- );
47
-
48
- $select->joinLeft(
49
- array('e' => $customerTable),
50
- 'e.entity_id = c.customer_id',
51
- array(
52
- 'entity_id',
53
- 'email' => new Zend_Db_Expr("IF(e.email IS NULL, ($guestSelect), e.email)")
54
- )
55
- );
56
-
57
  $subSelect = $this->getConnection()->select();
58
  $subSelect->from(array('g' => $logTable), array(
59
  'unique_id',
60
  'rule_id',
61
  'emails_sent' => new Zend_Db_Expr('COUNT(log_id)'),
62
- 'last_sent' => new Zend_Db_Expr('MAX(sent_at)')
63
  ));
64
 
65
  $subSelect->where('rule_id = ?', $rule->getId());
@@ -81,16 +55,16 @@ class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Mod
81
 
82
  $this->_joinFields['associated_at'] = array('table' => 'c', 'field' => 'associated_at');
83
  $this->_joinFields['emails_failed'] = array('table' => 'c', 'field' => 'emails_failed');
84
- $this->_joinFields['is_active'] = array('table' => 'c', 'field' => 'is_active');
85
 
86
  if ($salesRuleCouponTable) {
87
- $this->_joinFields['code'] = array('table' => 'sc', 'field' => 'code');
88
- $this->_joinFields['usage_limit'] = array('table' => 'sc', 'field' => 'usage_limit');
89
  $this->_joinFields['usage_per_customer'] = array('table' => 'sc', 'field' => 'usage_per_customer');
90
  }
91
 
92
  $this->_joinFields['emails_sent'] = array('table' => 'l', 'field' => 'emails_sent');
93
- $this->_joinFields['last_sent'] = array('table' => 'l', 'field' => 'last_sent');
94
 
95
  return $this;
96
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Model_Entity_Customer_Collection
8
  {
16
  $rule = Mage::registry('current_reminder_rule');
17
  $select = $this->getSelect();
18
 
19
+ $couponTable = $this->getTable('bronto_reminder/coupon');
20
+ $logTable = $this->getTable('bronto_reminder/log');
 
 
 
 
21
 
22
  try {
23
  $salesRuleCouponTable = $this->getTable('salesrule/coupon');
25
  $salesRuleCouponTable = false;
26
  }
27
 
28
+ $select->from(array('c' => $couponTable), array('store_id', 'unique_id', 'customer_id', 'customer_email', 'associated_at', 'emails_failed', 'is_active'));
29
  $select->where('c.rule_id = ?', $rule->getId());
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  $subSelect = $this->getConnection()->select();
32
  $subSelect->from(array('g' => $logTable), array(
33
  'unique_id',
34
  'rule_id',
35
  'emails_sent' => new Zend_Db_Expr('COUNT(log_id)'),
36
+ 'last_sent' => new Zend_Db_Expr('MAX(sent_at)')
37
  ));
38
 
39
  $subSelect->where('rule_id = ?', $rule->getId());
55
 
56
  $this->_joinFields['associated_at'] = array('table' => 'c', 'field' => 'associated_at');
57
  $this->_joinFields['emails_failed'] = array('table' => 'c', 'field' => 'emails_failed');
58
+ $this->_joinFields['is_active'] = array('table' => 'c', 'field' => 'is_active');
59
 
60
  if ($salesRuleCouponTable) {
61
+ $this->_joinFields['code'] = array('table' => 'sc', 'field' => 'code');
62
+ $this->_joinFields['usage_limit'] = array('table' => 'sc', 'field' => 'usage_limit');
63
  $this->_joinFields['usage_per_customer'] = array('table' => 'sc', 'field' => 'usage_per_customer');
64
  }
65
 
66
  $this->_joinFields['emails_sent'] = array('table' => 'l', 'field' => 'emails_sent');
67
+ $this->_joinFields['last_sent'] = array('table' => 'l', 'field' => 'last_sent');
68
 
69
  return $this;
70
  }
app/code/community/Bronto/Reminder/Model/Mysql4/Delivery.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Model_Mysql4_Delivery extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ public function _construct()
10
+ {
11
+ $this->_init('bronto_reminder/delivery', 'log_id');
12
+ }
13
+ }
app/code/community/Bronto/Reminder/Model/Mysql4/Delivery/Collection.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Model_Mysql4_Delivery_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
+ {
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->_init('bronto_reminder/delivery');
13
+ }
14
+
15
+ /**
16
+ * Specify collection select order by attribute value
17
+ * Backward compatibility with EAV collection
18
+ *
19
+ * @param string $attribute
20
+ * @param string $dir
21
+ *
22
+ * @return Bronto_Reminder_Model_Mysql4_Delivery_Collection
23
+ */
24
+ public function addAttributeToSort($attribute, $dir = 'asc')
25
+ {
26
+ $this->addOrder($attribute, $dir);
27
+
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Delete all the entities in the collection
33
+ */
34
+ public function delete()
35
+ {
36
+ foreach ($this->getItems() as $item) {
37
+ $item->delete($item);
38
+ }
39
+
40
+ return $this;
41
+ }
42
+ }
app/code/community/Bronto/Reminder/Model/Mysql4/Rule.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
- class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
 
9
  {
10
  /**
11
  * Rule websites table name
@@ -33,8 +33,9 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
33
  /**
34
  * Quote parameters into condition string
35
  *
36
- * @param string $string
37
  * @param string | array $param
 
38
  * @return string
39
  */
40
  public function quoteInto($string, $param)
@@ -46,6 +47,8 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
46
  * Prepare object data for saving
47
  *
48
  * @param Mage_Core_Model_Abstract $object
 
 
49
  */
50
  protected function _beforeSave(Mage_Core_Model_Abstract $object)
51
  {
@@ -71,6 +74,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
71
  * Perform actions after object save
72
  *
73
  * @param Mage_Core_Model_Abstract $rule
 
74
  * @return Mage_Core_Model_Mysql4_Abstract
75
  */
76
  protected function _afterSave(Mage_Core_Model_Abstract $rule)
@@ -81,6 +85,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
81
  if ($rule->hasData('store_messages')) {
82
  $this->_saveMessageData($rule);
83
  }
 
84
  return parent::_afterSave($rule);
85
  }
86
 
@@ -88,6 +93,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
88
  * Save all website ids associated to rule
89
  *
90
  * @param $rule
 
91
  * @return Bronto_Reminder_Model_Mysql4_Rule
92
  */
93
  protected function _saveWebsiteIds($rule)
@@ -100,11 +106,15 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
100
  }
101
 
102
  foreach ($websiteIds as $websiteId) {
103
- $adapter->insert($this->_websiteTable, array(
104
- 'website_id' => $websiteId,
105
- 'rule_id' => $rule->getId()
106
- ));
 
 
 
107
  }
 
108
  return $this;
109
  }
110
 
@@ -112,6 +122,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
112
  * Get website ids associated to the rule id
113
  *
114
  * @param int $ruleId
 
115
  * @return array
116
  */
117
  public function getWebsiteIds($ruleId)
@@ -122,6 +133,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
122
 
123
  $websiteIds = $this->_getReadAdapter()->fetchCol($select);
124
  array_unshift($websiteIds, "0");
 
125
  return $websiteIds;
126
  }
127
 
@@ -129,29 +141,39 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
129
  * Save store Messages
130
  *
131
  * @param $rule
 
132
  * @return Bronto_Reminder_Model_Mysql4_Rule
133
  */
134
  protected function _saveMessageData($rule)
135
  {
136
- $adapter = $this->_getWriteAdapter();
137
  $messageTable = $this->getTable('bronto_reminder/message');
138
  $adapter->delete($messageTable, array('rule_id = ?' => $rule->getId()));
139
 
140
- $labels = $rule->getStoreLabels();
141
  $descriptions = $rule->getStoreDescriptions();
 
 
142
 
143
  foreach ($rule->getStoreMessages() as $storeId => $messageId) {
144
  if (!$messageId) {
145
  continue;
146
  }
147
- $adapter->insert($messageTable, array(
148
- 'rule_id' => $rule->getId(),
149
- 'store_id' => $storeId,
150
- 'message_id' => $messageId,
151
- 'label' => $labels[$storeId],
152
- 'description' => $descriptions[$storeId]
153
- ));
 
 
 
 
 
 
154
  }
 
155
  return $this;
156
  }
157
 
@@ -159,14 +181,16 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
159
  * Get Message data assigned to reminder rule
160
  *
161
  * @param int $ruleId
 
162
  * @return array
163
  */
164
  public function getMessageData($ruleId)
165
  {
166
  $messageTable = $this->getTable('bronto_reminder/message');
167
- $select = $this->createSelect()
168
- ->from($messageTable, array('store_id', 'message_id', 'label', 'description'))
169
  ->where('rule_id = ?', $ruleId);
 
170
  return $this->_getReadAdapter()->fetchAll($select);
171
  }
172
 
@@ -176,17 +200,20 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
176
  *
177
  * @param int $ruleId
178
  * @param int $storeId
 
179
  * @return array
180
  */
181
  public function getStoreMessageData($ruleId, $storeId)
182
  {
183
  $messageTable = $this->getTable('bronto_reminder/message');
184
- $ruleTable = $this->getTable('bronto_reminder/rule');
185
 
186
- $select = $this->createSelect()->from(array('m' => $messageTable),
 
187
  'm.message_id,
188
  IF(m.label != \'\', m.label, r.default_label) as label,
189
- IF(m.description != \'\', m.description, r.default_description) as description'
 
190
  );
191
 
192
  $select->join(
@@ -202,16 +229,17 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
202
  }
203
 
204
  /**
205
- * @param int $ruleId
206
- * @param int $storeId
207
- * @param int $customerId
208
  * @param string $messageId
 
209
  * @return array
210
  */
211
  public function getRuleLogItemsData($ruleId, $storeId, $customerId, $messageId = null)
212
  {
213
  $couponTable = $this->getTable('bronto_reminder/coupon');
214
- $logTable = $this->getTable('bronto_reminder/log');
215
 
216
  $select = $this->createSelect()->from(array('l' => $logTable));
217
  $select->joinInner(
@@ -233,6 +261,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
233
  * Get comparison condition for rule condition operator which will be used in SQL query
234
  *
235
  * @param string $operator
 
236
  * @return string
237
  */
238
  public function getSqlOperator($operator)
@@ -256,27 +285,30 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
256
  default:
257
  Mage::throwException(Mage::helper('bronto_reminder')->__('Unknown operator specified.'));
258
  }
 
 
259
  }
260
 
261
  /**
262
- * Create string for select "where" condition based on field name, comparison operator and vield value
263
  *
264
  * @param string $field
265
  * @param string $operator
266
- * @param mixed $value
 
267
  * @return string
268
  */
269
  public function createConditionSql($field, $operator, $value)
270
  {
271
  $sqlOperator = $this->getSqlOperator($operator);
272
- $condition = '';
273
  switch ($operator) {
274
  case '{}':
275
  case '!{}':
276
  if (is_array($value)) {
277
  if (!empty($value)) {
278
  $sqlOperator = ($operator == '{}') ? 'IN' : 'NOT IN';
279
- $condition = $this->quoteInto($field . ' ' . $sqlOperator . ' (?)', $value);
280
  }
281
  } else {
282
  $condition = $this->quoteInto($field . ' ' . $sqlOperator . ' ?', '%' . $value . '%');
@@ -289,6 +321,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
289
  $condition = $this->quoteInto($field . ' ' . $sqlOperator . ' ?', $value);
290
  break;
291
  }
 
292
  return $condition;
293
  }
294
 
@@ -296,6 +329,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
296
  * Deactivate already matched customers before new matching process
297
  *
298
  * @param int $ruleId
 
299
  * @return Bronto_Reminder_Model_Mysql4_Rule
300
  */
301
  public function deactivateMatchedCustomers($ruleId)
@@ -305,6 +339,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
305
  array('is_active' => '0'),
306
  array('rule_id = ?' => $ruleId)
307
  );
 
308
  return $this;
309
  }
310
 
@@ -312,6 +347,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
312
  * Deactivate customers that have been matched and emailed
313
  *
314
  * @param string $uniqueId
 
315
  * @return Bronto_Reminder_Model_Mysql4_Rule
316
  */
317
  public function deactivateMatchedCustomer($uniqueId)
@@ -321,15 +357,17 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
321
  array('is_active' => '0'),
322
  array('unique_id = ?' => $uniqueId)
323
  );
 
324
  return $this;
325
  }
326
 
327
  /**
328
  * Additional debugging that shows query and parameter values
 
329
  * @param string $sql
330
- * @param array $bind
331
  */
332
- public function logFullQuery($sql, $bind)
333
  {
334
  foreach ($bind as $var => $val) {
335
  $sql = str_replace(':' . $var, $val, $sql);
@@ -341,14 +379,17 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
341
  * Try to associate reminder rule with matched customers.
342
  * If customer was added earlier, update is_active column.
343
  *
344
- * @param Bronto_Reminder_Model_Rule $rule
345
- * @param Mage_SalesRule_Model_Rule $salesRule
346
- * @param int $websiteId
347
- * @return Bronto_Reminder_Model_Mysql4_Rule
 
 
 
348
  */
349
- public function saveMatchedCustomers($rule, $salesRule, $websiteId, $threshold = null)
350
  {
351
- $select = $rule->getConditions()->getConditionsSql($rule, $websiteId);
352
  $interval = Mage::helper('bronto_reminder')->getCronInterval();
353
 
354
  if (!$rule->getConditionSql()) {
@@ -362,14 +403,46 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
362
  // Only pull for reminders not already attached to an active record
363
  $select->where('c.is_active IS NULL OR c.is_active <> 1');
364
 
365
- $i = 0;
366
- $ruleId = $rule->getId();
367
- $adapter = $this->_getWriteAdapter();
368
- $currentDate = $this->formatDate(time());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  $dataToInsert = array();
370
- Mage::helper('bronto_reminder')->writeDebug('ruleId: ' . $rule->getId() . ' website: ' . $websiteId, 'bronto_reminder_sql.log');
371
- # Replaced by logFullQuery below
372
- #Mage::helper('bronto_reminder')->writeDebug($select->__toString(), 'bronto_reminder_sql.log');
 
373
 
374
  // Log the query with binds replaced
375
  $this->logFullQuery($select, array('rule_id' => $ruleId, 'interval' => $interval));
@@ -382,23 +455,44 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
382
  $adapter->beginTransaction();
383
  while ($row = $stmt->fetch()) {
384
  if (empty($row['coupon_id']) && $salesRule) {
385
- $coupon = $salesRule->acquireCoupon();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  $couponId = ($coupon !== null) ? $coupon->getId() : null;
387
  } else {
388
  $couponId = $row['coupon_id'];
389
  }
390
 
391
  $dataToInsert[] = array(
392
- 'rule_id' => $ruleId,
393
- 'coupon_id' => $couponId,
394
- 'unique_id' => $row['unique_id'],
395
- 'store_id' => $row['store_id'],
396
- 'customer_id' => $row['customer_id'],
397
- 'quote_id' => $row['quote_id'],
398
- 'wishlist_id' => $row['wishlist_id'],
399
- 'visitor_id' => $row['visitor_id'],
400
- 'associated_at' => $currentDate,
401
- 'is_active' => '1'
402
  );
403
  $i++;
404
 
@@ -441,25 +535,27 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
441
  *
442
  * @param int|null $limit
443
  * @param int|null $ruleId
 
444
  * @return array
445
  */
446
  public function getCustomersForNotification($limit = null, $ruleId = null)
447
  {
448
  $couponTable = $this->getTable('bronto_reminder/coupon');
449
- $ruleTable = $this->getTable('bronto_reminder/rule');
450
- $logTable = $this->getTable('bronto_reminder/log');
451
- $currentDate = $this->formatDate(time());
452
 
453
  $select = $this->createSelect()->from(
454
  array('c' => $couponTable),
455
- array('rule_id', 'coupon_id', 'unique_id', 'store_id', 'customer_id', 'quote_id', 'wishlist_id', 'visitor_id')
456
- );
457
-
458
-
459
- $select->joinLeft(
460
- array('l' => $logTable),
461
- 'c.rule_id=l.rule_id AND c.unique_id=l.unique_id',
462
- array()
 
 
463
  );
464
 
465
  $select->join(
@@ -468,30 +564,32 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
468
  array('schedule')
469
  );
470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  if ($ruleId) {
472
  $select->where('c.rule_id = ?', $ruleId);
473
  }
474
 
475
  $select->where('c.is_active = 1');
476
  $select->group(array('c.unique_id', 'c.rule_id'));
477
- $select->having("(MAX(l.sent_at) IS NULL) OR (FIND_IN_SET(TO_DAYS('{$currentDate}') - TO_DAYS(MIN(l.sent_at)), r.schedule))");
478
 
479
  if ($limit) {
480
  $select->limit($limit);
481
  }
482
-
483
- /**
484
- SELECT `c`.`customer_id`, `c`.`coupon_id`, `c`.`rule_id`, `r`.`schedule`
485
- FROM `bronto_reminder_rule_coupon` AS `c`
486
- INNER JOIN `bronto_reminder_rule` AS `r` ON c.rule_id = r.rule_id AND r.is_active = 1
487
- LEFT JOIN `bronto_reminder_rule_log` AS `l` ON c.rule_id=l.rule_id AND c.customer_id=l.customer_id
488
- WHERE (c.rule_id = '1') AND (c.is_active = 1)
489
- GROUP BY `c`.`customer_id`, `c`.`rule_id`
490
- HAVING ((MAX(l.sent_at) IS NULL)
491
- OR (FIND_IN_SET(TO_DAYS('2012-05-11 09:21:27') - TO_DAYS(MIN(l.sent_at)), r.schedule)
492
- AND TO_DAYS('2012-05-11 09:21:27') != TO_DAYS(MAX(l.sent_at))))
493
- LIMIT 100
494
- */
495
 
496
  return $this->_getReadAdapter()->fetchAll($select);
497
  }
@@ -499,21 +597,25 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
499
  /**
500
  * Add notification log row after letter was successfully sent.
501
  *
502
- * @param int $ruleId
503
- * @param int $customerId
504
- * @return Bronto_Reminder_Model_Mysql4_Rule
 
 
 
505
  */
506
  public function addNotificationLog($ruleId, $uniqueId, $deliveryId = null, $messageId = null)
507
  {
508
  $data = array(
509
- 'rule_id' => $ruleId,
510
- 'unique_id' => $uniqueId,
511
- 'sent_at' => $this->formatDate(time()),
512
  'bronto_delivery_id' => $deliveryId,
513
- 'bronto_message_id' => $messageId,
514
  );
515
 
516
  $this->_getWriteAdapter()->insert($this->getTable('bronto_reminder/log'), $data);
 
517
  return $this;
518
  }
519
 
@@ -522,11 +624,13 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
522
  *
523
  * @param int $ruleId
524
  * @param int $uniqueId
 
525
  * @return Bronto_Reminder_Model_Mysql4_Rule
526
  */
527
  public function updateFailedEmailsCounter($ruleId, $uniqueId)
528
  {
529
- $this->_getWriteAdapter()->update($this->getTable('bronto_reminder/coupon'),
 
530
  array('emails_failed' => new Zend_Db_Expr('emails_failed + 1')),
531
  array('rule_id = ?' => $ruleId, 'unique_id = ?' => $uniqueId)
532
  );
@@ -538,6 +642,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
538
  * Return count of reminder rules assigned to specified sales rule.
539
  *
540
  * @param int $salesruleId
 
541
  * @return int
542
  */
543
  public function getAssignedRulesCount($salesruleId)
@@ -547,21 +652,37 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
547
  array(new Zend_Db_Expr('count(*)'))
548
  );
549
  $select->where('r.salesrule_id = ?', $salesruleId);
 
550
  return $this->_getReadAdapter()->fetchOne($select);
551
  }
552
 
553
  /**
554
  * Remove row from coupon table by column, value and store_id
555
  *
556
- * @param type $column
557
- * @param type $value
 
558
  * @return Bronto_Reminder_Model_Mysql4_Rule
559
  */
560
  public function removeFromReminders($column, $value)
561
  {
562
- $where = "$column = $value";
563
- $this->_getWriteAdapter()->delete($this->getTable('bronto_reminder/coupon'), $where);
 
 
 
 
 
 
 
 
 
 
 
 
 
564
 
 
565
  return $this;
566
  }
567
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
+ class Bronto_Reminder_Model_Mysql4_Rule
8
+ extends Mage_Core_Model_Mysql4_Abstract
9
  {
10
  /**
11
  * Rule websites table name
33
  /**
34
  * Quote parameters into condition string
35
  *
36
+ * @param string $string
37
  * @param string | array $param
38
+ *
39
  * @return string
40
  */
41
  public function quoteInto($string, $param)
47
  * Prepare object data for saving
48
  *
49
  * @param Mage_Core_Model_Abstract $object
50
+ *
51
+ * @return Mage_Core_Model_Resource_Db_Abstract|void
52
  */
53
  protected function _beforeSave(Mage_Core_Model_Abstract $object)
54
  {
74
  * Perform actions after object save
75
  *
76
  * @param Mage_Core_Model_Abstract $rule
77
+ *
78
  * @return Mage_Core_Model_Mysql4_Abstract
79
  */
80
  protected function _afterSave(Mage_Core_Model_Abstract $rule)
85
  if ($rule->hasData('store_messages')) {
86
  $this->_saveMessageData($rule);
87
  }
88
+
89
  return parent::_afterSave($rule);
90
  }
91
 
93
  * Save all website ids associated to rule
94
  *
95
  * @param $rule
96
+ *
97
  * @return Bronto_Reminder_Model_Mysql4_Rule
98
  */
99
  protected function _saveWebsiteIds($rule)
106
  }
107
 
108
  foreach ($websiteIds as $websiteId) {
109
+ $adapter->insert(
110
+ $this->_websiteTable,
111
+ array(
112
+ 'website_id' => $websiteId,
113
+ 'rule_id' => $rule->getId()
114
+ )
115
+ );
116
  }
117
+
118
  return $this;
119
  }
120
 
122
  * Get website ids associated to the rule id
123
  *
124
  * @param int $ruleId
125
+ *
126
  * @return array
127
  */
128
  public function getWebsiteIds($ruleId)
133
 
134
  $websiteIds = $this->_getReadAdapter()->fetchCol($select);
135
  array_unshift($websiteIds, "0");
136
+
137
  return $websiteIds;
138
  }
139
 
141
  * Save store Messages
142
  *
143
  * @param $rule
144
+ *
145
  * @return Bronto_Reminder_Model_Mysql4_Rule
146
  */
147
  protected function _saveMessageData($rule)
148
  {
149
+ $adapter = $this->_getWriteAdapter();
150
  $messageTable = $this->getTable('bronto_reminder/message');
151
  $adapter->delete($messageTable, array('rule_id = ?' => $rule->getId()));
152
 
153
+ $labels = $rule->getStoreLabels();
154
  $descriptions = $rule->getStoreDescriptions();
155
+ $sendTypes = $rule->getStoreMessageSendtypes();
156
+ // $salesruleIds = $rule->getStoreSalesruleIds();
157
 
158
  foreach ($rule->getStoreMessages() as $storeId => $messageId) {
159
  if (!$messageId) {
160
  continue;
161
  }
162
+ $sendType = (array_key_exists($storeId, $sendTypes)) ? $sendTypes[$storeId] : 'transactional';
163
+ $adapter->insert(
164
+ $messageTable,
165
+ array(
166
+ 'rule_id' => $rule->getId(),
167
+ 'store_id' => $storeId,
168
+ 'message_id' => $messageId,
169
+ 'send_type' => $sendType,
170
+ 'label' => $labels[$storeId],
171
+ 'description' => $descriptions[$storeId],
172
+ // 'salesrule_id' => $salesruleIds[$storeId],
173
+ )
174
+ );
175
  }
176
+
177
  return $this;
178
  }
179
 
181
  * Get Message data assigned to reminder rule
182
  *
183
  * @param int $ruleId
184
+ *
185
  * @return array
186
  */
187
  public function getMessageData($ruleId)
188
  {
189
  $messageTable = $this->getTable('bronto_reminder/message');
190
+ $select = $this->createSelect()
191
+ ->from($messageTable, array('store_id', 'message_id', 'label', 'description', 'send_type'))
192
  ->where('rule_id = ?', $ruleId);
193
+
194
  return $this->_getReadAdapter()->fetchAll($select);
195
  }
196
 
200
  *
201
  * @param int $ruleId
202
  * @param int $storeId
203
+ *
204
  * @return array
205
  */
206
  public function getStoreMessageData($ruleId, $storeId)
207
  {
208
  $messageTable = $this->getTable('bronto_reminder/message');
209
+ $ruleTable = $this->getTable('bronto_reminder/rule');
210
 
211
+ $select = $this->createSelect()->from(
212
+ array('m' => $messageTable),
213
  'm.message_id,
214
  IF(m.label != \'\', m.label, r.default_label) as label,
215
+ IF(m.description != \'\', m.description, r.default_description) as description,
216
+ m.send_type'
217
  );
218
 
219
  $select->join(
229
  }
230
 
231
  /**
232
+ * @param int $ruleId
233
+ * @param int $storeId
234
+ * @param int $customerId
235
  * @param string $messageId
236
+ *
237
  * @return array
238
  */
239
  public function getRuleLogItemsData($ruleId, $storeId, $customerId, $messageId = null)
240
  {
241
  $couponTable = $this->getTable('bronto_reminder/coupon');
242
+ $logTable = $this->getTable('bronto_reminder/log');
243
 
244
  $select = $this->createSelect()->from(array('l' => $logTable));
245
  $select->joinInner(
261
  * Get comparison condition for rule condition operator which will be used in SQL query
262
  *
263
  * @param string $operator
264
+ *
265
  * @return string
266
  */
267
  public function getSqlOperator($operator)
285
  default:
286
  Mage::throwException(Mage::helper('bronto_reminder')->__('Unknown operator specified.'));
287
  }
288
+
289
+ return false;
290
  }
291
 
292
  /**
293
+ * Create string for select "where" condition based on field name, comparison operator and field value
294
  *
295
  * @param string $field
296
  * @param string $operator
297
+ * @param mixed $value
298
+ *
299
  * @return string
300
  */
301
  public function createConditionSql($field, $operator, $value)
302
  {
303
  $sqlOperator = $this->getSqlOperator($operator);
304
+ $condition = '';
305
  switch ($operator) {
306
  case '{}':
307
  case '!{}':
308
  if (is_array($value)) {
309
  if (!empty($value)) {
310
  $sqlOperator = ($operator == '{}') ? 'IN' : 'NOT IN';
311
+ $condition = $this->quoteInto($field . ' ' . $sqlOperator . ' (?)', $value);
312
  }
313
  } else {
314
  $condition = $this->quoteInto($field . ' ' . $sqlOperator . ' ?', '%' . $value . '%');
321
  $condition = $this->quoteInto($field . ' ' . $sqlOperator . ' ?', $value);
322
  break;
323
  }
324
+
325
  return $condition;
326
  }
327
 
329
  * Deactivate already matched customers before new matching process
330
  *
331
  * @param int $ruleId
332
+ *
333
  * @return Bronto_Reminder_Model_Mysql4_Rule
334
  */
335
  public function deactivateMatchedCustomers($ruleId)
339
  array('is_active' => '0'),
340
  array('rule_id = ?' => $ruleId)
341
  );
342
+
343
  return $this;
344
  }
345
 
347
  * Deactivate customers that have been matched and emailed
348
  *
349
  * @param string $uniqueId
350
+ *
351
  * @return Bronto_Reminder_Model_Mysql4_Rule
352
  */
353
  public function deactivateMatchedCustomer($uniqueId)
357
  array('is_active' => '0'),
358
  array('unique_id = ?' => $uniqueId)
359
  );
360
+
361
  return $this;
362
  }
363
 
364
  /**
365
  * Additional debugging that shows query and parameter values
366
+ *
367
  * @param string $sql
368
+ * @param array $bind
369
  */
370
+ public function logFullQuery($sql, $bind = array())
371
  {
372
  foreach ($bind as $var => $val) {
373
  $sql = str_replace(':' . $var, $val, $sql);
379
  * Try to associate reminder rule with matched customers.
380
  * If customer was added earlier, update is_active column.
381
  *
382
+ * @param Bronto_Reminder_Model_Rule $rule
383
+ * @param null|Mage_SalesRule_Model_Rule $salesRule
384
+ * @param int $websiteId
385
+ * @param null $threshold
386
+ *
387
+ * @return $this
388
+ * @throws Exception
389
  */
390
+ public function saveMatchedCustomers(Bronto_Reminder_Model_Rule $rule, $salesRule, $websiteId, $threshold = null)
391
  {
392
+ $select = $rule->getConditions()->getConditionsSql($rule, $websiteId);
393
  $interval = Mage::helper('bronto_reminder')->getCronInterval();
394
 
395
  if (!$rule->getConditionSql()) {
403
  // Only pull for reminders not already attached to an active record
404
  $select->where('c.is_active IS NULL OR c.is_active <> 1');
405
 
406
+ // Handle Send Limit
407
+ $sendLimit = $rule->getSendLimit();
408
+ if ($sendLimit > 0) {
409
+ $subSelect = $this->createSelect()->from(
410
+ array($this->getTable('bronto_reminder/log')),
411
+ array('num_send' => 'count(log_id)', 'unique_id')
412
+ )
413
+ ->group(array('unique_id'));
414
+
415
+ $select->joinLeft(
416
+ array('l' => $subSelect),
417
+ 'c.unique_id=l.unique_id',
418
+ array()
419
+ )
420
+ ->where('l.num_send IS NULL OR l.num_send < ?', $sendLimit);
421
+ }
422
+
423
+ // Handle Send To Value
424
+ switch ($rule->getSendTo()) {
425
+ case 'user':
426
+ $select->where('`root`.`customer_id` IS NOT NULL AND `root`.`customer_id` != 0');
427
+ break;
428
+ case 'guest':
429
+ $select->where('`root`.`customer_id` IS NULL OR `root`.`customer_id` = 0');
430
+ break;
431
+ case 'both':
432
+ default:
433
+ // No need to filter
434
+ break;
435
+ }
436
+
437
+ $i = 0;
438
+ $ruleId = $rule->getId();
439
+ $adapter = $this->_getWriteAdapter();
440
+ $currentDate = $this->formatDate(time());
441
  $dataToInsert = array();
442
+ Mage::helper('bronto_reminder')->writeDebug(
443
+ 'ruleId: ' . $rule->getId() . ' website: ' . $websiteId,
444
+ 'bronto_reminder_sql.log'
445
+ );
446
 
447
  // Log the query with binds replaced
448
  $this->logFullQuery($select, array('rule_id' => $ruleId, 'interval' => $interval));
455
  $adapter->beginTransaction();
456
  while ($row = $stmt->fetch()) {
457
  if (empty($row['coupon_id']) && $salesRule) {
458
+ if (
459
+ $salesRule->getCouponType() == Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC &&
460
+ $salesRule->getUseAutoGeneration()
461
+ ) {
462
+ $coupons = $salesRule->getCoupons();
463
+ if (!$coupons) {
464
+ $coupons = array();
465
+ }
466
+ foreach ($coupons as $couponTemp) {
467
+ if (
468
+ $couponTemp->getUsageLimit() > $couponTemp->getTimesUsed() &&
469
+ (
470
+ is_null($couponTemp->getExpirationDate()) ||
471
+ $couponTemp->getExpirationDate() > date('Y-m-d H:i:s', mktime(0, 0, 0, date('m'), date('d'), date('Y')))
472
+ )
473
+ ) {
474
+ $coupon = $couponTemp;
475
+ }
476
+ }
477
+ } else {
478
+ $coupon = $salesRule->acquireCoupon();
479
+ }
480
  $couponId = ($coupon !== null) ? $coupon->getId() : null;
481
  } else {
482
  $couponId = $row['coupon_id'];
483
  }
484
 
485
  $dataToInsert[] = array(
486
+ 'rule_id' => $ruleId,
487
+ 'coupon_id' => $couponId,
488
+ 'unique_id' => $row['unique_id'],
489
+ 'store_id' => $row['store_id'],
490
+ 'customer_id' => $row['customer_id'],
491
+ 'quote_id' => $row['quote_id'],
492
+ 'wishlist_id' => $row['wishlist_id'],
493
+ 'customer_email' => $row['customer_email'],
494
+ 'associated_at' => $currentDate,
495
+ 'is_active' => '1'
496
  );
497
  $i++;
498
 
535
  *
536
  * @param int|null $limit
537
  * @param int|null $ruleId
538
+ *
539
  * @return array
540
  */
541
  public function getCustomersForNotification($limit = null, $ruleId = null)
542
  {
543
  $couponTable = $this->getTable('bronto_reminder/coupon');
544
+ $ruleTable = $this->getTable('bronto_reminder/rule');
545
+ $logTable = $this->getTable('bronto_reminder/log');
 
546
 
547
  $select = $this->createSelect()->from(
548
  array('c' => $couponTable),
549
+ array(
550
+ 'rule_id',
551
+ 'coupon_id',
552
+ 'unique_id',
553
+ 'store_id',
554
+ 'customer_id',
555
+ 'customer_email',
556
+ 'quote_id',
557
+ 'wishlist_id',
558
+ )
559
  );
560
 
561
  $select->join(
564
  array('schedule')
565
  );
566
 
567
+ // Create sub-select to get number of log entries for this unique ID
568
+ $subSelect = $this->createSelect()->from(
569
+ array($logTable),
570
+ array('num_send' => 'count(log_id)', 'unique_id')
571
+ )
572
+ ->group(array('unique_id'));
573
+
574
+ // Join sub-select to main select on unique ID
575
+ $select->joinLeft(
576
+ array('l' => $subSelect),
577
+ 'c.unique_id=l.unique_id',
578
+ array()
579
+ )
580
+ ->where("l.num_send IS NULL OR r.send_limit > l.num_send OR r.send_limit <= 0");
581
+
582
  if ($ruleId) {
583
  $select->where('c.rule_id = ?', $ruleId);
584
  }
585
 
586
  $select->where('c.is_active = 1');
587
  $select->group(array('c.unique_id', 'c.rule_id'));
 
588
 
589
  if ($limit) {
590
  $select->limit($limit);
591
  }
592
+ $this->logFullQuery($select);
 
 
 
 
 
 
 
 
 
 
 
 
593
 
594
  return $this->_getReadAdapter()->fetchAll($select);
595
  }
597
  /**
598
  * Add notification log row after letter was successfully sent.
599
  *
600
+ * @param $ruleId
601
+ * @param $uniqueId
602
+ * @param null $deliveryId
603
+ * @param null $messageId
604
+ *
605
+ * @return $this
606
  */
607
  public function addNotificationLog($ruleId, $uniqueId, $deliveryId = null, $messageId = null)
608
  {
609
  $data = array(
610
+ 'rule_id' => $ruleId,
611
+ 'unique_id' => $uniqueId,
612
+ 'sent_at' => $this->formatDate(time()),
613
  'bronto_delivery_id' => $deliveryId,
614
+ 'bronto_message_id' => $messageId,
615
  );
616
 
617
  $this->_getWriteAdapter()->insert($this->getTable('bronto_reminder/log'), $data);
618
+
619
  return $this;
620
  }
621
 
624
  *
625
  * @param int $ruleId
626
  * @param int $uniqueId
627
+ *
628
  * @return Bronto_Reminder_Model_Mysql4_Rule
629
  */
630
  public function updateFailedEmailsCounter($ruleId, $uniqueId)
631
  {
632
+ $this->_getWriteAdapter()->update(
633
+ $this->getTable('bronto_reminder/coupon'),
634
  array('emails_failed' => new Zend_Db_Expr('emails_failed + 1')),
635
  array('rule_id = ?' => $ruleId, 'unique_id = ?' => $uniqueId)
636
  );
642
  * Return count of reminder rules assigned to specified sales rule.
643
  *
644
  * @param int $salesruleId
645
+ *
646
  * @return int
647
  */
648
  public function getAssignedRulesCount($salesruleId)
652
  array(new Zend_Db_Expr('count(*)'))
653
  );
654
  $select->where('r.salesrule_id = ?', $salesruleId);
655
+
656
  return $this->_getReadAdapter()->fetchOne($select);
657
  }
658
 
659
  /**
660
  * Remove row from coupon table by column, value and store_id
661
  *
662
+ * @param string $column
663
+ * @param mixed $value
664
+ *
665
  * @return Bronto_Reminder_Model_Mysql4_Rule
666
  */
667
  public function removeFromReminders($column, $value)
668
  {
669
+ // Check to see if an entry exists in the coupon table
670
+ $where = "$column = $value";
671
+ $select = $this->createSelect()->from(
672
+ array($this->getTable('bronto_reminder/coupon')),
673
+ array('unique_id')
674
+ )->where("{$column} = ?", $value)->limit(1);
675
+
676
+ // We get the Unique ID so we can remove the log entries as well
677
+ $uniqueId = $this->_getReadAdapter()->fetchOne($select);
678
+
679
+ // If a Unique ID was found to match, delete log and coupon table entries
680
+ if ($uniqueId) {
681
+ $this->_getWriteAdapter()->delete($this->getTable('bronto_reminder/log'), "unique_id = $uniqueId");
682
+ $this->_getWriteAdapter()->delete($this->getTable('bronto_reminder/coupon'), $where);
683
+ }
684
 
685
+ // Return
686
  return $this;
687
  }
688
  }
app/code/community/Bronto/Reminder/Model/Mysql4/Rule/Collection.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
  {
@@ -21,19 +20,22 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
21
  * Limit rules collection by is_active column
22
  *
23
  * @param int $value
 
24
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
25
  */
26
  public function addIsActiveFilter($value)
27
  {
28
  $this->getSelect()->where('main_table.is_active = ?', $value);
 
29
  return $this;
30
  }
31
 
32
  /**
33
  * Limit rules collection by date columns
34
  *
35
- * @param int $value
36
- * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
 
37
  */
38
  public function addDateFilter($date)
39
  {
@@ -48,11 +50,13 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
48
  * Limit rules collection by separate rule
49
  *
50
  * @param int $value
 
51
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
52
  */
53
  public function addRuleFilter($value)
54
  {
55
  $this->getSelect()->where('main_table.rule_id = ?', $value);
 
56
  return $this;
57
  }
58
 
@@ -65,7 +69,7 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
65
  {
66
  parent::_afterLoad();
67
  if ($this->getFlag('add_websites_to_result') && $this->_items) {
68
- $select = $this->getConnection()->select()
69
  ->from($this->getTable('bronto_reminder/website'), array(
70
  'rule_id',
71
  new Zend_Db_Expr('GROUP_CONCAT(website_id)')
@@ -87,12 +91,14 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
87
  * Init flag for adding rule website ids to collection result
88
  *
89
  * @param bool | null $flag
 
90
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
91
  */
92
  public function addWebsitesToResult($flag = null)
93
  {
94
  $flag = ($flag === null) ? true : $flag;
95
  $this->setFlag('add_websites_to_result', $flag);
 
96
  return $this;
97
  }
98
 
@@ -100,6 +106,7 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
100
  * Limit rules collection by specific website
101
  *
102
  * @param int | array | Mage_Core_Model_Website $websiteId
 
103
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
104
  */
105
  public function addWebsiteFilter($websiteId)
@@ -122,10 +129,11 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
122
  }
123
 
124
  /**
125
- * Redeclared for support website id filter
126
  *
127
  * @param string $field
128
- * @param mixed $condition
 
129
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
130
  */
131
  public function addFieldToFilter($field, $condition = null)
@@ -133,6 +141,7 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
133
  if ($field == 'website_ids') {
134
  return $this->addWebsiteFilter($condition);
135
  }
 
136
  return parent::addFieldToFilter($field, $condition);
137
  }
138
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
  {
20
  * Limit rules collection by is_active column
21
  *
22
  * @param int $value
23
+ *
24
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
25
  */
26
  public function addIsActiveFilter($value)
27
  {
28
  $this->getSelect()->where('main_table.is_active = ?', $value);
29
+
30
  return $this;
31
  }
32
 
33
  /**
34
  * Limit rules collection by date columns
35
  *
36
+ * @param $date
37
+ *
38
+ * @return $this
39
  */
40
  public function addDateFilter($date)
41
  {
50
  * Limit rules collection by separate rule
51
  *
52
  * @param int $value
53
+ *
54
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
55
  */
56
  public function addRuleFilter($value)
57
  {
58
  $this->getSelect()->where('main_table.rule_id = ?', $value);
59
+
60
  return $this;
61
  }
62
 
69
  {
70
  parent::_afterLoad();
71
  if ($this->getFlag('add_websites_to_result') && $this->_items) {
72
+ $select = $this->getConnection()->select()
73
  ->from($this->getTable('bronto_reminder/website'), array(
74
  'rule_id',
75
  new Zend_Db_Expr('GROUP_CONCAT(website_id)')
91
  * Init flag for adding rule website ids to collection result
92
  *
93
  * @param bool | null $flag
94
+ *
95
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
96
  */
97
  public function addWebsitesToResult($flag = null)
98
  {
99
  $flag = ($flag === null) ? true : $flag;
100
  $this->setFlag('add_websites_to_result', $flag);
101
+
102
  return $this;
103
  }
104
 
106
  * Limit rules collection by specific website
107
  *
108
  * @param int | array | Mage_Core_Model_Website $websiteId
109
+ *
110
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
111
  */
112
  public function addWebsiteFilter($websiteId)
129
  }
130
 
131
  /**
132
+ * Re-declared for support website id filter
133
  *
134
  * @param string $field
135
+ * @param mixed $condition
136
+ *
137
  * @return Bronto_Reminder_Model_Mysql4_Rule_Collection
138
  */
139
  public function addFieldToFilter($field, $condition = null)
141
  if ($field == 'website_ids') {
142
  return $this->addWebsiteFilter($condition);
143
  }
144
+
145
  return parent::addFieldToFilter($field, $condition);
146
  }
147
  }
app/code/community/Bronto/Reminder/Model/Observer.php CHANGED
@@ -1,13 +1,12 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Observer
9
  {
10
- const NOTICE_IDENTIFER = 'bronto_reminder';
11
 
12
  /**
13
  * @param Varien_Event_Observer $observer
@@ -21,13 +20,14 @@ class Bronto_Reminder_Model_Observer
21
  }
22
 
23
  // Verify Requirements
24
- if (!Mage::helper(self::NOTICE_IDENTIFER)->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
25
  return;
26
  }
27
  }
28
 
29
  /**
30
  * Observes module becoming enabled and displays message warning user to configure settings
 
31
  * @param Varien_Event_Observer $observer
32
  */
33
  public function watchEnableAction(Varien_Event_Observer $observer)
@@ -47,6 +47,7 @@ class Bronto_Reminder_Model_Observer
47
  if ($transport = $observer->getEvent()->getTransport()) {
48
  $transport->setIsCouponTypeAutoVisible(true);
49
  }
 
50
  return $this;
51
  }
52
 
@@ -68,24 +69,34 @@ class Bronto_Reminder_Model_Observer
68
  $couponTypeFiled->setNote(Mage::helper('bronto_reminder')->__('Coupons can be auto-generated by reminder promotion rules.'));
69
  }
70
  }
 
71
  return $this;
72
  }
73
 
74
  /**
75
- * Send scheduled notifications
76
  *
77
- * @return Bronto_Reminder_Model_Observer
 
 
78
  */
79
- public function scheduledNotification()
80
  {
81
  Mage::helper('bronto_reminder')->writeDebug('scheduledNotification() triggered...');
82
- if (Mage::helper('bronto_reminder')->isEnabled()) {
83
- $result = Mage::getModel('bronto_reminder/rule')->sendReminderEmails();
84
- return $result;
85
- } else {
86
- return 'Bronto_Reminder module is not enabled.';
 
 
 
 
 
87
  }
88
  Mage::helper('bronto_reminder')->writeDebug('Done!');
 
 
89
  }
90
 
91
  /**
@@ -93,16 +104,17 @@ class Bronto_Reminder_Model_Observer
93
  * remove from bronto_reminder_rule_coupon
94
  *
95
  * @param Varien_Event_Observer $observer
 
96
  * @return Varien_Event_Observer
97
  */
98
  public function updateReminderQueue(Varien_Event_Observer $observer)
99
  {
100
- $object = $observer->getEvent()->getDataObject();
101
  $filterField = false;
102
  $filterValue = false;
103
 
104
  if ($object instanceof Mage_Wishlist_Model_Wishlist) {
105
- $wishlist = $object;
106
  $collection = $wishlist->getItemCollection();
107
 
108
  if (0 === $collection->count()) {
@@ -119,7 +131,7 @@ class Bronto_Reminder_Model_Observer
119
  }
120
 
121
  if ($filterField && $filterValue) {
122
- // Quote is not active, so remove from queue if exists
123
  Mage::getModel('bronto_reminder/rule')
124
  ->removeFromReminders($filterField, $filterValue);
125
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Observer
8
  {
9
+ const NOTICE_IDENTIFIER = 'bronto_reminder';
10
 
11
  /**
12
  * @param Varien_Event_Observer $observer
20
  }
21
 
22
  // Verify Requirements
23
+ if (!Mage::helper(self::NOTICE_IDENTIFIER)->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
24
  return;
25
  }
26
  }
27
 
28
  /**
29
  * Observes module becoming enabled and displays message warning user to configure settings
30
+ *
31
  * @param Varien_Event_Observer $observer
32
  */
33
  public function watchEnableAction(Varien_Event_Observer $observer)
47
  if ($transport = $observer->getEvent()->getTransport()) {
48
  $transport->setIsCouponTypeAutoVisible(true);
49
  }
50
+
51
  return $this;
52
  }
53
 
69
  $couponTypeFiled->setNote(Mage::helper('bronto_reminder')->__('Coupons can be auto-generated by reminder promotion rules.'));
70
  }
71
  }
72
+
73
  return $this;
74
  }
75
 
76
  /**
77
+ * Send Scheduled Notifications
78
  *
79
+ * @param bool $brontoCron
80
+ *
81
+ * @return $this|string
82
  */
83
+ public function scheduledNotification($brontoCron = false)
84
  {
85
  Mage::helper('bronto_reminder')->writeDebug('scheduledNotification() triggered...');
86
+
87
+ // Only allow cron to run if isset to use mage cron or is coming from bronto cron
88
+ if (Mage::helper('bronto_reminder')->canUseMageCron() || $brontoCron) {
89
+ if (Mage::helper('bronto_reminder')->isEnabled()) {
90
+ $result = Mage::getModel('bronto_reminder/rule')->sendReminderEmails();
91
+
92
+ return $result;
93
+ } else {
94
+ return 'Bronto_Reminder module is not enabled.';
95
+ }
96
  }
97
  Mage::helper('bronto_reminder')->writeDebug('Done!');
98
+
99
+ return $this;
100
  }
101
 
102
  /**
104
  * remove from bronto_reminder_rule_coupon
105
  *
106
  * @param Varien_Event_Observer $observer
107
+ *
108
  * @return Varien_Event_Observer
109
  */
110
  public function updateReminderQueue(Varien_Event_Observer $observer)
111
  {
112
+ $object = $observer->getEvent()->getDataObject();
113
  $filterField = false;
114
  $filterValue = false;
115
 
116
  if ($object instanceof Mage_Wishlist_Model_Wishlist) {
117
+ $wishlist = $object;
118
  $collection = $wishlist->getItemCollection();
119
 
120
  if (0 === $collection->count()) {
131
  }
132
 
133
  if ($filterField && $filterValue) {
134
+ // Quote/Wishlist is not active, so remove from queue if exists
135
  Mage::getModel('bronto_reminder/rule')
136
  ->removeFromReminders($filterField, $filterValue);
137
  }
app/code/community/Bronto/Reminder/Model/Rule.php CHANGED
@@ -1,15 +1,17 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
- * @method Bronto_Reminder_Model_Mysql4_Rule _getResource()
8
  */
9
- class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
 
10
  {
11
  /**
12
  * Contains data defined per store view, will be used in Messages as variables
 
13
  * @var array
14
  */
15
  protected $_messageData = array();
@@ -29,7 +31,12 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
29
  {
30
  Mage_Core_Model_Abstract::_afterLoad();
31
 
32
- if (Mage::helper('bronto_verify')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('<=', 6), 9, 10, 11))) {
 
 
 
 
 
33
  $conditionsArr = unserialize($this->getConditionsSerialized());
34
  if (!empty($conditionsArr) && is_array($conditionsArr)) {
35
  $this->getConditions()->loadArray($conditionsArr);
@@ -39,8 +46,10 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
39
  $messageData = $this->_getResource()->getMessageData($this->getId());
40
 
41
  foreach ($messageData as $data) {
42
- $message = (empty($data['message_id'])) ? null : $data['message_id'];
43
- $this->setData('store_message_' . $data['store_id'], $message);
 
 
44
  }
45
 
46
  return $this;
@@ -91,12 +100,15 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
91
  if (!$this->hasData('website_ids')) {
92
  $this->setData('website_ids', $this->_getResource()->getWebsiteIds($this->getId()));
93
  }
 
94
  return $this->_getData('website_ids');
95
  }
96
 
97
  /**
98
  * Get array of Registered User abandons and then Guest abandons
 
99
  * @param int $limit
 
100
  * @return array
101
  */
102
  protected function _getRecipients($limit)
@@ -107,8 +119,10 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
107
 
108
  /**
109
  * Get customer object for recipient
110
- * @param array $recipient
 
111
  * @param Mage_Sales_Model_Quote $quote
 
112
  * @return boolean|Mage_Customer_Model_Customer
113
  */
114
  protected function _getRecipientCustomer(array $recipient, $quote)
@@ -118,7 +132,7 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
118
  $customer = Mage::getModel('customer/customer')->load($recipient['customer_id']);
119
  } elseif ($quote) {
120
  // Guest Abandon. Create Customer on the fly
121
- $storeId = $recipient['store_id'];
122
  $customer = Mage::getModel('customer/customer')
123
  ->setFirstName($quote->getCustomerFirstname())
124
  ->setLastName($quote->getCustomerLastname())
@@ -139,19 +153,24 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
139
  * Send reminder emails
140
  *
141
  * @param bool $dontSend
 
142
  * @return Bronto_Reminder_Model_Rule
143
  */
144
  public function sendReminderEmails($dontSend = false)
145
  {
146
  // If we aren't matching and we aren't allow to send emails, say so
147
- if (!$dontSend && !Mage::helper('bronto_reminder')->isAllowSendForAny() || !Mage::helper('bronto_reminder')->isEnabledForAny()) {
 
 
 
148
  Mage::helper('bronto_reminder')->writeInfo(Mage::helper('bronto_reminder')->getNotAllowedText());
 
149
  return $this;
150
  }
151
 
152
  /* @var $mail Bronto_Reminder_Model_Email_Message */
153
- $mail = Mage::getModel('bronto_reminder/email_message');
154
- $limit = Mage::helper('bronto_reminder')->getOneRunLimit();
155
  $identity = Mage::helper('bronto_reminder')->getEmailIdentity();
156
 
157
  $this->_matchCustomers();
@@ -163,13 +182,13 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
163
  // Get Array of Recipients
164
  $recipients = $this->_getRecipients($limit);
165
 
166
- $total = 0;
167
  $success = 0;
168
- $error = 0;
169
  foreach ($recipients as $recipient) {
170
  $total++;
171
 
172
- $quote = false;
173
  $wishlist = false;
174
 
175
  // Load Store
@@ -223,12 +242,12 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
223
  }
224
 
225
  $templateVars = array(
226
- 'store' => $store,
227
- 'customer' => $customer,
228
- 'promotion_name' => $messageData['label'],
229
  'promotion_description' => $messageData['description'],
230
- 'coupon' => $coupon,
231
- 'rule' => $this,
232
  );
233
 
234
 
@@ -242,8 +261,12 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
242
  Mage::helper('bronto_reminder')->writeDebug('Sending message to: ' . $customer->getEmail());
243
 
244
  try {
245
- $message = Mage::helper('bronto_reminder/message')->getMessageById($messageData['message_id'], $store->getId(), $store->getWebsiteId());
246
- $mail->setTemplateSendType('transactional');
 
 
 
 
247
  $mail->sendTransactional(
248
  $message,
249
  $identity,
@@ -263,7 +286,10 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
263
  $this->_getResource()
264
  ->deactivateMatchedCustomer($recipient['unique_id'])
265
  ->addNotificationLog(
266
- $recipient['rule_id'], $recipient['unique_id'], $mail->getLastDeliveryId(), $messageData['message_id']
 
 
 
267
  );
268
 
269
  $success++;
@@ -275,9 +301,9 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
275
  }
276
 
277
  return array(
278
- 'total' => $total,
279
  'success' => $success,
280
- 'error' => $error,
281
  );
282
  }
283
 
@@ -288,9 +314,9 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
288
  */
289
  protected function _matchCustomers()
290
  {
291
- $threshold = Mage::helper('bronto_reminder')->getSendFailureThreshold();
292
  $currentDate = Mage::getModel('core/date')->date('Y-m-d');
293
- $rules = $this->getCollection()
294
  ->addDateFilter($currentDate)
295
  ->addIsActiveFilter(1);
296
 
@@ -299,14 +325,14 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
299
  }
300
 
301
  foreach ($rules as $rule) {
302
- // $this->_getResource()->deactivateMatchedCustomers($rule->getId());
303
 
304
  if ($rule->getSalesruleId()) {
305
  /* @var $salesRule Mage_SalesRule_Model_Rule */
306
- $salesRule = Mage::getSingleton('salesrule/rule')->load($rule->getSalesruleId());
307
  $websiteIds = array_intersect($rule->getWebsiteIds(), $salesRule->getWebsiteIds());
308
  } else {
309
- $salesRule = null;
310
  $websiteIds = $rule->getWebsiteIds();
311
  }
312
 
@@ -326,6 +352,7 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
326
  *
327
  * @param int $ruleId
328
  * @param int $storeId
 
329
  * @return array|false
330
  */
331
  public function getMessageData($ruleId, $storeId)
@@ -340,14 +367,16 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
340
  return false;
341
  }
342
  }
 
343
  return $this->_messageData[$ruleId][$storeId];
344
  }
345
 
346
  /**
347
- * @param int $ruleId
348
- * @param int $storeId
349
- * @param int $customerId
350
  * @param string $messageId
 
351
  * @return boolean|array
352
  */
353
  public function getRuleLogItems($ruleId, $storeId, $customerId, $messageId = null)
@@ -355,16 +384,15 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
355
  if ($data = $this->_getResource()->getRuleLogItemsData($ruleId, $storeId, $customerId, $messageId)) {
356
  return $data;
357
  }
 
358
  return false;
359
  }
360
 
361
  /**
362
  * Remove row from coupon table by column, value and store_id
363
  *
364
- * @param type $column
365
- * @param type $value
366
- * @param type $storeId
367
- * @return Bronto_Reminder_Model_Mysql4_Rule
368
  */
369
  public function removeFromReminders($column, $value)
370
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ *
7
+ * @method Bronto_Reminder_Model_Mysql4_Rule _getResource()
8
  */
9
+ class Bronto_Reminder_Model_Rule
10
+ extends Mage_Rule_Model_Rule
11
  {
12
  /**
13
  * Contains data defined per store view, will be used in Messages as variables
14
+ *
15
  * @var array
16
  */
17
  protected $_messageData = array();
31
  {
32
  Mage_Core_Model_Abstract::_afterLoad();
33
 
34
+ if (Mage::helper('bronto_verify')->isVersionMatch(
35
+ Mage::getVersionInfo(),
36
+ 1,
37
+ array(array('<=', 6), 9, 10, 11)
38
+ )
39
+ ) {
40
  $conditionsArr = unserialize($this->getConditionsSerialized());
41
  if (!empty($conditionsArr) && is_array($conditionsArr)) {
42
  $this->getConditions()->loadArray($conditionsArr);
46
  $messageData = $this->_getResource()->getMessageData($this->getId());
47
 
48
  foreach ($messageData as $data) {
49
+ $message = (empty($data['message_id'])) ? null : $data['message_id'];
50
+ $sendType = (empty($data['send_type'])) ? 'transactional' : $data['send_type'];
51
+ $this->setData('store_message_' . $data['store_id'], $message)
52
+ ->setData('store_message_sendtype_' . $data['store_id'], $sendType);
53
  }
54
 
55
  return $this;
100
  if (!$this->hasData('website_ids')) {
101
  $this->setData('website_ids', $this->_getResource()->getWebsiteIds($this->getId()));
102
  }
103
+
104
  return $this->_getData('website_ids');
105
  }
106
 
107
  /**
108
  * Get array of Registered User abandons and then Guest abandons
109
+ *
110
  * @param int $limit
111
+ *
112
  * @return array
113
  */
114
  protected function _getRecipients($limit)
119
 
120
  /**
121
  * Get customer object for recipient
122
+ *
123
+ * @param array $recipient
124
  * @param Mage_Sales_Model_Quote $quote
125
+ *
126
  * @return boolean|Mage_Customer_Model_Customer
127
  */
128
  protected function _getRecipientCustomer(array $recipient, $quote)
132
  $customer = Mage::getModel('customer/customer')->load($recipient['customer_id']);
133
  } elseif ($quote) {
134
  // Guest Abandon. Create Customer on the fly
135
+ $storeId = $recipient['store_id'];
136
  $customer = Mage::getModel('customer/customer')
137
  ->setFirstName($quote->getCustomerFirstname())
138
  ->setLastName($quote->getCustomerLastname())
153
  * Send reminder emails
154
  *
155
  * @param bool $dontSend
156
+ *
157
  * @return Bronto_Reminder_Model_Rule
158
  */
159
  public function sendReminderEmails($dontSend = false)
160
  {
161
  // If we aren't matching and we aren't allow to send emails, say so
162
+ if (!$dontSend &&
163
+ !Mage::helper('bronto_reminder')->isAllowSendForAny() ||
164
+ !Mage::helper('bronto_reminder')->isEnabledForAny()
165
+ ) {
166
  Mage::helper('bronto_reminder')->writeInfo(Mage::helper('bronto_reminder')->getNotAllowedText());
167
+
168
  return $this;
169
  }
170
 
171
  /* @var $mail Bronto_Reminder_Model_Email_Message */
172
+ $mail = Mage::getModel('bronto_reminder/email_message');
173
+ $limit = Mage::helper('bronto_reminder')->getOneRunLimit();
174
  $identity = Mage::helper('bronto_reminder')->getEmailIdentity();
175
 
176
  $this->_matchCustomers();
182
  // Get Array of Recipients
183
  $recipients = $this->_getRecipients($limit);
184
 
185
+ $total = 0;
186
  $success = 0;
187
+ $error = 0;
188
  foreach ($recipients as $recipient) {
189
  $total++;
190
 
191
+ $quote = false;
192
  $wishlist = false;
193
 
194
  // Load Store
242
  }
243
 
244
  $templateVars = array(
245
+ 'store' => $store,
246
+ 'customer' => $customer,
247
+ 'promotion_name' => $messageData['label'],
248
  'promotion_description' => $messageData['description'],
249
+ 'coupon' => $coupon,
250
+ 'rule' => $this,
251
  );
252
 
253
 
261
  Mage::helper('bronto_reminder')->writeDebug('Sending message to: ' . $customer->getEmail());
262
 
263
  try {
264
+ $message = Mage::helper('bronto_reminder/message')->getMessageById(
265
+ $messageData['message_id'],
266
+ $store->getId(),
267
+ $store->getWebsiteId()
268
+ );
269
+ $mail->setTemplateSendType($messageData['send_type']);
270
  $mail->sendTransactional(
271
  $message,
272
  $identity,
286
  $this->_getResource()
287
  ->deactivateMatchedCustomer($recipient['unique_id'])
288
  ->addNotificationLog(
289
+ $recipient['rule_id'],
290
+ $recipient['unique_id'],
291
+ $mail->getLastDeliveryId(),
292
+ $messageData['message_id']
293
  );
294
 
295
  $success++;
301
  }
302
 
303
  return array(
304
+ 'total' => $total,
305
  'success' => $success,
306
+ 'error' => $error,
307
  );
308
  }
309
 
314
  */
315
  protected function _matchCustomers()
316
  {
317
+ $threshold = Mage::helper('bronto_reminder')->getSendFailureThreshold();
318
  $currentDate = Mage::getModel('core/date')->date('Y-m-d');
319
+ $rules = $this->getCollection()
320
  ->addDateFilter($currentDate)
321
  ->addIsActiveFilter(1);
322
 
325
  }
326
 
327
  foreach ($rules as $rule) {
328
+ // $this->_getResource()->deactivateMatchedCustomers($rule->getId());
329
 
330
  if ($rule->getSalesruleId()) {
331
  /* @var $salesRule Mage_SalesRule_Model_Rule */
332
+ $salesRule = Mage::getSingleton('salesrule/rule')->load($rule->getSalesruleId());
333
  $websiteIds = array_intersect($rule->getWebsiteIds(), $salesRule->getWebsiteIds());
334
  } else {
335
+ $salesRule = null;
336
  $websiteIds = $rule->getWebsiteIds();
337
  }
338
 
352
  *
353
  * @param int $ruleId
354
  * @param int $storeId
355
+ *
356
  * @return array|false
357
  */
358
  public function getMessageData($ruleId, $storeId)
367
  return false;
368
  }
369
  }
370
+
371
  return $this->_messageData[$ruleId][$storeId];
372
  }
373
 
374
  /**
375
+ * @param int $ruleId
376
+ * @param int $storeId
377
+ * @param int $customerId
378
  * @param string $messageId
379
+ *
380
  * @return boolean|array
381
  */
382
  public function getRuleLogItems($ruleId, $storeId, $customerId, $messageId = null)
384
  if ($data = $this->_getResource()->getRuleLogItemsData($ruleId, $storeId, $customerId, $messageId)) {
385
  return $data;
386
  }
387
+
388
  return false;
389
  }
390
 
391
  /**
392
  * Remove row from coupon table by column, value and store_id
393
  *
394
+ * @param $column
395
+ * @param $value
 
 
396
  */
397
  public function removeFromReminders($column, $value)
398
  {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
@@ -42,6 +41,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
42
  public function loadValueOptions()
43
  {
44
  $this->setValueOption(array());
 
45
  return $this;
46
  }
47
 
@@ -54,11 +54,12 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
54
  {
55
  $this->setOperatorOption(array(
56
  '==' => Mage::helper('rule')->__('for'),
57
- // '>' => Mage::helper('rule')->__('for greater than'),
58
- // '>=' => Mage::helper('rule')->__('for or greater than'),
59
- // '<' => Mage::helper('rule')->__('for less than'),
60
- // '<=' => Mage::helper('rule')->__('for or less than'),
61
  ));
 
62
  return $this;
63
  }
64
 
@@ -80,10 +81,11 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
80
  public function loadAttributeOptions()
81
  {
82
  $this->setAttributeOption(array(
83
- 'days' => Mage::helper('bronto_reminder')->__('days'),
84
- 'hours' => Mage::helper('bronto_reminder')->__('hours'),
85
  'minutes' => Mage::helper('bronto_reminder')->__('minutes')
86
  ));
 
87
  return $this;
88
  }
89
 
@@ -96,7 +98,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
96
  {
97
  return $this->getTypeElementHtml()
98
  . Mage::helper('bronto_reminder')->__('Shopping cart is not empty and abandoned for %s %s and %s of these conditions match:',
99
- // $this->getOperatorElementHtml(),
100
  $this->getValueElementHtml(),
101
  $this->getAttributeElementHtml(),
102
  $this->getAggregatorElement()->getHtml())
@@ -106,15 +108,16 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
106
  /**
107
  * Get condition SQL select
108
  *
109
- * @param $rule
110
  * @param int|Zend_Db_Expr $website
 
111
  * @return Varien_Db_Select
112
  */
113
  protected function _prepareConditionsSql($rule, $website)
114
  {
115
  $attributeValue = strtolower($this->getAttribute());
116
  $conditionValue = (int)$this->getValue();
117
- $requiredValue = 1;
118
 
119
  if ($conditionValue <= 0) {
120
  Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value greater than 0.', $attributeValue));
@@ -157,16 +160,17 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
157
  /**
158
  * Get base SQL select
159
  *
160
- * @param $rule
161
  * @param int|Zend_Db_Expr $website
 
162
  * @return Varien_Db_Select
163
  */
164
  public function getConditionsSql($rule, $website)
165
  {
166
- $select = $this->_prepareConditionsSql($rule, $website);
167
- $required = $this->_getRequiredValidation();
168
  $aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
169
- $operator = $required ? '=' : '<>';
170
  $conditions = array();
171
 
172
  foreach ($this->getConditions() as $condition) {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
41
  public function loadValueOptions()
42
  {
43
  $this->setValueOption(array());
44
+
45
  return $this;
46
  }
47
 
54
  {
55
  $this->setOperatorOption(array(
56
  '==' => Mage::helper('rule')->__('for'),
57
+ // '>' => Mage::helper('rule')->__('for greater than'),
58
+ // '>=' => Mage::helper('rule')->__('for or greater than'),
59
+ // '<' => Mage::helper('rule')->__('for less than'),
60
+ // '<=' => Mage::helper('rule')->__('for or less than'),
61
  ));
62
+
63
  return $this;
64
  }
65
 
81
  public function loadAttributeOptions()
82
  {
83
  $this->setAttributeOption(array(
84
+ 'days' => Mage::helper('bronto_reminder')->__('days'),
85
+ 'hours' => Mage::helper('bronto_reminder')->__('hours'),
86
  'minutes' => Mage::helper('bronto_reminder')->__('minutes')
87
  ));
88
+
89
  return $this;
90
  }
91
 
98
  {
99
  return $this->getTypeElementHtml()
100
  . Mage::helper('bronto_reminder')->__('Shopping cart is not empty and abandoned for %s %s and %s of these conditions match:',
101
+ // $this->getOperatorElementHtml(),
102
  $this->getValueElementHtml(),
103
  $this->getAttributeElementHtml(),
104
  $this->getAggregatorElement()->getHtml())
108
  /**
109
  * Get condition SQL select
110
  *
111
+ * @param $rule
112
  * @param int|Zend_Db_Expr $website
113
+ *
114
  * @return Varien_Db_Select
115
  */
116
  protected function _prepareConditionsSql($rule, $website)
117
  {
118
  $attributeValue = strtolower($this->getAttribute());
119
  $conditionValue = (int)$this->getValue();
120
+ $requiredValue = 1;
121
 
122
  if ($conditionValue <= 0) {
123
  Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value greater than 0.', $attributeValue));
160
  /**
161
  * Get base SQL select
162
  *
163
+ * @param $rule
164
  * @param int|Zend_Db_Expr $website
165
+ *
166
  * @return Varien_Db_Select
167
  */
168
  public function getConditionsSql($rule, $website)
169
  {
170
+ $select = $this->_prepareConditionsSql($rule, $website);
171
+ $required = $this->_getRequiredValidation();
172
  $aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
173
+ $operator = $required ? '=' : '<>';
174
  $conditions = array();
175
 
176
  foreach ($this->getConditions() as $condition) {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Amount.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_Model_Condition_Abstract
9
  {
10
  /**
11
  * Description for protected
 
12
  * @var string
13
  */
14
  protected $_inputType = 'numeric';
@@ -28,7 +28,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_M
28
  public function getNewChildSelectOptions()
29
  {
30
  return array('value' => $this->getType(),
31
- 'label' => Mage::helper('bronto_reminder')->__('Total Amount'));
32
  }
33
 
34
  /**
@@ -39,9 +39,10 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_M
39
  public function loadAttributeOptions()
40
  {
41
  $this->setAttributeOption(array(
42
- 'subtotal' => Mage::helper('bronto_reminder')->__('subtotal'),
43
  'grand_total' => Mage::helper('bronto_reminder')->__('grand total')
44
  ));
 
45
  return $this;
46
  }
47
 
@@ -61,13 +62,14 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_M
61
  /**
62
  * Build condition limitations sql string for specific website
63
  *
64
- * @param $rule
65
  * @param int | Zend_Db_Expr $website
 
66
  * @return Varien_Db_Select
67
  */
68
  public function getConditionsSql($rule, $website)
69
  {
70
- $table = $this->getResource()->getTable('sales/quote');
71
  $operator = $this->getResource()->getSqlOperator($this->getOperator());
72
 
73
  $select = $this->getResource()->createSelect();
@@ -89,6 +91,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_M
89
  $select->where("{$field} {$operator} ?", $this->getValue());
90
  $select->where('quote.entity_id = root.quote_id');
91
  $select->limit(1);
 
92
  return $select;
93
  }
94
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_Model_Condition_Abstract
8
  {
9
  /**
10
  * Description for protected
11
+ *
12
  * @var string
13
  */
14
  protected $_inputType = 'numeric';
28
  public function getNewChildSelectOptions()
29
  {
30
  return array('value' => $this->getType(),
31
+ 'label' => Mage::helper('bronto_reminder')->__('Total Amount'));
32
  }
33
 
34
  /**
39
  public function loadAttributeOptions()
40
  {
41
  $this->setAttributeOption(array(
42
+ 'subtotal' => Mage::helper('bronto_reminder')->__('subtotal'),
43
  'grand_total' => Mage::helper('bronto_reminder')->__('grand total')
44
  ));
45
+
46
  return $this;
47
  }
48
 
62
  /**
63
  * Build condition limitations sql string for specific website
64
  *
65
+ * @param $rule
66
  * @param int | Zend_Db_Expr $website
67
+ *
68
  * @return Varien_Db_Select
69
  */
70
  public function getConditionsSql($rule, $website)
71
  {
72
+ $table = $this->getResource()->getTable('sales/quote');
73
  $operator = $this->getResource()->getSqlOperator($this->getOperator());
74
 
75
  $select = $this->getResource()->createSelect();
91
  $select->where("{$field} {$operator} ?", $this->getValue());
92
  $select->where('quote.entity_id = root.quote_id');
93
  $select->limit(1);
94
+
95
  return $select;
96
  }
97
  }
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Attributes.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -27,7 +26,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Remind
27
  public function getNewChildSelectOptions()
28
  {
29
  return array('value' => $this->getType(),
30
- 'label' => Mage::helper('bronto_reminder')->__('Numeric Attribute'));
31
  }
32
 
33
  /**
@@ -38,12 +37,13 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Remind
38
  public function loadAttributeOptions()
39
  {
40
  $this->setAttributeOption(array(
41
- 'weight' => Mage::helper('bronto_reminder')->__('weight'),
42
  'row_weight' => Mage::helper('bronto_reminder')->__('row weight'),
43
- 'qty' => Mage::helper('bronto_reminder')->__('quantity'),
44
- 'price' => Mage::helper('bronto_reminder')->__('base price'),
45
- 'base_cost' => Mage::helper('bronto_reminder')->__('base cost')
46
  ));
 
47
  return $this;
48
  }
49
 
@@ -63,15 +63,16 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Remind
63
  /**
64
  * Build condition limitations sql string for specific website
65
  *
66
- * @param $rule
67
  * @param int | Zend_Db_Expr $website
 
68
  * @return Varien_Db_Select
69
  */
70
  public function getConditionsSql($rule, $website)
71
  {
72
- $quoteTable = $this->getResource()->getTable('sales/quote');
73
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
74
- $operator = $this->getResource()->getSqlOperator($this->getOperator());
75
 
76
  $select = $this->getResource()->createSelect();
77
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
@@ -107,6 +108,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Remind
107
  $select->where("{$field} {$operator} ?", $this->getValue());
108
  $select->where('quote.entity_id = root.quote_id');
109
  $select->limit(1);
 
110
  return $select;
111
  }
112
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Reminder_Model_Condition_Abstract
8
  {
26
  public function getNewChildSelectOptions()
27
  {
28
  return array('value' => $this->getType(),
29
+ 'label' => Mage::helper('bronto_reminder')->__('Numeric Attribute'));
30
  }
31
 
32
  /**
37
  public function loadAttributeOptions()
38
  {
39
  $this->setAttributeOption(array(
40
+ 'weight' => Mage::helper('bronto_reminder')->__('weight'),
41
  'row_weight' => Mage::helper('bronto_reminder')->__('row weight'),
42
+ 'qty' => Mage::helper('bronto_reminder')->__('quantity'),
43
+ 'price' => Mage::helper('bronto_reminder')->__('base price'),
44
+ 'base_cost' => Mage::helper('bronto_reminder')->__('base cost')
45
  ));
46
+
47
  return $this;
48
  }
49
 
63
  /**
64
  * Build condition limitations sql string for specific website
65
  *
66
+ * @param $rule
67
  * @param int | Zend_Db_Expr $website
68
+ *
69
  * @return Varien_Db_Select
70
  */
71
  public function getConditionsSql($rule, $website)
72
  {
73
+ $quoteTable = $this->getResource()->getTable('sales/quote');
74
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
75
+ $operator = $this->getResource()->getSqlOperator($this->getOperator());
76
 
77
  $select = $this->getResource()->createSelect();
78
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
108
  $select->where("{$field} {$operator} ?", $this->getValue());
109
  $select->where('quote.entity_id = root.quote_id');
110
  $select->limit(1);
111
+
112
  return $select;
113
  }
114
  }
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Combine.php CHANGED
@@ -1,16 +1,13 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Combine extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
10
  /**
11
- * Intialize model
12
- *
13
- * @return void
14
  */
15
  public function __construct()
16
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Combine extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
9
  /**
10
+ * Initialize model
 
 
11
  */
12
  public function __construct()
13
  {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Couponcode.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Couponcode extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -22,7 +21,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Couponcode extends Bronto_Remind
22
  public function getNewChildSelectOptions()
23
  {
24
  return array('value' => $this->getType(),
25
- 'label' => Mage::helper('bronto_reminder')->__('Coupon Code'));
26
  }
27
 
28
  /**
@@ -59,19 +58,21 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Couponcode extends Bronto_Remind
59
  '1' => Mage::helper('bronto_reminder')->__('has'),
60
  '0' => Mage::helper('bronto_reminder')->__('does not have')
61
  ));
 
62
  return $this;
63
  }
64
 
65
  /**
66
  * Get SQL select
67
  *
68
- * @param $rule
69
  * @param int | Zend_Db_Expr $website
 
70
  * @return Varien_Db_Select
71
  */
72
  public function getConditionsSql($rule, $website)
73
  {
74
- $table = $this->getResource()->getTable('sales/quote');
75
  $inversion = ((int)$this->getValue() ? '' : '!');
76
 
77
  $select = $this->getResource()->createSelect();
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Couponcode extends Bronto_Reminder_Model_Condition_Abstract
8
  {
21
  public function getNewChildSelectOptions()
22
  {
23
  return array('value' => $this->getType(),
24
+ 'label' => Mage::helper('bronto_reminder')->__('Coupon Code'));
25
  }
26
 
27
  /**
58
  '1' => Mage::helper('bronto_reminder')->__('has'),
59
  '0' => Mage::helper('bronto_reminder')->__('does not have')
60
  ));
61
+
62
  return $this;
63
  }
64
 
65
  /**
66
  * Get SQL select
67
  *
68
+ * @param $rule
69
  * @param int | Zend_Db_Expr $website
70
+ *
71
  * @return Varien_Db_Select
72
  */
73
  public function getConditionsSql($rule, $website)
74
  {
75
+ $table = $this->getResource()->getTable('sales/quote');
76
  $inversion = ((int)$this->getValue() ? '' : '!');
77
 
78
  $select = $this->getResource()->createSelect();
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Itemsquantity.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Itemsquantity extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -27,7 +26,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Itemsquantity extends Bronto_Rem
27
  public function getNewChildSelectOptions()
28
  {
29
  return array('value' => $this->getType(),
30
- 'label' => Mage::helper('bronto_reminder')->__('Cart Line Items'));
31
  }
32
 
33
  /**
@@ -46,13 +45,14 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Itemsquantity extends Bronto_Rem
46
  /**
47
  * Get SQL select for matching shopping cart items count
48
  *
49
- * @param $rule
50
  * @param int | Zend_Db_Expr $website
 
51
  * @return Varien_Db_Select
52
  */
53
  public function getConditionsSql($rule, $website)
54
  {
55
- $table = $this->getResource()->getTable('sales/quote');
56
  $operator = $this->getResource()->getSqlOperator($this->getOperator());
57
 
58
  $select = $this->getResource()->createSelect();
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Itemsquantity extends Bronto_Reminder_Model_Condition_Abstract
8
  {
26
  public function getNewChildSelectOptions()
27
  {
28
  return array('value' => $this->getType(),
29
+ 'label' => Mage::helper('bronto_reminder')->__('Cart Line Items'));
30
  }
31
 
32
  /**
45
  /**
46
  * Get SQL select for matching shopping cart items count
47
  *
48
+ * @param $rule
49
  * @param int | Zend_Db_Expr $website
50
+ *
51
  * @return Varien_Db_Select
52
  */
53
  public function getConditionsSql($rule, $website)
54
  {
55
+ $table = $this->getResource()->getTable('sales/quote');
56
  $operator = $this->getResource()->getSqlOperator($this->getOperator());
57
 
58
  $select = $this->getResource()->createSelect();
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Sku.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Sku extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -22,7 +21,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Sku extends Bronto_Reminder_Mode
22
  public function getNewChildSelectOptions()
23
  {
24
  return array('value' => $this->getType(),
25
- 'label' => Mage::helper('bronto_reminder')->__('SKU'));
26
  }
27
 
28
  /**
@@ -41,26 +40,28 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Sku extends Bronto_Reminder_Mode
41
  /**
42
  * Initialize value select options
43
  *
44
- * @return Bronto_Reminder_Model_Rule_Condition_Wishlist_Sku
45
  */
46
  public function loadValueOptions()
47
  {
48
  $this->setValueOption(Mage::getSingleton('adminhtml/system_store')->getStoreOptionHash());
 
49
  return $this;
50
  }
51
 
52
  /**
53
  * Get SQL select
54
  *
55
- * @param $rule
56
  * @param int | Zend_Db_Expr $website
 
57
  * @return Varien_Db_Select
58
  */
59
  public function getConditionsSql($rule, $website)
60
  {
61
- $quoteTable = $this->getResource()->getTable('sales/quote');
62
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
63
- $operator = $this->getResource()->getSqlOperator($this->getOperator());
64
 
65
  $select = $this->getResource()->createSelect();
66
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Sku extends Bronto_Reminder_Model_Condition_Abstract
8
  {
21
  public function getNewChildSelectOptions()
22
  {
23
  return array('value' => $this->getType(),
24
+ 'label' => Mage::helper('bronto_reminder')->__('SKU'));
25
  }
26
 
27
  /**
40
  /**
41
  * Initialize value select options
42
  *
43
+ * @return $this
44
  */
45
  public function loadValueOptions()
46
  {
47
  $this->setValueOption(Mage::getSingleton('adminhtml/system_store')->getStoreOptionHash());
48
+
49
  return $this;
50
  }
51
 
52
  /**
53
  * Get SQL select
54
  *
55
+ * @param $rule
56
  * @param int | Zend_Db_Expr $website
57
+ *
58
  * @return Varien_Db_Select
59
  */
60
  public function getConditionsSql($rule, $website)
61
  {
62
+ $quoteTable = $this->getResource()->getTable('sales/quote');
63
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
64
+ $operator = $this->getResource()->getSqlOperator($this->getOperator());
65
 
66
  $select = $this->getResource()->createSelect();
67
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Storeview.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Storeview extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -22,7 +21,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Storeview extends Bronto_Reminde
22
  public function getNewChildSelectOptions()
23
  {
24
  return array('value' => $this->getType(),
25
- 'label' => Mage::helper('bronto_reminder')->__('Store View'));
26
  }
27
 
28
  /**
@@ -46,6 +45,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Storeview extends Bronto_Reminde
46
  public function loadValueOptions()
47
  {
48
  $this->setValueOption(Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm());
 
49
  return $this;
50
  }
51
 
@@ -81,21 +81,23 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Storeview extends Bronto_Reminde
81
  '==' => Mage::helper('rule')->__('from'),
82
  '!=' => Mage::helper('rule')->__('not from')
83
  ));
 
84
  return $this;
85
  }
86
 
87
  /**
88
  * Get SQL select
89
  *
90
- * @param $rule
91
  * @param int | Zend_Db_Expr $website
 
92
  * @return Varien_Db_Select
93
  */
94
  public function getConditionsSql($rule, $website)
95
  {
96
- $quoteTable = $this->getResource()->getTable('sales/quote');
97
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
98
- $operator = $this->getResource()->getSqlOperator($this->getOperator());
99
 
100
  $select = $this->getResource()->createSelect();
101
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Storeview extends Bronto_Reminder_Model_Condition_Abstract
8
  {
21
  public function getNewChildSelectOptions()
22
  {
23
  return array('value' => $this->getType(),
24
+ 'label' => Mage::helper('bronto_reminder')->__('Store View'));
25
  }
26
 
27
  /**
45
  public function loadValueOptions()
46
  {
47
  $this->setValueOption(Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm());
48
+
49
  return $this;
50
  }
51
 
81
  '==' => Mage::helper('rule')->__('from'),
82
  '!=' => Mage::helper('rule')->__('not from')
83
  ));
84
+
85
  return $this;
86
  }
87
 
88
  /**
89
  * Get SQL select
90
  *
91
+ * @param $rule
92
  * @param int | Zend_Db_Expr $website
93
+ *
94
  * @return Varien_Db_Select
95
  */
96
  public function getConditionsSql($rule, $website)
97
  {
98
+ $quoteTable = $this->getResource()->getTable('sales/quote');
99
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
100
+ $operator = $this->getResource()->getSqlOperator($this->getOperator());
101
 
102
  $select = $this->getResource()->createSelect();
103
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Subcombine.php CHANGED
@@ -1,16 +1,13 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Subcombine extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
10
  /**
11
- * Intialize model
12
- *
13
- * @return void
14
  */
15
  public function __construct()
16
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Subcombine extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
9
  /**
10
+ * Initialize model
 
 
11
  */
12
  public function __construct()
13
  {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Subselection.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Subselection extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
@@ -45,6 +44,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Subselection extends Bronto_Remi
45
  '==' => Mage::helper('bronto_reminder')->__('found'),
46
  '!=' => Mage::helper('bronto_reminder')->__('not found')
47
  ));
 
48
  return $this;
49
  }
50
 
@@ -65,14 +65,15 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Subselection extends Bronto_Remi
65
  /**
66
  * Build query for matching shopping cart items
67
  *
68
- * @param $rule
69
  * @param int | Zend_Db_Expr $website
 
70
  * @return Varien_Db_Select
71
  */
72
  protected function _prepareConditionsSql($rule, $website)
73
  {
74
- $select = $this->getResource()->createSelect();
75
- $quoteTable = $this->getResource()->getTable('sales/quote');
76
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
77
 
78
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Subselection extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
44
  '==' => Mage::helper('bronto_reminder')->__('found'),
45
  '!=' => Mage::helper('bronto_reminder')->__('not found')
46
  ));
47
+
48
  return $this;
49
  }
50
 
65
  /**
66
  * Build query for matching shopping cart items
67
  *
68
+ * @param $rule
69
  * @param int | Zend_Db_Expr $website
70
+ *
71
  * @return Varien_Db_Select
72
  */
73
  protected function _prepareConditionsSql($rule, $website)
74
  {
75
+ $select = $this->getResource()->createSelect();
76
+ $quoteTable = $this->getResource()->getTable('sales/quote');
77
  $quoteItemTable = $this->getResource()->getTable('sales/quote_item');
78
 
79
  $select->from(array('item' => $quoteItemTable), array(new Zend_Db_Expr(1)));
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Totalquantity.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Totalquantity extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -27,7 +26,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Totalquantity extends Bronto_Rem
27
  public function getNewChildSelectOptions()
28
  {
29
  return array('value' => $this->getType(),
30
- 'label' => Mage::helper('bronto_reminder')->__('Items Quantity'));
31
  }
32
 
33
  /**
@@ -46,13 +45,14 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Totalquantity extends Bronto_Rem
46
  /**
47
  * Get SQL select for matching shopping cart products count
48
  *
49
- * @param $rule
50
  * @param int | Zend_Db_Expr $website
 
51
  * @return Varien_Db_Select
52
  */
53
  public function getConditionsSql($rule, $website)
54
  {
55
- $table = $this->getResource()->getTable('sales/quote');
56
  $operator = $this->getResource()->getSqlOperator($this->getOperator());
57
 
58
  $select = $this->getResource()->createSelect();
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Totalquantity extends Bronto_Reminder_Model_Condition_Abstract
8
  {
26
  public function getNewChildSelectOptions()
27
  {
28
  return array('value' => $this->getType(),
29
+ 'label' => Mage::helper('bronto_reminder')->__('Items Quantity'));
30
  }
31
 
32
  /**
45
  /**
46
  * Get SQL select for matching shopping cart products count
47
  *
48
+ * @param $rule
49
  * @param int | Zend_Db_Expr $website
50
+ *
51
  * @return Varien_Db_Select
52
  */
53
  public function getConditionsSql($rule, $website)
54
  {
55
+ $table = $this->getResource()->getTable('sales/quote');
56
  $operator = $this->getResource()->getSqlOperator($this->getOperator());
57
 
58
  $select = $this->getResource()->createSelect();
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Virtual.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Cart_Virtual extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -22,7 +21,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Virtual extends Bronto_Reminder_
22
  public function getNewChildSelectOptions()
23
  {
24
  return array('value' => $this->getType(),
25
- 'label' => Mage::helper('bronto_reminder')->__('Virtual Only'));
26
  }
27
 
28
  /**
@@ -59,14 +58,16 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Virtual extends Bronto_Reminder_
59
  '1' => Mage::helper('bronto_reminder')->__('has'),
60
  '0' => Mage::helper('bronto_reminder')->__('does not have')
61
  ));
 
62
  return $this;
63
  }
64
 
65
  /**
66
  * Get SQL select
67
  *
68
- * @param $rule
69
  * @param int | Zend_Db_Expr $website
 
70
  * @return Varien_Db_Select
71
  */
72
  public function getConditionsSql($rule, $website)
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Cart_Virtual extends Bronto_Reminder_Model_Condition_Abstract
8
  {
21
  public function getNewChildSelectOptions()
22
  {
23
  return array('value' => $this->getType(),
24
+ 'label' => Mage::helper('bronto_reminder')->__('Virtual Only'));
25
  }
26
 
27
  /**
58
  '1' => Mage::helper('bronto_reminder')->__('has'),
59
  '0' => Mage::helper('bronto_reminder')->__('does not have')
60
  ));
61
+
62
  return $this;
63
  }
64
 
65
  /**
66
  * Get SQL select
67
  *
68
+ * @param $rule
69
  * @param int | Zend_Db_Expr $website
70
+ *
71
  * @return Varien_Db_Select
72
  */
73
  public function getConditionsSql($rule, $website)
app/code/community/Bronto/Reminder/Model/Rule/Condition/Combine.php CHANGED
@@ -1,16 +1,13 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Combine extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
10
  /**
11
- * Intialize model
12
- *
13
- * @return void
14
  */
15
  public function __construct()
16
  {
@@ -35,6 +32,7 @@ class Bronto_Reminder_Model_Rule_Condition_Combine extends Bronto_Reminder_Model
35
  );
36
 
37
  $conditions = array_merge_recursive(parent::getNewChildSelectOptions(), $conditions);
 
38
  return $conditions;
39
  }
40
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Combine extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
9
  /**
10
+ * Initialize model
 
 
11
  */
12
  public function __construct()
13
  {
32
  );
33
 
34
  $conditions = array_merge_recursive(parent::getNewChildSelectOptions(), $conditions);
35
+
36
  return $conditions;
37
  }
38
  }
app/code/community/Bronto/Reminder/Model/Rule/Condition/Combine/Root.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_Model_Rule_Condition_Combine
9
  {
@@ -18,6 +17,7 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
18
  *
19
  * @param null|Bronto_Reminder_Model_Rule $rule
20
  * @param int | Zend_Db_Expr $website
 
21
  * @return Varien_Db_Select
22
  */
23
  protected function _prepareConditionsSql($rule, $website)
@@ -26,17 +26,15 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
26
 
27
  $conditionTypes = array();
28
  foreach ($this->getConditions() as $condition) {
29
- $type = explode('_', $condition->getType());
30
  $conditionTypes[] = array_pop($type);
31
  }
32
 
33
  // Define Tables
34
- $customerTable = $this->getResource()->getTable('customer/entity');
35
- $quoteTable = $this->getResource()->getTable('sales/quote');
36
- $storeTable = $this->getResource()->getTable('core/store');
37
- $logQuoteTable = Mage::getResourceSingleton('log/log')->getTable('log/quote_table');
38
- $logCustomerTable = Mage::getResourceSingleton('log/log')->getTable('log/customer');
39
- $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
40
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
41
 
42
  // If conditions are based on Cart or Wishlist
@@ -51,20 +49,15 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
51
  $subselect->from(
52
  array('quote' => $quoteTable),
53
  array(
54
- 'quote_id' => 'entity_id',
55
- 'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, IF(wishlist.customer_id IS NULL, 0, wishlist.customer_id), quote.customer_id)')
 
56
  )
57
  )
58
  ->where('quote.is_active = ?', 1)
59
  ->where('quote.items_count > ?', 0)
60
  ->where('quote.customer_email IS NOT NULL');
61
 
62
- $subselect->joinLeft(
63
- array('log' => $logQuoteTable),
64
- 'log.quote_id=quote.entity_id',
65
- array('visitor_id' => 'log.visitor_id')
66
- );
67
-
68
  $subselect->joinInner(
69
  array('store' => $storeTable),
70
  'quote.store_id=store.store_id',
@@ -91,20 +84,16 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
91
  $subselect->from(
92
  array('quote' => $quoteTable),
93
  array(
94
- 'quote_id' => 'entity_id',
95
- 'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, 0, quote.customer_id)'),
96
- 'wishlist_id' => new Zend_Db_Expr('0'),
 
97
  )
98
  )
99
  ->where('quote.is_active = ?', 1)
100
  ->where('quote.items_count > ?', 0)
101
- ->where('quote.customer_email IS NOT NULL');
102
-
103
- $subselect->joinLeft(
104
- array('log' => $logQuoteTable),
105
- 'log.quote_id=quote.entity_id',
106
- array('visitor_id' => 'log.visitor_id')
107
- );
108
 
109
  $subselect->joinInner(
110
  array('store' => $storeTable),
@@ -119,8 +108,9 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
119
  $subselect->from(
120
  array('customer' => $customerTable),
121
  array(
122
- 'quote_id' => new Zend_Db_Expr('0'),
123
- 'customer_id' => 'entity_id',
 
124
  )
125
  );
126
 
@@ -136,12 +126,6 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
136
  array()
137
  );
138
 
139
- $subselect->joinLeft(
140
- array('log' => $logCustomerTable),
141
- 'log.customer_id=customer.entity_id',
142
- array('visitor_id' => 'log.visitor_id')
143
- );
144
-
145
  $subselect->joinInner(
146
  array('store' => $storeTable),
147
  'wishlist_item.store_id=store.store_id',
@@ -151,16 +135,16 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
151
 
152
  // Set main select to pull use subselect as root and pull required fields
153
  $select->from(array('root' => $subselect), array(
154
- 'unique_id' => new Zend_Db_Expr(
155
- "CONCAT(:rule_id, '-', `root`.`store_id`, '-', IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`), '-', IF(`root`.`visitor_id` IS NULL, 0, `root`.`visitor_id`))"
156
- ),
157
  'store_id',
158
  'customer_id' => new Zend_Db_Expr("IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`)"),
159
- 'quote_id' => new Zend_Db_Expr("IF(`root`.`quote_id` IS NULL, 0, `root`.`quote_id`)"),
160
- 'wishlist_id' => new Zend_Db_Expr("IF(`root`.`wishlist_id` IS NULL, 0, `root`.`wishlist_id`)"),
161
- 'visitor_id' => new Zend_Db_Expr("IF(`root`.`visitor_id` IS NULL, 0, `root`.`visitor_id`)")
162
  ))
163
- ->group($groupby);
164
  }
165
 
166
  $couponTable = $this->getResource()->getTable('bronto_reminder/coupon');
@@ -176,18 +160,19 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
176
 
177
  /**
178
  * Get SQL select.
179
- * Rewrited for cover root conditions combination with additional condition by customer
180
  *
181
  * @param null|Bronto_Reminder_Model_Rule $rule
182
- * @param int | Zend_Db_Expr $website
 
183
  * @return Varien_Db_Select
184
  */
185
  public function getConditionsSql($rule, $website)
186
  {
187
- $select = $this->_prepareConditionsSql($rule, $website);
188
- $required = $this->_getRequiredValidation();
189
  $aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
190
- $operator = $required ? '=' : '<>';
191
  $conditions = array();
192
 
193
  foreach ($this->getConditions() as $condition) {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_Model_Rule_Condition_Combine
8
  {
17
  *
18
  * @param null|Bronto_Reminder_Model_Rule $rule
19
  * @param int | Zend_Db_Expr $website
20
+ *
21
  * @return Varien_Db_Select
22
  */
23
  protected function _prepareConditionsSql($rule, $website)
26
 
27
  $conditionTypes = array();
28
  foreach ($this->getConditions() as $condition) {
29
+ $type = explode('_', $condition->getType());
30
  $conditionTypes[] = array_pop($type);
31
  }
32
 
33
  // Define Tables
34
+ $customerTable = $this->getResource()->getTable('customer/entity');
35
+ $quoteTable = $this->getResource()->getTable('sales/quote');
36
+ $storeTable = $this->getResource()->getTable('core/store');
37
+ $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
 
 
38
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
39
 
40
  // If conditions are based on Cart or Wishlist
49
  $subselect->from(
50
  array('quote' => $quoteTable),
51
  array(
52
+ 'quote_id' => 'entity_id',
53
+ 'customer_email' => 'customer_email',
54
+ 'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, IF(wishlist.customer_id IS NULL, 0, wishlist.customer_id), quote.customer_id)')
55
  )
56
  )
57
  ->where('quote.is_active = ?', 1)
58
  ->where('quote.items_count > ?', 0)
59
  ->where('quote.customer_email IS NOT NULL');
60
 
 
 
 
 
 
 
61
  $subselect->joinInner(
62
  array('store' => $storeTable),
63
  'quote.store_id=store.store_id',
84
  $subselect->from(
85
  array('quote' => $quoteTable),
86
  array(
87
+ 'quote_id' => 'entity_id',
88
+ 'customer_email' => 'customer_email',
89
+ 'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, 0, quote.customer_id)'),
90
+ 'wishlist_id' => new Zend_Db_Expr('0'),
91
  )
92
  )
93
  ->where('quote.is_active = ?', 1)
94
  ->where('quote.items_count > ?', 0)
95
+ ->where('quote.customer_email IS NOT NULL')
96
+ ->order(array('quote.updated_at desc', 'quote.entity_id desc'));
 
 
 
 
 
97
 
98
  $subselect->joinInner(
99
  array('store' => $storeTable),
108
  $subselect->from(
109
  array('customer' => $customerTable),
110
  array(
111
+ 'quote_id' => new Zend_Db_Expr('0'),
112
+ 'customer_id' => 'entity_id',
113
+ 'customer_email' => 'email',
114
  )
115
  );
116
 
126
  array()
127
  );
128
 
 
 
 
 
 
 
129
  $subselect->joinInner(
130
  array('store' => $storeTable),
131
  'wishlist_item.store_id=store.store_id',
135
 
136
  // Set main select to pull use subselect as root and pull required fields
137
  $select->from(array('root' => $subselect), array(
138
+ 'unique_id' => new Zend_Db_Expr(
139
+ "CONCAT(:rule_id, '-', `root`.`store_id`, '-', `root`.`quote_id`, '-', `root`.`wishlist_id`, '-', `root`.`customer_email`)"
140
+ ),
141
  'store_id',
142
  'customer_id' => new Zend_Db_Expr("IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`)"),
143
+ 'customer_email',
144
+ 'quote_id' => new Zend_Db_Expr("IF(`root`.`quote_id` IS NULL, 0, `root`.`quote_id`)"),
145
+ 'wishlist_id' => new Zend_Db_Expr("IF(`root`.`wishlist_id` IS NULL, 0, `root`.`wishlist_id`)")
146
  ))
147
+ /*->group($groupby)*/;
148
  }
149
 
150
  $couponTable = $this->getResource()->getTable('bronto_reminder/coupon');
160
 
161
  /**
162
  * Get SQL select.
163
+ * Rewritten for cover root conditions combination with additional condition by customer
164
  *
165
  * @param null|Bronto_Reminder_Model_Rule $rule
166
+ * @param int | Zend_Db_Expr $website
167
+ *
168
  * @return Varien_Db_Select
169
  */
170
  public function getConditionsSql($rule, $website)
171
  {
172
+ $select = $this->_prepareConditionsSql($rule, $website);
173
+ $required = $this->_getRequiredValidation();
174
  $aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
175
+ $operator = $required ? '=' : '<>';
176
  $conditions = array();
177
 
178
  foreach ($this->getConditions() as $condition) {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
@@ -42,6 +41,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
42
  public function loadValueOptions()
43
  {
44
  $this->setValueOption(array());
 
45
  return $this;
46
  }
47
 
@@ -54,9 +54,10 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
54
  {
55
  $this->setOperatorOption(array(
56
  '==' => Mage::helper('rule')->__('for'),
57
- // '>' => Mage::helper('rule')->__('for greater than'),
58
- // '>=' => Mage::helper('rule')->__('for or greater than')
59
  ));
 
60
  return $this;
61
  }
62
 
@@ -79,7 +80,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
79
  {
80
  return $this->getTypeElementHtml()
81
  . Mage::helper('bronto_reminder')->__('Wishlist is not empty and abandoned for %s day(s) and %s of these conditions match:',
82
- // $this->getOperatorElementHtml(),
83
  $this->getValueElementHtml(),
84
  $this->getAggregatorElement()->getHtml())
85
  . $this->getRemoveLinkHtml();
@@ -90,6 +91,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
90
  *
91
  * @param $rule
92
  * @param $website
 
93
  * @return Varien_Db_Select
94
  */
95
  protected function _prepareConditionsSql($rule, $website)
@@ -101,7 +103,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
101
  // Convert to minutes
102
  $conditionValue *= 1440;
103
 
104
- $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
105
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
106
 
107
  $select = $this->getResource()->createSelect();
@@ -127,14 +129,15 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
127
  *
128
  * @param $rule
129
  * @param $website
 
130
  * @return Varien_Db_Select
131
  */
132
  public function getConditionsSql($rule, $website)
133
  {
134
- $select = $this->_prepareConditionsSql($rule, $website);
135
- $required = $this->_getRequiredValidation();
136
  $aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
137
- $operator = $required ? '=' : '<>';
138
  $conditions = array();
139
 
140
  foreach ($this->getConditions() as $condition) {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
41
  public function loadValueOptions()
42
  {
43
  $this->setValueOption(array());
44
+
45
  return $this;
46
  }
47
 
54
  {
55
  $this->setOperatorOption(array(
56
  '==' => Mage::helper('rule')->__('for'),
57
+ // '>' => Mage::helper('rule')->__('for greater than'),
58
+ // '>=' => Mage::helper('rule')->__('for or greater than')
59
  ));
60
+
61
  return $this;
62
  }
63
 
80
  {
81
  return $this->getTypeElementHtml()
82
  . Mage::helper('bronto_reminder')->__('Wishlist is not empty and abandoned for %s day(s) and %s of these conditions match:',
83
+ // $this->getOperatorElementHtml(),
84
  $this->getValueElementHtml(),
85
  $this->getAggregatorElement()->getHtml())
86
  . $this->getRemoveLinkHtml();
91
  *
92
  * @param $rule
93
  * @param $website
94
+ *
95
  * @return Varien_Db_Select
96
  */
97
  protected function _prepareConditionsSql($rule, $website)
103
  // Convert to minutes
104
  $conditionValue *= 1440;
105
 
106
+ $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
107
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
108
 
109
  $select = $this->getResource()->createSelect();
129
  *
130
  * @param $rule
131
  * @param $website
132
+ *
133
  * @return Varien_Db_Select
134
  */
135
  public function getConditionsSql($rule, $website)
136
  {
137
+ $select = $this->_prepareConditionsSql($rule, $website);
138
+ $required = $this->_getRequiredValidation();
139
  $aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
140
+ $operator = $required ? '=' : '<>';
141
  $conditions = array();
142
 
143
  foreach ($this->getConditions() as $condition) {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Attributes.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Attributes extends Mage_CatalogRule_Model_Rule_Condition_Product
9
  {
@@ -16,16 +15,18 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Attributes extends Mage_Cata
16
 
17
  /**
18
  * Customize default operator input by type mapper for some types
 
19
  * @return array
20
  */
21
  public function getDefaultOperatorInputByType()
22
  {
23
  if (null === $this->_defaultOperatorInputByType) {
24
  parent::getDefaultOperatorInputByType();
25
- $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
26
- $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
27
  $this->_defaultOperatorInputByType['category'] = array('{}', '!{}');
28
  }
 
29
  return $this->_defaultOperatorInputByType;
30
  }
31
 
@@ -116,21 +117,22 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Attributes extends Mage_Cata
116
  * Apply product attribute subfilter to parent/base condition query
117
  *
118
  * @param string $fieldName base query field name
119
- * @param bool $requireValid strict validation flag
120
- * @param $website
 
121
  * @return string
122
  */
123
  public function getSubfilterSql($fieldName, $requireValid, $website)
124
  {
125
  $attribute = $this->getAttributeObject();
126
- $table = $attribute->getBackendTable();
127
 
128
  $resource = $this->getResource();
129
- $select = $resource->createSelect();
130
  $select->from(array('main' => $table), array('entity_id'));
131
 
132
  if ($attribute->getAttributeCode() == 'category_ids') {
133
- $condition = $resource->createConditionSql(
134
  'cat.category_id', $this->getOperator(), explode(',', $this->getValue())
135
  );
136
  $categorySelect = $resource->createSelect();
@@ -154,6 +156,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Attributes extends Mage_Cata
154
  }
155
  $select->where($condition);
156
  $inOperator = ($requireValid ? 'IN' : 'NOT IN');
 
157
  return sprintf("%s %s (%s)", $fieldName, $inOperator, $select);
158
  }
159
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Attributes extends Mage_CatalogRule_Model_Rule_Condition_Product
8
  {
15
 
16
  /**
17
  * Customize default operator input by type mapper for some types
18
+ *
19
  * @return array
20
  */
21
  public function getDefaultOperatorInputByType()
22
  {
23
  if (null === $this->_defaultOperatorInputByType) {
24
  parent::getDefaultOperatorInputByType();
25
+ $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
26
+ $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
27
  $this->_defaultOperatorInputByType['category'] = array('{}', '!{}');
28
  }
29
+
30
  return $this->_defaultOperatorInputByType;
31
  }
32
 
117
  * Apply product attribute subfilter to parent/base condition query
118
  *
119
  * @param string $fieldName base query field name
120
+ * @param bool $requireValid strict validation flag
121
+ * @param $website
122
+ *
123
  * @return string
124
  */
125
  public function getSubfilterSql($fieldName, $requireValid, $website)
126
  {
127
  $attribute = $this->getAttributeObject();
128
+ $table = $attribute->getBackendTable();
129
 
130
  $resource = $this->getResource();
131
+ $select = $resource->createSelect();
132
  $select->from(array('main' => $table), array('entity_id'));
133
 
134
  if ($attribute->getAttributeCode() == 'category_ids') {
135
+ $condition = $resource->createConditionSql(
136
  'cat.category_id', $this->getOperator(), explode(',', $this->getValue())
137
  );
138
  $categorySelect = $resource->createSelect();
156
  }
157
  $select->where($condition);
158
  $inOperator = ($requireValid ? 'IN' : 'NOT IN');
159
+
160
  return sprintf("%s %s (%s)", $fieldName, $inOperator, $select);
161
  }
162
  }
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Combine.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Combine extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Combine extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Quantity.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Quantity extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -27,7 +26,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Quantity extends Bronto_Remi
27
  public function getNewChildSelectOptions()
28
  {
29
  return array('value' => $this->getType(),
30
- 'label' => Mage::helper('bronto_reminder')->__('Number of Items'));
31
  }
32
 
33
  /**
@@ -46,16 +45,17 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Quantity extends Bronto_Remi
46
  /**
47
  * Get SQL select
48
  *
49
- * @param $rule
50
  * @param int | Zend_Db_Expr $website
 
51
  * @return Varien_Db_Select
52
  */
53
  public function getConditionsSql($rule, $website)
54
  {
55
- $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
56
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
57
- $operator = $this->getResource()->getSqlOperator($this->getOperator());
58
- $result = "IF (COUNT(*) {$operator} {$this->getValue()}, 1, 0)";
59
 
60
  $select = $this->getResource()->createSelect();
61
  $select->from(array('item' => $wishlistItemTable), array(new Zend_Db_Expr($result)));
@@ -68,6 +68,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Quantity extends Bronto_Remi
68
 
69
  $this->_limitByStoreWebsite($select, $website, 'item.store_id');
70
  $select->where($this->_createCustomerFilter('list.customer_id'));
 
71
  return $select;
72
  }
73
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Quantity extends Bronto_Reminder_Model_Condition_Abstract
8
  {
26
  public function getNewChildSelectOptions()
27
  {
28
  return array('value' => $this->getType(),
29
+ 'label' => Mage::helper('bronto_reminder')->__('Number of Items'));
30
  }
31
 
32
  /**
45
  /**
46
  * Get SQL select
47
  *
48
+ * @param $rule
49
  * @param int | Zend_Db_Expr $website
50
+ *
51
  * @return Varien_Db_Select
52
  */
53
  public function getConditionsSql($rule, $website)
54
  {
55
+ $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
56
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
57
+ $operator = $this->getResource()->getSqlOperator($this->getOperator());
58
+ $result = "IF (COUNT(*) {$operator} {$this->getValue()}, 1, 0)";
59
 
60
  $select = $this->getResource()->createSelect();
61
  $select->from(array('item' => $wishlistItemTable), array(new Zend_Db_Expr($result)));
68
 
69
  $this->_limitByStoreWebsite($select, $website, 'item.store_id');
70
  $select->where($this->_createCustomerFilter('list.customer_id'));
71
+
72
  return $select;
73
  }
74
  }
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Sharing.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Sharing extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -22,7 +21,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Sharing extends Bronto_Remin
22
  public function getNewChildSelectOptions()
23
  {
24
  return array('value' => $this->getType(),
25
- 'label' => Mage::helper('bronto_reminder')->__('Sharing'));
26
  }
27
 
28
  /**
@@ -59,14 +58,16 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Sharing extends Bronto_Remin
59
  '1' => Mage::helper('bronto_reminder')->__('is'),
60
  '0' => Mage::helper('bronto_reminder')->__('is not'),
61
  ));
 
62
  return $this;
63
  }
64
 
65
  /**
66
  * Get SQL select
67
  *
68
- * @param $rule
69
  * @param int | Zend_Db_Expr $website
 
70
  * @return Varien_Db_Select
71
  */
72
  public function getConditionsSql($rule, $website)
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Sharing extends Bronto_Reminder_Model_Condition_Abstract
8
  {
21
  public function getNewChildSelectOptions()
22
  {
23
  return array('value' => $this->getType(),
24
+ 'label' => Mage::helper('bronto_reminder')->__('Sharing'));
25
  }
26
 
27
  /**
58
  '1' => Mage::helper('bronto_reminder')->__('is'),
59
  '0' => Mage::helper('bronto_reminder')->__('is not'),
60
  ));
61
+
62
  return $this;
63
  }
64
 
65
  /**
66
  * Get SQL select
67
  *
68
+ * @param $rule
69
  * @param int | Zend_Db_Expr $website
70
+ *
71
  * @return Varien_Db_Select
72
  */
73
  public function getConditionsSql($rule, $website)
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Storeview.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Storeview extends Bronto_Reminder_Model_Condition_Abstract
9
  {
@@ -22,7 +21,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Storeview extends Bronto_Rem
22
  public function getNewChildSelectOptions()
23
  {
24
  return array('value' => $this->getType(),
25
- 'label' => Mage::helper('bronto_reminder')->__('Store View'));
26
  }
27
 
28
  /**
@@ -46,6 +45,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Storeview extends Bronto_Rem
46
  public function loadValueOptions()
47
  {
48
  $this->setValueOption(Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm());
 
49
  return $this;
50
  }
51
 
@@ -81,21 +81,23 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Storeview extends Bronto_Rem
81
  '==' => Mage::helper('rule')->__('from'),
82
  '!=' => Mage::helper('rule')->__('not from')
83
  ));
 
84
  return $this;
85
  }
86
 
87
  /**
88
  * Get SQL select
89
  *
90
- * @param $rule
91
  * @param int | Zend_Db_Expr $website
 
92
  * @return Varien_Db_Select
93
  */
94
  public function getConditionsSql($rule, $website)
95
  {
96
- $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
97
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
98
- $operator = $this->getResource()->getSqlOperator($this->getOperator());
99
 
100
  $select = $this->getResource()->createSelect();
101
  $select->from(array('item' => $wishlistItemTable), array(new Zend_Db_Expr(1)));
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Storeview extends Bronto_Reminder_Model_Condition_Abstract
8
  {
21
  public function getNewChildSelectOptions()
22
  {
23
  return array('value' => $this->getType(),
24
+ 'label' => Mage::helper('bronto_reminder')->__('Store View'));
25
  }
26
 
27
  /**
45
  public function loadValueOptions()
46
  {
47
  $this->setValueOption(Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm());
48
+
49
  return $this;
50
  }
51
 
81
  '==' => Mage::helper('rule')->__('from'),
82
  '!=' => Mage::helper('rule')->__('not from')
83
  ));
84
+
85
  return $this;
86
  }
87
 
88
  /**
89
  * Get SQL select
90
  *
91
+ * @param $rule
92
  * @param int | Zend_Db_Expr $website
93
+ *
94
  * @return Varien_Db_Select
95
  */
96
  public function getConditionsSql($rule, $website)
97
  {
98
+ $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
99
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
100
+ $operator = $this->getResource()->getSqlOperator($this->getOperator());
101
 
102
  $select = $this->getResource()->createSelect();
103
  $select->from(array('item' => $wishlistItemTable), array(new Zend_Db_Expr(1)));
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Subcombine.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Subcombine extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Subcombine extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist/Subselection.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Subselection extends Bronto_Reminder_Model_Condition_Combine_Abstract
9
  {
@@ -45,6 +44,7 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Subselection extends Bronto_
45
  '==' => Mage::helper('bronto_reminder')->__('found'),
46
  '!=' => Mage::helper('bronto_reminder')->__('not found')
47
  ));
 
48
  return $this;
49
  }
50
 
@@ -65,13 +65,14 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist_Subselection extends Bronto_
65
  /**
66
  * Build query for matching wishlist items
67
  *
68
- * @param $rule
69
  * @param int | Zend_Db_Expr $website
 
70
  * @return Varien_Db_Select
71
  */
72
  protected function _prepareConditionsSql($rule, $website)
73
  {
74
- $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
75
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
76
 
77
  $select = $this->getResource()->createSelect();
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_Rule_Condition_Wishlist_Subselection extends Bronto_Reminder_Model_Condition_Combine_Abstract
8
  {
44
  '==' => Mage::helper('bronto_reminder')->__('found'),
45
  '!=' => Mage::helper('bronto_reminder')->__('not found')
46
  ));
47
+
48
  return $this;
49
  }
50
 
65
  /**
66
  * Build query for matching wishlist items
67
  *
68
+ * @param $rule
69
  * @param int | Zend_Db_Expr $website
70
+ *
71
  * @return Varien_Db_Select
72
  */
73
  protected function _prepareConditionsSql($rule, $website)
74
  {
75
+ $wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
76
  $wishlistItemTable = $this->getResource()->getTable('wishlist/item');
77
 
78
  $select = $this->getResource()->createSelect();
app/code/community/Bronto/Reminder/Model/System/Config/Backend/Allowsend.php CHANGED
@@ -2,8 +2,7 @@
2
 
3
  /**
4
  * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.4.12
7
  */
8
  class Bronto_Reminder_Model_System_Config_Backend_Allowsend extends Mage_Core_Model_Config_Data
9
  {
2
 
3
  /**
4
  * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_System_Config_Backend_Allowsend extends Mage_Core_Model_Config_Data
8
  {
app/code/community/Bronto/Reminder/Model/System/Config/Backend/Cron.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
9
  {
@@ -16,4 +15,20 @@ class Bronto_Reminder_Model_System_Config_Backend_Cron extends Bronto_Common_Mod
16
  * @var string
17
  */
18
  protected $_cron_model_path = 'crontab/jobs/bronto_reminder_send_notification/run/model';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
8
  {
15
  * @var string
16
  */
17
  protected $_cron_model_path = 'crontab/jobs/bronto_reminder_send_notification/run/model';
18
+
19
+ /**
20
+ * @return string
21
+ */
22
+ public function getCronStringPath()
23
+ {
24
+ return Mage::helper('bronto_reminder')->getCronStringPath();
25
+ }
26
+
27
+ /**
28
+ * @return string
29
+ */
30
+ public function getCronModelPath()
31
+ {
32
+ return Mage::helper('bronto_reminder')->getCronModelPath();
33
+ }
34
  }
app/code/community/Bronto/Reminder/controllers/Adminhtml/DeliveryController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reminder_Adminhtml_DeliveryController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ protected function _initAction()
10
+ {
11
+ $this->_title($this->__('Bronto Deliveries'))->_title($this->__('Logs'));
12
+ $this->loadLayout()
13
+ ->_setActiveMenu('adminhtml_delivery_index')
14
+ ->_addBreadcrumb(
15
+ Mage::helper('bronto_reminder')->__('Bronto Delivery Log'),
16
+ Mage::helper('bronto_reminder')->__('Bronto Delivery Log')
17
+ );
18
+
19
+ return $this;
20
+ }
21
+
22
+ public function indexAction()
23
+ {
24
+ $this->_initAction()->renderLayout();
25
+ }
26
+
27
+ /**
28
+ * Deletes all log history
29
+ */
30
+ public function clearAction()
31
+ {
32
+ /* @var $collection Bronto_Reminder_Model_Mysql4_Delivery_Collection */
33
+ $collection = Mage::getModel('bronto_reminder/delivery')->getCollection();
34
+ $collection->delete();
35
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bronto_reminder')->__('All log entries have been deleted'));
36
+ $this->_redirect('*/*/index');
37
+ }
38
+ }
app/code/community/Bronto/Reminder/controllers/Adminhtml/RemindersController.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Controller_Action
9
  {
@@ -20,6 +19,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
20
  Mage::helper('bronto_reminder')->__('Reminder Rules'),
21
  Mage::helper('bronto_reminder')->__('Reminder Rules')
22
  );
 
23
  return $this;
24
  }
25
 
@@ -33,7 +33,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
33
  protected function _initRule($requestParam = 'id')
34
  {
35
  $ruleId = $this->getRequest()->getParam($requestParam, 0);
36
- $rule = Mage::getModel('bronto_reminder/rule');
37
  if ($ruleId) {
38
  $rule->load($ruleId);
39
  if (!$rule->getId()) {
@@ -41,6 +41,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
41
  }
42
  }
43
  Mage::register('current_reminder_rule', $rule);
 
44
  return $rule;
45
  }
46
 
@@ -73,6 +74,8 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
73
 
74
  /**
75
  * Edit reminder rule
 
 
76
  */
77
  public function editAction()
78
  {
@@ -83,6 +86,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
83
  $model = $this->_initRule();
84
  } catch (Mage_Core_Exception $e) {
85
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
 
86
  return $this->_redirect('*/*/');
87
  }
88
 
@@ -118,6 +122,8 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
118
  ->_addContent($block)
119
  ->_addLeft($this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tabs'))
120
  ->renderLayout();
 
 
121
  }
122
 
123
  /**
@@ -127,9 +133,9 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
127
  */
128
  public function newConditionHtmlAction()
129
  {
130
- $id = $this->getRequest()->getParam('id');
131
  $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
132
- $type = $typeArr[0];
133
 
134
  $model = Mage::getModel($type)
135
  ->setId($id)
@@ -153,6 +159,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
153
  * Massages the POST data for Rule submission
154
  *
155
  * @param array $data
 
156
  * @return array
157
  */
158
  protected function _prepareRuleFormData($data)
@@ -188,7 +195,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
188
  }
189
 
190
  if (isset($json['message'])) {
191
- $json['error'] = true;
192
  $json['message'] = Mage::getBlockSingleton('core/messages')
193
  ->addError($json['message'])
194
  ->getGroupedHtml();
@@ -200,9 +207,9 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
200
  }
201
 
202
  /**
203
- * Save reminder rule
204
  *
205
- * @return void
206
  */
207
  public function saveAction()
208
  {
@@ -222,7 +229,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
222
  return $this->_redirect(
223
  '*/*/edit',
224
  array(
225
- 'id' => $model->getId(),
226
  '_current' => true,
227
  )
228
  );
@@ -231,6 +238,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
231
  } catch (Mage_Core_Exception $e) {
232
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
233
  Mage::getSingleton('adminhtml/session')->setPageData($data);
 
234
  return $this->_redirect('*/*/edit', array('id' => $model->getId()));
235
  } catch (Exception $e) {
236
  Mage::getSingleton('adminhtml/session')->addError($this->__('Failed to save reminder rule.'));
@@ -238,6 +246,8 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
238
  }
239
  }
240
  $this->_redirect('*/*/');
 
 
241
  }
242
 
243
  /**
@@ -254,6 +264,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
254
  } catch (Mage_Core_Exception $e) {
255
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
256
  $this->_redirect('*/*/edit', array('id' => $model->getId()));
 
257
  return;
258
  } catch (Exception $e) {
259
  Mage::getSingleton('adminhtml/session')->addError($this->__('Failed to delete reminder rule.'));
@@ -271,12 +282,12 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
271
  {
272
  try {
273
  Mage::helper('bronto_reminder')->writeDebug("Admin pressed 'Run Now'...");
274
- $model = $this->_initRule();
275
  $result = $model->sendReminderEmails();
276
  if ($result) {
277
- $total = $result['total'];
278
  $success = $result['success'];
279
- $error = $result['error'];
280
  Mage::getSingleton('adminhtml/session')->addSuccess(sprintf("Processed %d Reminders (%d Error / %d Success)", $total, $error, $success));
281
  } else {
282
  Mage::getSingleton('adminhtml/session')->addError('Reminder rule sending failed.');
@@ -371,6 +382,7 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
371
  $array[$dateField] = $filterInternal->filter($array[$dateField]);
372
  }
373
  }
 
374
  return $array;
375
  }
376
 
@@ -388,8 +400,11 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
388
  * bar / <default title>
389
  *
390
  * @see self::_renderTitles()
391
- * @param string|false|-1|null $text
392
- * @return Mage_Core_Controller_Varien_Action
 
 
 
393
  */
394
  protected function _title($text = null, $resetIfExists = true)
395
  {
@@ -408,12 +423,13 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
408
  } elseif (empty($this->_titles) || $resetIfExists) {
409
  if (false === $text) {
410
  $this->_removeDefaultTitle = false;
411
- $this->_titles = array();
412
  } elseif (null === $text) {
413
  $this->_removeDefaultTitle = true;
414
- $this->_titles = array();
415
  }
416
  }
 
417
  return $this;
418
  }
419
 
@@ -433,28 +449,34 @@ class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Contr
433
  * Will forward to deniedAction(), if not allowed.
434
  *
435
  * @param string $section
 
436
  * @return bool
437
  */
438
  protected function _isSectionAllowed($section)
439
  {
440
  try {
441
- $session = Mage::getSingleton('admin/session');
442
  $resourceLookup = "admin/system/config/{$section}";
443
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
444
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
445
  if (!$session->isAllowed($resourceId)) {
446
  throw new Exception('');
447
  }
 
448
  return true;
449
  }
450
  } catch (Zend_Acl_Exception $e) {
451
  $this->norouteAction();
452
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
453
  return false;
454
  } catch (Exception $e) {
455
  $this->deniedAction();
456
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 
457
  return false;
458
  }
 
 
459
  }
460
  }
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_Adminhtml_RemindersController extends Mage_Adminhtml_Controller_Action
8
  {
19
  Mage::helper('bronto_reminder')->__('Reminder Rules'),
20
  Mage::helper('bronto_reminder')->__('Reminder Rules')
21
  );
22
+
23
  return $this;
24
  }
25
 
33
  protected function _initRule($requestParam = 'id')
34
  {
35
  $ruleId = $this->getRequest()->getParam($requestParam, 0);
36
+ $rule = Mage::getModel('bronto_reminder/rule');
37
  if ($ruleId) {
38
  $rule->load($ruleId);
39
  if (!$rule->getId()) {
41
  }
42
  }
43
  Mage::register('current_reminder_rule', $rule);
44
+
45
  return $rule;
46
  }
47
 
74
 
75
  /**
76
  * Edit reminder rule
77
+ *
78
+ * @return $this|Mage_Core_Controller_Varien_Action
79
  */
80
  public function editAction()
81
  {
86
  $model = $this->_initRule();
87
  } catch (Mage_Core_Exception $e) {
88
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
89
+
90
  return $this->_redirect('*/*/');
91
  }
92
 
122
  ->_addContent($block)
123
  ->_addLeft($this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tabs'))
124
  ->renderLayout();
125
+
126
+ return $this;
127
  }
128
 
129
  /**
133
  */
134
  public function newConditionHtmlAction()
135
  {
136
+ $id = $this->getRequest()->getParam('id');
137
  $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
138
+ $type = $typeArr[0];
139
 
140
  $model = Mage::getModel($type)
141
  ->setId($id)
159
  * Massages the POST data for Rule submission
160
  *
161
  * @param array $data
162
+ *
163
  * @return array
164
  */
165
  protected function _prepareRuleFormData($data)
195
  }
196
 
197
  if (isset($json['message'])) {
198
+ $json['error'] = true;
199
  $json['message'] = Mage::getBlockSingleton('core/messages')
200
  ->addError($json['message'])
201
  ->getGroupedHtml();
207
  }
208
 
209
  /**
210
+ * Save Reminder Rule
211
  *
212
+ * @return $this|Mage_Core_Controller_Varien_Action
213
  */
214
  public function saveAction()
215
  {
229
  return $this->_redirect(
230
  '*/*/edit',
231
  array(
232
+ 'id' => $model->getId(),
233
  '_current' => true,
234
  )
235
  );
238
  } catch (Mage_Core_Exception $e) {
239
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
240
  Mage::getSingleton('adminhtml/session')->setPageData($data);
241
+
242
  return $this->_redirect('*/*/edit', array('id' => $model->getId()));
243
  } catch (Exception $e) {
244
  Mage::getSingleton('adminhtml/session')->addError($this->__('Failed to save reminder rule.'));
246
  }
247
  }
248
  $this->_redirect('*/*/');
249
+
250
+ return $this;
251
  }
252
 
253
  /**
264
  } catch (Mage_Core_Exception $e) {
265
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
266
  $this->_redirect('*/*/edit', array('id' => $model->getId()));
267
+
268
  return;
269
  } catch (Exception $e) {
270
  Mage::getSingleton('adminhtml/session')->addError($this->__('Failed to delete reminder rule.'));
282
  {
283
  try {
284
  Mage::helper('bronto_reminder')->writeDebug("Admin pressed 'Run Now'...");
285
+ $model = $this->_initRule();
286
  $result = $model->sendReminderEmails();
287
  if ($result) {
288
+ $total = $result['total'];
289
  $success = $result['success'];
290
+ $error = $result['error'];
291
  Mage::getSingleton('adminhtml/session')->addSuccess(sprintf("Processed %d Reminders (%d Error / %d Success)", $total, $error, $success));
292
  } else {
293
  Mage::getSingleton('adminhtml/session')->addError('Reminder rule sending failed.');
382
  $array[$dateField] = $filterInternal->filter($array[$dateField]);
383
  }
384
  }
385
+
386
  return $array;
387
  }
388
 
400
  * bar / <default title>
401
  *
402
  * @see self::_renderTitles()
403
+ *
404
+ * @param null $text
405
+ * @param bool $resetIfExists
406
+ *
407
+ * @return $this|Mage_Core_Controller_Varien_Action
408
  */
409
  protected function _title($text = null, $resetIfExists = true)
410
  {
423
  } elseif (empty($this->_titles) || $resetIfExists) {
424
  if (false === $text) {
425
  $this->_removeDefaultTitle = false;
426
+ $this->_titles = array();
427
  } elseif (null === $text) {
428
  $this->_removeDefaultTitle = true;
429
+ $this->_titles = array();
430
  }
431
  }
432
+
433
  return $this;
434
  }
435
 
449
  * Will forward to deniedAction(), if not allowed.
450
  *
451
  * @param string $section
452
+ *
453
  * @return bool
454
  */
455
  protected function _isSectionAllowed($section)
456
  {
457
  try {
458
+ $session = Mage::getSingleton('admin/session');
459
  $resourceLookup = "admin/system/config/{$section}";
460
  if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
461
  $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
462
  if (!$session->isAllowed($resourceId)) {
463
  throw new Exception('');
464
  }
465
+
466
  return true;
467
  }
468
  } catch (Zend_Acl_Exception $e) {
469
  $this->norouteAction();
470
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
471
+
472
  return false;
473
  } catch (Exception $e) {
474
  $this->deniedAction();
475
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
476
+
477
  return false;
478
  }
479
+
480
+ return false;
481
  }
482
  }
app/code/community/Bronto/Reminder/controllers/LoadController.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
  /**
4
- * @package Bronto\Reminder
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- * @version 1.5.0
7
  */
8
  class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
9
  {
@@ -14,20 +13,18 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
14
  public function indexAction()
15
  {
16
  // Acquire Parameters
17
- $storeCode = $this->getRequest()->getParam('___store', 'default');
18
- $quoteId = $this->getRequest()->getParam('id', false);
19
  $wishlistId = $this->getRequest()->getParam('wishlist_id', false);
20
- $ruleId = $this->getRequest()->getParam('rule_id', 0);
21
- $messageId = $this->getRequest()->getParam('message_id', 0);
22
 
23
  // Load store from store code and get ID
24
- $store = $this->_getStoreByCode($storeCode);
25
- // $store = Mage::getModel('core/store')->load($storeCode);
26
  $storeId = $store->getId();
27
 
28
  // Set Defaults
29
- $quote = false;
30
- $wishlist = false;
31
  $redirectUrl = false;
32
 
33
  // Set Current Store to the acquired store id
@@ -36,7 +33,7 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
36
  // If quote ID is good, send to cart; If wishlist ID is good, send to wishlist
37
  if ($quote = $this->_handleQuote($quoteId, $storeId)) {
38
  $redirectUrl = Mage::app()->getStore()->getUrl('checkout/cart');
39
- } else if ($wishlist = $this->_handleWishlist($wishlistId)) {
40
  $redirectUrl = Mage::app()->getStore()->getUrl('wishlist');
41
  }
42
 
@@ -61,8 +58,8 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
61
  }
62
 
63
  // Check for persistent cookie
64
- $pCookie = Mage::getModel('core/cookie')->get('persistent_shopping_cart', false);
65
- $persist = (int)Mage::getStoreConfig('persistent/options/enabled');
66
  $loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
67
 
68
  // Handle persistent cart issues
@@ -76,7 +73,9 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
76
 
77
  /**
78
  * Use Store Code to pull Store Object
 
79
  * @param string $storeCode
 
80
  * @return boolean
81
  */
82
  protected function _getStoreByCode($storeCode)
@@ -89,13 +88,16 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
89
  return $store;
90
  }
91
  }
 
92
  return false;
93
  }
94
 
95
  /**
96
  * Handle Quote
 
97
  * @param int|string $quoteId
98
  * @param int|string $storeId
 
99
  * @return boolean|Mage_Sales_Model_Quote
100
  */
101
  protected function _handleQuote($quoteId, $storeId)
@@ -122,8 +124,10 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
122
 
123
  /**
124
  * Handle Wishlist
 
125
  * @param int|string $wishlistId
126
  * @param int|string $storeId
 
127
  * @return boolean|Mage_Wishlist_Model_Wishlist
128
  */
129
  protected function _handleWishlist($wishlistId, $storeId)
@@ -140,14 +144,17 @@ class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
140
  if ($wishlist->getId()) {
141
  return $wishlist;
142
  }
 
143
  return false;
144
  }
145
 
146
  /**
147
  * Get Customer ID from Quote/Wishlist
148
- * @param int $ruleId
149
- * @param Mage_Sales_Model_Quote $quote
 
150
  * @param Mage_Wishlist_Model_Wishlist $wishlist
 
151
  * @return int
152
  */
153
  protected function _getCustomerId($ruleId, $quote, $wishlist)
1
  <?php
2
 
3
  /**
4
+ * @package Bronto\Reminder
5
+ * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Reminder_LoadController extends Mage_Core_Controller_Front_Action
8
  {
13
  public function indexAction()
14
  {
15
  // Acquire Parameters
16
+ $storeCode = $this->getRequest()->getParam('___store', 'default');
17
+ $quoteId = $this->getRequest()->getParam('id', false);
18
  $wishlistId = $this->getRequest()->getParam('wishlist_id', false);
19
+ $ruleId = $this->getRequest()->getParam('rule_id', 0);
20
+ $messageId = $this->getRequest()->getParam('message_id', 0);
21
 
22
  // Load store from store code and get ID
23
+ $store = Mage::getModel('core/store')->load($storeCode);
 
24
  $storeId = $store->getId();
25
 
26
  // Set Defaults
27
+ $wishlist = false;
 
28
  $redirectUrl = false;
29
 
30
  // Set Current Store to the acquired store id
33
  // If quote ID is good, send to cart; If wishlist ID is good, send to wishlist
34
  if ($quote = $this->_handleQuote($quoteId, $storeId)) {
35
  $redirectUrl = Mage::app()->getStore()->getUrl('checkout/cart');
36
+ } else if ($wishlist = $this->_handleWishlist($wishlistId, $storeId)) {
37
  $redirectUrl = Mage::app()->getStore()->getUrl('wishlist');
38
  }
39
 
58
  }
59
 
60
  // Check for persistent cookie
61
+ $pCookie = Mage::getModel('core/cookie')->get('persistent_shopping_cart', false);
62
+ $persist = (int)Mage::getStoreConfig('persistent/options/enabled');
63
  $loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
64
 
65
  // Handle persistent cart issues
73
 
74
  /**
75
  * Use Store Code to pull Store Object
76
+ *
77
  * @param string $storeCode
78
+ *
79
  * @return boolean
80
  */
81
  protected function _getStoreByCode($storeCode)
88
  return $store;
89
  }
90
  }
91
+
92
  return false;
93
  }
94
 
95
  /**
96
  * Handle Quote
97
+ *
98
  * @param int|string $quoteId
99
  * @param int|string $storeId
100
+ *
101
  * @return boolean|Mage_Sales_Model_Quote
102
  */
103
  protected function _handleQuote($quoteId, $storeId)
124
 
125
  /**
126
  * Handle Wishlist
127
+ *
128
  * @param int|string $wishlistId
129
  * @param int|string $storeId
130
+ *
131
  * @return boolean|Mage_Wishlist_Model_Wishlist
132
  */
133
  protected function _handleWishlist($wishlistId, $storeId)
144
  if ($wishlist->getId()) {
145
  return $wishlist;
146
  }
147
+
148
  return false;
149
  }
150
 
151
  /**
152
  * Get Customer ID from Quote/Wishlist
153
+ *
154
+ * @param int $ruleId
155
+ * @param Mage_Sales_Model_Quote $quote
156
  * @param Mage_Wishlist_Model_Wishlist $wishlist
157
+ *
158
  * @return int
159
  */
160
  protected function _getCustomerId($ruleId, $quote, $wishlist)
app/code/community/Bronto/Reminder/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Bronto_Reminder>
5
- <version>1.4.12</version>
6
  </Bronto_Reminder>
7
  </modules>
8
  <global>
@@ -39,6 +39,9 @@
39
  <log>
40
  <table>bronto_reminder_rule_log</table>
41
  </log>
 
 
 
42
  <guest>
43
  <table>bronto_guest_emails</table>
44
  </guest>
@@ -75,6 +78,9 @@
75
  <bronto_reminder>
76
  <settings>
77
  <enabled>0</enabled>
 
 
 
78
  <frequency>I</frequency>
79
  <interval>15</interval>
80
  <minutes>0</minutes>
2
  <config>
3
  <modules>
4
  <Bronto_Reminder>
5
+ <version>1.4.16</version>
6
  </Bronto_Reminder>
7
  </modules>
8
  <global>
39
  <log>
40
  <table>bronto_reminder_rule_log</table>
41
  </log>
42
+ <delivery>
43
+ <table>bronto_reminder_delivery_log</table>
44
+ </delivery>
45
  <guest>
46
  <table>bronto_guest_emails</table>
47
  </guest>
78
  <bronto_reminder>
79
  <settings>
80
  <enabled>0</enabled>
81
+ <log_enabled>1</log_enabled>
82
+ <log_fields_enabled>1</log_fields_enabled>
83
+ <mage_cron>1</mage_cron>
84
  <frequency>I</frequency>
85
  <interval>15</interval>
86
  <minutes>0</minutes>
app/code/community/Bronto/Reminder/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <sections>
4
  <bronto_reminder translate="label" module="bronto_reminder">
5
- <label>Reminder Emails</label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>500</sort_order>
@@ -22,7 +22,7 @@
22
  <label>Settings</label>
23
  <frontend_type>text</frontend_type>
24
  <frontend_model>bronto_reminder/adminhtml_system_config_settings</frontend_model>
25
- <sort_order>1</sort_order>
26
  <show_in_default>1</show_in_default>
27
  <show_in_website>1</show_in_website>
28
  <show_in_store>1</show_in_store>
@@ -34,7 +34,7 @@
34
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
35
  <backend_model>bronto_common/system_config_backend_enable</backend_model>
36
  <source_model>adminhtml/system_config_source_yesno</source_model>
37
- <sort_order>1</sort_order>
38
  <show_in_default>1</show_in_default>
39
  <show_in_website>1</show_in_website>
40
  <show_in_store>1</show_in_store>
@@ -44,23 +44,63 @@
44
  <frontend_type>select</frontend_type>
45
  <backend_model>bronto_reminder/system_config_backend_allowsend</backend_model>
46
  <source_model>adminhtml/system_config_source_yesno</source_model>
47
- <sort_order>2</sort_order>
48
  <show_in_default>1</show_in_default>
49
  <show_in_website>1</show_in_website>
50
  <show_in_store>1</show_in_store>
51
- <comment>Selecting 'Yes' will allow emails to being sending. 'No' will allow matching
52
- customers but will not send emails
53
  </comment>
54
  </allow_send>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  <frequency translate="label">
56
  <label>Frequency</label>
57
  <depends>
58
  <enabled>1</enabled>
 
59
  </depends>
60
  <frontend_type>select</frontend_type>
61
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
62
  <backend_model>bronto_reminder/system_config_backend_cron</backend_model>
63
- <sort_order>3</sort_order>
64
  <show_in_default>1</show_in_default>
65
  <show_in_website>0</show_in_website>
66
  <show_in_store>0</show_in_store>
@@ -69,13 +109,12 @@
69
  <label>Interval</label>
70
  <depends>
71
  <enabled>1</enabled>
72
- </depends>
73
- <depends>
74
  <frequency>I</frequency>
75
  </depends>
76
  <frontend_type>select</frontend_type>
77
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
78
- <sort_order>4</sort_order>
79
  <show_in_default>1</show_in_default>
80
  <show_in_website>0</show_in_website>
81
  <show_in_store>0</show_in_store>
@@ -85,12 +124,10 @@
85
  <label>Minute of the Hour</label>
86
  <depends>
87
  <enabled>1</enabled>
88
- </depends>
89
- <depends>
90
  <frequency>H</frequency>
91
  </depends>
92
  <frontend_type>text</frontend_type>
93
- <sort_order>5</sort_order>
94
  <show_in_default>1</show_in_default>
95
  <show_in_website>0</show_in_website>
96
  <show_in_store>0</show_in_store>
@@ -100,9 +137,10 @@
100
  <label>Start Time</label>
101
  <depends>
102
  <enabled>1</enabled>
 
103
  </depends>
104
  <frontend_type>time</frontend_type>
105
- <sort_order>6</sort_order>
106
  <show_in_default>1</show_in_default>
107
  <show_in_website>0</show_in_website>
108
  <show_in_store>0</show_in_store>
@@ -112,8 +150,9 @@
112
  <depends>
113
  <enabled>1</enabled>
114
  </depends>
115
- <frontend_type>text</frontend_type>
116
- <sort_order>7</sort_order>
 
117
  <show_in_default>1</show_in_default>
118
  <show_in_website>1</show_in_website>
119
  <show_in_store>1</show_in_store>
@@ -124,7 +163,7 @@
124
  <enabled>1</enabled>
125
  </depends>
126
  <frontend_type>text</frontend_type>
127
- <sort_order>8</sort_order>
128
  <show_in_default>1</show_in_default>
129
  <show_in_website>1</show_in_website>
130
  <show_in_store>1</show_in_store>
@@ -139,7 +178,7 @@
139
  </depends>
140
  <frontend_type>select</frontend_type>
141
  <source_model>adminhtml/system_config_source_email_identity</source_model>
142
- <sort_order>10</sort_order>
143
  <show_in_default>1</show_in_default>
144
  <show_in_website>1</show_in_website>
145
  <show_in_store>1</show_in_store>
@@ -149,7 +188,7 @@
149
  <cron_list>
150
  <frontend_type>text</frontend_type>
151
  <frontend_model>bronto_reminder/adminhtml_system_config_cron</frontend_model>
152
- <sort_order>3</sort_order>
153
  <show_in_default>1</show_in_default>
154
  <show_in_website>1</show_in_website>
155
  <show_in_store>1</show_in_store>
2
  <config>
3
  <sections>
4
  <bronto_reminder translate="label" module="bronto_reminder">
5
+ <label><![CDATA[<div id="bronto_reminder_icon_block">Reminder Emails</div>]]></label>
6
  <tab>bronto</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>500</sort_order>
22
  <label>Settings</label>
23
  <frontend_type>text</frontend_type>
24
  <frontend_model>bronto_reminder/adminhtml_system_config_settings</frontend_model>
25
+ <sort_order>20</sort_order>
26
  <show_in_default>1</show_in_default>
27
  <show_in_website>1</show_in_website>
28
  <show_in_store>1</show_in_store>
34
  <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
35
  <backend_model>bronto_common/system_config_backend_enable</backend_model>
36
  <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <sort_order>10</sort_order>
38
  <show_in_default>1</show_in_default>
39
  <show_in_website>1</show_in_website>
40
  <show_in_store>1</show_in_store>
44
  <frontend_type>select</frontend_type>
45
  <backend_model>bronto_reminder/system_config_backend_allowsend</backend_model>
46
  <source_model>adminhtml/system_config_source_yesno</source_model>
47
+ <sort_order>20</sort_order>
48
  <show_in_default>1</show_in_default>
49
  <show_in_website>1</show_in_website>
50
  <show_in_store>1</show_in_store>
51
+ <comment><![CDATA[Selecting <em>Yes</em> will allow emails to begin sending. <em>No</em> will allow matching
52
+ customers, but will not send emails.]]>
53
  </comment>
54
  </allow_send>
55
+ <log_enabled translate="label">
56
+ <label>Log Deliveries</label>
57
+ <depends>
58
+ <enabled>1</enabled>
59
+ </depends>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>21</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </log_enabled>
67
+ <log_fields_enabled translate="label">
68
+ <label>Log Delivery Fields</label>
69
+ <depends>
70
+ <enabled>1</enabled>
71
+ </depends>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>adminhtml/system_config_source_yesno</source_model>
74
+ <sort_order>22</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
+ </log_fields_enabled>
79
+ <mage_cron>
80
+ <label>Use Magento Cron</label>
81
+ <depends>
82
+ <enabled>1</enabled>
83
+ </depends>
84
+ <frontend_type>select</frontend_type>
85
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
86
+ <source_model>adminhtml/system_config_source_yesno</source_model>
87
+ <sort_order>30</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>0</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ <comment>
92
+ <![CDATA[Setting to <em>No</em> will prevent the Magento Cron from triggering the import process for this module.<br />For more details, check the <em>Cron Settings</em> section in the <strong>Bronto &raquo; Advanced</strong> tab.]]></comment>
93
+ </mage_cron>
94
  <frequency translate="label">
95
  <label>Frequency</label>
96
  <depends>
97
  <enabled>1</enabled>
98
+ <mage_cron>1</mage_cron>
99
  </depends>
100
  <frontend_type>select</frontend_type>
101
  <source_model>bronto_common/system_config_source_cron_frequency</source_model>
102
  <backend_model>bronto_reminder/system_config_backend_cron</backend_model>
103
+ <sort_order>40</sort_order>
104
  <show_in_default>1</show_in_default>
105
  <show_in_website>0</show_in_website>
106
  <show_in_store>0</show_in_store>
109
  <label>Interval</label>
110
  <depends>
111
  <enabled>1</enabled>
112
+ <mage_cron>1</mage_cron>
 
113
  <frequency>I</frequency>
114
  </depends>
115
  <frontend_type>select</frontend_type>
116
  <source_model>bronto_common/system_config_source_cron_minutes</source_model>
117
+ <sort_order>50</sort_order>
118
  <show_in_default>1</show_in_default>
119
  <show_in_website>0</show_in_website>
120
  <show_in_store>0</show_in_store>
124
  <label>Minute of the Hour</label>
125
  <depends>
126
  <enabled>1</enabled>
 
 
127
  <frequency>H</frequency>
128
  </depends>
129
  <frontend_type>text</frontend_type>
130
+ <sort_order>60</sort_order>
131
  <show_in_default>1</show_in_default>
132
  <show_in_website>0</show_in_website>
133
  <show_in_store>0</show_in_store>
137
  <label>Start Time</label>
138
  <depends>
139
  <enabled>1</enabled>
140
+ <mage_cron>1</mage_cron>
141
  </depends>
142
  <frontend_type>time</frontend_type>
143
+ <sort_order>70</sort_order>
144
  <show_in_default>1</show_in_default>
145
  <show_in_website>0</show_in_website>
146
  <show_in_store>0</show_in_store>
150
  <depends>
151
  <enabled>1</enabled>
152
  </depends>
153
+ <frontend_type>select</frontend_type>
154
+ <source_model>bronto_common/system_config_source_limit</source_model>
155
+ <sort_order>80</sort_order>
156
  <show_in_default>1</show_in_default>
157
  <show_in_website>1</show_in_website>
158
  <show_in_store>1</show_in_store>
163
  <enabled>1</enabled>
164
  </depends>
165
  <frontend_type>text</frontend_type>
166
+ <sort_order>90</sort_order>
167
  <show_in_default>1</show_in_default>
168
  <show_in_website>1</show_in_website>
169
  <show_in_store>1</show_in_store>
178
  </depends>
179
  <frontend_type>select</frontend_type>
180
  <source_model>adminhtml/system_config_source_email_identity</source_model>
181
+ <sort_order>100</sort_order>
182
  <show_in_default>1</show_in_default>
183
  <show_in_website>1</show_in_website>
184
  <show_in_store>1</show_in_store>
188
  <cron_list>
189
  <frontend_type>text</frontend_type>
190
  <frontend_model>bronto_reminder/adminhtml_system_config_cron</frontend_model>
191
+ <sort_order>30</sort_order>
192
  <show_in_default>1</show_in_default>
193
  <show_in_website>1</show_in_website>
194
  <show_in_store>1</show_in_store>
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.12.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  $installer = $this;
3
- /* @var $installer Mage_Core_Model_Mysql4_Setup */
4
 
5
  $installer->startSetup();
6
 
1
  <?php
2
  $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
 
5
  $installer->startSetup();
6
 
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.13.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ try {
8
+ // Create New Reminder Rule Table
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/rule')}`;
11
+
12
+ CREATE TABLE `{$installer->getTable('bronto_reminder/rule')}` (
13
+ `rule_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
14
+ `name` varchar(255) NOT NULL DEFAULT '',
15
+ `description` text NOT NULL,
16
+ `conditions_serialized` mediumtext NOT NULL,
17
+ `condition_sql` mediumtext,
18
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
19
+ `salesrule_id` int(10) unsigned DEFAULT NULL,
20
+ `schedule` varchar(255) NOT NULL DEFAULT '',
21
+ `default_label` varchar(255) NOT NULL DEFAULT '',
22
+ `default_description` text NOT NULL,
23
+ `active_from` datetime DEFAULT NULL,
24
+ `active_to` datetime DEFAULT NULL,
25
+ `send_to` enum('user', 'guest', 'both') DEFAULT 'both',
26
+ PRIMARY KEY (`rule_id`),
27
+ KEY `IDX_BRONTO_REMINDER_SALESRULE` (`salesrule_id`),
28
+ CONSTRAINT `FK_BRONTO_REMINDER_SALESRULE` FOREIGN KEY (`salesrule_id`)
29
+ REFERENCES `{$this->getTable('salesrule')}` (`rule_id`) ON DELETE SET NULL ON UPDATE CASCADE
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+ ");
32
+ } catch (Exception $e) {
33
+ throw new RuntimeException('Failed Creating Reminder Rule Table: ' . $e->getMessage());
34
+ }
35
+
36
+ try {
37
+ // Create New Reminder Rule Website Table
38
+ $installer->run("
39
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/website')}`;
40
+
41
+ CREATE TABLE `{$installer->getTable('bronto_reminder/website')}` (
42
+ `rule_id` int(10) unsigned NOT NULL,
43
+ `website_id` smallint(5) unsigned NOT NULL,
44
+ PRIMARY KEY (`rule_id`,`website_id`),
45
+ KEY `IDX_BRONTO_REMINDER_WEBSITE` (`website_id`),
46
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE` FOREIGN KEY (`rule_id`)
47
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
48
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
49
+ ");
50
+ } catch (Exception $e) {
51
+ throw new RuntimeException('Failed Creating Reminder Rule Website Table: ' . $e->getMessage());
52
+ }
53
+
54
+ try {
55
+ // Create New Reminder Message Table
56
+ $installer->run("
57
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/message')}`;
58
+
59
+ CREATE TABLE `{$installer->getTable('bronto_reminder/message')}` (
60
+ `rule_id` int(10) unsigned NOT NULL,
61
+ `store_id` smallint(5) NOT NULL,
62
+ `message_id` varchar(255) NOT NULL DEFAULT '',
63
+ `label` varchar(255) DEFAULT NULL,
64
+ `description` text,
65
+ PRIMARY KEY (`rule_id`,`store_id`),
66
+ KEY `IDX_BRONTO_REMINDER_MESSAGE_RULE` (`rule_id`),
67
+ KEY `IDX_BRONTO_REMINDER_MESSAGE` (`message_id`),
68
+ CONSTRAINT `FK_BRONTO_REMINDER_MESSAGE_RULE` FOREIGN KEY (`rule_id`)
69
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
70
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
71
+ ");
72
+ } catch (Exception $e) {
73
+ throw new RuntimeException('Failed Creating Reminder Message Table: ' . $e->getMessage());
74
+ }
75
+
76
+ try {
77
+ // Create New Reminder Rule Coupon Table
78
+ $installer->run("
79
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/coupon')}`;
80
+
81
+ CREATE TABLE `{$installer->getTable('bronto_reminder/coupon')}` (
82
+ `rule_id` int(10) unsigned NOT NULL,
83
+ `coupon_id` int(10) unsigned DEFAULT NULL,
84
+ `unique_id` varchar(20) NOT NULL,
85
+ `store_id` int(10) unsigned NOT NULL,
86
+ `customer_id` int(10) unsigned NOT NULL,
87
+ `visitor_id` int(10) unsigned NOT NULL DEFAULT '0',
88
+ `quote_id` int(10) unsigned NOT NULL DEFAULT '0',
89
+ `wishlist_id` int(10) unsigned NOT NULL DEFAULT '0',
90
+ `associated_at` datetime NOT NULL,
91
+ `emails_failed` smallint(5) unsigned NOT NULL DEFAULT '0',
92
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '1',
93
+ PRIMARY KEY (`rule_id`,`unique_id`,`store_id`,`customer_id`,`visitor_id`,`quote_id`,`wishlist_id`),
94
+ KEY `IDX_BRONTO_REMINDER_RULE_COUPON` (`rule_id`),
95
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE_COUPON` FOREIGN KEY (`rule_id`)
96
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
97
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
98
+ ");
99
+ } catch (Exception $e) {
100
+ throw new RuntimeException('Failed Creating Reminder Rule Coupon Table: ' . $e->getMessage());
101
+ }
102
+
103
+ try {
104
+ // Create New Reminder Rule Website Table
105
+ $installer->run("
106
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/log')}`;
107
+
108
+ CREATE TABLE `{$installer->getTable('bronto_reminder/log')}` (
109
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
110
+ `rule_id` int(10) unsigned NOT NULL,
111
+ `unique_id` varchar(20) NOT NULL,
112
+ `sent_at` datetime NOT NULL,
113
+ `bronto_delivery_id` varchar(255) DEFAULT NULL,
114
+ `bronto_message_id` varchar(255) DEFAULT NULL,
115
+ PRIMARY KEY (`log_id`),
116
+ KEY `IDX_BRONTO_REMINDER_LOG_RULE` (`rule_id`),
117
+ CONSTRAINT `FK_BRONTO_REMINDER_LOG_RULE` FOREIGN KEY (`rule_id`)
118
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
119
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
120
+ ");
121
+ } catch (Exception $e) {
122
+ throw new RuntimeException('Failed Creating Reminder Rule Log Table: ' . $e->getMessage());
123
+ }
124
+
125
+ $installer->endSetup();
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.14.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ try {
8
+ // Create New Reminder Rule Table
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/rule')}`;
11
+
12
+ CREATE TABLE `{$installer->getTable('bronto_reminder/rule')}` (
13
+ `rule_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
14
+ `name` varchar(255) NOT NULL DEFAULT '',
15
+ `description` text NOT NULL,
16
+ `conditions_serialized` mediumtext NOT NULL,
17
+ `condition_sql` mediumtext,
18
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
19
+ `salesrule_id` int(10) unsigned DEFAULT NULL,
20
+ `schedule` varchar(255) NOT NULL DEFAULT '',
21
+ `default_label` varchar(255) NOT NULL DEFAULT '',
22
+ `default_description` text NOT NULL,
23
+ `active_from` datetime DEFAULT NULL,
24
+ `active_to` datetime DEFAULT NULL,
25
+ `send_to` enum('user', 'guest', 'both') DEFAULT 'both',
26
+ PRIMARY KEY (`rule_id`),
27
+ KEY `IDX_BRONTO_REMINDER_SALESRULE` (`salesrule_id`),
28
+ CONSTRAINT `FK_BRONTO_REMINDER_SALESRULE` FOREIGN KEY (`salesrule_id`)
29
+ REFERENCES `{$this->getTable('salesrule')}` (`rule_id`) ON DELETE SET NULL ON UPDATE CASCADE
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+ ");
32
+ } catch (Exception $e) {
33
+ throw new RuntimeException('Failed Creating Reminder Rule Table: ' . $e->getMessage());
34
+ }
35
+
36
+ try {
37
+ // Create New Reminder Rule Website Table
38
+ $installer->run("
39
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/website')}`;
40
+
41
+ CREATE TABLE `{$installer->getTable('bronto_reminder/website')}` (
42
+ `rule_id` int(10) unsigned NOT NULL,
43
+ `website_id` smallint(5) unsigned NOT NULL,
44
+ PRIMARY KEY (`rule_id`,`website_id`),
45
+ KEY `IDX_BRONTO_REMINDER_WEBSITE` (`website_id`),
46
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE` FOREIGN KEY (`rule_id`)
47
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
48
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
49
+ ");
50
+ } catch (Exception $e) {
51
+ throw new RuntimeException('Failed Creating Reminder Rule Website Table: ' . $e->getMessage());
52
+ }
53
+
54
+ try {
55
+ // Create New Reminder Message Table
56
+ $installer->run("
57
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/message')}`;
58
+
59
+ CREATE TABLE `{$installer->getTable('bronto_reminder/message')}` (
60
+ `rule_id` int(10) unsigned NOT NULL,
61
+ `store_id` smallint(5) NOT NULL,
62
+ `message_id` varchar(255) NOT NULL DEFAULT '',
63
+ `send_type` varchar(20) NOT NULL DEFAULT 'transactional',
64
+ `label` varchar(255) DEFAULT NULL,
65
+ `description` text,
66
+ PRIMARY KEY (`rule_id`,`store_id`),
67
+ KEY `IDX_BRONTO_REMINDER_MESSAGE_RULE` (`rule_id`),
68
+ KEY `IDX_BRONTO_REMINDER_MESSAGE` (`message_id`),
69
+ CONSTRAINT `FK_BRONTO_REMINDER_MESSAGE_RULE` FOREIGN KEY (`rule_id`)
70
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
71
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
72
+ ");
73
+ } catch (Exception $e) {
74
+ throw new RuntimeException('Failed Creating Reminder Message Table: ' . $e->getMessage());
75
+ }
76
+
77
+ try {
78
+ // Create New Reminder Rule Coupon Table
79
+ $installer->run("
80
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/coupon')}`;
81
+
82
+ CREATE TABLE `{$installer->getTable('bronto_reminder/coupon')}` (
83
+ `rule_id` int(10) unsigned NOT NULL,
84
+ `coupon_id` int(10) unsigned DEFAULT NULL,
85
+ `unique_id` varchar(20) NOT NULL,
86
+ `store_id` int(10) unsigned NOT NULL,
87
+ `customer_id` int(10) unsigned NOT NULL,
88
+ `visitor_id` int(10) unsigned NOT NULL DEFAULT '0',
89
+ `quote_id` int(10) unsigned NOT NULL DEFAULT '0',
90
+ `wishlist_id` int(10) unsigned NOT NULL DEFAULT '0',
91
+ `associated_at` datetime NOT NULL,
92
+ `emails_failed` smallint(5) unsigned NOT NULL DEFAULT '0',
93
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '1',
94
+ PRIMARY KEY (`rule_id`,`unique_id`,`store_id`,`customer_id`,`visitor_id`,`quote_id`,`wishlist_id`),
95
+ KEY `IDX_BRONTO_REMINDER_RULE_COUPON` (`rule_id`),
96
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE_COUPON` FOREIGN KEY (`rule_id`)
97
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
98
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
99
+ ");
100
+ } catch (Exception $e) {
101
+ throw new RuntimeException('Failed Creating Reminder Rule Coupon Table: ' . $e->getMessage());
102
+ }
103
+
104
+ try {
105
+ // Create New Reminder Rule Website Table
106
+ $installer->run("
107
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/log')}`;
108
+
109
+ CREATE TABLE `{$installer->getTable('bronto_reminder/log')}` (
110
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
111
+ `rule_id` int(10) unsigned NOT NULL,
112
+ `unique_id` varchar(20) NOT NULL,
113
+ `sent_at` datetime NOT NULL,
114
+ `bronto_delivery_id` varchar(255) DEFAULT NULL,
115
+ `bronto_message_id` varchar(255) DEFAULT NULL,
116
+ PRIMARY KEY (`log_id`),
117
+ KEY `IDX_BRONTO_REMINDER_LOG_RULE` (`rule_id`),
118
+ CONSTRAINT `FK_BRONTO_REMINDER_LOG_RULE` FOREIGN KEY (`rule_id`)
119
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
120
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
121
+ ");
122
+ } catch (Exception $e) {
123
+ throw new RuntimeException('Failed Creating Reminder Rule Log Table: ' . $e->getMessage());
124
+ }
125
+
126
+ $installer->endSetup();
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.15.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ try {
8
+ // Create New Reminder Rule Table
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/rule')}`;
11
+
12
+ CREATE TABLE `{$installer->getTable('bronto_reminder/rule')}` (
13
+ `rule_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
14
+ `name` varchar(255) NOT NULL DEFAULT '',
15
+ `description` text NOT NULL,
16
+ `conditions_serialized` mediumtext NOT NULL,
17
+ `condition_sql` mediumtext,
18
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
19
+ `salesrule_id` int(10) unsigned DEFAULT NULL,
20
+ `schedule` varchar(255) NOT NULL DEFAULT '',
21
+ `default_label` varchar(255) NOT NULL DEFAULT '',
22
+ `default_description` text NOT NULL,
23
+ `active_from` datetime DEFAULT NULL,
24
+ `active_to` datetime DEFAULT NULL,
25
+ `send_to` enum('user', 'guest', 'both') DEFAULT 'both',
26
+ PRIMARY KEY (`rule_id`),
27
+ KEY `IDX_BRONTO_REMINDER_SALESRULE` (`salesrule_id`),
28
+ CONSTRAINT `FK_BRONTO_REMINDER_SALESRULE` FOREIGN KEY (`salesrule_id`)
29
+ REFERENCES `{$this->getTable('salesrule')}` (`rule_id`) ON DELETE SET NULL ON UPDATE CASCADE
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+ ");
32
+ } catch (Exception $e) {
33
+ throw new RuntimeException('Failed Creating Reminder Rule Table: ' . $e->getMessage());
34
+ }
35
+
36
+ try {
37
+ // Create New Reminder Rule Website Table
38
+ $installer->run("
39
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/website')}`;
40
+
41
+ CREATE TABLE `{$installer->getTable('bronto_reminder/website')}` (
42
+ `rule_id` int(10) unsigned NOT NULL,
43
+ `website_id` smallint(5) unsigned NOT NULL,
44
+ PRIMARY KEY (`rule_id`,`website_id`),
45
+ KEY `IDX_BRONTO_REMINDER_WEBSITE` (`website_id`),
46
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE` FOREIGN KEY (`rule_id`)
47
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
48
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
49
+ ");
50
+ } catch (Exception $e) {
51
+ throw new RuntimeException('Failed Creating Reminder Rule Website Table: ' . $e->getMessage());
52
+ }
53
+
54
+ try {
55
+ // Create New Reminder Message Table
56
+ $installer->run("
57
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/message')}`;
58
+
59
+ CREATE TABLE `{$installer->getTable('bronto_reminder/message')}` (
60
+ `rule_id` int(10) unsigned NOT NULL,
61
+ `store_id` smallint(5) NOT NULL,
62
+ `message_id` varchar(255) NOT NULL DEFAULT '',
63
+ `send_type` varchar(20) NOT NULL DEFAULT 'transactional',
64
+ `label` varchar(255) DEFAULT NULL,
65
+ `description` text,
66
+ PRIMARY KEY (`rule_id`,`store_id`),
67
+ KEY `IDX_BRONTO_REMINDER_MESSAGE_RULE` (`rule_id`),
68
+ KEY `IDX_BRONTO_REMINDER_MESSAGE` (`message_id`),
69
+ CONSTRAINT `FK_BRONTO_REMINDER_MESSAGE_RULE` FOREIGN KEY (`rule_id`)
70
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
71
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
72
+ ");
73
+ } catch (Exception $e) {
74
+ throw new RuntimeException('Failed Creating Reminder Message Table: ' . $e->getMessage());
75
+ }
76
+
77
+ try {
78
+ // Create New Reminder Rule Coupon Table
79
+ $installer->run("
80
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/coupon')}`;
81
+
82
+ CREATE TABLE `{$installer->getTable('bronto_reminder/coupon')}` (
83
+ `rule_id` int(10) unsigned NOT NULL,
84
+ `coupon_id` int(10) unsigned DEFAULT NULL,
85
+ `unique_id` varchar(20) NOT NULL,
86
+ `store_id` int(10) unsigned NOT NULL,
87
+ `customer_id` int(10) unsigned NOT NULL,
88
+ `visitor_id` int(10) unsigned NOT NULL DEFAULT '0',
89
+ `quote_id` int(10) unsigned NOT NULL DEFAULT '0',
90
+ `wishlist_id` int(10) unsigned NOT NULL DEFAULT '0',
91
+ `associated_at` datetime NOT NULL,
92
+ `emails_failed` smallint(5) unsigned NOT NULL DEFAULT '0',
93
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '1',
94
+ PRIMARY KEY (`rule_id`,`unique_id`,`store_id`,`customer_id`,`visitor_id`,`quote_id`,`wishlist_id`),
95
+ KEY `IDX_BRONTO_REMINDER_RULE_COUPON` (`rule_id`),
96
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE_COUPON` FOREIGN KEY (`rule_id`)
97
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
98
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
99
+ ");
100
+ } catch (Exception $e) {
101
+ throw new RuntimeException('Failed Creating Reminder Rule Coupon Table: ' . $e->getMessage());
102
+ }
103
+
104
+ try {
105
+ // Create New Reminder Rule Website Table
106
+ $installer->run("
107
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/log')}`;
108
+
109
+ CREATE TABLE `{$installer->getTable('bronto_reminder/log')}` (
110
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
111
+ `rule_id` int(10) unsigned NOT NULL,
112
+ `unique_id` varchar(20) NOT NULL,
113
+ `sent_at` datetime NOT NULL,
114
+ `bronto_delivery_id` varchar(255) DEFAULT NULL,
115
+ `bronto_message_id` varchar(255) DEFAULT NULL,
116
+ PRIMARY KEY (`log_id`),
117
+ KEY `IDX_BRONTO_REMINDER_LOG_RULE` (`rule_id`),
118
+ CONSTRAINT `FK_BRONTO_REMINDER_LOG_RULE` FOREIGN KEY (`rule_id`)
119
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
120
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
121
+ ");
122
+ } catch (Exception $e) {
123
+ throw new RuntimeException('Failed Creating Reminder Rule Log Table: ' . $e->getMessage());
124
+ }
125
+
126
+ /**
127
+ * Reminder Delivery Log table
128
+ */
129
+ try {
130
+
131
+ $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/delivery')}`;");
132
+
133
+ $installer->run("
134
+ CREATE TABLE `{$installer->getTable('bronto_reminder/delivery')}` (
135
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
136
+ `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
137
+ `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
138
+ `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
139
+ `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
140
+ `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
141
+ `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
142
+ `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
143
+ `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
144
+ `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
145
+ `fields` text COMMENT 'Fields',
146
+ PRIMARY KEY (`log_id`),
147
+ KEY `IDX_BRONTO_REMINDER_LOG_CUSTOMER_EMAIL` (`customer_email`),
148
+ KEY `IDX_BRONTO_REMINDER_LOG_SENT_AT` (`sent_at`)
149
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Reminder Delivery Logs'
150
+ ");
151
+
152
+ } catch (Exception $e) {
153
+ Mage::helper('bronto_reminder')->writeError($e->getMessage());
154
+ }
155
+
156
+ $installer->endSetup();
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-install-1.4.16.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ try {
8
+ // Create New Reminder Rule Table
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/rule')}`;
11
+
12
+ CREATE TABLE `{$installer->getTable('bronto_reminder/rule')}` (
13
+ `rule_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
14
+ `name` varchar(255) NOT NULL DEFAULT '',
15
+ `description` text NOT NULL,
16
+ `conditions_serialized` mediumtext NOT NULL,
17
+ `condition_sql` mediumtext,
18
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
19
+ `salesrule_id` int(10) unsigned DEFAULT NULL,
20
+ `schedule` varchar(255) NOT NULL DEFAULT '',
21
+ `default_label` varchar(255) NOT NULL DEFAULT '',
22
+ `default_description` text NOT NULL,
23
+ `active_from` datetime DEFAULT NULL,
24
+ `active_to` datetime DEFAULT NULL,
25
+ `send_to` enum('user', 'guest', 'both') DEFAULT 'both',
26
+ `send_limit` int(10) DEFAULT 1,
27
+ PRIMARY KEY (`rule_id`),
28
+ KEY `IDX_BRONTO_REMINDER_SALESRULE` (`salesrule_id`),
29
+ CONSTRAINT `FK_BRONTO_REMINDER_SALESRULE` FOREIGN KEY (`salesrule_id`)
30
+ REFERENCES `{$this->getTable('salesrule')}` (`rule_id`) ON DELETE SET NULL ON UPDATE CASCADE
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32
+ ");
33
+ } catch (Exception $e) {
34
+ throw new RuntimeException('Failed Creating Reminder Rule Table: ' . $e->getMessage());
35
+ }
36
+
37
+ try {
38
+ // Create New Reminder Rule Website Table
39
+ $installer->run("
40
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/website')}`;
41
+
42
+ CREATE TABLE `{$installer->getTable('bronto_reminder/website')}` (
43
+ `rule_id` int(10) unsigned NOT NULL,
44
+ `website_id` smallint(5) unsigned NOT NULL,
45
+ PRIMARY KEY (`rule_id`,`website_id`),
46
+ KEY `IDX_BRONTO_REMINDER_WEBSITE` (`website_id`),
47
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE` FOREIGN KEY (`rule_id`)
48
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
49
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
50
+ ");
51
+ } catch (Exception $e) {
52
+ throw new RuntimeException('Failed Creating Reminder Rule Website Table: ' . $e->getMessage());
53
+ }
54
+
55
+ try {
56
+ // Create New Reminder Message Table
57
+ $installer->run("
58
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/message')}`;
59
+
60
+ CREATE TABLE `{$installer->getTable('bronto_reminder/message')}` (
61
+ `rule_id` int(10) unsigned NOT NULL,
62
+ `store_id` smallint(5) NOT NULL,
63
+ `message_id` varchar(255) NOT NULL DEFAULT '',
64
+ `send_type` varchar(20) NOT NULL DEFAULT 'transactional',
65
+ `label` varchar(255) DEFAULT NULL,
66
+ `description` text,
67
+ PRIMARY KEY (`rule_id`,`store_id`),
68
+ KEY `IDX_BRONTO_REMINDER_MESSAGE_RULE` (`rule_id`),
69
+ KEY `IDX_BRONTO_REMINDER_MESSAGE` (`message_id`),
70
+ CONSTRAINT `FK_BRONTO_REMINDER_MESSAGE_RULE` FOREIGN KEY (`rule_id`)
71
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
72
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
73
+ ");
74
+ } catch (Exception $e) {
75
+ throw new RuntimeException('Failed Creating Reminder Message Table: ' . $e->getMessage());
76
+ }
77
+
78
+ try {
79
+ // Create New Reminder Rule Coupon Table
80
+ $installer->run("
81
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/coupon')}`;
82
+
83
+ CREATE TABLE `{$installer->getTable('bronto_reminder/coupon')}` (
84
+ `rule_id` int(10) unsigned NOT NULL,
85
+ `coupon_id` int(10) unsigned DEFAULT NULL,
86
+ `unique_id` varchar(255) NOT NULL,
87
+ `store_id` int(10) unsigned NOT NULL,
88
+ `customer_id` int(10) unsigned NOT NULL,
89
+ `customer_email` varchar(255) CHARACTER SET utf8 NOT NULL,
90
+ `quote_id` int(10) unsigned NOT NULL DEFAULT '0',
91
+ `wishlist_id` int(10) unsigned NOT NULL DEFAULT '0',
92
+ `associated_at` datetime NOT NULL,
93
+ `emails_failed` smallint(5) unsigned NOT NULL DEFAULT '0',
94
+ `is_active` tinyint(1) unsigned NOT NULL DEFAULT '1',
95
+ PRIMARY KEY (`rule_id`,`unique_id`,`store_id`,`customer_email`),
96
+ KEY `IDX_BRONTO_REMINDER_RULE_COUPON` (`rule_id`),
97
+ CONSTRAINT `FK_BRONTO_REMINDER_RULE_COUPON` FOREIGN KEY (`rule_id`)
98
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
99
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
100
+ ");
101
+ } catch (Exception $e) {
102
+ throw new RuntimeException('Failed Creating Reminder Rule Coupon Table: ' . $e->getMessage());
103
+ }
104
+
105
+ try {
106
+ // Create New Reminder Rule Website Table
107
+ $installer->run("
108
+ DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/log')}`;
109
+
110
+ CREATE TABLE `{$installer->getTable('bronto_reminder/log')}` (
111
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
112
+ `rule_id` int(10) unsigned NOT NULL,
113
+ `unique_id` varchar(255) NOT NULL,
114
+ `sent_at` datetime NOT NULL,
115
+ `bronto_delivery_id` varchar(255) DEFAULT NULL,
116
+ `bronto_message_id` varchar(255) DEFAULT NULL,
117
+ PRIMARY KEY (`log_id`),
118
+ KEY `IDX_BRONTO_REMINDER_LOG_RULE` (`rule_id`),
119
+ CONSTRAINT `FK_BRONTO_REMINDER_LOG_RULE` FOREIGN KEY (`rule_id`)
120
+ REFERENCES `{$installer->getTable('bronto_reminder/rule')}` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE
121
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
122
+ ");
123
+ } catch (Exception $e) {
124
+ throw new RuntimeException('Failed Creating Reminder Rule Log Table: ' . $e->getMessage());
125
+ }
126
+
127
+ /**
128
+ * Reminder Delivery Log table
129
+ */
130
+ try {
131
+
132
+ $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/delivery')}`;");
133
+
134
+ $installer->run("
135
+ CREATE TABLE `{$installer->getTable('bronto_reminder/delivery')}` (
136
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
137
+ `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
138
+ `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
139
+ `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
140
+ `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
141
+ `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
142
+ `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
143
+ `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
144
+ `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
145
+ `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
146
+ `fields` text COMMENT 'Fields',
147
+ PRIMARY KEY (`log_id`),
148
+ KEY `IDX_BRONTO_REMINDER_LOG_CUSTOMER_EMAIL` (`customer_email`),
149
+ KEY `IDX_BRONTO_REMINDER_LOG_SENT_AT` (`sent_at`)
150
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Reminder Delivery Logs'
151
+ ");
152
+
153
+ } catch (Exception $e) {
154
+ Mage::helper('bronto_reminder')->writeError($e->getMessage());
155
+ }
156
+
157
+ $installer->endSetup();
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.12-1.4.13.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ try {
9
+ $installer->run("
10
+ ALTER TABLE `{$installer->getTable('bronto_reminder/rule')}`
11
+ ADD COLUMN `send_to` enum('user', 'guest', 'both') DEFAULT 'both';
12
+ ");
13
+ } catch (Exception $e) {
14
+ throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
15
+ }
16
+
17
+ $installer->endSetup();
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.13-1.4.14.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ try {
9
+ $installer->run("
10
+ ALTER TABLE `{$installer->getTable('bronto_reminder/message')}`
11
+ ADD COLUMN `send_type` varchar(20) NOT NULL DEFAULT 'transactional';
12
+ ");
13
+ } catch (Exception $e) {
14
+ throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
15
+ }
16
+
17
+ $installer->endSetup();
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.14-1.4.15.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ /**
8
+ * Reminder Delivery Log table
9
+ */
10
+ try {
11
+
12
+ $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_reminder/delivery')}`;");
13
+
14
+ $installer->run("
15
+ CREATE TABLE `{$installer->getTable('bronto_reminder/delivery')}` (
16
+ `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
17
+ `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
18
+ `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
19
+ `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
20
+ `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
21
+ `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
22
+ `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
23
+ `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
24
+ `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
25
+ `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
26
+ `fields` text COMMENT 'Fields',
27
+ PRIMARY KEY (`log_id`),
28
+ KEY `IDX_BRONTO_REMINDER_LOG_CUSTOMER_EMAIL` (`customer_email`),
29
+ KEY `IDX_BRONTO_REMINDER_LOG_SENT_AT` (`sent_at`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Reminder Delivery Logs'
31
+ ");
32
+
33
+ } catch (Exception $e) {
34
+ Mage::helper('bronto_reminder')->writeError($e->getMessage());
35
+ }
app/code/community/Bronto/Reminder/sql/bronto_reminder_setup/mysql4-upgrade-1.4.15-1.4.16.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Core_Model_Resource_Setup|Mage_Core_Model_Mysql4_Setup */
4
+
5
+ $installer->startSetup();
6
+
7
+ try {
8
+ $installer->run("
9
+ ALTER TABLE `{$installer->getTable('bronto_reminder/rule')}`
10
+ ADD COLUMN `send_limit` int(10) DEFAULT 1;
11
+ ");
12
+ } catch (Exception $e) {
13
+ Mage::helper('bronto_reminder')->writeError($e->getMessage());
14
+ }
15
+
16
+ try {
17
+ $installer->run("TRUNCATE `{$installer->getTable('bronto_reminder/coupon')}`;");
18
+
19
+ $installer->run("
20
+ ALTER TABLE `{$installer->getTable('bronto_reminder/coupon')}`
21
+ CHANGE COLUMN `unique_id` `unique_id` varchar(255) CHARACTER SET utf8 NOT NULL,
22
+ CHANGE COLUMN `visitor_id` `customer_email` varchar(255) CHARACTER SET utf8 NOT NULL,
23
+ DROP PRIMARY KEY,
24
+ ADD PRIMARY KEY (`rule_id`,`unique_id`,`store_id`,`customer_email`);
25
+ ");
26
+ } catch (Exception $e) {
27
+ Mage::helper('bronto_reminder')->writeError($e->getMessage());
28
+ }
29
+
30
+ try {
31
+ $installer->run("
32
+ ALTER TABLE `{$installer->getTable('bronto_reminder/log')}`
33
+ CHANGE COLUMN `unique_id` `unique_id` varchar(255) CHARACTER SET utf8 NOT NULL;
34
+ ");
35
+ } catch (Exception $e) {
36
+ Mage::helper('bronto_reminder')->writeError($e->getMessage());
37
+ }
38
+
39
+ $installer->endSetup();
app/code/community/Bronto/Reviews/Block/Adminhtml/System/Config/About.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2012 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reviews_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
8
+ {
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $_module = 'bronto_reviews';
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_name = 'Bronto Review Request Module';
18
+ }
app/code/community/Bronto/Reviews/Helper/Contact.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ * @version 0.0.1
7
+ */
8
+ class Bronto_Reviews_Helper_Contact
9
+ extends Bronto_Common_Helper_Contact
10
+ {
11
+ /**
12
+ * Retrieve helper module name
13
+ *
14
+ * @return string
15
+ */
16
+ protected function _getModuleName()
17
+ {
18
+ return 'Bronto_Reviews';
19
+ }
20
+
21
+ /**
22
+ * @param string $email
23
+ * @return Bronto_Api_Contact_Row
24
+ */
25
+ public function getContactByEmail($email, $customSource = 'bronto_reviews', $store = null)
26
+ {
27
+ return parent::getContactByEmail($email, $customSource, $store);
28
+ }
29
+ }
app/code/community/Bronto/Reviews/Helper/Data.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reviews_Helper_Data
8
+ extends Bronto_Common_Helper_Data
9
+ implements Bronto_Common_Helper_DataInterface
10
+ {
11
+ const XML_PATH_ENABLED = 'bronto_reviews/settings/enabled';
12
+ const XML_PATH_STATUS = 'bronto_reviews/settings/status';
13
+ const XML_PATH_CANCEL_STATUS = 'bronto_reviews/settings/cancel_status';
14
+ const XML_PATH_URL_SUFFIX = 'bronto_reviews/settings/url_suffix';
15
+ const XML_PATH_PERIOD = 'bronto_reviews/settings/period';
16
+ const XML_PATH_MESSAGE = 'bronto_reviews/settings/message';
17
+ const XML_PATH_SENDER_EMAIL = 'bronto_reviews/settings/sender_email';
18
+ const XML_PATH_SENDER_NAME = 'bronto_reviews/settings/sender_name';
19
+ const XML_PATH_REPLY_TO = 'bronto_reviews/settings/reply_to';
20
+
21
+ /**
22
+ * Check if module is enabled
23
+ *
24
+ * @param string $scope
25
+ * @param int $scopeId
26
+ *
27
+ * @return bool
28
+ */
29
+ public function isEnabled($scope = 'default', $scopeId = 0)
30
+ {
31
+ // Check if valid token is present
32
+ if (!$this->validApiToken(null, $scope, $scopeId)) {
33
+ return false;
34
+ }
35
+
36
+ // Get Enabled Scope
37
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
38
+ }
39
+
40
+ /**
41
+ * Disable Module for Specified Scope
42
+ *
43
+ * @param string $scope
44
+ * @param int $scopeId
45
+ * @param bool $deleteConfig
46
+ *
47
+ * @return bool
48
+ */
49
+ public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
50
+ {
51
+ return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
52
+ }
53
+
54
+ /**
55
+ * Get Order Status at which to send Review Request Emails
56
+ *
57
+ * @param string $scope
58
+ * @param int $scopeId
59
+ *
60
+ * @return mixed
61
+ */
62
+ public function getReviewSendStatus($scope = 'default', $scopeId = 0)
63
+ {
64
+ return $this->getAdminScopedConfig(self::XML_PATH_STATUS, $scope, $scopeId);
65
+ }
66
+
67
+ /**
68
+ * Get Order Status at which to cancel Review Request Emails
69
+ *
70
+ * @param string $scope
71
+ * @param int $scopeId
72
+ *
73
+ * @return array
74
+ */
75
+ public function getReviewCancelStatus($scope = 'default', $scopeId = 0)
76
+ {
77
+ $status = $this->getAdminScopedConfig(self::XML_PATH_CANCEL_STATUS, $scope, $scopeId);
78
+ if ($status != '') {
79
+ $status = explode(',', $status);
80
+ } else {
81
+ $status = array();
82
+ }
83
+
84
+ return $status;
85
+ }
86
+
87
+ /**
88
+ * Get suffix to append to product URLs
89
+ *
90
+ * @param string $scope
91
+ * @param int $scopeId
92
+ *
93
+ * @return mixed
94
+ */
95
+ public function getProductUrlSuffix($scope = 'default', $scopeId = 0)
96
+ {
97
+ return $this->getAdminScopedConfig(self::XML_PATH_URL_SUFFIX, $scope, $scopeId);
98
+ }
99
+
100
+
101
+ /**
102
+ * Get Period to wait before sending Review Request
103
+ *
104
+ * @param string $scope
105
+ * @param int $scopeId
106
+ *
107
+ * @return mixed
108
+ */
109
+ public function getReviewSendPeriod($scope = 'default', $scopeId = 0)
110
+ {
111
+ return $this->getAdminScopedConfig(self::XML_PATH_PERIOD, $scope, $scopeId);
112
+ }
113
+
114
+ /**
115
+ * Get Bronto Message to use for sending Review Request Email
116
+ *
117
+ * @param string $scope
118
+ * @param int $scopeId
119
+ *
120
+ * @return mixed
121
+ */
122
+ public function getReviewSendMessage($scope = 'default', $scopeId = 0)
123
+ {
124
+ return $this->getAdminScopedConfig(self::XML_PATH_MESSAGE, $scope, $scopeId);
125
+ }
126
+
127
+ /**
128
+ * Get the review url for the product
129
+ *
130
+ * @param $product
131
+ * @return string
132
+ */
133
+ public function getReviewsUrl($product, $storeId = null)
134
+ {
135
+ $url = Mage::getModel('core/url')->setStore($storeId);
136
+ return $url->getUrl('review/product/list', array(
137
+ 'id' => $product->getId()
138
+ ));
139
+ }
140
+
141
+ /**
142
+ * Get Sender Email Address
143
+ *
144
+ * @param string $scope
145
+ * @param int $scopeId
146
+ *
147
+ * @return mixed
148
+ */
149
+ public function getReviewSenderEmail($scope = 'default', $scopeId = 0)
150
+ {
151
+ return $this->getAdminScopedConfig(self::XML_PATH_SENDER_EMAIL, $scope, $scopeId);
152
+ }
153
+
154
+ /**
155
+ * Get Sender Name
156
+ *
157
+ * @param string $scope
158
+ * @param int $scopeId
159
+ *
160
+ * @return mixed
161
+ */
162
+ public function getReviewSenderName($scope = 'default', $scopeId = 0)
163
+ {
164
+ return $this->getAdminScopedConfig(self::XML_PATH_SENDER_NAME, $scope, $scopeId);
165
+ }
166
+
167
+ /**
168
+ * Get Reply-To Email Address
169
+ *
170
+ * @param string $scope
171
+ * @param int $scopeId
172
+ *
173
+ * @return mixed
174
+ */
175
+ public function getReviewReplyTo($scope = 'default', $scopeId = 0)
176
+ {
177
+ return $this->getAdminScopedConfig(self::XML_PATH_REPLY_TO, $scope, $scopeId);
178
+ }
179
+ }
app/code/community/Bronto/Reviews/Helper/Message.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ * @version 0.0.1
7
+ */
8
+ class Bronto_Reviews_Helper_Message
9
+ extends Bronto_Common_Helper_Message
10
+ {
11
+ /**
12
+ * Retrieve helper module name
13
+ *
14
+ * @return string
15
+ */
16
+ protected function _getModuleName()
17
+ {
18
+ return 'Bronto_Reviews';
19
+ }
20
+ }
app/code/community/Bronto/Reviews/Model/Mysql4/Queue.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ * @version 0.0.1
7
+ */
8
+ class Bronto_Reviews_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+ /**
11
+ * Primery key auto increment flag
12
+ *
13
+ * @var bool
14
+ */
15
+ protected $_isPkAutoIncrement = false;
16
+
17
+ /**
18
+ * Initialize Model
19
+ *
20
+ * @return void
21
+ * @access public
22
+ */
23
+ public function _construct()
24
+ {
25
+ $this->_init('bronto_reviews/queue', 'order_id');
26
+ }
27
+ }
app/code/community/Bronto/Reviews/Model/Mysql4/Queue/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ * @version 0.0.1
7
+ */
8
+ class Bronto_Reviews_Model_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+ protected function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('bronto_reviews/queue');
14
+ }
15
+ }
app/code/community/Bronto/Reviews/Model/Observer.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reviews_Model_Observer
8
+ {
9
+ const NOTICE_IDENTIFER = 'bronto_reviews';
10
+
11
+ // Helper
12
+ protected $_helper;
13
+
14
+ // Data Members
15
+ protected $_contact;
16
+ protected $_order;
17
+ protected $_deliveryObject;
18
+ protected $_deliveryRow;
19
+ protected $_deliveryId;
20
+
21
+ public function __construct()
22
+ {
23
+ /* @var Bronto_Reviews_Helper_Data $_helper */
24
+ $this->_helper = Mage::helper(self::NOTICE_IDENTIFER);
25
+ }
26
+
27
+ /**
28
+ * Set Contact Row Object to use
29
+ *
30
+ * @param Bronto_Api_Contact_Row $contact
31
+ *
32
+ * @return Bronto_Reviews_Model_Observer
33
+ */
34
+ public function setContact(Bronto_Api_Contact_Row $contact)
35
+ {
36
+ $this->_contact = $contact;
37
+
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Get Contact Row Object to use
43
+ *
44
+ * @return Bronto_Api_Contact_Row
45
+ */
46
+ public function getContact()
47
+ {
48
+ if (!$this->_contact) {
49
+ // Retrieve Store's configured API Token
50
+ $token = $this->_helper->getApiToken('store', $this->getOrder()->getStoreId());
51
+
52
+ /** @var Bronto_Common_Model_Api $api */
53
+ $api = $this->_helper->getApi($token, 'store', $this->getOrder()->getStoreId());
54
+
55
+ /** @var Bronto_Api_Contact $contactObject */
56
+ $contactObject = $api->getContactObject();
57
+
58
+ /** @var Bronto_Api_Contact_Row $brontoContact */
59
+ $brontoContact = $contactObject->createRow(array());
60
+ $brontoContact->email = $this->getOrder()->getCustomerEmail();
61
+ $brontoContact->save();
62
+
63
+ $this->setContact($brontoContact);
64
+ }
65
+
66
+ return $this->_contact;
67
+ }
68
+
69
+ /**
70
+ * Set Order to use
71
+ *
72
+ * @param Mage_Sales_Model_Order $order
73
+ *
74
+ * @return Bronto_Reviews_Model_Observer
75
+ */
76
+ public function setOrder(Mage_Sales_Model_Order $order)
77
+ {
78
+ $this->_order = $order;
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Get Order to use
85
+ *
86
+ * @return Mage_Sales_Model_Order
87
+ */
88
+ public function getOrder()
89
+ {
90
+ return $this->_order;
91
+ }
92
+
93
+ /**
94
+ * Set Delivery Object to use
95
+ *
96
+ * @param Bronto_Api_Delivery $deliveryObject
97
+ *
98
+ * @return Bronto_Reviews_Model_Observer
99
+ */
100
+ public function setDeliveryObject(Bronto_Api_Delivery $deliveryObject)
101
+ {
102
+ $this->_deliveryObject = $deliveryObject;
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Get Delivery Object to use
109
+ *
110
+ * @return boolean|Bronto_Api_Delivery
111
+ */
112
+ public function getDeliveryObject()
113
+ {
114
+ if (!$this->_deliveryObject) {
115
+ try {
116
+ // Retrieve Store's configured API Token
117
+ $token = $this->_helper->getApiToken('store', $this->getOrder()->getStoreId());
118
+
119
+ /* @var Bronto_Common_Model_Api $api */
120
+ $api = $this->_helper->getApi($token, 'store', $this->getOrder()->getStoreId());
121
+
122
+ /* @var Bronto_Api_Delivery $deliveryObject */
123
+ $this->_deliveryObject = $api->getDeliveryObject();
124
+ } catch (Exception $e) {
125
+ $this->_helper->writeError('Bronto Failed creating apiObject:' . $e->getMessage());
126
+
127
+ return false;
128
+ }
129
+ }
130
+
131
+ return $this->_deliveryObject;
132
+ }
133
+
134
+ /**
135
+ * Set Delivery Row Object to use
136
+ *
137
+ * @param Bronto_Api_Delivery_Row $deliveryRow
138
+ *
139
+ * @return Bronto_Reviews_Model_Observer
140
+ */
141
+ public function setDeliveryRow(Bronto_Api_Delivery_Row $deliveryRow)
142
+ {
143
+ $this->_deliveryRow = $deliveryRow;
144
+
145
+ return $this;
146
+ }
147
+
148
+ /**
149
+ * Get Delivery Row if exists, create if doesn't
150
+ *
151
+ * @return boolean
152
+ */
153
+ public function getDeliveryRow()
154
+ {
155
+ if (!$this->_deliveryRow) {
156
+ try {
157
+ $this->_deliveryRow = $this->getDeliveryObject()->createRow(array());
158
+ } catch (Exception $e) {
159
+ $this->_helper->writeError('Bronto Failed creating apiObject:' . $e->getMessage());
160
+
161
+ return false;
162
+ }
163
+ }
164
+
165
+ return $this->_deliveryRow;
166
+ }
167
+
168
+ /**
169
+ * Set Delivery ID
170
+ *
171
+ * @param string $deliveryId
172
+ *
173
+ * @return Bronto_Reviews_Model_Observer
174
+ */
175
+ public function setDeliveryId($deliveryId)
176
+ {
177
+ $this->_deliveryId = $deliveryId;
178
+
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * Get Delivery ID
184
+ *
185
+ * @return string
186
+ */
187
+ public function getDeliveryId()
188
+ {
189
+ return $this->_deliveryId;
190
+ }
191
+
192
+ /**
193
+ * Observe saving of Order and determine if a Review Request should be sent
194
+ * and then send
195
+ *
196
+ * @param Varien_Event_Observer $observer
197
+ *
198
+ * @return Varien_Event_Observer
199
+ */
200
+ public function markOrderForReview(Varien_Event_Observer $observer)
201
+ {
202
+ if (!$this->_helper->isEnabled('store', Mage::app()->getStore()->getId())) {
203
+ return $observer;
204
+ }
205
+
206
+ $this->setOrder($observer->getOrder())->process();
207
+
208
+ return $observer;
209
+ }
210
+
211
+ /**
212
+ * Process Order for Review Request
213
+ */
214
+ public function process()
215
+ {
216
+ /* @var $order Mage_Sales_Model_Order */
217
+ $order = $this->getOrder();
218
+
219
+ // Get Statuses
220
+ $reviewStatus = $this->_helper->getReviewSendStatus('store', $order->getStoreId());
221
+ $cancelStatus = $this->_helper->getReviewCancelStatus('store', $order->getStoreId());
222
+
223
+ // If Original Increment ID is Null, proceed
224
+ if (is_null($order->getOriginalIncrementId())) {
225
+ // If current order status matches review send status, proceed
226
+ if ($order->getStatus() == $reviewStatus) {
227
+ $reviewQueue = Mage::getModel('bronto_reviews/queue')
228
+ ->load($order->getId());
229
+
230
+ // If Queue Doesn't have Delivery ID, proceed
231
+ if (is_null($reviewQueue->getDeliveryId())) {
232
+ $this->_makeDelivery();
233
+
234
+ // If Delivery Row sent correctly, save the ID
235
+ if ($this->getDeliveryId()) {
236
+ $reviewQueue->setDeliveryId($this->getDeliveryId())->save();
237
+ }
238
+ }
239
+ } elseif (in_array($order->getStatus(), $cancelStatus)) {
240
+ $reviewQueue = Mage::getModel('bronto_reviews/queue')
241
+ ->load($order->getId());
242
+
243
+ // If Queue has Delivery ID, cancel Delivery
244
+ if (!is_null($reviewQueue->getDeliveryId())) {
245
+ $this->_cancelDelivery($reviewQueue->getDeliveryId());
246
+ }
247
+ }
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Deletes the Delivery that was previously created
253
+ *
254
+ * @param $deliveryId
255
+ */
256
+ protected function _cancelDelivery($deliveryId)
257
+ {
258
+ try {
259
+ $result = $this->getDeliveryObject()->delete(array('id' => $deliveryId));
260
+ if ($result->hasErrors()) {
261
+ $error = implode('<br />', $result->getErrors());
262
+
263
+ Mage::throwException($error);
264
+ }
265
+ } catch (Exception $e) {
266
+ $this->_helper->writeError('Failed Cancelling Delivery: ' . $e->getMessage());
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Create Delivery With Order Details
272
+ */
273
+ protected function _makeDelivery()
274
+ {
275
+ try {
276
+ // Get Delivery Object
277
+ $this->_helper->writeDebug(' Creating Delivery Row');
278
+
279
+ /** @var $deliveryRow Bronto_Api_Delivery_Row */
280
+ $deliveryRow = $this->getDeliveryRow();
281
+
282
+ // Get Order Object
283
+ /** @var $order Mage_Sales_Model_Order */
284
+ $order = $this->getOrder();
285
+
286
+ // Get Contact Object
287
+ $this->_helper->writeDebug(' Creating Contact Object for email: ' . $order->getCustomerEmail());
288
+ /** @var $contact Bronto_Api_Contact_Row */
289
+ $contact = $this->getContact();
290
+
291
+ // Create Recipient
292
+ $deliveryRecipientObject = array(
293
+ 'type' => 'contact',
294
+ 'id' => $contact->id
295
+ );
296
+
297
+ // Create Send Time
298
+ $sendTime = date('c', strtotime('+' . abs($this->_helper->getReviewSendPeriod('store', $order->getStoreId())) . ' days'));
299
+ $this->_helper->writeDebug(' Delivery being set for ' . $sendTime);
300
+
301
+ // Create Delivery Row
302
+ $deliveryRow->start = $sendTime;
303
+ $deliveryRow->messageId = $this->_helper->getReviewSendMessage('store', $order->getStoreId());
304
+ $deliveryRow->type = 'marketing';
305
+ $deliveryRow->fromEmail = $this->_helper->getReviewSenderEmail('store', $order->getStoreId());
306
+ $deliveryRow->fromName = $this->_helper->getReviewSenderName('store', $order->getStoreId());
307
+ $deliveryRow->replyEmail = $this->_helper->getReviewReplyTo('store', $order->getStoreId());
308
+ $deliveryRow->recipients = array($deliveryRecipientObject);
309
+ $deliveryRow->fields = $this->_buildFields();
310
+
311
+ // Save Delivery
312
+ $this->_helper->writeDebug(' Saving Delivery Row');
313
+ $deliveryRow->save();
314
+
315
+ // Verbose Logging
316
+ $this->_helper->writeVerboseDebug('===== FLUSH =====', 'bronto_reviews_api.log');
317
+ $this->_helper->writeVerboseDebug(var_export($this->getDeliveryObject()->getApi()->getLastRequest(), true), 'bronto_reviews_api.log');
318
+ $this->_helper->writeVerboseDebug(var_export($this->getDeliveryObject()->getApi()->getLastResponse(), true), 'bronto_reviews_api.log');
319
+
320
+ if ($deliveryRow->hasError()) {
321
+ Mage::throwException($deliveryRow->getErrorCode() . ' ' . $deliveryRow->getErrorMessage());
322
+ } else {
323
+ $this->setDeliveryId($deliveryRow->id);
324
+ $this->_helper->writeLog("Review Request sent to {$order->getCustomerEmail()}. Delivery ID: {$deliveryRow->id}");
325
+ }
326
+ } catch (Exception $e) {
327
+ $this->_helper->writeError('Bronto Failed creating apiObject:' . $e->getMessage());
328
+ }
329
+ }
330
+
331
+ /**
332
+ * Get array of fields for delivery
333
+ *
334
+ * @return array
335
+ */
336
+ protected function _buildFields()
337
+ {
338
+ /** @var $order Mage_Sales_Model_Order */
339
+ $order = $this->getOrder();
340
+
341
+ // Build Fields
342
+ $fields = array(
343
+ array('name' => 'orderCustomerName', 'type' => 'html', 'content' => $order->getCustomerName()),
344
+ array('name' => 'orderIncrementId', 'type' => 'html', 'content' => $order->getIncrementId()),
345
+ array('name' => 'orderCreatedAt', 'type' => 'html', 'content' => $order->getCreatedAt()),
346
+ );
347
+
348
+ // Cycle through order items and create fields
349
+ $productInc = 1;
350
+ foreach ($order->getAllItems() as $item) {
351
+ // Get Store ID from Order
352
+ $storeId = $order->getStoreId();
353
+
354
+ /** @var Mage_Catalog_Model_Product $product */
355
+ $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getProductId());
356
+
357
+ // Build Product URL with Suffix Config
358
+ $productUrl = Mage::helper('bronto_order')->getItemUrl($item, $product, $storeId);
359
+ $productUrl .= ltrim($this->_helper->getProductUrlSuffix('store', $storeId), '/');
360
+
361
+ $reviewUrl = $this->_helper->getReviewsUrl($product, $storeId);
362
+ $reviewUrl .= ltrim($this->_helper->getProductUrlSuffix('store', $storeId), '/');
363
+
364
+ // Add Reviews Url
365
+ $fields[] = array(
366
+ 'name' => 'reviewUrl_' . $productInc,
367
+ 'type' => 'html',
368
+ 'content' => $reviewUrl
369
+ );
370
+
371
+ // Add Product Name Field
372
+ $fields[] = array(
373
+ 'name' => 'productName_' . $productInc,
374
+ 'type' => 'html',
375
+ 'content' => $item->getName()
376
+ );
377
+
378
+ // Add Product Image Field
379
+ $fields[] = array(
380
+ 'name' => 'productImgUrl_' . $productInc,
381
+ 'type' => 'html',
382
+ 'content' => Mage::helper('bronto_order')->getItemImg($item, $product, $storeId)
383
+ );
384
+
385
+ // Add Product URL Field
386
+ $fields[] = array(
387
+ 'name' => 'productUrl_' . $productInc,
388
+ 'type' => 'html',
389
+ 'content' => $productUrl
390
+ );
391
+
392
+ // Increment Count
393
+ $productInc++;
394
+ }
395
+
396
+ return $fields;
397
+ }
398
+ }
app/code/community/Bronto/Reviews/Model/Queue.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ * @version 0.0.1
7
+ */
8
+ class Bronto_Reviews_Model_Queue extends Mage_Core_Model_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('bronto_reviews/queue');
14
+ }
15
+
16
+ public function load($id = false, $column = false)
17
+ {
18
+ parent::load($id, 'order_id');
19
+
20
+ if (!$this->getId()) {
21
+ $this->setId($id);
22
+ }
23
+
24
+ return $this;
25
+ }
26
+ }
app/code/community/Bronto/Reviews/Model/System/Config/Source/Message.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reviews_Model_System_Config_Source_Message
8
+ {
9
+ /**
10
+ * @return array
11
+ */
12
+ public function toOptionArray()
13
+ {
14
+ return Mage::helper('bronto_reviews/message')->getMessagesOptionsArray();
15
+ }
16
+ }
app/code/community/Bronto/Reviews/Model/System/Config/Source/Orderstatus.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Reviews
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Reviews_Model_System_Config_Source_Orderstatus
8
+ {
9
+ /**
10
+ * @return array
11
+ */
12
+ public function toOptionArray()
13
+ {
14
+ $status = Mage::getModel('sales/order_status')->getCollection();
15
+ $statArray = array();
16
+ foreach ($status as $stat) {
17
+ $statArray[] = array(
18
+ 'value' => $stat->getStatus(),
19
+ 'label' => $stat->getLabel()
20
+ );
21
+ }
22
+ return $statArray;
23
+
24
+ // These are Order States not Status'
25
+ // return array(
26
+ // array('value' => 'new', 'label' => Mage::helper('adminhtml')->__('New Order')),
27
+ // array('value' => 'pending_payment', 'label' => Mage::helper('adminhtml')->__('Pending Payment')),
28
+ // array('value' => 'processing', 'label' => Mage::helper('adminhtml')->__('Processing')),
29
+ // array('value' => 'complete', 'label' => Mage::helper('adminhtml')->__('Complete')),
30
+ // array('value' => 'closed', 'label' => Mage::helper('adminhtml')->__('Closed')),
31
+ // array('value' => 'canceled', 'label' => Mage::helper('adminhtml')->__('Cancelled')),
32
+ // array('value' => 'holded', 'label' => Mage::helper('adminhtml')->__('On Hold')),
33
+ // array('value' => 'payment_review', 'label' => Mage::helper('adminhtml')->__('Payment Review')),
34
+ // );
35
+ }
36
+
37
+ /**
38
+ * Get options in "key-value" format
39
+ *
40
+ * @return array
41
+ */
42
+ public function toArray()
43
+ {
44
+ $status = Mage::getModel('sales/order_status')->getCollection();
45
+ $statArray = array();
46
+ foreach ($status as $stat) {
47
+ $statArray[] = array(
48
+ $stat->getStatus() => $stat->getLabel()
49
+ );
50
+ }
51
+ return $statArray;
52
+ }
53
+ }
app/code/community/Bronto/Reviews/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
+ <bronto_reviews module="bronto_reviews">
12
+ <title>Bronto Review Request Section</title>
13
+ <sort_order>9999</sort_order>
14
+ </bronto_reviews>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Bronto/Reviews/etc/config.xml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bronto_Reviews>
5
+ <version>0.0.1</version>
6
+ </Bronto_Reviews>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <bronto_reviews>
11
+ <class>Bronto_Reviews_Helper</class>
12
+ </bronto_reviews>
13
+ </helpers>
14
+ <blocks>
15
+ <bronto_reviews>
16
+ <class>Bronto_Reviews_Block</class>
17
+ </bronto_reviews>
18
+ </blocks>
19
+ <models>
20
+ <bronto_reviews>
21
+ <class>Bronto_Reviews_Model</class>
22
+ <resourceModel>bronto_reviews_mysql4</resourceModel>
23
+ </bronto_reviews>
24
+ <bronto_reviews_mysql4>
25
+ <class>Bronto_Reviews_Model_Mysql4</class>
26
+ <entities>
27
+ <queue>
28
+ <table>bronto_reviews_queue</table>
29
+ </queue>
30
+ </entities>
31
+ </bronto_reviews_mysql4>
32
+ </models>
33
+ <resources>
34
+ <bronto_reviews_setup>
35
+ <setup>
36
+ <module>Bronto_Reviews</module>
37
+ </setup>
38
+ <connection>
39
+ <use>core_setup</use>
40
+ </connection>
41
+ </bronto_reviews_setup>
42
+ <bronto_reviews_write>
43
+ <connection>
44
+ <use>core_write</use>
45
+ </connection>
46
+ </bronto_reviews_write>
47
+ <bronto_reviews_read>
48
+ <connection>
49
+ <use>core_read</use>
50
+ </connection>
51
+ </bronto_reviews_read>
52
+ </resources>
53
+ <events>
54
+ <sales_order_save_after>
55
+ <observers>
56
+ <bronto_reviews_sales_order_save_after>
57
+ <type>singleton</type>
58
+ <class>bronto_reviews/observer</class>
59
+ <method>markOrderForReview</method>
60
+ </bronto_reviews_sales_order_save_after>
61
+ </observers>
62
+ </sales_order_save_after>
63
+ </events>
64
+ </global>
65
+ <default>
66
+ <bronto_reviews>
67
+ <settings>
68
+ <enabled>0</enabled>
69
+ <status>complete</status>
70
+ <cancel_status>closed</cancel_status>
71
+ <url_suffix>#review-form</url_suffix>
72
+ <period>14</period>
73
+ <message></message>
74
+ <sender_email></sender_email>
75
+ <sender_name></sender_name>
76
+ <reply_to></reply_to>
77
+ </settings>
78
+ </bronto_reviews>
79
+ </default>
80
+
81
+ <phpunit>
82
+ <suite>
83
+ <modules>
84
+ <Bronto_Reviews/>
85
+ </modules>
86
+ </suite>
87
+ </phpunit>
88
+ </config>
app/code/community/Bronto/Reviews/etc/system.xml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <bronto_reviews module="bronto_reviews">
5
+ <label>Review Requests</label>
6
+ <tab>bronto</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>895</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <about>
14
+ <frontend_type>text</frontend_type>
15
+ <frontend_model>bronto_reviews/adminhtml_system_config_about</frontend_model>
16
+ <sort_order>0</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ </about>
21
+ <settings>
22
+ <label>Settings</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <expanded>1</expanded>
29
+ <fields>
30
+ <enabled>
31
+ <label>Enable Module</label>
32
+ <frontend_type>select</frontend_type>
33
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
34
+ <backend_model>bronto_common/system_config_backend_enable</backend_model>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>0</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </enabled>
41
+ <status>
42
+ <label>Order Status</label>
43
+ <depends><enabled>1</enabled></depends>
44
+ <frontend_type>select</frontend_type>
45
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
46
+ <source_model>bronto_reviews/system_config_source_orderstatus</source_model>
47
+ <comment>The order status which will trigger a scheduled
48
+ delivery for the Review Request.</comment>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <validate>validate-select</validate>
54
+ </status>
55
+ <cancel_status>
56
+ <label>Cancel Delivery Status</label>
57
+ <depends><enabled>1</enabled></depends>
58
+ <frontend_type>multiselect</frontend_type>
59
+ <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
60
+ <source_model>bronto_reviews/system_config_source_orderstatus</source_model>
61
+ <comment>Select the order status(es) that will cause the email delivery to be cancelled.</comment>
62
+ <sort_order>15</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </cancel_status>
67
+ <period>
68
+ <label>Send Period</label>
69
+ <depends><enabled>1</enabled></depends>
70
+ <frontend_type>text</frontend_type>
71
+ <comment>Schedule the email this many days after the order status trigger. Must be between 0 and 365.</comment>
72
+ <sort_order>20</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ <validate>required-entry validate-number-range number-range-0-365</validate>
77
+ </period>
78
+ <message>
79
+ <label>Review Request Message</label>
80
+ <depends><enabled>1</enabled></depends>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>bronto_reviews/system_config_source_message</source_model>
83
+ <comment>The Bronto Message to use for Review Requests.</comment>
84
+ <sort_order>30</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
+ <validate>validate-select required-entry</validate>
89
+ </message>
90
+ <url_suffix>
91
+ <label>URL Suffix</label>
92
+ <depends><enabled>1</enabled></depends>
93
+ <frontend_type>text</frontend_type>
94
+ <comment><![CDATA[This suffix will be added to both the Product URL and the Review URL.<br />Default: &quot;<code>#review-form</code>&quot;]]></comment>
95
+ <sort_order>31</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </url_suffix>
100
+ <sender_name>
101
+ <label>Sender Name</label>
102
+ <depends><enabled>1</enabled></depends>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>40</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <validate>required-entry</validate>
109
+ </sender_name>
110
+ <sender_email>
111
+ <label>Sender Email</label>
112
+ <depends><enabled>1</enabled></depends>
113
+ <frontend_type>text</frontend_type>
114
+ <sort_order>50</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ <validate>required-entry validate-email</validate>
119
+ </sender_email>
120
+ <reply_to>
121
+ <label>Sender Reply-To</label>
122
+ <depends><enabled>1</enabled></depends>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>60</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ <validate>required-entry validate-email</validate>
129
+ </reply_to>
130
+ </fields>
131
+ </settings>
132
+ </groups>
133
+ </bronto_reviews>
134
+ </sections>
135
+ </config>
app/code/community/Bronto/Reviews/sql/bronto_reviews_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Sales_Model_Mysql4_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+
9
+ try {
10
+ $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_reviews/queue')}`;");
11
+
12
+ $installer->run("
13
+ CREATE TABLE `{$installer->getTable('bronto_reviews/queue')}` (
14
+ `order_id` int(10) unsigned NOT NULL COMMENT 'Magento Order ID',
15
+ `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Message ID',
16
+ PRIMARY KEY (`order_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Review Request Deliveries'
18
+ ");
19
+
20
+ } catch (Exception $e) {
21
+ Mage::helper('bronto_reviews')->writeError($e->getMessage());
22
+ }
23
+
24
+ $installer->endSetup();
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/About.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_System_Config_About
14
  extends Bronto_Common_Block_Adminhtml_System_Config_About
@@ -16,6 +15,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_About
16
 
17
  /**
18
  * Description for protected
 
19
  * @var string
20
  * @access protected
21
  */
@@ -23,6 +23,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_About
23
 
24
  /**
25
  * Description for protected
 
26
  * @var string
27
  * @access protected
28
  */
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_System_Config_About
13
  extends Bronto_Common_Block_Adminhtml_System_Config_About
15
 
16
  /**
17
  * Description for protected
18
+ *
19
  * @var string
20
  * @access protected
21
  */
23
 
24
  /**
25
  * Description for protected
26
+ *
27
  * @var string
28
  * @access protected
29
  */
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Advanced/Observersearch.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Permission Table Generator
5
+ *
6
+ * @category Bronto
7
+ * @package Bronto_Verify
8
+ * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
+ * @copyright 2013 Adam Daniels
10
+ * @license http://www.atlanticbt.com/ Atlantic BT
11
+ */
12
+ class Bronto_Verify_Block_Adminhtml_System_Config_Advanced_Observersearch
13
+ extends Mage_Adminhtml_Block_Template
14
+ {
15
+ /**
16
+ * Parity bit
17
+ *
18
+ * @var integer
19
+ * @access protected
20
+ */
21
+ protected $_i = 0;
22
+
23
+ /**
24
+ * psuedo constructor
25
+ *
26
+ * @return void
27
+ * @access public
28
+ */
29
+ public function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->setTemplate('bronto/verify/advanced/observer.phtml');
33
+ }
34
+
35
+ /**
36
+ * Get if even or odd
37
+ *
38
+ * @return string
39
+ * @access public
40
+ */
41
+ public function getParity()
42
+ {
43
+ return $this->_i++ % 2 ? 'even' : '';
44
+ }
45
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Conflictchecker.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_System_Config_Conflictchecker
14
  extends Mage_Adminhtml_Block_Abstract
@@ -16,6 +15,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Conflictchecker
16
  {
17
  /**
18
  * rewritten xml nodes
 
19
  * @var array
20
  * @access protected
21
  */
@@ -38,17 +38,18 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Conflictchecker
38
 
39
  // Chain of Responsibility
40
  // each checker looks through its designated area for rewrites
41
- $blocks = Mage::getModel('bronto_verify/config_blocks');
42
- $models = Mage::getModel('bronto_verify/config_models', array($blocks));
43
- $helpers = Mage::getModel('bronto_verify/config_helpers', array($models));
44
  $resources = Mage::getModel('bronto_verify/config_resources', array($helpers));
45
- $checker = Mage::getModel('bronto_verify/config_checker', array($resources));
46
 
47
- $conflicts = $checker->getConflicts($config->getNode('frontend'));
48
 
49
  $globalDataStore->getRewriteConflicts();
50
 
51
- $printer = new Bronto_ConflictChecker_Model_Config_Printer();
 
52
  return $printer->render($globalDataStore, 'XML configurations rewritten more than once');
53
  }
54
  }
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_System_Config_Conflictchecker
13
  extends Mage_Adminhtml_Block_Abstract
15
  {
16
  /**
17
  * rewritten xml nodes
18
+ *
19
  * @var array
20
  * @access protected
21
  */
38
 
39
  // Chain of Responsibility
40
  // each checker looks through its designated area for rewrites
41
+ $blocks = Mage::getModel('bronto_verify/config_blocks');
42
+ $models = Mage::getModel('bronto_verify/config_models', array($blocks));
43
+ $helpers = Mage::getModel('bronto_verify/config_helpers', array($models));
44
  $resources = Mage::getModel('bronto_verify/config_resources', array($helpers));
45
+ $checker = Mage::getModel('bronto_verify/config_checker', array($resources));
46
 
47
+ $checker->getConflicts($config->getNode('frontend'));
48
 
49
  $globalDataStore->getRewriteConflicts();
50
 
51
+ $printer = new Bronto_Verify_Model_Config_Printer();
52
+
53
  return $printer->render($globalDataStore, 'XML configurations rewritten more than once');
54
  }
55
  }
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Apitoken.php CHANGED
@@ -8,14 +8,15 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
- class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Mage_Adminhtml_Block_System_Config_Form_Field
 
14
  {
15
  /**
16
  * Get element ID of the dependent field's parent row
17
  *
18
  * @param object $element
 
19
  * @return String
20
  */
21
  protected function _getRowElementId($element)
@@ -27,6 +28,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
27
  * Override method to output our custom HTML with JavaScript
28
  *
29
  * @param Varien_Data_Form_Element_Abstract $element
 
30
  * @return String
31
  */
32
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
@@ -34,14 +36,18 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
34
  $_html = array();
35
 
36
  // Create form object to grab scope details
37
- $form = new Mage_Adminhtml_Block_System_Config_Form;
38
- $scope = $form->getScope();
39
  $scopeId = $form->getScopeId();
40
- $token = Mage::helper('bronto_verify/apitoken')->getApiToken();
41
 
42
  $script = "
43
  <span id=\"loadingmask\" style=\"display: none; width: 100px;\">
44
- <span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Validating...') . "</span>
 
 
 
 
45
  <span id=\"loading-mask\"></span>
46
  </span>
47
  <script>
@@ -62,15 +68,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
62
  parameters: {token: token, scope: '{$scope}', scopeid: '{$scopeId}'},
63
  onComplete: function(transport) {
64
  Element.hide('loadingmask');
65
- if (transport.responseText == '\"Passed Verification\"') {
66
- statusText.innerHTML = 'Passed Verification';
67
- statusText.addClassName('valid');
68
- } else if (transport.responseText == '\"Failed Verification\"') {
69
- statusText.innerHTML = 'Failed Verification';
70
- statusText.addClassName('invalid');
71
- } else {
72
- statusText.innerHTML = 'No Token Provided';
73
- }
74
  }
75
  });
76
 
@@ -79,30 +77,28 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
79
  </script>
80
  ";
81
 
82
- if (!$this->helper('bronto_common')->getApiToken()) {
83
- $statusText = '<span style="color:grey;font-weight:bold">No Token Provided</span>';
84
- } else {
85
- $statusText = '<span style="color:grey;font-weight:bold">' .
86
- $this->helper('bronto_verify/apitoken')->getAdminScopedApitokenStatusText() .
87
- '</span>';
88
- $button = $this->getLayout()
89
- ->createBlock('bronto_verify/adminhtml_widget_button_runtoken')
90
- ->toHtml();
91
- $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
92
- }
93
 
94
- // Show Roundtrip Install Verification Status
95
- $_html[] = '<style>' .
96
- '#bronto-validation-status { color:grey; font-weight:bold; }' .
97
- '#bronto-validation-status.valid { color: green; }' .
98
- '#bronto-validation-status.invalid { color: red; }' .
99
- '</style>' . $statusText . $buttonHtml;
 
 
 
 
100
 
101
  $_html[] = $script;
102
 
103
  // Show everything Else
104
  if (!empty($_html)) {
105
  $elementHtml = implode('<br />', $_html);
 
106
  return $elementHtml;
107
  }
108
 
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
+ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Apitoken
13
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
14
  {
15
  /**
16
  * Get element ID of the dependent field's parent row
17
  *
18
  * @param object $element
19
+ *
20
  * @return String
21
  */
22
  protected function _getRowElementId($element)
28
  * Override method to output our custom HTML with JavaScript
29
  *
30
  * @param Varien_Data_Form_Element_Abstract $element
31
+ *
32
  * @return String
33
  */
34
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
36
  $_html = array();
37
 
38
  // Create form object to grab scope details
39
+ $form = new Mage_Adminhtml_Block_System_Config_Form;
40
+ $scope = $form->getScope();
41
  $scopeId = $form->getScopeId();
42
+ $token = Mage::helper('bronto_verify/apitoken')->getApiToken();
43
 
44
  $script = "
45
  <span id=\"loadingmask\" style=\"display: none; width: 100px;\">
46
+ <span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" .
47
+ $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') .
48
+ ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" .
49
+ $this->__(' Validating...') .
50
+ "</span>
51
  <span id=\"loading-mask\"></span>
52
  </span>
53
  <script>
68
  parameters: {token: token, scope: '{$scope}', scopeid: '{$scopeId}'},
69
  onComplete: function(transport) {
70
  Element.hide('loadingmask');
71
+ statusText.innerHTML = transport.responseText;
 
 
 
 
 
 
 
 
72
  }
73
  });
74
 
77
  </script>
78
  ";
79
 
80
+ $button = $this->getLayout()
81
+ ->createBlock('bronto_verify/adminhtml_widget_button_runtoken')
82
+ ->toHtml();
83
+ $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
 
 
 
 
 
 
 
84
 
85
+ // Show API Token Verification Status
86
+ $_html[] = $buttonHtml .
87
+ '<style>' .
88
+ ' #bronto-validation-status { color:grey; font-weight:bold; }' .
89
+ ' #bronto-validation-status .valid { color: green; }' .
90
+ ' #bronto-validation-status .invalid { color: red; }' .
91
+ '</style>' .
92
+ '<span id="bronto-validation-status">' .
93
+ $this->helper('bronto_verify/apitoken')->setApiToken($token)->getAdminScopedApitokenStatusText() .
94
+ '</span>';
95
 
96
  $_html[] = $script;
97
 
98
  // Show everything Else
99
  if (!empty($_html)) {
100
  $elementHtml = implode('<br />', $_html);
101
+
102
  return $elementHtml;
103
  }
104
 
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Button.php CHANGED
@@ -23,6 +23,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Button
23
  public function render(Varien_Data_Form_Element_Abstract $element)
24
  {
25
  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
 
26
  return parent::render($element);
27
  }
28
 
@@ -31,8 +32,8 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Button
31
  $originalData = $element->getOriginalData();
32
  $this->addData(array(
33
  'button_label' => Mage::helper('bronto_verify')->__($originalData['button_label']),
34
- 'html_id' => $element->getHtmlId(),
35
- 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/permissionchecker/verify')
36
  ));
37
 
38
  return $this->_toHtml();
23
  public function render(Varien_Data_Form_Element_Abstract $element)
24
  {
25
  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
26
+
27
  return parent::render($element);
28
  }
29
 
32
  $originalData = $element->getOriginalData();
33
  $this->addData(array(
34
  'button_label' => Mage::helper('bronto_verify')->__($originalData['button_label']),
35
+ 'html_id' => $element->getHtmlId(),
36
+ 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/permissionchecker/verify')
37
  ));
38
 
39
  return $this->_toHtml();
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Classpath.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Path Search Field
5
+ *
6
+ * @category Bronto
7
+ * @package Bronto_Verify
8
+ * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
+ * @copyright 2013 Adam Daniels
10
+ * @license http://www.atlanticbt.com/ Atlantic BT
11
+ */
12
+ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Classpath extends Mage_Adminhtml_Block_System_Config_Form_Field
13
+ {
14
+
15
+ /**
16
+ * Get element ID of the dependent field's parent row
17
+ *
18
+ * @param object $element
19
+ *
20
+ * @return String
21
+ */
22
+ protected function _getRowElementId($element)
23
+ {
24
+ return 'row_' . $element->getId();
25
+ }
26
+
27
+ /**
28
+ * Override method to output our custom HTML with JavaScript
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $element
31
+ *
32
+ * @return String
33
+ */
34
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
35
+ {
36
+ $_html = array();
37
+
38
+ $element->setData('after_element_html', "
39
+ <span id=\"classpath-loadingmask\" style=\"display: none; width: 100px;\">
40
+ <span class=\"loader\" id=\"classpath-loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Searching For Class Path...') . "</span>
41
+ <span id=\"classpath-loading-mask\"></span>
42
+ </span>
43
+
44
+ <script>
45
+ //<![CDATA[
46
+ Event.observe(window, 'load', function() {
47
+ var newTr = '<tr id=\"bronto_verify_advanced_classpath_results\"><td class=\"classpath_results\" colspan=\"4\"><div id=\"bronto-classpath-results\"></div></td></tr>';
48
+ $('" . $this->_getRowElementId($element) . "').insert({after: newTr});
49
+ });
50
+ function searchClasspath() {
51
+ var reloadUrl = '{$this->getUrl('*/advanced/ajaxclasspath')}';
52
+ var statusText = $('bronto-classpath-results');
53
+
54
+ var searchText = $('bronto_verify_advanced_classpath_search').value;
55
+ var classType = $('classpath-type').value;
56
+
57
+ statusText.innerHTML = $('classpath-loadingmask').innerHTML;
58
+
59
+ new Ajax.Request(reloadUrl, {
60
+ method: 'post',
61
+ parameters: {class: searchText, type: classType},
62
+ onComplete: function(transport) {
63
+ Element.hide('classpath-loadingmask');
64
+ statusText.innerHTML = transport.responseText;
65
+ }
66
+ });
67
+
68
+ return false;
69
+ }
70
+ //]]>
71
+ </script>
72
+ ");
73
+
74
+ // Add Class Type Selector to Input
75
+ $classTypeHtml = '<select id="classpath-type"><option value="model">Model (Default)</option><option value="helper">Helper</option><option value="block">Block</option><option value="controller">Controller</option></select>';
76
+
77
+ // Add Search Button
78
+ $button = $this->getLayout()
79
+ ->createBlock('bronto_verify/adminhtml_widget_button_classpath')
80
+ ->toHtml();
81
+ $buttonHtml = "<p class=\"form-buttons\" id=\"events-button\" style=\"float:none;\">{$button}</p>";
82
+
83
+
84
+ // Add Button to Html
85
+ $_html[] = $buttonHtml;
86
+
87
+ // Show everything Else
88
+ if (!empty($_html)) {
89
+ $elementHtml = $element->getElementHtml();
90
+ $elementHtml .= $classTypeHtml;
91
+ if ($element->getComment()) {
92
+ $elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
93
+ $element->setComment(null);
94
+ }
95
+ $elementHtml .= '<div style="margin-top:10px">';
96
+ $elementHtml .= implode('<br />', $_html);
97
+ $elementHtml .= '</div>';
98
+
99
+ return $elementHtml;
100
+ }
101
+
102
+ return parent::_getElementHtml($element);
103
+ }
104
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Conflict.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Conflict extends Mage_Adminhtml_Block_System_Config_Form_Field
14
  {
@@ -17,6 +16,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Conflict extends Ma
17
  * Get element ID of the dependent field's parent row
18
  *
19
  * @param object $element
 
20
  * @return String
21
  */
22
  protected function _getRowElementId($element)
@@ -28,6 +28,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Conflict extends Ma
28
  * Override method to output our custom HTML with JavaScript
29
  *
30
  * @param Varien_Data_Form_Element_Abstract $element
 
31
  * @return String
32
  */
33
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
@@ -66,7 +67,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Conflict extends Ma
66
  ";
67
 
68
 
69
- $button = $this->getLayout()
70
  ->createBlock('bronto_verify/adminhtml_widget_button_conflict')
71
  ->toHtml();
72
  $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\" style=\"float:none;\">{$button}</p>";
@@ -79,6 +80,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Conflict extends Ma
79
  // Show everything Else
80
  if (!empty($_html)) {
81
  $elementHtml = implode('', $_html);
 
82
  return $elementHtml;
83
  }
84
 
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Conflict extends Mage_Adminhtml_Block_System_Config_Form_Field
13
  {
16
  * Get element ID of the dependent field's parent row
17
  *
18
  * @param object $element
19
+ *
20
  * @return String
21
  */
22
  protected function _getRowElementId($element)
28
  * Override method to output our custom HTML with JavaScript
29
  *
30
  * @param Varien_Data_Form_Element_Abstract $element
31
+ *
32
  * @return String
33
  */
34
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
67
  ";
68
 
69
 
70
+ $button = $this->getLayout()
71
  ->createBlock('bronto_verify/adminhtml_widget_button_conflict')
72
  ->toHtml();
73
  $buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\" style=\"float:none;\">{$button}</p>";
80
  // Show everything Else
81
  if (!empty($_html)) {
82
  $elementHtml = implode('', $_html);
83
+
84
  return $elementHtml;
85
  }
86
 
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Events.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event Search Field
5
+ *
6
+ * @category Bronto
7
+ * @package Bronto_Verify
8
+ * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
+ * @copyright 2013 Adam Daniels
10
+ * @license http://www.atlanticbt.com/ Atlantic BT
11
+ */
12
+ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Events extends Mage_Adminhtml_Block_System_Config_Form_Field
13
+ {
14
+
15
+ /**
16
+ * Get element ID of the dependent field's parent row
17
+ *
18
+ * @param object $element
19
+ *
20
+ * @return String
21
+ */
22
+ protected function _getRowElementId($element)
23
+ {
24
+ return 'row_' . $element->getId();
25
+ }
26
+
27
+ /**
28
+ * Override method to output our custom HTML with JavaScript
29
+ *
30
+ * @param Varien_Data_Form_Element_Abstract $element
31
+ *
32
+ * @return String
33
+ */
34
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
35
+ {
36
+ $_html = array();
37
+
38
+ $element->setData('after_element_html', "
39
+ <span id=\"observer-loadingmask\" style=\"display: none; width: 100px;\">
40
+ <span class=\"loader\" id=\"observer-loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Searching For Observers...') . "</span>
41
+ <span id=\"observer-loading-mask\"></span>
42
+ </span>
43
+
44
+ <script>
45
+ //<![CDATA[
46
+ Event.observe(window, 'load', function() {
47
+ var newTr = '<tr id=\"bronto_verify_advanced_results\"><td class=\"observer_results\" colspan=\"4\"><div id=\"bronto-observer-results\"></div></td></tr>';
48
+ $('" . $this->_getRowElementId($element) . "').insert({after: newTr});
49
+ });
50
+ function searchObservers() {
51
+ var reloadUrl = '{$this->getUrl('*/advanced/ajaxobservers')}';
52
+ var statusText = $('bronto-observer-results');
53
+
54
+ var searchText = $('bronto_verify_advanced_observer_search').value;
55
+
56
+ statusText.innerHTML = $('observer-loadingmask').innerHTML;
57
+
58
+ new Ajax.Request(reloadUrl, {
59
+ method: 'post',
60
+ parameters: {event: searchText},
61
+ onComplete: function(transport) {
62
+ Element.hide('observer-loadingmask');
63
+ statusText.innerHTML = transport.responseText;
64
+ }
65
+ });
66
+
67
+ return false;
68
+ }
69
+ //]]>
70
+ </script>
71
+ ");
72
+
73
+
74
+ $button = $this->getLayout()
75
+ ->createBlock('bronto_verify/adminhtml_widget_button_events')
76
+ ->toHtml();
77
+ $buttonHtml = "<p class=\"form-buttons\" id=\"events-button\" style=\"float:none;\">{$button}</p>";
78
+
79
+
80
+ // Add Button to Html
81
+ $_html[] = $buttonHtml;
82
+
83
+ // Show everything Else
84
+ if (!empty($_html)) {
85
+ $elementHtml = $element->getElementHtml();
86
+ if ($element->getComment()) {
87
+ $elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
88
+ $element->setComment(null);
89
+ }
90
+ $elementHtml .= '<div style="margin-top:10px">';
91
+ $elementHtml .= implode('', $_html);
92
+ $elementHtml .= '</div>';
93
+
94
+ return $elementHtml;
95
+ }
96
+
97
+ return parent::_getElementHtml($element);
98
+ }
99
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Field/Roundtrip.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends Mage_Adminhtml_Block_System_Config_Form_Field
14
  {
@@ -16,6 +15,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends M
16
  * Get element ID of the dependent field's parent row
17
  *
18
  * @param object $element
 
19
  * @return String
20
  */
21
  protected function _getRowElementId($element)
@@ -27,6 +27,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends M
27
  * Override method to output our custom HTML with JavaScript
28
  *
29
  * @param Varien_Data_Form_Element_Abstract $element
 
30
  * @return String
31
  */
32
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
@@ -34,8 +35,8 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends M
34
  $_html = array();
35
 
36
  // Create form object to grab scope details
37
- $form = new Mage_Adminhtml_Block_System_Config_Form;
38
- $scope = $form->getScope();
39
  $scopeId = $form->getScopeId();
40
 
41
  $script = "
@@ -78,7 +79,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends M
78
  $statusText = '<span style="color:grey;font-weight:bold">' .
79
  $this->helper('bronto_verify/roundtrip')->getAdminScopedRoundtripStatusText() .
80
  '</span>';
81
- $button = $this->getLayout()
82
  ->createBlock('bronto_verify/adminhtml_widget_button_runroundtrip')
83
  ->toHtml();
84
  $buttonHtml = "<p class=\"form-buttons\" id=\"roundtrip-verify-button\">{$button}</p>";
@@ -95,6 +96,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends M
95
  // Show everything Else
96
  if (!empty($_html)) {
97
  $elementHtml = implode('<br />', $_html);
 
98
  return $elementHtml;
99
  }
100
 
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_System_Config_Form_Field_Roundtrip extends Mage_Adminhtml_Block_System_Config_Form_Field
13
  {
15
  * Get element ID of the dependent field's parent row
16
  *
17
  * @param object $element
18
+ *
19
  * @return String
20
  */
21
  protected function _getRowElementId($element)
27
  * Override method to output our custom HTML with JavaScript
28
  *
29
  * @param Varien_Data_Form_Element_Abstract $element
30
+ *
31
  * @return String
32
  */
33
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
35
  $_html = array();
36
 
37
  // Create form object to grab scope details
38
+ $form = new Mage_Adminhtml_Block_System_Config_Form;
39
+ $scope = $form->getScope();
40
  $scopeId = $form->getScopeId();
41
 
42
  $script = "
79
  $statusText = '<span style="color:grey;font-weight:bold">' .
80
  $this->helper('bronto_verify/roundtrip')->getAdminScopedRoundtripStatusText() .
81
  '</span>';
82
+ $button = $this->getLayout()
83
  ->createBlock('bronto_verify/adminhtml_widget_button_runroundtrip')
84
  ->toHtml();
85
  $buttonHtml = "<p class=\"form-buttons\" id=\"roundtrip-verify-button\">{$button}</p>";
96
  // Show everything Else
97
  if (!empty($_html)) {
98
  $elementHtml = implode('<br />', $_html);
99
+
100
  return $elementHtml;
101
  }
102
 
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Magecron.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Bronto\Common
5
+ * @copyright 2011-2013 Bronto Software, Inc.
6
+ */
7
+ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Magecron
8
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
9
+ {
10
+ /**
11
+ * Return footer html for fieldset
12
+ * Add extra tooltip comments to elements
13
+ *
14
+ * @param Varien_Data_Form_Element_Abstract $element
15
+ *
16
+ * @return string
17
+ */
18
+ protected function _getFooterHtml($element)
19
+ {
20
+ $html = "<tr><td>&nbsp;</td>
21
+ <td id=\"bronto-magecron-example\" colspan=\"3\"><strong style=\"margin:5px;\">To setup the cron script, you will need to add a command to your crontab file. Here are some examples:</strong>
22
+ <div style=\"border:1px solid #ccc; padding:5px; margin:5px;\">
23
+ <strong>To run the Reminder Cron every 15 minutes:</strong>
24
+ <pre>*/15 * * * * root /usr/bin/php /var/www/magento/shell/bronto/cron.php -a run -t reminder</pre>
25
+ <strong>To run the Order Import Cron once Daily at Midnight:</strong>
26
+ <pre>0 0 * * * root /usr/bin/php /var/www/magento/shell/bronto/cron.php -a run -t order</pre>
27
+ <strong>To run the Customer Import Cron twice Daily:</strong>
28
+ <pre>0 */2 * * * root /usr/bin/php /var/www/magento/shell/bronto/cron.php -a run -t customer</pre>
29
+ <strong>To run the Newsletter Opt-In Cron every 30 minutes:</strong>
30
+ <pre>*/30 * * * * root /usr/bin/php /var/www/magento/shell/bronto/cron.php -a run -t newsletter</pre>
31
+ <strong>To run all Module Crons once Daily:</strong>
32
+ <pre>0 0 * * * root /usr/bin/php /var/www/magento/shell/bronto/cron.php -a run</pre>
33
+ </div>
34
+ <em style=\"margin:5px;\">* Note: You will need to change the owner, php path, and path to magento to match your environment.</em>
35
+ </td></tr>";
36
+
37
+ return $html . parent::_getFooterHtml($element);
38
+ }
39
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Form/Permission.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
6
- * @version 1.6.7
7
  */
8
  class Bronto_Verify_Block_Adminhtml_System_Config_Form_Permission
9
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
@@ -13,14 +12,15 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Permission
13
  * Add extra tooltip comments to elements
14
  *
15
  * @param Varien_Data_Form_Element_Abstract $element
 
16
  * @return string
17
  */
18
  protected function _getFooterHtml($element)
19
  {
20
  $owner = Mage::getStoreConfig('bronto_verify/permissionchecker/owner');
21
  $group = Mage::getStoreConfig('bronto_verify/permissionchecker/group');
22
- $dir = Mage::getStoreConfig('bronto_verify/permissionchecker/directories');
23
- $file = Mage::getStoreConfig('bronto_verify/permissionchecker/files');
24
 
25
  if ('' != $owner || '' != $group) {
26
  $chown = 'sudo chown -R ' . (('' != $owner) ? $owner : '') . (('' != $group) ? ':' . $group : '') . ' ./*';
@@ -29,11 +29,11 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Form_Permission
29
  }
30
 
31
  $vMage = 'mage';
32
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('<',5)))) {
33
  $vMage = 'pear';
34
  }
35
 
36
- $dPerm = ('' == $dir) ? '755' : $dir;
37
  $fPerm = ('' == $file) ? '644' : $file;
38
 
39
  $html = "<tr><td>&nbsp;</td>
3
  /**
4
  * @package Bronto\Common
5
  * @copyright 2011-2013 Bronto Software, Inc.
 
6
  */
7
  class Bronto_Verify_Block_Adminhtml_System_Config_Form_Permission
8
  extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
12
  * Add extra tooltip comments to elements
13
  *
14
  * @param Varien_Data_Form_Element_Abstract $element
15
+ *
16
  * @return string
17
  */
18
  protected function _getFooterHtml($element)
19
  {
20
  $owner = Mage::getStoreConfig('bronto_verify/permissionchecker/owner');
21
  $group = Mage::getStoreConfig('bronto_verify/permissionchecker/group');
22
+ $dir = Mage::getStoreConfig('bronto_verify/permissionchecker/directories');
23
+ $file = Mage::getStoreConfig('bronto_verify/permissionchecker/files');
24
 
25
  if ('' != $owner || '' != $group) {
26
  $chown = 'sudo chown -R ' . (('' != $owner) ? $owner : '') . (('' != $group) ? ':' . $group : '') . ' ./*';
29
  }
30
 
31
  $vMage = 'mage';
32
+ if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('<', 5)))) {
33
  $vMage = 'pear';
34
  }
35
 
36
+ $dPerm = ('' == $dir) ? '755' : $dir;
37
  $fPerm = ('' == $file) ? '644' : $file;
38
 
39
  $html = "<tr><td>&nbsp;</td>
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Installs.php ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * About Bronto block
5
+ *
6
+ * @category Bronto
7
+ * @package Bronto_Verify
8
+ * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
+ * @copyright 2013 Adam Daniels
10
+ * @license http://www.atlanticbt.com/ Atlantic BT
11
+ *
12
+ */
13
+ class Bronto_Verify_Block_Adminhtml_System_Config_Installs
14
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
15
+ {
16
+ /**
17
+ * Description for protected
18
+ *
19
+ * @var string
20
+ * @access protected
21
+ */
22
+ protected $_module = 'bronto_verify';
23
+ protected $_helper;
24
+
25
+ /**
26
+ * Array of displayable modules
27
+ *
28
+ * @var array
29
+ */
30
+ protected $_modules = array(
31
+ 'bronto_common',
32
+ 'bronto_newsletter',
33
+ 'bronto_customer',
34
+ 'bronto_order',
35
+ 'bronto_reminder',
36
+ 'bronto_email',
37
+ );
38
+
39
+ public function _construct()
40
+ {
41
+ parent::_construct();
42
+ $this->setTemplate('bronto/verify/installs.phtml');
43
+
44
+ $this->_helper = Mage::helper('bronto_verify');
45
+ }
46
+
47
+ /**
48
+ * @param Varien_Data_Form_Element_Abstract $element
49
+ *
50
+ * @return string
51
+ */
52
+ public function render(Varien_Data_Form_Element_Abstract $element)
53
+ {
54
+ $html = $this->_getHeaderHtml($element);
55
+ $html .= $this->toHtml();
56
+ $html .= $this->_getFooterHtml($element);
57
+
58
+ return $html;
59
+ }
60
+
61
+ /**
62
+ * Get Style for Scope
63
+ *
64
+ * @param $scope
65
+ *
66
+ * @return mixed
67
+ */
68
+ protected function _getScopedStyle($scope)
69
+ {
70
+ $scopeParams = $this->_helper->getScopeParams();
71
+
72
+ $styles = array(
73
+ 'default' => 'inactive',
74
+ 'website' => 'inactive',
75
+ 'group' => 'inactive',
76
+ 'store' => 'inactive',
77
+ );
78
+
79
+ switch ($scopeParams['scope']) {
80
+ case 'store':
81
+ $styles['store'] = 'active';
82
+ break;
83
+ case 'group':
84
+ $styles['group'] = 'active';
85
+ $styles['store'] = 'active';
86
+ break;
87
+ case 'website':
88
+ $styles['website'] = 'active';
89
+ $styles['group'] = 'active';
90
+ $styles['store'] = 'active';
91
+ break;
92
+ case 'default':
93
+ default:
94
+ $styles['default'] = 'active';
95
+ $styles['website'] = 'active';
96
+ $styles['group'] = 'active';
97
+ $styles['store'] = 'active';
98
+ break;
99
+ }
100
+
101
+ return $styles[$scope];
102
+ }
103
+
104
+
105
+ /**
106
+ * Get Multi-Dimensional array of all scopes to be included in current scope
107
+ *
108
+ * @return array
109
+ */
110
+ protected function _getScopeAllowedScopes()
111
+ {
112
+ $scopeParams = $this->_helper->getScopeParams();
113
+
114
+ // Start Allowed array with Default Config
115
+ $allowed = array(
116
+ 'default' => array(
117
+ 'label' => 'Default Config',
118
+ 'websites' => array(),
119
+ ),
120
+ );
121
+
122
+ // Identify Scope and Scope ID
123
+ $scope = $scopeParams['scope'];
124
+ $scopeId = $scopeParams[$scope . '_id'];
125
+
126
+ // Prep the models
127
+ $store_model = Mage::getModel('core/store'); //store model
128
+ $store_group_model = Mage::getModel('core/store_group'); //store group model
129
+ $website_model = Mage::getModel('core/website'); //website model
130
+
131
+ // Start Stepping Through
132
+ switch ($scope) {
133
+ case 'store':
134
+ $store_data = $store_model->load($scopeId);
135
+ $store_group_data = $store_group_model->load($store_data->getGroupId());
136
+ $website_data = $website_model->load($store_data->getWebsiteId());
137
+
138
+ $allowed['default']['websites'][$website_data->getCode()] = array(
139
+ 'id' => $website_data->getId(),
140
+ 'label' => $website_data->getName(),
141
+ 'groups' => array(
142
+ $store_group_data->getName() => array(
143
+ 'id' => $store_group_data->getId(),
144
+ 'label' => $store_group_data->getName(),
145
+ 'stores' => array(
146
+ $store_data->getCode() => array(
147
+ 'id' => $store_data->getId(),
148
+ 'label' => $store_data->getName(),
149
+ ),
150
+ ),
151
+ ),
152
+ ),
153
+ );
154
+
155
+ break;
156
+ case 'group':
157
+ $store_group_data = $store_group_model->load($scopeId);
158
+ $website_data = $website_model->load($store_group_model->getWebsiteId());
159
+
160
+ $stores_data = array();
161
+ foreach ($store_group_data->getStores() as $store) {
162
+ $stores_data[$store->getCode()] = array(
163
+ 'id' => $store->getId(),
164
+ 'label' => $store->getName(),
165
+ );
166
+ }
167
+
168
+ $allowed['default']['websites'][$website_data->getCode()] = array(
169
+ 'id' => $website_data->getId(),
170
+ 'label' => $website_data->getName(),
171
+ 'groups' => array(
172
+ $store_group_data->getName() => array(
173
+ 'id' => $store_group_data->getId(),
174
+ 'label' => $store_group_data->getName(),
175
+ 'stores' => $stores_data,
176
+ ),
177
+ ),
178
+ );
179
+
180
+ break;
181
+ case 'website':
182
+ $website_data = $website_model->load($scopeId);
183
+
184
+ $groups_data = array();
185
+ foreach ($website_data->getGroups() as $group) {
186
+ $stores_data = array();
187
+ foreach ($group->getStores() as $store) {
188
+ $stores_data[$store->getCode()] = array(
189
+ 'id' => $store->getId(),
190
+ 'label' => $store->getName(),
191
+ );
192
+ }
193
+
194
+ $groups_data[$group->getName()] = array(
195
+ 'id' => $group->getId(),
196
+ 'label' => $group->getName(),
197
+ 'stores' => $stores_data,
198
+ );
199
+ }
200
+
201
+ $allowed['default']['websites'][$website_data->getCode()] = array(
202
+ 'id' => $website_data->getId(),
203
+ 'label' => $website_data->getName(),
204
+ 'groups' => $groups_data,
205
+ );
206
+
207
+ break;
208
+ case 'default':
209
+ default:
210
+ $websites_data = array();
211
+ foreach (Mage::app()->getWebsites() as $website) {
212
+ $groups_data = array();
213
+ foreach ($website->getGroups() as $group) {
214
+ $stores_data = array();
215
+ foreach ($group->getStores() as $store) {
216
+ $stores_data[$store->getCode()] = array(
217
+ 'id' => $store->getId(),
218
+ 'label' => $store->getName(),
219
+ );
220
+ }
221
+
222
+ $groups_data[$group->getName()] = array(
223
+ 'id' => $group->getId(),
224
+ 'label' => $group->getName(),
225
+ 'stores' => $stores_data,
226
+ );
227
+ }
228
+
229
+ $websites_data[$website->getCode()] = array(
230
+ 'id' => $website->getId(),
231
+ 'label' => $website->getName(),
232
+ 'groups' => $groups_data,
233
+ );
234
+ }
235
+
236
+ $allowed['default']['websites'] = $websites_data;
237
+
238
+ break;
239
+ }
240
+
241
+ return $allowed;
242
+ }
243
+
244
+ /**
245
+ * Determine if module is enabled for specified scope
246
+ *
247
+ * @param string $module
248
+ * @param string $scope
249
+ * @param int $scopeId
250
+ *
251
+ * @return string
252
+ */
253
+ public function getIsEnabled($module = 'bronto_common', $scope = 'default', $scopeId = 0)
254
+ {
255
+ $helper = Mage::helper($module);
256
+ $reflectionClass = new ReflectionClass(get_class($helper));
257
+ $path = $reflectionClass->getConstant('XML_PATH_ENABLED');
258
+
259
+ return ((bool)$helper->getAdminScopedConfig($path, $scope, $scopeId)) ? 'enabled' : 'disabled';
260
+ }
261
+
262
+ /**
263
+ * Get Ordered List of Modules and their status for the specified scope
264
+ *
265
+ * @param null $store
266
+ * @param null $website
267
+ * @param string $defaultSpacer
268
+ * @param string $websiteSpacer
269
+ * @param string $groupSpacer
270
+ * @param string $storeSpacer
271
+ *
272
+ * @return string
273
+ */
274
+ public function getModulesStatus($store = null, $website = null, $defaultSpacer = '', $websiteSpacer = '', $groupSpacer = '', $storeSpacer = '')
275
+ {
276
+ // Build Scope
277
+ if ($store) {
278
+ $scope = 'store';
279
+ $scopeId = $store;
280
+ } elseif ($website) {
281
+ $scope = 'website';
282
+ $scopeId = $website;
283
+ } else {
284
+ $scope = 'default';
285
+ $scopeId = 0;
286
+ }
287
+
288
+ $html = '<ul class="bronto_verify-installs-modules">';
289
+
290
+ $html .= '<li>';
291
+ $html .= $defaultSpacer;
292
+ $html .= $websiteSpacer;
293
+ $html .= $groupSpacer;
294
+ $html .= $storeSpacer;
295
+ $html .= '<img src="' . $this->getJsUrl('spacer.gif') . '" class="x-tree-ec-icon x-tree-elbow-minus" onclick="toggleModules(this, \'modules-' . $scope . '-' . $scopeId . '\')">';
296
+ $html .= '<span>Modules</span>';
297
+ $html .= '<ol id="modules-' . $scope . '-' . $scopeId . '">';
298
+
299
+ $modules = Mage::helper('bronto_common')->getInstalledModules(true);
300
+ $mTotal = count($modules);
301
+ $mCount = 1;
302
+ foreach ($modules as $module) {
303
+ if (!in_array($module, $this->_modules)) {
304
+ continue;
305
+ }
306
+ $mHelper = Mage::helper($module);
307
+ $section = $module;
308
+ if ($section == 'bronto_common') {
309
+ $section = 'bronto';
310
+ }
311
+ $url = $this->getConfigScopeUrl($section, $scope, $scopeId);
312
+ $treeStyle = ($mCount == $mTotal) ? 'x-tree-elbow-end' : 'x-tree-elbow';
313
+
314
+ $html .= '<li>';
315
+ $html .= $defaultSpacer;
316
+ $html .= $websiteSpacer;
317
+ $html .= $groupSpacer;
318
+ $html .= $storeSpacer;
319
+
320
+ $html .= '<img src="' . $this->getJsUrl('spacer.gif') . '" class="x-tree-ec-icon ' . $treeStyle . '">';
321
+ $status = $this->getIsEnabled($module, $scope, $scopeId);
322
+ // $html .= '<img src="' . $this->getSkinUrl('bronto/images/InstallStatus' . ucfirst($status) . '.png') . '" title="' . ucfirst($status) . '" class="install-status-icon" /> ';
323
+ $html .= '<img src="' . $this->getJsUrl('spacer.gif') . '" class="installed-module-' . $status . '" title="' . ucfirst($status) . '" /> ';
324
+ $html .= '<a href="' . $url . '" class="installed-module-' . $status . '">' . $mHelper->getName() . '</a>';
325
+ $html .= '</li>';
326
+
327
+ $mCount++;
328
+ }
329
+
330
+ $html .= '</ol>';
331
+ $html .= '</li>';
332
+ $html .= '</ul>';
333
+
334
+ return $html;
335
+ }
336
+
337
+ /**
338
+ * Get Scoped URL to specified System Config Section
339
+ *
340
+ * @param $section
341
+ * @param $scope
342
+ * @param $scopeId
343
+ *
344
+ * @return mixed
345
+ */
346
+ public function getConfigScopeUrl($section, $scope, $scopeId)
347
+ {
348
+ return Mage::helper('bronto_common')->getScopeUrl('/system_config/edit/', array('section' => $section, 'scope' => $scope, $scope => $scopeId));
349
+ }
350
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/System/Config/Permissionchecker.php CHANGED
@@ -11,7 +11,6 @@
11
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
12
  * @copyright 2013 Adam Daniels
13
  * @license http://www.atlanticbt.com/ Atlantic BT
14
- * @version 0.1.0
15
  */
16
  class Bronto_Verify_Block_Adminhtml_System_Config_Permissionchecker
17
  extends Mage_Adminhtml_Block_Abstract
@@ -19,25 +18,22 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Permissionchecker
19
  /**
20
  * Render all files that don't validate to the proper permissions
21
  *
22
- * @param Varien_Data_Form_Element_Abstract $element Form element
23
- *
24
  * @return string
25
- * @access public
26
  */
27
  protected function _toHtml()
28
  {
29
  // Chain of Responsibility
30
  // each checker looks through its designated area to validate the node we're at.
31
- $file = Mage::getModel('bronto_verify/validator_file');
32
- $dir = Mage::getModel('bronto_verify/validator_directory', array($file));
33
  $group = Mage::getModel('bronto_verify/validator_group', array($dir));
34
  $owner = Mage::getModel('bronto_verify/validator_owner', array($group));
35
 
36
  $checker = Mage::getModel('bronto_verify/validator_checker', array($owner));
37
 
38
- $directory = new RecursiveDirectoryIterator(Mage::getBaseDir());
39
- $filter = new Bronto_Verify_Model_Validator_Filter_PatternIterator($directory);
40
- $iterator = new RecursiveIteratorIterator(
41
  $filter,
42
  RecursiveIteratorIterator::SELF_FIRST,
43
  RecursiveIteratorIterator::CATCH_GET_CHILD
@@ -45,6 +41,7 @@ class Bronto_Verify_Block_Adminhtml_System_Config_Permissionchecker
45
  $invalidFiles = $checker->validateSettings($iterator);
46
 
47
  $printer = new Bronto_Verify_Model_Validator_Printer();
 
48
  return $printer->render($invalidFiles);
49
  }
50
  }
11
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
12
  * @copyright 2013 Adam Daniels
13
  * @license http://www.atlanticbt.com/ Atlantic BT
 
14
  */
15
  class Bronto_Verify_Block_Adminhtml_System_Config_Permissionchecker
16
  extends Mage_Adminhtml_Block_Abstract
18
  /**
19
  * Render all files that don't validate to the proper permissions
20
  *
 
 
21
  * @return string
 
22
  */
23
  protected function _toHtml()
24
  {
25
  // Chain of Responsibility
26
  // each checker looks through its designated area to validate the node we're at.
27
+ $file = Mage::getModel('bronto_verify/validator_file');
28
+ $dir = Mage::getModel('bronto_verify/validator_directory', array($file));
29
  $group = Mage::getModel('bronto_verify/validator_group', array($dir));
30
  $owner = Mage::getModel('bronto_verify/validator_owner', array($group));
31
 
32
  $checker = Mage::getModel('bronto_verify/validator_checker', array($owner));
33
 
34
+ $directory = new RecursiveDirectoryIterator(Mage::getBaseDir());
35
+ $filter = new Bronto_Verify_Model_Validator_Filter_PatternIterator($directory);
36
+ $iterator = new RecursiveIteratorIterator(
37
  $filter,
38
  RecursiveIteratorIterator::SELF_FIRST,
39
  RecursiveIteratorIterator::CATCH_GET_CHILD
41
  $invalidFiles = $checker->validateSettings($iterator);
42
 
43
  $printer = new Bronto_Verify_Model_Validator_Printer();
44
+
45
  return $printer->render($invalidFiles);
46
  }
47
  }
app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Classpath.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Path Search Button
5
+ *
6
+ * @category Bronto
7
+ * @package Bronto_Verify
8
+ * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
+ * @copyright 2013 Adam Daniels
10
+ * @license http://www.atlanticbt.com/ Atlantic BT
11
+ */
12
+ class Bronto_Verify_Block_Adminhtml_Widget_Button_Classpath extends Mage_Adminhtml_Block_Widget_Button
13
+ {
14
+ /**
15
+ * Internal constructor not depended on params. Can be used for object initialization
16
+ */
17
+ protected function _construct()
18
+ {
19
+ $this->setLabel('Search Class Path');
20
+ $this->setOnClick("searchClasspath(); return false;");
21
+ }
22
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Conflict.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Conflict extends Mage_Adminhtml_Block_Widget_Button
14
  {
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Conflict extends Mage_Adminhtml_Block_Widget_Button
13
  {
app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Events.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event Observer Search Button
5
+ *
6
+ * @category Bronto
7
+ * @package Bronto_Verify
8
+ * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
+ * @copyright 2013 Adam Daniels
10
+ * @license http://www.atlanticbt.com/ Atlantic BT
11
+ */
12
+ class Bronto_Verify_Block_Adminhtml_Widget_Button_Events extends Mage_Adminhtml_Block_Widget_Button
13
+ {
14
+ /**
15
+ * Internal constructor not depended on params. Can be used for object initialization
16
+ */
17
+ protected function _construct()
18
+ {
19
+ $this->setLabel('Search Event Observers');
20
+ $this->setOnClick("searchObservers(); return false;");
21
+ }
22
+ }
app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Permissions.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Permissions extends Mage_Adminhtml_Block_Widget_Button
14
  {
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Permissions extends Mage_Adminhtml_Block_Widget_Button
13
  {
app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Runroundtrip.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Runroundtrip extends Mage_Adminhtml_Block_Widget_Button
14
  {
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Runroundtrip extends Mage_Adminhtml_Block_Widget_Button
13
  {
app/code/community/Bronto/Verify/Block/Adminhtml/Widget/Button/Runtoken.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Runtoken extends Mage_Adminhtml_Block_Widget_Button
14
  {
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Adminhtml_Widget_Button_Runtoken extends Mage_Adminhtml_Block_Widget_Button
13
  {
app/code/community/Bronto/Verify/Block/Conflictprinter.php CHANGED
@@ -8,13 +8,13 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Conflictprinter
14
  extends Mage_Adminhtml_Block_Template
15
  {
16
  /**
17
  * Parity bit
 
18
  * @var integer
19
  * @access protected
20
  */
@@ -33,7 +33,7 @@ class Bronto_Verify_Block_Conflictprinter
33
  }
34
 
35
  /**
36
- * Get if even or ordd
37
  *
38
  * @return mixed Return description (if any) ...
39
  * @access public
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Conflictprinter
13
  extends Mage_Adminhtml_Block_Template
14
  {
15
  /**
16
  * Parity bit
17
+ *
18
  * @var integer
19
  * @access protected
20
  */
33
  }
34
 
35
  /**
36
+ * Get if even or odd
37
  *
38
  * @return mixed Return description (if any) ...
39
  * @access public
app/code/community/Bronto/Verify/Block/Permissionprinter.php CHANGED
@@ -8,13 +8,13 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Block_Permissionprinter
14
  extends Mage_Adminhtml_Block_Template
15
  {
16
  /**
17
  * Parity bit
 
18
  * @var integer
19
  * @access protected
20
  */
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Block_Permissionprinter
13
  extends Mage_Adminhtml_Block_Template
14
  {
15
  /**
16
  * Parity bit
17
+ *
18
  * @var integer
19
  * @access protected
20
  */
app/code/community/Bronto/Verify/Helper/Apitoken.php CHANGED
@@ -8,27 +8,75 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Helper_Apitoken
14
  extends Bronto_Verify_Helper_Data
15
  {
16
  /**
17
  * API Token Status
 
18
  * @var integer
19
  * @access private
20
  */
21
- private $_status = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  /**
24
  * Get API Token Validation Status
25
  *
26
- * @return void
 
27
  * @access public
28
  */
29
  public function __construct()
30
  {
31
- $this->_status = Mage::getStoreConfig($this->getPath('token_status'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  /**
@@ -39,9 +87,63 @@ class Bronto_Verify_Helper_Apitoken
39
  */
40
  public function getApitokenStatus()
41
  {
 
 
 
42
  return $this->_status;
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  /**
46
  * Get a formatted version of the API Token status text
47
  *
@@ -50,15 +152,20 @@ class Bronto_Verify_Helper_Apitoken
50
  */
51
  protected function _getApitokenStatusText()
52
  {
 
 
 
 
 
53
  switch ($this->_status) {
54
  case 1:
55
- return '<span id="bronto-validation-status" class="valid">Passed Verification</span>';
56
  break;
57
  case 0:
58
- return '<span id="bronto-validation-status" class="invalid">Failed Verification</span>';
59
  break;
60
  default:
61
- return '<span id="bronto-validation-status" class="">Needs Verification</span>';
62
  break;
63
  }
64
  }
@@ -66,12 +173,13 @@ class Bronto_Verify_Helper_Apitoken
66
  /**
67
  * Get a formatted version of the API Token status text scoped to current admin scope
68
  *
69
- * @return type
70
- * @access public
71
  */
72
  public function getAdminScopedApitokenStatusText()
73
  {
74
- $this->_status = $this->getAdminScopedConfig($this->getPath('token_status'));
 
 
75
 
76
  return $this->_getApitokenStatusText();
77
  }
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Helper_Apitoken
13
  extends Bronto_Verify_Helper_Data
14
  {
15
  /**
16
  * API Token Status
17
+ *
18
  * @var integer
19
  * @access private
20
  */
21
+ private $_status = false;
22
+
23
+ /**
24
+ * API Token
25
+ *
26
+ * @var string
27
+ * @access private
28
+ */
29
+ private $_token = '';
30
+
31
+ /**
32
+ * Token Failure Reason Message
33
+ *
34
+ * @var string
35
+ * @access private
36
+ */
37
+ private $_reason = '';
38
 
39
  /**
40
  * Get API Token Validation Status
41
  *
42
+ * @return Bronto_Verify_Helper_Apitoken
43
+ *
44
  * @access public
45
  */
46
  public function __construct()
47
  {
48
+ $this->_status = Mage::helper('bronto_common')->getAdminScopedConfig($this->getPath('token_status'));
49
+ $this->_token = Mage::helper('bronto_common')->getApiToken();
50
+
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * Set API Token
56
+ *
57
+ * @param string $token
58
+ *
59
+ * @return $this
60
+ */
61
+ public function setApiToken($token)
62
+ {
63
+ $this->_token = $token;
64
+
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Set API Token Status
70
+ *
71
+ * @param int $status
72
+ *
73
+ * @return Bronto_Verify_Helper_Apitoken
74
+ */
75
+ public function setApitokenStatus($status)
76
+ {
77
+ $this->_status = $status;
78
+
79
+ return $this;
80
  }
81
 
82
  /**
87
  */
88
  public function getApitokenStatus()
89
  {
90
+ // Check Permissions First
91
+ $this->_checkApitokenPermissions();
92
+
93
  return $this->_status;
94
  }
95
 
96
+ /**
97
+ * Get Token Status reason message
98
+ *
99
+ * @return string
100
+ * @access public
101
+ */
102
+ public function getReason()
103
+ {
104
+ return $this->_reason;
105
+ }
106
+
107
+ /**
108
+ * Determines if this the API status is in a success state
109
+ *
110
+ * @return bool
111
+ */
112
+ public function getStatus()
113
+ {
114
+ return $this->_status == 1;
115
+ }
116
+
117
+ /**
118
+ * Get Permissions Text
119
+ *
120
+ * @return string
121
+ * @access protected
122
+ */
123
+ protected function _checkApitokenPermissions()
124
+ {
125
+ try {
126
+ $api = $this->getApi($this->_token);
127
+ $tokenRow = $api->getTokenInfo();
128
+
129
+ $access = $tokenRow->hasPermissions(7);
130
+
131
+ if (!$access) {
132
+ $this->_status = 0;
133
+ $this->_reason = 'Token Does Not Have Full Access';
134
+ }
135
+ } catch (Exception $e) {
136
+ if (102 == $e->getCode()) {
137
+ $this->_status = 0;
138
+ $this->_reason = 'Token is Not Active or is Invalid';
139
+ } else {
140
+ $this->writeError($e);
141
+ }
142
+ }
143
+
144
+ return $this->_reason;
145
+ }
146
+
147
  /**
148
  * Get a formatted version of the API Token status text
149
  *
152
  */
153
  protected function _getApitokenStatusText()
154
  {
155
+ $permissionText = $this->_checkApitokenPermissions();
156
+ if ('' != $permissionText) {
157
+ $permissionText = '<br /><span style="color: #2f2f2f;">Reason: </span>' . $permissionText;
158
+ }
159
+
160
  switch ($this->_status) {
161
  case 1:
162
+ return '<span id="bronto-validation-status-text" class="valid">Passed Verification</span>' . $permissionText;
163
  break;
164
  case 0:
165
+ return '<span id="bronto-validation-status-text" class="invalid">Failed Verification</span><br />' . $permissionText;
166
  break;
167
  default:
168
+ return '<span id="bronto-validation-status-text" class="">Needs Verification</span><br />' . $permissionText;
169
  break;
170
  }
171
  }
173
  /**
174
  * Get a formatted version of the API Token status text scoped to current admin scope
175
  *
176
+ * @return string
 
177
  */
178
  public function getAdminScopedApitokenStatusText()
179
  {
180
+ if (false === $this->_status) {
181
+ $this->_status = $this->getAdminScopedConfig($this->getPath('token_status'));
182
+ }
183
 
184
  return $this->_getApitokenStatusText();
185
  }
app/code/community/Bronto/Verify/Helper/Conflictchecker.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Helper_Conflictchecker
14
  extends Bronto_Verify_Helper_Data
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Helper_Conflictchecker
13
  extends Bronto_Verify_Helper_Data
app/code/community/Bronto/Verify/Helper/Data.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Helper_Data
14
  extends Bronto_Common_Helper_Data
@@ -18,6 +17,44 @@ class Bronto_Verify_Helper_Data
18
  */
19
  const XML_PATH_ROUNDTRIP_ROOT = 'bronto_verify/settings/';
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * Get the full path from path ending
23
  *
@@ -31,11 +68,118 @@ class Bronto_Verify_Helper_Data
31
  return self::XML_PATH_ROUNDTRIP_ROOT . $pathend;
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Set the value of a setting
36
  *
37
- * @param string $path The setting path to set the value for
38
- * @param string $value
 
 
39
  *
40
  * @return Mage_Core_Model_Config
41
  * @access public
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Helper_Data
13
  extends Bronto_Common_Helper_Data
17
  */
18
  const XML_PATH_ROUNDTRIP_ROOT = 'bronto_verify/settings/';
19
 
20
+ const XML_PATH_SOAP_CLIENT = 'bronto_verify/soap_options/soap_client';
21
+ const XML_PATH_SOAP_STREAM_CONTEXT = 'bronto_verify/soap_options/stream_context';
22
+ const XML_PATH_SOAP_RETRY_LIMIT = 'bronto_verify/soap_options/retry_limit';
23
+ const XML_PATH_SOAP_CONNECTION_TIMEOUT = 'bronto_verify/soap_options/connection_timeout';
24
+ const XML_PATH_SOAP_TRACE = 'bronto_verify/soap_options/trace';
25
+ const XML_PATH_SOAP_EXCEPTIONS = 'bronto_verify/soap_options/exceptions';
26
+ const XML_PATH_WSDL_CACHE = 'bronto_verify/soap_options/wsdl_cache';
27
+
28
+ const DEFAULT_SOAP_CLIENT = 'Bronto_SoapClient';
29
+
30
+ /**
31
+ * Module Human Readable Name
32
+ */
33
+ protected $_name = 'Bronto Advanced Configuration';
34
+
35
+ /**
36
+ * Check if module is enabled (Verify Module Always Enabled)
37
+ *
38
+ * @param string $scope
39
+ * @param int $scopeId
40
+ *
41
+ * @return bool
42
+ */
43
+ public function isEnabled($scope = 'default', $scopeId = 0)
44
+ {
45
+ true;
46
+ }
47
+
48
+ /**
49
+ * Get Human Readable Name
50
+ *
51
+ * @return string
52
+ */
53
+ public function getName()
54
+ {
55
+ return $this->__($this->_name);
56
+ }
57
+
58
  /**
59
  * Get the full path from path ending
60
  *
68
  return self::XML_PATH_ROUNDTRIP_ROOT . $pathend;
69
  }
70
 
71
+ /**
72
+ * Get SOAP Options
73
+ *
74
+ * @return array
75
+ */
76
+ public function getSoapOptions()
77
+ {
78
+ // Return Default Options
79
+ return array(
80
+ 'soap_client' => $this->getSoapClient(),
81
+ 'retry_limit' => $this->getSoapRetryLimit(),
82
+ 'connection_timeout' => $this->getSoapConnectionTimeout(),
83
+ 'trace' => $this->getSoapTrace(),
84
+ 'exceptions' => $this->getSoapExceptions(),
85
+ 'cache_wsdl' => $this->getSoapCacheWsdl(),
86
+ 'debug' => $this->isDebugEnabled(),
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Override the Bronto_SoapCLient class name
92
+ *
93
+ * @return string
94
+ */
95
+ public function getSoapClient()
96
+ {
97
+ $class = $this->getAdminScopedConfig(self::XML_PATH_SOAP_CLIENT);
98
+ if (empty($class)) {
99
+ $class = self::DEFAULT_SOAP_CLIENT;
100
+ }
101
+ if (
102
+ $this->isStreamContextOverride() &&
103
+ $class == self::DEFAULT_SOAP_CLIENT
104
+ ) {
105
+ $class = 'Bronto_Common_Model_SoapClient';
106
+ }
107
+ return $class;
108
+ }
109
+
110
+ /**
111
+ * Override the default Soap client with the stream context override
112
+ *
113
+ * @return bool
114
+ */
115
+ public function isStreamContextOverride()
116
+ {
117
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_SOAP_STREAM_CONTEXT);
118
+ }
119
+
120
+ /**
121
+ * Get Config Value for SOAP Retry Limit
122
+ *
123
+ * @return int
124
+ */
125
+ public function getSoapRetryLimit()
126
+ {
127
+ return (int)$this->getAdminScopedConfig(self::XML_PATH_SOAP_RETRY_LIMIT);
128
+ }
129
+
130
+ /**
131
+ * Get Config Value for SOAP Connection Timeout
132
+ *
133
+ * @return int
134
+ */
135
+ public function getSoapConnectionTimeout()
136
+ {
137
+ return (int)$this->getAdminScopedConfig(self::XML_PATH_SOAP_CONNECTION_TIMEOUT);
138
+ }
139
+
140
+ /**
141
+ * Get Config Value for SOAP Trace
142
+ *
143
+ * @return bool
144
+ */
145
+ public function getSoapTrace()
146
+ {
147
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_SOAP_TRACE) == '1';
148
+ }
149
+
150
+ /**
151
+ * Get Config Value for SOAP Exceptions
152
+ *
153
+ * @return bool
154
+ */
155
+ public function getSoapExceptions()
156
+ {
157
+ return (bool)$this->getAdminScopedConfig(self::XML_PATH_SOAP_EXCEPTIONS) == '1';
158
+ }
159
+
160
+ public function getSoapCacheWsdl()
161
+ {
162
+ $cacheWsdl = $this->getAdminScopedConfig(self::XML_PATH_WSDL_CACHE);
163
+ switch ($cacheWsdl) {
164
+ case 'WSDL_CACHE_NONE':
165
+ return WSDL_CACHE_NONE;
166
+ case 'WSDL_CACHE_DISK':
167
+ return WSDL_CACHE_DISK;
168
+ case 'WSDL_CACHE_MEMORY':
169
+ return WSDL_CACHE_MEMORY;
170
+ case 'WSDL_CACHE_BOTH':
171
+ default:
172
+ return WSDL_CACHE_BOTH;
173
+ }
174
+ }
175
+
176
  /**
177
  * Set the value of a setting
178
  *
179
+ * @param string $path The setting path to set the value for
180
+ * @param string $value
181
+ * @param string $scope
182
+ * @param int|string $scopeId
183
  *
184
  * @return Mage_Core_Model_Config
185
  * @access public
app/code/community/Bronto/Verify/Helper/Permissionchecker.php CHANGED
@@ -8,7 +8,6 @@
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
11
- * @version 0.1.0
12
  */
13
  class Bronto_Verify_Helper_Permissionchecker
14
  extends Bronto_Verify_Helper_Data
@@ -16,13 +15,14 @@ class Bronto_Verify_Helper_Permissionchecker
16
  /**
17
  * Check file name to see if it matches anything that needs to be filtered
18
  *
19
- * @return boolean
20
- * @access public
 
21
  */
22
  public function accept($path)
23
  {
24
- $exclusions = Mage::getStoreConfig('bronto_verify/permissionchecker/exclude');
25
- $exclusions = explode(',', $exclusions);
26
  $exclusions[] = '.';
27
  $exclusions[] = '..';
28
  array_walk($exclusions, create_function('&$val', '$val = trim($val);'));
8
  * @author Adam Daniels <adam.daniels@atlanticbt.com>
9
  * @copyright 2013 Adam Daniels
10
  * @license http://www.atlanticbt.com/ Atlantic BT
 
11
  */
12
  class Bronto_Verify_Helper_Permissionchecker
13
  extends Bronto_Verify_Helper_Data
15
  /**
16
  * Check file name to see if it matches anything that needs to be filtered
17
  *
18
+ * @param $path
19
+ *
20
+ * @return bool
21
  */
22
  public function accept($path)
23
  {
24
+ $exclusions = Mage::getStoreConfig('bronto_verify/permissionchecker/exclude');
25
+ $exclusions = explode(',', $exclusions);
26
  $exclusions[] = '.';
27
  $exclusions[] = '..';
28
  array_walk($exclusions, create_function('&$val', '$val = trim($val);'));
app/code/community/Bronto/Verify/{Helper/Roundtrip.php → Help} RENAMED
File without changes