Bronto_Extension - Version 3.0.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 Jason Baronciani
Extension Bronto_Extension
Version 3.0.0
Comparing to
See all releases


Code changes from version 2.4.4 to 3.0.0

Files changed (243) hide show
  1. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/About.php +0 -115
  2. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron.php +0 -366
  3. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron/Error.php +0 -14
  4. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron/Queue.php +0 -23
  5. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form.php +0 -40
  6. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Coupon.php +0 -21
  7. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field.php +0 -47
  8. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Apitoken.php +0 -147
  9. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Debug.php +0 -69
  10. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Download.php +0 -67
  11. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Hidden.php +0 -22
  12. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Image.php +0 -38
  13. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/List.php +0 -46
  14. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support.php +0 -21
  15. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support/Site.php +0 -29
  16. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Fieldset.php +0 -23
  17. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Guide.php +0 -113
  18. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Support.php +0 -37
  19. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Suppressed.php +0 -80
  20. app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Suppressed/Reset.php +0 -23
  21. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Abstract.php +0 -48
  22. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Debug.php +0 -16
  23. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Download.php +0 -14
  24. app/code/community/Bronto/Common/Block/Adminhtml/Widget/Queue/Button/Run.php +0 -28
  25. app/code/community/Bronto/Common/Block/Cart/Recovery.php +0 -309
  26. app/code/community/Bronto/Common/Block/Popup.php +0 -29
  27. app/code/community/Bronto/Common/Helper/Api.php +0 -287
  28. app/code/community/Bronto/Common/Helper/Contact.php +0 -134
  29. app/code/community/Bronto/Common/Helper/Coupon.php +0 -327
  30. app/code/community/Bronto/Common/Helper/Data.php +0 -1243
  31. app/code/community/Bronto/Common/Helper/DataInterface.php +0 -19
  32. app/code/community/Bronto/Common/Helper/Field.php +0 -45
  33. app/code/community/Bronto/Common/Helper/Item.php +0 -124
  34. app/code/community/Bronto/Common/Helper/Message.php +0 -151
  35. app/code/community/Bronto/Common/Helper/Product.php +0 -201
  36. app/code/community/Bronto/Common/Helper/Salesrule.php +0 -39
  37. app/code/community/Bronto/Common/Helper/Support.php +0 -547
  38. app/code/community/Bronto/Common/Model/Api.php +0 -106
  39. app/code/community/Bronto/Common/Model/Archive.php +0 -86
  40. app/code/community/Bronto/Common/Model/Container/Cart/Recovery.php +0 -43
  41. app/code/community/Bronto/Common/Model/Coupon/Observer.php +0 -55
  42. app/code/community/Bronto/Common/Model/Email/Template.php +0 -627
  43. app/code/community/Bronto/Common/Model/Email/Template/Filter.php +0 -1352
  44. app/code/community/Bronto/Common/Model/Email/Template/Templatefilter.php +0 -276
  45. app/code/community/Bronto/Common/Model/Error.php +0 -79
  46. app/code/community/Bronto/Common/Model/Flusher.php +0 -140
  47. app/code/community/Bronto/Common/Model/Keysentry.php +0 -134
  48. app/code/community/Bronto/Common/Model/List.php +0 -67
  49. app/code/community/Bronto/Common/Model/Mysql4/Api.php +0 -14
  50. app/code/community/Bronto/Common/Model/Mysql4/Api/Collection.php +0 -13
  51. app/code/community/Bronto/Common/Model/Mysql4/Error.php +0 -12
  52. app/code/community/Bronto/Common/Model/Mysql4/Error/Collection.php +0 -35
  53. app/code/community/Bronto/Common/Model/Mysql4/Queue.php +0 -27
  54. app/code/community/Bronto/Common/Model/Mysql4/Queue/Collection.php +0 -43
  55. app/code/community/Bronto/Common/Model/Observer.php +0 -370
  56. app/code/community/Bronto/Common/Model/Queue.php +0 -200
  57. app/code/community/Bronto/Common/Model/Resource/Abstract.php +0 -180
  58. app/code/community/Bronto/Common/Model/Resource/Setup.php +0 -156
  59. app/code/community/Bronto/Common/Model/SoapClient.php +0 -22
  60. app/code/community/Bronto/Common/Model/System/Config/Backend/Cron.php +0 -202
  61. app/code/community/Bronto/Common/Model/System/Config/Backend/Cron/Error.php +0 -7
  62. app/code/community/Bronto/Common/Model/System/Config/Backend/Cron/Queue.php +0 -7
  63. app/code/community/Bronto/Common/Model/System/Config/Backend/Enable.php +0 -31
  64. app/code/community/Bronto/Common/Model/System/Config/Backend/Token.php +0 -99
  65. app/code/community/Bronto/Common/Model/System/Config/Source/Attributes.php +0 -44
  66. app/code/community/Bronto/Common/Model/System/Config/Source/Contact/Status.php +0 -49
  67. app/code/community/Bronto/Common/Model/System/Config/Source/Coupon.php +0 -77
  68. app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Frequency.php +0 -41
  69. app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Minutes.php +0 -28
  70. app/code/community/Bronto/Common/Model/System/Config/Source/Field.php +0 -70
  71. app/code/community/Bronto/Common/Model/System/Config/Source/Image.php +0 -22
  72. app/code/community/Bronto/Common/Model/System/Config/Source/Limit.php +0 -24
  73. app/code/community/Bronto/Common/Model/System/Config/Source/List.php +0 -40
  74. app/code/community/Bronto/Common/Model/System/Config/Source/Message.php +0 -62
  75. app/code/community/Bronto/Common/Model/System/Config/Source/Related.php +0 -53
  76. app/code/community/Bronto/Common/Model/System/Config/Source/Role.php +0 -31
  77. app/code/community/Bronto/Common/Model/System/Config/Source/SendOptions.php +0 -97
  78. app/code/community/Bronto/Common/Model/System/Config/Source/Synclimit.php +0 -22
  79. app/code/community/Bronto/Common/controllers/Adminhtml/DebugController.php +0 -111
  80. app/code/community/Bronto/Common/controllers/Adminhtml/GuidersController.php +0 -21
  81. app/code/community/Bronto/Common/controllers/CouponController.php +0 -72
  82. app/code/community/Bronto/Common/etc/adminhtml.xml +0 -39
  83. app/code/community/Bronto/Common/etc/cache.xml +0 -13
  84. app/code/community/Bronto/Common/etc/config.xml +0 -244
  85. app/code/community/Bronto/Common/etc/system.xml +0 -1124
  86. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-1.7.0.php +0 -10
  87. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.2.1.php +0 -38
  88. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.3.0.php +0 -13
  89. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.3.1.php +0 -13
  90. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.4.2.php +0 -13
  91. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.4.4.php +0 -13
  92. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-1.7.0-2.2.1.php +0 -38
  93. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.0.4-2.2.1.php +0 -38
  94. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.0.4.2-2.2.1.php +0 -38
  95. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.1.0-2.2.1.php +0 -38
  96. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.2.0-2.2.1.php +0 -38
  97. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.2.2-2.3.0.php +0 -8
  98. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.3.0-2.4.0.php +0 -7
  99. app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.4.0-2.4.2.php +0 -7
  100. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/About.php +0 -18
  101. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Cron.php +0 -110
  102. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Rewardpoints.php +0 -44
  103. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Storecredit.php +0 -44
  104. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes.php +0 -349
  105. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Address.php +0 -54
  106. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Customer.php +0 -57
  107. app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Suppressed.php +0 -27
  108. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Mark.php +0 -18
  109. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Reset.php +0 -26
  110. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Run.php +0 -22
  111. app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Sync.php +0 -22
  112. app/code/community/Bronto/Customer/Helper/Data.php +0 -380
  113. app/code/community/Bronto/Customer/Model/Mysql4/Queue.php +0 -36
  114. app/code/community/Bronto/Customer/Model/Mysql4/Queue/Collection.php +0 -118
  115. app/code/community/Bronto/Customer/Model/Mysql4/Setup.php +0 -19
  116. app/code/community/Bronto/Customer/Model/Observer.php +0 -671
  117. app/code/community/Bronto/Customer/Model/Queue.php +0 -117
  118. app/code/community/Bronto/Customer/Model/Resource/Customer.php +0 -28
  119. app/code/community/Bronto/Customer/Model/System/Config/Backend/Brontofield.php +0 -69
  120. app/code/community/Bronto/Customer/Model/System/Config/Backend/Cron.php +0 -27
  121. app/code/community/Bronto/Customer/Model/System/Config/Backend/Newfield.php +0 -67
  122. app/code/community/Bronto/Customer/controllers/Adminhtml/CustomerController.php +0 -306
  123. app/code/community/Bronto/Customer/etc/adminhtml.xml +0 -23
  124. app/code/community/Bronto/Customer/etc/config.xml +0 -157
  125. app/code/community/Bronto/Customer/etc/system.xml +0 -1007
  126. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.0.php +0 -27
  127. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.3.php +0 -48
  128. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.0-1.0.1.php +0 -46
  129. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.1-1.0.2.php +0 -29
  130. app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.2-1.0.3.php +0 -32
  131. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/About.php +0 -18
  132. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Settings.php +0 -24
  133. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates.php +0 -247
  134. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Field.php +0 -25
  135. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Fieldset.php +0 -425
  136. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Label.php +0 -38
  137. app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Sendtype.php +0 -27
  138. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import.php +0 -95
  139. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Edit.php +0 -25
  140. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid.php +0 -107
  141. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid/Renderer/Action.php +0 -53
  142. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log.php +0 -65
  143. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid.php +0 -114
  144. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Customer.php +0 -28
  145. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Fields.php +0 -40
  146. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template.php +0 -129
  147. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit.php +0 -209
  148. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit/Form.php +0 -457
  149. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid.php +0 -167
  150. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Action.php +0 -66
  151. app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Storename.php +0 -24
  152. app/code/community/Bronto/Email/Helper/Contact.php +0 -32
  153. app/code/community/Bronto/Email/Helper/Data.php +0 -312
  154. app/code/community/Bronto/Email/Helper/Field.php +0 -18
  155. app/code/community/Bronto/Email/Helper/Message.php +0 -18
  156. app/code/community/Bronto/Email/Model/Log.php +0 -14
  157. app/code/community/Bronto/Email/Model/Message.php +0 -14
  158. app/code/community/Bronto/Email/Model/Mysql4/Log.php +0 -13
  159. app/code/community/Bronto/Email/Model/Mysql4/Log/Collection.php +0 -42
  160. app/code/community/Bronto/Email/Model/Mysql4/Message.php +0 -20
  161. app/code/community/Bronto/Email/Model/Mysql4/Message/Collection.php +0 -14
  162. app/code/community/Bronto/Email/Model/Mysql4/Template.php +0 -74
  163. app/code/community/Bronto/Email/Model/Mysql4/Template/Collection.php +0 -52
  164. app/code/community/Bronto/Email/Model/Observer.php +0 -141
  165. app/code/community/Bronto/Email/Model/Resource/Setup.php +0 -147
  166. app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Field.php +0 -43
  167. app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Sendtype.php +0 -40
  168. app/code/community/Bronto/Email/Model/System/Config/Backend/Usebronto.php +0 -12
  169. app/code/community/Bronto/Email/Model/System/Config/Source/Email/Template.php +0 -93
  170. app/code/community/Bronto/Email/Model/System/Config/Source/Sendtype.php +0 -19
  171. app/code/community/Bronto/Email/Model/Template.php +0 -229
  172. app/code/community/Bronto/Email/Model/Template/Import.php +0 -317
  173. app/code/community/Bronto/Email/Model/Template/Mailer.php +0 -62
  174. app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/LogController.php +0 -47
  175. app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/TemplateController.php +0 -570
  176. app/code/community/Bronto/Email/etc/adminhtml.xml +0 -23
  177. app/code/community/Bronto/Email/etc/config.xml +0 -139
  178. app/code/community/Bronto/Email/etc/system.xml +0 -1407
  179. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.0.php +0 -30
  180. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.2.php +0 -59
  181. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.5.php +0 -59
  182. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.8.php +0 -64
  183. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.2.php +0 -75
  184. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.7.php +0 -63
  185. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.8.php +0 -64
  186. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.9.php +0 -65
  187. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.2.0.php +0 -13
  188. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.2.1.php +0 -13
  189. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.2.2.php +0 -13
  190. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.0-1.0.2.php +0 -48
  191. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.2-1.0.5.php +0 -8
  192. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.5-1.0.8.php +0 -21
  193. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.8-1.1.1.php +0 -8
  194. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.1-1.1.2.php +0 -20
  195. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.2-1.1.7.php +0 -63
  196. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.7-1.1.8.php +0 -20
  197. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.8-1.1.9.php +0 -20
  198. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.9-1.2.0.php +0 -7
  199. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.2.0-1.2.1.php +0 -13
  200. app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.2.1-1.2.2.php +0 -13
  201. app/code/community/Bronto/Emailcapture/Block/Emailcapture.php +0 -42
  202. app/code/community/Bronto/Emailcapture/Helper/Data.php +0 -61
  203. app/code/community/Bronto/Emailcapture/Model/Mysql4/Queue.php +0 -36
  204. app/code/community/Bronto/Emailcapture/Model/Mysql4/Queue/Collection.php +0 -21
  205. app/code/community/Bronto/Emailcapture/Model/Observer.php +0 -66
  206. app/code/community/Bronto/Emailcapture/Model/Queue.php +0 -138
  207. app/code/community/Bronto/Emailcapture/controllers/IndexController.php +0 -39
  208. app/code/community/Bronto/Emailcapture/etc/config.xml +0 -119
  209. app/code/community/Bronto/Emailcapture/etc/system.xml +0 -41
  210. app/code/community/Bronto/Emailcapture/sql/bronto_emailcapture_setup/mysql4-install-1.0.0.php +0 -22
  211. app/code/community/Bronto/News/Block/Adminhtml/ItemRender.php +0 -24
  212. app/code/community/Bronto/News/Block/Adminhtml/Redirect.php +0 -27
  213. app/code/community/Bronto/News/Block/Adminhtml/System/Config/About.php +0 -15
  214. app/code/community/Bronto/News/Block/Adminhtml/System/Config/Form.php +0 -28
  215. app/code/community/Bronto/News/Block/Adminhtml/System/Config/General.php +0 -13
  216. app/code/community/Bronto/News/Block/Adminhtml/System/Config/News.php +0 -159
  217. app/code/community/Bronto/News/Block/Adminhtml/System/Config/Releases.php +0 -13
  218. app/code/community/Bronto/News/Helper/Data.php +0 -231
  219. app/code/community/Bronto/News/Model/Item.php +0 -143
  220. app/code/community/Bronto/News/Model/Mysql4/Item.php +0 -13
  221. app/code/community/Bronto/News/Model/Mysql4/Item/Collection.php +0 -24
  222. app/code/community/Bronto/News/Model/Observer.php +0 -54
  223. app/code/community/Bronto/News/Model/Resource/Setup.php +0 -37
  224. app/code/community/Bronto/News/controllers/Adminhtml/AnnouncementController.php +0 -55
  225. app/code/community/Bronto/News/controllers/RouteController.php +0 -25
  226. app/code/community/Bronto/News/etc/adminhtml.xml +0 -23
  227. app/code/community/Bronto/News/etc/config.xml +0 -116
  228. app/code/community/Bronto/News/etc/system.xml +0 -45
  229. app/code/community/Bronto/News/sql/bronto_news_setup/mysql4-install-1.0.0.php +0 -33
  230. app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/About.php +0 -25
  231. app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Cron.php +0 -111
  232. app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Suppressed.php +0 -27
  233. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Mark.php +0 -18
  234. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Reset.php +0 -25
  235. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Run.php +0 -23
  236. app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Sync.php +0 -22
  237. app/code/community/Bronto/Newsletter/Block/Checkout/Onepage/Newsletter.php +0 -222
  238. app/code/community/Bronto/Newsletter/Helper/Contact.php +0 -152
  239. app/code/community/Bronto/Newsletter/Helper/Data.php +0 -257
  240. app/code/community/Bronto/Newsletter/Model/Mysql4/Queue.php +0 -38
  241. app/code/community/Bronto/Newsletter/Model/Mysql4/Queue/Collection.php +0 -121
  242. app/code/community/Bronto/Newsletter/Model/Observer.php +0 -431
  243. app/code/community/Bronto/Newsletter/Model/Queue.php +0 -115
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/About.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Common
5
- * @copyright 2011-2013 Bronto Software, Inc.
6
- */
7
- class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
8
- {
9
- /**
10
- * Name of module
11
- *
12
- * @var string
13
- */
14
- protected $_module = 'bronto_common';
15
-
16
- public function _construct()
17
- {
18
- parent::_construct();
19
- $this->setTemplate('bronto/common/about.phtml');
20
- }
21
-
22
- /**
23
- * @param Varien_Data_Form_Element_Abstract $element
24
- *
25
- * @return string
26
- */
27
- public function render(Varien_Data_Form_Element_Abstract $element)
28
- {
29
- return $this->toHtml();
30
- }
31
-
32
- /**
33
- * Get the module namespace
34
- *
35
- * @return string
36
- */
37
- public function getModuleNamespace()
38
- {
39
- return $this->_module;
40
- }
41
-
42
- /**
43
- * Get the module name
44
- *
45
- * @return string
46
- */
47
- public function getModuleName()
48
- {
49
- return Mage::helper($this->_module)->getName();
50
- }
51
-
52
- /**
53
- * Get Section Name
54
- *
55
- * @return string
56
- */
57
- public function getSection()
58
- {
59
- return Mage::app()->getRequest()->getParam('section');
60
- }
61
-
62
- /**
63
- * Get the module version
64
- *
65
- * @return string
66
- */
67
- public function getModuleVersion()
68
- {
69
- $version = Mage::helper($this->_module)->getModuleVersion();
70
-
71
- return empty($version) ? null : "v{$version}";
72
- }
73
-
74
- /**
75
- * Get log url
76
- *
77
- * @return string
78
- */
79
- public function getLogViewUrl()
80
- {
81
- return Mage::getSingleton('adminhtml/url')->getUrl('bronto/log/index', array('print' => 1, 'file' => $this->_module));
82
- }
83
-
84
- /**
85
- * Get if debugging is turned on for module
86
- *
87
- * @return bool
88
- */
89
- public function hasDebugEnabled()
90
- {
91
- return (bool)Mage::helper($this->_module)->isDebugEnabled();
92
- }
93
-
94
- /**
95
- * Get if the log file exists
96
- *
97
- * @return bool
98
- */
99
- public function logFileExists()
100
- {
101
- $logFile = Mage::getBaseDir('log') . DIRECTORY_SEPARATOR . "{$this->_module}.log";
102
-
103
- return (bool)@file_exists($logFile);
104
- }
105
-
106
- /**
107
- * Forwards call to helper from view
108
- *
109
- * @return boolean
110
- */
111
- public function isValidApiToken()
112
- {
113
- return Mage::helper('bronto_verify/apitoken')->getStatus();
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron.php DELETED
@@ -1,366 +0,0 @@
1
- <?php
2
-
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;
29
-
30
- public function _construct()
31
- {
32
- parent::_construct();
33
- $this->setTemplate('bronto/common/cron.phtml');
34
- }
35
-
36
- /**
37
- * Prepare the layout
38
- *
39
- * @return Bronto_Common_Block_Adminhtml_System_Config_Cron
40
- */
41
- protected function _prepareLayout()
42
- {
43
- if ($head = $this->getLayout()->getBlock('head')) {
44
- $head->addCss('bronto/cron.css');
45
- }
46
-
47
- return parent::_prepareLayout();
48
- }
49
-
50
- /**
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)
58
- {
59
- return $this->toHtml();
60
- }
61
-
62
- /**
63
- * Get a job schedule collection
64
- *
65
- * @return Mage_Cron_Model_Mysql4_Schedule_Collection
66
- */
67
- public function getJobSchedule()
68
- {
69
- return Mage::getModel('cron/schedule')->getCollection()
70
- ->addFieldToFilter('job_code', $this->_jobCode)
71
- ->setPageSize(6)
72
- ->setCurPage(1)
73
- ->setOrder('scheduled_at', 'DESC');
74
- }
75
-
76
- /**
77
- * Get cron job message
78
- * Note: Limits to 100 characters
79
- *
80
- * @param Mage_Cron_Model_Schedule $job
81
- *
82
- * @return string
83
- */
84
- public function getTruncatedJobMessages($job)
85
- {
86
- return Mage::helper('core/string')->truncate($job->getMessages(), 100);
87
- }
88
-
89
- /**
90
- * Get the HTML markup for the button widgets
91
- *
92
- * @return string
93
- */
94
- public function getButtonsHtml()
95
- {
96
- $html = null;
97
- if ($buttons = $this->getButtons()) {
98
- foreach ($buttons as $_button) {
99
- $html .= $_button->toHtml();
100
- }
101
- }
102
-
103
- if (!empty($html)) {
104
- $html = "<p class=\"form-buttons bronto-cron\">{$html}</p>";
105
- }
106
-
107
- return $html;
108
- }
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
-
121
- if ($getCount) {
122
- return $count;
123
- }
124
-
125
- if ($total > 0) {
126
- $percent = round(((float)$count / (float)$total) * 100, 1);
127
- }
128
-
129
- if ($getBar) {
130
- if ($count > 0) {
131
- $html .= "<div class=\"bronto-progress-bar-complete\" style=\"width: {$percent}%\">";
132
- $html .= ($percent > 4) ? "{$percent}%" : "&nbsp;";
133
- $html .= "</div>";
134
- }
135
- }
136
-
137
- if ($getLegend) {
138
- $html .= '<div class="bronto-progress-bar-legend-complete">';
139
- $html .= '<div class="bronto-progress-bar-legend-status"></div>';
140
- $html .= "<div class=\"bronto-progress-bar-legend-details\">Completed: {$percent}% ({$count}/{$total})</div>";
141
- $html .= '</div>';
142
- }
143
-
144
- return $html;
145
- }
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;
155
- }
156
-
157
- if ($total > 0) {
158
- $percent = round(((float)$count / (float)$total) * 100, 1);
159
- }
160
-
161
- if ($getBar) {
162
- if ($count > 0) {
163
- $html .= "<div class=\"bronto-progress-bar-suppressed\" style=\"width: {$percent}%\">";
164
- $html .= ($percent > 4) ? "{$percent}%" : "&nbsp;";
165
- $html .= "</div>";
166
- }
167
- }
168
-
169
- if ($getLegend) {
170
- $html .= '<div class="bronto-progress-bar-legend-suppressed">';
171
- $html .= '<div class="bronto-progress-bar-legend-status"></div>';
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;
187
- }
188
-
189
- if ($total > 0) {
190
- $percent = round(((float)$count / (float)$total) * 100, 1);
191
- }
192
-
193
- if ($getBar) {
194
- if ($count > 0) {
195
- $html .= "<div class=\"bronto-progress-bar-disabled\" style=\"width: {$percent}%\">";
196
- $html .= ($percent > 4) ? "{$percent}%" : "&nbsp;";
197
- $html .= "</div>";
198
- }
199
- }
200
-
201
- if ($getLegend) {
202
- $html .= '<div class="bronto-progress-bar-legend-disabled">';
203
- $html .= '<div class="bronto-progress-bar-legend-status"></div>';
204
- $html .= "<div class=\"bronto-progress-bar-legend-details\">Disabled: {$percent}% ({$count}/{$total})</div>";
205
- $html .= '</div>';
206
- }
207
-
208
- return $html;
209
- }
210
-
211
- /**
212
- * Get the HTML markup for the progress bar
213
- *
214
- * @return string
215
- */
216
- public function getProgressBarHtml()
217
- {
218
- $total = (int)$this->getProgressBarTotal();
219
-
220
- // Build Status Legend
221
- $html = '<div class="bronto-progress-bar-legend">';
222
- $html .= $this->_getProgressComplete($total, false, false, true);
223
- $html .= $this->_getProgressSuppressed($total, false, false, true);
224
- $html .= $this->_getProgressDisabled($total, false, false, true);
225
- $html .= '</div>';
226
-
227
- // Build Progress Bar
228
- $html .= "<div class=\"bronto-progress-bar\">";
229
- $html .= $this->_getProgressComplete($total);
230
- $html .= $this->_getProgressSuppressed($total);
231
- $html .= $this->_getProgressDisabled($total);
232
- $html .= '</div>';
233
-
234
- // Add Info Hover
235
- $html .= '<div class="bronto-help bronto-floater">';
236
- $html .= ' <ul class="bronto-help-window">';
237
- $html .= ' <li><strong>Completed</strong> refers to items that have been successfully imported.</li>';
238
- $html .= ' <li><strong>Suppressed</strong> refers to items that have failed to import and will not be attempted again until all have been reset.</li>';
239
- $html .= ' <li><strong>Disabled</strong> refers to items that exist in stores where this module is not enabled</li>';
240
- $html .= ' </ul>';
241
- $html .= '</div>';
242
-
243
- return $html;
244
- }
245
-
246
- /**
247
- * Color code the job status
248
- *
249
- * @param string $status
250
- *
251
- * @return string
252
- */
253
- public function decorateJobStatus($status)
254
- {
255
- switch ($status) {
256
- case Mage_Cron_Model_Schedule::STATUS_SUCCESS:
257
- $color = 'green';
258
- break;
259
- case Mage_Cron_Model_Schedule::STATUS_RUNNING:
260
- $color = 'yellow';
261
- break;
262
- case Mage_Cron_Model_Schedule::STATUS_MISSED:
263
- $color = 'orange';
264
- break;
265
- case Mage_Cron_Model_Schedule::STATUS_ERROR:
266
- $color = 'red';
267
- break;
268
- case Mage_Cron_Model_Schedule::STATUS_PENDING:
269
- default:
270
- $color = 'lightgray';
271
- break;
272
- }
273
-
274
- return "<span class=\"bar-{$color}\"><span>{$status}</span></span>";
275
- }
276
-
277
- /**
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
-
291
- /**
292
- * Get button widgets
293
- *
294
- * @return array
295
- */
296
- public function getButtons()
297
- {
298
- return $this->_buttons;
299
- }
300
-
301
- /**
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
-
315
- /**
316
- * Get if we have a progress bar
317
- *
318
- * @return boolean
319
- */
320
- public function hasProgressBar()
321
- {
322
- return (bool)$this->_hasProgressBar;
323
- }
324
-
325
- /**
326
- * @return int
327
- */
328
- protected function getProgressBarTotal()
329
- {
330
- return 0;
331
- }
332
-
333
- /**
334
- * @return int
335
- */
336
- protected function getProgressBarPending()
337
- {
338
- return 0;
339
- }
340
-
341
- /**
342
- * @return int
343
- */
344
- protected function getProgressBarSuppressed()
345
- {
346
- return 0;
347
- }
348
-
349
- /**
350
- * @return int
351
- */
352
- protected function getProgressBarDisabled()
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/Cron/Error.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Cron_Error extends Bronto_Common_Block_Adminhtml_System_Config_Cron
4
- {
5
- protected $_jobCode = 'bronto_common_errors';
6
-
7
- /**
8
- * @return bool
9
- */
10
- public function showCronTable()
11
- {
12
- return Mage::helper('bronto_common/api')->canUseMageCron();
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron/Queue.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Cron_Queue extends Bronto_Common_Block_Adminhtml_System_Config_Cron
4
- {
5
- protected $_jobCode = 'bronto_common_queue';
6
-
7
- /**
8
- * @see parent
9
- */
10
- protected function _prepareLayout()
11
- {
12
- $this->addButton($this->getLayout()->createBlock('bronto_common/adminhtml_widget_queue_button_run'));
13
- return parent::_prepareLayout();
14
- }
15
-
16
- /**
17
- * @see parent
18
- */
19
- public function showCronTable()
20
- {
21
- return Mage::helper('bronto_common/api')->queueCanUseMageCron();
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function setParentBlock(Mage_Core_Block_Abstract $block)
9
- {
10
- $block
11
- ->getChild('save_button')
12
- ->setOnClick("confirmAndSubmit();");
13
- return parent::setParentBlock($block);
14
- }
15
-
16
- /**
17
- * @see parent
18
- */
19
- public function _afterToHtml($html)
20
- {
21
- $html .= '
22
- <script type="text/javascript">
23
- function confirmAndSubmit() {
24
- var canSubmit = true;
25
- $$("#bronto_support_terms").each(function(elem) {
26
- if (elem.value === "0") {
27
- canSubmit = confirm("You must agree to Bronto\'s Terms of Service in the Registration section. You agree to the Terms by pressing \"OK\".");
28
- if (canSubmit) {
29
- elem.value = "1";
30
- }
31
- }
32
- });
33
- if (canSubmit) {
34
- configForm.submit();
35
- }
36
- }
37
- </script>';
38
- return parent::_afterToHtml($html);
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Coupon.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Coupon extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function render(Varien_Data_Form_Element_Abstract $element)
9
- {
10
- $exampleCode = 'ABC123';
11
- $store = Mage::app()->getStore();
12
- $helper = Mage::helper('bronto_common/coupon');
13
- $comment = $element->getComment();
14
- $comment = str_replace('{baseUrl}', $store->getUrl('/'), $comment);
15
- $comment = str_replace('{code}', $helper->getCouponParam(), $comment);
16
- $comment = str_replace('{example}', $exampleCode, $comment);
17
- $comment = str_replace('{error}', $helper->getErrorCodeParam(), $comment);
18
- $element->setComment($comment);
19
- return parent::render($element);
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
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)
17
- {
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
- }
44
-
45
- return parent::_getElementHtml($element);
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Apitoken.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
-
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)
18
- {
19
- return 'row_' . $element->getId();
20
- }
21
-
22
- /**
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);
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Debug.php DELETED
@@ -1,69 +0,0 @@
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;">
18
- <span class="loader" id="debug-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->__('Collecting Information') . '</span>
19
- </span>
20
- <div id="debug-information-result" style="display:none;margin: 13px 3px 3px 0"></div>
21
- <script>
22
- function collectDebugInformation() {
23
- var collectUrl = "' . $this->getUrl("*/debug/collect") . '";
24
- var debugResult = $("debug-information-result");
25
- debugResult.innerHTML = $("debug-loadingmask").innerHTML;
26
- Element.show(debugResult);
27
-
28
- new Ajax.Request(collectUrl, {
29
- method: "post",
30
- onComplete: function(transport) {
31
- debugResult.innerHTML = "<textarea readonly style=\"width: 480px; height:480px; resize:none;\">" + JSON.stringify(transport.responseJSON, undefined, 4) + "</textarea>";
32
- }
33
- });
34
- }
35
- </script>
36
- ';
37
-
38
- $button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_debug');
39
-
40
- return $button->toHtml() . $script;
41
- }
42
-
43
- /**
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
-
55
- /**
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 DELETED
@@ -1,67 +0,0 @@
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>
19
- function createLogArchive() {
20
- var archiveUrl = "' . $this->getUrl("*/debug/archive") . '";
21
- var archiveResult = $("archive-information-result");
22
- archiveResult.innerHTML = $("archive-loadingmask").innerHTML;
23
- Element.show(archiveResult);
24
-
25
- new Ajax.Request(archiveUrl, {
26
- method: "post",
27
- onComplete: function(transport) {
28
- var response = transport.responseJSON;
29
- archiveResult.innerHTML = "<p>Created archive: <a target=\"_blank\" href=\"" + response.link + "\">" + response.name + "</a></p>";
30
- }
31
- });
32
- }
33
- </script>
34
- ';
35
-
36
- $button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_download');
37
-
38
- return $button->toHtml() . $script;
39
- }
40
-
41
- /**
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
-
53
- /**
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 DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
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)
15
- {
16
- if (!extension_loaded('soap') || !extension_loaded('openssl') || !Mage::helper('bronto_common')->getApiToken()) {
17
- return null;
18
- }
19
-
20
- return parent::render($element);
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Image.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Image extends Bronto_Common_Block_Adminhtml_System_Config_Form_Field
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' => '', 'height' => ''),
17
- 'small_image' => array('width' => '88', 'height' => '77'),
18
- 'thumbnail' => array('width' => '75', 'height' => '75'),
19
- );
20
-
21
- $element->setData('onchange', "defaultImageSize();");
22
- $element->setData('after_element_html', "
23
- <script>
24
- function defaultImageSize() {
25
- var sizes = " . json_encode($defaultSizes) . ";
26
- var size = sizes[$('{$element->getId()}').value];
27
- if (size) {
28
- for (var name in size) {
29
- $('bronto_format_image_' + name).value = size[name];
30
- }
31
- }
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 DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
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)
17
- {
18
- if (!Mage::app()->isSingleStoreMode()) {
19
- $request = Mage::app()->getRequest();
20
- if (!$request->getParam('store') && !$request->getParam('website') && !$request->getParam('group')) {
21
- $element->setCanUseDefaultValue(false)
22
- ->setDisabled('disabled')
23
- ->setValue(null);
24
- }
25
- }
26
-
27
- return parent::_getElementHtml($element);
28
- }
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)
36
- {
37
- if (!Mage::app()->isSingleStoreMode()) {
38
- $request = Mage::app()->getRequest();
39
- if (!$request->getParam('store') && !$request->getParam('website') && !$request->getParam('group')) {
40
- return null;
41
- }
42
- }
43
-
44
- return parent::render($element);
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Support extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- /**
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
-
19
- return parent::_getElementHtml($element);
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support/Site.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Support_Site extends Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Support
4
- {
5
- /**
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
-
27
- return parent::_getElementHtml($element);
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Fieldset.php DELETED
@@ -1,23 +0,0 @@
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;
19
- }
20
-
21
- return parent::_getCollapseState($element);
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Guide.php DELETED
@@ -1,113 +0,0 @@
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_api',
17
- 'bronto_common',
18
- 'bronto_news',
19
- 'bronto_newsletter',
20
- 'bronto_customer',
21
- 'bronto_order',
22
- 'bronto_reminder',
23
- 'bronto_email',
24
- 'bronto_verify',
25
- 'bronto_coupon',
26
- 'bronto_popup',
27
- 'bronto_cartrecovery',
28
- 'bronto_product',
29
- 'bronto_reviews',
30
- );
31
-
32
- /**
33
- * Function to match query section against current section
34
- *
35
- * @param $section
36
- *
37
- * @return bool
38
- */
39
- public function isBrontoSection($section)
40
- {
41
- return $this->getCurrentSection() == $section;
42
- }
43
-
44
- /**
45
- * Get code for child html block based on current section
46
- *
47
- * @return string
48
- */
49
- public function getSectionChildHtml()
50
- {
51
- $section = $this->getCurrentSection();
52
- if (in_array($section, $this->_sections)) {
53
- return $section . '_guide';
54
- }
55
-
56
- return false;
57
- }
58
-
59
- /**
60
- * Get Current section from request params
61
- *
62
- * @return mixed
63
- */
64
- public function getCurrentSection()
65
- {
66
- $section = Mage::app()->getRequest()->getParam('section', false);
67
- if ($section == 'bronto') {
68
- $section = 'bronto_common';
69
- }
70
-
71
- return $section;
72
- }
73
-
74
- /**
75
- * Get Url for Ajax call to toggle displaying guide for current section
76
- *
77
- * @return mixed
78
- */
79
- public function getToggleUrl()
80
- {
81
- return Mage::helper("adminhtml")->getUrl('*/guiders/toggle');
82
- }
83
-
84
- /**
85
- * Determine if guide should be shown
86
- *
87
- * @param bool|string $section
88
- *
89
- * @return bool
90
- */
91
- public function canShowGuide($section = false)
92
- {
93
- if (!$section) {
94
- $section = $this->getCurrentSection();
95
- }
96
-
97
- $canShow = Mage::helper('bronto_common')->getAdminScopedConfig($section . '/guide/display');
98
-
99
- return ($canShow == '0') ? false : true;
100
- }
101
-
102
- /**
103
- * Determine if Currently in Default Scope
104
- *
105
- * @return bool
106
- */
107
- public function isDefaultScope()
108
- {
109
- $scopeParams = Mage::helper('bronto_common')->getScopeParams();
110
-
111
- return ($scopeParams['scope'] == 'default');
112
- }
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Support.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Support extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
- {
5
-
6
- /**
7
- * Prepare layout with help hover
8
- *
9
- * @return Bronto_Common_Block_Adminhtml_System_Config_Support
10
- */
11
- protected function _prepareLayout()
12
- {
13
- if ($head = $this->getLayout()->getBlock('head')) {
14
- $head->addCss('bronto/cron.css');
15
- }
16
-
17
- return parent::_prepareLayout();
18
- }
19
-
20
- /**
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)
28
- {
29
- $helper = Mage::helper('bronto_common/support');
30
-
31
- if (!$helper->isRegistered()) {
32
- return 1;
33
- }
34
-
35
- return parent::_getCollapseState($element);
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Suppressed.php DELETED
@@ -1,80 +0,0 @@
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
- foreach ($element->getSortedElements() as $elem) {
41
- $html .= $elem->toHtml();
42
- }
43
-
44
- $html .= $this->toHtml();
45
- $html .= $this->_getFooterHtml($element);
46
-
47
- return $html;
48
- }
49
-
50
- /**
51
- * Get URL for AJAX call
52
- *
53
- * @return string
54
- */
55
- public function getAjaxUrl()
56
- {
57
- return '';
58
- }
59
-
60
- /**
61
- * Get URL for reset AJAX call
62
- *
63
- * @return string
64
- */
65
- public function getResetUrl()
66
- {
67
- return '';
68
- }
69
-
70
- /**
71
- * The Suppression interface is always collapsed
72
- *
73
- * @param Varien_Data_Form_Element_Abstract $element
74
- * @return bool
75
- */
76
- protected function _getCollapseState($element)
77
- {
78
- return false;
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Suppressed/Reset.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_System_Config_Suppressed_Reset extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract implements Varien_Data_Form_Element_Renderer_Interface
4
- {
5
- /**
6
- * @see parent
7
- */
8
- protected function _setUp()
9
- {
10
- $this->setOnClick('resetAllSuppressed(); return false;');
11
- $this->setClass('delete');
12
- $this->setStyle('margin-bottom: 10px');
13
- }
14
-
15
- /**
16
- * @see parent
17
- */
18
- public function render(Varien_Data_Form_Element_Abstract $element)
19
- {
20
- $this->setLabel($element->getLabel());
21
- return $this->toHtml();
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Abstract.php DELETED
@@ -1,48 +0,0 @@
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 DELETED
@@ -1,16 +0,0 @@
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
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Download.php DELETED
@@ -1,14 +0,0 @@
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/Adminhtml/Widget/Queue/Button/Run.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Adminhtml_Widget_Queue_Button_Run extends Mage_Adminhtml_Block_Widget_Button
4
- {
5
- /**
6
- * @see parent
7
- */
8
- protected function _construct()
9
- {
10
- $this->setLabel('Run Now');
11
- $this->setOnClick("setLocation('" . $this->getRunUrl() . "'); return false;");
12
- $this->setClass('bronto-cron-run');
13
-
14
- if (!Mage::helper('bronto_common/api')->canUseQueue()) {
15
- $this->setDisabled(true)->setClass('disabled');
16
- }
17
- }
18
-
19
- /**
20
- * Get the run url for the API send queue
21
- *
22
- * @return string
23
- */
24
- public function getRunUrl()
25
- {
26
- return $this->getUrl('*/debug/send');
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Cart/Recovery.php DELETED
@@ -1,309 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Block_Cart_Recovery extends Mage_Core_Block_Template
4
- {
5
- private $_quote;
6
- private $_order;
7
- private $_displayOrder = false;
8
- private $_categoryCache = array();
9
-
10
- /**
11
- * Get the Cart Recovery Javascript
12
- *
13
- * @return string
14
- */
15
- public function getCartRecoveryCode()
16
- {
17
- return Mage::helper('bronto_common')->getCartRecoveryCode();
18
- }
19
-
20
- /**
21
- * Get the line item attribute code
22
- *
23
- * @return string
24
- */
25
- public function getLineItemAttributeCode()
26
- {
27
- return Mage::helper('bronto_common')->getLineItemAttributeCode();
28
- }
29
-
30
- /**
31
- * Get the checkout session containing cart and order data
32
- *
33
- * @return Mage_Checkout_Model_Session
34
- */
35
- public function getCheckout()
36
- {
37
- return Mage::getSingleton('checkout/session');
38
- }
39
-
40
- /**
41
- * Gets the checkout url for the cart
42
- *
43
- * @return string
44
- */
45
- public function getCheckoutUrl()
46
- {
47
- $quote = $this->getQuote();
48
- if ($quote) {
49
- $quoteId = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
50
- return Mage::app()->getStore()->getUrl('reminder/load', array('id' => $quoteId));
51
- }
52
- return Mage::app()->getStore()->getUrl('checkout/cart');
53
- }
54
-
55
- /**
56
- * Sets the display order flag
57
- *
58
- * @param $value
59
- */
60
- public function setDisplayOrder($value)
61
- {
62
- $this->_displayOrder = (boolean)((int) $value);
63
- }
64
-
65
- /**
66
- * Gets the cart in the session
67
- *
68
- * @return Mage_Sales_Model_Quote
69
- */
70
- public function getQuote()
71
- {
72
- if (is_null($this->_quote)) {
73
- $this->_quote = false;
74
- if ($this->getCheckout()->hasQuote()) {
75
- $this->_quote = $this->getCheckout()->getQuote();
76
- }
77
- }
78
- return $this->_quote;
79
- }
80
-
81
- /**
82
- * Gets the order that was placed
83
- *
84
- * @return Mage_Sales_Model_Order
85
- */
86
- public function getOrder()
87
- {
88
- if (is_null($this->_order)) {
89
- $this->_order = false;
90
- $orderId = $this->getCheckout()->getLastOrderId();
91
- if ($this->_displayOrder && $orderId) {
92
- $order = Mage::getModel('sales/order')->load($orderId);
93
- if ($order->getId()) {
94
- $this->_order = $order;
95
- }
96
- }
97
- }
98
- return $this->_order;
99
- }
100
-
101
- /**
102
- * Gets the applicable sales object
103
- *
104
- * @return Mage_Sales_Model_Quote | Mage_Sales_Model_Order
105
- */
106
- public function getSalesObject()
107
- {
108
- if ($this->getOrder()) {
109
- return $this->getOrder();
110
- } else if ($this->getQuote() && $this->getQuote()->getId()) {
111
- return $this->getQuote();
112
- } else {
113
- return false;
114
- }
115
- }
116
-
117
- /**
118
- * Formats the categories into reasonable display names
119
- *
120
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
121
- * @return string
122
- */
123
- public function renderCategories($lineItem)
124
- {
125
- $categories = array();
126
- $product = $this->getProduct($lineItem);
127
- foreach ($product->getCategoryIds() as $categoryId) {
128
- if (isset($this->_categoryCache[$categoryId])) {
129
- $category = $this->_categoryCache[$categoryId];
130
- } else {
131
- $category = Mage::getModel('catalog/category')->load($categoryId);
132
- $this->_categoryCache[$categoryId] = $category;
133
- }
134
- $parent = $category->getParentCategory();
135
- $categories[] = $parent->getUrlKey() ?
136
- $parent->getUrlKey() :
137
- $parent->formatUrlKey($parent->getName());
138
- $categories[] = $category->getUrlKey() ?
139
- $category->getUrlKey() :
140
- $category->formatUrlKey($category->getName());
141
- }
142
- $categories = array_unique($categories);
143
- return implode(' ', $categories);
144
- }
145
-
146
- /**
147
- * Gets the product associated with this line item
148
- *
149
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
150
- * @return Mage_Catalog_Model_Product
151
- */
152
- private function getProduct($lineItem, $includeParent = true)
153
- {
154
- return Mage::helper('bronto_common/item')->getProduct($lineItem, $includeParent);
155
- }
156
-
157
- private function getParentItem($lineItem)
158
- {
159
- return Mage::helper('bronto_common/item')->getParentItem($lineItem);
160
- }
161
-
162
- public function getName($lineItem)
163
- {
164
- return Mage::helper('bronto_common/item')->getName($lineItem);
165
- }
166
-
167
- /**
168
- * Gets the product description
169
- *
170
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
171
- * @return string
172
- */
173
- public function getDescription($lineItem)
174
- {
175
- return $this->getProduct($lineItem)->getDescription();
176
- }
177
-
178
- /**
179
- * Gets the product url for a given line item
180
- *
181
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
182
- * @return string
183
- */
184
- public function getProductUrl($lineItem)
185
- {
186
- return Mage::helper('bronto_common/item')->getProductUrl($lineItem);
187
- }
188
-
189
- /**
190
- * Gets the other attribute value
191
- *
192
- * @return mixed
193
- */
194
- public function getOther($lineItem)
195
- {
196
- $product = $this->getProduct($lineItem, false);
197
- $attributeCode = $this->getLineItemAttributeCode();
198
- if ($attributeCode) {
199
- $attributeValue = $product->getData($attributeCode);
200
- if (!is_null($attributeValue)) {
201
- $attribute = $product->getResource()->getAttribute($attributeCode);
202
- if ($attribute->getFrontendInput() == 'select') {
203
- return $attribute->getSource()->getOptionText($attributeValue);
204
- }
205
- return $attributeValue;
206
- }
207
- }
208
- return '';
209
- }
210
-
211
- /**
212
- * Gets the product image url
213
- *
214
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
215
- * @return string
216
- */
217
- public function getImage($lineItem)
218
- {
219
- return Mage::helper('bronto_common/item')->getImage($lineItem);
220
- }
221
-
222
- /**
223
- * Gets the qty of the lineItem
224
- *
225
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
226
- * @return float
227
- */
228
- public function getQty($lineItem)
229
- {
230
- return Mage::helper('bronto_common/item')->getQty($lineItem);
231
- }
232
-
233
- /**
234
- * Gets the discount amount for the cart container
235
- *
236
- * @return float
237
- */
238
- public function getDiscountAmount()
239
- {
240
- $object = $this->getSalesObject();
241
- if ($object instanceof Mage_Sales_Model_Quote) {
242
- return $object->getSubtotal() - $object->getSubtotalWithDiscount();
243
- } else {
244
- return $object->getDiscountAmount();
245
- }
246
- }
247
-
248
- public function getFlatItems()
249
- {
250
- return Mage::helper('bronto_common/item')->getFlatItems($this->getSalesObject());
251
- }
252
-
253
- /**
254
- * Gets parent item's unit price
255
- *
256
- * @param mixed
257
- * @return float
258
- */
259
- public function getOriginalPrice($lineItem)
260
- {
261
- return $this->getParentItem($lineItem)->getOriginalPrice();
262
- }
263
-
264
- /**
265
- * Gets parent item's price
266
- *
267
- * @param mixed
268
- * @return float
269
- */
270
- public function getPrice($lineItem)
271
- {
272
- return $this->getParentItem($lineItem)->getPrice();
273
- }
274
-
275
- /**
276
- * Gets parent item's rowtotal
277
- *
278
- * @param mixed
279
- * @return float
280
- */
281
- public function getRowTotal($lineItem)
282
- {
283
- return $this->getParentItem($lineItem)->getRowTotal();
284
- }
285
-
286
- /**
287
- * Should the block even write the code?
288
- *
289
- * @return boolean
290
- */
291
- public function shouldWriteDom()
292
- {
293
- return ($this->getCartRecoveryCode() && $this->getSalesObject());
294
- }
295
-
296
- /**
297
- * Gets the current code for the sales object
298
- *
299
- * @return string
300
- */
301
- public function getCurrencyCode()
302
- {
303
- if ($this->getOrder()) {
304
- return $this->getOrder()->getOrderCurrencyCode();
305
- } else {
306
- return $this->getQuote()->getQuoteCurrencyCode();
307
- }
308
- }
309
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Block/Popup.php DELETED
@@ -1,29 +0,0 @@
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
-
19
- /**
20
- * Gets the Pop-up submission URL
21
- *
22
- * @return string
23
- */
24
- public function getPopupSubmitUrl()
25
- {
26
- $store = Mage::app()->getStore();
27
- return Mage::getUrl('btnewsletter/index/submit', array('_secure' => $store->isCurrentlySecure()));
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Api.php DELETED
@@ -1,287 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Helper_Api extends Bronto_Common_Helper_Data
4
- {
5
- const XML_PATH_ENABLED = 'bronto_api/settings/enabled';
6
- const XML_PATH_MAGE_CRON = 'bronto_api/settings/mage_cron';
7
- const XML_PATH_ATTEMPT_THRES = 'bronto_api/settings/threshold';
8
- const XML_PATH_TIME = 'bronto_api/settings/time';
9
- const XML_PATH_INTERVAL = 'bronto_api/settings/interval';
10
- const XML_PATH_FREQUENCY = 'bronto_api/settings/frequency';
11
- const XML_PATH_FREQUENCY_MIN = 'bronto_api/settings/minutes';
12
- const XML_PATH_ERROR_THRES = 'bronto_api/setting/limit';
13
-
14
-
15
- const XML_PATH_QUEUE_ENABLED = 'bronto_api/queue_settings/enabled';
16
- const XML_PATH_QUEUE_MAGE_CRON = 'bronto_api/queue_settings/mage_cron';
17
- const XML_PATH_QUEUE_LIMIT = 'bronto_api/queue_settings/limit';
18
- const XML_PATH_QUEUE_TIME = 'bronto_api/queue_settings/time';
19
- const XML_PATH_QUEUE_INTERVAL = 'bronto_api/queue_settings/interval';
20
- const XML_PATH_QUEUE_FREQUENCY = 'bronto_api/queue_settings/frequency';
21
- const XML_PATH_QUEUE_FREQUENCY_MIN = 'bronto_api/queue_settings/minutes';
22
-
23
- const XML_PATH_SOAP_CLIENT = 'bronto_api/soap_options/soap_client';
24
- const XML_PATH_API_RETRYER = 'bronto_api/soap_options/retryer';
25
- const XML_PATH_SOAP_STREAM_CONTEXT = 'bronto_api/soap_options/stream_context';
26
- const XML_PATH_SOAP_RETRY_LIMIT = 'bronto_api/soap_options/retry_limit';
27
- const XML_PATH_SOAP_CONNECTION_TIMEOUT = 'bronto_api/soap_options/connection_timeout';
28
- const XML_PATH_SOAP_TRACE = 'bronto_api/soap_options/trace';
29
- const XML_PATH_SOAP_EXCEPTIONS = 'bronto_api/soap_options/exceptions';
30
- const XML_PATH_WSDL_CACHE = 'bronto_api/soap_options/wsdl_cache';
31
-
32
- const DEFAULT_SOAP_CLIENT = 'SoapClient';
33
- const DEFAULT_OLD_SOAP_CLIENT = 'Bronto_SoapClient';
34
-
35
- /**
36
- * Gets the Canonical name of the helper
37
- *
38
- * @return string
39
- */
40
- public function getName()
41
- {
42
- return $this->__('Bronto API Retry');
43
- }
44
-
45
- /**
46
- * Gets the Canonical name of the Send Queue
47
- *
48
- * @return string
49
- */
50
- public function getSendName()
51
- {
52
- return $this->__('Bronto Send Queue');
53
- }
54
-
55
- /**
56
- * Checks if the api retryer is enabled
57
- *
58
- * @return bool
59
- */
60
- public function isEnabled($scope = 'default', $scopeId = 0)
61
- {
62
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_ENABLED);
63
- }
64
-
65
- /**
66
- * @see parent
67
- */
68
- public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
69
- {
70
- return (
71
- $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig) &&
72
- $this->_disableModule(self::XML_PATH_QUEUE_ENABLED, $scope, $scopeId, $deleteConfig)
73
- );
74
- }
75
-
76
- /**
77
- * Checked if the send queue is enabled
78
- *
79
- * @param string $scope
80
- * @param int $scopeId
81
- * @return bool
82
- */
83
- public function canUseQueue($scope = 'default', $scopeId = 0)
84
- {
85
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_QUEUE_ENABLED, $scope, $scopeId);
86
- }
87
-
88
- /**
89
- * Check if the cron is magento
90
- *
91
- * @param string $scope
92
- * @param int $scopeId
93
- * @return bool
94
- */
95
- public function queueCanUseMageCron($scope = 'default', $scopeId = 0)
96
- {
97
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_QUEUE_MAGE_CRON, $scope, $scopeId);
98
- }
99
-
100
- /**
101
- * Gets the send queue threshold
102
- *
103
- * @param string $scope
104
- * @param int $scopeId
105
- * @return int
106
- */
107
- public function getSendLimit($scope = 'default', $scopeId = 0)
108
- {
109
- return (int) $this->getAdminScopedConfig(self::XML_PATH_QUEUE_LIMIT, $scope, $scopeId);
110
- }
111
-
112
- /**
113
- * Gets the entries whose attempts are less than this amount
114
- *
115
- * @return int
116
- */
117
- public function getAttemptThreshold()
118
- {
119
- return (int) $this->getAdminScopedConfig(self::XML_PATH_ATTEMPT_THRES);
120
- }
121
-
122
- /**
123
- * Gets the number of error entries to process
124
- *
125
- * @return int
126
- */
127
- public function getErrorThreshold()
128
- {
129
- return (int) $this->getAdminScopedConfig(self::XML_PATH_ERROR_THRES);
130
- }
131
-
132
- /**
133
- * Whether or not to use Magento cron
134
- *
135
- * @return bool
136
- */
137
- public function canUseMageCron()
138
- {
139
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
140
- }
141
-
142
- /**
143
- * Get SOAP Options
144
- *
145
- * @return array
146
- */
147
- public function getSoapOptions()
148
- {
149
- // Return Default Options
150
- return array(
151
- 'soapClass' => $this->getSoapClient(),
152
- 'observer' => $this->getApiObserver(),
153
- 'retries' => $this->getSoapRetryLimit(),
154
- 'retryer' => $this->getApiRetryer(),
155
- 'soapOptions' => array(
156
- 'connection_timeout' => $this->getSoapConnectionTimeout(),
157
- 'trace' => $this->getSoapTrace() || $this->isVerboseEnabled(),
158
- 'exceptions' => $this->getSoapExceptions(),
159
- 'cache_wsdl' => $this->getSoapCacheWsdl()
160
- )
161
- );
162
- }
163
-
164
- /**
165
- * Gets the class name for the retryer
166
- *
167
- * @return string
168
- */
169
- public function getApiRetryer()
170
- {
171
- $class = $this->getAdminScopedConfig(self::XML_PATH_API_RETRYER);
172
- if (!empty($class) && class_exists($class)) {
173
- return Mage::getModel('bronto_common/error');
174
- }
175
- return '';
176
- }
177
-
178
- /**
179
- * Override the Bronto_SoapCLient class name
180
- *
181
- * @return string
182
- */
183
- public function getSoapClient()
184
- {
185
- $class = $this->getAdminScopedConfig(self::XML_PATH_SOAP_CLIENT);
186
- if (empty($class) || $class == self::DEFAULT_OLD_SOAP_CLIENT || !class_exists($class)) {
187
- $class = self::DEFAULT_SOAP_CLIENT;
188
- }
189
- return $class;
190
- }
191
-
192
- /**
193
- * Overrides the Bronto_Observer use in Bronto_Api
194
- *
195
- * @return string
196
- */
197
- public function getApiObserver()
198
- {
199
- return '';
200
- }
201
-
202
- /**
203
- * Override the default Soap client with the stream context override
204
- *
205
- * @return bool
206
- */
207
- public function isStreamContextOverride()
208
- {
209
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_SOAP_STREAM_CONTEXT);
210
- }
211
-
212
- /**
213
- * Turn on stream context override
214
- *
215
- * @param bool $state
216
- * @return Bronto_Common_Helper_Api
217
- */
218
- public function setStreamContext($state)
219
- {
220
- $config = Mage::getModel('core/config');
221
- $config->saveConfig(self::XML_PATH_SOAP_STREAM_CONTEXT, $state ? '1' : '0', 'default', 0);
222
-
223
- Mage::getConfig()->reinit();
224
- Mage::app()->reinitStores();
225
- return $this;
226
- }
227
-
228
- /**
229
- * Get Config Value for SOAP Retry Limit
230
- *
231
- * @return int
232
- */
233
- public function getSoapRetryLimit()
234
- {
235
- return (int)$this->getAdminScopedConfig(self::XML_PATH_SOAP_RETRY_LIMIT);
236
- }
237
-
238
- /**
239
- * Get Config Value for SOAP Connection Timeout
240
- *
241
- * @return int
242
- */
243
- public function getSoapConnectionTimeout()
244
- {
245
- return (int)$this->getAdminScopedConfig(self::XML_PATH_SOAP_CONNECTION_TIMEOUT);
246
- }
247
-
248
- /**
249
- * Get Config Value for SOAP Trace
250
- *
251
- * @return bool
252
- */
253
- public function getSoapTrace()
254
- {
255
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_SOAP_TRACE) == '1';
256
- }
257
-
258
- /**
259
- * Get Config Value for SOAP Exceptions
260
- *
261
- * @return bool
262
- */
263
- public function getSoapExceptions()
264
- {
265
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_SOAP_EXCEPTIONS) == '1';
266
- }
267
-
268
- /**
269
- * @return string
270
- */
271
- public function getSoapCacheWsdl()
272
- {
273
- $cacheWsdl = $this->getAdminScopedConfig(self::XML_PATH_WSDL_CACHE);
274
- switch ($cacheWsdl) {
275
- case 'WSDL_CACHE_NONE':
276
- return WSDL_CACHE_NONE;
277
- case 'WSDL_CACHE_DISK':
278
- return WSDL_CACHE_DISK;
279
- case 'WSDL_CACHE_MEMORY':
280
- return WSDL_CACHE_MEMORY;
281
- case 'WSDL_CACHE_BOTH':
282
- default:
283
- return WSDL_CACHE_BOTH;
284
- }
285
- }
286
-
287
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Contact.php DELETED
@@ -1,134 +0,0 @@
1
- <?php
2
-
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)
17
- {
18
- if (empty($email)) {
19
- return false;
20
- }
21
-
22
- $api = $this->getApi(null, 'store', $store);
23
- $contacts = $api->transferContact();
24
- try {
25
- $contact = $contacts->read()
26
- ->withIncludeLists(true)
27
- ->where->email->equalTo($email)
28
- ->first();
29
- if (!is_null($contact)) {
30
- return $contact;
31
- }
32
- } catch (Exception $e) {
33
- $this->writeError('Failed to read contact ' . $email . ': ' . $e->getMessage());
34
- }
35
- return $contacts->createObject()
36
- ->withEmail($email)
37
- ->withCustomSource($customSource);
38
- }
39
-
40
- /**
41
- * A more efficient way to read multiple emails from Bronto
42
- *
43
- * @param array $emails
44
- * @param string $customSource (Optiona)
45
- * @param int $store (Optional)
46
- * @param bool $createNonExistent (Optional)
47
- *
48
- * @return array Bronto_Api_Contact_Row
49
- */
50
- public function getContactsByEmail($emails, $customSource = null, $store = null, $createNonExistent = false)
51
- {
52
- if (empty($emails)) {
53
- return false;
54
- }
55
-
56
- $api = $this->getApi(null, 'store', $store);
57
- $contactObject = $api->transferContact();
58
- $readContacts = $contactObject->read();
59
- foreach ($emails as $email) {
60
- $readContacts->or->email->equalTo($email);
61
- }
62
- $results = $readContacts->getIterator()->toArray();
63
- if (count($results) != count($emails)) {
64
- $contacts = array();
65
- foreach ($results as $contact) {
66
- $contacts[$contact->getEmail()] = $contact;
67
- }
68
-
69
- $newContacts = array();
70
- foreach ($emails as $email) {
71
- if (!isset($contacts[$email])) {
72
- $contact = $contactObject->createObject()
73
- ->withEmail($email)
74
- ->withStatus('transactional')
75
- ->withCustomSource($customSource);
76
- $newContacts[] = $contact;
77
- }
78
- }
79
-
80
- if ($createNonExistent) {
81
- return array_merge($contacts, $this->saveContacts($contactObject, $newContacts));
82
- } else {
83
- return array_merge($contacts, $newContacts);
84
- }
85
- } else {
86
- return $results;
87
- }
88
- }
89
-
90
- /**
91
- * More efficient way add saving multiple contacts
92
- *
93
- * @param array Bronto_Api_Contact_Row
94
- * @return array Bronto_Api_Contact_Row
95
- */
96
- public function saveContacts($contactObject, $contacts)
97
- {
98
- if (empty($contacts)) {
99
- return $contacts;
100
- }
101
- try {
102
- $newContacts = array();
103
- foreach ($contactObject->addOrUpdate()->push($contacts) as $result) {
104
- $item = $result->getItem();
105
- $contact = $result->getOriginal();
106
- if ($item->getIsError()) {
107
- $this->writeError("Failed to create contact {$contact->getEmail()}: ({$item->getErrorCode()}): {$item->getErrorString()}");
108
- $contact->withError($item->getErrorMessage());
109
- } else {
110
- $contact->withId($item->getId());
111
- }
112
- $newContacts[] = $contact;
113
- }
114
- return $newContacts;
115
- } catch (Exception $e) {
116
- $this->writeError($e);
117
- }
118
- $this->_flushApiLogs($contactObject->getApi());
119
- return $contacts;
120
- }
121
-
122
- /**
123
- * Writes the contact save logs
124
- *
125
- * @param Bronto_Api $api
126
- * @return void
127
- */
128
- protected function _flushApiLogs($api)
129
- {
130
- $this->writeVerboseDebug('===== CONTACT SAVE =====', 'bronto_common_api.log');
131
- $this->writeVerboseDebug(var_export($api->getLastRequest(), true), 'bronto_common_api.log');
132
- $this->writeVerboseDebug(var_export($api->getLastResponse(), true), 'bronto_common_api.log');
133
- }
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Coupon.php DELETED
@@ -1,327 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Helper_Coupon extends Bronto_Common_Helper_Data
4
- {
5
-
6
- const XML_PATH_ENABLED = 'bronto_coupon/apply_coupon/enabled';
7
- const XML_PATH_SUCCESS_MESSAGE = 'bronto_coupon/apply_coupon/success_message';
8
- const XML_PATH_COUPON_PARAM = 'bronto_coupon/apply_coupon/coupon_code_param';
9
- const XML_PATH_ERROR_PARAM = 'bronto_coupon/apply_coupon/error_message_param';
10
- const XML_PATH_LINK_MESSAGE = 'bronto_coupon/apply_coupon/link';
11
- const XML_PATH_USES_OBSERVER = 'bronto_coupon/apply_coupon/use_observer';
12
-
13
- const INVALID_CODE = 'invalid';
14
- const DEPLETED_CODE = 'depleted';
15
- const EXPIRED_CODE = 'expired';
16
- const CONFLICT_CODE = 'conflict';
17
- const FORCE_PARAM = '___force_code';
18
-
19
- protected $_validCodes = array(
20
- self::INVALID_CODE => 'translateCode',
21
- self::EXPIRED_CODE => 'translateCode',
22
- self::DEPLETED_CODE => 'translateCode',
23
- self::CONFLICT_CODE => 'translateConflict'
24
- );
25
-
26
- /**
27
- * Gets the display name for the coupon module
28
- *
29
- * @return string
30
- */
31
- public function getName()
32
- {
33
- return $this->__('Bronto Coupon Management');
34
- }
35
-
36
- /**
37
- * Is this module enabled
38
- *
39
- * @param string $scope
40
- * @param int $scopeId
41
- * @return boolean
42
- */
43
- public function isEnabled($scope = 'default', $scopeId = 0)
44
- {
45
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
46
- }
47
-
48
- /**
49
- * Disable Module for Specified Scope
50
- *
51
- * @param string $scope
52
- * @param int $scopeId
53
- * @param bool $deleteConfig
54
- *
55
- * @return bool
56
- */
57
- public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
58
- {
59
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
60
- }
61
-
62
- /**
63
- * Determines if the supplied code is a valid one
64
- *
65
- * @param string $code
66
- * @return boolean
67
- */
68
- public function isValidErrorCode($code)
69
- {
70
- return array_key_exists($code, $this->_validCodes);
71
- }
72
-
73
- /**
74
- * Gets the coupon code param used to parse out of the URL
75
- *
76
- * @param string $scope
77
- * @param int $scopeId
78
- * @return string
79
- */
80
- public function getCouponParam($scope = 'default', $scopeId = 0)
81
- {
82
- return $this->getAdminScopedConfig(self::XML_PATH_COUPON_PARAM, $scope, $scopeId);
83
- }
84
-
85
- /**
86
- * Gets the error code param used to parse out of the URL
87
- *
88
- * @param string $scope
89
- * @param int $scopeId
90
- * @return string
91
- */
92
- public function getErrorCodeParam($scope = 'default', $scopeId = 0)
93
- {
94
- return $this->getAdminScopedConfig(self::XML_PATH_ERROR_PARAM, $scope, $scopeId);
95
- }
96
-
97
- /**
98
- * Gets both params used in the settings
99
- *
100
- * @param string $scope
101
- * @param int $scopeId
102
- * @return array
103
- */
104
- public function getParams($scope = 'default', $scopeId = 0)
105
- {
106
- return array(
107
- $this->getCouponParam($scope, $scopeId),
108
- $this->getErrorCodeParam($scope, $scopeId)
109
- );
110
- }
111
-
112
- /**
113
- * Gets the error code message from the configuration scope
114
- *
115
- * @param string $errorCode
116
- * @param string $couponCode
117
- * @param string $scope
118
- * @param int $scopeId
119
- * @return string
120
- */
121
- public function getErrorMessage($errorCode, $couponCode, $scope = 'default', $scopeId = 0)
122
- {
123
- $baseMessage = $this->getAdminScopedConfig('bronto_coupon/apply_coupon/' . $errorCode, $scope, $scopeId);
124
- $translateCallback = $this->_validCodes[$errorCode];
125
- return $this->$translateCallback($baseMessage, empty($couponCode) ? 'code' : $couponCode);
126
- }
127
-
128
- /**
129
- * Gets the the success message
130
- *
131
- * @param string $couponCode
132
- * @param string $scope
133
- * @param int $scopeId
134
- * @return string
135
- */
136
- public function getSuccessMessage($couponCode, $scope = 'default', $scopeId = 0)
137
- {
138
- return $this->translateCode($this->getAdminScopedConfig(self::XML_PATH_SUCCESS_MESSAGE, $scope, $scopeId), $couponCode);
139
- }
140
-
141
- /**
142
- * Gets the link message content
143
- *
144
- * @param string $scope
145
- * @param int $scopeId
146
- * @return string
147
- */
148
- public function getLinkContent($scope = 'default', $scopeId = 0)
149
- {
150
- return $this->getAdminScopedConfig(self::XML_PATH_LINK_MESSAGE, $scope, $scopeId);
151
- }
152
-
153
- /**
154
- * Uses a controller observer
155
- *
156
- * @param string $scope
157
- * @param int $scopeId
158
- * @return boolean
159
- */
160
- public function isObservingController($scope = 'default', $scopeId = 0)
161
- {
162
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_USES_OBSERVER, $scope, $scopeId);
163
- }
164
-
165
- /**
166
- * Translate a message using the coupon code
167
- *
168
- * @param string $message
169
- * @param string $couponCode
170
- * @param string $key
171
- * @return string
172
- */
173
- public function translateCode($message, $couponCode, $key = 'code')
174
- {
175
- return str_replace('{' . $key . '}', $couponCode, $message);
176
- }
177
-
178
- /**
179
- * Translate the conflict message
180
- *
181
- * @param string $message
182
- * @param string $couponCode
183
- * @return string
184
- */
185
- public function translateConflict($message, $couponCode)
186
- {
187
- $couponParam = $this->getCouponParam();
188
- $forceUrl = Mage::app()->getStore()->getUrl('*/*/*', array(
189
- $couponParam => $couponCode,
190
- self::FORCE_PARAM => 1,
191
- ));
192
- $quote = Mage::getSingleton('checkout/cart')->getQuote();
193
- $linkContent = $this->getLinkContent();
194
- $replacements = array(
195
- 'link' => '<a href="' . $forceUrl . '">' . $linkContent . '</a>',
196
- 'oldCode' => $quote->getCouponCode(),
197
- 'newCode' => $couponCode,
198
- );
199
- foreach ($replacements as $key => $value) {
200
- $message = str_replace('{' . $key . '}', $value, $message);
201
- }
202
- return $message;
203
- }
204
-
205
- /**
206
- * Sets the coupon code either in the session or on the quote
207
- *
208
- * @param int $ruleId
209
- * @param string $couponCode
210
- */
211
- public function applyCode($ruleId = null, $couponCode = null)
212
- {
213
- $session = Mage::getSingleton('core/session');
214
- if (is_null($couponCode)) {
215
- $couponCode = $session->getCouponCode();
216
- $ruleId = $session->getRuleId();
217
- } else {
218
- $session->setCouponCode($couponCode);
219
- $session->setRuleId($ruleId);
220
- }
221
- $quote = Mage::getSingleton('checkout/cart')->getQuote();
222
- if ($quote && $couponCode) {
223
- $quote->setCouponCode($couponCode)->save();
224
- if ($this->_isRuleApplied($ruleId)) {
225
- $session->unsCouponCode($couponCode);
226
- $session->unsRuleId($ruleId);
227
- }
228
- }
229
- }
230
-
231
- /**
232
- * Validates the coupon code given certain high level constraints
233
- *
234
- * @param string $couponCode
235
- * @param boolean $force
236
- * @return Mage_Salesrule_Model_Coupon
237
- */
238
- protected function _validateCode($couponCode, $force = false)
239
- {
240
- $websiteId = Mage::app()->getWebsite()->getId();
241
- $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
242
- $rules = Mage::getModel('salesrule/rule')
243
- ->getCollection()
244
- ->setValidationFilter($websiteId, $customerGroupId, $couponCode)
245
- ->addFieldToFilter('main_table.coupon_type', array('in' => array(Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO)));
246
- foreach ($rules as $rule) {
247
- $coupon = Mage::getModel('salesrule/coupon')->loadByCode($couponCode);
248
- if ($coupon->getUsageLimit() && $coupon->getTimesUsed() >= $coupon->getUsageLimit()) {
249
- Mage::throwException('depleted');
250
- }
251
- $quote = Mage::getSingleton('checkout/cart')->getQuote();
252
- if ($quote) {
253
- if (!$force && $quote->getCouponCode() && $quote->getCouponCode() != $couponCode) {
254
- Mage::throwException('conflict');
255
- }
256
- }
257
- return $coupon;
258
- }
259
- Mage::throwException('invalid');
260
- }
261
-
262
- /**
263
- * Takes in an HTTP request and applies the code
264
- *
265
- * @param Mage_Core_Controller_Request_Http $request
266
- * @return boolean
267
- */
268
- public function applyCodeFromRequest($request)
269
- {
270
- list($couponParam, $errorParam) = $this->getParams();
271
- $session = Mage::getSingleton('core/session');
272
- $errorCode = $request->getParam($errorParam, null);
273
- $couponCode = $request->getParam($couponParam, null);
274
- if ($errorCode || $couponCode) {
275
- if (!empty($couponCode)) {
276
- $force = $request->has(self::FORCE_PARAM);
277
- try {
278
- $coupon = $this->_validateCode($couponCode, $force);
279
- if (!$this->isCouponApplied($coupon->getRuleId(), $couponCode)) {
280
- $this->applyCode($coupon->getRuleId(), $couponCode);
281
- $session->addSuccess($this->getSuccessMessage($couponCode));
282
- }
283
- return true;
284
- } catch (Exception $e) {
285
- $errorCode = $e->getMessage();
286
- }
287
- }
288
- if (!$this->isValidErrorCode($errorCode)) {
289
- $errorCode = self::INVALID_CODE;
290
- }
291
- $session->addError($this->getErrorMessage($errorCode, $couponCode));
292
- }
293
- return false;
294
- }
295
-
296
- /**
297
- * Internal method to determine if the rule was applied to a quote in the
298
- * session
299
- *
300
- * @param int $ruleId
301
- * @return boolean
302
- */
303
- private function _isRuleApplied($ruleId)
304
- {
305
- $quote = Mage::getSingleton('checkout/cart')->getQuote();
306
- if ($quote) {
307
- return in_array($ruleId, explode(',', $quote->getAppliedRuleIds()));
308
- }
309
- return false;
310
- }
311
-
312
- /**
313
- * Has this coupon already been applied
314
- *
315
- * @param int $ruleId
316
- * @param string $couponCode
317
- * @return boolean
318
- */
319
- public function isCouponApplied($ruleId, $couponCode)
320
- {
321
- $session = Mage::getSingleton('core/session');
322
- if ($session->getCouponCode() == $couponCode) {
323
- return true;
324
- }
325
- return $this->_isRuleApplied($ruleId);
326
- }
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Data.php DELETED
@@ -1,1243 +0,0 @@
1
- <?php
2
-
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
- const MAX_TOKEN_LENGTH = 36;
11
-
12
- /**
13
- * Common Settings
14
- */
15
- const XML_PATH_GLOBAL_SETTINGS = 'bronto/settings/';
16
- const XML_PATH_API_TOKEN = 'bronto/settings/api_token';
17
- const XML_PATH_DEBUG = 'bronto/settings/debug';
18
- const XML_PATH_VERBOSE = 'bronto/settings/verbose';
19
- const XML_PATH_TEST = 'bronto/settings/test';
20
- const XML_PATH_NOTICES = 'bronto/settings/notices';
21
- const XML_PATH_ENABLED = 'bronto/settings/enabled';
22
- const XML_PATH_TABLE_RUN = 'bronto/settings/fix_script';
23
-
24
- /**
25
- * Formatting Settings
26
- */
27
- const XML_PATH_IMAGE_TYPE = 'bronto/format/image_type';
28
- const XML_PATH_IMAGE_WIDTH = 'bronto/format/image_width';
29
- const XML_PATH_IMAGE_HEIGHT = 'bronto/format/image_height';
30
- const XML_PATH_USE_SYMBOL = 'bronto/format/use_symbol';
31
- const XML_PATH_INCL_TAX = 'bronto/format/incl_tax';
32
- const XML_PATH_GREETING_FULL = 'bronto/format/default_greeting';
33
- const XML_PATH_GREETING_PRE = 'bronto/format/default_greeting_prefix';
34
- const XML_PATH_GREETING_FIRST = 'bronto/format/default_greeting_firstname';
35
- const XML_PATH_GREETING_LAST = 'bronto/format/default_greeting_lastname';
36
-
37
- /**
38
- * Cron Settings
39
- */
40
- const XML_PATH_MAGE_CRON = 'bronto/settings/mage_cron';
41
- const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_common_delete_archives/schedule/cron_expr';
42
- const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_common_delete_archives/run/model';
43
-
44
- /**
45
- * Pop-up Settings
46
- */
47
- const XML_PATH_POPUP_CODE = 'bronto_popup/settings/code';
48
- const XML_PATH_POPUP_SUBSCRIBE = 'bronto_popup/settings/subscribe';
49
-
50
- /**
51
- * Coupon Settings
52
- */
53
- const XML_PATH_COUPON_SITE_HASH = 'bronto_coupon/settings/site_hash';
54
-
55
- /**
56
- * Cart Recovery
57
- */
58
- const XML_PATH_CART_RECOVERY_CODE = 'bronto_cartrecovery/settings/code';
59
- const XML_PATH_CART_RECOVERY_OTHER = 'bronto_cartrecovery/settings/other';
60
-
61
- /**
62
- * Module Human Readable Name
63
- */
64
- protected $_name = 'Bronto Extension for Magento';
65
-
66
- /**
67
- * Get Human Readable Name
68
- *
69
- * @return string
70
- */
71
- public function getName()
72
- {
73
- return $this->__($this->_name);
74
- }
75
-
76
- /**
77
- * Check if module is enabled
78
- *
79
- * @param string $scope
80
- * @param int $scopeId
81
- *
82
- * @return bool
83
- */
84
- public function isEnabled($scope = 'default', $scopeId = 0)
85
- {
86
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
87
- }
88
-
89
- /*
90
- * Get Text to display in notice when enabling module
91
- *
92
- * @return string
93
- */
94
- public function getModuleEnabledText()
95
- {
96
- return $this->__('If you have changed your API token, please ensure you reconfigure all available options.');
97
- }
98
-
99
- /**
100
- * Determines if the last time the table schema scan was a previous version
101
- *
102
- * @return bool
103
- */
104
- public function shouldRunFixScript()
105
- {
106
- return $this->getModuleVersion() != $this->getAdminScopedConfig(
107
- self::XML_PATH_TABLE_RUN,
108
- 'default', $scopeId = 0);
109
- }
110
-
111
- /**
112
- * Get Javascript for Pop-up
113
- *
114
- * @return string
115
- */
116
- public function getPopupCode()
117
- {
118
- return $this->getAdminScopedConfig(self::XML_PATH_POPUP_CODE);
119
- }
120
-
121
- /**
122
- * Can the user be subscribed to magento?
123
- *
124
- * @return bool
125
- */
126
- public function isSubscribeToMagento()
127
- {
128
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_POPUP_SUBSCRIBE);
129
- }
130
-
131
- /**
132
- * Get Site has for the coupon redemption code
133
- *
134
- * @return string
135
- */
136
- public function getCouponSiteHash()
137
- {
138
- return $this->getAdminScopedConfig(self::XML_PATH_COUPON_SITE_HASH);
139
- }
140
-
141
- /**
142
- * Get the Cart Recovery code for the account
143
- *
144
- * @return string
145
- */
146
- public function getCartRecoveryCode()
147
- {
148
- return $this->getAdminScopedConfig(self::XML_PATH_CART_RECOVERY_CODE);
149
- }
150
-
151
- /**
152
- * Get the Cart Recovery other line item attribute code
153
- *
154
- * @return string
155
- */
156
- public function getLineItemAttributeCode()
157
- {
158
- return $this->getAdminScopedConfig(self::XML_PATH_CART_RECOVERY_OTHER);
159
- }
160
-
161
- /**
162
- * Determine if email can be sent through bronto
163
- *
164
- * @param Mage_Core_Model_Email_Template $template
165
- * @param string|int $storeId
166
- *
167
- * @return boolean
168
- */
169
- public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
170
- {
171
- if ($this->isEnabled('store', $storeId)) {
172
- return true;
173
- }
174
-
175
- return false;
176
- }
177
-
178
- /**
179
- * Get Image URL for Product, sized to config specs
180
- *
181
- * @param Mage_Catalog_Model_Product $product
182
- *
183
- * @return string
184
- */
185
- public function getProductImageUrl($product)
186
- {
187
- try {
188
- return (string)Mage::helper('catalog/image')
189
- ->init($product, $this->getImageType($product->getStoreId()))
190
- ->resize(
191
- $this->getImageWidth($product->getStoreId()),
192
- $this->getImageHeight($product->getStoreId())
193
- );
194
- } catch (Exception $e) {
195
- return '';
196
- }
197
- }
198
-
199
- /**
200
- * @param string|int $storeId
201
- *
202
- * @return string
203
- */
204
- public function getImageType($storeId = null)
205
- {
206
- return $this->getAdminScopedConfig(self::XML_PATH_IMAGE_TYPE, 'store', $storeId);
207
- }
208
-
209
- /**
210
- * @param string|int $storeId
211
- *
212
- * @return int|null
213
- */
214
- public function getImageWidth($storeId = null)
215
- {
216
- $width = (int)$this->getAdminScopedConfig(self::XML_PATH_IMAGE_WIDTH, 'store', $storeId);
217
-
218
- return empty($width) ? null : abs($width);
219
- }
220
-
221
- /**
222
- * @param string|int $storeId
223
- *
224
- * @return int|null
225
- */
226
- public function getImageHeight($storeId = null)
227
- {
228
- $height = (int)$this->getAdminScopedConfig(self::XML_PATH_IMAGE_HEIGHT, 'store', $storeId);
229
-
230
- return empty($height) ? null : abs($height);
231
- }
232
-
233
- /**
234
- * @param string|int $storeId
235
- *
236
- * @return bool
237
- */
238
- public function useCurrencySymbol($storeId = null)
239
- {
240
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_USE_SYMBOL, 'store', $storeId);
241
- }
242
-
243
- /**
244
- * @param mixed $storeId
245
- *
246
- * @return bool
247
- */
248
- public function displayPriceIncTax($storeId = null)
249
- {
250
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_INCL_TAX, 'store', $storeId);
251
- }
252
-
253
- /**
254
- * Get Default Greeting Settings
255
- *
256
- * @param string $piece
257
- * @param string $scope
258
- * @param int $scopeId
259
- *
260
- * @return mixed
261
- */
262
- public function getDefaultGreeting($piece = 'full', $scope = 'default', $scopeId = 0)
263
- {
264
- switch ($piece) {
265
- case 'prefix':
266
- return $this->getAdminScopedConfig(self::XML_PATH_GREETING_PRE, $scope, $scopeId);
267
- case 'firstname':
268
- return $this->getAdminScopedConfig(self::XML_PATH_GREETING_FIRST, $scope, $scopeId);
269
- case 'lastname':
270
- return $this->getAdminScopedConfig(self::XML_PATH_GREETING_LAST, $scope, $scopeId);
271
- case 'full':
272
- default:
273
- return $this->getAdminScopedConfig(self::XML_PATH_GREETING_FULL, $scope, $scopeId);
274
- }
275
- }
276
-
277
- /**
278
- * Check if module can use the magento cron
279
- *
280
- * @return bool
281
- */
282
- public function canUseMageCron()
283
- {
284
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
285
- }
286
-
287
- /**
288
- * @return string
289
- */
290
- public function getCronStringPath()
291
- {
292
- return self::XML_PATH_CRON_STRING;
293
- }
294
-
295
- /**
296
- * @return string
297
- */
298
- public function getCronModelPath()
299
- {
300
- return self::XML_PATH_CRON_MODEL;
301
- }
302
-
303
- /**
304
- * Disable Specified Module
305
- *
306
- * @param string $scope
307
- * @param int $scopeId
308
- * @param bool $deleteConfig
309
- *
310
- * @return bool
311
- */
312
- public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
313
- {
314
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
315
- }
316
-
317
- /**
318
- * @param string $path
319
- * @param string $scope
320
- * @param int $scopeId
321
- * @param bool $deleteConfig
322
- *
323
- * @return bool
324
- */
325
- protected function _disableModule($path, $scope = 'default', $scopeId = 0, $deleteConfig = false)
326
- {
327
- if ($scope == 'website' || $scope == 'store') {
328
- $scope .= 's';
329
- }
330
-
331
- $coreConfig = Mage::getModel('core/config');
332
- $coreConfigData = Mage::getModel('core/config_data');
333
-
334
- // If set, we delete the config value instead of just setting it to 0
335
- if ($deleteConfig) {
336
- $coreConfig->deleteConfig($path, $scope, $scopeId);
337
-
338
- $coreConfigData
339
- ->load($path)
340
- ->setScope($scope)
341
- ->setScopeId($scopeId)
342
- ->delete();
343
- } else {
344
- $coreConfig->saveConfig($path, 0, $scope, $scopeId);
345
-
346
- if (!$this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, array('edition' => 'Professional', 'major' => 9), 10))) {
347
- list($module) = explode('/', $path);
348
-
349
- $coreConfigData->setScope($scope)
350
- ->setScopeId($scopeId)
351
- ->setPath("$module/settings/enabled")
352
- ->setValue(0)
353
- ->save();
354
- }
355
- }
356
-
357
- return $this;
358
- }
359
-
360
- /**
361
- * Determine if module is active
362
- *
363
- * @return boolean
364
- */
365
- public function isModuleActive()
366
- {
367
- // If module is not enabled, return false
368
- if (!$this->isEnabled()) {
369
- return false;
370
- }
371
-
372
- // If requirements are not met, return false
373
- if (!$this->verifyRequirements($this->_getModuleName())) {
374
- return false;
375
- }
376
-
377
- return true;
378
- }
379
-
380
- /**
381
- * Does this helper have custom config?
382
- *
383
- * @return boolean
384
- */
385
- public function hasCustomConfig()
386
- {
387
- return false;
388
- }
389
-
390
- /**
391
- * @deprecated since version 1.6.7
392
- * @see verifyRequirements
393
- */
394
- public function varifyRequirements($module, $required = array())
395
- {
396
- return $this->verifyRequirements($module, $required);
397
- }
398
-
399
- /**
400
- * Verify that all required PHP extensions are loaded
401
- *
402
- * @param string $module
403
- * @param array $required
404
- *
405
- * @return boolean
406
- */
407
- public function verifyRequirements($module, $required = array())
408
- {
409
- // Check for required PHP extensions
410
- $verified = true;
411
- $missing = array();
412
- $defaultRequired = array('soap', 'openssl');
413
- $required = array_merge($required, $defaultRequired);
414
- $module = strtolower($module);
415
-
416
- /*
417
- * Run through PHP extensions to see if they are loaded
418
- * if no, add them to the list of missing and set verified = false flag
419
- */
420
- foreach ($required as $extName) {
421
- try {
422
- if (!extension_loaded($extName)) {
423
- $missing[] = $extName;
424
- $verified = false;
425
- }
426
- } catch (Exception $e) {
427
- $missing[] = $extName;
428
- $verified = false;
429
- }
430
- }
431
-
432
- // If not verified, create a message telling the user what they are missing
433
- if (!$verified) {
434
- // If module is enabled, disable it
435
- if (Mage::helper($module)->isEnabled()) {
436
- Mage::helper($module)->disableModule();
437
- }
438
- // Create message informing of missing extensions
439
- $message = Mage::getSingleton('core/message')->error(
440
- $this->__(
441
- sprintf(
442
- 'The module "' .
443
- $module .
444
- '" has been automatically disabled due to missing PHP extensions: %s',
445
- implode(',', $missing)
446
- )
447
- )
448
- );
449
- $message->setIdentifier($module);
450
- Mage::getSingleton('adminhtml/session')->addMessage($message);
451
-
452
- return false;
453
- }
454
-
455
- return true;
456
- }
457
-
458
- /**
459
- * Get Token Instance
460
- *
461
- * @param null $token
462
- * @param string $scope
463
- * @param int $scopeId
464
- *
465
- * @return Bronto_Common_Model_Api
466
- */
467
- public function getApi($token = null, $scope = 'default', $scopeId = 0)
468
- {
469
- if (empty($token)) {
470
- $token = $this->getApiToken($scope, $scopeId);
471
- }
472
-
473
- return Mage::getModel('bronto_common/api')
474
- ->load($token)
475
- ->setToken($token)
476
- ->getClient();
477
- }
478
-
479
- /**
480
- * Get API Token from Config
481
- *
482
- * @param string $scope
483
- * @param int $scopeId
484
- *
485
- * @return bool|mixed
486
- */
487
- public function getApiToken($scope = 'default', $scopeId = 0)
488
- {
489
- $token = $this->getAdminScopedConfig(self::XML_PATH_API_TOKEN, $scope, $scopeId);
490
-
491
- if (!$token || empty($token) || is_null($token) || $token == 'NULL') {
492
- return false;
493
- }
494
-
495
- return $token;
496
- }
497
-
498
- /**
499
- * Determine if API token is valid
500
- *
501
- * @param null $token
502
- * @param string $scope
503
- * @param int $scopeId
504
- *
505
- * @return bool
506
- */
507
- public function validApiToken($token = null, $scope = 'default', $scopeId = 0)
508
- {
509
- // If token is specifically set to false, then there is no token and is technically valid
510
- if (false === $token) {
511
- return true;
512
- }
513
-
514
- // If token is empty try to pull from config
515
- if (empty($token)) {
516
- $token = $this->getApiToken($scope, $scopeId);
517
- }
518
-
519
- if (strlen($token) < Bronto_Common_Helper_Data::MAX_TOKEN_LENGTH) {
520
- return false;
521
- }
522
-
523
- try {
524
- $api = $this->getApi($token, $scope, $scopeId);
525
- $tokenRow = $api->transferApiToken()->getById($token);
526
-
527
- return $tokenRow->getPermissions() == 7;
528
- } catch (Exception $e) {
529
- $helper = Mage::helper('bronto_common/api');
530
- if (
531
- !$helper->isStreamContextOverride() &&
532
- (
533
- $e->getCode() == Bronto_Api_Exception::WSDL_PARSE_ERROR ||
534
- $e->getCode() == Bronto_Api_Exception::CONNECTION_RESET
535
- )
536
- ) {
537
- $helper->setStreamContext(true);
538
- return $this->validApiToken($token, $scope, $scopeId);
539
- } else {
540
- if ($helper->isStreamContextOverride()) {
541
- $helper->setStreamContext(false);
542
- }
543
- return false;
544
- }
545
- }
546
- }
547
-
548
- /**
549
- * Determines if the last API token used is in a valid state at the current
550
- * scope.
551
- *
552
- * @return bool
553
- */
554
- public function validApiStatus()
555
- {
556
- if (!Mage::helper('bronto_verify/apitoken')->getStatus()) {
557
- $this->_addSingleSessionMessage(
558
- 'error',
559
- 'The Bronto API Token you have entered for this scope appears to be invalid.'
560
- );
561
- return false;
562
- }
563
-
564
- return true;
565
- }
566
-
567
- /**
568
- * Adds a single message to the session, as to not flood the
569
- * session messages with the same content
570
- *
571
- * @param $type string
572
- * @param $msg string
573
- * @param $module string (optional)
574
- * @return boolean
575
- */
576
- protected function _addSingleSessionMessage($type, $msg, $module = 'bronto_common')
577
- {
578
- $message = Mage::getSingleton('core/message')->{$type}($this->__($msg));
579
- $message->setIdentifier($module);
580
- $session = Mage::getSingleton('adminhtml/session');
581
- foreach ($session->getMessages()->getItemsByType($type) as $set) {
582
- if ($set->getIdentifier() == $message->getIdentifier()) {
583
- $exists = true;
584
- break;
585
- }
586
- }
587
-
588
- if (empty($exists)) {
589
- $session->addMessage($message);
590
- }
591
-
592
- return empty($exists);
593
- }
594
-
595
- /**
596
- * Check all API tokens are valid
597
- *
598
- * @param string $identifier
599
- *
600
- * @return bool
601
- */
602
- public function validApiTokens($identifier = 'bronto_common')
603
- {
604
- $valid = true;
605
- if (!$this->validApiToken($this->getApiToken())) {
606
- $message = Mage::getSingleton('core/message')->error(
607
- $this->__('The Bronto API Token you have entered for Default Configuration appears to be invalid.')
608
- );
609
- $message->setIdentifier($identifier);
610
- Mage::getSingleton('adminhtml/session')->addMessage($message);
611
- $valid = false;
612
- }
613
- foreach (Mage::app()->getWebsites() as $website) {
614
- if (!$this->validApiToken($this->getApiToken('website', $website->getId()), 'website', $website->getId())) {
615
- $message = Mage::getSingleton('core/message')->error(
616
- $this->__(
617
- sprintf(
618
- 'The Bronto API Token you have entered for website "%s" appears to be invalid.',
619
- $website->getName()
620
- )
621
- )
622
- );
623
- $message->setIdentifier($identifier);
624
- Mage::getSingleton('adminhtml/session')->addMessage($message);
625
- $valid = false;
626
- }
627
- foreach ($website->getGroups() as $group) {
628
- $stores = $group->getStores();
629
- if (count($stores) > 0) {
630
- foreach ($stores as $store) {
631
- if (!$this->validApiToken($this->getApiToken('store', $store->getId()), 'store', $store->getId())) {
632
- $message = Mage::getSingleton('core/message')->error(
633
- $this->__(
634
- sprintf(
635
- 'The Bronto API Token you have entered for store "%s" on website "%s" appears to be invalid.',
636
- $store->getName(),
637
- $website->getName()
638
- )
639
- )
640
- );
641
- $message->setIdentifier($identifier);
642
- Mage::getSingleton('adminhtml/session')->addMessage($message);
643
- $valid = false;
644
- }
645
- }
646
- }
647
- }
648
- }
649
-
650
- return $valid;
651
- }
652
-
653
- /**
654
- * @param string $moduleName
655
- *
656
- * @return bool
657
- */
658
- public function isModuleInstalled($moduleName = null)
659
- {
660
- $modules = (array)Mage::getConfig()->getNode('modules')->children();
661
-
662
- if ($moduleName === null) {
663
- $moduleName = $this->_getModuleName();
664
- }
665
-
666
- if (!isset($modules[$moduleName])) {
667
- return false;
668
- }
669
-
670
- return ($modules[$moduleName]->active == 'true');
671
- }
672
-
673
- /**
674
- * @param string $moduleName
675
- *
676
- * @return string
677
- */
678
- public function getModuleVersion($moduleName = null)
679
- {
680
- $modules = (array)Mage::getConfig()->getNode('modules')->children();
681
-
682
- if ($moduleName === null) {
683
- $moduleName = $this->_getModuleName();
684
- }
685
-
686
- return isset($modules[$moduleName]) ? (string)$modules[$moduleName]->version : null;
687
- }
688
-
689
- /**
690
- * @return bool
691
- */
692
- public function isDebugEnabled()
693
- {
694
- if (!$this->getApiToken()) {
695
- return false;
696
- }
697
-
698
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_DEBUG);
699
- }
700
-
701
- /**
702
- * @return bool
703
- */
704
- public function isVerboseEnabled()
705
- {
706
- if (!$this->isDebugEnabled()) {
707
- return false;
708
- }
709
-
710
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_VERBOSE);
711
- }
712
-
713
- /**
714
- * @return bool
715
- */
716
- public function isNoticesEnabled()
717
- {
718
- if (!$this->getApiToken()) {
719
- return false;
720
- }
721
-
722
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_NOTICES);
723
- }
724
-
725
- /**
726
- * Write message to Debug log
727
- *
728
- * @param mixed $message
729
- * @param null $file
730
- * @param bool $verbose
731
- *
732
- * @return bool|void
733
- */
734
- public function writeDebug($message, $file = null, $verbose = false)
735
- {
736
- if ($verbose && !$this->isVerboseEnabled()) {
737
- return false;
738
- }
739
-
740
- if ($this->isDebugEnabled()) {
741
- return $this->writeLog($message, $file, Zend_Log::DEBUG);
742
- }
743
-
744
- return false;
745
- }
746
-
747
- /**
748
- * @param string $message
749
- * @param string|null $file
750
- *
751
- * @return bool|void
752
- */
753
- public function writeVerboseDebug($message, $file = null)
754
- {
755
- if ($this->isVerboseEnabled()) {
756
- return $this->writeDebug($message, $file, true);
757
- }
758
-
759
- return false;
760
- }
761
-
762
- /**
763
- * @param string $message
764
- * @param string|null $file
765
- *
766
- * @return bool|void
767
- */
768
- public function writeInfo($message, $file = null)
769
- {
770
- if ($this->isNoticesEnabled()) {
771
- if (Mage::getSingleton('admin/session')->isLoggedIn()) {
772
- /* @var $message Mage_Core_Model_Message_Notice */
773
- $sessionMessage = Mage::getSingleton('core/message')->notice("[Bronto] {$message}");
774
- Mage::getSingleton('adminhtml/session')->addMessage($sessionMessage);
775
- } else {
776
- Mage::getSingleton('core/session')->addNotice("[Bronto] {$message}");
777
- }
778
- }
779
-
780
- return $this->writeLog($message, $file, Zend_Log::INFO);
781
- }
782
-
783
- /**
784
- * @param Exception|string $message
785
- * @param string|null $file
786
- *
787
- * @return bool|void
788
- */
789
- public function writeError($message, $file = null)
790
- {
791
- if (is_object($message) && $message instanceOf Exception) {
792
- $message = $message->getMessage();
793
- }
794
- if ($this->isNoticesEnabled()) {
795
- if (Mage::getSingleton('admin/session')->isLoggedIn()) {
796
- /* @var $message Mage_Core_Model_Message_Error */
797
- $message = Mage::getSingleton('core/message')->error("[Bronto] {$message}");
798
- Mage::getSingleton('adminhtml/session')->addMessage($message);
799
- } else {
800
- Mage::getSingleton('core/session')->addError("[Bronto] {$message}");
801
- }
802
- }
803
-
804
- return $this->writeLog($message, $file, Zend_Log::ERR);
805
- }
806
-
807
- /**
808
- * @param string $message
809
- * @param string|null $file
810
- * @param int $level
811
- *
812
- * @return bool|void
813
- */
814
- public function writeLog($message, $file = null, $level = Zend_Log::DEBUG)
815
- {
816
- if (empty($file)) {
817
- $file = strtolower($this->_getModuleName()) . '.log';
818
- }
819
- if (!is_string($message)) {
820
- if (method_exists($message, '__toString')) {
821
- $message = $message->__toString();
822
- } else {
823
- return false;
824
- }
825
- }
826
-
827
- return Mage::log($message, $level, $this->_stampFile($file), true);
828
- }
829
-
830
- /**
831
- * Add Date Stamp to log file name
832
- *
833
- * @param $filename
834
- * @param bool $withTime
835
- *
836
- * @return mixed
837
- */
838
- protected function _stampFile($filename, $withTime = true)
839
- {
840
- // Ensure var/log/bronto exists
841
- $logDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
842
- if (!is_dir($logDir)) {
843
- mkdir($logDir, 0777, true);
844
- }
845
-
846
- // If time stamp requested, append
847
- if ($withTime) {
848
- $stamp = date('Ymd', time());
849
- $filename = str_replace('.', ".{$stamp}.", $filename);
850
- }
851
-
852
- // replace bronto_ with bronto/ to place in folder
853
- return str_replace('bronto_', 'bronto' . DS, $filename);
854
- }
855
-
856
- /**
857
- * Get list of active custom modules
858
- *
859
- * @param bool $brontoOnly
860
- *
861
- * @return array
862
- */
863
- public function getInstalledModules($brontoOnly = false)
864
- {
865
- $moduleList = array();
866
- $modules = Mage::getConfig()->getNode('modules')->children();
867
-
868
- foreach ($modules as $name => $module) {
869
- if ($brontoOnly) {
870
- if (strpos($name, 'Bronto_') !== false && $module->active == 'true') {
871
- $moduleList[] = strtolower($name);
872
- }
873
- } else if (strpos($name, 'Mage_') === false && strpos($name, 'Enterprise_') === false &&
874
- $module->active == 'true'
875
- ) {
876
- $moduleList[] = $name . ' [v' . $module->version . ' codePool: ' . $module->codePool . ']';
877
- }
878
- }
879
-
880
- return $moduleList;
881
- }
882
-
883
- /**
884
- * Get array of current scope parameters
885
- *
886
- * @return array
887
- */
888
- public function getScopeParams()
889
- {
890
- // Get Request Object
891
- $request = Mage::app()->getRequest();
892
-
893
- // Define Scope Params
894
- $scopeParams = array(
895
- 'scope' => 'default',
896
- 'default' => 0,
897
- 'default_id' => 0,
898
- 'store' => $request->getParam('store', false),
899
- 'store_id' => 0,
900
- 'website' => $request->getParam('website', false),
901
- 'website_id' => 0,
902
- 'group' => $request->getParam('group', false),
903
- 'group_id' => 0,
904
- );
905
-
906
- // Update Scope based on what has been set
907
- if (!empty($scopeParams['store'])) {
908
- $store = Mage::app()->getStore($scopeParams['store']);
909
- if ($store->getId()) {
910
- $scopeParams['store_id'] = $store->getId();
911
- } else {
912
- $scopeParams['store_id'] = Mage::app()->getStore()->getId();
913
- }
914
- $scopeParams['scope'] = 'store';
915
- } elseif (!empty($scopeParams['website'])) {
916
- $website = Mage::app()->getWebsite($scopeParams['website']);
917
- if ($website->getId()) {
918
- $scopeParams['website_id'] = $website->getId();
919
- }
920
- $scopeParams['scope'] = 'website';
921
- } elseif (!empty($scopeParams['group'])) {
922
- $group = Mage::app()->getGroup($scopeParams['group']);
923
- if ($group->getId()) {
924
- $scopeParams['group_id'] = $group->getId();
925
- }
926
- $scopeParams['scope'] = 'group';
927
- }
928
-
929
- // Return array of Scope Params
930
- return $scopeParams;
931
- }
932
-
933
- /**
934
- * Get Url with scope data included
935
- *
936
- * @param $url
937
- * @param array $scopeParams
938
- *
939
- * @return mixed
940
- */
941
- public function getScopeUrl($url, $scopeParams = array())
942
- {
943
- $curScopeParams = $this->getScopeParams();
944
- $curScope = array(
945
- 'scope' => $curScopeParams['scope'],
946
- $curScopeParams['scope'] => $curScopeParams[$curScopeParams['scope']],
947
- );
948
-
949
- if (array_key_exists('scope', $scopeParams)) {
950
- if ($scopeParams['scope'] != $curScope['scope']) {
951
- unset($curScope[$curScope['scope']]);
952
- }
953
-
954
- unset($scopeParams['scope']);
955
- }
956
- unset($curScope['scope']);
957
-
958
- $scopeParams = array_merge($scopeParams, $curScope);
959
-
960
- return Mage::helper('adminhtml')->getUrl($url, $scopeParams);
961
- }
962
-
963
- /**
964
- * Get Scoped Config Data
965
- *
966
- * @param $path
967
- * @param string $scope
968
- * @param int $scopeId
969
- *
970
- * @return mixed
971
- */
972
- public function getAdminScopedConfig($path, $scope = 'default', $scopeId = 0)
973
- {
974
- if ('store' == $scope) {
975
- return Mage::getStoreConfig($path, $scopeId);
976
- } elseif ('website' == $scope) {
977
- $website = Mage::app()->getWebsite($scopeId);
978
-
979
- return $website->getConfig($path);
980
- }
981
-
982
- $scopeParams = $this->getScopeParams();
983
-
984
- switch ($scopeParams['scope']) {
985
- case 'store':
986
- $source = Mage::app()->getStore($scopeParams['store']);
987
- break;
988
- case 'website':
989
- $source = Mage::app()->getWebsite($scopeParams['website']);
990
- break;
991
- case 'group':
992
- $source = Mage::app()->getGroup($scopeParams['group'])->getWebsite();
993
- break;
994
- default:
995
- return Mage::getStoreConfig($path);
996
- break;
997
- }
998
-
999
- if ($source) {
1000
- return $source->getConfig($path);
1001
- }
1002
-
1003
- return Mage::getStoreConfig($path);
1004
- }
1005
-
1006
- /**
1007
- * Get Array of Store Ids based on current store/website/group
1008
- *
1009
- * @return boolean|array
1010
- */
1011
- public function getStoreIds()
1012
- {
1013
- $scopeParams = $this->getScopeParams();
1014
-
1015
- switch ($scopeParams['scope']) {
1016
- case 'store':
1017
- $source = Mage::app()->getStore($scopeParams['store']);
1018
- $storeIds = $source->getId();
1019
- break;
1020
- case 'website':
1021
- $source = Mage::app()->getWebsite($scopeParams['website']);
1022
- $storeIds = $source->getStoreIds();
1023
- break;
1024
- case 'group':
1025
- $source = Mage::app()->getGroup($scopeParams['group'])->getWebsite();
1026
- $storeIds = $source->getStoreIds();
1027
- break;
1028
- default:
1029
- $storeIds = array_keys(Mage::app()->getStores(true));
1030
- break;
1031
- }
1032
-
1033
- return $storeIds;
1034
- }
1035
-
1036
- /**
1037
- * Is this the Enterprise edition?
1038
- *
1039
- * @return boolean
1040
- */
1041
- public function isEnterpriseEdition()
1042
- {
1043
- return ('Enterprise' == $this->getEdition());
1044
- }
1045
-
1046
- /**
1047
- * Is this the Professional edition?
1048
- *
1049
- * @return bool
1050
- */
1051
- public function isProfessionalEdition()
1052
- {
1053
- return ('Professional' == $this->getEdition());
1054
- }
1055
-
1056
- /**
1057
- * Get Edition from version Info
1058
- *
1059
- * @param array|boolean $versionInfo
1060
- *
1061
- * @return string|boolean
1062
- */
1063
- public function getEdition($versionInfo = false)
1064
- {
1065
- // Ensure we have version info
1066
- if (!$versionInfo || !is_array($versionInfo)) {
1067
- if (method_exists('Mage', 'getEdition')) {
1068
- return Mage::getEdition();
1069
- }
1070
- $versionInfo = Mage::getVersionInfo();
1071
- }
1072
-
1073
- // Get Edition from version
1074
- if (array_key_exists('major', $versionInfo) && array_key_exists('minor', $versionInfo)) {
1075
- $major = $versionInfo['major'];
1076
- $minor = $versionInfo['minor'];
1077
-
1078
- if (1 == $major) {
1079
- if ($minor < 9 || ($minor == 9 && method_exists('Mage', 'getEdition'))) {
1080
- return 'Community';
1081
- } else if ($minor >= 9 && $minor < 11) {
1082
- return 'Professional';
1083
- } else if ($minor >= 11) {
1084
- return 'Enterprise';
1085
- }
1086
- }
1087
- }
1088
-
1089
- return false;
1090
- }
1091
-
1092
- /**
1093
- * Takes major and minor version info and determines if current magento install matches
1094
- *
1095
- * Uses magic method to get Arguments
1096
- *
1097
- * param array $versionInfo
1098
- * param int|string|array $major
1099
- * param int|string|array $minor
1100
- * param int|string|array $revision (Optional)
1101
- * param int|string|array $patch (Optional)
1102
- * param string $edition (Optional) 'CE'|'Community'|'PE'|'Professional'|'EE'|'Enterprise'
1103
- *
1104
- * @return bool
1105
- */
1106
- public function isVersionMatch()
1107
- {
1108
- /**
1109
- * Get arguments passed to function
1110
- *
1111
- * [0] = Magento Version Array (Required)
1112
- * [1] = Compare Major Version (Optional)
1113
- * [2] = Compare Minor Version (Optional)
1114
- * [3] = Compare Revision Number (Optional)
1115
- * [4] = Compare Patch Number (Optional)
1116
- * [5] = Compare Edition (Optional)
1117
- */
1118
- $parts = $this->_mapVersionParts(func_get_args());
1119
-
1120
- // At least version info and one other
1121
- if (!array_key_exists('versionInfo', $parts) || count($parts) < 2) {
1122
- return false;
1123
- }
1124
-
1125
- // Get Magento Version from passed arguments
1126
- $mageVersion = $parts['versionInfo'];
1127
- $mageVersion['edition'] = $this->getEdition($mageVersion);
1128
- unset($parts['versionInfo']);
1129
-
1130
- // Cycle through the elements of the magento version
1131
- foreach ($mageVersion as $index => $mValue) {
1132
- // If the compare value doesn't exist for this index, continue
1133
- if (!isset($parts[$index])) {
1134
- continue;
1135
- }
1136
-
1137
- // Get compare value
1138
- $value = $parts[$index];
1139
- // Ensure Value is an array
1140
- if (!is_array($value)) {
1141
- $value = array($value);
1142
- }
1143
-
1144
- // Cycle through compare value array to compare against
1145
- // current Magento version element
1146
- $internalMatch = false;
1147
- foreach ($value as $option) {
1148
- $edition = false;
1149
- $operator = '==';
1150
- $compare = $option;
1151
-
1152
- // If the current compare value is an array,
1153
- // get the operator and value provided
1154
- if (is_array($option)) {
1155
- if (array_key_exists('edition', $option)) {
1156
- $edition = $option['edition'];
1157
- $compare = $option['major'];
1158
- } else {
1159
- list ($operator, $compare) = $option;
1160
- }
1161
- }
1162
-
1163
- if ($index == 'edition') {
1164
- // handle possibility of initials being used
1165
- switch (strtoupper($compare)) {
1166
- case 'EE':
1167
- $compare = 'Enterprise';
1168
- break;
1169
- case 'CE':
1170
- $compare = 'Community';
1171
- break;
1172
- case 'PE':
1173
- $compare = 'Professional';
1174
- break;
1175
- default:
1176
- break;
1177
- }
1178
-
1179
- // If response from getEdition matches compare edition
1180
- $internalMatch = ($mValue == $compare);
1181
- } else {
1182
- // Use version_compare to compare the Magento version to the
1183
- // Current compare version using the provided operator
1184
- $internalMatch = version_compare($mValue, $compare, $operator);
1185
- if ($edition && $internalMatch) {
1186
- $internalMatch = ($mageVersion['edition'] == $edition);
1187
- }
1188
- }
1189
-
1190
- if ($internalMatch) {
1191
- break;
1192
- }
1193
- }
1194
-
1195
- // If the internal Match flag hasn't been set to true,
1196
- // there is no match
1197
- if (!$internalMatch) {
1198
- return false;
1199
- }
1200
- }
1201
-
1202
- // If we haven't returned false yet, that means there is a match
1203
- return true;
1204
- }
1205
-
1206
- /**
1207
- * Maps parts array to expected array
1208
- *
1209
- * @param array $parts
1210
- *
1211
- * @return array
1212
- */
1213
- private function _mapVersionParts($parts)
1214
- {
1215
- // Parts must be array
1216
- if (!is_array($parts)) {
1217
- return false;
1218
- }
1219
-
1220
- // Generate index map values
1221
- $mapKeys = array(
1222
- 'versionInfo' => 0,
1223
- 'major' => 1,
1224
- 'minor' => 2,
1225
- 'revision' => 3,
1226
- 'patch' => 4,
1227
- 'edition' => 5,
1228
- );
1229
-
1230
- // Placeholder array
1231
- $versionParts = array();
1232
-
1233
- // Cycle Through and map values as needed
1234
- foreach ($mapKeys as $map => $index) {
1235
- if (array_key_exists($index, $parts) && !is_null($parts[$index])) {
1236
- $versionParts[$map] = $parts[$index];
1237
- }
1238
- }
1239
-
1240
- // Return Mapped Array
1241
- return $versionParts;
1242
- }
1243
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/DataInterface.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Common
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- interface Bronto_Common_Helper_DataInterface
8
- {
9
- /**
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 DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
-
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
- private static $_fieldCache = array();
10
-
11
- /**
12
- * @param string $name
13
- * @param array $options
14
- *
15
- * @return Bronto_Api_Field_Row
16
- */
17
- public function getFieldByName($name, $options)
18
- {
19
- /* @var $fieldObject Bronto_Api_Field */
20
- $fieldObject = $this->getApi()->transferField();
21
-
22
- if (!array_key_exists($name, self::$_fieldCache)) {
23
- $field = $fieldObject->getByName($name);
24
- if (!$field) {
25
- $field = $fieldObject->createObject()
26
- ->withName($name)
27
- ->withType($options['type']);
28
- if (!empty($options['options'])) {
29
- $field->withOptions($options['options']);
30
- }
31
- }
32
- if (isset($options['label']) && !empty($options['label'])) {
33
- $field->withLabel($options['label']);
34
- }
35
- try {
36
- $fieldObject->save($field);
37
- self::$_fieldCache[$name] = $field;
38
- } catch (Exception $e) {
39
- $this->writeError($e);
40
- }
41
- }
42
-
43
- return self::$_fieldCache[$name];
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Item.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Helper_Item extends Mage_Core_Helper_Abstract
4
- {
5
- private $_productCache = array();
6
-
7
- /**
8
- * Gets the product associated with this line item
9
- *
10
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
11
- * @return Mage_Catalog_Model_Product
12
- */
13
- public function getProduct($lineItem, $includeParent = true)
14
- {
15
- if ($includeParent) {
16
- $lineItem = $this->getParentItem($lineItem);
17
- }
18
- if (!isset($this->_productCache[$lineItem->getProductId()])) {
19
- $this->_productCache[$lineItem->getProductId()] = Mage::getModel('catalog/product')
20
- ->setStoreId($lineItem->getStoreId())
21
- ->load($lineItem->getProductId());
22
- }
23
- return $this->_productCache[$lineItem->getProductId()];
24
- }
25
-
26
- public function getParentItem($lineItem)
27
- {
28
- if ($lineItem->getParentItemId()) {
29
- return $lineItem->getParentItem();
30
- }
31
- return $lineItem;
32
- }
33
-
34
- /**
35
- * Gets the product url for a given line item
36
- *
37
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
38
- * @return string
39
- */
40
- public function getProductUrl($lineItem)
41
- {
42
- if ($lineItem->getRedirectUrl()) {
43
- return $lineItem->getRedirectUrl();
44
- }
45
- $helper = Mage::helper('bronto_common/product');
46
- $product = $this->getProduct($lineItem, false);
47
- if (!$helper->isVisibleInidividually($product)) {
48
- $product = $this->getProduct($lineItem);
49
- }
50
- if (!$helper->isVisibleInidividually($product)) {
51
- $product = $helper->getGroupedProduct($product);
52
- }
53
- return Mage::helper('catalog/product')->getProductUrl($product);
54
- }
55
-
56
- /**
57
- * Gets the product image url
58
- *
59
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
60
- * @return string
61
- */
62
- public function getImage($lineItem)
63
- {
64
- $helper = Mage::helper('bronto_common/product');
65
- $product = $this->getProduct($lineItem, false);
66
- $image = Mage::helper('bronto_common')->getProductImageUrl($product);
67
- // No image, get the parent
68
- if (preg_match('|/placeholder/|', $image)) {
69
- $product = $this->getProduct($lineItem);
70
- if (!$helper->isVisibleInidividually($product)) {
71
- $product = $helper->getGroupedProduct($product);
72
- }
73
- return Mage::helper('bronto_common')->getProductImageUrl($product);
74
- }
75
- return $image;
76
- }
77
-
78
- public function getDescription($lineItem)
79
- {
80
- return $this->getProduct($lineItem)->getDescription();
81
- }
82
-
83
- public function getName($lineItem)
84
- {
85
- return $this->getParentItem($lineItem)->getName();
86
- }
87
-
88
- public function getFlatItems($object)
89
- {
90
- $index = null;
91
- $lineItems = array();
92
- foreach ($object->getAllItems() as $lineItem) {
93
- if (method_exists($lineItem, 'getOrderItem')) {
94
- $lineItem = $lineItem->getOrderItem();
95
- }
96
- if ($lineItem->getParentItemId()) {
97
- $lineItems[$index] = $lineItem;
98
- } else {
99
- $lineItems[] = $lineItem;
100
- if (is_null($index)) {
101
- $index = 0;
102
- } else {
103
- $index++;
104
- }
105
- }
106
- }
107
- return $lineItems;
108
- }
109
-
110
- /**
111
- * Gets the qty of the lineItem
112
- *
113
- * @param Mage_Sales_Model_Quote_Item | Mage_Sales_Model_Order_Item
114
- * @return float
115
- */
116
- public function getQty($lineItem)
117
- {
118
- if ($lineItem instanceof Mage_Sales_Model_Order_Item) {
119
- return $this->getParentItem($lineItem)->getQtyOrdered();
120
- } else {
121
- return $this->getParentItem($lineItem)->getQty();
122
- }
123
- }
124
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Message.php DELETED
@@ -1,151 +0,0 @@
1
- <?php
2
-
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
- protected static $_options = array();
10
-
11
- /**
12
- * Get Bronto Message Object by ID
13
- *
14
- * @param $messageId
15
- * @param null $storeId
16
- * @param null $websiteId
17
- *
18
- * @return Bronto_Api_Message_Row
19
- */
20
- public function getMessageById($messageId, $storeId = null, $websiteId = null)
21
- {
22
- if (!is_null($storeId)) {
23
- $scope = 'store';
24
- $scopeId = $storeId;
25
- } elseif (!is_null($websiteId)) {
26
- $scope = 'website';
27
- $scopeId = $websiteId;
28
- } else {
29
- $scope = 'default';
30
- $scopeId = 0;
31
- }
32
-
33
- /* @var $messageObject Bronto_Api_Message */
34
- $messageObject = $this->getApi(null, $scope, $scopeId)->transferMessage();
35
-
36
- // Load Message
37
- try {
38
- return $messageObject->read()
39
- ->where->id->is($messageId)
40
- ->withIncludeContent(false)
41
- ->first();
42
- } catch (Exception $e) {
43
- $this->writeError($e);
44
- }
45
-
46
- return $messageObject->createObject();
47
- }
48
-
49
- /**
50
- * @return array
51
- */
52
- public function getAllMessageOptions()
53
- {
54
- $messageOptions = array();
55
- foreach (Mage::app()->getWebsites() as $website) {
56
- foreach ($website->getGroups() as $group) {
57
- $stores = $group->getStores();
58
- if (count($stores) == 0) {
59
- continue;
60
- }
61
- foreach ($stores as $store) {
62
- if (Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
63
- $storeMessages = $this->getMessagesOptionsArray(
64
- $store->getId(),
65
- $website->getId()
66
- );
67
- $messageOptions = array_merge($messageOptions, $storeMessages);
68
- }
69
- }
70
- }
71
- }
72
-
73
- $existingValues = array();
74
- foreach ($messageOptions as $key => $option) {
75
- if (!in_array($option['value'], $existingValues)) {
76
- $existingValues[] = $option['value'];
77
- } else {
78
- unset($messageOptions[$key]);
79
- }
80
- }
81
-
82
- return $messageOptions;
83
- }
84
-
85
- /**
86
- * Retrieve array of available Bronto Messages
87
- *
88
- * @param null $store
89
- * @param null $websiteId
90
- * @param array $filter
91
- * @param bool $withCreateNew
92
- *
93
- * @return array
94
- */
95
- public function getMessagesOptionsArray($store = null, $websiteId = null, $filter = array(), $withCreateNew = false)
96
- {
97
- if (!is_null($store)) {
98
- $scope = 'store';
99
- $scopeId = $store;
100
- } elseif (!is_null($websiteId)) {
101
- $scope = 'website';
102
- $scopeId = $websiteId;
103
- } else {
104
- $scope = 'default';
105
- $scopeId = 0;
106
- }
107
-
108
- /* @var $api Bronto_Api */
109
- $api = $this->getApi(null, $scope, $scopeId);
110
- $options = array();
111
- if ($api && !array_key_exists($api->getToken(), self::$_options)) {
112
- /* @var $messageObject Bronto_Api_Message */
113
- $messageObject = $api->transferMessage();
114
- $readMessages = $messageObject->read(array('filter' => $filter))
115
- ->withIncludeContent(false)
116
- ->withStatus('active');
117
-
118
- try {
119
- foreach ($readMessages as $message) {
120
- $options[] = array(
121
- 'label' => $message->getName(),
122
- 'value' => $message->getId()
123
- );
124
- }
125
- } catch (Exception $e) {
126
- Mage::helper('bronto_common')->writeError($e);
127
- }
128
-
129
- if ($withCreateNew) {
130
- // Add Create New.. Option
131
- array_unshift($options, array(
132
- 'label' => '** Create New...',
133
- 'value' => '_new_'
134
- ));
135
- } else {
136
- // Add -- None Selected -- Option
137
- array_unshift($options, array(
138
- 'label' => '-- None Selected --',
139
- 'value' => ''
140
- ));
141
- }
142
- // Sort Alphabetically
143
- sort($options);
144
- self::$_options[$api->getToken()] = $options;
145
- } else {
146
- $options = self::$_options[$api->getToken()];
147
- }
148
-
149
- return $options;
150
- }
151
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Product.php DELETED
@@ -1,201 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var array
11
- */
12
- protected $_productCache = array();
13
-
14
- /**
15
- * @var array
16
- */
17
- protected $_templateVars = array();
18
-
19
- /**
20
- * Transforms input string by replacing parameters in the
21
- * template string with corresponding values
22
- *
23
- * @link https://github.com/leek/zf-components/blob/master/library/Leek/Config.php
24
- *
25
- * @param string $subject Template string
26
- * @param array $map Key / value pairs to substitute with
27
- * @param string $delimiter Template parameter delimiter (must be valid without escaping in a regular expression)
28
- * @param bool $blankIfNone Set to blank if none found
29
- *
30
- * @return string
31
- * @static
32
- */
33
- public function templatize($subject, $map, $delimiter = '%', $blankIfNone = false)
34
- {
35
- if ($matches = $this->getTemplateVariables($subject, $delimiter)) {
36
- $map = array_change_key_case($map, CASE_LOWER);
37
- foreach ($matches as $match) {
38
- if (isset($map[$match])) {
39
- $subject = str_replace($delimiter . $match . $delimiter, $map[$match], $subject);
40
- } elseif ($blankIfNone) {
41
- $subject = str_replace($delimiter . $match . $delimiter, '', $subject);
42
- }
43
- }
44
- }
45
-
46
- return $subject;
47
- }
48
-
49
- /**
50
- * Get Variables from Template
51
- *
52
- * @param $subject
53
- * @param string $delimiter
54
- *
55
- * @return mixed
56
- */
57
- public function getTemplateVariables($subject, $delimiter = '%')
58
- {
59
- if (!isset($this->_templateVars[$subject])) {
60
- $this->_templateVars[$subject] = array();
61
- if (preg_match_all('/' . $delimiter . '([a-z0-9_]+)' . $delimiter . '/', $subject, $matches)) {
62
- if ($matches[1]) {
63
- $this->_templateVars[$subject] = $matches[1];
64
- }
65
- }
66
- }
67
-
68
- return $this->_templateVars[$subject];
69
- }
70
-
71
- /**
72
- * Get Product by ID and Store ID
73
- *
74
- * @param $productId
75
- * @param bool $storeId
76
- *
77
- * @return bool|Mage_Core_Model_Abstract
78
- */
79
- public function getProduct($productId, $storeId = false)
80
- {
81
- if (is_int($productId) || is_string($productId)) {
82
- if (isset($this->_productCache[$storeId][$productId])) {
83
- return $this->_productCache[$storeId][$productId];
84
- } elseif ($storeId) {
85
- $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
86
- } else {
87
- $product = Mage::getModel('catalog/product')->load($productId);
88
- }
89
- } else {
90
- $product = $productId;
91
- }
92
-
93
- if (!is_object($product) || !($product instanceOf Mage_Catalog_Model_Product)) {
94
- return Mage::getModel('catalog/product');
95
- } else {
96
- $productId = $product->getId();
97
- }
98
-
99
- $this->_productCache[$storeId][$productId] = $product;
100
-
101
- return $product;
102
- }
103
-
104
- /**
105
- * Is this product visible individually?
106
- *
107
- * @param Mage_Catalog_Model_Product $product
108
- * @return boolean
109
- */
110
- public function isVisibleInidividually($product)
111
- {
112
- return $product->getVisibility() != Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
113
- }
114
-
115
- /**
116
- * Gets the configurable product if the product is a simple/configurable
117
- *
118
- * @param Mage_Catalog_Model_Product $product
119
- * @return Mage_Catalog_Model_Product
120
- */
121
- public function getConfigurableProduct($product)
122
- {
123
- if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
124
- $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
125
- if (isset($parentIds[0])) {
126
- return $this->getProduct($parentIds[0], $product->getStoreId());
127
- }
128
- }
129
- return $product;
130
- }
131
-
132
- /**
133
- * Gets the grouped product parent if this simple product belongs to a group
134
- *
135
- * @param Mage_Catalog_Model_Product $product
136
- * @return Mage_Catalog_Model_Product
137
- */
138
- public function getGroupedProduct($product)
139
- {
140
- if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
141
- $parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
142
- if (isset($parentIds[0])) {
143
- return $this->getProduct($parentIds[0], $product->getStoreId());
144
- }
145
- }
146
- return $product;
147
- }
148
-
149
- /**
150
- * Get Attributes for Product
151
- *
152
- * @param $productId
153
- * @param $name
154
- * @param bool $storeId
155
- *
156
- * @return bool|mixed|string
157
- */
158
- public function getProductAttribute($productId, $name, $storeId = false)
159
- {
160
- if ($product = $this->getProduct($productId, $storeId)) {
161
- try {
162
- switch ($name) {
163
- case 'img':
164
- case 'image':
165
- return Mage::helper('bronto_common')->getProductImageUrl($product);
166
- // return $product->getSmallImageUrl();
167
- case 'url':
168
- if (!$this->isVisibleInidividually($product)) {
169
- $product = $this->getGroupedProduct($product);
170
- }
171
- return Mage::helper('catalog/product')->getProductUrl($product);
172
- }
173
-
174
- $inputType = $product->getResource()
175
- ->getAttribute($name)
176
- ->getFrontend()
177
- ->getInputType();
178
-
179
- switch ($inputType) {
180
- case 'multiselect':
181
- case 'select':
182
- case 'dropdown':
183
- $value = $product->getAttributeText($name);
184
- if (is_array($value)) {
185
- $value = implode(', ', $value);
186
- }
187
- break;
188
- default:
189
- $value = $product->getData($name);
190
- break;
191
- }
192
-
193
- return $value;
194
- } catch (Exception $e) {
195
- //
196
- }
197
- }
198
-
199
- return false;
200
- }
201
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Salesrule.php DELETED
@@ -1,39 +0,0 @@
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
- return Mage::getModel('bronto_common/system_config_source_coupon')
37
- ->toOptionArray();
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Helper/Support.php DELETED
@@ -1,547 +0,0 @@
1
- <?php
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
- const XML_PATH_CLEAR_LOGS = 'bronto/settings/clear_logs';
10
- const XML_PATH_LOG_THRES = 'bronto/settings/log_threshold';
11
-
12
- // Process registration
13
- protected $_registrationUrl = 'https://brontops.com/register/magento';
14
-
15
- // Last time the support information was pushed
16
- protected $_lastRun;
17
- protected $_client;
18
-
19
- protected $_supportFormFields = array(
20
- 'site_name',
21
- 'firstname',
22
- 'lastname',
23
- 'email',
24
- 'number',
25
- 'title',
26
- 'using_solution_partner',
27
- 'partner',
28
- 'terms',
29
- 'magento_version',
30
- 'magento_edition',
31
- 'extension_version',
32
- );
33
-
34
- /**
35
- * @return bool
36
- */
37
- public function isRegistered()
38
- {
39
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_REGISTERED);
40
- }
41
-
42
- /**
43
- * @return bool
44
- */
45
- public function shouldClearLogs()
46
- {
47
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_CLEAR_LOGS);
48
- }
49
-
50
- public function getLogThreshold()
51
- {
52
- return (int)$this->getAdminScopedConfig(self::XML_PATH_LOG_THRES) * (60 * 60 * 24);
53
- }
54
-
55
- /**
56
- * @param $onBronto boolean (optional)
57
- * @return boolean
58
- */
59
- public function verifyRegistration($onBronto = false) {
60
- if (!$this->isRegistered()) {
61
- $appendix = '<a href="#bronto_support-head">below</a>.';
62
- if (!$onBronto) {
63
- $registerUrl = Mage::getSingleton('adminhtml/url')
64
- ->getUrl('*/system_config/edit', array('section' => 'bronto'));
65
- $appendix = '<a href="' . $registerUrl . '">here</a>.';
66
- }
67
- $this->_addSingleSessionMessage(
68
- 'warning',
69
- 'Please register your Bronto extension ' . $appendix
70
- );
71
- return false;
72
- }
73
- return true;
74
- }
75
-
76
- /**
77
- * @return int
78
- */
79
- public function getLastRunTimestamp()
80
- {
81
- if (is_null($this->_lastRun)) {
82
- $lastRun = $this->getAdminScopedConfig(self::XML_PATH_LAST_RUN);
83
- $this->_lastRun = $lastRun ? $lastRun : 0;
84
- }
85
-
86
- return $this->_lastRun;
87
- }
88
-
89
- /**
90
- * Set the registration value for this extension
91
- *
92
- * @param boolean $register
93
- *
94
- * @return Mage_Core_Helper_Data
95
- */
96
- public function setRegistered($register = true)
97
- {
98
- $config = Mage::getModel('core/config');
99
- $config->saveConfig(self::XML_PATH_REGISTERED, $register ? '1' : '0', 'default', 0);
100
-
101
- // Force the register to pickup immediately
102
- Mage::getConfig()->reinit();
103
- Mage::app()->reinitStores();
104
-
105
- return $this;
106
- }
107
-
108
- /**
109
- * Set the last run time for this extension
110
- *
111
- * @param string $date
112
- *
113
- * @return $this
114
- */
115
- public function setLastRunDate($date)
116
- {
117
- $this->_lastRun = Mage::getModel('core/date')->timestamp($date);
118
-
119
- $config = Mage::getModel('core/config');
120
- $config->saveConfig(self::XML_PATH_LAST_RUN, $this->_lastRun, 'default', 0);
121
-
122
- return $this;
123
- }
124
-
125
- /**
126
- * Retrieves some support information
127
- *
128
- * @return array
129
- */
130
- public function getSupportInformation()
131
- {
132
- $data = array();
133
- foreach ($this->_supportFormFields as $key) {
134
- switch ($key) {
135
- case 'extension_version':
136
- $value = 'v' . $this->getModuleVersion();
137
- break;
138
- case 'magento_version':
139
- $value = 'v' . Mage::getVersion();
140
- break;
141
- case 'magento_edition':
142
- $value = $this->getEdition();
143
- break;
144
- default:
145
- $value = $this->getAdminScopedConfig(self::XML_PATH_SUPPORT . "/$key");
146
- }
147
- $data[$key] = $value ? $value : '';
148
- }
149
-
150
- return $data;
151
- }
152
-
153
- /**
154
- * Determines if this last run is a day old
155
- *
156
- * @param string $currentDate
157
- *
158
- * @return boolean
159
- */
160
- public function isLastRunDifferent($currentDate)
161
- {
162
- $lastRun = $this->getLastRunTimestamp();
163
-
164
- return $lastRun != Mage::getModel('core/date')->timestamp($currentDate);
165
- }
166
-
167
- /**
168
- * Gets the number of the reminder rules
169
- *
170
- * @param string $currentDate
171
- *
172
- * @return int
173
- */
174
- public function getActiveReminderRules($currentDate)
175
- {
176
- return Mage::getModel('bronto_reminder/rule')
177
- ->getCollection()
178
- ->addDateFilter($currentDate)
179
- ->addIsActiveFilter(1)
180
- ->count();
181
- }
182
-
183
- /**
184
- * Returns debug information as a collection
185
- *
186
- * @return array
187
- */
188
- public function getDebugInformation($scope = 'default', $scope = 0)
189
- {
190
- $currentDate = Mage::getModel('core/date')->date('Y-m-d');
191
- $brontoModules = $this->getEnabledBrontoModules();
192
- $formData = $this->getSupportInformation();
193
- $request = Mage::app()->getRequest();
194
-
195
- return array_merge(
196
- // Form submission
197
- $formData,
198
- // Current Websites / Stores; Enabled Bronto Modules
199
- array(
200
- // Client / Server information
201
- 'server_name' => $request->getServer('SERVER_NAME'),
202
- 'server_address' => $request->getServer('SERVER_ADDR'),
203
- 'server_protocol' => $request->getServer('SERVER_PROTOCOL'),
204
- 'php_version' => 'v' . phpversion(),
205
- 'mysql_version' => 'v' . Mage::getResourceModel('core/config')->getReadConnection()->getServerVersion(),
206
- 'number_active_rules' => $this->getActiveReminderRules($currentDate),
207
- ),
208
- array(
209
- // Installed Modules
210
- 'installed_modules' => $this->getInstalledModules(),
211
- 'magento_installation' => $this->getStoreInfo(),
212
- ),
213
- array(
214
- 'bronto_modules' => $brontoModules,
215
- 'bronto_config' => $this->getBrontoConfigs($brontoModules, $scope, $scopeId)
216
- )
217
- );
218
- }
219
-
220
- /**
221
- * Submits the Support form information
222
- *
223
- * @param array $formData (Optional)
224
- *
225
- * @return boolean
226
- */
227
- public function submitSupportForm($formData = array())
228
- {
229
- $currentDate = Mage::getModel('core/date')->date('Y-m-d');
230
- $this->setLastRunDate($currentDate)->setRegistered();
231
-
232
- $formData['extension_version'] = 'v' . $this->getModuleVersion();
233
- $formData['magento_version'] = 'v' . Mage::getVersion();
234
- $formData['magento_edition'] = $this->getEdition();
235
-
236
- $yesNo = Mage::getModel('adminhtml/system_config_source_yesno');
237
- foreach (array('using_solution_partner', 'terms') as $formKey) {
238
- if (array_key_exists($formKey, $formData)) {
239
- $selectedValue = $formData[$formKey];
240
- foreach ($yesNo->toOptionArray() as $option) {
241
- if ($option['value'] == $selectedValue) {
242
- $formData[$formKey] = $option['label'];
243
- }
244
- }
245
- }
246
- }
247
-
248
- return $this->_submitWebform(
249
- array_merge($this->getSupportInformation(), $formData)
250
- );
251
- }
252
-
253
- /**
254
- * Gets the Bronto Modules install on the server
255
- *
256
- * @return array
257
- */
258
- public function getEnabledBrontoModules()
259
- {
260
- $brontoModules = array();
261
-
262
- $modules = Mage::getConfig()->getNode('modules')->children();
263
- foreach ($modules as $name => $module) {
264
- if (
265
- $module->active == 'true' &&
266
- strpos($name, 'Bronto_') !== false &&
267
- (
268
- $name == 'Bronto_Common' ||
269
- Mage::helper(strtolower($name))->isEnabled()
270
- )
271
- ) {
272
- $brontoModules[$name] = 'v' . $module->version;
273
- }
274
- }
275
-
276
- return $brontoModules;
277
- }
278
-
279
- /**
280
- * Gets the Bronto configuration settings
281
- *
282
- * @param array $brontoModules
283
- * @param string $scope
284
- * @param int $scopeId
285
- *
286
- * @return array
287
- */
288
- public function getBrontoConfigs($brontoModules, $scope = 'default', $scopeId = 0)
289
- {
290
- $configs = array();
291
- $processedConfigs = array();
292
-
293
- foreach ($brontoModules as $name => $module) {
294
- $helperName = strtolower($name);
295
-
296
- $helper = Mage::helper($helperName);
297
- $reflector = new ReflectionClass(get_class($helper));
298
-
299
- $moduleConfig = array();
300
- foreach ($reflector->getConstants() as $cName => $setting) {
301
- if ($cName == 'XML_PATH_ENABLED' || isset($processedConfigs[$setting])) {
302
- continue;
303
- }
304
-
305
- $settingNameParts = explode('/', $setting);
306
- $settingName = end($settingNameParts);
307
-
308
- $value = $this->getAdminScopedConfig($setting, $scope, $scopeId);
309
- if (empty($settingName)) {
310
- continue;
311
- }
312
-
313
- $processedConfigs[$setting] = $value;
314
- $moduleConfig[$settingName] = $value;
315
- }
316
-
317
- if ($helper->hasCustomConfig()) {
318
- $moduleConfig = array_merge($moduleConfig, $helper->getCustomConfig($scope, $scopeId));
319
- }
320
-
321
- if ($moduleConfig) {
322
- $configs["{$helperName}_config"] = $moduleConfig;
323
- }
324
- }
325
-
326
- return $configs;
327
- }
328
-
329
- /**
330
- * Retrieve website and store count
331
- *
332
- * @return array
333
- */
334
- public function getStoreInfo()
335
- {
336
- $storeInfo = array();
337
- $websites = Mage::app()->getWebsites();
338
- $totalWebsites = count($websites);
339
- $totalStores = 0;
340
- foreach ($websites as $website) {
341
- $websiteStores = count($website->getStores());
342
- $totalStores += $websiteStores;
343
- $s = $websiteStores == 1 ? '' : 's';
344
- $storeInfo[] = "A website with $websiteStores store$s.";
345
- }
346
- $websites = $totalWebsites == 1 ? 'website' : 'websites';
347
- $stores = $totalStores == 1 ? 'store' : 'stores';
348
-
349
- $storeInfo[] = "Total of $totalWebsites $websites and $totalStores $stores";
350
-
351
- return $storeInfo;
352
- }
353
-
354
- /**
355
- * Creates a log archive with the last 30 days of files in it
356
- *
357
- * @return Bronto_Common_Model_Archive
358
- */
359
- public function getLogArchive()
360
- {
361
- $logDir = Mage::getBaseDir('var') . DS . 'log';
362
- $systemLog = $logDir . DS . 'system.log';
363
- $exceptionLog = $logDir . DS . 'exception.log';
364
-
365
- $brontoLogDir = $logDir . DS . 'bronto';
366
- $tmpDir = $this->getArchiveDirectory();
367
- $file = $tmpDir . DS . 'log.' . time() . '.zip';
368
-
369
- $archive = Mage::getModel('bronto_common/archive');
370
- if ($archive->open($file, ZipArchive::OVERWRITE)) {
371
- $now = time();
372
- $threshold = $now - $this->getLogThreshold();
373
-
374
- $archive->addEmptyDir('log');
375
-
376
- if (file_exists($systemLog)) {
377
- $archive->addFromString('log/system.log', $this->_tailLog($systemLog));
378
- }
379
-
380
- if (file_exists($exceptionLog)) {
381
- $archive->addFromString('log/exception.log', $this->_tailLog($exceptionLog));
382
- }
383
-
384
- $archive->addFromString('log/phpinfo.html', $this->getPhpInfoOutput());
385
- $archive->addEmptyDir('log/bronto');
386
- foreach (glob($brontoLogDir . DS . "*.log") as $logFile) {
387
- $stat = lstat($logFile);
388
- if ($stat['mtime'] < $threshold) {
389
- continue;
390
- }
391
- $archive->addFile($logFile, 'log/bronto/' . basename($logFile));
392
- }
393
- $archive->close();
394
- } else {
395
- Mage::throwException('Could not create archive at ' . $file);
396
- }
397
-
398
- return $archive;
399
- }
400
-
401
- /**
402
- * Removes log files that are over the threshold old
403
- *
404
- * @return bool
405
- */
406
- public function clearOldLogs()
407
- {
408
- $logDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
409
- $threshold = time() - $this->getLogThreshold();
410
-
411
- $success = true;
412
- foreach (glob($logDir . DS . '*log') as $logFile) {
413
- $stat = lstat($logFile);
414
- if ($stat['mtime'] < $threshold) {
415
- $success = $success && unlink($logFile);
416
- }
417
- }
418
- return $success;
419
- }
420
-
421
- /**
422
- * Tails a given log for output
423
- *
424
- * @param $logfile
425
- *
426
- * @return string
427
- */
428
- protected function _tailLog($logfile)
429
- {
430
- $length = filesize($logfile);
431
- $maxRead = (1 * 1000 * 100);
432
- $fh = fopen($logfile, 'r');
433
- if ($length > $maxRead) {
434
- fseek($fh, $length - $maxRead);
435
- }
436
- $contents = fread($fh, $maxRead);
437
- fclose($fh);
438
-
439
- return $contents;
440
- }
441
-
442
-
443
- /**
444
- * Gets the PHPInfo in string format
445
- *
446
- * @return string
447
- */
448
- public function getPhpInfoOutput()
449
- {
450
- ob_start();
451
- phpinfo();
452
-
453
- return ob_get_clean();
454
- }
455
-
456
- /**
457
- * Gets the archive directory
458
- *
459
- * @return string
460
- */
461
- public function getArchiveDirectory()
462
- {
463
- $brontoLogDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
464
- $tmpDir = $brontoLogDir . DS . 'archives';
465
- if (!file_exists($tmpDir)) {
466
- mkdir($tmpDir, 0777, true);
467
- }
468
-
469
- return $brontoLogDir . DS . 'archives';
470
- }
471
-
472
- /**
473
- * Deletes all of the archive logs
474
- */
475
- public function clearArchiveDirectory()
476
- {
477
- foreach (glob($this->getArchiveDirectory() . DS . '*') as $file) {
478
- unlink($file);
479
- }
480
- }
481
-
482
- /**
483
- * Sets the internal webform submission client
484
- *
485
- * @param Mage_HTTP_Client_Curl $client
486
- *
487
- * @return Bronto_Common_Helper_Support
488
- */
489
- public function setHttpClient(Mage_HTTP_Client_Curl $client)
490
- {
491
- $this->_client = $client;
492
-
493
- return $this;
494
- }
495
-
496
- /**
497
- * Returns the Curl client used to submit the webform
498
- *
499
- * @return Mage_HTTP_Client_Curl
500
- */
501
- protected function _getHttpClient()
502
- {
503
- if (empty($this->_client)) {
504
- $this->_client = new Mage_HTTP_Client_Curl();
505
- }
506
-
507
- return $this->_client;
508
- }
509
-
510
- /**
511
- * Submits a webform with the registration info
512
- *
513
- * @param array $formData
514
- *
515
- * @return bool
516
- */
517
- protected function _submitWebform(array $formData)
518
- {
519
-
520
- $client = $this->_getHttpClient();
521
- $params = array();
522
- foreach ($this->_supportFormFields as $name) {
523
- $parts = explode('_', $name);
524
- $restCamel = array_map('ucfirst', array_slice($parts, 1));
525
- $camel = implode('', array_merge(array($parts[0]), $restCamel));
526
-
527
- $params[$camel] = $formData[$name];
528
- }
529
-
530
- $json = Mage::helper('core')->jsonEncode($params);
531
-
532
- try {
533
- $client->setOptions(array(
534
- CURLOPT_SSL_VERIFYPEER => 0,
535
- CURLOPT_POSTFIELDS => $json
536
- ));
537
- $client->post($this->_registrationUrl, $params);
538
- } catch (Exception $e) {
539
- var_dump($e->getMessage());
540
- $this->writeError('Registration submission failed: ', $e->getMessage());
541
-
542
- return false;
543
- }
544
-
545
- return true;
546
- }
547
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Api.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Common
6
- */
7
- class Bronto_Common_Model_Api extends Mage_Core_Model_Abstract implements Bronto_Api_Observer
8
- {
9
-
10
- protected static $_instances = array();
11
-
12
- /**
13
- * @see parent
14
- */
15
- protected function _construct()
16
- {
17
- parent::_construct();
18
- $this->_init('bronto_common/api');
19
- }
20
-
21
- /**
22
- * Gets the Bronto_Api client for for use in Magento
23
- *
24
- * @return Bronto_Api
25
- */
26
- public function getClient()
27
- {
28
- $token = $this->getToken();
29
- if (!isset(self::$_instances[$token])) {
30
- $options = Mage::helper('bronto_common/api')->getSoapOptions();
31
- if (empty($options['observer'])) {
32
- $options['observer'] = $this;
33
- }
34
- self::$_instances[$token] = new Bronto_Api($token, $options);
35
- }
36
- if ($this->hasSessionId()) {
37
- self::$_instances[$token]->setSessionId($this->getSessionId());
38
- }
39
- return self::$_instances[$token];
40
- }
41
-
42
- /**
43
- * @see parent
44
- *
45
- * @param Bronto_Api $api
46
- */
47
- public function onBeforeLogin($api)
48
- {
49
- if ($this->hasSetSession()) {
50
- $this->unsSessionId();
51
- Mage::helper('bronto_common')->writeDebug('Session ID expired for token: ' . $this->getToken());
52
- $this->_setOnce = false;
53
- } else {
54
- try {
55
- parent::load($api->getToken());
56
- if ($this->hasSessionId()) {
57
- $api->setSessionId($this->getSessionId());
58
- Mage::helper('bronto_common')->writeDebug('Hitting API sessionId cache for token: ' . $this->getToken());
59
- $this->_setOnce = true;
60
- }
61
- } catch (Exception $e) {
62
- // Swallow read exceptions, in case of FTP install
63
- Mage::helper('bronto_common')->writeError('Failed to read from api session table: ' . $e->getMessage());
64
- }
65
- }
66
- }
67
-
68
- /**
69
- * @see parent
70
- *
71
- * @param string $apiToken
72
- * @param string $sessionId
73
- */
74
- public function onLogin($apiToken, $sessionId)
75
- {
76
- try {
77
- $this
78
- ->setToken($apiToken)
79
- ->setSessionId($sessionId)
80
- ->setCreatedAt(Mage::getSingleton('core/date')->gmtDate())
81
- ->save();
82
- Mage::helper('bronto_common')->writeDebug("Initiating API for token: {$this->getToken()}");
83
- } catch (Exception $e) {
84
- Mage::helper('bronto_common')->writeError("Failed to update API {$this->getToken()} Session: " . $e->getMessage());
85
- }
86
- }
87
-
88
- /**
89
- * @see parent
90
- *
91
- * @param Bronto_Api $api
92
- * @param Bronto_Api_Exception $exception
93
- */
94
- public function onError(Bronto_Api $api, Bronto_Api_Exception $exception)
95
- {
96
- if ($exception instanceOf Bronto_Api_Exception) {
97
- if ($request = $api->getLastRequest()) {
98
- Mage::helper('bronto_common')->writeDebug(var_export($request, true));
99
- }
100
-
101
- if ($response = $api->getLastResponse()) {
102
- Mage::helper('bronto_common')->writeDebug(var_export($response, true));
103
- }
104
- }
105
- }
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Archive.php DELETED
@@ -1,86 +0,0 @@
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/Container/Cart/Recovery.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Container_Cart_Recovery extends Enterprise_PageCache_Model_Container_Abstract
4
- {
5
- /**
6
- * @see parent
7
- */
8
- protected function _getCacheId()
9
- {
10
- return 'BRONTO_CART_RECOVERY_' . $this->_getIdentifier() . '_' . rand(0, 99);
11
- }
12
-
13
- /**
14
- * @see parent
15
- */
16
- protected function _renderBlock()
17
- {
18
- $blockClass = $this->_placeholder->getAttribute('block');
19
- $template = $this->_placeholder->getAttribute('template');
20
- $block = new $blockClass;
21
- $block->setTemplate($template);
22
- $block->setLayout(Mage::app()->getLayout());
23
- return $block->toHtml();
24
- }
25
-
26
- /**
27
- * Gets a unique id from timestamp
28
- *
29
- * @return string
30
- */
31
- protected function _getIdentifier()
32
- {
33
- return microtime();
34
- }
35
-
36
- /**
37
- * @see parent
38
- */
39
- protected function _saveCache($data, $id, $tags = array(), $lifetime = null)
40
- {
41
- return false;
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Coupon/Observer.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Coupon_Observer
4
- {
5
- const TARGET_AREA = 'frontend';
6
-
7
- protected $_helper;
8
-
9
- /**
10
- * Simple constructor override for helpers
11
- */
12
- public function __construct()
13
- {
14
- $this->_helper = Mage::helper('bronto_common/coupon');
15
- }
16
-
17
- /**
18
- * Is the observer applicable in this case?
19
- *
20
- * @param Mage_Core_Controller_Front_Action $action
21
- * @return boolean
22
- */
23
- protected function _isApplicable($action)
24
- {
25
- return (
26
- $action->getLayout()->getArea() == self::TARGET_AREA &&
27
- $this->_helper->isEnabled() &&
28
- $this->_helper->isObservingController()
29
- );
30
- }
31
-
32
- /**
33
- * Sets the coupon code on the quote or on the session
34
- *
35
- * @param Varien_Event_Observer $observer
36
- */
37
- public function addCodeToSession($observer)
38
- {
39
- $action = $observer->getControllerAction();
40
- if ($this->_isApplicable($action)) {
41
- $this->_helper->applyCodeFromRequest($action->getRequest());
42
- }
43
- return false;
44
- }
45
-
46
- /**
47
- * Sets the coupon code on the quote
48
- *
49
- * @param Varien_Event_Observer $observer
50
- */
51
- public function addCodeToQuote($observer)
52
- {
53
- $this->_helper->applyCode();
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Email/Template.php DELETED
@@ -1,627 +0,0 @@
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
- {
9
- /**
10
- * @var string
11
- */
12
- protected $_helper = 'bronto_common';
13
-
14
- /**
15
- * @var Bronto_Api_Model_Message
16
- */
17
- protected $_message;
18
-
19
- /**
20
- * @var string
21
- */
22
- protected $_lastDeliveryId;
23
-
24
- /**
25
- * @var Bronto_Email_Model_Log
26
- */
27
- protected $_log;
28
-
29
- /**
30
- * Set the message
31
- *
32
- * @param Bronto_Api_Model_Message $message
33
- */
34
- public function setMessage(Bronto_Api_Model_Message $message)
35
- {
36
- $this->_message = $message;
37
- }
38
-
39
- /**
40
- * Get the message currently set
41
- *
42
- * @return boolean|Bronto_Api_Model_Message False if no message is set
43
- */
44
- public function getMessage()
45
- {
46
- if (empty($this->_message)) {
47
- $messageId = $this->getBrontoMessageId();
48
- if (!empty($messageId)) {
49
- $this->_message = Mage::helper('bronto_common/message')->getMessageById($messageId);
50
- } else {
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
- {
67
- if (!Mage::helper($this->_helper)->canSendBronto($this, $storeId)) {
68
- return parent::getTemplateFilter();
69
- }
70
-
71
- if (empty($this->_templateFilter)) {
72
- $this->_templateFilter = Mage::getModel('bronto_common/email_template_filter');
73
- if (method_exists($this->_templateFilter, 'getInlineCssFile')) {
74
- $this->_templateFilter
75
- ->setUseAbsoluteLinks($this->getUseAbsoluteLinks())
76
- ->setStoreId($this->getDesignConfig()->getStore());
77
- }
78
- }
79
-
80
- return $this->_templateFilter;
81
- }
82
-
83
- /**
84
- * Gets the the global recommendation or the one configured for the email
85
- *
86
- * @param int $storeId
87
- * @return int
88
- */
89
- protected function _getRecommendationId($storeId = null)
90
- {
91
- $recommendationId = $this->getProductRecommendation();
92
- if ($recommendationId) {
93
- return $recommendationId;
94
- }
95
-
96
- if ($this->_helper == 'bronto_email') {
97
- $recommendationId = Mage::helper('bronto_email')->getDefaultRecommendation('store', $storeId);
98
- }
99
-
100
- return $recommendationId;
101
- }
102
-
103
- /**
104
- * Gets the global rule id or the one configured for the email
105
- *
106
- * @param int $storeId
107
- * @return int
108
- */
109
- protected function _getSalesRule($storeId = null)
110
- {
111
- $rule = Mage::getModel('salesrule/rule');
112
- $ruleId = $this->getSalesRule();
113
- if ($ruleId) {
114
- if ($rule->load($ruleId)->getId()) {
115
- return $rule;
116
- }
117
- }
118
-
119
- if ($this->_helper == 'bronto_email') {
120
- $ruleId = Mage::helper('bronto_email')->getDefaultRule('store', $storeId);
121
- if ($ruleId) {
122
- if ($rule->load($ruleId)->getId()) {
123
- return $rule;
124
- }
125
- }
126
- }
127
-
128
- return null;
129
- }
130
-
131
- /**
132
- * Gets the delivery flags for this message
133
- *
134
- * @param int $storeId
135
- * @return int
136
- */
137
- protected function _getSendFlags($storeId = null)
138
- {
139
- $sendFlags = $this->getSendFlags();
140
- if ($sendFlags) {
141
- return $sendFlags;
142
- }
143
-
144
- if ($this->_helper == 'bronto_email') {
145
- $sendFlags = Mage::helper('bronto_email')->getDefaultSendFlags('store', $storeId);
146
- }
147
- return $sendFlags;
148
- }
149
-
150
- /**
151
- * Process email template code
152
- *
153
- * @param Bronto_Api_Model_Delivery $delivery
154
- * @param array $variables
155
- *
156
- * @return Bronto_Api_Model_Delivery
157
- */
158
- public function getProcessedDelivery(Bronto_Api_Model_Delivery $delivery, array $variables = array())
159
- {
160
- $processor = $this->getTemplateFilter($variables['store']->getId());
161
-
162
- if (isset($variables['subscriber']) && ($variables['subscriber'] instanceof Mage_Newsletter_Model_Subscriber)) {
163
- $processor->setStoreId($variables['subscriber']->getStoreId());
164
- }
165
-
166
- if ($this->getBrontoMessageId()) {
167
- $processor->setMessageId($this->getBrontoMessageId());
168
- }
169
-
170
- if (method_exists($this, '_addEmailVariables')) {
171
- $variables = $this->_addEmailVariables($variables, $processor->getStoreId());
172
- }
173
-
174
- $processor->setVariables($variables);
175
- $processor->setAvailable($this->getVariablesOptionArray());
176
-
177
- $appEmu = Mage::getSingleton('core/app_emulation');
178
- $emuInfo = $appEmu->startEnvironmentEmulation($processor->getStoreId(), 'frontend');
179
- try {
180
- $this->setInlineCssFile($this->getInlineCss() ? $this->getInlineCss() : 'email-inline.css');
181
- $processor->setBaseTemplate($this);
182
- $delivery = $processor->filter($delivery);
183
- } catch (Exception $e) {
184
- $appEmu->stopEnvironmentEmulation($emuInfo);
185
- throw $e;
186
- }
187
- $appEmu->stopEnvironmentEmulation($emuInfo);
188
- return $delivery;
189
- }
190
-
191
- /**
192
- * If this message can be used for sending queue as main template
193
- *
194
- * @return boolean
195
- */
196
- public function isMessageValidForSend()
197
- {
198
- if (!($this->getSenderName() && $this->getSenderEmail())) {
199
- Mage::helper($this->_helper)->writeError(' Message cannot be sent: Sender Name or Email is not set');
200
-
201
- return false;
202
- }
203
-
204
- return true;
205
- }
206
-
207
- /**
208
- * TODO: move this into an event handler of some kind
209
- * Gets any related fields for a delivery
210
- *
211
- * @param Bronto_Common_Model_Queue $queue
212
- */
213
- protected function _setRelatedFields($queue)
214
- {
215
- $helper = Mage::helper('bronto_product');
216
- $info = $queue->getRecommendationInfo();
217
- if ($info->getId() && $helper->isEnabled('store', $queue->getStoreId())) {
218
- $recommendation = Mage::getModel('bronto_product/recommendation')
219
- ->load($info->getId());
220
- if ($recommendation->hasEntityId()) {
221
- $data = $queue->getUnserializedEmailData()->getData();
222
- if ($info->getCustomer()) {
223
- $customer = Mage::getModel('customer/customer')->setId($info->getCustomer());
224
- $recommendation->setCustomer($customer);
225
- }
226
- $hash = $helper->collectRecommendations(
227
- $recommendation,
228
- $queue->getStoreId(),
229
- $info->getProductIds());
230
- $fields = $helper->relatedFields($hash, $queue->getStoreId());
231
- foreach ($fields as $relatedFields) {
232
- $data['delivery']['fields'] = array_merge($data['delivery']['fields'], $relatedFields);
233
- }
234
- $queue->setUnserializedEmailData($data);
235
- }
236
- }
237
- }
238
-
239
- /**
240
- * Sends a Bronto Delivery
241
- *
242
- * @param Bronto_Common_Model_Queue $queue
243
- * @return boolean
244
- */
245
- public function sendDeliveryFromQueue($queue)
246
- {
247
- $deliveryErrors = 0;
248
- $message = $queue->getMessage();
249
- $contacts = $queue->getContacts();
250
-
251
- $this->setSendQueue($queue);
252
- $this->setMessage($message);
253
- $this->setBrontoMessageId($message->getId());
254
- $this->setBrontoMessageName($message->getName());
255
- $this->setBrontoMessageApproved(1);
256
- $this->_setRelatedFields($queue);
257
-
258
- foreach ($contacts as $contact) {
259
- $this->_beforeSend($contact, $message);
260
- if (!$contact->id) {
261
- $deliveryErrors++;
262
- $this->_afterSend(false, "{$contact->email}: {$contact->error}");
263
- continue;
264
- }
265
- try {
266
- $delivery = $queue->prepareDelivery()
267
- ->withStart($this->_startTime($queue->getStoreId()))
268
- ->addContact($contact->getId());
269
- $list = Mage::getModel('bronto_common/list', array(
270
- $this->_helper,
271
- $queue->getAdditionalData()->getExclusionList()
272
- ));
273
- $excludes = $list->addAdditionalRecipients($queue->getStoreId());
274
- foreach ($excludes as $exclude) {
275
- $delivery->ineligibleList($exclude['id']);
276
- }
277
- $queue->getDeliveryObject()->save($delivery);
278
- $this->setLastDeliveryId($delivery->getId());
279
- $this->_afterSend(true, null, $delivery);
280
- } catch (Exception $e) {
281
- $deliveryErrors++;
282
- $errorMessage = $e->getMessage();
283
- if ($e->getCode() === 215) {
284
- // Replace message id with message name
285
- if (preg_match_all("/([a-zA-Z0-9\-]){36}/", $errorMessage, $matches)) { // Grab field id if exists
286
- foreach ($matches[0] as $match) {
287
- $errorMessage = str_replace($match, $message->getName(), $errorMessage);
288
- }
289
- }
290
- }
291
-
292
- Mage::helper($this->_helper)->writeError($errorMessage);
293
- $this->_afterSend(false, $errorMessage, $delivery);
294
- }
295
- $this->_flushLogs($queue->getDeliveryObject()->getApi());
296
- }
297
- return $deliveryErrors == 0;
298
- }
299
-
300
- /**
301
- * Write the API delivery flush
302
- *
303
- * @param Bronto_Api $api
304
- */
305
- protected function _flushLogs(Bronto_Api $api)
306
- {
307
- $helper = Mage::helper($this->_helper);
308
- $apiLog = "{$this->_helper}_api.log";
309
- $helper->writeVerboseDebug("===== {$helper->getName()} Delivery =====", $apiLog);
310
- $helper->writeVerboseDebug(var_export($api->getLastRequest(), true), $apiLog);
311
- $helper->writeVerboseDebug(var_export($api->getLastResponse(), true), $apiLog);
312
- }
313
-
314
- /**
315
- * Send mail to recipient
316
- *
317
- * @param array|string $email E-mail(s)
318
- * @param array|string|null $name receiver name(s)
319
- * @param array $variables template variables
320
- *
321
- * @return boolean
322
- */
323
- public function send($email, $name = null, array $variables = array())
324
- {
325
- // In the rare case we got here w/o hitting sendTransactional first...
326
- if (!isset($variables['store']) || !is_object($variables['store'])) {
327
- // Get the current store view, as to not break things
328
- $variables['store'] = Mage::app()->getStore();
329
- }
330
-
331
- // If not set to go through Bronto, fall through to magento sending
332
- if (!Mage::helper($this->_helper)->canSendBronto($this, $variables['store']->getId())) {
333
- return parent::send($email, $name, $variables);
334
- }
335
-
336
- $messageId = $this->getBrontoMessageId();
337
- $sendType = $this->getTemplateSendType();
338
- if ($sendType != 'transactional') {
339
- $sendType = 'triggered';
340
- }
341
-
342
- // If messageId is empty, send through Magento
343
- if (empty($messageId)) {
344
- return parent::send($email, $name, $variables);
345
- }
346
-
347
- // If message is not valid for sending, return false
348
- if (!$this->isMessageValidForSend()) {
349
- return false;
350
- }
351
-
352
- // Handle CC and BCC by simply adding as array
353
- $emails = array_values((array)$email);
354
- $names = is_array($name) ? $name : (array)$name;
355
- $names = array_values($names);
356
- foreach ($emails as $key => $email) {
357
- if (!isset($names[$key])) {
358
- $names[$key] = substr($email, 0, strpos($email, '@'));
359
- }
360
- }
361
-
362
- $variables['email'] = reset($emails);
363
- $variables['name'] = reset($names);
364
- $this->setUseAbsoluteLinks(true);
365
-
366
- $delivery = new Bronto_Api_Model_Delivery();
367
- $delivery = $this->getProcessedDelivery($delivery, $variables);
368
- $this->_additionalFields($delivery, $variables);
369
- $productContext = Mage::helper('bronto_product')
370
- ->itemsToProductHash($this->getTemplateFilter()
371
- ->getProductContext(), $variables['store']->getId());
372
- $sendOptions = Mage::getModel('bronto_common/system_config_source_sendOptions');
373
- $sendOption = $this->_getSendFlags($variables['store']->getId());
374
- if ($sendOptions->setDeliveryFlags($delivery, $sendOption)) {
375
- $optionLabels = $sendOptions->toArray();
376
- Mage::helper($this->_helper)->writeDebug("Setting send flags for messageId {$this->getBrontoMessageId()}: {$optionLabels[$sendOption]}");
377
- }
378
-
379
- $data = array(
380
- 'emails' => $emails,
381
- 'params' => $this->_additionalData(),
382
- 'recommendation' => array(
383
- 'product_ids' => array_keys($productContext),
384
- 'customer' => $this->getTemplateFilter()->getCustomerId(),
385
- 'id' => $this->_getRecommendationId($variables['store']->getId()),
386
- ),
387
- 'delivery' => array(
388
- 'messageId' => $messageId,
389
- 'type' => $sendType ? $sendType : 'transactional',
390
- 'fromEmail' => $this->getSenderEmail(),
391
- 'fromName' => $this->getSenderName(),
392
- 'replyEmail' => $this->getSenderEmail(),
393
- ) + $delivery->toArray()
394
- );
395
-
396
- $queue = Mage::getModel('bronto_common/queue')
397
- ->setStoreId($variables['store']->getId())
398
- ->setUnserializedEmailData($data)
399
- ->setEmailClass($this->_emailClass())
400
- ->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
401
-
402
- $apiHelper = Mage::helper('bronto_common/api');
403
- if ($this->_queuable() && $apiHelper->canUseQueue('store', $queue->getStoreId())) {
404
- try {
405
- $queue->save();
406
- return true;
407
- } catch (Exception $e) {
408
- $apiHelper->writeError('Failed to save email to queue for store ' . $queue->getStoreId() . ': ' . $e->getMessage());
409
- return $this->sendDeliveryFromQueue($queue);
410
- }
411
- } else {
412
- $api = $apiHelper->getApi(null, 'store', $variables['store']->getId());
413
- return $this->sendDeliveryFromQueue($queue->setApi($api));
414
- }
415
- }
416
-
417
- /**
418
- * Send transactional email to recipient
419
- *
420
- * @param int $templateId
421
- * @param string|array $sender Sender information, can be declared as part of config path
422
- * @param string $email Recipient email
423
- * @param string $name Recipient name
424
- * @param array $vars Variables which can be used in template
425
- * @param int|null $storeId
426
- *
427
- * @return Mage_Core_Model_Email_Template
428
- */
429
- public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
430
- {
431
- // If Template ID is 'nosend', then simply return false
432
- if ($templateId == 'nosend') {
433
- return false;
434
- }
435
-
436
- // If not set to go through Bronto, fall through to magento sending
437
- if (!Mage::helper($this->_helper)->canSendBronto($this, $storeId)) {
438
- return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
439
- } else {
440
- // If module enabled and template ID is not an instance of the api row, see if we can pull an instance
441
- if (!($templateId instanceof Bronto_Api_Model_Message)) {
442
- $emailTemplate = Mage::getModel('bronto_email/template')
443
- ->setDesignConfig($this->getDesignConfig()->getData());
444
-
445
- // If $templateId is numeric, load template by ID, else is default and should send through Magento
446
- if (is_numeric($templateId)) {
447
- $emailTemplate->load($templateId);
448
- } else {
449
- $this->setTemplateSendType('magento');
450
- return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
451
- }
452
-
453
- // If Template doesn't have a Bronto Message ID, send through magento
454
- if (!$emailTemplate->getBrontoMessageId() || is_null($emailTemplate->getBrontoMessageId())) {
455
- return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
456
- }
457
-
458
- $message = new Bronto_Api_Model_Message();
459
- $message->withId($emailTemplate->getBrontoMessageId());
460
-
461
- // Send through main template model
462
- $emailTemplate->sendTransactional(
463
- $message,
464
- $sender,
465
- $email,
466
- $name,
467
- $vars,
468
- $storeId
469
- );
470
-
471
- return $this->setSentSuccess($emailTemplate->getSentSuccess());
472
- } else {
473
- $this->setBrontoMessageId($templateId->id);
474
- }
475
- }
476
-
477
- // Start the send process
478
- $this->setSentSuccess(false);
479
- if (($storeId === null) && $this->getDesignConfig()->getStore()) {
480
- $storeId = $this->getDesignConfig()->getStore();
481
- }
482
-
483
- // If $sender is not array, it is a reference to a config setting, otherwise it should have 'name' and 'email'
484
- if (!is_array($sender)) {
485
- $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
486
- $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
487
- } else {
488
- $this->setSenderName($sender['name']);
489
- $this->setSenderEmail($sender['email']);
490
- }
491
-
492
- // If store is not set, set it
493
- if (!isset($vars['store'])) {
494
- $vars['store'] = Mage::app()->getStore($storeId);
495
- }
496
-
497
- // Check for Sales Rules
498
- if (!isset($vars['coupon']) && $rule = $this->_getSalesRule($storeId)) {
499
- try {
500
- /** @var Mage_SalesRule_Model_Coupon $coupon */
501
- $coupon = $rule->acquireCoupon();
502
-
503
- if ($coupon) {
504
- $vars['coupon'] = $coupon;
505
- }
506
- } catch (Exception $e) {
507
- Mage::helper($this->_helper)->writeError(' Failed loading Sales Rule with ID: ' . $rule->getId());
508
- }
509
- }
510
-
511
- // Send
512
- $this->setSentSuccess($this->send($email, $name, $vars));
513
-
514
- return $this;
515
- }
516
-
517
- /**
518
- * @param string $deliveryId
519
- *
520
- * @return Bronto_Common_Model_Email_Template
521
- */
522
- public function setLastDeliveryId($deliveryId)
523
- {
524
- $this->_lastDeliveryId = $deliveryId;
525
- return $this;
526
- }
527
-
528
- /**
529
- * @return string
530
- */
531
- public function getLastDeliveryId()
532
- {
533
- return $this->_lastDeliveryId;
534
- }
535
-
536
- /**
537
- * Allows the retryer to trigger
538
- *
539
- * @param Bronto_Api_Delivery $deliveryObject
540
- * TODO: API fix
541
- */
542
- public function triggerBeforeAfterSend(Bronto_Api_Operation_Delivery $deliveryOps, Bronto_Api_Model_Delivery $delivery)
543
- {
544
- $contactObject = $deliveryOps->getApi()->transferContact();
545
- $messageObject = $deliveryOps->getApi()->transferMessage();
546
-
547
- try {
548
- $this->_flushLogs($deliveryOps->getApi());
549
-
550
- $message = $messageObject->getById($delivery->getMessageId());
551
- $contact = $contactObject->getById($delivery->recipients[0]['id']);
552
-
553
- $this->_beforeSend($contact, $message);
554
- $this->_afterSend(true, null, $delivery);
555
- } catch (Exception $e) {
556
- Mage::helper($this->_helper)->writeError('Failed to trigger email send: ' . $e->getMessage());
557
- }
558
- }
559
-
560
- /**
561
- * The string model class associating this email template
562
- *
563
- * @return string
564
- */
565
- protected function _emailClass()
566
- {
567
- return 'bronto_common/email_template';
568
- }
569
-
570
- /**
571
- * Is this a queuable message?
572
- *
573
- * @return bool
574
- */
575
- protected function _queuable()
576
- {
577
- return true;
578
- }
579
-
580
- /**
581
- * When should this email be sent out?
582
- *
583
- * @param int $storeId
584
- * @return string
585
- */
586
- protected function _startTime($storeId)
587
- {
588
- return date('c');
589
- }
590
-
591
- /**
592
- * Ability to set additional fields
593
- *
594
- * @param $delivery
595
- * @param $variables
596
- */
597
- protected function _additionalFields($delivery, $variables)
598
- {
599
- }
600
-
601
- /**
602
- * Ability to add to the serialization data
603
- *
604
- * @return array
605
- */
606
- protected function _additionalData()
607
- {
608
- return array();
609
- }
610
-
611
- /**
612
- * @param Bronto_Api_Model_Contact $contact
613
- * @param Bronto_Api_Model_Message $message
614
- */
615
- protected function _beforeSend(Bronto_Api_Model_Contact $contact, Bronto_Api_Model_Message $message)
616
- {
617
- }
618
-
619
- /**
620
- * @param int $success
621
- * @param string $error
622
- * @param Bronto_Api_Model_Delivery $delivery
623
- */
624
- protected function _afterSend($success, $error = null, Bronto_Api_Model_Delivery $delivery = null)
625
- {
626
- }
627
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Email/Template/Filter.php DELETED
@@ -1,1352 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var string
11
- */
12
- protected $_eventPrefix = 'bronto_common_email_filter';
13
-
14
- /**
15
- * @var Bronto_Api_Delivery_Row
16
- */
17
- protected $_delivery;
18
-
19
- /**
20
- * @var int
21
- */
22
- protected $_storeId;
23
-
24
- /**
25
- * @var Mage_Core_Model_Store
26
- */
27
- protected $_store;
28
-
29
- /**
30
- * @var string
31
- */
32
- protected $_messageId;
33
-
34
- /**
35
- * @var Mage_Core_Helper_Data
36
- */
37
- protected $_currency;
38
-
39
- /**
40
- * @var Mage_Customer_Model_Customer
41
- */
42
- protected $_customer;
43
-
44
- protected $_items = array();
45
-
46
- /**
47
- * Available template variables
48
- *
49
- * @var array
50
- */
51
- protected $_available = array();
52
-
53
- /**
54
- * @var array
55
- */
56
- protected $_processedAvailable = array();
57
-
58
- /**
59
- * @var array
60
- */
61
- protected $_filteredObjects = array();
62
-
63
- /**
64
- * @var array
65
- */
66
- protected $_queryParams = array();
67
-
68
- protected $_baseTemplate;
69
-
70
- /**
71
- * Map of keys that we would rather have a pretty name for.
72
- * Rather than a 25 character truncated value.
73
- *
74
- * @var array
75
- */
76
- protected $_prettyMap = array(
77
- 'subscriberConfirmationLink' => 'subConfirmationLink'
78
- );
79
-
80
- /**
81
- * @return Mage_Customer_Model_Customer
82
- */
83
- public function getCustomerId()
84
- {
85
- if ($this->_customer) {
86
- return $this->_customer->getId();
87
- }
88
- return null;
89
- }
90
-
91
- /**
92
- * Returns the item context
93
- *
94
- * @return mixed
95
- */
96
- public function getProductContext()
97
- {
98
- return $this->_items;
99
- }
100
-
101
- /**
102
- * Adds an item to the item context
103
- *
104
- * @return mixed
105
- */
106
- public function addItemToContext($item)
107
- {
108
- $this->_items[] = $item;
109
- return $this;
110
- }
111
-
112
- /**
113
- * Sets the base template model for the processor
114
- *
115
- * @param Mage_Core_Model_Email_Template $_baseTemplate
116
- * @return Bronto_Common_Model_Email_Template_Filter
117
- */
118
- public function setBaseTemplate($_baseTemplate)
119
- {
120
- $this->_baseTemplate = $_baseTemplate;
121
- return $this;
122
- }
123
-
124
- /**
125
- * Sets the inline CSS for this processor
126
- *
127
- * @param string $text
128
- * @return string
129
- */
130
- protected function _applyInlineCssStyles($text)
131
- {
132
- if (method_exists($this, 'getInlineCssFile')) {
133
- $stripDocType = preg_replace('/^<!DOCTYPE.+?>/', '', $this->_baseTemplate->getPreparedTemplateText($text));
134
- $stripHtmlBody = preg_replace('/<html(?:[^>]+)>|<body(?:[^>]+)>/', '', $stripDocType);
135
- return str_replace(array('</html>', '</body>'), array('', ''), $stripHtmlBody);
136
- }
137
- return $text;
138
- }
139
-
140
- /**
141
- * Filter using this recommendation
142
- *
143
- * @param Bronto_Product_Model_Recommendation $rec
144
- * @return Bronto_Common_Model_Email_Template_Filter
145
- */
146
- public function setRecommendation(Bronto_Product_Model_Recommendation $rec)
147
- {
148
- $this->_recommendation = $rec;
149
- return $this;
150
- }
151
-
152
- /**
153
- * Respect the design package and theme
154
- */
155
- protected function _respectDesignTheme()
156
- {
157
- // When emailing from the admin, we need to ensure that we're using templates from the frontend
158
- Mage::getDesign()
159
- ->setPackageName($this->getStore()->getConfig('design/package/name'))
160
- ->setTheme($this->getStore()->getConfig('design/theme/template'))
161
- ->setArea('frontend');
162
- }
163
-
164
- /**
165
- * @return array
166
- */
167
- protected function _processAvailable()
168
- {
169
- $this->_processedAvailable = array();
170
-
171
- foreach ($this->_available as $available) {
172
- $variable = isset($available['value']) ? $available['value'] : null;
173
- if (preg_match('/^{{layout handle="[a-zA-Z_]*_order_items"/', $variable)) {
174
- continue;
175
- }
176
- if (preg_match('/^{{skin|store|layout|block/', $variable)) {
177
- continue;
178
- }
179
-
180
- $variable = str_replace('{{var ', '', $variable);
181
- $variable = str_replace('{{htmlescape var=$', '', $variable);
182
- $variable = str_replace('}}', '', $variable);
183
-
184
- $parts = explode('.', $variable);
185
- foreach ($parts as $i => $part) {
186
- if (stripos($part, 'get') === 0) {
187
- $parts[$i] = str_replace('get', '', $parts[$i]);
188
- $parts[$i] = str_replace('()', '', $parts[$i]);
189
- }
190
- if (stripos($part, 'format') === 0) {
191
- unset($parts[$i]);
192
- }
193
- }
194
-
195
- $variable = $this->_camelize(implode('_', $parts));
196
- if (strlen($variable) > 25) {
197
- $variable = substr($variable, 0, 25);
198
- }
199
- $this->_processedAvailable[] = $variable;
200
-
201
- }
202
-
203
- return $this->_processedAvailable;
204
- }
205
-
206
- /**
207
- * @return Bronto_Common_Model_Email_Template_Filter
208
- */
209
- protected function _processQueryParams()
210
- {
211
- $this->_queryParams = array();
212
-
213
- // Add rule_id (if available)
214
- if (isset($this->_templateVars['rule'])) {
215
- if (class_exists('Bronto_Reminder_Model_Rule', false) && $this->_templateVars['rule'] instanceOf Bronto_Reminder_Model_Rule) {
216
- $this->_queryParams['rule_id'] = $this->_templateVars['rule']->getId();
217
- }
218
- }
219
-
220
- // Add message_id (if available)
221
- if ($this->getMessageId()) {
222
- $this->_queryParams['message_id'] = $this->getMessageId();
223
- }
224
-
225
- return $this;
226
- }
227
-
228
- /**
229
- * @param Bronto_Api_Delivery_Row $delivery
230
- *
231
- * @return Bronto_Api_Delivery_Row
232
- */
233
- public function filter($delivery)
234
- {
235
- if (!$delivery instanceof Bronto_Api_Model_Delivery) {
236
- return parent::filter($delivery);
237
- }
238
-
239
- $this->_filteredObjects = array();
240
- $this->_delivery = $delivery;
241
-
242
- $this->_processAvailable();
243
- $this->_processQueryParams();
244
-
245
- foreach ($this->_templateVars as $var => $value) {
246
-
247
- //
248
- // Handle strings
249
- if (is_string($value)) {
250
- $key = $this->_camelize($var);
251
- if (in_array($key, $this->_processedAvailable)) {
252
- $this->setField($key, $value);
253
- } else {
254
- // Sanitize the best we can...
255
- $key = preg_replace('/[^\w_]$/', '', $key);
256
- $key = $this->_camelize($key);
257
- $this->setField($key, $value);
258
- }
259
- }
260
-
261
- if (is_object($value)) {
262
- $eventSuffix = 'unknown';
263
-
264
- // Handle properties that can be get()'ed
265
- foreach ($this->_processedAvailable as $keyValue) {
266
- $method = str_replace($var, '', $keyValue);
267
- $object = str_replace($method, '', $keyValue);
268
- if ($object == $var) {
269
- try {
270
- $method = "get{$method}";
271
- $this->setField($keyValue, $value->{$method}());
272
- } catch (Exception $e) {
273
- // Ignore
274
- }
275
- }
276
- }
277
-
278
- // Coupon
279
- if ($value instanceof Mage_SalesRule_Model_Coupon) {
280
- $this->_filterCoupon($value);
281
- $eventSuffix = 'coupon';
282
- }
283
-
284
- // Store
285
- if ($value instanceOf Mage_Core_Model_Store) {
286
- $this->_filterStore($value);
287
- $eventSuffix = 'store';
288
- }
289
-
290
- // Admin User
291
- if ($value instanceOf Mage_Admin_Model_User) {
292
- $this->_filterAdmin($value);
293
- $eventSuffix = 'admin';
294
- }
295
-
296
- // Subscriber
297
- if ($value instanceOf Mage_Newsletter_Model_Subscriber) {
298
- if (!$this->_customer) {
299
- /** @var Mage_Customer_Model_Customer _customer */
300
- $this->_customer = Mage::getModel('customer/customer')->load($value->getCustomerId());
301
- }
302
-
303
- $this->_filterSubscriber($value);
304
- $eventSuffix = 'subscriber';
305
- }
306
-
307
- // Customer
308
- if ($value instanceOf Mage_Customer_Model_Customer) {
309
- /** @var Mage_Customer_Model_Customer _customer */
310
- $this->_customer = $value;
311
- $this->_filterCustomer($value);
312
- $eventSuffix = 'customer';
313
- }
314
-
315
- // Shipment
316
- if ($value instanceOf Mage_Sales_Model_Order_Shipment) {
317
- if (!$this->_customer) {
318
- /** @var Mage_Customer_Model_Customer _customer */
319
- $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
320
- }
321
- $this->_filterShipment($value);
322
- $eventSuffix = 'shipment';
323
- }
324
-
325
- // Invoice
326
- if ($value instanceOf Mage_Sales_Model_Order_Invoice) {
327
- if (!$this->_customer) {
328
- /** @var Mage_Customer_Model_Customer _customer */
329
- $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
330
- }
331
- $this->_filterInvoice($value);
332
- $eventSuffix = 'invoice';
333
- }
334
-
335
- // Order
336
- if ($value instanceOf Mage_Sales_Model_Order) {
337
- if (!$this->_customer) {
338
- /** @var Mage_Customer_Model_Customer _customer */
339
- $this->_customer = Mage::getModel('customer/customer')->load($value->getCustomerId());
340
- }
341
- $this->_filterOrder($value);
342
- $eventSuffix = 'order';
343
- }
344
-
345
- // Credit memo
346
- if ($value instanceOf Mage_Sales_Model_Order_Creditmemo) {
347
- if (!$this->_customer) {
348
- /** @var Mage_Customer_Model_Customer _customer */
349
- $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
350
- }
351
- $this->_filterCreditmemo($value);
352
- $eventSuffix = 'creditmemo';
353
- }
354
-
355
- // Quote
356
- if ($value instanceOf Mage_Sales_Model_Quote) {
357
- if (!$this->_customer) {
358
- /** @var Mage_Customer_Model_Customer _customer */
359
- $this->_customer = $value->getCustomer();
360
- }
361
- $this->_filterQuote($value);
362
- $eventSuffix = 'quote';
363
- }
364
-
365
- // Wishlist
366
- if ($value instanceOf Mage_Wishlist_Model_Wishlist) {
367
- if (!$this->_customer) {
368
- /** @var Mage_Customer_Model_Customer _customer */
369
- $this->_customer = Mage::getModel('customer/customer')->load($value->getCustomerId());
370
- }
371
- $this->_filterWishlist($value);
372
- $eventSuffix = 'wishlist';
373
- }
374
-
375
- // Product
376
- if ($value instanceOf Mage_Catalog_Model_Product) {
377
- $this->_filterProduct($value);
378
- $eventSuffix = 'product';
379
- }
380
-
381
- if ($value instanceof Mage_Sales_Model_Order_Address) {
382
- if (!$this->_customer) {
383
- /** @var Mage_Customer_Model_Customer _customer */
384
- $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
385
- }
386
- $this->_filterAddress($value);
387
- $eventSuffix = 'address';
388
- }
389
-
390
- $this->_firePostFilterEvent($value, $eventSuffix);
391
-
392
- }
393
- }
394
-
395
- return $this->_delivery;
396
- }
397
-
398
- /**
399
- * Fires an event after filtering a value
400
- *
401
- * @param mixed $value
402
- * @param string $eventSuffix (Optional)
403
- */
404
- protected function _firePostFilterEvent($value, $eventSuffix = null)
405
- {
406
- if ($eventSuffix) {
407
- Mage::dispatchEvent("{$this->_eventPrefix}_{$eventSuffix}", array(
408
- 'filter' => $this,
409
- $eventSuffix => $value
410
- ));
411
- }
412
- }
413
-
414
- /**
415
- * Add Coupon Code to Email
416
- *
417
- * @param Mage_SalesRule_Model_Coupon $coupon
418
- *
419
- * @return $this
420
- */
421
- protected function _filterCoupon(Mage_SalesRule_Model_Coupon $coupon)
422
- {
423
- if (!in_array('coupon', $this->_filteredObjects)) {
424
- $this->setField('couponCode', $coupon->getCode());
425
- $this->_filteredObjects[] = 'coupon';
426
- }
427
-
428
- return $this;
429
- }
430
-
431
- /**
432
- * @param Mage_Core_Model_Store $store
433
- *
434
- * @return Bronto_Common_Model_Email_Template_Filter
435
- */
436
- protected function _filterStore(Mage_Core_Model_Store $store)
437
- {
438
- if (!in_array('store', $this->_filteredObjects)) {
439
- $this->setStore($store);
440
- $this->setField('storeName', $store->getName());
441
- $this->setField('storeFrontendName', $store->getFrontendName());
442
- $this->setField('storeURL', $store->getUrl('cms', $this->getQueryParams()));
443
- $this->setField('cartURL', $store->getUrl('checkout/cart', $this->getQueryParams()));
444
- $this->setField('customerURL', $store->getUrl('customer/account', $this->getQueryParams()));
445
- $this->setField('supportEmail', $store->getConfig('trans_email/ident_support/email'));
446
- $this->setField('supportPhone', $store->getConfig('general/store_information/phone'));
447
- $this->setField('salesEmail', $store->getConfig('trans_email/ident_sales/email'));
448
-
449
- // if the theme is not set at all (not a likely occurrence in a real site)
450
- // then it returns the theme for the Find (RSS feed).
451
- $theme = Mage::getSingleton('core/design_package')->getTheme('skin');
452
- if ($theme == 'find') {
453
- $theme = 'default';
454
- }
455
- $package = Mage::getSingleton('core/design_package')->getPackageName();
456
- $this->setField('emailLogo', Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend' . DS . $package . DS . $theme . DS . 'images/logo_email.gif');
457
-
458
- $this->_filteredObjects[] = 'store';
459
- }
460
-
461
- return $this;
462
- }
463
-
464
- /**
465
- * @param Mage_Admin_Model_User $user
466
- *
467
- * @return Bronto_Common_Model_Email_Template_Filter
468
- */
469
- protected function _filterAdmin(Mage_Admin_Model_User $user)
470
- {
471
- if (!in_array('admin', $this->_filteredObjects)) {
472
- $this->setField('adminName', $user->getUsername());
473
- $this->setField('adminPassword', $user->getPlainPassword());
474
- $this->setField('adminLoginURL', Mage::helper('adminhtml')->getUrl('adminhtml/system_account/'));
475
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
476
- $this->setField('adminPasswordResetLink', Mage::helper('adminhtml')->getUrl('adminhtml/index/resetpassword', array('_query' => array('id' => $user->getId(), 'token' => $user->getRpToken()))));
477
- }
478
-
479
- $this->_filteredObjects[] = 'admin';
480
- }
481
-
482
- return $this;
483
- }
484
-
485
- /**
486
- * @param Mage_Newsletter_Model_Subscriber $subscriber
487
- *
488
- * @return Bronto_Common_Model_Email_Template_Filter
489
- */
490
- protected function _filterSubscriber(Mage_Newsletter_Model_Subscriber $subscriber)
491
- {
492
- if (!in_array('subscriber', $this->_filteredObjects)) {
493
- $this->_filterCustomer($this->_customer);
494
- $this->_filteredObjects[] = 'subscriber';
495
- }
496
-
497
- return $this;
498
- }
499
-
500
- /**
501
- * @param Mage_Customer_Model_Customer $customer
502
- *
503
- * @return Bronto_Common_Model_Email_Template_Filter
504
- */
505
- protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
506
- {
507
- if (!in_array('customer', $this->_filteredObjects)) {
508
- // Handle Defaults from settings
509
- $customerName = (trim($customer->getName()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('full', 'store', $this->getStoreId()) : $customer->getName();
510
- $customerPrefix = (trim($customer->getPrefix()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('prefix', 'store', $this->getStoreId()) : $customer->getPrefix();
511
- $customerFirstName = (trim($customer->getFirstname()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('firstname', 'store', $this->getStoreId()) : $customer->getFirstname();
512
- $customerLastName = (trim($customer->getLastname()) == '') ? Mage::helper('bronto_common')->getDefaultGreeting('lastname', 'store', $this->getStoreId()) : $customer->getLastname();
513
-
514
- $this->setField('customerName', $customerName);
515
- $this->setField('firstName', $customerFirstName);
516
- $this->setField('prefix', $customerPrefix);
517
- $this->setField('lastName', $customerLastName);
518
- $this->setField('customerEmail', $customer->getEmail());
519
- $this->setField('customerPassword', $customer->getPassword());
520
- if ($store = $customer->getStore()) {
521
- $this->setField('confirmationLink', $store->getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
522
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
523
- $this->setField('passwordResetLink', $store->getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
524
- }
525
- } else {
526
- $this->setField('confirmationLink', Mage::getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
527
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
528
- $this->setField('passwordResetLink', Mage::getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
529
- }
530
- }
531
-
532
- $this->_filteredObjects[] = 'customer';
533
- }
534
-
535
- return $this;
536
- }
537
-
538
- /**
539
- * @param Mage_Sales_Model_Order $order
540
- * @param string $type
541
- *
542
- * @return Bronto_Common_Model_Email_Template_Filter
543
- */
544
- protected function _filterOrder(Mage_Sales_Model_Order $order, $type = 'order')
545
- {
546
- if (!in_array('order', $this->_filteredObjects)) {
547
- $this->setStoreId($order->getStoreId());
548
-
549
- $index = 1;
550
- $lineItems = Mage::helper('bronto_common/item')->getFlatItems($order);
551
- foreach ($lineItems as $item /* @var $item Mage_Sales_Model_Order_Item */) {
552
- $this->_filterOrderItem($item, $index);
553
- $index++;
554
- }
555
-
556
- // Add Related Content
557
- $this->_items = $order->getAllItems();
558
-
559
- // Order may not be a shippable order
560
- $shipAddress = 'N/A';
561
- $shipDescription = 'N/A';
562
- if ($order->getIsNotVirtual()) {
563
- $shipAddress = $order->getShippingAddress()->format('html');
564
- $shipDescription = $order->getShippingDescription();
565
- }
566
-
567
- // Check for guest orders
568
- $customerName = $order->getCustomerIsGuest() ? $order->getBillingAddress()->getName() : $order->getCustomerName();
569
-
570
- $this->setField('orderIncrementId', $order->getIncrementId());
571
- $this->setField('orderCreatedAt', $order->getCreatedAtFormated('long'));
572
- $this->setField('orderBillingAddress', $order->getBillingAddress()->format('html'));
573
- $this->setField('orderShippingAddress', $shipAddress);
574
- $this->setField('orderShippingDescription', $shipDescription);
575
- $this->setField('orderCustomerName', $customerName);
576
- $this->setField('orderStatusLabel', $order->getStatusLabel());
577
- $this->setField('orderItems', $this->_filterOrderItems($order));
578
-
579
- $this->_respectDesignTheme();
580
- $totals = $this->_getTotalsBlock(Mage::getSingleton('core/layout'), $order, 'sales/order_totals', 'order_totals');
581
- $this->setField('orderTotals', $this->_applyInlineCssStyles($totals->toHtml()));
582
-
583
- $this->_filteredObjects[] = 'order';
584
- }
585
-
586
- return $this;
587
- }
588
-
589
- protected function _filterAddress(Mage_Sales_Model_Order_Address $address)
590
- {
591
- if (!in_array('address', $this->_filteredObjects)) {
592
-
593
- $this->setField('billingName', $address->getName());
594
- $this->_filteredObjects[] = 'address';
595
- }
596
-
597
- return $this;
598
- }
599
-
600
- /**
601
- * @param Mage_Sales_Model_Order_Invoice $invoice
602
- *
603
- * @return Bronto_Common_Model_Email_Template_Filter
604
- */
605
- protected function _filterInvoice(Mage_Sales_Model_Order_Invoice $invoice)
606
- {
607
- if (!in_array('invoice', $this->_filteredObjects)) {
608
- $index = 1;
609
- $lineItems = Mage::helper('bronto_common/item')->getFlatItems($invoice);
610
- foreach ($lineItems as $item/* @var $item Mage_Sales_Model_Order_Invoice_Item */) {
611
- $this->_filterOrderItem($item, $index);
612
- $index++;
613
- }
614
-
615
- // Add Related Content
616
- $this->_items = $invoice->getAllItems();
617
-
618
- $this->setField('invoiceIncrementId', $invoice->getIncrementId());
619
- $this->setField('invoiceItems', $this->_filterInvoiceItems($invoice));
620
-
621
- $this->_filteredObjects[] = 'invoice';
622
- }
623
-
624
- return $this;
625
- }
626
-
627
- /**
628
- * @param Mage_Sales_Model_Order_Shipment $shipment
629
- *
630
- * @return Bronto_Common_Model_Email_Template_Filter
631
- */
632
- protected function _filterShipment(Mage_Sales_Model_Order_Shipment $shipment)
633
- {
634
- $this->setStoreId($shipment->getOrder()->getStoreId());
635
- if (!in_array('shipment', $this->_filteredObjects)) {
636
- $index = 1;
637
- $lineItems = Mage::helper('bronto_common/item')->getFlatItems($shipment);
638
- foreach ($lineItems as $item/* @var $item Mage_Sales_Model_Order_Shipment_Item */) {
639
- $this->_filterOrderItem($item, $index);
640
- $index++;
641
- }
642
-
643
- $createdAt = $shipment->getCreatedAtStoreDate();
644
- if (empty($createdAt)) {
645
- // unset the blank string to force current timestamp
646
- $createdAt = null;
647
- }
648
-
649
- // Add Related Content
650
- $this->_items = $shipment->getAllItems();
651
-
652
- $this->setField('shipmentIncrementId', $shipment->getIncrementId());
653
- $this->setField('shipmentCreatedAt', Mage::helper('core')->formatDate($createdAt, 'long', true)); // TODO: needed?
654
- $this->setField('shipmentItems', $this->_filterShipmentItems($shipment));
655
- $this->setField('shipmentTracking', $this->_getShipmentTrackingNumber($shipment, $shipment->getOrder()));
656
-
657
- $this->_filteredObjects[] = 'shipment';
658
- }
659
-
660
- return $this;
661
- }
662
-
663
- /**
664
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
665
- *
666
- * @return Bronto_Common_Model_Email_Template_Filter
667
- */
668
- protected function _filterCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
669
- {
670
- if (!in_array('creditmemo', $this->_filteredObjects)) {
671
- $index = 1;
672
- $lineItems = Mage::helper('bronto_common/item')->getFlatItems($creditmemo);
673
- foreach ($lineItems as $item/* @var $item Mage_Sales_Model_Order_Creditmemo_Item */) {
674
- $this->_filterOrderItem($item, $index);
675
- $index++;
676
- }
677
-
678
- $createdAt = $creditmemo->getCreatedAtStoreDate();
679
- if (empty($createdAt)) {
680
- // unset the blank string to force current timestamp
681
- $createdAt = null;
682
- }
683
-
684
- // Add Related Content
685
- $this->_items = $creditmemo->getAllItems();
686
-
687
- $this->setField('creditmemoIncrementId', $creditmemo->getIncrementId());
688
- $this->setField('creditmemoCreatedAt', Mage::helper('core')->formatDate($createdAt, 'long', true)); // TODO: needed?
689
- $this->setField('creditmemoItems', $this->_filterCreditmemoItems($creditmemo));
690
-
691
- $this->_filteredObjects[] = 'creditmemo';
692
- }
693
-
694
- return $this;
695
- }
696
-
697
- /**
698
- * @param Mage_Sales_Model_Quote $quote
699
- *
700
- * @return Bronto_Common_Model_Email_Template_Filter
701
- */
702
- protected function _filterQuote(Mage_Sales_Model_Quote $quote)
703
- {
704
- if (!in_array('quote', $this->_filteredObjects)) {
705
- $this->setStoreId($quote->getStoreId());
706
- $currencyCode = $quote->getQuoteCurrencyCode();
707
-
708
- if (Mage::helper('bronto_common')->displayPriceIncTax($quote->getStoreId())) {
709
- $totals = $quote->getTotals();
710
- $this->setField('subtotal', $this->formatPrice($totals['subtotal']->getValue(), $currencyCode));
711
- $this->setField('grandTotal', $this->formatPrice($totals['grand_total']->getValue(), $currencyCode));
712
- } else {
713
- $this->setField('subtotal', $this->formatPrice($quote->getSubtotal(), $currencyCode));
714
- $this->setField('grandTotal', $this->formatPrice($quote->getGrandTotal(), $currencyCode));
715
- }
716
-
717
- $index = 1;
718
- $lineItems = Mage::helper('bronto_common/item')->getFlatItems($quote);
719
- foreach ($lineItems as $item/* @var $item Mage_Sales_Model_Quote_Item */) {
720
- $this->_filterQuoteItem($item, $index);
721
- $index++;
722
- }
723
-
724
- // Add Related Content
725
- $this->_items = $quote->getAllItems();
726
-
727
- $queryParams = $this->getQueryParams();
728
- $queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
729
- if ($store = $this->getStore()) {
730
- $this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
731
- } else {
732
- $this->setField('quoteURL', Mage::getUrl('reminder/load/index', $queryParams));
733
- }
734
-
735
- // Setup quote items as a template
736
- if (class_exists('Bronto_Reminder_Block_Cart_Items', false)) {
737
- $layout = Mage::getSingleton('core/layout');
738
-
739
- /* @var $items Mage_Sales_Block_Items_Abstract */
740
- $items = $layout->createBlock('bronto/bronto_reminder_cart_items', 'items');
741
- $items->setTemplate('bronto/reminder/items.phtml');
742
- $items->setQuote($item->getQuote());
743
-
744
- $this->_respectDesignTheme();
745
- $this->setField("cartItems", $this->_applyInlineCssStyles($items->toHtml()));
746
- }
747
-
748
- $this->_filteredObjects[] = 'quote';
749
- }
750
-
751
- return $this;
752
- }
753
-
754
- /**
755
- * @param Mage_Sales_Model_Quote_Item $item
756
- * @param int $index
757
- *
758
- * @return Bronto_Common_Model_Email_Template_Filter
759
- */
760
- protected function _filterQuoteItem($item, $index = null)
761
- {
762
- $helper = Mage::helper('bronto_common/item');
763
- $parentItem = $helper->getParentItem($item);
764
- $this->setField("productId_{$index}", $parentItem->getProductId());
765
- $this->setField("productUrl_{$index}", $helper->getProductUrl($item));
766
- $this->setField("productImgUrl_{$index}", $helper->getImage($item));
767
- $this->setField("productDescription_{$index}", $helper->getDescription($item));
768
- if (Mage::helper('bronto_common')->displayPriceIncTax($item->getStore())) {
769
- $checkout = Mage::helper('checkout');
770
- $this->setField("productPrice_{$index}", $this->formatPrice($checkout->getPriceInclTax($parentItem)));
771
- $this->setField("productTotal_{$index}", $this->formatPrice($checkout->getSubtotalInclTax($parentItem)));
772
- } else {
773
- $this->setField("productPrice_{$index}", $this->formatPrice($parentItem->getPrice()));
774
- $this->setField("productTotal_{$index}", $this->formatPrice($parentItem->getRowTotal()));
775
- }
776
-
777
- $this->setField("productName_{$index}", $parentItem->getName());
778
- $this->setField("productSku_{$index}", $item->getSku());
779
- $this->setField("productQty_{$index}", $helper->getQty($item));
780
- $this->setField("productUrl_{$index}", $this->_getQuoteItemUrl($item));
781
-
782
- return $this;
783
- }
784
-
785
- /**
786
- * @param Mage_Wishlist_Model_Wishlist $wishlist
787
- *
788
- * @return Bronto_Common_Model_Email_Template_Filter
789
- */
790
- protected function _filterWishlist(Mage_Wishlist_Model_Wishlist $wishlist)
791
- {
792
- if (!in_array('wishlist', $this->_filteredObjects)) {
793
- $index = 1;
794
- foreach ($wishlist->getItemCollection() as $item/* @var $item Mage_Wishlist_Model_Item */) {
795
- if (!$item->getParentItem()) {
796
- $this->_filterWishlistItem($item, $index);
797
- $index++;
798
- }
799
- }
800
-
801
- // Add Related Content
802
- $this->_items = $wishlist->getItemCollection();
803
-
804
- $queryParams = $this->getQueryParams();
805
- $queryParams['wishlist_id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($wishlist->getId())));
806
- if ($store = $this->getStore()) {
807
- $this->setField('wishlistURL', $store->getUrl('reminder/load/index', $queryParams));
808
- } else {
809
- $this->setField('wishlistURL', Mage::getUrl('reminder/load/index', $queryParams));
810
- }
811
-
812
- // Setup wishlist items as a template
813
- if (class_exists('Bronto_Reminder_Block_Wishlist_Items', false)) {
814
- $layout = Mage::getSingleton('core/layout');
815
-
816
- /* @var $items Mage_Sales_Block_Items_Abstract */
817
- $items = $layout->createBlock('bronto/bronto_reminder_wishlist_items', 'items');
818
- $items->setTemplate('bronto/reminder/items.phtml');
819
- $items->setWishlist($item->getWishlist());
820
-
821
- $this->_respectDesignTheme();
822
- $this->setField("wishlistItems", $this->_applyInlineCssStyles($items->toHtml()));
823
- }
824
-
825
- $this->_filteredObjects[] = 'wishlist';
826
- }
827
-
828
- return $this;
829
- }
830
-
831
- /**
832
- * @param Mage_Wishlist_Model_Item $item
833
- * @param int $index
834
- *
835
- * @return Bronto_Common_Model_Email_Template_Filter
836
- */
837
- protected function _filterWishlistItem(Mage_Wishlist_Model_Item $item, $index = null)
838
- {
839
- if ($item->getParentItem()) {
840
- return $this;
841
- }
842
-
843
- $this->setStoreId($item->getStoreId());
844
- $this->setField("productName_{$index}", $item->getName());
845
- $this->setField("productPrice_{$index}", $this->formatPrice($item->getPrice()));
846
- $this->setField("productQty_{$index}", $item->getQty());
847
- $this->setField("productUrl_{$index}", $this->_getWishlistItemUrl($item));
848
-
849
- /* @var $product Mage_Catalog_Model_Product */
850
- $product = $item->getProduct();
851
- if (!$product) {
852
- $product = Mage::helper('bronto_common/product')
853
- ->getProduct($item->getProductId(), $this->getStoreId() ? $this->getStoreId() : false);
854
- }
855
- $this->setField("productSku_{$index}", $product->getSku());
856
-
857
- $this->_filterProduct($product, $index);
858
-
859
- return $this;
860
- }
861
-
862
- /**
863
- * @param Mage_Sales_Model_Order $order
864
- *
865
- * @return String containing HTML for order items
866
- */
867
- protected function _filterOrderItems(Mage_Sales_Model_Order $order)
868
- {
869
- $html = parent::layoutDirective(array(
870
- 2 => ' handle="sales_email_order_items" order=$order'
871
- ));
872
- return $this->_applyInlineCssStyles($html);
873
- }
874
-
875
- /**
876
- * @param Mage_Sales_Model_Order_Item $item
877
- * @param int $index
878
- *
879
- * @return Bronto_Common_Model_Email_Template_Filter
880
- */
881
- protected function _filterOrderItem($item, $index = null)
882
- {
883
- $helper = Mage::helper('bronto_common/item');
884
- $parentItem = $helper->getParentItem($item);
885
- // Product Price Excluding Tax
886
- if (Mage::helper('tax')->displaySalesPriceExclTax($this->getStore()) || Mage::helper('tax')->displaySalesBothPrices($this->getStore())) {
887
- if (Mage::helper('weee')->typeOfDisplay($parentItem, array(0, 1, 4), 'email', $this->getStore())) {
888
- $this->setField("productPriceExclTax_{$index}", $this->formatPrice($parentItem->getRowTotal() + $parentItem->getWeeeTaxAppliedRowAmount() + $parentItem->getWeeeTaxRowDisposition()));
889
- } else {
890
- $this->setField("productPriceExclTax_{$index}", $this->formatPrice($parentItem->getRowTotal()));
891
- }
892
- }
893
-
894
- // Product Price Including Tax
895
- if (Mage::helper('tax')->displaySalesPriceInclTax($this->getStore()) || Mage::helper('tax')->displaySalesBothPrices($this->getStore())) {
896
- $_incl = Mage::helper('checkout')->getSubtotalInclTax($parentItem);
897
- if (Mage::helper('weee')->typeOfDisplay($parentItem, array(0, 1, 4), 'email', $this->getStore())) {
898
- $this->setField("productPriceInclTax_{$index}", $this->formatPrice($_incl + $parentItem->getWeeeTaxAppliedRowAmount()));
899
- } else {
900
- $this->setField("productPriceInclTax_{$index}", $this->formatPrice($_incl - $parentItem->getWeeeTaxRowDisposition()));
901
- }
902
- }
903
-
904
- // Set Product Detail Fields
905
- $this->setField("productName_{$index}", $parentItem->getName());
906
- $this->setField("productSku_{$index}", $item->getSku());
907
- $this->setField("productPrice_{$index}", $this->formatPrice($parentItem->getPrice()));
908
- $this->setField("productTotal_{$index}", $this->formatPrice($parentItem->getRowTotal()));
909
- $this->setField("productQty_{$index}", $helper->getQty($item));
910
- $this->setField("productUrl_{$index}", $helper->getProductUrl($item));
911
- $this->setField("productImgUrl_{$index}", $helper->getImage($item));
912
- $this->setField("productId_{$index}", $parentItem->getProductId());
913
- $this->setField("productDescription_{$index}", $helper->getDescription($item));
914
-
915
- // Handle Gift Message Details
916
- if ($parentItem->getGiftMessageId() && $_giftMessage = Mage::helper('giftmessage/message')->getGiftMessage($parentItem->getGiftMessageId())) {
917
- $this->setField("giftMessage_{$index}", $_giftMessage->getMessage());
918
- $this->setField("giftMessageFrom_{$index}", $_giftMessage->getSender());
919
- $this->setField("giftMessageTo_{$index}", $_giftMessage->getRecipient());
920
- }
921
-
922
- return $this;
923
- }
924
-
925
- /**
926
- * @param Mage_Sales_Model_Order_Invoice $invoice
927
- *
928
- * @return String containing HTML for invoice items
929
- */
930
- protected function _filterInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
931
- {
932
- $html = parent::layoutDirective(array(
933
- 2 => ' area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order'
934
- ));
935
- return $this->_applyInlineCssStyles($html);
936
- }
937
-
938
- /**
939
- * @param Mage_Sales_Model_Order_Shipment $shipment
940
- *
941
- * @return String containing HTML for shipment items and tracking numbers
942
- */
943
- protected function _filterShipmentItems(Mage_Sales_Model_Order_Shipment $shipment)
944
- {
945
- $html = parent::layoutDirective(array(
946
- 2 => ' handle="sales_email_order_shipment_items" shipment=$shipment order=$order'
947
- ));
948
- return $this->_applyInlineCssStyles($html);
949
- }
950
-
951
- /**
952
- * Get the shipment tracking info.
953
- *
954
- * @param Mage_Sales_Model_Order_Shipment $shipment
955
- * @param Mage_Sales_Model_Order $order
956
- */
957
- protected function _getShipmentTrackingNumber(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order)
958
- {
959
- $layout = Mage::getSingleton('core/layout');
960
- $block = $layout->createBlock('core/template')->setTemplate('email/order/shipment/track.phtml');
961
- $block->setOrder($order);
962
- $block->setShipment($shipment);
963
- $block->setArea('frontend');
964
-
965
- return $this->_applyInlineCssStyles($block->toHtml());
966
- }
967
-
968
- /**
969
- * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
970
- *
971
- * @return String containing HTML for credit memo items
972
- */
973
- protected function _filterCreditmemoItems(Mage_Sales_Model_Order_Creditmemo $creditmemo)
974
- {
975
- $html = parent::layoutDirective(array(
976
- 2 => ' handle="sales_email_order_creditmemo_items" creditmemo=$creditmemo order=$order'
977
- ));
978
- return $this->_applyInlineCssStyles($html);
979
- }
980
-
981
- /**
982
- * Get the totals block for order-style emails.
983
- *
984
- * @param Mage_Core_Model_Layout $layout
985
- * @param Mage_Sales_Model_Order $order
986
- * @param String $totals_block_type
987
- * @param String $totals_block_name
988
- *
989
- * @return Mage_Core_Block_Template
990
- */
991
- protected function _getTotalsBlock($layout, $order, $totals_block_type, $totals_block_name)
992
- {
993
- // Change this path for order totals
994
- $templatePath = 'sales/order/totals.phtml';
995
- /*
996
- switch ($totals_block_name) {
997
- case 'creditmemo_totals':
998
- case 'invoice_totals':
999
- // Be sure to use 'invoice_totals' and 'creditmemo_totals',
1000
- // inplace of 'totals' here
1001
- $templatePath = str_replace('totals', $totals_block_name, $templatePath);
1002
- }
1003
- */
1004
-
1005
- $totals = $layout->createBlock($totals_block_type, $totals_block_name);
1006
- $totals->setOrder($order);
1007
- $totals->setTemplate($templatePath);
1008
- $totals->setLabelProperties('colspan="3" align="right" style="padding:3px 9px"');
1009
- $totals->setValueProperties('align="right" style="padding:3px 9px"');
1010
-
1011
- $tax = $layout->createBlock('tax/sales_order_tax', 'tax');
1012
- $tax->setOrder($order);
1013
- $tax->setTemplate('tax/order/tax.phtml');
1014
- $tax->setIsPlaneMode(1);
1015
- $totals->append($tax, 'tax');
1016
-
1017
- return $totals;
1018
- }
1019
-
1020
- /**
1021
- * @param Mage_Catalog_Model_Product $product
1022
- * @param int $index
1023
- *
1024
- * @return Bronto_Common_Model_Email_Template_Filter
1025
- */
1026
- protected function _filterProduct(Mage_Catalog_Model_Product $product, $index = null)
1027
- {
1028
- // Load full product
1029
- $product = Mage::helper('bronto_common/product')
1030
- ->getProduct($product->getId(), $product->getStoreId());
1031
-
1032
- if ($index !== null) {
1033
- try {
1034
- // Sets original product ID before pulling in parent
1035
- $this->setField("productId_{$index}", $product->getId());
1036
- $product = $this->_getSimpleProduct($product);
1037
- $imageUrl = Mage::helper('bronto_common')->getProductImageUrl($product);
1038
- $this->setField("productImgUrl_{$index}", $imageUrl);
1039
- $this->setField("productDescription_{$index}", $product->getDescription());
1040
- } catch (Exception $e) {
1041
- Mage::log('Error loading image: ' . $e);
1042
- }
1043
- } else {
1044
- $this->setField('productId', $product->getId());
1045
- $this->setField('productUrl', $product->getUrl());
1046
- $this->setField('productName', $product->getName());
1047
- try {
1048
- $product = $this->_getSimpleProduct($product);
1049
- $this->setField('productImgUrl', Mage::helper('bronto_common')->getProductImageUrl($product));
1050
- $this->setField('productDescription', $product->getDescription());
1051
- } catch (Exception $e) {
1052
- Mage::log('Error loading image: ' . $e);
1053
- }
1054
- }
1055
-
1056
- return $this;
1057
- }
1058
-
1059
- /**
1060
- * Gets the visible configurable product for a simple product
1061
- * This is a fix for SCP
1062
- *
1063
- * @param Mage_Catalog_Model_Product $product
1064
- * @return Mage_Catalog_Model_Product
1065
- */
1066
- protected function _getSimpleProduct($product)
1067
- {
1068
- return Mage::helper('bronto_common/product')
1069
- ->getConfigurableProduct($product);
1070
- }
1071
-
1072
- /**
1073
- * Gets the url for a Configurable product for this simple product
1074
- *
1075
- * @param Mage_Catalog_Model_Product $product
1076
- * @return string
1077
- */
1078
- protected function _getProductUrl($product)
1079
- {
1080
- $helper = Mage::helper('bronto_common/product');
1081
- if (!$helper->isVisibleInidividually($product)) {
1082
- $config = $helper->getConfigurableProduct($product);
1083
- if ($config->getId() != $product->getId()) {
1084
- $product = $config;
1085
- } else {
1086
- $product = $helper->getGroupedProduct($product);
1087
- }
1088
- }
1089
- return Mage::helper('catalog/product')->getProductUrl($product);
1090
- }
1091
-
1092
- /**
1093
- * @param Mage_Sales_Model_Quote_Item $item
1094
- *
1095
- * @return string
1096
- */
1097
- protected function _getQuoteItemUrl(Mage_Sales_Model_Quote_Item $item)
1098
- {
1099
- if ($item->getRedirectUrl()) {
1100
- return $item->getRedirectUrl();
1101
- }
1102
- return $this->_getProductUrl($item->getProduct());
1103
- }
1104
-
1105
- /**
1106
- * @param Mage_Wishlist_Model_Item $item
1107
- *
1108
- * @return string
1109
- */
1110
- protected function _getWishlistItemUrl(Mage_Wishlist_Model_Item $item)
1111
- {
1112
- if ($item->getRedirectUrl()) {
1113
- return $item->getRedirectUrl();
1114
- }
1115
- return $this->_getProductUrl($item->getProduct());
1116
- }
1117
-
1118
- /**
1119
- * @param Mage_Sales_Model_Order_Item $item
1120
- *
1121
- * @return string
1122
- */
1123
- protected function _getOrderItemUrl(Mage_Sales_Model_Order_Item $item)
1124
- {
1125
- if ($item->getRedirectUrl()) {
1126
- return $item->getRedirectUrl();
1127
- }
1128
-
1129
- if ($item->getProduct()) {
1130
- return $this->_getProductUrl($item->getProduct());
1131
- }
1132
-
1133
- $product = Mage::helper('bronto_common/product')
1134
- ->getProduct($item->getProductId(), $this->getStoreId());
1135
-
1136
- if ($product->getId()) {
1137
- return $this->_getProductUrl($product);
1138
- }
1139
-
1140
- return '';
1141
- }
1142
-
1143
- /**
1144
- * @param string $key
1145
- * @param string|array $value
1146
- * @param string $type
1147
- *
1148
- * @return Bronto_Common_Model_Email_Template_Filter
1149
- */
1150
- public function setField($key, $value, $type = 'html')
1151
- {
1152
- if (!is_string($key) || empty($key)) {
1153
- return $this;
1154
- }
1155
-
1156
- if (is_array($value)) {
1157
- // Address objects come in as an array on payment failed emails
1158
- $delim = $type == 'html' ? '<br/>' : "\n\r";
1159
- if (isset($value['address_id'])) {
1160
- $new_value = $value['street'] . $delim;
1161
- $new_value .= $value['city'] . $delim;
1162
- $new_value .= $value['region'] . $delim;
1163
- $new_value .= $value['postcode'] . $delim;
1164
- $new_value .= $value['country_id'];
1165
- $this->_delivery->withField($key, $new_value, $type);
1166
- }
1167
- } else {
1168
- if (isset($this->_prettyMap[$key])) {
1169
- // Overwrite $key if we have a mapped overridden value
1170
- $key = $this->_prettyMap[$key];
1171
- }
1172
- $this->_delivery->withField($key, $value, $type);
1173
- }
1174
-
1175
- return $this;
1176
- }
1177
-
1178
- /**
1179
- * @return array
1180
- */
1181
- public function getQueryParams()
1182
- {
1183
- return $this->_queryParams;
1184
- }
1185
-
1186
- /**
1187
- * Setter
1188
- *
1189
- * @param integer $storeId
1190
- *
1191
- * @return Bronto_Common_Model_Email_Template_Filter
1192
- */
1193
- public function setStoreId($storeId)
1194
- {
1195
- $this->_storeId = $storeId;
1196
-
1197
- return $this;
1198
- }
1199
-
1200
- /**
1201
- * Getter
1202
- * if $_storeId is null return Design store id
1203
- *
1204
- * @return integer
1205
- */
1206
- public function getStoreId()
1207
- {
1208
- if (null === $this->_storeId) {
1209
- $this->_storeId = Mage::app()->getStore()->getId();
1210
- }
1211
-
1212
- return $this->_storeId;
1213
- }
1214
-
1215
- /**
1216
- * @param Mage_Core_Model_Store $store
1217
- *
1218
- * @return Bronto_Common_Model_Email_Template_Filter
1219
- */
1220
- public function setStore(Mage_Core_Model_Store $store)
1221
- {
1222
- $this->_store = $store;
1223
- $this->setStoreId($store->getId());
1224
-
1225
- return $this;
1226
- }
1227
-
1228
- /**
1229
- * @return Mage_Core_Model_Store
1230
- */
1231
- public function getStore()
1232
- {
1233
- // Only attempt to load the store if a storeId is present
1234
- if ($this->_storeId) {
1235
- if (is_null($this->_store) || $this->_store->getId() != $this->_storeId) {
1236
- $this->_store = Mage::getModel('core/store')->load($this->_storeId);
1237
- }
1238
- } else if (is_null($this->_store)) {
1239
- $this->_store = Mage::app()->getStore();
1240
- }
1241
-
1242
- return $this->_store;
1243
- }
1244
-
1245
- /**
1246
- * @param string $messageId
1247
- *
1248
- * @return Bronto_Common_Model_Email_Template_Filter
1249
- */
1250
- public function setMessageId($messageId)
1251
- {
1252
- $this->_messageId = $messageId;
1253
-
1254
- return $this;
1255
- }
1256
-
1257
- /**
1258
- * @return string
1259
- */
1260
- public function getMessageId()
1261
- {
1262
- return $this->_messageId;
1263
- }
1264
-
1265
- /**
1266
- * @param array $variables
1267
- *
1268
- * @return Bronto_Common_Model_Email_Template_Filter
1269
- */
1270
- public function setAvailable($variables = array())
1271
- {
1272
- if (!is_array($variables)) {
1273
- $variables = array();
1274
- }
1275
- foreach ($variables as $name => $value) {
1276
- $this->_available[$name] = $value;
1277
- }
1278
-
1279
- return $this;
1280
- }
1281
-
1282
- /**
1283
- * Converts field names for setters and getters
1284
- *
1285
- * @param string $name
1286
- *
1287
- * @return string
1288
- */
1289
- protected function _underscore($name)
1290
- {
1291
- $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
1292
-
1293
- return $result;
1294
- }
1295
-
1296
- /**
1297
- * @param string $name
1298
- *
1299
- * @return string
1300
- */
1301
- protected function _camelize($name)
1302
- {
1303
- return $this->_lcfirst(uc_words($name, ''));
1304
- }
1305
-
1306
- /**
1307
- * For PHP < 5.3
1308
- *
1309
- * @param string $string
1310
- *
1311
- * @return string
1312
- */
1313
- protected function _lcfirst($string)
1314
- {
1315
- if (function_exists('lcfirst') !== false) {
1316
- return lcfirst($string);
1317
- } else {
1318
- if (!empty($string)) {
1319
- $string{0} = strtolower($string{0});
1320
- }
1321
- }
1322
-
1323
- return $string;
1324
- }
1325
-
1326
- /**
1327
- * Convenience method for formatting currency values
1328
- *
1329
- * @param float $price
1330
- * @param string $currencyCode (Optional)
1331
- *
1332
- * @return string
1333
- */
1334
- public function formatPrice($price, $currencyCode = null)
1335
- {
1336
- $options = array(
1337
- 'precision' => 2,
1338
- 'display' => Zend_Currency::NO_SYMBOL,
1339
- );
1340
-
1341
- if (Mage::helper('bronto_common')->useCurrencySymbol($this->getStore()->getId())) {
1342
- unset($options['display']);
1343
- }
1344
-
1345
- $currencyCode = $currencyCode ? $currencyCode : $this->getStore()->getDefaultCurrencyCode();
1346
- if (is_null($this->_currency) || $this->_currency->getCode() != $currencyCode) {
1347
- $this->_currency = Mage::getModel('directory/currency')->load($currencyCode);
1348
- }
1349
-
1350
- return $this->_currency->formatTxt($price, $options);
1351
- }
1352
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Email/Template/Templatefilter.php DELETED
@@ -1,276 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Email_Template_Templatefilter extends Mage_Core_Model_Email_Template_Filter
4
- {
5
-
6
-
7
- public function blockDirective($construction)
8
- {
9
- $params = $this->_getIncludeParameters($construction[2]);
10
- switch ($params['template']) {
11
- case 'email/order/shipment/track.phtml':
12
- return $this->_addBrontoStyle('shipmentTracking');
13
- default:
14
- return '';
15
- }
16
-
17
- }
18
-
19
- /**
20
- *
21
- * @param array $construction
22
- *
23
- * @return string
24
- */
25
- public function layoutDirective($construction)
26
- {
27
- $params = $this->_getIncludeParameters($construction[2]);
28
- switch ($params['handle']) {
29
- case 'sales_email_order_shipment_items':
30
- $return = 'shipmentItems';
31
- break;
32
- case 'sales_email_order_items':
33
- $return = 'orderItems';
34
- break;
35
- case 'sales_email_order_creditmemo_items':
36
- $return = 'creditmemoItems';
37
- break;
38
- case 'sales_email_order_invoice_items':
39
- $return = 'invoiceItems';
40
- break;
41
- default:
42
- return '';
43
- break;
44
- }
45
-
46
- return $this->_addBrontoStyle($return);
47
- }
48
-
49
- /**
50
- * Retrieve block parameters
51
- *
52
- * @param mixed $value
53
- *
54
- * @return array
55
- */
56
- protected function _getBlockParameters($value)
57
- {
58
- $tokenizer = new Varien_Filter_Template_Tokenizer_Parameter();
59
- $tokenizer->setString($value);
60
-
61
- return $tokenizer->tokenize();
62
- }
63
-
64
- /**
65
- * Retrieve store URL directive
66
- * Support url and direct_url properties
67
- *
68
- * @param array $construction
69
- *
70
- * @return string
71
- */
72
- public function storeDirective($construction)
73
- {
74
- $params = $this->_getIncludeParameters($construction[2]);
75
-
76
- if (isset($params['direct_url'])) {
77
- return $this->_addBrontoStyle('storeurl_' . str_replace('/', '_', $params['direct_url']));
78
- } elseif (isset($params['url'])) {
79
- switch (trim($params['url'], '/')) {
80
- case 'checkout/cart':
81
- return $this->_addBrontoStyle('cartURL');
82
- case 'wishlist/wishlist':
83
- case 'wishlist/index':
84
- case 'wishlist/index/index':
85
- case 'wishlist':
86
- return $this->_addBrontoStyle('wishlistURL');
87
- case 'customer/account':
88
- return $this->_addBrontoStyle('customerURL');
89
- case 'adminhtml/index/resetpassword':
90
- return $this->_addBrontoStyle('adminPasswordResetLink');
91
- case 'customer/account/resetpassword':
92
- return $this->_addBrontoStyle('passwordResetLink');
93
- case 'customer/account/confirm':
94
- return $this->_addBrontoStyle('confirmationLink');
95
- case '':
96
- return $this->_addBrontoStyle('storeURL');
97
- default:
98
- return $this->_addBrontoStyle('storeurl_' . str_replace('/', '_', $params['url']));
99
- }
100
- } else {
101
- return $this->_addBrontoStyle('storeURL');
102
- }
103
- }
104
-
105
- /**
106
- * Directive for converting special characters to HTML entities
107
- * Supported options:
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
-
124
- /**
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
-
138
- protected function processVariable($variable)
139
- {
140
-
141
- switch (trim($variable)) {
142
- case "order.getCreatedAtFormated('long')":
143
- return 'orderCreatedAt';
144
- case "rma.getCreatedAtFormated('long')":
145
- return 'rmaCreatedAt';
146
- case "logo_url":
147
- return 'emailLogo';
148
- case "user.name":
149
- return 'adminName';
150
- case "subscriber.getConfirmationLink()":
151
- return 'subConfirmationLink';
152
- }
153
- $parts = explode('|', $variable, 2);
154
- if (2 === count($parts)) {
155
- list($returnVariable, $modifiersString) = $parts;
156
- } else {
157
- $returnVariable = $variable;
158
- }
159
- $parts = explode('.', $returnVariable);
160
- foreach ($parts as $i => $part) {
161
- if (stripos($part, 'get') === 0) {
162
- $parts[$i] = str_replace('get', '', $parts[$i]);
163
- $parts[$i] = str_replace('()', '', $parts[$i]);
164
- }
165
- if (stripos($part, 'format') === 0) {
166
- unset($parts[$i]);
167
- }
168
- }
169
-
170
- return implode('_', $parts);
171
- }
172
-
173
- /**
174
- * HTTP Protocol directive
175
- *
176
- * Using:
177
- * {{protocol}} - current protocol http or https
178
- * {{protocol url="www.domain.com/"}} domain URL with current protocol
179
- * {{protocol http="http://url" https="https://url"}
180
- * also allow additional parameter "store"
181
- *
182
- * @param array $construction
183
- *
184
- * @return string
185
- */
186
- public function protocolDirective($construction)
187
- {
188
- return '';
189
- }
190
-
191
- /**
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']) {
203
- case 'trans_email/ident_support/email':
204
- $returnValue = 'supportEmail';
205
- break;
206
- case 'general/store_information/phone':
207
- $returnValue = 'supportPhone';
208
- break;
209
- case 'trans_email/ident_sales/email':
210
- $returnValue = 'salesEmail';
211
- break;
212
- default:
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)
229
- {
230
- try {
231
- $value = parent::filter($value);
232
- } catch (Exception $e) {
233
- $value = '';
234
- Mage::logException($e);
235
- }
236
-
237
- return $value;
238
- }
239
-
240
- public function dependDirective($construction)
241
- {
242
- return $this->filter($construction[2]);
243
- }
244
-
245
- public function ifDirective($construction)
246
- {
247
- return '';
248
- }
249
-
250
- protected function _camelize($name)
251
- {
252
- return $this->_lcfirst(uc_words($name, ''));
253
- }
254
-
255
- protected function _lcfirst($string)
256
- {
257
- if (function_exists('lcfirst') !== false) {
258
- return lcfirst($string);
259
- } else {
260
- if (!empty($string)) {
261
- $string{0} = strtolower($string{0});
262
- }
263
- }
264
-
265
- return $string;
266
- }
267
-
268
- protected function _addBrontoStyle($string)
269
- {
270
- $variable = $this->_camelize($string);
271
- if (strlen($variable) > 25) {
272
- $variable = substr($variable, 0, 25);
273
- }
274
- return '%%#' . $variable . '%%';
275
- }
276
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Error.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Error extends Mage_Core_Model_Abstract implements Bronto_Api_Retryer
4
- {
5
- protected $_api;
6
-
7
- /**
8
- * @see parent
9
- */
10
- protected function _construct()
11
- {
12
- parent::_construct();
13
- $this->_init('bronto_common/error');
14
- }
15
-
16
- /**
17
- * @see parent
18
- *
19
- * @param Bronto_Object $object
20
- * @param string $apiToken
21
- * @param int $attempts
22
- * @return int|false
23
- */
24
- public function store(Bronto_Object $object, $apiToken, $attempts = 0)
25
- {
26
- // Only deliveries are retried
27
- if ($object->getTransferType() == 'Delivery') {
28
- if ($this->hasId() && empty($attempts)) {
29
- $this->unsId();
30
- }
31
- try {
32
- $this
33
- ->setObject(serialize($object->withToken($apiToken)))
34
- ->setAttempts($attempts)
35
- ->setLastAttempt(Mage::getSingleton('core/date')->gmtDate())
36
- ->save();
37
- Mage::helper('bronto_common')->writeDebug('Storing failed delivery.');
38
- return $this->getId();
39
- } catch (Exception $e) {
40
- Mage::helper('bronto_common')->writeError('Failed to store delivery: ' . $e->getMessage());
41
- return false;
42
- }
43
- }
44
- }
45
-
46
- /**
47
- * @see parent
48
- *
49
- * @param int $identifier
50
- * @return bool
51
- */
52
- public function attempt($identifier)
53
- {
54
- $request = unserialize($this->getObject());
55
- $api = new Bronto_Api($request->getToken());
56
-
57
- try {
58
- $this->delete();
59
- $deliveryOps = $api->transferDelivery();
60
- foreach ($deliveryOps->createWritePager($request) as $result) {
61
- $delivery = $result->getOriginal();
62
- $item = $result->getItem();
63
- if ($item->getIsError()) {
64
- Mage::throwException("Failed to send failed delivery {$item->getErrorString()}");
65
- }
66
- if ($delivery->hasEmailClass()) {
67
- $delivery->withId($item->getId());
68
- $email = Mage::getModel($delivery->getEmailClass());
69
- $email->triggerBeforeAfterSend($deliveryOps, $delivery);
70
- }
71
- }
72
- } catch (Exception $e) {
73
- $this->store($delivery, $request->getToken(), $this->getAttempts() + 1);
74
- return false;
75
- }
76
-
77
- return true;
78
- }
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Flusher.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Flusher implements Bronto_Api_Write_Flusher
4
- {
5
- private $_result;
6
- private $_helper;
7
-
8
- public function __construct()
9
- {
10
- $this->_result = new Bronto_Object(array(
11
- 'success' => 0,
12
- 'error' => 0,
13
- 'total' => 0
14
- ));
15
- }
16
-
17
- /**
18
- * @see parent
19
- */
20
- public function onFlush($iterator)
21
- {
22
- $now = Mage::getSingleton('core/date')->gmtDate();
23
- try {
24
- foreach ($iterator as $result) {
25
- $queueRow = $this->_queueEntry($result->getOriginal()->getQueueRow());
26
- $item = $result->getItem();
27
- if ($item->getIsError()) {
28
- $queueRow
29
- ->setBrontoImported(null)
30
- ->setBrontoSuppressed("{$item->getErrorCode()}: {$item->getErrorString()}");
31
- $this->_result->incrementError();
32
- } else {
33
- $queueRow
34
- ->setBrontoImported($now)
35
- ->setBrontoSuppressed(null);
36
- $this->_result->incrementSuccess();
37
- }
38
- $queueRow->save();
39
- $this->_result->incrementTotal();
40
- }
41
- $this->_flushLogs($iterator->getOperation()->getApi());
42
- } catch (InvalidArgumentException $iae) {
43
- Mage::helper($this->_helper)->writeDebug("Client error: {$iae->getMessage()}");
44
- } catch (Exception $e) {
45
- $request = $iterator->getRequest();
46
- $requestData = $request->getData();
47
- $objects = $requestData[$request->getKey()];
48
- switch ($e->getCode()) {
49
- case 107:
50
- foreach ($objects as $object) {
51
- if (is_array($object) && !($object instanceof Bronto_Object)) {
52
- $object = new Bronto_Object($object);
53
- }
54
- $queueRow = $this->_queueEntry($object->getQueueRow());
55
- try {
56
- $iterator->getOperation()->getApi()->execute(new Bronto_Object(array(
57
- 'method' => $request->getMethod(),
58
- 'data' => array($request->getKey() => array($object->toArray())),
59
- 'hasUpdates' => true
60
- )));
61
- $queueRow
62
- ->setBrontoImported($now)
63
- ->setBrontoSuppressed(null);
64
- $this->_result->incrementSuccess();
65
- } catch (Exception $e) {
66
- $queueRow
67
- ->setBrontoImported(null)
68
- ->setBrontoSuppressed("Failed to process contact.");
69
- $this->_result->incrementError();
70
- }
71
- $queueRow->save();
72
- $this->_result->incrementTotal();
73
- $this->_flushLogs($iterator->getOperation()->getApi());
74
- }
75
- break;
76
- default:
77
- if ($e->getCode() > 200) {
78
- foreach ($objects as $object) {
79
- if (is_array($object) && !($object instanceof Bronto_Object)) {
80
- $object = new Bronto_Object($object);
81
- }
82
- $this->_queueEntry($object->getQueueRow())
83
- ->setBrontoImported(null)
84
- ->setBrontoSuppressed($e->getMessage())
85
- ->save();
86
- $this->_result->incrementError();
87
- $this->_result->incrementTotal();
88
- }
89
- }
90
- Mage::helper($this->_helper)->writeError($e);
91
- $this->_flushLogs($iterator->getOperation()->getApi());
92
- }
93
- }
94
- }
95
-
96
- /**
97
- * Extracts entry and returns the original queue model
98
- *
99
- * @return mixed
100
- */
101
- protected function _queueEntry($originalRow)
102
- {
103
- $queueRow = Mage::getModel("{$this->_helper}/queue");
104
- $queueRow->setData($originalRow);
105
- return $queueRow;
106
- }
107
-
108
- /**
109
- * Verbose log the API flush
110
- *
111
- * @param Bronto_Api $api
112
- */
113
- protected function _flushLogs($api)
114
- {
115
- $helper = Mage::helper($this->_helper);
116
- $apiLog = "{$this->_helper}_api.log";
117
- $helper->writeVerboseDebug("===== FLUSH =====", $apiLog);
118
- $helper->writeVerboseDebug(var_export($api->getLastRequest(), true), $apiLog);
119
- $helper->writeVerboseDebug(var_export($api->getLastResponse(), true), $apiLog);
120
- }
121
-
122
- /**
123
- * Gets the cached results from the consequtive write calls
124
- *
125
- * @return array
126
- */
127
- public function getResult()
128
- {
129
- return $this->_result->toArray();
130
- }
131
-
132
- /**
133
- * @return
134
- */
135
- public function setHelper($helperName)
136
- {
137
- $this->_helper = $helperName;
138
- return $this;
139
- }
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Keysentry.php DELETED
@@ -1,134 +0,0 @@
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 API Retry and Send Queue
16
- */
17
- const API = 'bronto_common/api';
18
-
19
- /**
20
- * Bronto Couponmodue alias
21
- */
22
- const COUPON = 'bronto_common/coupon';
23
-
24
- /**
25
- * Bronto customer module alias
26
- */
27
- const CUSTOMER = 'bronto_customer';
28
-
29
- /**
30
- * Bronto email module alias
31
- */
32
- const EMAIL = 'bronto_email';
33
-
34
- /**
35
- * Bronto newsletter module alias
36
- */
37
- const NEWSLETTER = 'bronto_newsletter';
38
-
39
- /**
40
- * Bronto order module alias
41
- */
42
- const ORDER = 'bronto_order';
43
-
44
- /**
45
- * Bronto reminder module alias
46
- */
47
- const REMINDER = 'bronto_reminder';
48
-
49
- /**
50
- * Bronto reviews module alias
51
- */
52
- const REVIEWS = 'bronto_reviews';
53
-
54
- /**
55
- * Bronto product reccommendations
56
- */
57
- const PRODUCT = 'bronto_product';
58
-
59
- /**
60
- * Disable all the defined modules for the scope
61
- *
62
- * @param mixed $scope Site scope
63
- * @param integer $scopeId Site scope id
64
- * @param boolean $includeCommon switch to disable bronto_common module
65
- * @param boolean $deleteChildren if true will delete config values for child scopes
66
- */
67
- public function disableModules($scope, $scopeId, $includeCommon = false, $deleteChildren = false)
68
- {
69
- if ($includeCommon) {
70
- Mage::helper(self::COMMON)->disableModule($scope, $scopeId, $deleteChildren);
71
- }
72
-
73
- Mage::helper(self::CUSTOMER)->disableModule($scope, $scopeId, $deleteChildren);
74
- Mage::helper(self::EMAIL)->disableModule($scope, $scopeId, $deleteChildren);
75
- Mage::helper(self::NEWSLETTER)->disableModule($scope, $scopeId, $deleteChildren);
76
- Mage::helper(self::ORDER)->disableModule($scope, $scopeId, $deleteChildren);
77
- Mage::helper(self::REMINDER)->disableModule($scope, $scopeId, $deleteChildren);
78
- Mage::helper(self::REVIEWS)->disableModule($scope, $scopeId, $deleteChildren);
79
- Mage::helper(self::PRODUCT)->disableModule($scope, $scopeId, $deleteChildren);
80
- Mage::helper(self::COUPON)->disableModule($scope, $scopeId, $deleteChildren);
81
- Mage::helper(self::API)->disableModule($scope, $scopeId, $deleteChildren);
82
-
83
- // Get Child Items
84
- if ('website' == $scope) {
85
- $website = Mage::app()->getWebsite($scopeId);
86
- foreach ($website->getStoreIds() as $storeId) {
87
- $this->disableModules('store', $storeId, $includeCommon, true);
88
- }
89
- } elseif ('default' == $scope) {
90
- foreach (Mage::app()->getWebsites(false) as $website) {
91
- $this->disableModules('website', $website->getId(), $includeCommon, true);
92
- }
93
- }
94
- }
95
-
96
- /**
97
- * Remove Bronto Message Connection for Template
98
- *
99
- * @param Varien_Data_Collection_Db $collection
100
- * @param string $scope
101
- * @param string|int $scopeId
102
- */
103
- public function unlinkEmails(Varien_Data_Collection_Db $collection, $scope, $scopeId)
104
- {
105
- switch ($scope) {
106
- case 'stores':
107
- case 'store':
108
- $storeId = $scopeId;
109
- break;
110
- case 'websites':
111
- case 'website':
112
- $storeId = Mage::app()->getWebsite($scopeId)->getStoreIds();
113
- break;
114
- default:
115
- $storeId = false;
116
- break;
117
- }
118
-
119
- // create filter
120
- if ($storeId) {
121
- if (is_array($storeId)) {
122
- $filter = array('in' => $storeId);
123
- } else {
124
- $filter = array('eq' => $storeId);
125
- }
126
- $collection->addFieldToFilter('store_id', $filter);
127
- }
128
-
129
- // Delete Bronto Message connection to template
130
- foreach ($collection as $message) {
131
- $message->delete();
132
- }
133
- }
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/List.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
- class Bronto_Common_Model_List
3
- {
4
- private $_helper;
5
- private $_path;
6
-
7
- public function __construct($params = array())
8
- {
9
- $settings = null;
10
- if (count($params) >= 2) {
11
- list($module, $settings) = $params;
12
- } else {
13
- $module = $params[0];
14
- }
15
- if (is_null($settings)) {
16
- $settings = 'settings';
17
- }
18
- $this->_path = "{$module}/{$settings}/exclusion";
19
- $this->_helper = Mage::helper($module);
20
- }
21
-
22
- /**
23
- * Gets an array of Bronto List ids for delivery exclusion
24
- *
25
- * @param string $scope
26
- * @param mixed $scopeId
27
- * @return array
28
- */
29
- public function getExclusionLists($scope = 'default', $scopeId = 0)
30
- {
31
- $listIds = $this->_helper->getAdminScopedConfig($this->_path, $scope, $scopeId);
32
- if (empty($listIds)) {
33
- return array();
34
- }
35
- if (is_string($listIds)) {
36
- return explode(',', $listIds);
37
- }
38
- return $listIds;
39
- }
40
-
41
- /**
42
- * @param mixed $storeId
43
- * @return array
44
- */
45
- public function addAdditionalRecipients($storeId)
46
- {
47
- $listIds = $this->getExclusionLists('store', $storeId);
48
- $recipients = array();
49
- if ($listIds) {
50
- try {
51
- $listObject = $this->_helper->getApi(null, 'store', $storeId)->transferMailList();
52
- $lists = $listObject->read()->where->id->in($listIds);
53
- foreach ($lists as $list) {
54
- $this->_helper->writeDebug("Excluding list: {$list->getName()} ({$list->getId()})");
55
- $recipients[] = array(
56
- 'type' => 'list',
57
- 'id' => $list->getId(),
58
- 'deliveryType' => 'ineligible'
59
- );
60
- }
61
- } catch (Exception $e) {
62
- $this->_helper->writeError("Unable to add exclusion lists: " . $e->getMessage());
63
- }
64
- }
65
- return $recipients;
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Mysql4/Api.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Mysql4_Api extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
- protected $_isPkAutoIncrement = false;
6
-
7
- /**
8
- * @see parent
9
- */
10
- public function _construct()
11
- {
12
- $this->_init('bronto_common/api', 'token');
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Mysql4/Api/Collection.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Mysql4_Api_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function _construct()
9
- {
10
- parent::_construct();
11
- $this->_init('bronto_common/api');
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Mysql4/Error.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Mysql4_Error extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function _construct()
9
- {
10
- $this->_init('bronto_common/error', 'error_id');
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Mysql4/Error/Collection.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Mysql4_Error_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function _construct()
9
- {
10
- parent::_construct();
11
- $this->_init('bronto_common/error');
12
- }
13
-
14
- /**
15
- * Orders the items by last attempt time
16
- *
17
- * @return Bronto_Common_Model_Mysql4_Error_Collection
18
- */
19
- public function orderByOldest()
20
- {
21
- return $this->addOrder('last_attempt', self::SORT_ORDER_ASC);
22
- }
23
-
24
- /**
25
- * Gets the entries that have less than the threshold attempts
26
- *
27
- * @param int $threshold
28
- * @return Bronto_Common_Model_Mysql4_Error_Collection
29
- */
30
- public function addAttemptThreshold($threshold)
31
- {
32
- $this->addFieldToFilter('attempts', array('lt' => $threshold));
33
- return $this;
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Mysql4/Queue.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function _construct()
9
- {
10
- $this->_init('bronto_common/queue', 'queue_id');
11
- }
12
-
13
- /**
14
- * Flags the obtained the items for holding
15
- *
16
- * @param array $items
17
- * @return Bronto_Common_Model_Mysql4_Queue
18
- */
19
- public function flagForHolding($ids)
20
- {
21
- $resource = $this->_getWriteAdapter();
22
- $condition = $this->getIdFieldName() . ' IN (' . implode(',', $ids) . ')';
23
- $update = array('holding' => 1);
24
- $resource = $resource->update($this->getMainTable(), $update, $condition);
25
- return $this;
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Mysql4/Queue/Collection.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
- /**
6
- * @see parent
7
- */
8
- public function _construct()
9
- {
10
- parent::_construct();
11
- $this->_init('bronto_common/queue');
12
- }
13
-
14
- /**
15
- * Only gets the entries that aren't flagged for holding
16
- *
17
- * @return Bronto_Common_Model_Mysql4_Queue_Collection
18
- */
19
- public function getReadyEntries()
20
- {
21
- return $this->addFieldToFilter('holding', array('eq' => 0));
22
- }
23
-
24
- /**
25
- * Only gets the entries for the store in question
26
- *
27
- * @return Bronto_Common_Model_Mysql4_Queue_Collection
28
- */
29
- public function getEntriesForStore($storeId)
30
- {
31
- return $this->addFieldToFilter('store_id', array('eq' => $storeId));
32
- }
33
-
34
- /**
35
- * Gets the oldest to pop out the queue
36
- *
37
- * @return Bronto_Common_Model_Mysql4_Queue_Collection
38
- */
39
- public function orderByOldest()
40
- {
41
- return $this->addOrder('created_at', self::SORT_ORDER_ASC);
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Observer.php DELETED
@@ -1,370 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Common
6
- */
7
- class Bronto_Common_Model_Observer
8
- {
9
-
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, array(array('edition' => 'Professional', 'major' => 9)))) {
46
- $sentry->unlinkEmails(
47
- Mage::getModel('bronto_email/message')->getCollection(),
48
- $scope,
49
- $scopeId
50
- );
51
- }
52
-
53
- Mage::getConfig()->reinit();
54
- Mage::app()->reinitStores();
55
- }
56
-
57
- /**
58
- * events: controller_action_predispatch
59
- *
60
- * @param Varien_Event_Observer $observer
61
- *
62
- * @return mixed
63
- */
64
- public function checkBrontoRequirements(Varien_Event_Observer $observer)
65
- {
66
-
67
- $action = $observer->getEvent()->getControllerAction();
68
- // In session, not Ajax, not POST
69
- if (
70
- !Mage::getSingleton('admin/session')->isLoggedIn() ||
71
- $action->getRequest()->isAjax() ||
72
- $action->getRequest()->isPost()
73
- ) {
74
- return false;
75
- }
76
-
77
- $helper = Mage::helper(self::NOTICE_IDENTIFIER);
78
-
79
- // Verify Requirements
80
- if (!$helper->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
81
- return false;
82
- }
83
-
84
- // Bug user about registration, only once
85
- $onBronto = $action->getRequest()->getParam('section') == 'bronto';
86
- !Mage::helper(self::SUPPORT_IDENTIFIER)->verifyRegistration($onBronto);
87
-
88
- // Verify API tokens are valid
89
- if ($helper->isEnabled() && !$helper->validApiStatus()) {
90
- return false;
91
- }
92
-
93
- return $this;
94
- }
95
-
96
- /**
97
- * Cron to clear downloaded zips
98
- */
99
- public function clearArchives($cron)
100
- {
101
- Mage::helper(self::SUPPORT_IDENTIFIER)->clearArchiveDirectory();
102
- }
103
-
104
- /**
105
- * Cron to clear really old log entries
106
- */
107
- public function clearOldLogs($cron)
108
- {
109
- $helper = Mage::helper(self::SUPPORT_IDENTIFIER);
110
- if ($helper->isEnabled() && $helper->shouldClearLogs()) {
111
- $helper->clearOldLogs();
112
- }
113
- }
114
-
115
- /**
116
- * Cron to process API errors
117
- */
118
- public function processApiErrors($cron = null)
119
- {
120
- $results = array(
121
- 'total' => 0,
122
- 'success' => 0,
123
- 'error' => 0
124
- );
125
-
126
- $helper = Mage::helper('bronto_common/api');
127
- if (!$helper->isEnabled()) {
128
- return $results;
129
- }
130
- $helper->writeDebug('Retrying API errors.');
131
- $api = $helper->getApi();
132
- try {
133
- $api->login();
134
- } catch (Exception $e) {
135
- $helper->writeDebug('Skipping process because API is not taking calls: ' . $e->getMessage());
136
- return $results;
137
- }
138
-
139
- $collection = Mage::getModel('bronto_common/error')->getCollection()
140
- ->orderByOldest()
141
- ->addAttemptThreshold($helper->getAttemptThreshold())
142
- ->setPageSize($helper->getErrorThreshold());
143
-
144
- foreach ($collection->getItems() as $error) {
145
- try {
146
- $error->attempt($error->getId());
147
- $results['success']++;
148
- } catch (Exception $e) {
149
- $helper->writeError('An entry was place back in the queue: ' . $e->getMessage());
150
- $results['error']++;
151
- }
152
- $results['total']++;
153
- }
154
-
155
- return $results;
156
- }
157
-
158
- /**
159
- * Cron to process email sending
160
- *
161
- * @return array
162
- */
163
- public function processSendQueue($cron = null)
164
- {
165
- $results = array(
166
- 'total' => 0,
167
- 'success' => 0,
168
- 'error' => 0
169
- );
170
- $stores = Mage::app()->getStores(true);
171
- foreach ($stores as $store) {
172
- foreach ($this->processSendForStore($store) as $field => $count) {
173
- $results[$field] += $count;
174
- }
175
- }
176
- return $results;
177
- }
178
-
179
- /**
180
- * Processes the website sends
181
- *
182
- * @param int $websiteId
183
- * @return array
184
- */
185
- public function processSendForSite($websiteId)
186
- {
187
- $results = array(
188
- 'total' => 0,
189
- 'success' => 0,
190
- 'error' => 0,
191
- );
192
- $website = Mage::app()->getWebsite($websiteId);
193
- foreach ($website->getStores() as $store) {
194
- foreach ($this->processSendForStore($store) as $field => $count) {
195
- $results[$field] += $count;
196
- }
197
- }
198
- return $results;
199
- }
200
-
201
- /**
202
- * Processes the send queue for a given scope
203
- *
204
- * @return array
205
- */
206
- public function processSendForScope()
207
- {
208
- $scopeParams = Mage::helper('bronto_common')->getScopeParams();
209
- if ($scopeParams['store']) {
210
- return $this->processSendForStore($scopeParams['store_id']);
211
- } else if ($scopeParams['website']) {
212
- return $this->processSendForSite($scopeParams['website_id']);
213
- } else {
214
- return $this->processSendQueue();
215
- }
216
- }
217
-
218
- /**
219
- * Processes the send queue for a given store
220
- *
221
- * @param int storeId
222
- * @return array
223
- */
224
- public function processSendForStore($storeId)
225
- {
226
- $results = array(
227
- 'total' => 0,
228
- 'success' => 0,
229
- 'error' => 0,
230
- );
231
- $helper = Mage::helper('bronto_common/api');
232
- $singleton = Mage::getModel('bronto_common/queue');
233
- $store = Mage::app()->getStore($storeId);
234
- if (!$helper->canUseQueue('store', $store->getId())) {
235
- return $results;
236
- }
237
-
238
- $api = $helper->getApi(null, 'store', $store->getId());
239
- $collection = $singleton->getCollection()
240
- ->orderByOldest()
241
- ->getReadyEntries()
242
- ->getEntriesForStore($store->getId())
243
- ->setPageSize($helper->getSendLimit('store', $store->getId()))
244
- ->getItems();
245
- $singleton->flagForHolding($collection);
246
-
247
- foreach ($collection as $queue) {
248
- $results['total']++;
249
- try {
250
- if ($queue->setApi($api)->send()) {
251
- $results['success']++;
252
- } else {
253
- $results['error']++;
254
- }
255
- } catch (Exception $e) {
256
- $helper->writeError('Error in delivery for store ' . $store->getId() . ': ' . $e->getMessage());
257
- $results['error']++;
258
- }
259
- // Pop, in either case
260
- $queue->delete();
261
- }
262
- return $results;
263
- }
264
-
265
- /**
266
- * Validates that certain fields are not empty
267
- *
268
- * @param array $groups
269
- * @param boolean $formatWeb (Optional)
270
- *
271
- * @throws Mage_Exception
272
- */
273
- protected function _validateSupportForm($groups, $formatWeb = true)
274
- {
275
- $helper = Mage::helper(self::NOTICE_IDENTIFIER);
276
-
277
- $errors = array();
278
- foreach ($this->_validatedFields as $field => $label) {
279
- $values = $groups['support']['fields'][$field];
280
- if (array_key_exists('inherit', $values) && $values['inherit']) {
281
- continue;
282
- }
283
-
284
- if (array_key_exists('value', $values) && empty($values['value'])) {
285
- $errors[] = $helper->__("Please enter your $label.");
286
- }
287
- }
288
-
289
- $usingPartner = $groups['support']['fields']['using_solution_partner'];
290
- if (array_key_exists('value', $usingPartner) && !empty($usingPartner['value'])) {
291
- if (array_key_exists('inherit', $groups['support']['fields']['partner']) && $groups['support']['fields']['partner']['inherit']) {
292
- return;
293
- }
294
-
295
- if (empty($groups['support']['fields']['partner']['value'])) {
296
- $errors[] = $helper->__('Please enter your Solution Partner or SI Name.');
297
- }
298
- }
299
-
300
- if ($errors) {
301
- Mage::throwException(implode($formatWeb ? '<br/>' : "\n", $errors));
302
- }
303
- }
304
-
305
- /**
306
- * Save registration from from admin save config button
307
- * events: model_config_data_save_before
308
- *
309
- * @param Varien_Event_Observer $observer
310
- *
311
- * @return boolean
312
- */
313
- public function registerExtension(Varien_Event_Observer $observer)
314
- {
315
- $action = $observer->getEvent()->getControllerAction();
316
- $session = Mage::getSingleton('admin/session');
317
- $support = Mage::helper(self::SUPPORT_IDENTIFIER);
318
-
319
- if (
320
- $session->isLoggedIn() &&
321
- !$action->getRequest()->isAjax() &&
322
- $action->getRequest()->isPost() &&
323
- $action->getRequest()->getParam('section') == 'bronto'
324
- ) {
325
-
326
- $groups = $action->getRequest()->getParam('groups');
327
- $enabled = $groups['settings']['fields']['enabled'];
328
-
329
- // If Module is not enabled, don't proceed
330
- if (array_key_exists('value', $enabled) && $enabled['value'] == '0') {
331
- return false;
332
- }
333
-
334
- $apiToken = $groups['settings']['fields']['api_token'];
335
-
336
- if (!array_key_exists('value', $apiToken) || (array_key_exists('value', $apiToken) && empty($apiToken['value']))) {
337
- return false;
338
- }
339
-
340
- if (empty($groups['support'])) {
341
- return false;
342
- }
343
-
344
- try {
345
- $this->_validateSupportForm($groups);
346
-
347
- $postFields = array();
348
- foreach ($groups['support']['fields'] as $field => $values) {
349
- if (array_key_exists('inherit', $groups['support']['fields'][$field]) && $groups['support']['fields'][$field]['inherit']) {
350
- continue;
351
- }
352
- $postFields[$field] = $values['value'];
353
- }
354
-
355
- return $support->submitSupportForm($postFields);
356
- } catch (Exception $e) {
357
- Mage::getSingleton('adminhtml/session')
358
- ->addMessage(
359
- Mage::getSingleton('core/message')
360
- ->error($e->getMessage())
361
- ->setIdentifier(self::NOTICE_IDENTIFIER)
362
- );
363
-
364
- Mage::helper(self::NOTICE_IDENTIFIER)->writeError($e->getMessage());
365
- }
366
- }
367
-
368
- return false;
369
- }
370
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Queue.php DELETED
@@ -1,200 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_Queue extends Mage_Core_Model_Abstract
4
- {
5
- protected $_eventPrefix = 'bronto_common_queue';
6
-
7
- /**
8
- * @var Bronto_Api
9
- */
10
- protected $_api;
11
-
12
- /**
13
- * @var array Bronto_Api_Model_Contact
14
- */
15
- protected $_contacts;
16
-
17
- /**
18
- * @var Bronto_Api_Message_Row
19
- */
20
- protected $_message;
21
-
22
- /**
23
- * @var Bronto_Api_Operation_Delivery
24
- */
25
- protected $_deliveryObject;
26
-
27
- /**
28
- * @var array
29
- */
30
- protected $_unserializedData;
31
-
32
- /**
33
- * @see parent
34
- */
35
- protected function _construct()
36
- {
37
- parent::_construct();
38
- $this->_init('bronto_common/queue');
39
- }
40
-
41
- /**
42
- * Flags the obtained the items for holding
43
- *
44
- * @param array $items
45
- * @return array
46
- */
47
- public function flagForHolding($items)
48
- {
49
- $ids = array();
50
- foreach ($items as $item) {
51
- $ids[] = $item->getId();
52
- }
53
- if (empty($ids)) {
54
- return array();
55
- }
56
- $this->_getResource()->flagForHolding($ids);
57
- return $ids;
58
- }
59
-
60
- /**
61
- * Sets the Bronto_Api
62
- *
63
- * @param Bronto_Api
64
- * @return Bronto_Common_Model_Queue
65
- */
66
- public function setApi($api)
67
- {
68
- $this->_api = $api;
69
- return $this;
70
- }
71
-
72
- /**
73
- * Gets the Bronto_Api for this queue
74
- *
75
- * @return Bronto_Api
76
- */
77
- protected function _api()
78
- {
79
- if (is_null($this->_api)) {
80
- $this->_api = Mage::helper('bronto_common')->getApi(null, 'store', $this->getStoreId());
81
- }
82
- return $this->_api;
83
- }
84
-
85
- /**
86
- * @return Bronto_Api_Operation_Delivery
87
- */
88
- public function getDeliveryObject()
89
- {
90
- if (is_null($this->_deliveryObject)) {
91
- $this->_deliveryObject = $this->_api()->transferDelivery();
92
- }
93
- return $this->_deliveryObject;
94
- }
95
-
96
- /**
97
- * Sets the unserialized data for emails
98
- *
99
- * @param array
100
- * @return Bronto_Common_Model_Queue
101
- */
102
- public function setUnserializedEmailData($data)
103
- {
104
- $this->_unserializedData = $data;
105
- return $this->setEmailData(serialize($data));
106
- }
107
-
108
- /**
109
- * Gets the unserialized data for emails
110
- *
111
- * @return Varien_Object
112
- */
113
- public function getUnserializedEmailData()
114
- {
115
- if (is_null($this->_unserializedData)) {
116
- $this->_unserializedData = unserialize($this->getEmailData());
117
- }
118
- return new Varien_Object($this->_unserializedData);
119
- }
120
-
121
- /**
122
- * Gets the contacts to send the delivery
123
- *
124
- * @return array Bronto_Api_Contact_Row
125
- */
126
- public function getContacts()
127
- {
128
- if (is_null($this->_contacts)) {
129
- $emails = $this->getUnserializedEmailData()->getEmails();
130
- $contactHelper = Mage::helper('bronto_common/contact');
131
- $this->_contacts = $contactHelper->getContactsByEmail($emails, null, $this->getStoreId(), true);
132
- }
133
- return $this->_contacts;
134
- }
135
-
136
- /**
137
- * Gets the specialized data
138
- *
139
- * @return Varien_Object
140
- */
141
- public function getAdditionalData()
142
- {
143
- return new Varien_Object($this->getUnserializedEmailData()->getParams());
144
- }
145
-
146
- /**
147
- * Gets the Bronto Message associated with this delivery
148
- *
149
- * @return Bronto_Api_Message_Row
150
- */
151
- public function getMessage()
152
- {
153
- if (is_null($this->_message)) {
154
- $deliveryData = $this->getUnserializedEmailData()->getDelivery();
155
- $this->_message = Mage::helper('bronto_common/message')->getMessageById($deliveryData['messageId'], $this->getStoreId());
156
- }
157
- return $this->_message;
158
- }
159
-
160
- /**
161
- * Gets the Recommendation info supplied by the email model
162
- *
163
- * @return Varien_Object
164
- */
165
- public function getRecommendationInfo()
166
- {
167
- return new Varien_Object($this->getUnserializedEmailData()->getRecommendation());
168
- }
169
-
170
- /**
171
- * Creates a Bronto_Api_Model_Delivery from internals
172
- *
173
- * @param array $additionalFields
174
- * @return Bronto_Api_Model_Delivery
175
- */
176
- public function prepareDelivery($additionalFields = array())
177
- {
178
- $delivery = $this->getDeliveryObject()->createObject()
179
- ->withEmailClass($this->getEmailClass());
180
- $deliveryData = $this->getUnserializedEmailData()->getDelivery();
181
- foreach ($deliveryData as $field => $value) {
182
- if ($field == 'fields' && !empty($additionalFields)) {
183
- $value = array_merge($value, $additionalFields);
184
- }
185
- $delivery->{$field} = $value;
186
- }
187
- return $delivery;
188
- }
189
-
190
- /**
191
- * Sends a Bronto Delivery
192
- *
193
- * @reutrn bool
194
- */
195
- public function send()
196
- {
197
- $template = Mage::getModel($this->getEmailClass());
198
- return $template->sendDeliveryFromQueue($this);
199
- }
200
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Resource/Abstract.php DELETED
@@ -1,180 +0,0 @@
1
- <?php
2
-
3
- abstract class Bronto_Common_Model_Resource_Abstract extends Mage_Core_Model_Resource_Setup
4
- {
5
- protected $_dropStmt = 'DROP TABLE IF EXISTS `{table}`;';
6
-
7
- /**
8
- * Return the module namespace for this setup
9
- *
10
- * eg: 'bronto_common'
11
- * @return string
12
- */
13
- protected abstract function _module();
14
-
15
- /**
16
- * Return the table definitions belonging to this module
17
- *
18
- * eg: array('table' => 'CREATE {table} ...')
19
- * @return array
20
- */
21
- protected abstract function _tables();
22
-
23
- /**
24
- * Return the update definitions belonging to this module
25
- *
26
- * eg: array('1.0.1' => array('table' => array('sql' => 'UPDATE....')))
27
- * @return array
28
- */
29
- protected abstract function _updates();
30
-
31
- /**
32
- * Gets the internal table name for $key
33
- *
34
- * @param string $key
35
- * @return string
36
- */
37
- protected function _tableName($key)
38
- {
39
- return $this->getTable("{$this->_module()}/$key");
40
- }
41
-
42
- /**
43
- * Replaces the {table} name in the statement
44
- *
45
- * @param string $key
46
- * @param string $string
47
- * @return string
48
- */
49
- protected function _replaceName($key, $string)
50
- {
51
- return $this->_replaceText('table', $this->_tableName($key), $string);
52
- }
53
-
54
- /**
55
- * Wrapper around str_replace for special replace keys
56
- *
57
- * @param string $key
58
- * @param string $value
59
- * @param string $original
60
- * @return string
61
- */
62
- protected function _replaceText($key, $value, $original)
63
- {
64
- return str_replace('{' . $key . '}', $value, $original);
65
- }
66
-
67
- /**
68
- * Repalce the table and all others
69
- *
70
- * @param string $table
71
- * @param string $string
72
- * @param array $extra
73
- * @return string
74
- */
75
- protected function _replaceStatement($table, $string, $extra = array()) {
76
- $statement = $this->_replaceName($table, $string);
77
- foreach ($extra as $key => $value) {
78
- $statement = $this->_replaceText($key, $value, $statement);
79
- }
80
- return $statement;
81
- }
82
-
83
- /**
84
- * Triggers the callback for a given update
85
- *
86
- * @param array $update
87
- */
88
- protected function _updateCallback($state, $table, $update)
89
- {
90
- if (array_key_exists($state, $update)) {
91
- $callback = $update[$state];
92
- if (is_string($callback)) {
93
- $callback = array($this, $callback);
94
- }
95
- if (is_callable($callback)) {
96
- call_user_func($callback, $table);
97
- }
98
- }
99
- }
100
-
101
- /**
102
- * Creates the table with the provided stmt.
103
- *
104
- * @param string $table
105
- * @param array $extra (Optional)
106
- * @return void
107
- * @throws RuntimeException is the table does not exist
108
- */
109
- public function createTable($table, $extra = array())
110
- {
111
- $tables = $this->_tables();
112
- if (!array_key_exists($table, $this->_tables())) {
113
- throw new RuntimeException("Table {$table} does not exist.");
114
- }
115
- $this->run($this->_replaceStatement($table, $tables[$table], $extra));
116
- }
117
-
118
- /**
119
- * Creates all of the tables
120
- *
121
- * @param array $extra (Optional)
122
- */
123
- public function createTables($extra = array())
124
- {
125
- foreach ($this->_tables() as $table => $statement) {
126
- $this->dropTable($table);
127
- $this->createTable($table, $extra);
128
- }
129
- }
130
-
131
- /**
132
- * Drops all of the tables
133
- */
134
- public function dropTables()
135
- {
136
- foreach ($this->_tables() as $table => $_) {
137
- $this->dropTable($table);
138
- }
139
- }
140
-
141
- /**
142
- * Drops the table with the given key
143
- *
144
- * @param string $table
145
- * @return void
146
- */
147
- public function dropTable($table)
148
- {
149
- $this->run($this->_replaceName($table, $this->_dropStmt));
150
- }
151
-
152
- /**
153
- * Updates the table with the specific commands
154
- *
155
- * @param string $table
156
- * @param string $version
157
- * @return void
158
- */
159
- public function updateTables($version)
160
- {
161
- $updates = $this->_updates();
162
- if (!array_key_exists($version, $updates)) {
163
- throw new RuntimeException("Version $version is not defined.");
164
- }
165
- // Updates all of the tables in this version
166
- foreach ($updates[$version] as $table => $update) {
167
- $extra = !empty($update['extra']) ? $update['extra'] : array();
168
- try {
169
- $this->_updateCallback('before', $table, $update);
170
- if (isset($update['sql'])) {
171
- $sql = is_array($update['sql']) ? implode(';', $update['sql']) : $update['sql'];
172
- $this->run($this->_replaceName($table, $sql, $extra));
173
- }
174
- $this->_updateCallback('after', $table, $update);
175
- } catch (Exception $e) {
176
- Mage::helper($this->_module())->writeError("Failed to update $table to $version: {$e->getMessage()}");
177
- }
178
- }
179
- }
180
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/Resource/Setup.php DELETED
@@ -1,156 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Common
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Common_Model_Resource_Setup extends Bronto_Common_Model_Resource_Abstract
8
- {
9
-
10
- /**
11
- * @see parent
12
- * @return string
13
- */
14
- protected function _module()
15
- {
16
- return 'bronto_common';
17
- }
18
-
19
- /**
20
- * Gets all of the create table definititions at this version
21
- *
22
- * @see parent
23
- * @return array
24
- */
25
- protected function _tables()
26
- {
27
- return array(
28
- 'api' => "
29
- CREATE TABLE `{table}` (
30
- `token` varchar(36) NOT NULL,
31
- `session_id` varchar(36) NOT NULL,
32
- `created_at` datetime NOT NULL,
33
- PRIMARY KEY (`token`)
34
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'",
35
- 'error' => "
36
- CREATE TABLE `{table}` (
37
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
38
- `email_class` varchar(100) NULL,
39
- `object` mediumtext NOT NULL DEFAULT '',
40
- `attempts` smallint(1) NOT NULL,
41
- `last_attempt` datetime NOT NULL,
42
- PRIMARY KEY (`error_id`),
43
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
44
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
45
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'",
46
- 'queue' => "
47
- CREATE TABLE `{table}` (
48
- `queue_id` int(11) NOT NULL AUTO_INCREMENT,
49
- `store_id` int(11) NOT NULL DEFAULT '1',
50
- `email_class` varchar(100) NOT NULL,
51
- `email_data` mediumtext NOT NULL DEFAULT '',
52
- `holding` smallint(1) NOT NULL DEFAULT 0,
53
- `created_at` datetime NOT NULL,
54
- PRIMARY KEY (`queue_id`),
55
- KEY `IDX_BRONTO_SEND_QUEUE_STORE` (`store_id`),
56
- KEY `IDX_BRONTO_SEND_QUEUE_HOLDING` (`holding`),
57
- KEY `IDX_BRONTO_SEND_QUEUE_TIMESTAMP` (`created_at`)
58
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Send queue'"
59
- );
60
- }
61
-
62
- /**
63
- * Updates the appropriate tables
64
- *
65
- * @see parent
66
- * @return array
67
- */
68
- protected function _updates()
69
- {
70
- return array(
71
- '2.3.0' => array(
72
- 'error' => array(
73
- 'sql' => 'ALTER TABLE {table} MODIFY COLUMN `object` mediumtext'
74
- ),
75
- 'queue' => array(
76
- 'before' => 'dropTable',
77
- 'after' => 'createTable',
78
- )
79
- )
80
- );
81
- }
82
-
83
- /**
84
- * Re-submits the registration information stored in core_config_data
85
- *
86
- * @return boolean
87
- */
88
- public function resubmitFormInfo()
89
- {
90
- $helper = Mage::helper('bronto_common/support');
91
- $prefix = Bronto_Common_Helper_Support::XML_PATH_SUPPORT . '/';
92
- $skippable = array(
93
- Bronto_Common_Helper_Support::XML_PATH_LAST_RUN,
94
- Bronto_Common_Helper_Support::XML_PATH_REGISTERED
95
- );
96
- $submittedData = Mage::getModel('core/config_data')->getCollection()
97
- ->addFieldToFilter('scope', array('eq' => 'default'))
98
- ->addFieldToFilter('path', array('like' => $prefix . '%'));
99
- $formData = array();
100
- foreach ($submittedData as $config) {
101
- if (in_array($config->getKey(), $skippable)) {
102
- continue;
103
- }
104
- $key = str_replace($prefix, '', $config->getPath());
105
- $formData[$key] = $config->getValue();
106
- }
107
- return $helper->submitSupportForm($formData);
108
- }
109
-
110
- public function handleOld()
111
- {
112
- // Look if Bronto folder exists in local codepool and recursively remove if it is
113
- $source = Mage::getBaseDir('base') . DS . 'app' . DS . 'code' . DS . 'local' . DS . 'Bronto' . DS;
114
- $destination = Mage::getBaseDir('base') . DS . 'var' . DS . 'bronto_backup' . DS;
115
- if (file_exists($source)) {
116
- $this->rcopy($source, $destination);
117
- $this->rrmdir($source);
118
-
119
- // Add Notification so customer is sure to know
120
- Mage::getSingleton('adminnotification/inbox')->add(
121
- 4,
122
- 'Bronto Update - Old Version Moved',
123
- 'Bronto has been updated. We have moved the files from your previous installation to ' . $destination
124
- );
125
- }
126
- }
127
-
128
- public function rrmdir($dir)
129
- {
130
- $files = array_diff(scandir($dir), array('.', '..'));
131
- foreach ($files as $file) {
132
- (is_dir("$dir/$file")) ? $this->rrmdir("$dir/$file") : unlink("$dir/$file");
133
- }
134
- rmdir($dir);
135
- }
136
-
137
- public function rcopy($src, $dst)
138
- {
139
- // Remove Destination if it is a file
140
- if (file_exists($dst)) {
141
- $this->rrmdir($dst);
142
- }
143
- // If Source is a directory create destination and move everything
144
- if (is_dir($src)) {
145
- mkdir($dst);
146
- $files = scandir($src);
147
- foreach ($files as $file) {
148
- if ($file != "." && $file != "..") {
149
- $this->rcopy("$src/$file", "$dst/$file");
150
- }
151
- }
152
- } elseif (file_exists($src)) {
153
- copy($src, $dst);
154
- }
155
- }
156
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/SoapClient.php DELETED
@@ -1,22 +0,0 @@
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(array('ssl' => $opts));
20
- parent::__construct($wsdl, $options);
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Backend/Cron.php DELETED
@@ -1,202 +0,0 @@
1
- <?php
2
-
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
9
- {
10
- /**
11
- * @var string
12
- */
13
- protected $_cron_string_path;
14
-
15
- /**
16
- * @var string
17
- */
18
- protected $_cron_model_path;
19
-
20
- /**
21
- * @var string
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
- *
49
- * @return Bronto_Common_Model_System_Config_Backend_Cron
50
- */
51
- protected function _afterSave()
52
- {
53
- $cronExprString = '';
54
-
55
- $useMageCron = $this->getFieldsetOrInheritedValue($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->getFieldsetOrInheritedValue('frequency');
70
-
71
- if ($frequency == $minutely) {
72
- $interval = (int)$this->getFieldsetOrInheritedValue('interval');
73
- $cronExprString = "*/{$interval} * * * *";
74
- } elseif ($frequency == $hourly) {
75
- $minutes = (int)$this->getFieldsetOrInheritedValue('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->getFieldsetOrInheritedValue('time');
83
- $timeMinutes = $time[1];
84
- $timeHours = $time[0];
85
- // Fix Midnight Issue
86
- if ('00' == $timeMinutes && '00' == $timeHours) {
87
- $timeMinutes = '59';
88
- $timeHours = '23';
89
- }
90
- $cronExprString = "{$timeMinutes} {$timeHours} * * *";
91
- }
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
- }
116
-
117
- /**
118
- * Gets the fieldsetform key or an inherited value
119
- *
120
- * @param string key
121
- * @return mixed
122
- */
123
- public function getFieldsetOrInheritedValue($key)
124
- {
125
- $fieldSetValue = $this->getFieldsetDataValue($key);
126
- if (empty($fieldSetValue)) {
127
- $helper = Mage::helper('bronto_common');
128
- $path = preg_replace('|/[^/]+$|', '/' . $key, $this->getPath());
129
- return $helper->getAdminScopedConfig($path, 'default');
130
- }
131
- return $fieldSetValue;
132
- }
133
-
134
- /**
135
- * Get value by key for new user data from <section>/groups/<group>/fields/<field>
136
- *
137
- * @param string $key
138
- *
139
- * @return string
140
- */
141
- public function getFieldsetDataValue($key)
142
- {
143
- if (method_exists('Mage_Core_Model_Config_Data', 'getFieldsetDataValue')) {
144
- return parent::getFieldsetDataValue($key);
145
- }
146
-
147
- // Handle older Magento versions
148
- $data = $this->_getData('fieldset_data');
149
- if (is_array($data) && isset($data[$key])) {
150
- return $data[$key];
151
- }
152
-
153
- $data = $this->getData();
154
- $groups = isset($data['groups']) ? $data['groups'] : array();
155
- $groupId = isset($data['group_id']) ? $data['group_id'] : array();
156
- foreach ($groups as $group => $fields) {
157
- $fields = isset($fields['fields']) ? $fields['fields'] : $fields;
158
- if ($group == $groupId) {
159
- if (isset($fields[$key]['value'])) {
160
- return $fields[$key]['value'];
161
- }
162
- }
163
- }
164
-
165
- return null;
166
- }
167
-
168
- /**
169
- * Save Config Value by Path
170
- *
171
- * @param string $path
172
- * @param mixed $value
173
- *
174
- * @return Bronto_Common_Model_System_Config_Backend_Cron
175
- */
176
- protected function _saveConfigData($path, $value)
177
- {
178
- Mage::getModel('core/config_data')
179
- ->load($path, 'path')
180
- ->setValue($value)
181
- ->setPath($path)
182
- ->save();
183
-
184
- return $this;
185
- }
186
-
187
- /**
188
- * Delete Config Value by Path
189
- *
190
- * @param string $path
191
- *
192
- * @return Bronto_Common_Model_System_Config_Backend_Cron
193
- */
194
- protected function _deleteConfigData($path)
195
- {
196
- Mage::getModel('core/config_data')
197
- ->load($path, 'path')
198
- ->delete();
199
-
200
- return $this;
201
- }
202
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Backend/Cron/Error.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Backend_Cron_Error extends Bronto_Common_Model_System_Config_Backend_Cron
4
- {
5
- protected $_cron_string_path = 'crontab/jobs/bronto_common_errors/schedule/cron_expr';
6
- protected $_cron_model_path = 'crontab/jobs/bronto_common_errors/run/model';
7
- }
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Backend/Cron/Queue.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Backend_Cron_Queue extends Bronto_Common_Model_System_Config_Backend_Cron
4
- {
5
- protected $_cron_string_path = 'crontab/jobs/bronto_common_queue/schedule/cron_expr';
6
- protected $_cron_model_path = 'crontab/jobs/bronto_common_queue/run/model';
7
- }
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Backend/Enable.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
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
9
- {
10
-
11
- protected $_eventPrefix = 'bronto_enable';
12
-
13
- /**
14
- * @return Bronto_Common_Model_System_Config_Backend_Enable
15
- */
16
- protected function _beforeSave()
17
- {
18
- if ($this->isValueChanged()) {
19
- // Build Event from section and method
20
- $pathParts = explode('/', $this->getPath());
21
- $section = array_shift($pathParts);
22
- $method = ($this->getValue() == "0") ? 'disable' : 'enable';
23
- $event = $section . '_' . $method;
24
-
25
- // Trigger section/method specific event
26
- Mage::dispatchEvent($event, $this->getData());
27
- }
28
-
29
- return parent::_beforeSave();
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Backend/Token.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
-
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
- {
9
-
10
- protected $_eventPrefix = 'bronto_token_model';
11
-
12
- /**
13
- * @return Bronto_Common_Model_System_Config_Backend_Token
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, array(array('edition' => 'Professional', 'major' => 9)))) {
89
- $sentry->unlinkEmails(
90
- Mage::getModel('bronto_email/message')->getCollection(),
91
- $this->getScope(),
92
- $this->getScopeId()
93
- );
94
- }
95
-
96
- Mage::getConfig()->reinit();
97
- Mage::app()->reinitStores();
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Attributes.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Source_Attributes
4
- {
5
- private $_options;
6
- // Exclude a set of base product attributes that are already included
7
- private $_exclude = array(
8
- 'price',
9
- 'group_price',
10
- 'special_price',
11
- 'special_price_from_date',
12
- 'special_price_to_date',
13
- 'tier_price',
14
- 'description',
15
- 'short_description',
16
- 'sku',
17
- 'name',
18
- 'image',
19
- 'image_label',
20
- 'small_image',
21
- 'small_image_label',
22
- 'thumbnail',
23
- 'thumbnail_label',
24
- );
25
-
26
- public function toOptionArray()
27
- {
28
- if (is_null($this->_options)) {
29
- $this->_options = array(
30
- '' => Mage::helper('bronto_common')->__('-- None Selected --')
31
- );
32
- $attrs = Mage::getResourceModel('catalog/product_attribute_collection')
33
- ->addVisibleFilter()
34
- ->addFieldToFilter('main_table.attribute_code', array('nin' => $this->_exclude));
35
- foreach ($attrs as $attr) {
36
- if (!$attr->getFrontendLabel()) {
37
- continue;
38
- }
39
- $this->_options[$attr->getAttributeCode()] = $attr->getFrontendLabel();
40
- }
41
- }
42
- return $this->_options;
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Contact/Status.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
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
- */
16
- protected $_options = array();
17
-
18
- /**
19
- * Short description for function
20
- *
21
- * Long description (if any) ...
22
- *
23
- * @return array Return description (if any) ...
24
- * @access public
25
- */
26
- public function toOptionArray()
27
- {
28
- if (!empty($this->_options)) {
29
- return $this->_options;
30
- }
31
-
32
- try {
33
- if ($api = Mage::helper('bronto_common')->getApi()) {
34
- /* @var $contactObject Bronto_Api_Contact */
35
- $contactObject = $api->getContactObject();
36
- foreach ($contactObject->getOptionValues('status') as $status) {
37
- $this->_options[] = array(
38
- 'value' => $status,
39
- 'label' => $status,
40
- );
41
- }
42
- }
43
- } catch (Exception $e) {
44
- // Ignore
45
- }
46
-
47
- return $this->_options;
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Coupon.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Source_Coupon
4
- {
5
- private $_options;
6
-
7
- /**
8
- * Gathers all of the sales rules on the system
9
- *
10
- * @return array
11
- */
12
- protected function _fillOptions($default = false)
13
- {
14
- $options = array();
15
- /** @var Mage_SalesRule_Model_Resource_Rule_Collection $rules */
16
- $now = Mage::getModel('core/date')->date('Y-m-d');
17
- $rules = Mage::getModel('salesrule/rule')->getCollection()
18
- ->addFieldToFilter('is_active', array('eq' => 1))
19
- ->addFieldToFilter('coupon_type', array('in' => array(Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC, Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO)))
20
- ->addFieldToFilter('from_date', array(
21
- array('null' => true),
22
- array('lteq' => $now)
23
- ))
24
- ->addFieldToFilter('to_date', array(
25
- array('null' => true),
26
- array('gteq' => $now)
27
- ))
28
- ->setOrder('sort_order');
29
- if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 6, 10, 11, array('major' => 9, 'edition' => 'Professional')))) {
30
- $rules->addFieldToFilter('use_auto_generation', array('eq' => 0));
31
- }
32
-
33
- // If there are any rules
34
- if ($rules->getSize()) {
35
- // Cycle Through Rules
36
- foreach ($rules as $rule) {
37
- // Handle Coupon Label
38
- $couponLabel = '(Coupon: *Auto Generated*)';
39
- if ($couponCode = $rule->getPrimaryCoupon()->getCode()) {
40
- $couponLabel = "(Coupon: {$couponCode})";
41
- }
42
-
43
- // Build Option
44
- $options[] = array(
45
- 'label' => "{$rule->getName()} {$couponLabel}",
46
- 'value' => $rule->getRuleId(),
47
- );
48
- }
49
- }
50
-
51
- $noneSelected = '-- None Selected --';
52
- if ($default) {
53
- $noneSelected = '-- Use Default --';
54
- }
55
-
56
- // Add -- None Selected -- Option
57
- array_unshift($options, array(
58
- 'label' => Mage::helper('bronto_common')->__($noneSelected),
59
- 'value' => ''
60
- ));
61
-
62
- return $options;
63
- }
64
-
65
- /**
66
- * Retrieve option array of sales rules
67
- *
68
- * @return array
69
- */
70
- public function toOptionArray($noneSelected = false)
71
- {
72
- if (empty($this->_options)) {
73
- $this->_options = $this->_fillOptions($noneSelected);
74
- }
75
- return $this->_options;
76
- }
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Frequency.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Common
6
- */
7
- class Bronto_Common_Model_System_Config_Source_Cron_Frequency
8
- {
9
-
10
- /**
11
- * Description for const
12
- */
13
- const CRON_MINUTELY = 'I';
14
-
15
- /**
16
- * Description for const
17
- */
18
- const CRON_HOURLY = 'H';
19
-
20
- /**
21
- * Description for const
22
- */
23
- const CRON_DAILY = 'D';
24
-
25
- /**
26
- * Short description for function
27
- *
28
- * Long description (if any) ...
29
- *
30
- * @return mixed Return description (if any) ...
31
- * @access public
32
- */
33
- public function toOptionArray()
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 DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Common
6
- */
7
- class Bronto_Common_Model_System_Config_Source_Cron_Minutes
8
- {
9
-
10
- /**
11
- * Short description for function
12
- *
13
- * Long description (if any) ...
14
- *
15
- * @return mixed Return description (if any) ...
16
- * @access public
17
- */
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'),
25
- 30 => Mage::helper('cron')->__('30 minutes'),
26
- );
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Field.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Common
6
- */
7
- class Bronto_Common_Model_System_Config_Source_Field
8
- {
9
- /**
10
- * @var array
11
- */
12
- protected $_options = array();
13
-
14
- /**
15
- * @return array
16
- */
17
- public function toOptionArray()
18
- {
19
- if (!empty($this->_options)) {
20
- return $this->_options;
21
- }
22
-
23
- try {
24
- if ($api = Mage::helper('bronto_common')->getApi()) {
25
- /* @var $fieldObject Bronto_Api_Field */
26
- $fieldObject = $api->transferField();
27
- foreach ($fieldObject->read() as $field) {
28
- $this->_options[] = array(
29
- 'value' => $field->getId(),
30
- 'label' => $field->getLabel(),
31
- );
32
- }
33
- }
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError($e);
36
- }
37
-
38
- array_unshift($this->_options, array(
39
- 'label' => 'Create New...',
40
- 'value' => '_new_',
41
- ));
42
-
43
- array_unshift($this->_options, array(
44
- 'label' => '-- None Selected --',
45
- 'value' => '_none_',
46
- ));
47
-
48
- return $this->_options;
49
- }
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)
59
- {
60
- try {
61
- if ($api = Mage::helper('bronto_common')->getApi()) {
62
- return $api->transferField()->getById($id);
63
- }
64
- } catch (Exception $e) {
65
- Mage::helper('bronto_common')->writeError($e);
66
- }
67
-
68
- return false;
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Image.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Source_Image
4
- {
5
- protected $_helper;
6
-
7
- /**
8
- * Return product image types
9
- *
10
- * @return array
11
- */
12
- public function toOptionArray()
13
- {
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 DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Common
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Common_Model_System_Config_Source_Limit
8
- {
9
- /**
10
- * @return array
11
- */
12
- public function toOptionArray()
13
- {
14
- return array(
15
- 10 => 10,
16
- 25 => 25,
17
- 50 => 50,
18
- 100 => 100,
19
- 250 => 250,
20
- 500 => 500,
21
- 1000 => 1000,
22
- );
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/List.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Common
6
- */
7
- class Bronto_Common_Model_System_Config_Source_List
8
- {
9
- /**
10
- * @var array
11
- */
12
- protected static $_options = array();
13
-
14
- /**
15
- * @return array
16
- */
17
- public function toOptionArray()
18
- {
19
- $helper = Mage::helper('bronto_common');
20
- $token = $helper->getApiToken();
21
- if (!isset(self::$_options[$token])) {
22
- self::$_options[$token] = array();
23
- try {
24
- if ($api = Mage::helper('bronto_common')->getApi($token)) {
25
- $listObject = $api->transferMailList();
26
- foreach ($listObject->read() as $list) {
27
- self::$_options[$token][] = array(
28
- 'value' => $list->getId(),
29
- 'label' => $list->getLabel(),
30
- );
31
- }
32
- }
33
- } catch (Exception $e) {
34
- $helper->writeError('Unable to get List options: ' . $e->getMessage());
35
- }
36
- }
37
-
38
- return self::$_options[$token];
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Message.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Bronto_Common
6
- */
7
- class Bronto_Common_Model_System_Config_Source_Message
8
- {
9
- /**
10
- * @var array
11
- */
12
- protected static $_options = array();
13
-
14
- /**
15
- * Get Messages as Array of Labels and Values for Select Fields
16
- *
17
- * @param null $token
18
- * @param boolean $useDefault
19
- * @return array
20
- */
21
- public function toOptionArray($token = null, $useDefault = false)
22
- {
23
- $helper = Mage::helper('bronto_common');
24
- $key = empty($token) ? $helper->getApiToken() : $token;
25
- if (!array_key_exists($key, self::$_options)) {
26
- self::$_options[$key] = array();
27
- try {
28
- if ($api = Mage::helper('bronto_common')->getApi($key)) {
29
- /* @var $messageObject Bronto_Api_Message */
30
- $messageObject = $api->transferMessage();
31
- foreach ($messageObject->read()->withIncludeContent(false) as $message) {
32
- $_option = array(
33
- 'label' => $message->getName(),
34
- 'value' => $message->getId(),
35
- );
36
-
37
- if ($message->getStatus() != 'active') {
38
- $_option['disabled'] = true;
39
- }
40
-
41
- self::$_options[$key][] = $_option;
42
- }
43
- }
44
- } catch (Exception $e) {
45
- $helper->writeError($e);
46
- }
47
-
48
- array_unshift(self::$_options[$key], array(
49
- 'label' => '',
50
- 'value' => '',
51
- ));
52
- }
53
-
54
- if ($useDefault) {
55
- self::$_options[$key][0]['label'] = $helper->__('-- Use Default --');
56
- } else {
57
- self::$_options[$key][0]['label'] = $helper->__('-- None Selected --');
58
- }
59
-
60
- return self::$_options[$key];
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Related.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Source_Related
4
- {
5
-
6
- /**
7
- * @var array
8
- */
9
- protected $_options;
10
-
11
- /**
12
- * Related Product Sources key => value pairs
13
- *
14
- * @param null $isMultiselect
15
- *
16
- * @return array
17
- */
18
- public function toOptionArray($isMultiselect = null)
19
- {
20
- if (!is_null($this->_options)) {
21
- return $this->_options;
22
- }
23
-
24
- $helper = Mage::helper('bronto_common');
25
-
26
- $productSources = array(
27
- array('value' => 'related', 'label' => $helper->__('Related Products')),
28
- array('value' => 'upsell', 'label' => $helper->__('Up-sells')),
29
- array('value' => 'crosssell', 'label' => $helper->__('Cross-sells')),
30
- );
31
-
32
- $globalSources = array(
33
- array('value' => 'bestseller', 'label' => $helper->__('Bestsellers')),
34
- array('value' => 'mostviewed', 'label' => $helper->__('Most Viewed')),
35
- );
36
-
37
- $customerSources = array(
38
- array('value' => 'recentlyviewed', 'label' => $helper->__('Recently Viewed')),
39
- );
40
-
41
- $this->_options = array(
42
- array('label' => $helper->__('Product Specific Sources'), 'value' => $productSources),
43
- array('label' => $helper->__('Global Sources'), 'value' => $globalSources),
44
- array('label' => $helper->__('Customer Specific Sources'), 'value' => $customerSources),
45
- );
46
-
47
- if (!$isMultiselect) {
48
- array_unshift($this->_options, array('value' => '', 'label' => $helper->__('--Please Select--')));
49
- }
50
-
51
- return $this->_options;
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Role.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Source_Role
4
- {
5
-
6
- /**
7
- * @var array
8
- */
9
- protected $_options;
10
-
11
- /**
12
- * Supporting role key => value pairs
13
- *
14
- * @return array
15
- */
16
- public function toOptionArray()
17
- {
18
- if (!is_null($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;
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/SendOptions.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_Model_System_Config_Source_SendOptions
4
- {
5
- private $_options;
6
-
7
- private static $_optionToFlag = array(
8
- 3 => 'replyTracking',
9
- 2 => 'fatigueOverride',
10
- 1 => 'authentication',
11
- );
12
-
13
- /**
14
- * Retrieve option values from bit masked values
15
- *
16
- * @return array
17
- */
18
- public function toArray()
19
- {
20
- if (empty($this->_options)) {
21
- $helper = Mage::helper('bronto_common');
22
- $this->_options = array(
23
- 1 => $helper->__('Sender Authentication'),
24
- 2 => $helper->__('Fatigue Override'),
25
- 3 => $helper->__('Reply Tracking'),
26
- );
27
- $concatValues = array();
28
- $allValues = 0;
29
- $allLabels = '';
30
- foreach ($this->_options as $key => $label) {
31
- $allValues = $allValues === 0 ? $key : $allValues << $key;
32
- if ($label == end($this->_options)) {
33
- $concatValues[$allValues] = $helper->__($allLabels . 'and ' . $label);
34
- } else {
35
- foreach (range($key + 1, count($this->_options)) as $number) {
36
- $concatValues[$key << $number] = $helper->__(implode(' and ', array($this->_options[$key], $this->_options[$number])));
37
- }
38
- $allLabels .= $label . ', ';
39
- }
40
- }
41
- $this->_options += $concatValues;
42
- }
43
- return $this->_options;
44
- }
45
-
46
- /**
47
- * Retrieve config options for sending options
48
- *
49
- * @return array
50
- */
51
- public function toOptionArray($default = false)
52
- {
53
- $helper = Mage::helper('bronto_common');
54
- $options = array();
55
- foreach ($this->toArray() as $value => $label) {
56
- $options[] = array(
57
- 'value' => $value,
58
- 'label' => $label
59
- );
60
- }
61
-
62
- $firstOption = array(
63
- 'label' => $helper->__($default ? '-- Use Default -- ' : '-- None Selected --'),
64
- 'value' => 0
65
- );
66
- array_unshift($options, $firstOption);
67
- return $options;
68
- }
69
-
70
- /**
71
- * Sets the send flags based on masked value
72
- *
73
- * @param Bronto_Api_Delivery_Row $delivery
74
- * @param int $optionValue
75
- * @return boolean
76
- */
77
- public function setDeliveryFlags($delivery, $optionValue)
78
- {
79
- if (empty($optionValue)) {
80
- return false;
81
- }
82
-
83
- if (array_key_exists($optionValue, self::$_optionToFlag)) {
84
- $delivery->{self::$_optionToFlag[$optionValue]} = true;
85
- return true;
86
- }
87
-
88
- foreach (self::$_optionToFlag as $value => $flag) {
89
- $testValue = $optionValue >> $value;
90
- if ($testValue != 0 || $optionValue == $value) {
91
- $delivery->{$flag} = true;
92
- $optionValue = $testValue;
93
- }
94
- }
95
- return true;
96
- }
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/Model/System/Config/Source/Synclimit.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Common
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Common_Model_System_Config_Source_Synclimit
8
- {
9
- /**
10
- * @return array
11
- */
12
- public function toOptionArray()
13
- {
14
- return array(
15
- 100 => 100,
16
- 250 => 250,
17
- 500 => 500,
18
- 1000 => 1000,
19
- 5000 => 5000,
20
- );
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/controllers/Adminhtml/DebugController.php DELETED
@@ -1,111 +0,0 @@
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
-
20
- /**
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
42
- // PHP json_encode exists on the server, then use it
43
- if (function_exists('json_encode')) {
44
- $json = json_encode($debug);
45
- } else {
46
- $json = Mage::helper('core')->jsonEncode($debug);
47
- }
48
-
49
- $this
50
- ->getResponse()
51
- ->setHeader('Content-Type', 'application/json')
52
- ->setBody($json);
53
- }
54
-
55
- /**
56
- * Runs the API send queue
57
- */
58
- public function sendAction()
59
- {
60
- $helper = Mage::helper('bronto_common/api');
61
- $result = Mage::getModel('bronto_common/observer')->processSendForScope();
62
- $this->_getSession()->addSuccess(sprintf("Processed %d Deliveries (%d Error / %d Success)", $result['total'], $result['error'], $result['success']));
63
- $returnParams = array('section' => 'bronto_api');
64
- $returnParams = array_merge($returnParams, $helper->getScopeParams());
65
- $this->_redirect('*/system_config/edit', $returnParams);
66
- }
67
-
68
- /**
69
- * Sends an archive to the browser
70
- */
71
- public function archiveAction()
72
- {
73
- $zip = basename($this->_getHelper()->getLogArchive()->getFilename());
74
- $json = Mage::helper('core')->jsonEncode(array(
75
- 'name' => $zip,
76
- 'link' => $this->getUrl('*/*/download', array('file' => $zip)),
77
- ));
78
-
79
- $this
80
- ->getResponse()
81
- ->setHeader('Content-Type', 'application/json')
82
- ->setBody($json);
83
- }
84
-
85
- /**
86
- * Sends the zip to the browser
87
- */
88
- public function downloadAction()
89
- {
90
- $file = $this->getRequest()->getParam('file');
91
- $baseArchiveDir = $this->_getHelper()->getArchiveDirectory();
92
-
93
- if (!file_exists($baseArchiveDir . DS . $file)) {
94
- Mage::getSingleton('adminhtml/session')->addError("Archive '$file' does not exist.");
95
-
96
- return $this->_redirect('*/system_config/edit', array('section' => 'bronto'));
97
- } else {
98
- $this
99
- ->getResponse()
100
- ->setHeader('Content-Description', 'File Transfer')
101
- ->setHeader('Content-Type', 'application/zip')
102
- ->setHeader('Content-Disposition', 'attachment; filename="bronto_logs_' . time() . '.zip"')
103
- ->clearBody();
104
-
105
- $this->getResponse()->sendHeaders();
106
- ob_end_flush();
107
- readfile($baseArchiveDir . DS . $file);
108
- exit;
109
- }
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/controllers/Adminhtml/GuidersController.php DELETED
@@ -1,21 +0,0 @@
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/CouponController.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Common_CouponController extends Mage_Core_Controller_Front_Action
4
- {
5
- const URL_PARAM = 'redirect_path';
6
- const MOVE_PERMANENTLY = 301;
7
- const HEADER_REFERER = 'referer';
8
-
9
- /**
10
- * Gets the redirected store url
11
- *
12
- * @return string
13
- */
14
- protected function _parseUrl()
15
- {
16
- $helper = Mage::helper('bronto_common/coupon');
17
- $request = $this->getRequest();
18
- $url = ltrim($request->getParam(self::URL_PARAM), '/');
19
- $allParams = $request->getParams();
20
- foreach ($helper->getParams() as $strippable) {
21
- unset($allParams[$strippable]);
22
- }
23
- unset($allParams[self::URL_PARAM]);
24
- $store = Mage::app()->getStore();
25
- return $store->getUrl($url, $allParams);
26
- }
27
-
28
- /**
29
- * Gets the referer url
30
- *
31
- * @return string
32
- */
33
- protected function _parseReferer()
34
- {
35
- return $this->getRequest()->getHeader(self::HEADER_REFERER);
36
- }
37
-
38
- /**
39
- * Gets parseable params to applicable route methods
40
- *
41
- * @return array
42
- */
43
- protected function _routes()
44
- {
45
- return array(
46
- self::URL_PARAM => '_parseUrl',
47
- Bronto_Common_Helper_Coupon::FORCE_PARAM => '_parseReferer'
48
- );
49
- }
50
-
51
- /**
52
- * Handle routes accordingly
53
- */
54
- public function indexAction()
55
- {
56
- $request = $this->getRequest();
57
- $helper = Mage::helper('bronto_common/coupon');
58
- // If enabled, and observer didn't catch it
59
- if ($helper->isEnabled() && !$helper->isObservingController()) {
60
- $helper->applyCodeFromRequest($request);
61
- }
62
-
63
- foreach ($this->_routes() as $param => $method) {
64
- if ($request->has($param)) {
65
- return $this->getResponse()
66
- ->setRedirect($this->$method(), self::MOVE_PERMANENTLY)
67
- ->sendHeaders();
68
- }
69
- }
70
- $this->_redirect('/');
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/etc/adminhtml.xml DELETED
@@ -1,39 +0,0 @@
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 module="bronto_common">
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
- <bronto_coupon module="bronto_common">
20
- <title>Bronto Coupon Section</title>
21
- <sort_order>9996</sort_order>
22
- </bronto_coupon>
23
- <bronto_cartrecovery module="bronto_common">
24
- <title>Bronto Cart Recovery Section</title>
25
- <sort_order>9997</sort_order>
26
- </bronto_cartrecovery>
27
- <bronto_api module="bronto_common">
28
- <title>Bronto API Section</title>
29
- <sort_order>9995</sort_order>
30
- </bronto_api>
31
- </children>
32
- </config>
33
- </children>
34
- </system>
35
- </children>
36
- </admin>
37
- </resources>
38
- </acl>
39
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/etc/cache.xml DELETED
@@ -1,13 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <placeholders>
4
- <bronto_cart_recovery>
5
- <block>bronto_common/cart_recovery</block>
6
- <name>bronto.cartrecovery</name>
7
- <template>bronto/common/recovery.phtml</template>
8
- <placeholder>BRONTO_CART_RECOVERY</placeholder>
9
- <container>Bronto_Common_Model_Container_Cart_Recovery</container>
10
- <cache_lifetime>false</cache_lifetime>
11
- </bronto_cart_recovery>
12
- </placeholders>
13
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/etc/config.xml DELETED
@@ -1,244 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Bronto_Common>
5
- <version>2.4.4</version>
6
- </Bronto_Common>
7
- </modules>
8
- <global>
9
- <blocks>
10
- <bronto_common>
11
- <class>Bronto_Common_Block</class>
12
- </bronto_common>
13
- </blocks>
14
- <helpers>
15
- <bronto_common>
16
- <class>Bronto_Common_Helper</class>
17
- </bronto_common>
18
- </helpers>
19
- <models>
20
- <bronto_common>
21
- <class>Bronto_Common_Model</class>
22
- <resourceModel>bronto_common_mysql4</resourceModel>
23
- </bronto_common>
24
- <bronto_common_mysql4>
25
- <class>Bronto_Common_Model_Mysql4</class>
26
- <entities>
27
- <api>
28
- <table>bronto_common_api</table>
29
- </api>
30
- <error>
31
- <table>bronto_common_api_errors</table>
32
- </error>
33
- <queue>
34
- <table>bronto_common_api_send_queue</table>
35
- </queue>
36
- </entities>
37
- </bronto_common_mysql4>
38
- </models>
39
- <resources>
40
- <bronto_common_setup>
41
- <setup>
42
- <module>Bronto_Common</module>
43
- <class>Bronto_Common_Model_Resource_Setup</class>
44
- </setup>
45
- <connection>
46
- <use>core_setup</use>
47
- </connection>
48
- </bronto_common_setup>
49
- </resources>
50
- <events>
51
- <controller_action_predispatch>
52
- <observers>
53
- <bronto_coupon_session_set>
54
- <type>singleton</type>
55
- <class>bronto_common/coupon_observer</class>
56
- <method>addCodeToSession</method>
57
- </bronto_coupon_session_set>
58
- </observers>
59
- </controller_action_predispatch>
60
- <checkout_cart_product_add_after>
61
- <observers>
62
- <bronto_coupon_session_add_product>
63
- <type>singleton</type>
64
- <class>bronto_common/coupon_observer</class>
65
- <method>addCodeToQuote</method>
66
- </bronto_coupon_session_add_product>
67
- </observers>
68
- </checkout_cart_product_add_after>
69
- </events>
70
- </global>
71
- <frontend>
72
- <layout>
73
- <updates>
74
- <bronto_common>
75
- <file>bronto/common.xml</file>
76
- </bronto_common>
77
- </updates>
78
- </layout>
79
- <routers>
80
- <bronto_coupon>
81
- <use>standard</use>
82
- <args>
83
- <module>Bronto_Common</module>
84
- <frontName>apply</frontName>
85
- </args>
86
- </bronto_coupon>
87
- </routers>
88
- </frontend>
89
- <admin>
90
- <routers>
91
- <adminhtml>
92
- <args>
93
- <modules>
94
- <bronto_common before="Mage_Adminhtml">Bronto_Common_Adminhtml</bronto_common>
95
- </modules>
96
- </args>
97
- </adminhtml>
98
- </routers>
99
- </admin>
100
- <adminhtml>
101
- <layout>
102
- <updates>
103
- <bronto_common>
104
- <file>bronto/common.xml</file>
105
- </bronto_common>
106
- </updates>
107
- </layout>
108
- <events>
109
- <bronto_disable>
110
- <observers>
111
- <bronto_common_disable>
112
- <class>bronto_common/observer</class>
113
- <method>watchDisableAction</method>
114
- </bronto_common_disable>
115
- </observers>
116
- </bronto_disable>
117
- <controller_action_predispatch>
118
- <observers>
119
- <bronto_common_controller_action_predispatch>
120
- <class>bronto_common/observer</class>
121
- <method>checkBrontoRequirements</method>
122
- </bronto_common_controller_action_predispatch>
123
- </observers>
124
- </controller_action_predispatch>
125
- <controller_action_predispatch_adminhtml>
126
- <observers>
127
- <bronto_common_registration_form_submit>
128
- <class>bronto_common/observer</class>
129
- <method>registerExtension</method>
130
- </bronto_common_registration_form_submit>
131
- </observers>
132
- </controller_action_predispatch_adminhtml>
133
- </events>
134
- </adminhtml>
135
- <default>
136
- <bronto>
137
- <settings>
138
- <enabled>1</enabled>
139
- <debug>1</debug>
140
- <log_threshold>30</log_threshold>
141
- <clear_logs>1</clear_logs>
142
- <verbose>0</verbose>
143
- <test>0</test>
144
- <notices>0</notices>
145
- </settings>
146
- <format>
147
- <image_type>image</image_type>
148
- <default_greeting>Valued Customer</default_greeting>
149
- <default_greeting_prefix></default_greeting_prefix>
150
- <default_greeting_firstname></default_greeting_firstname>
151
- <default_greeting_lastname></default_greeting_lastname>
152
- </format>
153
- <support>
154
- <registered>0</registered>
155
- <using_solution_partner>1</using_solution_partner>
156
- </support>
157
- </bronto>
158
- <bronto_popup>
159
- <settings>
160
- <subscribe>0</subscribe>
161
- </settings>
162
- </bronto_popup>
163
- <bronto_coupon>
164
- <apply_coupon>
165
- <enabled>0</enabled>
166
- <use_observer>1</use_observer>
167
- <coupon_code_param>coupon</coupon_code_param>
168
- <error_message_param>invalid_coupon</error_message_param>
169
- <success_message><![CDATA[Coupon {code} was successfully applied to your shopping session.]]></success_message>
170
- <invalid><![CDATA[The Coupon {code} is invalid.]]></invalid>
171
- <depleted><![CDATA[The Coupon {code} has been depleted.]]></depleted>
172
- <expired><![CDATA[The Coupon {code} has expired.]]></expired>
173
- <conflict><![CDATA[Your shopping session already has coupon {oldCode} applied. {link} to apply {newCode} instead.]]></conflict>
174
- <link>Click here</link>
175
- </apply_coupon>
176
- </bronto_coupon>
177
- <bronto_api>
178
- <settings>
179
- <enabled>0</enabled>
180
- <mage_cron>1</mage_cron>
181
- <frequency>I</frequency>
182
- <interval>5</interval>
183
- <minutes>0</minutes>
184
- <limit>50</limit>
185
- <threshold>5</threshold>
186
- </settings>
187
- <queue_settings>
188
- <enabled>0</enabled>
189
- <mage_cron>1</mage_cron>
190
- <frequency>I</frequency>
191
- <interval>5</interval>
192
- <minutes>0</minutes>
193
- <limit>50</limit>
194
- </queue_settings>
195
- <soap_options>
196
- <soap_client>SoapClient</soap_client>
197
- <retryer>Bronto_Common_Model_Error</retryer>
198
- <stream_context>0</stream_context>
199
- <retry_limit>2</retry_limit>
200
- <trace>0</trace>
201
- <exceptions>1</exceptions>
202
- <connection_timeout>30</connection_timeout>
203
- <cache_wsdl>WSDL_CACHE_BOTH</cache_wsdl>
204
- </soap_options>
205
- </bronto_api>
206
- </default>
207
- <crontab>
208
- <jobs>
209
- <bronto_common_errors>
210
- <run>
211
- <model>bronto_common/observer::processApiErrors</model>
212
- </run>
213
- </bronto_common_errors>
214
- <bronto_common_queue>
215
- <run>
216
- <model>bronto_common/observer::processSendQueue</model>
217
- </run>
218
- </bronto_common_queue>
219
- <bronto_common_delete_archives>
220
- <schedule>
221
- <cron_expr>0 0 * * *</cron_expr>
222
- </schedule>
223
- <run>
224
- <model>bronto_common/observer::clearArchives</model>
225
- </run>
226
- </bronto_common_delete_archives>
227
- <bronto_common_delete_old_logs>
228
- <schedule>
229
- <cron_expr>0 0 * * *</cron_expr>
230
- </schedule>
231
- <run>
232
- <model>bronto_common/observer::clearOldLogs</model>
233
- </run>
234
- </bronto_common_delete_old_logs>
235
- </jobs>
236
- </crontab>
237
- <phpunit>
238
- <suite>
239
- <modules>
240
- <Bronto_Common/>
241
- </modules>
242
- </suite>
243
- </phpunit>
244
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/etc/system.xml DELETED
@@ -1,1124 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <tabs>
4
- <bronto module="bronto_common">
5
- <label><![CDATA[<div>Bronto</div>]]></label>
6
- <class>bronto-section</class>
7
- <sort_order>999</sort_order>
8
- </bronto>
9
- </tabs>
10
- <sections>
11
- <bronto_api module="bronto_common">
12
- <label>Advanced API</label>
13
- <tab>bronto</tab>
14
- <frontend_type>text</frontend_type>
15
- <sort_order>900</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
- <apitoken>
29
- <label>API Status</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
- <fields>
37
- <token_status>
38
- <label>Last API Token Status</label>
39
- <frontend_type>text</frontend_type>
40
- <frontend_model>bronto_verify/adminhtml_system_config_form_field_apitoken</frontend_model>
41
- <sort_order>10</sort_order>
42
- <show_in_default>1</show_in_default>
43
- <show_in_website>1</show_in_website>
44
- <show_in_store>1</show_in_store>
45
- </token_status>
46
- <roundtrip_status>
47
- <label>Last API Connection Status</label>
48
- <frontend_type>text</frontend_type>
49
- <frontend_model>bronto_verify/adminhtml_system_config_form_field_roundtrip</frontend_model>
50
- <sort_order>11</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
- </roundtrip_status>
55
- </fields>
56
- </apitoken>
57
- <queue_settings>
58
- <label>API Send Queue Settings</label>
59
- <frontend_type>text</frontend_type>
60
- <sort_order>2</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>1</show_in_website>
63
- <show_in_store>1</show_in_store>
64
- <expanded>1</expanded>
65
- <fields>
66
- <enabled>
67
- <label>Enabled</label>
68
- <frontend_type>select</frontend_type>
69
- <backend_model>bronto_common/system_config_backend_enable</backend_model>
70
- <source_model>adminhtml/system_config_source_yesno</source_model>
71
- <sort_order>0</sort_order>
72
- <show_in_default>1</show_in_default>
73
- <show_in_website>1</show_in_website>
74
- <show_in_store>1</show_in_store>
75
- <comment><![CDATA[With send queuing enabled,
76
- <em>all</em>
77
- transactional emails will be placed in a queue,
78
- and must be flushed. While this is a more performant
79
- method, real-time sending is essentially disabled.
80
- It is <em>highly</em>
81
- recommended to flush this queue using the system
82
- cron, or the lowest available interval Magento cron.]]></comment>
83
- </enabled>
84
- <mage_cron>
85
- <label>Use Magento Cron</label>
86
- <depends>
87
- <enabled>1</enabled>
88
- </depends>
89
- <frontend_type>select</frontend_type>
90
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
91
- <source_model>adminhtml/system_config_source_yesno</source_model>
92
- <backend_model>bronto_common/system_config_backend_cron_queue</backend_model>
93
- <sort_order>2</sort_order>
94
- <show_in_default>1</show_in_default>
95
- <show_in_website>1</show_in_website>
96
- <show_in_store>1</show_in_store>
97
- <comment>
98
- <![CDATA[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>
99
- </mage_cron>
100
- <frequency>
101
- <label>Frequency</label>
102
- <depends>
103
- <enabled>1</enabled>
104
- <mage_cron>1</mage_cron>
105
- </depends>
106
- <frontend_type>select</frontend_type>
107
- <source_model>bronto_common/system_config_source_cron_frequency</source_model>
108
- <backend_model>bronto_common/system_config_backend_cron_error</backend_model>
109
- <sort_order>3</sort_order>
110
- <show_in_default>1</show_in_default>
111
- <show_in_website>1</show_in_website>
112
- <show_in_store>1</show_in_store>
113
- </frequency>
114
- <interval>
115
- <label>Interval</label>
116
- <depends>
117
- <enabled>1</enabled>
118
- <frequency>I</frequency>
119
- <mage_cron>1</mage_cron>
120
- </depends>
121
- <frontend_type>select</frontend_type>
122
- <source_model>bronto_common/system_config_source_cron_minutes</source_model>
123
- <sort_order>4</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>Set this value larger than your cron.php launch period.</comment>
128
- </interval>
129
- <minutes>
130
- <label>Minute of the Hour</label>
131
- <depends>
132
- <frequency>H</frequency>
133
- <mage_cron>1</mage_cron>
134
- <enabled>1</enabled>
135
- </depends>
136
- <frontend_type>text</frontend_type>
137
- <sort_order>40</sort_order>
138
- <show_in_default>1</show_in_default>
139
- <show_in_website>1</show_in_website>
140
- <show_in_store>1</show_in_store>
141
- <comment>Valid range: 0-59 (default 0).</comment>
142
- </minutes>
143
- <time>
144
- <label>Start Time</label>
145
- <depends>
146
- <enabled>1</enabled>
147
- <mage_cron>1</mage_cron>
148
- </depends>
149
- <frontend_type>time</frontend_type>
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
- </time>
155
- <limit>
156
- <label>Limit</label>
157
- <depends>
158
- <enabled>1</enabled>
159
- </depends>
160
- <frontend_type>select</frontend_type>
161
- <source_model>bronto_common/system_config_source_limit</source_model>
162
- <sort_order>6</sort_order>
163
- <show_in_default>1</show_in_default>
164
- <show_in_website>1</show_in_website>
165
- <show_in_store>1</show_in_store>
166
- <comment>Total API deliveries to process every run.</comment>
167
- </limit>
168
- </fields>
169
- </queue_settings>
170
- <queue_cron_list>
171
- <frontend_type>text</frontend_type>
172
- <frontend_model>bronto_common/adminhtml_system_config_cron_queue</frontend_model>
173
- <sort_order>3</sort_order>
174
- <show_in_default>1</show_in_default>
175
- <show_in_website>0</show_in_website>
176
- <show_in_store>0</show_in_store>
177
- </queue_cron_list>
178
- <settings>
179
- <label>API Retry Settings</label>
180
- <frontend_type>text</frontend_type>
181
- <sort_order>4</sort_order>
182
- <show_in_default>1</show_in_default>
183
- <show_in_website>0</show_in_website>
184
- <show_in_store>0</show_in_store>
185
- <expanded>1</expanded>
186
- <fields>
187
- <enabled>
188
- <label>Enabled</label>
189
- <frontend_type>select</frontend_type>
190
- <backend_model>bronto_common/system_config_backend_enable</backend_model>
191
- <source_model>adminhtml/system_config_source_yesno</source_model>
192
- <sort_order>0</sort_order>
193
- <show_in_default>1</show_in_default>
194
- <show_in_website>0</show_in_website>
195
- <show_in_store>0</show_in_store>
196
- </enabled>
197
- <mage_cron>
198
- <label>Use Magento Cron</label>
199
- <depends>
200
- <enabled>1</enabled>
201
- </depends>
202
- <frontend_type>select</frontend_type>
203
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
204
- <source_model>adminhtml/system_config_source_yesno</source_model>
205
- <backend_model>bronto_common/system_config_backend_cron_error</backend_model>
206
- <sort_order>2</sort_order>
207
- <show_in_default>1</show_in_default>
208
- <show_in_website>0</show_in_website>
209
- <show_in_store>0</show_in_store>
210
- <comment>
211
- <![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>
212
- </mage_cron>
213
- <frequency>
214
- <label>Frequency</label>
215
- <depends>
216
- <enabled>1</enabled>
217
- <mage_cron>1</mage_cron>
218
- </depends>
219
- <frontend_type>select</frontend_type>
220
- <source_model>bronto_common/system_config_source_cron_frequency</source_model>
221
- <backend_model>bronto_common/system_config_backend_cron_error</backend_model>
222
- <sort_order>3</sort_order>
223
- <show_in_default>1</show_in_default>
224
- <show_in_website>0</show_in_website>
225
- <show_in_store>0</show_in_store>
226
- </frequency>
227
- <interval>
228
- <label>Interval</label>
229
- <depends>
230
- <enabled>1</enabled>
231
- <frequency>I</frequency>
232
- <mage_cron>1</mage_cron>
233
- </depends>
234
- <frontend_type>select</frontend_type>
235
- <source_model>bronto_common/system_config_source_cron_minutes</source_model>
236
- <sort_order>4</sort_order>
237
- <show_in_default>1</show_in_default>
238
- <show_in_website>0</show_in_website>
239
- <show_in_store>0</show_in_store>
240
- <comment>Set this value larger than your cron.php launch period.</comment>
241
- </interval>
242
- <minutes>
243
- <label>Minute of the Hour</label>
244
- <depends>
245
- <frequency>H</frequency>
246
- <mage_cron>1</mage_cron>
247
- <enabled>1</enabled>
248
- </depends>
249
- <frontend_type>text</frontend_type>
250
- <sort_order>40</sort_order>
251
- <show_in_default>1</show_in_default>
252
- <show_in_website>0</show_in_website>
253
- <show_in_store>0</show_in_store>
254
- <comment>Valid range: 0-59 (default 0).</comment>
255
- </minutes>
256
- <time>
257
- <label>Start Time</label>
258
- <depends>
259
- <enabled>1</enabled>
260
- <mage_cron>1</mage_cron>
261
- </depends>
262
- <frontend_type>time</frontend_type>
263
- <sort_order>5</sort_order>
264
- <show_in_default>1</show_in_default>
265
- <show_in_website>0</show_in_website>
266
- <show_in_store>0</show_in_store>
267
- </time>
268
- <limit>
269
- <label>Limit</label>
270
- <depends>
271
- <enabled>1</enabled>
272
- </depends>
273
- <frontend_type>select</frontend_type>
274
- <source_model>bronto_common/system_config_source_limit</source_model>
275
- <sort_order>6</sort_order>
276
- <show_in_default>1</show_in_default>
277
- <show_in_website>0</show_in_website>
278
- <show_in_store>0</show_in_store>
279
- <comment>Total API Errors to process every run.</comment>
280
- </limit>
281
- <threshold>
282
- <label>Attempt Threshold</label>
283
- <depends>
284
- <enabled>1</enabled>
285
- </depends>
286
- <frontend_type>text</frontend_type>
287
- <sort_order>7</sort_order>
288
- <show_in_default>1</show_in_default>
289
- <show_in_website>0</show_in_website>
290
- <show_in_store>0</show_in_store>
291
- <comment>Do not process entry whose attempts are
292
- over this amount.</comment>
293
- </threshold>
294
- </fields>
295
- </settings>
296
- <cron_list>
297
- <frontend_type>text</frontend_type>
298
- <frontend_model>bronto_common/adminhtml_system_config_cron_error</frontend_model>
299
- <sort_order>5</sort_order>
300
- <show_in_default>1</show_in_default>
301
- <show_in_website>0</show_in_website>
302
- <show_in_store>0</show_in_store>
303
- </cron_list>
304
- <soap_options>
305
- <label>SOAP Options</label>
306
- <frontend_type>text</frontend_type>
307
- <sort_order>6</sort_order>
308
- <show_in_default>1</show_in_default>
309
- <show_in_website>0</show_in_website>
310
- <show_in_store>0</show_in_store>
311
- <expanded>0</expanded>
312
- <fields>
313
- <soap_client>
314
- <label>SOAP class</label>
315
- <frontend_type>text</frontend_type>
316
- <sort_order>5</sort_order>
317
- <show_in_default>1</show_in_default>
318
- <show_in_website>0</show_in_website>
319
- <show_in_store>0</show_in_store>
320
- <comment><![CDATA[Overrides the Bronto_SoapClient class.<br/>
321
- Default: Bronto_SoapClient<br/>
322
- <em>* Provided class name must be available via
323
- Magento's autoloader.</em>]]></comment>
324
- </soap_client>
325
- <retryer>
326
- <label>Bronto Retryer</label>
327
- <frontend_type>text</frontend_type>
328
- <sort_order>7</sort_order>
329
- <show_in_default>1</show_in_default>
330
- <show_in_website>0</show_in_website>
331
- <show_in_store>0</show_in_store>
332
- <comment><![CDATA[Overrides the Bronto_Util_Retryer
333
- class.<br/>
334
- Default: Bronto_Common_Model_Error<br/>
335
- <em>* Provided class name must be available via
336
- Magento's autoloader.</em>]]></comment>
337
- </retryer>
338
- <stream_context>
339
- <label>Use Stream Context</label>
340
- <frontend_type>select</frontend_type>
341
- <source_model>adminhtml/system_config_source_yesno</source_model>
342
- <sort_order>8</sort_order>
343
- <show_in_default>1</show_in_default>
344
- <show_in_website>0</show_in_website>
345
- <show_in_store>0</show_in_store>
346
- <comment><![CDATA[Replace the SSL stream context for the
347
- underlying SOAP client.<br/><em>* Use this option if you
348
- are experiencing errors related to SSL or reaching
349
- the Bronto API WSDL.</em>]]></comment>
350
- </stream_context>
351
- <retry_limit>
352
- <label>Retry Limit</label>
353
- <frontend_type>text</frontend_type>
354
- <sort_order>10</sort_order>
355
- <show_in_default>1</show_in_default>
356
- <show_in_website>0</show_in_website>
357
- <show_in_store>0</show_in_store>
358
- <validate>validate-digits validate-digits-range digits-range-0-5</validate>
359
- <comment><![CDATA[The number of times the SOAP client will attempt to retry API call. Must be between 0 and 5.<br />Default: 2]]>
360
- </comment>
361
- </retry_limit>
362
- <connection_timeout>
363
- <label>Connection Timeout</label>
364
- <frontend_type>text</frontend_type>
365
- <sort_order>20</sort_order>
366
- <show_in_default>1</show_in_default>
367
- <show_in_website>0</show_in_website>
368
- <show_in_store>0</show_in_store>
369
- <validate>validate-digits validate-digits-range digits-range-0-3600</validate>
370
- <comment><![CDATA[The number of seconds the SOAP client will wait before attempting to retry the API call. Must be between 0 and 3600.<br />
371
- Default: 30]]>
372
- </comment>
373
- </connection_timeout>
374
- <trace>
375
- <label>Trace</label>
376
- <frontend_type>select</frontend_type>
377
- <source_model>adminhtml/system_config_source_yesno</source_model>
378
- <sort_order>30</sort_order>
379
- <show_in_default>1</show_in_default>
380
- <show_in_website>0</show_in_website>
381
- <show_in_store>0</show_in_store>
382
- <comment><![CDATA[If <em>Yes</em>, the SOAP client will trace its call.<br />Default: <em>No</em>]]></comment>
383
- </trace>
384
- <exceptions>
385
- <label>Exceptions</label>
386
- <frontend_type>select</frontend_type>
387
- <source_model>adminhtml/system_config_source_yesno</source_model>
388
- <sort_order>40</sort_order>
389
- <show_in_default>1</show_in_default>
390
- <show_in_website>0</show_in_website>
391
- <show_in_store>0</show_in_store>
392
- <comment><![CDATA[If <em>Yes</em>, the SOAP client will throw exceptions on failure.<br />Default: <em>Yes</em>]]></comment>
393
- </exceptions>
394
- <cache_wsdl>
395
- <label>WSDL Cache</label>
396
- <frontend_type>select</frontend_type>
397
- <source_model>bronto_verify/system_config_source_wsdlcache</source_model>
398
- <sort_order>50</sort_order>
399
- <show_in_default>1</show_in_default>
400
- <show_in_website>0</show_in_website>
401
- <show_in_store>0</show_in_store>
402
- <comment><![CDATA[If <em>Yes</em>, the SOAP client will cache the WSDL.<br />Default: <em>WSDL_CACHE_BOTH</em>]]></comment>
403
- </cache_wsdl>
404
- </fields>
405
- </soap_options>
406
- </groups>
407
- </bronto_api>
408
- <bronto_coupon module="bronto_common">
409
- <label>Coupon Management</label>
410
- <tab>bronto</tab>
411
- <frontend_type>text</frontend_type>
412
- <sort_order>898</sort_order>
413
- <show_in_default>1</show_in_default>
414
- <show_in_website>1</show_in_website>
415
- <show_in_store>1</show_in_store>
416
- <groups>
417
- <about>
418
- <frontend_type>text</frontend_type>
419
- <frontend_model>bronto_common/adminhtml_system_config_about</frontend_model>
420
- <sort_order>0</sort_order>
421
- <show_in_default>1</show_in_default>
422
- <show_in_website>1</show_in_website>
423
- <show_in_store>1</show_in_store>
424
- </about>
425
- <settings>
426
- <label>Coupon Manager Integration</label>
427
- <frontend_type>text</frontend_type>
428
- <sort_order>5</sort_order>
429
- <show_in_default>1</show_in_default>
430
- <show_in_website>1</show_in_website>
431
- <show_in_store>1</show_in_store>
432
- <expanded>1</expanded>
433
- <comment><![CDATA[With the Bronto Coupon Manager, you can easily edit, manage and distribute unique coupon codes via email marketing or SMS messaging for highly targeted, revenue-generating campaigns. Adding your account ID will enable the automatic redemption of coupons in Coupon Manager to report on valuable metrics such as: redemption rate, average redemption time, and revenue/discount per coupon. To learn more, please visit the <a target="_blank"
434
- href="https://appcenter.bronto.com/apps/coupon-manager">Bronto AppCenter</a> and contact your account manager.
435
- <br /><br/>]]></comment>
436
- <fields>
437
- <site_hash>
438
- <label>Account ID</label>
439
- <frontend_type>text</frontend_type>
440
- <comment>Found in the settings dialog of the Coupon Manager.</comment>
441
- <sort_order>80</sort_order>
442
- <show_in_default>1</show_in_default>
443
- <show_in_website>1</show_in_website>
444
- <show_in_store>1</show_in_store>
445
- </site_hash>
446
- </fields>
447
- </settings>
448
- <apply_coupon>
449
- <label>Auto-Apply Coupons</label>
450
- <frontend_type>text</frontend_type>
451
- <frontend_model>bronto_common/adminhtml_system_config_form_coupon</frontend_model>
452
- <sort_order>10</sort_order>
453
- <show_in_default>1</show_in_default>
454
- <show_in_website>1</show_in_website>
455
- <show_in_store>1</show_in_store>
456
- <expanded>1</expanded>
457
- <comment><![CDATA[When enabled, coupon codes can be applied
458
- to a customer's shopping session with one of two methods. There is
459
- a controller that listens to the store front route
460
- <strong>/apply/coupon/</strong>. You can pass the coupon
461
- code in the designated <em>Coupon Code Query
462
- Parameter</em>, and a redirect URL. For example:
463
- the URL <strong>{baseUrl}apply/coupon/?{code}={example}&redirect_path=%2Fcheckout%2Fcart</strong>
464
- will apply coupon <strong>{example}</strong> to the customer's
465
- shopping session, and redirect them to
466
- <strong>{baseUrl}checkout/cart/</strong>. The second method applies a
467
- coupon code by using an observer with <em>Use Event Observer</em> that
468
- will scan any store front URL for the
469
- <em>Coupon Code Query Parameter</em>. This method is optional, as
470
- it can be disabled. If the module is disabled, the controller will
471
- still perform redirects, but it will no longer apply coupons.<br/><br/>]]></comment>
472
- <fields>
473
- <enabled>
474
- <label>Enabled</label>
475
- <frontend_type>select</frontend_type>
476
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
477
- <backend_model>bronto_common/system_config_backend_enable</backend_model>
478
- <source_model>adminhtml/system_config_source_yesno</source_model>
479
- <sort_order>0</sort_order>
480
- <show_in_default>1</show_in_default>
481
- <show_in_website>1</show_in_website>
482
- <show_in_store>1</show_in_store>
483
- </enabled>
484
- <use_observer>
485
- <label>Use Event Observer</label>
486
- <depends><enabled>1</enabled></depends>
487
- <frontend_type>select</frontend_type>
488
- <source_model>adminhtml/system_config_source_yesno</source_model>
489
- <sort_order>5</sort_order>
490
- <show_in_default>1</show_in_default>
491
- <show_in_website>1</show_in_website>
492
- <show_in_store>1</show_in_store>
493
- </use_observer>
494
- <coupon_code_param>
495
- <label>Coupon Code Query Parameter</label>
496
- <depends><enabled>1</enabled></depends>
497
- <frontend_type>text</frontend_type>
498
- <sort_order>10</sort_order>
499
- <show_in_default>1</show_in_default>
500
- <show_in_website>1</show_in_website>
501
- <show_in_store>1</show_in_store>
502
- <comment>The value associated with this key will be
503
- the coupon code to be appiled to the shopping
504
- cart.
505
- </comment>
506
- </coupon_code_param>
507
- <error_message_param>
508
- <label>Invalid Coupon Query Parameter</label>
509
- <depends><enabled>1</enabled></depends>
510
- <frontend_type>text</frontend_type>
511
- <sort_order>20</sort_order>
512
- <show_in_default>1</show_in_default>
513
- <show_in_website>1</show_in_website>
514
- <show_in_store>1</show_in_store>
515
- <comment><![CDATA[The value associated with this key
516
- will cause the corresponding message to be
517
- displayed.<br/>Valid values are:<br/>
518
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>invalid</strong>: The Invalid Message
519
- will be used.<br/>
520
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>depleted</strong>: The Depleted Message
521
- will be used.<br/>
522
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>expired</strong>: The Expired Message
523
- will be used.]]></comment>
524
- </error_message_param>
525
- <success_message>
526
- <label>Success Message</label>
527
- <depends><enabled>1</enabled></depends>
528
- <frontend_type>textarea</frontend_type>
529
- <sort_order>30</sort_order>
530
- <show_in_default>1</show_in_default>
531
- <show_in_website>1</show_in_website>
532
- <show_in_store>1</show_in_store>
533
- <comment><![CDATA[Displayed when the coupon code in the URL was
534
- successfully applied to the session. The coupon code can be
535
- replaced in the message dynamically by using the
536
- <em>{code}</em> tag.]]></comment>
537
- </success_message>
538
- <invalid>
539
- <label>Invalid Message</label>
540
- <depends><enabled>1</enabled></depends>
541
- <frontend_type>textarea</frontend_type>
542
- <sort_order>40</sort_order>
543
- <show_in_default>1</show_in_default>
544
- <show_in_website>1</show_in_website>
545
- <show_in_store>1</show_in_store>
546
- <comment><![CDATA[Displayed when the coupon code is
547
- not applicable to the customer, does not exist, or
548
- if the <strong>invalid</strong> value is
549
- used. The coupon code can be replaced in the message
550
- dynamically by using the <em>{code}</em> tag.]]></comment>
551
- </invalid>
552
- <depleted>
553
- <label>Depleted Message</label>
554
- <depends><enabled>1</enabled></depends>
555
- <frontend_type>textarea</frontend_type>
556
- <sort_order>45</sort_order>
557
- <show_in_default>1</show_in_default>
558
- <show_in_website>1</show_in_website>
559
- <show_in_store>1</show_in_store>
560
- <comment><![CDATA[Displayed when there are no
561
- more uses for this coupon code or if the
562
- <strong>depleted</strong> value is used. The
563
- coupon code can be replaced in the message by using the
564
- <em>{code}</em> tag.]]></comment>
565
- </depleted>
566
- <expired>
567
- <label>Expired Message</label>
568
- <depends><enabled>1</enabled></depends>
569
- <frontend_type>textarea</frontend_type>
570
- <sort_order>50</sort_order>
571
- <show_in_default>1</show_in_default>
572
- <show_in_website>1</show_in_website>
573
- <show_in_store>1</show_in_store>
574
- <comment><![CDATA[Displayed when the coupon code has
575
- expired or if the <strong>expired</strong>
576
- value is used. The coupon code can be replaced in the
577
- message by using the <em>{code}</em>
578
- tag.]]></comment>
579
- </expired>
580
- <conflict>
581
- <label>Conflict Message</label>
582
- <depends><enabled>1</enabled></depends>
583
- <frontend_type>textarea</frontend_type>
584
- <sort_order>55</sort_order>
585
- <show_in_default>1</show_in_default>
586
- <show_in_website>1</show_in_website>
587
- <show_in_store>1</show_in_store>
588
- <comment><![CDATA[Displayed when a coupon code is
589
- currently applied in the session and it does not
590
- match the coupon code to be applied. There are
591
- three tags that can be replaced in the message
592
- dynamically:
593
- <br/>
594
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>{oldCode}</strong>: Coupon
595
- currently in the session.
596
- <br/>
597
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>{newCode}</strong>: Coupon to
598
- be applied to the session.
599
- <br/>
600
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>{link}</strong>: The link to apply the new coupon code.]]></comment>
601
- </conflict>
602
- <link>
603
- <label>Link Text</label>
604
- <depends><enabled>1</enabled></depends>
605
- <frontend_type>text</frontend_type>
606
- <sort_order>60</sort_order>
607
- <show_in_default>1</show_in_default>
608
- <show_in_website>1</show_in_website>
609
- <show_in_store>1</show_in_store>
610
- <comment><![CDATA[The link to apply the new coupon
611
- code instead, which can only be used by the
612
- <em>Conflict Message</em>. Two tags are
613
- available for dynamic replacement:<br/>
614
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>{oldCode}</strong>: Coupon currently in
615
- the session.<br/>
616
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>{newCode}</strong>: Coupon to be applied to the session.]]></comment>
617
- </link>
618
- </fields>
619
- </apply_coupon>
620
- </groups>
621
- </bronto_coupon>
622
- <bronto_cartrecovery module="bronto_common">
623
- <label>Cart Recovery Integration</label>
624
- <tab>bronto</tab>
625
- <frontend_type>text</frontend_type>
626
- <sort_order>900</sort_order>
627
- <show_in_default>1</show_in_default>
628
- <show_in_website>1</show_in_website>
629
- <show_in_store>1</show_in_store>
630
- <groups>
631
- <about>
632
- <frontend_type>text</frontend_type>
633
- <frontend_model>bronto_common/adminhtml_system_config_about</frontend_model>
634
- <sort_order>0</sort_order>
635
- <show_in_default>1</show_in_default>
636
- <show_in_website>1</show_in_website>
637
- <show_in_store>1</show_in_store>
638
- </about>
639
- <settings>
640
- <label>Settings</label>
641
- <frontend_type>text</frontend_type>
642
- <sort_order>1</sort_order>
643
- <show_in_default>1</show_in_default>
644
- <show_in_website>1</show_in_website>
645
- <show_in_store>1</show_in_store>
646
- <expanded>1</expanded>
647
- <comment><![CDATA[With Cart Recovery, you can recover more
648
- revenue
649
- by sending reminders to customers that have abandoned their
650
- shopping cart. To learn more, visit the <a
651
- target="_blank" href="https://appcenter.bronto.com/apps/cart-recovery">Bronto
652
- App Center</a> and contact your account manager.<br>
653
- <strong>Disclaimer</strong>: When using Cart Recovery,
654
- you will want to disable the Reminder Emails and Order
655
- Import modules of this extension. Please contact Support
656
- if you have any questions.<br>]]></comment>
657
- <fields>
658
- <code>
659
- <label>Cart Recovery Script</label>
660
- <frontend_type>textarea</frontend_type>
661
- <sort_order>0</sort_order>
662
- <show_in_default>1</show_in_default>
663
- <show_in_website>1</show_in_website>
664
- <show_in_store>1</show_in_store>
665
- </code>
666
- <other>
667
- <label>Other Product Attribute</label>
668
- <frontend_type>select</frontend_type>
669
- <source_model>bronto_common/system_config_source_attributes</source_model>
670
- <sort_order>5</sort_order>
671
- <show_in_default>1</show_in_default>
672
- <show_in_website>1</show_in_website>
673
- <show_in_store>1</show_in_store>
674
- <comment><![CDATA[Select the product attribute that will
675
- represent the <em>lineItemProductOther</em> field for line
676
- items.]]></comment>
677
- </other>
678
- </fields>
679
- </settings>
680
- </groups>
681
- </bronto_cartrecovery>
682
- <bronto_popup module="bronto_common">
683
- <label>Pop-up Manager Integration</label>
684
- <tab>bronto</tab>
685
- <frontend_type>text</frontend_type>
686
- <sort_order>899</sort_order>
687
- <show_in_default>1</show_in_default>
688
- <show_in_website>1</show_in_website>
689
- <show_in_store>1</show_in_store>
690
- <groups>
691
- <about>
692
- <frontend_type>text</frontend_type>
693
- <frontend_model>bronto_common/adminhtml_system_config_about</frontend_model>
694
- <sort_order>0</sort_order>
695
- <show_in_default>1</show_in_default>
696
- <show_in_website>1</show_in_website>
697
- <show_in_store>1</show_in_store>
698
- </about>
699
- <settings>
700
- <label>Settings</label>
701
- <frontend_type>text</frontend_type>
702
- <sort_order>1</sort_order>
703
- <show_in_default>1</show_in_default>
704
- <show_in_website>1</show_in_website>
705
- <show_in_store>1</show_in_store>
706
- <expanded>1</expanded>
707
- <comment><![CDATA[With Pop-Up Manager, you can create, test and manage pop-up sign-ups with minimal involvement from Bronto or your developer, and watch your email marketing list skyrocket! To learn more, visit the
708
- <a target="_blank"
709
- href="https://appcenter.bronto.com/apps/pop-up-manager">Bronto AppCenter</a> and contact your account manager.
710
- <br /><br/>]]></comment>
711
- <fields>
712
- <code>
713
- <label>Pop-up Manager Script</label>
714
- <frontend_type>textarea</frontend_type>
715
- <sort_order>0</sort_order>
716
- <show_in_default>1</show_in_default>
717
- <show_in_website>1</show_in_website>
718
- <show_in_store>1</show_in_store>
719
- </code>
720
- <subscribe>
721
- <label>Subscribe to Magento</label>
722
- <frontend_type>select</frontend_type>
723
- <source_model>adminhtml/system_config_source_yesno</source_model>
724
- <comment><![CDATA[If <em>Yes</em>, the customer subscribing to the Pop-Up will be subscribed to the Magento newsletter for the store view.]]></comment>
725
- <sort_order>1</sort_order>
726
- <show_in_default>1</show_in_default>
727
- <show_in_website>1</show_in_website>
728
- <show_in_store>1</show_in_store>
729
- </subscribe>
730
- </fields>
731
- </settings>
732
- </groups>
733
- </bronto_popup>
734
- <bronto module="bronto_common">
735
- <label>General</label>
736
- <tab>bronto</tab>
737
- <frontend_type>text</frontend_type>
738
- <frontend_model>bronto_common/adminhtml_system_config_form</frontend_model>
739
- <sort_order>100</sort_order>
740
- <show_in_default>1</show_in_default>
741
- <show_in_website>1</show_in_website>
742
- <show_in_store>1</show_in_store>
743
- <groups>
744
- <about>
745
- <frontend_type>text</frontend_type>
746
- <frontend_model>bronto_common/adminhtml_system_config_about</frontend_model>
747
- <sort_order>0</sort_order>
748
- <show_in_default>1</show_in_default>
749
- <show_in_website>1</show_in_website>
750
- <show_in_store>1</show_in_store>
751
- </about>
752
- <settings>
753
- <label>Settings</label>
754
- <frontend_type>text</frontend_type>
755
- <sort_order>1</sort_order>
756
- <show_in_default>1</show_in_default>
757
- <show_in_website>1</show_in_website>
758
- <show_in_store>1</show_in_store>
759
- <expanded>1</expanded>
760
- <fields>
761
- <enabled>
762
- <label>Enable Module</label>
763
- <frontend_type>select</frontend_type>
764
- <backend_model>bronto_common/system_config_backend_enable</backend_model>
765
- <source_model>adminhtml/system_config_source_yesno</source_model>
766
- <sort_order>0</sort_order>
767
- <show_in_default>1</show_in_default>
768
- <show_in_website>1</show_in_website>
769
- <show_in_store>1</show_in_store>
770
- <comment><![CDATA[Changing to <em>No</em> will disable all modules
771
- for this scope.]]></comment>
772
- </enabled>
773
- <api_token>
774
- <label>API Token</label>
775
- <depends>
776
- <enabled>1</enabled>
777
- </depends>
778
- <frontend_type>text</frontend_type>
779
- <frontend_model>bronto_common/adminhtml_system_config_form_field_apitoken</frontend_model>
780
- <backend_model>bronto_common/system_config_backend_token</backend_model>
781
- <sort_order>10</sort_order>
782
- <show_in_default>1</show_in_default>
783
- <show_in_website>1</show_in_website>
784
- <show_in_store>1</show_in_store>
785
- <validate>validate-length minimum-length-36</validate>
786
- <comment>
787
- <![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>
788
- </api_token>
789
- <debug>
790
- <label>Debug</label>
791
- <depends>
792
- <enabled>1</enabled>
793
- </depends>
794
- <frontend_type>select</frontend_type>
795
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
796
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
797
- <sort_order>20</sort_order>
798
- <show_in_default>1</show_in_default>
799
- <show_in_website>1</show_in_website>
800
- <show_in_store>1</show_in_store>
801
- <comment>
802
- <![CDATA[Allow the Bronto extension to write logs in <code>var/log</code>.]]></comment>
803
- </debug>
804
- <verbose>
805
- <label>Verbose Log Output</label>
806
- <depends>
807
- <debug>1</debug>
808
- </depends>
809
- <depends>
810
- <enabled>1</enabled>
811
- </depends>
812
- <frontend_type>select</frontend_type>
813
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
814
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
815
- <sort_order>25</sort_order>
816
- <show_in_default>1</show_in_default>
817
- <show_in_website>1</show_in_website>
818
- <show_in_store>1</show_in_store>
819
- <comment><![CDATA[If enabled, debug logs will also contain each API call.]]></comment>
820
- </verbose>
821
- <notices>
822
- <label>Error Notices</label>
823
- <depends>
824
- <enabled>1</enabled>
825
- </depends>
826
- <frontend_type>select</frontend_type>
827
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
828
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
829
- <sort_order>40</sort_order>
830
- <show_in_default>1</show_in_default>
831
- <show_in_website>1</show_in_website>
832
- <show_in_store>1</show_in_store>
833
- <comment>
834
- <![CDATA[Show warnings/errors as site notices.<br /><strong>Note:</strong> Site notices can be customer-facing.]]></comment>
835
- </notices>
836
- <clear_logs>
837
- <label>Enable Log Cleanup</label>
838
- <depends>
839
- <debug>1</debug>
840
- <enabled>1</enabled>
841
- </depends>
842
- <frontend_type>select</frontend_type>
843
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
844
- <source_model>adminhtml/system_config_source_yesno</source_model>
845
- <sort_order>50</sort_order>
846
- <show_in_default>1</show_in_default>
847
- <show_in_website>0</show_in_website>
848
- <show_in_store>0</show_in_store>
849
- <comment>At midnight, logs older than the Log
850
- Cleanup Threshold will be removed.</comment>
851
- </clear_logs>
852
- <log_threshold>
853
- <label>Log Cleanup Threshold</label>
854
- <depends>
855
- <debug>1</debug>
856
- <clear_logs>1</clear_logs>
857
- <enabled>1</enabled>
858
- </depends>
859
- <frontend_type>text</frontend_type>
860
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
861
- <sort_order>60</sort_order>
862
- <show_in_default>1</show_in_default>
863
- <show_in_website>0</show_in_website>
864
- <show_in_store>0</show_in_store>
865
- <comment><![CDATA[Number of days to keep logs.<br/>Default: 30]]></comment>
866
- </log_threshold>
867
- </fields>
868
- </settings>
869
- <support>
870
- <label>Registration</label>
871
- <frontend_type>text</frontend_type>
872
- <frontend_model>bronto_common/adminhtml_system_config_support</frontend_model>
873
- <sort_order>5</sort_order>
874
- <show_in_default>1</show_in_default>
875
- <show_in_website>1</show_in_website>
876
- <show_in_store>1</show_in_store>
877
- <fields>
878
- <site_name>
879
- <label>Bronto Site Name</label>
880
- <frontend_type>text</frontend_type>
881
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support_site
882
- </frontend_model>
883
- <sort_order>1</sort_order>
884
- <show_in_default>1</show_in_default>
885
- <show_in_website>1</show_in_website>
886
- <show_in_store>1</show_in_store>
887
- </site_name>
888
- <firstname>
889
- <label>First Name</label>
890
- <frontend_type>text</frontend_type>
891
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
892
- <validate>validate-length</validate>
893
- <sort_order>1</sort_order>
894
- <show_in_default>1</show_in_default>
895
- <show_in_website>1</show_in_website>
896
- <show_in_store>1</show_in_store>
897
- </firstname>
898
- <lastname>
899
- <label>Last Name</label>
900
- <frontend_type>text</frontend_type>
901
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
902
- <validate>validate-length</validate>
903
- <sort_order>2</sort_order>
904
- <show_in_default>1</show_in_default>
905
- <show_in_website>1</show_in_website>
906
- <show_in_store>1</show_in_store>
907
- </lastname>
908
- <title>
909
- <label>Title</label>
910
- <frontend_type>text</frontend_type>
911
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
912
- <validate>validate-length</validate>
913
- <sort_order>3</sort_order>
914
- <show_in_default>1</show_in_default>
915
- <show_in_website>1</show_in_website>
916
- <show_in_store>1</show_in_store>
917
- </title>
918
- <email>
919
- <label>Email</label>
920
- <frontend_type>text</frontend_type>
921
- <backend_model>adminhtml/system_config_backend_email_address</backend_model>
922
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
923
- <validate>validate-email</validate>
924
- <sort_order>5</sort_order>
925
- <show_in_default>1</show_in_default>
926
- <show_in_website>1</show_in_website>
927
- <show_in_store>1</show_in_store>
928
- </email>
929
- <number>
930
- <label>Phone Number</label>
931
- <frontend_type>text</frontend_type>
932
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
933
- <validate>validate-phone</validate>
934
- <sort_order>6</sort_order>
935
- <show_in_default>1</show_in_default>
936
- <show_in_website>1</show_in_website>
937
- <show_in_store>1</show_in_store>
938
- </number>
939
- <using_solution_partner>
940
- <label>Working with a Magento Solution Partner or Systems Integrator?</label>
941
- <frontend_type>select</frontend_type>
942
- <source_model>adminhtml/system_config_source_yesno</source_model>
943
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
944
- <sort_order>7</sort_order>
945
- <default_value>1</default_value>
946
- <show_in_default>1</show_in_default>
947
- <show_in_website>1</show_in_website>
948
- <show_in_store>1</show_in_store>
949
- </using_solution_partner>
950
- <partner>
951
- <depends>
952
- <using_solution_partner>1</using_solution_partner>
953
- </depends>
954
- <label>Name of Solution Partner or SI</label>
955
- <frontend_type>text</frontend_type>
956
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
957
- <sort_order>8</sort_order>
958
- <show_in_default>1</show_in_default>
959
- <show_in_website>1</show_in_website>
960
- <show_in_store>1</show_in_store>
961
- </partner>
962
- <terms>
963
- <label><![CDATA[Agree to Terms of Service?]]></label>
964
- <source_model>adminhtml/system_config_source_yesno</source_model>
965
- <frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
966
- <frontend_type>select</frontend_type>
967
- <sort_order>9</sort_order>
968
- <show_in_default>1</show_in_default>
969
- <show_in_website>1</show_in_website>
970
- <show_in_store>1</show_in_store>
971
- <comment>
972
- <![CDATA[If <em>Yes</em>, you certify the contacts you will be importing as active subscribers via the Newsletter Opt-In Module of this extension have been collected in compliance with the <a href="http://hosting-source.bm23.com/30245/public/Bronto_PMPolicy.html" target="_blank">Bronto Permission Marketing Policy</a>; specifically, the contacts have provided explicit and deliberate permission to receive email from you and have been emailed within the last 24 months. For more information, please contact Bronto Support.]]>
973
- </comment>
974
- </terms>
975
- </fields>
976
- </support>
977
- <format>
978
- <label>Email Formatting Options</label>
979
- <frontend_type>text</frontend_type>
980
- <frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
981
- <sort_order>10</sort_order>
982
- <show_in_default>1</show_in_default>
983
- <show_in_website>1</show_in_website>
984
- <show_in_store>1</show_in_store>
985
- <comment>
986
- <![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>
987
- <fields>
988
- <image_type>
989
- <label>Image Type</label>
990
- <frontend_type>select</frontend_type>
991
- <frontend_model>bronto_common/adminhtml_system_config_form_field_image</frontend_model>
992
- <source_model>bronto_common/system_config_source_image</source_model>
993
- <sort_order>1</sort_order>
994
- <show_in_default>1</show_in_default>
995
- <show_in_website>1</show_in_website>
996
- <show_in_store>1</show_in_store>
997
- <comment>The product image to use.</comment>
998
- </image_type>
999
- <image_width>
1000
- <label>Image Width</label>
1001
- <frontend_type>text</frontend_type>
1002
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1003
- <sort_order>10</sort_order>
1004
- <show_in_default>1</show_in_default>
1005
- <show_in_website>1</show_in_website>
1006
- <show_in_store>1</show_in_store>
1007
- <comment>Product image width in pixels.</comment>
1008
- </image_width>
1009
- <image_height>
1010
- <label>Image Height</label>
1011
- <frontend_type>text</frontend_type>
1012
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1013
- <sort_order>20</sort_order>
1014
- <show_in_default>1</show_in_default>
1015
- <show_in_website>1</show_in_website>
1016
- <show_in_store>1</show_in_store>
1017
- <comment>Product image height in pixels.</comment>
1018
- </image_height>
1019
- <default_greeting>
1020
- <label>Default Greeting</label>
1021
- <frontend_type>text</frontend_type>
1022
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1023
- <sort_order>40</sort_order>
1024
- <show_in_default>1</show_in_default>
1025
- <show_in_website>1</show_in_website>
1026
- <show_in_store>1</show_in_store>
1027
- <comment>
1028
- <![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>
1029
- </default_greeting>
1030
- <default_greeting_prefix>
1031
- <label>Default Greeting Prefix</label>
1032
- <frontend_type>text</frontend_type>
1033
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1034
- <sort_order>41</sort_order>
1035
- <show_in_default>1</show_in_default>
1036
- <show_in_website>1</show_in_website>
1037
- <show_in_store>1</show_in_store>
1038
- <comment>
1039
- <![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>
1040
- </default_greeting_prefix>
1041
- <default_greeting_firstname>
1042
- <label>Default Greeting First Name</label>
1043
- <frontend_type>text</frontend_type>
1044
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1045
- <sort_order>42</sort_order>
1046
- <show_in_default>1</show_in_default>
1047
- <show_in_website>1</show_in_website>
1048
- <show_in_store>1</show_in_store>
1049
- <comment>
1050
- <![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>
1051
- </default_greeting_firstname>
1052
- <default_greeting_lastname>
1053
- <label>Default Greeting Last Name</label>
1054
- <frontend_type>text</frontend_type>
1055
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1056
- <sort_order>43</sort_order>
1057
- <show_in_default>1</show_in_default>
1058
- <show_in_website>1</show_in_website>
1059
- <show_in_store>1</show_in_store>
1060
- <comment>
1061
- <![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>
1062
- </default_greeting_lastname>
1063
- <use_symbol>
1064
- <label>Include Currency Symbol</label>
1065
- <frontend_type>select</frontend_type>
1066
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1067
- <source_model>adminhtml/system_config_source_yesno</source_model>
1068
- <sort_order>44</sort_order>
1069
- <show_in_default>1</show_in_default>
1070
- <show_in_website>1</show_in_website>
1071
- <show_in_store>1</show_in_store>
1072
- <comment>
1073
- <![CDATA[Pass Default Display Currency symbol into email (located in "General" > "Currency Setup" > "Default Display Currency").]]></comment>
1074
- </use_symbol>
1075
- <incl_tax>
1076
- <label>Include Tax in Reminder Emails</label>
1077
- <frontend_type>select</frontend_type>
1078
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
1079
- <source_model>adminhtml/system_config_source_yesno</source_model>
1080
- <sort_order>45</sort_order>
1081
- <show_in_default>1</show_in_default>
1082
- <show_in_website>1</show_in_website>
1083
- <show_in_store>1</show_in_store>
1084
- <comment><![CDATA[If enabled, the <em>%%%%#productPrice_#%%%%</em> for
1085
- quote items will include the tax (if available)
1086
- for the given product, subtotal, and grand total.]]></comment>
1087
- </incl_tax>
1088
- </fields>
1089
- </format>
1090
- <information>
1091
- <label>Support Information</label>
1092
- <comment>
1093
- <![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>
1094
- <frontend_type>text</frontend_type>
1095
- <frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
1096
- <sort_order>15</sort_order>
1097
- <show_in_default>1</show_in_default>
1098
- <show_in_website>0</show_in_website>
1099
- <show_in_store>0</show_in_store>
1100
- <fields>
1101
- <download>
1102
- <label>Create Log Archive</label>
1103
- <frontend_type>text</frontend_type>
1104
- <frontend_model>bronto_common/adminhtml_system_config_form_field_download</frontend_model>
1105
- <sort_order>7</sort_order>
1106
- <show_in_default>1</show_in_default>
1107
- <show_in_website>1</show_in_website>
1108
- <show_in_store>1</show_in_store>
1109
- </download>
1110
- <debug>
1111
- <label>Debug Information</label>
1112
- <frontend_type>text</frontend_type>
1113
- <frontend_model>bronto_common/adminhtml_system_config_form_field_debug</frontend_model>
1114
- <sort_order>8</sort_order>
1115
- <show_in_default>1</show_in_default>
1116
- <show_in_website>0</show_in_website>
1117
- <show_in_store>0</show_in_store>
1118
- </debug>
1119
- </fields>
1120
- </information>
1121
- </groups>
1122
- </bronto>
1123
- </sections>
1124
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-1.7.0.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->handleOld();
9
-
10
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.2.1.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/api')}`;");
10
-
11
- $installer->run("
12
- CREATE TABLE `{$installer->getTable('bronto_common/api')}` (
13
- `token` varchar(36) NOT NULL,
14
- `session_id` varchar(36) NOT NULL,
15
- `created_at` datetime NOT NULL,
16
- PRIMARY KEY (`token`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'
18
- ");
19
-
20
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/error')}`;");
21
-
22
- $installer->run("
23
- CREATE TABLE `{$installer->getTable('bronto_common/error')}` (
24
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
25
- `email_class` varchar(100) NULL,
26
- `object` text NOT NULL DEFAULT '',
27
- `attempts` smallint(1) NOT NULL,
28
- `last_attempt` datetime NOT NULL,
29
- PRIMARY KEY (`error_id`),
30
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
31
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
32
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'
33
- ");
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError('Failed to create API tables: ' . $e->getMessage());
36
- }
37
-
38
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.3.0.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_common')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.3.1.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_common')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.4.2.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_common')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-install-2.4.4.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_common')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-1.7.0-2.2.1.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/api')}`;");
10
-
11
- $installer->run("
12
- CREATE TABLE `{$installer->getTable('bronto_common/api')}` (
13
- `token` varchar(36) NOT NULL,
14
- `session_id` varchar(36) NOT NULL,
15
- `created_at` datetime NOT NULL,
16
- PRIMARY KEY (`token`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'
18
- ");
19
-
20
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/error')}`;");
21
-
22
- $installer->run("
23
- CREATE TABLE `{$installer->getTable('bronto_common/error')}` (
24
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
25
- `email_class` varchar(100) NULL,
26
- `object` text NOT NULL DEFAULT '',
27
- `attempts` smallint(1) NOT NULL,
28
- `last_attempt` datetime NOT NULL,
29
- PRIMARY KEY (`error_id`),
30
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
31
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
32
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'
33
- ");
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError('Failed to create API tables: ' . $e->getMessage());
36
- }
37
-
38
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.0.4-2.2.1.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/api')}`;");
10
-
11
- $installer->run("
12
- CREATE TABLE `{$installer->getTable('bronto_common/api')}` (
13
- `token` varchar(36) NOT NULL,
14
- `session_id` varchar(36) NOT NULL,
15
- `created_at` datetime NOT NULL,
16
- PRIMARY KEY (`token`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'
18
- ");
19
-
20
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/error')}`;");
21
-
22
- $installer->run("
23
- CREATE TABLE `{$installer->getTable('bronto_common/error')}` (
24
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
25
- `email_class` varchar(100) NULL,
26
- `object` text NOT NULL DEFAULT '',
27
- `attempts` smallint(1) NOT NULL,
28
- `last_attempt` datetime NOT NULL,
29
- PRIMARY KEY (`error_id`),
30
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
31
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
32
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'
33
- ");
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError('Failed to create API tables: ' . $e->getMessage());
36
- }
37
-
38
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.0.4.2-2.2.1.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/api')}`;");
10
-
11
- $installer->run("
12
- CREATE TABLE `{$installer->getTable('bronto_common/api')}` (
13
- `token` varchar(36) NOT NULL,
14
- `session_id` varchar(36) NOT NULL,
15
- `created_at` datetime NOT NULL,
16
- PRIMARY KEY (`token`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'
18
- ");
19
-
20
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/error')}`;");
21
-
22
- $installer->run("
23
- CREATE TABLE `{$installer->getTable('bronto_common/error')}` (
24
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
25
- `email_class` varchar(100) NULL,
26
- `object` text NOT NULL DEFAULT '',
27
- `attempts` smallint(1) NOT NULL,
28
- `last_attempt` datetime NOT NULL,
29
- PRIMARY KEY (`error_id`),
30
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
31
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
32
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'
33
- ");
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError('Failed to create API tables: ' . $e->getMessage());
36
- }
37
-
38
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.1.0-2.2.1.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/api')}`;");
10
-
11
- $installer->run("
12
- CREATE TABLE `{$installer->getTable('bronto_common/api')}` (
13
- `token` varchar(36) NOT NULL,
14
- `session_id` varchar(36) NOT NULL,
15
- `created_at` datetime NOT NULL,
16
- PRIMARY KEY (`token`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'
18
- ");
19
-
20
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/error')}`;");
21
-
22
- $installer->run("
23
- CREATE TABLE `{$installer->getTable('bronto_common/error')}` (
24
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
25
- `email_class` varchar(100) NULL,
26
- `object` text NOT NULL DEFAULT '',
27
- `attempts` smallint(1) NOT NULL,
28
- `last_attempt` datetime NOT NULL,
29
- PRIMARY KEY (`error_id`),
30
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
31
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
32
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'
33
- ");
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError('Failed to create API tables: ' . $e->getMessage());
36
- }
37
-
38
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.2.0-2.2.1.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_Common_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/api')}`;");
10
-
11
- $installer->run("
12
- CREATE TABLE `{$installer->getTable('bronto_common/api')}` (
13
- `token` varchar(36) NOT NULL,
14
- `session_id` varchar(36) NOT NULL,
15
- `created_at` datetime NOT NULL,
16
- PRIMARY KEY (`token`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Session table'
18
- ");
19
-
20
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_common/error')}`;");
21
-
22
- $installer->run("
23
- CREATE TABLE `{$installer->getTable('bronto_common/error')}` (
24
- `error_id` int(11) NOT NULL AUTO_INCREMENT,
25
- `email_class` varchar(100) NULL,
26
- `object` text NOT NULL DEFAULT '',
27
- `attempts` smallint(1) NOT NULL,
28
- `last_attempt` datetime NOT NULL,
29
- PRIMARY KEY (`error_id`),
30
- KEY `IDX_BRONTO_ERROR_ATTEMPT` (`attempts`),
31
- KEY `IDX_BRONTO_ERROR_TIMESTAMP` (`last_attempt`)
32
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto API Error log'
33
- ");
34
- } catch (Exception $e) {
35
- Mage::helper('bronto_common')->writeError('Failed to create API tables: ' . $e->getMessage());
36
- }
37
-
38
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.2.2-2.3.0.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
- $installer->updateTables('2.3.0');
7
- $installer->resubmitFormInfo();
8
- $installer->endSetup();
 
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.3.0-2.4.0.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
- $installer->resubmitFormInfo();
7
- $installer->endSetup();
 
 
 
 
 
 
 
app/code/community/Bronto/Common/sql/bronto_common_setup/mysql4-upgrade-2.4.0-2.4.2.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
- $installer->resubmitFormInfo();
7
- $installer->endSetup();
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/About.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var string
11
- */
12
- protected $_module = 'bronto_customer';
13
-
14
- /**
15
- * @var string
16
- */
17
- protected $_name = 'Bronto Customer Import for Magento';
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Cron.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected $_jobCode = 'bronto_customer_import';
10
- protected $_hasProgressBar = true;
11
-
12
- /**
13
- * @return Bronto_Order_Block_Adminhtml_System_Config_Cron
14
- */
15
- protected function _prepareLayout()
16
- {
17
- $this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_sync'));
18
- $this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_reset'));
19
- $this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_mark'));
20
- $this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_run'));
21
-
22
- return parent::_prepareLayout();
23
- }
24
-
25
- /**
26
- * @return int
27
- */
28
- protected function getProgressBarTotal()
29
- {
30
- return $this->getCustomerResourceCollection()
31
- // ->addBrontoNotSuppressedFilter()
32
- ->getSize();
33
- }
34
-
35
- /**
36
- * @return int
37
- */
38
- protected function getProgressBarPending()
39
- {
40
- return $this->getCustomerResourceCollection()
41
- ->addBrontoNotImportedFilter()
42
- ->addBrontoNotSuppressedFilter()
43
- ->getSize();
44
- }
45
-
46
- /**
47
- * @return int
48
- */
49
- protected function getProgressBarSuppressed()
50
- {
51
- return $this->getCustomerResourceCollection()
52
- ->addBrontoNotImportedFilter()
53
- ->addBrontoSuppressedFilter()
54
- ->getSize();
55
- }
56
-
57
- /**
58
- * Get number of customers not imported from stores that don't have module enabled
59
- *
60
- * @return int
61
- */
62
- protected function getProgressBarDisabled()
63
- {
64
- $collection = Mage::getModel('bronto_customer/queue')->getCollection();
65
- $storeIds = Mage::helper('bronto_customer')->getStoreIds();
66
-
67
- if ($storeIds) {
68
- if (!is_array($storeIds)) {
69
- $storeIds = array($storeIds);
70
- }
71
- foreach ($storeIds as $key => $storeId) {
72
- if (Mage::getStoreConfig(Bronto_Customer_Helper_Data::XML_PATH_ENABLED, $storeId)) {
73
- unset($storeIds[$key]);
74
- }
75
- }
76
- $collection->addStoreFilter($storeIds);
77
-
78
- return $collection->addBrontoNotImportedFilter()
79
- ->addBrontoNotSuppressedFilter()
80
- ->getSize();
81
- }
82
-
83
- return 0;
84
- }
85
-
86
- /**
87
- * @return Bronto_Customer_Model_Mysql4_Queue_Collection
88
- */
89
- protected function getCustomerResourceCollection()
90
- {
91
- $collection = Mage::getModel('bronto_customer/queue')->getCollection();
92
- $storeIds = Mage::helper('bronto_customer')->getStoreIds();
93
-
94
- if ($storeIds) {
95
- $collection->addStoreFilter($storeIds);
96
- }
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_customer')->canUseMageCron();
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Field/Rewardpoints.php DELETED
@@ -1,44 +0,0 @@
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 DELETED
@@ -1,44 +0,0 @@
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 DELETED
@@ -1,349 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected $_ignoreAttributes = array();
10
- protected $_configPath = '';
11
- protected $_dummyElement;
12
- protected $_dummyNewElement;
13
- protected $_fieldRenderer;
14
- protected $_values;
15
-
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'] = trim($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
-
40
- // Get Array of existing fields
41
- $skips = $this->_getUsedAttributeCodes($element);
42
- $order = 100;
43
- // Cycle through Attributes and skip ignored attributes
44
- foreach ($this->_getAttributes() as $_attribute) {
45
- $_attributeCode = $_attribute->getAttributeCode();
46
- if (in_array($_attributeCode, $skips)) {
47
- continue;
48
- } else {
49
- try {
50
- $order = $order + 5;
51
- $html .= $this->_getFieldHtml($element, $_attribute, $order);
52
- } catch (Exception $e) {
53
- Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
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
-
147
- return $this->_dummyElement;
148
- }
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 '';
210
- }
211
-
212
- // Define Field Dependencies
213
- $this->getForm()->getChild('element_dependense')
214
- ->addFieldMap($field->getHtmlId(), $field->getName())
215
- ->addFieldMap($newField->getHtmlId(), $newField->getName())
216
- ->addFieldDependence($newField->getName(), $field->getName(), '_new_');
217
-
218
- return $field->toHtml() . $newField->toHtml();
219
- }
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(
232
- Varien_Data_Form_Element_Abstract $fieldset,
233
- Varien_Object $e,
234
- Mage_Eav_Model_Entity_Attribute $attribute,
235
- $fieldStep = 'standard'
236
- )
237
- {
238
- // Get Config Data
239
- $configData = $this->getConfigData();
240
- if ('' == $attribute->getFrontendLabel()) {
241
- return false;
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
-
257
- // Get field Renderer
258
- if ($e->frontend_model) {
259
- $fieldRenderer = Mage::getBlockSingleton((string)$e->frontend_model);
260
- } else {
261
- $fieldRenderer = $this->_getFieldRenderer();
262
- }
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) {
271
- $model = Mage::getModel((string)$e->backend_model);
272
- if (!$model instanceof Mage_Core_Model_Config_Data) {
273
- Mage::throwException('Invalid config field backend model: ' . (string)$e->backend_model);
274
- }
275
- $model->setPath($path)->setValue($data)->afterLoad();
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),
298
- ));
299
-
300
- // Add Validation
301
- if ($e->validate) {
302
- $field->addClass($e->validate);
303
- }
304
-
305
- // Determine if value can be empty
306
- if (isset($e->frontend_type) && 'multiselect' === (string)$e->frontend_type && isset($e->can_be_empty)) {
307
- $field->setCanBeEmpty(true);
308
- }
309
-
310
- // Set Field Renderer
311
- $field->setRenderer($fieldRenderer);
312
-
313
- // Use Source Model to define available options
314
- if ($e->source_model) {
315
- $sourceModel = Mage::getSingleton((string)$e->source_model);
316
- if ($sourceModel instanceof Varien_Object) {
317
- $sourceModel->setPath($path);
318
- }
319
- $field->setValues($sourceModel->toOptionArray());
320
- }
321
-
322
- return $field;
323
- }
324
-
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) {
336
- // Determine the *actual* name for this select box
337
- preg_match('/\[(\w+)\]\[value\]/', $_element->getName(), $matches);
338
- if (isset($matches[1])) {
339
- // Add to list
340
- $usedAttributeCodes[] = $matches[1];
341
- }
342
- }
343
-
344
- // Merge in ignored attribute codes
345
- $usedAttributeCodes = array_merge($usedAttributeCodes, $this->_ignoreAttributes);
346
-
347
- return $usedAttributeCodes;
348
- }
349
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Address.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var array<Mage_Customer_Model_Attribute>
11
- */
12
- private $_addressAttributes;
13
-
14
- /**
15
- * @var array<string>
16
- */
17
- protected $_ignoreAttributes = array(
18
- 'firstname',
19
- 'lastname',
20
- 'middlename',
21
- 'prefix',
22
- 'region_id',
23
- 'suffix',
24
- 'vat_id',
25
- 'vat_is_valid',
26
- 'vat_request_id',
27
- 'vat_request_date',
28
- 'vat_request_success',
29
- );
30
-
31
- protected $_configPath = Bronto_Customer_Helper_Data::XML_PREFIX_ADDRESS_ATTR;
32
- protected $_idPath = 'bronto_customer_address_attributes_';
33
- protected $_fieldNameTemplate = 'groups[address_attributes][fields][_attrCode_][value]';
34
-
35
- /**
36
- * @return array
37
- */
38
- protected function _getAttributes()
39
- {
40
- return $this->_getAddressAttributes();
41
- }
42
-
43
- /**
44
- * @return array
45
- */
46
- private function _getAddressAttributes()
47
- {
48
- if ($this->_addressAttributes === null) {
49
- $this->_addressAttributes = Mage::getModel('customer/entity_address_attribute_collection');
50
- }
51
-
52
- return $this->_addressAttributes;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Customer.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var array<Mage_Customer_Model_Attribute>
11
- */
12
- private $_customerAttributes;
13
-
14
- /**
15
- * @var array<string>
16
- */
17
- protected $_ignoreAttributes = array(
18
- 'increment_id',
19
- 'updated_at',
20
- 'store_id',
21
- 'entity_id',
22
- 'attribute_set_id',
23
- 'entity_type_id',
24
- 'password_hash',
25
- 'default_billing',
26
- 'default_shipping',
27
- 'email',
28
- 'confirmation',
29
- 'reward_update_notification',
30
- 'reward_warning_notification',
31
- 'disable_auto_group_change',
32
- );
33
-
34
- protected $_configPath = Bronto_Customer_Helper_Data::XML_PREFIX_CUSTOMER_ATTR;
35
- protected $_idPath = 'bronto_customer_attributes_';
36
- protected $_fieldNameTemplate = 'groups[attributes][fields][_attrCode_][value]';
37
-
38
- /**
39
- * @return array
40
- */
41
- protected function _getAttributes()
42
- {
43
- return $this->_getCustomerAttributes();
44
- }
45
-
46
- /**
47
- * @return array
48
- */
49
- private function _getCustomerAttributes()
50
- {
51
- if ($this->_customerAttributes === null) {
52
- $this->_customerAttributes = Mage::getModel('customer/entity_attribute_collection');
53
- }
54
-
55
- return $this->_customerAttributes;
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Suppressed.php DELETED
@@ -1,27 +0,0 @@
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
-
20
- /**
21
- * @see parent
22
- */
23
- public function getResetUrl()
24
- {
25
- return Mage::helper('bronto_common')->getScopeUrl('adminhtml/customer/reset');
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Mark.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Customer_Block_Adminhtml_Widget_Button_Mark extends Mage_Adminhtml_Block_Widget_Button
4
- {
5
- /**
6
- * @see parent
7
- */
8
- protected function _construct()
9
- {
10
- $this->setLabel('Mark All Imported');
11
- $this->setOnClick("deleteConfirm('This will mark all customers as imported and will not send the information to Bronto.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/mark') . "'); return false;");
12
- $this->setClass('bronto-cron-mark');
13
-
14
- if (!Mage::helper('bronto_customer')->isModuleActive() || (!Mage::helper('bronto_common')->isDebugEnabled())) {
15
- $this->setDisabled(true)->setClass('disabled');
16
- }
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Reset.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Internal constructor not depended on params. Can be used for object initialization
11
- */
12
- protected function _construct()
13
- {
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())) {
20
- $this->setDisabled(true)->setClass('disabled');
21
- if (!Mage::helper('bronto_customer')->isDebugEnabled()) {
22
- $this->setTitle('Enable Debug in the General section to ' . $this->getLabel() . '.');
23
- }
24
- }
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Run.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Internal constructor not depended on params. Can be used for object initialization
11
- */
12
- protected function _construct()
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');
20
- }
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Sync.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Internal constructor not depended on params. Can be used for object initialization
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');
20
- }
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Helper/Data.php DELETED
@@ -1,380 +0,0 @@
1
- <?php
2
-
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
- const XML_PREFIX_BILLING_ATTR = 'bronto_customer/billing_address_attributes/';
19
-
20
- const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_customer_import/schedule/cron_expr';
21
- const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_customer_import/run/model';
22
-
23
- private $_addressTypes = array(
24
- 'address' => 'getPrimaryShippingAddress',
25
- 'billing_address' => 'getPrimaryBillingAddress'
26
- );
27
-
28
- /**
29
- * Module Human Readable Name
30
- */
31
- protected $_name = 'Bronto Contact Import';
32
-
33
- /**
34
- * Gets the address types to customer method to obtain them
35
- *
36
- * @return array
37
- */
38
- public function getAddressTypes()
39
- {
40
- return $this->_addressTypes;
41
- }
42
-
43
- /**
44
- * Get Human Readable Name
45
- *
46
- * @return string
47
- */
48
- public function getName()
49
- {
50
- return $this->__($this->_name);
51
- }
52
-
53
- /**
54
- * Check if module is enabled
55
- *
56
- * @param string $scope
57
- * @param int $scopeId
58
- *
59
- * @return bool
60
- */
61
- public function isEnabled($scope = 'default', $scopeId = 0)
62
- {
63
- // Get Enabled Scope
64
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
65
- }
66
-
67
- /*
68
- * Get Text to display in notice when enabling module
69
- *
70
- * @return string
71
- */
72
- public function getModuleEnabledText()
73
- {
74
- $message = parent::getModuleEnabledText();
75
- $scopeData = $this->getScopeParams();
76
- if ($scopeData['scope'] != 'default') {
77
- $message = $this->__(
78
- 'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
79
- 'you should un-check the `Use Website` or `Use Default` for ALL <em>Customer Attributes</em> ' .
80
- 'and <em>Address Attributes</em> on this page and select the desired fields.'
81
- );
82
- }
83
-
84
- return $message;
85
- }
86
-
87
- /**
88
- * Disable Module for Specified Scope
89
- *
90
- * @param string $scope
91
- * @param int $scopeId
92
- * @param bool $deleteConfig
93
- *
94
- * @return bool
95
- */
96
- public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
97
- {
98
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
99
- }
100
-
101
- /**
102
- * Get Send Limit
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
- * Get Sync Limit
116
- *
117
- * @return int
118
- */
119
- public function getSyncLimit()
120
- {
121
- return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
122
- }
123
-
124
- /**
125
- * Check if module can use the magento cron
126
- *
127
- * @return bool
128
- */
129
- public function canUseMageCron()
130
- {
131
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
132
- }
133
-
134
- /**
135
- * @return string
136
- */
137
- public function getCronStringPath()
138
- {
139
- return self::XML_PATH_CRON_STRING;
140
- }
141
-
142
- /**
143
- * @return string
144
- */
145
- public function getCronModelPath()
146
- {
147
- return self::XML_PATH_CRON_MODEL;
148
- }
149
-
150
- /**
151
- * @return array
152
- */
153
- public function getSystemAttributes()
154
- {
155
- return array(
156
- 'attributes' => array(
157
- 'prefix',
158
- 'new_prefix',
159
- 'firstname',
160
- 'new_firstname',
161
- 'middlename',
162
- 'new_middlename',
163
- 'lastname',
164
- 'new_lastname',
165
- 'suffix',
166
- 'new_suffix',
167
- 'gender',
168
- 'new_gender',
169
- 'dob',
170
- 'new_dob',
171
- 'taxvat',
172
- 'new_taxvat',
173
- 'website_id',
174
- 'new_website_id',
175
- 'group_id',
176
- 'new_group_id',
177
- 'created_at',
178
- 'new_created_at',
179
- 'created_in',
180
- 'new_created_in',
181
- ),
182
- 'address_attributes' => array(
183
- 'street',
184
- 'new_street',
185
- 'city',
186
- 'new_city',
187
- 'region',
188
- 'new_region',
189
- 'region_code_id',
190
- 'new_region_code_id',
191
- 'postcode',
192
- 'new_postcode',
193
- 'country_id',
194
- 'new_country_id',
195
- 'country_code_id',
196
- 'new_country_code_id',
197
- 'company',
198
- 'new_company',
199
- 'telephone',
200
- 'new_telephone',
201
- 'fax',
202
- 'new_fax',
203
- ),
204
- 'billing_address_attributes' => array(
205
- 'street',
206
- 'new_street',
207
- 'city',
208
- 'new_city',
209
- 'region',
210
- 'new_region',
211
- 'region_code_id',
212
- 'new_region_code_id',
213
- 'postcode',
214
- 'new_postcode',
215
- 'country_id',
216
- 'new_country_id',
217
- 'country_code_id',
218
- 'new_country_code_id',
219
- 'company',
220
- 'new_company',
221
- 'telephone',
222
- 'new_telephone',
223
- 'fax',
224
- 'new_fax',
225
- ),
226
- );
227
- }
228
-
229
- /**
230
- * Get Customer Attribute Field for scope
231
- *
232
- * @param $attribute
233
- * @param string $scope
234
- * @param int $scopeId
235
- *
236
- * @return mixed
237
- */
238
- public function getCustomerAttributeField($attribute, $scope = 'default', $scopeId = 0)
239
- {
240
- return $this->getAdminScopedConfig(self::XML_PREFIX_CUSTOMER_ATTR . $attribute, $scope, $scopeId);
241
- }
242
-
243
- /**
244
- * Gets Customer attributes that may or may not be prefixed
245
- *
246
- * @param string $attribute
247
- * @param string $prefix
248
- * @param string $scope
249
- * @param int $scopeId
250
- *
251
- * @return mixed
252
- */
253
- public function getPrefixedAttributeField($attribute, $prefix = '', $scope = 'default', $scopeId = 0)
254
- {
255
- $prefix = !empty($prefix) ? $prefix . '_' : '';
256
- return $this->getAdminScopedConfig("bronto_customer/{$prefix}attributes/" . $attribute, $scope, $scopeId);
257
- }
258
-
259
- /**
260
- * Get Address Attribute Field for scope
261
- *
262
- * @param $attribute
263
- * @param string $scope
264
- * @param int $scopeId
265
- *
266
- * @return mixed
267
- */
268
- public function getAddressAttributeField($attribute, $scope = 'default', $scopeId = 0)
269
- {
270
- return $this->getPrefixedAttributeField($attribute, 'address', $scope, $scopeId);
271
- }
272
-
273
- /**
274
- * Get the billing address attribute field for scope
275
- *
276
- * @param string $attribute
277
- * @param string $scope
278
- * @param int $scopeId
279
- *
280
- * @return mixed
281
- */
282
- public function getBillingAddressAttributeField($attribute, $scope = 'default', $scopeId = 0)
283
- {
284
- return $this->getPrefixedAttributeField($attribute, 'billing_address', $scope, $scopeId);
285
- }
286
-
287
- /**
288
- * Retrieve helper module name
289
- *
290
- * @return string
291
- */
292
- protected function _getModuleName()
293
- {
294
- return 'bronto_customer';
295
- }
296
-
297
- /**
298
- * Get Human Readable label for attribute value option
299
- *
300
- * @param Mage_Eav_Model_Entity_Attribute $attribute
301
- * @param int|string $attributeValueId
302
- *
303
- * @return string|boolean
304
- */
305
- public function getAttributeAdminLabel($attribute, $attributeValueId)
306
- {
307
- if ($attribute->getFrontendInput() == 'select') {
308
- return $attribute->getSource()->getOptionText($attributeValueId);
309
- }
310
- return false;
311
- }
312
-
313
- /**
314
- * Get Count of customers not in queue
315
- *
316
- * @return int
317
- */
318
- public function getMissingCustomersCount()
319
- {
320
- return Mage::getModel('bronto_customer/queue')
321
- ->getMissingCustomersCount();
322
- }
323
-
324
- /**
325
- * Get Customers which aren't in contact queue
326
- *
327
- * @return array
328
- */
329
- public function getMissingCustomers()
330
- {
331
- return Mage::getModel('bronto_customer/queue')
332
- ->getMissingCustomers();
333
- }
334
-
335
- /**
336
- * Does this helper have custom config for debugging
337
- *
338
- * @return boolean
339
- */
340
- public function hasCustomConfig()
341
- {
342
- return true;
343
- }
344
-
345
- /**
346
- * Gets the bronto customer field attributes
347
- *
348
- * @param object $store (Optional)
349
- *
350
- * @return array
351
- */
352
- public function getCustomConfig($scope = 'default', $scopeId = 0)
353
- {
354
- $customerAttributes = Mage::getModel('customer/entity_attribute_collection');
355
- $addressAttributes = Mage::getModel('customer/entity_address_attribute_collection');
356
-
357
- $attributes = array();
358
- $data = array();
359
- foreach ($customerAttributes as $attribute) {
360
- $config = $this->getCustomerAttributeField($attribute->getAttributeCode(), $scope, $scopeId);
361
- if ($config && $attribute->getFrontendLabel()) {
362
- $data[$attribute->getAttributeCode()] = $config;
363
- }
364
- }
365
- $attributes['customer_attributes'] = $data;
366
-
367
- foreach ($this->_addressTypes as $prefix => $methodName) {
368
- $addressData = array();
369
- foreach ($addressAttributes as $attribute) {
370
- $config = $this->getPrefixedAttributeField($attribute->getAttributeCode(), $prefix, $scope, $scopeId);
371
- if ($config && $attribute->getFrontendLabel()) {
372
- $addressData[$attribute->getAttributeCode()] = $config;
373
- }
374
- }
375
- $attributes["{$prefix}_attributes"] = $addressData;
376
- }
377
-
378
- return $attributes;
379
- }
380
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/Mysql4/Queue.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Primary 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_customer/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/Customer/Model/Mysql4/Queue/Collection.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
-
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
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_customer/queue');
20
- }
21
-
22
- /**
23
- * @return Bronto_Order_Model_Mysql4_Queue_Collection
24
- */
25
- public function addBrontoImportedFilter()
26
- {
27
- $this->addFieldToFilter('bronto_imported', array('notnull' => true));
28
-
29
- return $this;
30
- }
31
-
32
- /**
33
- * @return Bronto_Order_Model_Mysql4_Queue_Collection
34
- */
35
- public function addBrontoSuppressedFilter()
36
- {
37
- $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
38
-
39
- return $this;
40
- }
41
-
42
- /**
43
- * @return Bronto_Order_Model_Mysql4_Queue_Collection
44
- */
45
- public function addBrontoNotImportedFilter()
46
- {
47
- $this->addFieldToFilter('bronto_imported', array('null' => true));
48
-
49
- return $this;
50
- }
51
-
52
- /**
53
- * @return Bronto_Order_Model_Mysql4_Queue_Collection
54
- */
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)
68
- {
69
- $nullCheck = false;
70
-
71
- if (!is_array($storeIds)) {
72
- $storeIds = array($storeIds);
73
- }
74
-
75
- $storeIds = array_unique($storeIds);
76
-
77
- if ($index = array_search(null, $storeIds, true)) {
78
- unset($storeIds[$index]);
79
- $nullCheck = true;
80
- }
81
-
82
- if ($nullCheck) {
83
- $this->getSelect()->where('store_id IN(?) OR store_id IS NULL', $storeIds);
84
- } else {
85
- $this->getSelect()->where('store_id IN(?)', $storeIds);
86
- }
87
-
88
- return $this;
89
- }
90
-
91
- /**
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)
99
- {
100
- $this->getSelect()->order("created_at $dir");
101
-
102
- return $this;
103
- }
104
-
105
- /**
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)
113
- {
114
- $this->getSelect()->order("updated_at $dir");
115
-
116
- return $this;
117
- }
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/Mysql4/Setup.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected function _getAttributeColumnDefinition($code, $data)
10
- {
11
- $definition = parent::_getAttributeColumnDefinition($code, $data);
12
-
13
- if ($code === 'bronto_imported' && is_string($definition)) {
14
- return 'datetime NULL DEFAULT NULL';
15
- }
16
-
17
- return $definition;
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/Observer.php DELETED
@@ -1,671 +0,0 @@
1
- <?php
2
-
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
- {
9
- private $_fieldMap = array();
10
- private $_blackList = array();
11
- private $_rewardsInfo = array(
12
- 'reward_points' => array('Reward Points', 'getPointsBalance'),
13
- 'reward_points_dollars' => array('Reward Curreny Amount', 'getFormatedCurrencyAmount')
14
- );
15
- private $_expandedfields = array(
16
- 'country_id' => array('getCountryId', 'Country Code', 'country_code_id'),
17
- 'region' => array('getRegionCode', 'Region Code', 'region_code_id')
18
- );
19
-
20
- /**
21
- * Observes module becoming enabled and displays message warning user to configure settings
22
- *
23
- * @param Varien_Event_Observer $observer
24
- */
25
- public function watchEnableAction(Varien_Event_Observer $observer)
26
- {
27
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_customer')->__(Mage::helper('bronto_customer')->getModuleEnabledText()));
28
- }
29
-
30
- /**
31
- * @param mixed $storeId
32
- * @param int $limit
33
- *
34
- * @return array
35
- */
36
- public function processCustomersForStore($storeId = null, $limit)
37
- {
38
- if (!$limit) {
39
- Mage::helper('bronto_customer')->writeDebug(' Limit empty. Skipping...');
40
-
41
- return false;
42
- }
43
-
44
- /** @var Mage_Core_Model_Store $store */
45
- $store = Mage::app()->getStore($storeId);
46
- $storeId = $store->getId();
47
-
48
- $contactFlusher = Mage::getModel('bronto_common/flusher')->setHelper('bronto_customer');
49
- Mage::helper('bronto_customer')->writeDebug("Starting Customer Import process for store: {$store->getName()} ({$storeId})");
50
-
51
- if (!$store->getConfig(Bronto_Customer_Helper_Data::XML_PATH_ENABLED)) {
52
- Mage::helper('bronto_customer')->writeDebug(' Module disabled for this store. Skipping...');
53
-
54
- return $contactFlusher->getResult();
55
- }
56
-
57
- // Retrieve Store's configured API Token
58
- $token = $store->getConfig(Bronto_Common_Helper_Data::XML_PATH_API_TOKEN);
59
-
60
- /** @var Bronto_Common_Model_Api $api */
61
- $api = Mage::helper('bronto_customer')->getApi($token, 'store', $store->getId());
62
-
63
- /** @var Bronto_Api_Operation_Contact $contactObject */
64
- $contactObject = $api->transferContact();
65
-
66
- // Get all customers in queue who haven't been imported into bronto
67
- $customerRows = Mage::getModel('bronto_customer/queue')
68
- ->getCollection()
69
- ->addBrontoNotImportedFilter()
70
- ->addBrontoNotSuppressedFilter()
71
- ->orderByUpdatedAt()
72
- ->setPageSize($limit)
73
- ->addStoreFilter($storeId)
74
- ->getItems();
75
-
76
- if (empty($customerRows)) {
77
- Mage::helper('bronto_customer')->writeVerboseDebug(' No Customers to process. Skipping...');
78
-
79
- return $contactFlusher->getResult();
80
- }
81
-
82
- /** @var Mage_Customer_Model_Entity_Attribute_Collection $customerAttributes */
83
- $customerAttributes = Mage::getModel('customer/entity_attribute_collection');
84
- /** @var Mage_Customer_Model_Entity_Address_Attribute_Collection $addressAttributes */
85
- $addressAttributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
86
- $this->_buildValidFieldMapForStore($store, $customerAttributes, $addressAttributes);
87
- // Flush every 100 Customers
88
- $addOrUpdate = $contactObject->addOrUpdate(100)->withFlusher($contactFlusher);
89
-
90
- // For each Customer...
91
- foreach ($customerRows as $customerRow) {
92
- $customerId = $customerRow->getCustomerId();
93
- if ($customer = Mage::getModel('customer/customer')->load($customerId)/* @var $customer Mage_Customer_Model_Customer */) {
94
- Mage::helper('bronto_customer')->writeDebug(" Processing Customer ID: {$customerId} for Store ID: {$storeId}");
95
-
96
- $brontoContact = $contactObject->createObject()
97
- ->withStatus(Bronto_Api_Model_Contact::STATUS_TRANSACTIONAL)
98
- ->withEmail($customer->getEmail())
99
- ->withQueueRow($customerRow->getData());
100
- /* Process Customer Attributes */
101
- try {
102
- $brontoContact = $this->_processAttributes($brontoContact, $customer, $customerAttributes, $store, 'customer');
103
- $brontoContact = $this->_processRewardPoints($brontoContact, $customer, $store);
104
- $brontoContact = $this->_processStoreCredit($brontoContact, $customer, $store);
105
- foreach (Mage::helper('bronto_customer')->getAddressTypes() as $prefix => $methodName) {
106
- $address = $customer->$methodName();
107
- if (!empty($address)) {
108
- $brontoContact = $this->_processAttributes($brontoContact, $address, $addressAttributes, $store, $prefix);
109
- }
110
- }
111
-
112
- $addOrUpdate->addContact($brontoContact);
113
- } catch (Exception $e) {
114
- Mage::helper('bronto_customer')->writeError($e);
115
- }
116
- }
117
- }
118
-
119
- $addOrUpdate->flush();
120
- $result = $contactFlusher->getResult();
121
-
122
- Mage::helper('bronto_customer')->writeDebug(' Success: ' . $result['success']);
123
- Mage::helper('bronto_customer')->writeDebug(' Error: ' . $result['error']);
124
- Mage::helper('bronto_customer')->writeDebug(' Total: ' . $result['total']);
125
-
126
- return $result;
127
- }
128
-
129
- /**
130
- * Convenience method for checking availability
131
- *
132
- * @param string $token
133
- * @param string $fieldId
134
- * @return boolean
135
- */
136
- protected function _skippableAttribute($token, $fieldId)
137
- {
138
- if (empty($fieldId) || '_none_' == $fieldId) {
139
- return true;
140
- }
141
- if (isset($this->_blackList[$fieldId])) {
142
- return true;
143
- }
144
- if (!empty($token)) {
145
- if (isset($this->_fieldMap[$token][$fieldId])) {
146
- return true;
147
- }
148
- }
149
- return false;
150
- }
151
-
152
- /**
153
- * Convenience method for checking value availabiility
154
- *
155
- * @param string $fieldId
156
- * @param string $value
157
- * @return boolean
158
- */
159
- protected function _skippableProcessValue($fieldId, $value)
160
- {
161
- if ($this->_skippableAttribute('', $fieldId)) {
162
- return true;
163
- }
164
- if ('' === $value || is_null($value)) {
165
- return true;
166
- }
167
- return false;
168
- }
169
-
170
- /**
171
- * Build internal field mapping for a token for a given store
172
- *
173
- * @param Mage_Core_Model_Store $store
174
- * @param Iterable $attributes
175
- * @param Iterable $addressAttrs
176
- * @return void
177
- */
178
- protected function _buildValidFieldMapForStore($store, $attributes, $addressAttrs)
179
- {
180
- $helper = Mage::helper('bronto_customer');
181
- $token = $helper->getApiToken('store', $store->getId());
182
- if (!isset($this->_fieldMap[$token])) {
183
- $this->_fieldMap[$token] = array();
184
- }
185
- $fieldsToCheck = array();
186
- // Dynamic attrs
187
- $pathPrefix = Bronto_Customer_Helper_Data::XML_PREFIX_CUSTOMER_ATTR;
188
- foreach ($attributes as $attribute) {
189
- if ('' == $attribute->getFrontendLabel()) {
190
- continue;
191
- }
192
- $fieldId = $helper->getCustomerAttributeField($attribute->getAttributeCode(), 'store', $store->getId());
193
- if ($this->_skippableAttribute($token, $fieldId)) {
194
- continue;
195
- }
196
- $xmlPath = "{$pathPrefix}{$attribute->getAttributeCode()}";
197
- $fieldsToCheck[$fieldId] = array($xmlPath, $attribute->getFrontendLabel());
198
- }
199
- // Reward Points / Store Credit
200
- foreach ($this->_rewardsInfo + array('store_credit' => array('Store Credit', '_')) as $key => $labelMethodTuple) {
201
- list($label, $method) = $labelMethodTuple;
202
- $fieldId = $helper->getCustomerAttributeField($key, 'store', $store->getId());
203
- if ($this->_skippableAttribute($token, $fieldId)) {
204
- continue;
205
- }
206
- $xmlPath = "{$pathPrefix}{$key}";
207
- $fieldsToCheck[$fieldId] = array($xmlPath, $helper->__($label));
208
- }
209
- // Address related
210
- foreach ($helper->getAddressTypes() as $prefix => $methodName) {
211
- $pathPrefix = "bronto_customer/{$prefix}_attributes/";
212
- foreach ($addressAttrs as $attribute) {
213
- if ('' == $attribute->getFrontendLabel()) {
214
- continue;
215
- }
216
- $code = $attribute->getAttributeCode();
217
- if (isset($this->_expandedfields[$code])) {
218
- list($method, $label, $field) = $this->_expandedfields[$code];
219
- $fieldId = $helper->getPrefixedAttributeField($field, $prefix, 'store', $store->getId());
220
- if (!$this->_skippableAttribute($token, $fieldId)) {
221
- $fieldsToCheck[$fieldId] = array("{$pathPrefix}{$field}", $helper->__($label));
222
- }
223
- }
224
- $fieldId = $helper->getPrefixedAttributeField($code, $prefix, 'store', $store->getId());
225
- if ($this->_skippableAttribute($token, $fieldId)) {
226
- continue;
227
- }
228
- $xmlPath = "{$pathPrefix}{$attribute->getAttributeCode()}";
229
- $fieldsToCheck[$fieldId] = array($xmlPath, $attribute->getFrontendLabel());
230
- }
231
- }
232
- // Do a read call, diff and warn
233
- if (!empty($fieldsToCheck)) {
234
- $configData = Mage::getModel('core/config_data');
235
- $fieldIds = array_keys($fieldsToCheck);
236
- $api = $helper->getApi($token, 'store', $store->getId());
237
- $fieldObject = $api->transferField();
238
- $readFields = $fieldObject->read()->where->id->in($fieldIds);
239
- foreach ($readFields as $field) {
240
- $this->_fieldMap[$token][$field->id] = $field->label;
241
- unset($fieldsToCheck[$field->id]);
242
- }
243
- // These contain fieldIds that no longer exist in this account
244
- foreach ($fieldsToCheck as $fieldId => $codeLabelTuple) {
245
- list($xmlPath, $label) = $codeLabelTuple;
246
- $helper->writeError("Field mapping for store {$store->getId()} no longer exists: {$fieldId}: {$label}");
247
- $collection = $configData->getCollection()
248
- ->addFieldToFilter('scope_id', array('eq' => $store->getId()))
249
- ->addFieldToFilter('path', array('eq' => $xmlPath));
250
- // Remove from config data
251
- foreach ($collection as $config) {
252
- $config->delete();
253
- $this->_blackList[$fieldId] = $store->getId();
254
- }
255
- }
256
- }
257
- }
258
-
259
- /**
260
- * @param Bronto_Api_Model_Contact $brontoContact
261
- * @param Mage_Customer_Model_Customer $customer
262
- * @param Mage_Core_Model_Store $store
263
- *
264
- * @return Bronto_Api_Model_Contact
265
- */
266
- protected function _processRewardPoints(Bronto_Api_Model_Contact $brontoContact, Mage_Customer_Model_Customer $customer, Mage_Core_Model_Store $store)
267
- {
268
- // If Reward Points is installed
269
- if (Mage::helper('bronto_common')->isModuleInstalled('Enterprise_Reward')) {
270
- /** @var Enterprise_Reward_Model_Reward $reward */
271
- $reward = Mage::getModel('enterprise_reward/reward')->setCustomerId($customer->getId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
272
- foreach ($this->_rewardsInfo as $key => $labelMethodTuple) {
273
- list($label, $methodName) = $labelMethodTuple;
274
- $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($key, 'store', $store->getId());
275
- $_attributeValue = $reward->$methodName();
276
- // Skip un-mapped or empty attributes
277
- if ($this->_skippableProcessValue($_fieldName, $_attributeValue)) {
278
- continue;
279
- }
280
-
281
- $brontoContact->addField($_fieldName, $_attributeValue);
282
- }
283
- }
284
-
285
- return $brontoContact;
286
- }
287
-
288
- /**
289
- * @param Bronto_Api_Model_Contact $brontoContact
290
- * @param Mage_Customer_Model_Customer $customer
291
- * @param Mage_Core_Model_Store $store
292
- *
293
- * @return Bronto_Api_Model_Contact
294
- */
295
- protected function _processStoreCredit(Bronto_Api_Model_Contact $brontoContact, Mage_Customer_Model_Customer $customer, Mage_Core_Model_Store $store)
296
- {
297
- // If Store Credit is installed
298
- if (Mage::helper('bronto_common')->isModuleInstalled('Enterprise_CustomerBalance')) {
299
- $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField('store_credit', 'store', $store->getId());
300
-
301
- /** @var Enterprise_CustomerBalance_Model_Balance $balance */
302
- $balance = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($customer->getId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
303
- $_attributeValue = Mage::app()->getLocale()->currency($balance->getWebsiteCurrencyCode())
304
- ->toCurrency($balance->getAmount());
305
-
306
- // Skip un-mapped or empty attributes
307
- if ($this->_skippableProcessValue($_fieldName, $_attributeValue)) {
308
- return $brontoContact;
309
- }
310
-
311
- $brontoContact->addField($_fieldName, $_attributeValue);
312
- }
313
-
314
- return $brontoContact;
315
- }
316
-
317
- /**
318
- * Cycle through attributes and validate against Bronto Field type
319
- *
320
- * @param Bronto_Api_Model_Contact $brontoContact
321
- * @param $source
322
- * @param $attributes
323
- * @param Mage_Core_Model_Store $store
324
- * @param string $type 'customer' or 'address'
325
- *
326
- * @return Bronto_Api_Model_Contact
327
- */
328
- protected function _processAttributes(Bronto_Api_Model_Contact $brontoContact, $source, $attributes, Mage_Core_Model_Store $store, $type = 'customer')
329
- {
330
- $helper = Mage::helper('bronto_customer');
331
- // For each Customer attribute
332
- foreach ($attributes as $attribute) {
333
- if ('' == $attribute->getFrontendLabel()) {
334
- continue;
335
- }
336
- $_attributeCode = $attribute->getAttributeCode();
337
-
338
- // Get Attribute Field
339
- switch ($type) {
340
- case 'billing_address':
341
- case 'address':
342
- $_fieldName = $helper->getPrefixedAttributeField($_attributeCode, $type, 'store', $store->getId());
343
- // Backward compatibility for country name and codes
344
- if (array_key_exists($_attributeCode, $this->_expandedfields)) {
345
- list($method, $label, $field) = $this->_expandedfields[$_attributeCode];
346
- $_attributeValue = strtolower($source->$method());
347
- $_brontoField = $helper->getPrefixedAttributeField($field, $type, 'store', $store->getId());
348
- if (!$this->_skippableProcessValue($_brontoField, $_attributeValue)) {
349
- $brontoContact->addField($_brontoField, $_attributeValue);
350
- }
351
- }
352
- break;
353
- default:
354
- $_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, 'store', $store->getId());
355
- break;
356
- }
357
-
358
- // Get Customer Attribute Value
359
- $_attributeValue = $this->_getReadableValue($attribute, $source->getData($_attributeCode));
360
-
361
- // Skip un-mapped or empty attributes
362
- if ($this->_skippableProcessValue($_fieldName, $_attributeValue)) {
363
- continue;
364
- }
365
-
366
- $brontoContact->addField($_fieldName, $_attributeValue);
367
- }
368
-
369
- return $brontoContact;
370
- }
371
-
372
- /**
373
- * Based on attribute type, pull the value or the label
374
- *
375
- * @param string $attribute
376
- * @param mixed $value
377
- *
378
- * @return mixed
379
- */
380
- protected function _getReadableValue($attribute, $value)
381
- {
382
- if ('' == $value) {
383
- return '';
384
- }
385
-
386
- $_attributeType = $attribute->getFrontendInput();
387
- $_attributeCode = $attribute->getAttributeCode();
388
- $_attributeBack = $attribute->getBackendType();
389
-
390
- // Pick up Website/Store/Group Values
391
- switch ($_attributeCode) {
392
- case 'website_id':
393
- $websiteModel = Mage::getModel('core/website')->load($value);
394
-
395
- return $websiteModel->getName();
396
- break;
397
- case 'store_id':
398
- $storeModel = Mage::getModel('core/store')->load($value);
399
-
400
- return $storeModel->getName();
401
- break;
402
- case 'group_id':
403
- $groupModel = Mage::getModel('customer/group')->load($value);
404
-
405
- return $groupModel->getCode();
406
- break;
407
- case 'country_id':
408
- $countryModel = Mage::getModel('directory/country')->load($value);
409
-
410
- return $countryModel->getName();
411
- break;
412
- default:
413
- break;
414
- }
415
-
416
- if ($_attributeBack == 'datetime' || $_attributeType == 'date') {
417
- $value = $this->_formatDateValue($value);
418
- }
419
-
420
- // Format Attribute Values
421
- switch ($_attributeType) {
422
- case 'select':
423
- return strtolower($attribute->getSource()->getOptionText($value));
424
- break;
425
- case 'boolean':
426
- return $value == 1 ? 'true' : 'false';
427
- case 'multiselect':
428
- $values = array();
429
- if (!is_array($value)) {
430
- $value = explode(',', $value);
431
- }
432
- if (!is_array($value)) {
433
- $value = array($value);
434
- }
435
-
436
- $source = $attribute->getSource();
437
- foreach ($value as $val) {
438
- $values[] = strtolower($source->getOptionText($val));
439
- }
440
-
441
- return implode(', ', $values);
442
- break;
443
- default:
444
- return $value;
445
- break;
446
- }
447
- }
448
-
449
- /**
450
- * Format the value into a Bronto acceptable date
451
- *
452
- * @param string $value
453
- * @return string
454
- */
455
- protected function _formatDateValue($value)
456
- {
457
- return date('c', strtotime($value));
458
- }
459
-
460
- /**
461
- * @param bool $brontoCron
462
- *
463
- * @return array
464
- */
465
- public function processCustomers($brontoCron = false)
466
- {
467
- $result = array(
468
- 'total' => 0,
469
- 'success' => 0,
470
- 'error' => 0,
471
- );
472
-
473
- // Only allow cron to run if isset to use mage cron or is coming from bronto cron
474
- if (Mage::helper('bronto_customer')->canUseMageCron() || $brontoCron) {
475
- $limit = Mage::helper('bronto_customer')->getLimit();
476
-
477
- $stores = Mage::app()->getStores(true);
478
- foreach ($stores as $_store) {
479
- if ($limit <= 0) {
480
- continue;
481
- }
482
- $storeResult = $this->processCustomersForStore($_store, $limit);
483
- $result['total'] += $storeResult['total'];
484
- $result['success'] += $storeResult['success'];
485
- $result['error'] += $storeResult['error'];
486
- $limit = $limit - $storeResult['total'];
487
- }
488
- }
489
-
490
- return $result;
491
- }
492
-
493
- /**
494
- * @param Varien_Event_Observer $observer
495
- */
496
- public function markCustomerForReimport(Varien_Event_Observer $observer)
497
- {
498
- /* @var $customer Mage_Customer_Model_Customer */
499
- $customer = $observer->getCustomer();
500
-
501
- /* @var $contactQueue Bronto_Customer_Model_Queue */
502
- Mage::getModel('bronto_customer/queue')
503
- ->getCustomerRow($customer->getId(), $customer->getStoreId())
504
- ->setCreatedAt($customer->getCreatedAt())
505
- ->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
506
- ->setBrontoImported(null)
507
- ->setBrontoSuppressed(null)
508
- ->save();
509
- }
510
-
511
- /**
512
- * Grab Config Data Object before save and handle the 'Create New...' value for
513
- * fields that were generated dynamically
514
- *
515
- * @param Varien_Event_Observer $observer
516
- *
517
- * @return Varien_Event_Observer
518
- */
519
- public function saveDynamicField(Varien_Event_Observer $observer)
520
- {
521
- $action = $observer->getEvent()->getControllerAction();
522
-
523
- if ($action->getRequest()->getParam('section') == 'bronto_customer') {
524
- $groups = $action->getRequest()->getPost('groups');
525
- $section = $action->getRequest()->getParam('section');
526
-
527
- // Pre-Process Fields to Strip out and Handle Dynamic Fields
528
- $groups = $this->_handleDynamicAttributes($groups, $section);
529
-
530
- // Replace Existing 'groups' data with newly stripped 'groups' data and pass on to be saved
531
- $observer->getEvent()->getControllerAction()->getRequest()->setPost('groups', $groups);
532
- }
533
-
534
- return $observer;
535
- }
536
-
537
- /**
538
- * Process customer and address attributes and save back to observer
539
- *
540
- * @param array $groups
541
- * @param string $section
542
- *
543
- * @return array
544
- */
545
- protected function _handleDynamicAttributes($groups, $section)
546
- {
547
- // Process Dynamic Customer Attribute Fields
548
- if (array_key_exists('attributes', $groups)) {
549
- $attrFieldsCustomer = $this->_processDynamicAttributes($groups['attributes']['fields'], $section, 'attributes');
550
- $groups['attributes']['fields'] = $attrFieldsCustomer;
551
- }
552
-
553
- foreach (Mage::helper('bronto_customer')->getAddressTypes() as $prefix => $methodName) {
554
- $key = "{$prefix}_attributes";
555
- // Process Dynamic Address Attribute Fields
556
- if (array_key_exists($key, $groups)) {
557
- $attrFieldsAddress = $this->_processDynamicAttributes($groups[$key]['fields'], $section, $key);
558
- $groups[$key]['fields'] = $attrFieldsAddress;
559
- }
560
- }
561
-
562
- // Return Updated Groups Data
563
- return $groups;
564
- }
565
-
566
- /**
567
- * Capture "Create New..." attributes, create field in Bronto, and save field id
568
- *
569
- * @param array $attributesFields
570
- * @param string $section
571
- * @param string $group
572
- *
573
- * @return array
574
- */
575
- protected function _processDynamicAttributes($attributesFields = array(), $section, $group)
576
- {
577
- // Create Config Object
578
- $config = Mage::getModel('core/config');
579
-
580
- // Get Admin Scope Parameters
581
- $scopeParams = Mage::helper('bronto_common')->getScopeParams();
582
-
583
- // Get Array of Attributes that are hard-coded into system.xml
584
- $ignore = Mage::helper('bronto_customer')->getSystemAttributes();
585
-
586
- $api = Mage::helper('bronto_common')->getApi();
587
-
588
- $fieldCache = array();
589
-
590
- // Cycle Through Attribute Fields to Find and Save Dynamic Fields
591
- foreach ($attributesFields as $fieldId => $field) {
592
- // Save Dynamic 'Create New...' Fields
593
- if (preg_match('/_dynamic_new/', $fieldId) || preg_match('/_new/', $fieldId)) {
594
- // Strip off '_dynamic_new' or '_new' from Field ID to Get real Field ID
595
- $realField = preg_replace('/_dynamic_new|_new$/', '', $fieldId);
596
-
597
- if (!is_array($field)) {
598
- $value = $field;
599
- } else {
600
- $value = $field['value'];
601
- }
602
-
603
- if (is_null($value)) {
604
- continue;
605
- }
606
-
607
- try {
608
- /* @var $fieldObject Bronto_Api_Field */
609
- $fieldObject = $api->transferField();
610
- $fieldName = Bronto_Utils::normalize($value);
611
-
612
- if (!array_key_exists($fieldName, $fieldCache)) {
613
- $brontoField = $fieldObject->getByName($fieldName);
614
- if (!$brontoField) {
615
- $brontoField = $fieldObject->createObject()
616
- ->withName($fieldName)
617
- ->withLabel($value)->asText()->asHidden();
618
- foreach ($fieldObject->add()->addField($brontoField) as $result) {
619
- $item = $result->getItem();
620
- if ($item->getIsError()) {
621
- Mage::throwException("{$item->getErrorCode()}: {$item->getErrorMessage()}");
622
- }
623
- $brontoField->withId($item->getId());
624
- }
625
- }
626
- $fieldCache[$fieldName] = $brontoField;
627
- }
628
-
629
- $scope = $scopeParams['scope'];
630
- if ($scope != 'default') {
631
- $scope .= 's';
632
- }
633
-
634
- // Save Field To Config
635
- $config->saveConfig(
636
- $section . '/' . $group . '/' . $realField,
637
- $brontoField->getId(),
638
- $scope,
639
- $scopeParams[$scopeParams['scope'] . '_id']
640
- );
641
-
642
- // Unset Dynamic Fields
643
- unset($attributesFields[$realField]);
644
- unset($attributesFields[$fieldId]);
645
- unset($fieldObject);
646
- } catch (Exception $e) {
647
- Mage::helper('bronto_customer')->writeError("Unable to save new field: {$value}: {$e->getMessage()}");
648
- }
649
- } // Save Dynamic Fields
650
- elseif (array_key_exists('value', $field) && !in_array($fieldId, $ignore[$group])) {
651
- $scope = $scopeParams['scope'];
652
- if ($scope != 'default') {
653
- $scope .= 's';
654
- }
655
-
656
- // Save Field To Config
657
- $config->saveConfig(
658
- $section . '/' . $group . '/' . $fieldId,
659
- array_key_exists('value', $field) ? $field['value'] : '',
660
- $scope,
661
- $scopeParams[$scopeParams['scope'] . '_id']
662
- );
663
-
664
- // Unset Dynamic Field
665
- unset($attributesFields[$fieldId]);
666
- }
667
- }
668
-
669
- return $attributesFields;
670
- }
671
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/Queue.php DELETED
@@ -1,117 +0,0 @@
1
- <?php
2
-
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
- {
9
- public function _construct()
10
- {
11
- parent::_construct();
12
- $this->_init('bronto_customer/queue');
13
- }
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)
24
- {
25
- // Create Collection
26
- $collection = $this->getCollection()
27
- ->addFieldToFilter('customer_id', $customerId)
28
- ->addFieldToFilter('store_id', $storeId);
29
-
30
- // Handle Results
31
- if ($collection->count() == 1) {
32
- return $collection->getFirstItem();
33
- } else {
34
- $this->setCustomerId($customerId)
35
- ->setStoreId($storeId);
36
- }
37
-
38
- return $this;
39
- }
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();
54
- $select->from(
55
- array('customer' => $resource->getTable('customer/entity')),
56
- array(new Zend_Db_Expr('COUNT(entity_id) as count'))
57
- )
58
- ->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter));
59
-
60
- // Get Results
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)
77
- {
78
- // Build Sub-Select Statement
79
- $subselect = $adapter->select()
80
- ->from(
81
- array('queue' => $resource->getTable('bronto_customer/queue')),
82
- array(new Zend_Db_Expr(1))
83
- )
84
- ->where('queue.customer_id = customer.entity_id');
85
-
86
- return $subselect;
87
- }
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();
102
-
103
- // Build Select Statement
104
- $select = $adapter->select();
105
- $select->from(
106
- array('customer' => $resource->getTable('customer/entity')),
107
- array('entity_id', 'created_at', 'store_id')
108
- )
109
- ->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter))
110
- ->limit($count);
111
-
112
- // Get Results
113
- $result = $adapter->query($select)->fetchAll();
114
-
115
- return $result;
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/Resource/Customer.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Customer_Model_Resource_Customer extends Mage_Customer_Model_Resource_Customer
4
- {
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- }
9
-
10
- /**
11
- * Retrieve customer entity default attributes
12
- *
13
- * @return array
14
- */
15
- protected function _getDefaultAttributes()
16
- {
17
- return array(
18
- 'entity_type_id',
19
- 'attribute_set_id',
20
- 'created_at',
21
- 'updated_at',
22
- 'increment_id',
23
- 'store_id',
24
- 'website_id',
25
- 'is_active' // This should be in here by default, but it isn't
26
- );
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/System/Config/Backend/Brontofield.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Customer
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Customer_Model_System_Config_Backend_Brontofield extends Mage_Core_Model_Config_Data
8
- {
9
- /**
10
- * Processing object before save data
11
- *
12
- * @return Mage_Core_Model_Abstract
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
-
24
- if ($fieldObject) {
25
- $attributes = null;
26
- if ('attributes' == $this->group_id) {
27
- $attributes = Mage::getModel('customer/entity_attribute_collection');
28
- } elseif ('address_attributes' == $this->group_id) {
29
- $attributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
30
- }
31
-
32
- if ($attributes) {
33
- foreach ($attributes as $attribute) {
34
- if ($this->field == $attribute->attribute_code) {
35
- if ($attribute->frontend_input != $fieldObject->type && $fieldObject->type != 'text') {
36
- $message = "Input type doesn't match: {$this->getFieldConfig()->label} [type: {$attribute->frontend_input}] => {$fieldObject->label} [type: {$fieldObject->type}]"
37
- . "... Please note that this could cause issues when attempting to import customers";
38
- // Throw Warning, but allow saving
39
- Mage::getSingleton('core/session')->addWarning(Mage::helper('adminhtml')->__($message));
40
- // Throw Exception and prevent saving
41
- // Mage::throwException(Mage::helper('adminhtml')->__($message));
42
- }
43
- }
44
- }
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
- {
61
- Mage::getModel('core/config_data')
62
- ->load($path, 'path')
63
- ->setValue($value)
64
- ->setPath($path)
65
- ->save();
66
-
67
- return $this;
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/Model/System/Config/Backend/Cron.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Customer
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Customer_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
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 DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Customer
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Customer_Model_System_Config_Backend_Newfield extends Mage_Core_Model_Config_Data
8
- {
9
- private static $_fieldCache = array();
10
-
11
- /**
12
- * Processing object before save data
13
- *
14
- * @return Mage_Core_Model_Abstract
15
- */
16
- protected function _beforeSave()
17
- {
18
- if ($this->isValueChanged()) {
19
- try {
20
- $fieldObject = Mage::helper('bronto_common')->getApi()->transferField();
21
- $fieldName = Bronto_Utils::normalize($this->getValue());
22
- if (!array_key_exists($fieldName, self::$_fieldCache)) {
23
- $field = $fieldObject->getByName($fieldName);
24
- if (!$field) {
25
- $field->withName($fieldName)->withLabel($this->getValue())->asText()->asHidden();
26
- $field->withId($fieldObject->add()->addField($field)->first()->getItem()->getId());
27
- }
28
- self::$_fieldCache[$fieldName] = $field;
29
- }
30
- $this->_saveConfigData(str_replace('_new', '', $this->getPath()), $field->getId());
31
- $this->setValue(null);
32
- } catch (Exception $e) {
33
- Mage::throwException(Mage::helper('adminhtml')->__('Unable to save new field: ') . $e->getMessage());
34
- }
35
- }
36
-
37
- return parent::_beforeSave();
38
- }
39
-
40
- /**
41
- * Save Configuration Data
42
- *
43
- * @param $path
44
- * @param $value
45
- *
46
- * @return $this
47
- */
48
- protected function _saveConfigData($path, $value)
49
- {
50
- $scopeParams = Mage::helper('bronto_common')->getScopeParams();
51
-
52
- $scope = $scopeParams['scope'];
53
- if ($scope != 'default') {
54
- $scope .= 's';
55
- }
56
-
57
- Mage::getModel('core/config_data')
58
- ->load($path, 'path')
59
- ->setValue($value)
60
- ->setPath($path)
61
- ->setScope($scope)
62
- ->setScopeId($scopeParams[$scopeParams['scope'] . '_id'])
63
- ->save();
64
-
65
- return $this;
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/controllers/Adminhtml/CustomerController.php DELETED
@@ -1,306 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @category Bronto
5
- * @package Bronto_Customer
6
- */
7
- class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action
8
- {
9
- /**
10
- * Run immediately
11
- */
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()) {
21
- if (!is_array($storeIds)) {
22
- $storeIds = array($storeIds);
23
- }
24
- foreach ($storeIds as $storeId) {
25
- if ($limit <= 0) {
26
- continue;
27
- }
28
- $storeResult = $model->processCustomersForStore($storeId, $limit);
29
- $result['total'] += $storeResult['total'];
30
- $result['success'] += $storeResult['success'];
31
- $result['error'] += $storeResult['error'];
32
- $limit = $limit - $storeResult['total'];
33
- }
34
- } else {
35
- $result = $model->processCustomers(true);
36
- }
37
-
38
- if (is_array($result)) {
39
- $this->_getSession()->addSuccess(sprintf("Processed %d Customers (%d Error / %d Success)", $result['total'], $result['error'], $result['success']));
40
- } else {
41
- $this->_getSession()->addError('Scheduled Import failed: ' . $result);
42
- }
43
-
44
- } catch (Exception $e) {
45
- $this->_getSession()->addError($e->getMessage());
46
- $helper->writeError($e);
47
- }
48
-
49
- $returnParams = array('section' => 'bronto_customer');
50
- $returnParams = array_merge($returnParams, $helper->getScopeParams());
51
- $this->_redirect('*/system_config/edit', $returnParams);
52
- }
53
-
54
- /**
55
- * Marks all Customers as imported
56
- */
57
- public function markAction()
58
- {
59
- $helper = Mage::helper('bronto_customer');
60
- $resource = Mage::getResourceModel('bronto_customer/queue');
61
- $adapter = $resource->getWriteAdapter();
62
-
63
- try {
64
- $date = Mage::getSingleton('core/date')->gmtDate();
65
- $adapter->update(
66
- $resource->getTable('bronto_customer/queue'),
67
- array('bronto_imported' => $date),
68
- array(
69
- 'bronto_imported IS NULL' => '',
70
- 'bronto_suppressed IS NULL' => ''
71
- ));
72
- $helper->writeInfo("Mark All Customers was explicitly pressed.");
73
- } catch (Exception $e) {
74
- $helper->writeError($e);
75
- $this->_getSession()->addError('Mark All failed: ' . $e->getMessage());
76
- }
77
-
78
- $returnParams = array('section' => 'bronto_customer');
79
- $returnParams = array_merge($returnParams, $helper->getScopeParams());
80
- $this->_redirect('*/system_config/edit', $returnParams);
81
- }
82
-
83
- /**
84
- * Reset all Customers
85
- */
86
- public function resetAction()
87
- {
88
- $helper = Mage::helper('bronto_customer');
89
- $storeIds = $helper->getStoreIds();
90
- $resource = Mage::getResourceModel('bronto_customer/queue');
91
- $adapter = $resource->getWriteAdapter();
92
-
93
- $queue_id = $this->getRequest()->getParam('queue_id', false);
94
- $suppressed = $this->getRequest()->getParam('suppressed', false);
95
-
96
- $where = array();
97
- if ($storeIds) {
98
- $where = array('store_id IN (?)' => $storeIds);
99
- }
100
-
101
- if ($queue_id) {
102
- $where['queue_id = ?'] = $queue_id;
103
- }
104
-
105
- if ($suppressed) {
106
- $where['bronto_suppressed IS NOT NULL'] = '';
107
- }
108
-
109
- try {
110
- $adapter->update(
111
- $resource->getTable('bronto_customer/queue'),
112
- array(
113
- 'bronto_imported' => null,
114
- 'bronto_suppressed' => null,
115
- ),
116
- $where
117
- );
118
- } catch (Exception $e) {
119
- $helper->writeError($e);
120
- $this->_getSession()->addError('Reset failed: ' . $e->getMessage());
121
- }
122
-
123
- $returnParams = array('section' => 'bronto_customer');
124
- $returnParams = array_merge($returnParams, $helper->getScopeParams());
125
- $this->_redirect('*/system_config/edit', $returnParams);
126
- }
127
-
128
- /**
129
- * Pull Customers from Customer Table if not in queue
130
- */
131
- public function syncAction()
132
- {
133
- $helper = Mage::helper('bronto_customer');
134
- $imported = 0;
135
-
136
- try {
137
- $customers = Mage::helper('bronto_customer')->getMissingCustomers();
138
- $waiting = count($customers);
139
-
140
- if ($waiting > 0) {
141
- foreach ($customers as $customer) {
142
- Mage::getModel('bronto_customer/queue')->getCustomerRow($customer['entity_id'], $customer['store_id'])
143
- ->setCreatedAt($customer['created_at'])
144
- ->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
145
- ->setBrontoImported(0)
146
- ->save();
147
-
148
- $imported++;
149
- }
150
- }
151
- } catch (Exception $e) {
152
- Mage::helper('bronto_customer')->writeError($e);
153
- $this->_getSession()->addError('Sync failed: ' . $e->getMessage());
154
- }
155
-
156
- if ($imported == $waiting && $waiting == 0) {
157
- $this->_getSession()->addSuccess($helper->__('All Customers are synced to the queue.'));
158
- } else {
159
- $this->_getSession()->addSuccess(sprintf("%d of %d Customers were added to the Queue", $imported, $waiting));
160
- }
161
- $returnParams = array('section' => 'bronto_customer');
162
- $returnParams = array_merge($returnParams, $helper->getScopeParams());
163
- $this->_redirect('*/system_config/edit', $returnParams);
164
- }
165
-
166
- /**
167
- * Action to handle providing suppression table in config page
168
- */
169
- public function suppressionAction()
170
- {
171
- $request = $this->getRequest();
172
- $page = $request->getParam('page', 1);
173
- $limit = 10;
174
-
175
- // Get Suppressed Items
176
- $suppressed = array();
177
- $collection = Mage::getModel('bronto_customer/queue')->getCollection()
178
- ->addBrontoSuppressedFilter()
179
- ->addStoreFilter(Mage::helper('bronto_common')->getStoreIds())
180
- ->orderByUpdatedAt()
181
- ->setPageSize($limit)
182
- ->setCurPage($page);
183
-
184
- $items = $collection->getItems();
185
- foreach ($items as $item) {
186
- $customerName = Mage::getModel('customer/customer')->load($item->getCustomerId())->getName();
187
- $customerEmail = Mage::getModel('customer/customer')->load($item->getCustomerId())->getEmail();
188
- $customerLink = Mage::helper('bronto_common')->getScopeUrl('/customer/edit/', array('id' => $item->getCustomerId()));
189
- $storeName = Mage::getModel('core/store')->load($item->getStoreId())->getName();
190
- $resetLink = Mage::helper('bronto_common')->getScopeUrl('adminhtml/customer/reset', array('queue_id' => $item->getId()));
191
- $suppressed[] = array(
192
- 'updated_at' => $item->getUpdatedAt(),
193
- 'customer' => "<a href=\"{$customerLink}\">{$customerName}</a>",
194
- 'email' => $customerEmail,
195
- 'store_id' => $storeName,
196
- 'reason' => $item->getBrontoSuppressed(),
197
- 'action' => "<a href=\"{$resetLink}\">Reset</a>",
198
- );
199
- }
200
-
201
- $prevPage = ($page > 1) ? $page - 1 : false;
202
-
203
- $remaining = $collection->getSize() - ($limit * $page);
204
- $nextPage = ($remaining > 0) ? $page + 1 : false;
205
-
206
- $html = $this->_getSuppressionTableHtml($suppressed, $prevPage, $nextPage);
207
-
208
- $this->getResponse()->setBody($html);
209
- }
210
-
211
- /**
212
- * Get HTML table for suppression items
213
- *
214
- * @param $suppressedItems
215
- * @param $prevPage
216
- * @param $nextPage
217
- *
218
- * @return string
219
- */
220
- protected function _getSuppressionTableHtml($suppressedItems, $prevPage, $nextPage)
221
- {
222
- $html = '';
223
- if ($prevPage) {
224
- $html .= '<div class="bronto-suppression-interface-control previous" onclick="loadSuppressionTable(' . $prevPage . ')">Load Newer</div>';
225
- }
226
- $html .= '
227
- <table class="border">
228
- <thead>
229
- <tr class="headings">
230
- <th style="white-space: nowrap">Date Suppressed</th>
231
- <th style="white-space: nowrap">Customer</th>
232
- <th style="white-space: nowrap">Customer Email</th>
233
- <th style="white-space: nowrap">Store</th>
234
- <th width="100%">Reason for Suppression</th>
235
- <th style="white-space: nowrap">Action</th>
236
- </tr>
237
- </thead>
238
- <tbody>';
239
-
240
- if (count($suppressedItems)) {
241
- foreach ($suppressedItems as $suppressed) {
242
- $html .= '<tr>';
243
- foreach ($suppressed as $value) {
244
- $html .= "<td style=\"white-space: nowrap\">{$value}</td>";
245
- }
246
- $html .= '</tr>';
247
- }
248
- } else {
249
- $html .= '<tr><td colspan="6"><strong>No Suppressed Items</strong></td></tr>';
250
- }
251
-
252
- $html .= '
253
- </tbody>
254
- </table>';
255
- if ($nextPage) {
256
- $html .= '<div class="bronto-suppression-interface-control next" onclick="loadSuppressionTable(' . $nextPage . ')">Load Older</div>';
257
- }
258
-
259
- return $html;
260
- }
261
-
262
- /**
263
- * @return bool
264
- */
265
- protected function _isAllowed()
266
- {
267
- return $this->_isSectionAllowed('bronto_customer');
268
- }
269
-
270
- /**
271
- * Check if specified section allowed in ACL
272
- *
273
- * Will forward to deniedAction(), if not allowed.
274
- *
275
- * @param string $section
276
- *
277
- * @return bool
278
- */
279
- protected function _isSectionAllowed($section)
280
- {
281
- try {
282
- $session = Mage::getSingleton('admin/session');
283
- $resourceLookup = "admin/system/config/{$section}";
284
- if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
285
- $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId();
286
- if (!$session->isAllowed($resourceId)) {
287
- throw new Exception('');
288
- }
289
-
290
- return true;
291
- }
292
- } catch (Zend_Acl_Exception $e) {
293
- $this->norouteAction();
294
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
295
-
296
- return false;
297
- } catch (Exception $e) {
298
- $this->deniedAction();
299
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
300
-
301
- return false;
302
- }
303
-
304
- return false;
305
- }
306
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/etc/adminhtml.xml DELETED
@@ -1,23 +0,0 @@
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_customer module="bronto_customer">
12
- <title>Bronto Contact Import Section</title>
13
- <sort_order>9994</sort_order>
14
- </bronto_customer>
15
- </children>
16
- </config>
17
- </children>
18
- </system>
19
- </children>
20
- </admin>
21
- </resources>
22
- </acl>
23
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/etc/config.xml DELETED
@@ -1,157 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Bronto_Customer>
5
- <version>1.0.3</version>
6
- </Bronto_Customer>
7
- </modules>
8
- <global>
9
- <blocks>
10
- <bronto_customer>
11
- <class>Bronto_Customer_Block</class>
12
- </bronto_customer>
13
- </blocks>
14
- <helpers>
15
- <bronto_customer>
16
- <class>Bronto_Customer_Helper</class>
17
- </bronto_customer>
18
- </helpers>
19
- <models>
20
- <bronto_customer>
21
- <class>Bronto_Customer_Model</class>
22
- <resourceModel>bronto_customer_mysql4</resourceModel>
23
- </bronto_customer>
24
- <bronto_customer_resource>
25
- <rewrite>
26
- <customer_resource>Bronto_Company_Model_Resource_Customer</customer_resource>
27
- </rewrite>
28
- </bronto_customer_resource>
29
- <bronto_customer_mysql4>
30
- <class>Bronto_Customer_Model_Mysql4</class>
31
- <entities>
32
- <queue>
33
- <table>bronto_customer_queue</table>
34
- </queue>
35
- </entities>
36
- </bronto_customer_mysql4>
37
- </models>
38
- <resources>
39
- <bronto_customer_setup>
40
- <setup>
41
- <module>Bronto_Customer</module>
42
- <class>Bronto_Customer_Model_Mysql4_Setup</class>
43
- </setup>
44
- <connection>
45
- <use>core_setup</use>
46
- </connection>
47
- </bronto_customer_setup>
48
- <bronto_customer_write>
49
- <connection>
50
- <use>core_write</use>
51
- </connection>
52
- </bronto_customer_write>
53
- <bronto_customer_read>
54
- <connection>
55
- <use>core_read</use>
56
- </connection>
57
- </bronto_customer_read>
58
- </resources>
59
- <events>
60
- <customer_save_after>
61
- <observers>
62
- <bronto_customer_sales_customer_save_after>
63
- <type>singleton</type>
64
- <class>bronto_customer/observer</class>
65
- <method>markCustomerForReimport</method>
66
- </bronto_customer_sales_customer_save_after>
67
- </observers>
68
- </customer_save_after>
69
- <controller_action_predispatch_adminhtml_system_config_save>
70
- <observers>
71
- <bronto_customer_controller_action_postdispatch_adminhtml_system_config_save>
72
- <type>singleton</type>
73
- <class>bronto_customer/observer</class>
74
- <method>saveDynamicField</method>
75
- </bronto_customer_controller_action_postdispatch_adminhtml_system_config_save>
76
- </observers>
77
- </controller_action_predispatch_adminhtml_system_config_save>
78
- </events>
79
- </global>
80
- <admin>
81
- <routers>
82
- <adminhtml>
83
- <args>
84
- <modules>
85
- <bronto_customer before="Mage_Adminhtml">Bronto_Customer_Adminhtml</bronto_customer>
86
- </modules>
87
- </args>
88
- </adminhtml>
89
- </routers>
90
- </admin>
91
- <adminhtml>
92
- <events>
93
- <bronto_customer_enable>
94
- <observers>
95
- <bronto_customer_enable>
96
- <type>singleton</type>
97
- <class>bronto_customer/observer</class>
98
- <method>watchEnableAction</method>
99
- </bronto_customer_enable>
100
- </observers>
101
- </bronto_customer_enable>
102
- </events>
103
- </adminhtml>
104
- <default>
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>
112
- <limit>100</limit>
113
- <sync_limit>1000</sync_limit>
114
- </settings>
115
- <attributes>
116
- <prefix>_none_</prefix>
117
- <firstname>firstname</firstname>
118
- <middlename>_none_</middlename>
119
- <lastname>lastname</lastname>
120
- <suffix>_none_</suffix>
121
- <gender>gender</gender>
122
- <dob>birthday</dob>
123
- <taxvat>_none_</taxvat>
124
- <website_id>_none_</website_id>
125
- <group_id>_none_</group_id>
126
- <created_at>_none_</created_at>
127
- <created_in>_none_</created_in>
128
- </attributes>
129
- <address_attributes>
130
- <street>address1</street>
131
- <city>city</city>
132
- <region>state</region>
133
- <postcode>postal_code</postcode>
134
- <country_id>country</country_id>
135
- <company>_none_</company>
136
- <telephone>phone_home</telephone>
137
- <fax>_none_</fax>
138
- </address_attributes>
139
- </bronto_customer>
140
- </default>
141
- <crontab>
142
- <jobs>
143
- <bronto_customer_import>
144
- <run>
145
- <model>bronto_customer/observer::processCustomers</model>
146
- </run>
147
- </bronto_customer_import>
148
- </jobs>
149
- </crontab>
150
- <phpunit>
151
- <suite>
152
- <modules>
153
- <Bronto_Customer/>
154
- </modules>
155
- </suite>
156
- </phpunit>
157
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/etc/system.xml DELETED
@@ -1,1007 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <sections>
4
- <bronto_customer module="bronto_customer">
5
- <label>Contact Import</label>
6
- <tab>bronto</tab>
7
- <frontend_type>text</frontend_type>
8
- <sort_order>200</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_customer/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>5</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
- <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>
65
- <backend_model>bronto_customer/system_config_backend_cron</backend_model>
66
- <sort_order>20</sort_order>
67
- <show_in_default>1</show_in_default>
68
- <show_in_website>1</show_in_website>
69
- <show_in_store>1</show_in_store>
70
- </frequency>
71
- <interval>
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>
79
- <sort_order>30</sort_order>
80
- <show_in_default>1</show_in_default>
81
- <show_in_website>1</show_in_website>
82
- <show_in_store>1</show_in_store>
83
- <comment>Set this value larger than your cron.php launch period.</comment>
84
- </interval>
85
- <minutes>
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>
93
- <show_in_default>1</show_in_default>
94
- <show_in_website>1</show_in_website>
95
- <show_in_store>1</show_in_store>
96
- <comment>Valid range: 0-59 (default 0).</comment>
97
- </minutes>
98
- <time>
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>
112
- <depends>
113
- <enabled>1</enabled>
114
- </depends>
115
- <frontend_type>select</frontend_type>
116
- <source_model>bronto_common/system_config_source_limit</source_model>
117
- <sort_order>60</sort_order>
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>
125
- <depends>
126
- <enabled>1</enabled>
127
- </depends>
128
- <frontend_type>select</frontend_type>
129
- <source_model>bronto_common/system_config_source_synclimit</source_model>
130
- <sort_order>65</sort_order>
131
- <show_in_default>1</show_in_default>
132
- <show_in_website>1</show_in_website>
133
- <show_in_store>1</show_in_store>
134
- <comment>Total Customers to sync to queue at a time.</comment>
135
- </sync_limit>
136
- </fields>
137
- </settings>
138
- <cron_list>
139
- <frontend_type>text</frontend_type>
140
- <frontend_model>bronto_customer/adminhtml_system_config_cron</frontend_model>
141
- <sort_order>6</sort_order>
142
- <show_in_default>1</show_in_default>
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
- <fields>
156
- <reset>
157
- <label>Reset All Suppressed Customers</label>
158
- <frontend_type>text</frontend_type>
159
- <frontend_model>bronto_common/adminhtml_system_config_suppressed_reset</frontend_model>
160
- <sort_order>0</sort_order>
161
- <show_in_default>1</show_in_default>
162
- <show_in_website>1</show_in_website>
163
- <show_in_store>1</show_in_store>
164
- </reset>
165
- </fields>
166
- </suppressed>
167
- <attributes>
168
- <label>Customer Attributes</label>
169
- <frontend_type>text</frontend_type>
170
- <frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_customer
171
- </frontend_model>
172
- <sort_order>10</sort_order>
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
- <fields>
177
- <!-- prefix -->
178
- <prefix>
179
- <sort_order>1</sort_order>
180
- <label>Prefix</label>
181
- <frontend_type>select</frontend_type>
182
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
183
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
184
- <source_model>bronto_common/system_config_source_field</source_model>
185
- <show_in_default>1</show_in_default>
186
- <show_in_website>1</show_in_website>
187
- <show_in_store>1</show_in_store>
188
- </prefix>
189
- <prefix_new>
190
- <sort_order>2</sort_order>
191
- <frontend_type>text</frontend_type>
192
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
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
- <depends>
197
- <prefix>_new_</prefix>
198
- </depends>
199
- </prefix_new>
200
- <!-- firstname -->
201
- <firstname>
202
- <sort_order>5</sort_order>
203
- <label>First Name</label>
204
- <frontend_type>select</frontend_type>
205
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
206
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
207
- <source_model>bronto_common/system_config_source_field</source_model>
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
- </firstname>
212
- <firstname_new>
213
- <sort_order>6</sort_order>
214
- <frontend_type>text</frontend_type>
215
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
216
- <show_in_default>1</show_in_default>
217
- <show_in_website>1</show_in_website>
218
- <show_in_store>1</show_in_store>
219
- <depends>
220
- <firstname>_new_</firstname>
221
- </depends>
222
- </firstname_new>
223
- <!-- middlename -->
224
- <middlename>
225
- <sort_order>10</sort_order>
226
- <label>Middle Name/Initial</label>
227
- <frontend_type>select</frontend_type>
228
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
229
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
230
- <source_model>bronto_common/system_config_source_field</source_model>
231
- <show_in_default>1</show_in_default>
232
- <show_in_website>1</show_in_website>
233
- <show_in_store>1</show_in_store>
234
- </middlename>
235
- <middlename_new>
236
- <sort_order>11</sort_order>
237
- <frontend_type>text</frontend_type>
238
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
239
- <show_in_default>1</show_in_default>
240
- <show_in_website>1</show_in_website>
241
- <show_in_store>1</show_in_store>
242
- <depends>
243
- <middlename>_new_</middlename>
244
- </depends>
245
- </middlename_new>
246
- <!-- lastname -->
247
- <lastname>
248
- <sort_order>15</sort_order>
249
- <label>Last Name</label>
250
- <frontend_type>select</frontend_type>
251
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
252
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
253
- <source_model>bronto_common/system_config_source_field</source_model>
254
- <show_in_default>1</show_in_default>
255
- <show_in_website>1</show_in_website>
256
- <show_in_store>1</show_in_store>
257
- </lastname>
258
- <lastname_new>
259
- <sort_order>16</sort_order>
260
- <frontend_type>text</frontend_type>
261
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
262
- <show_in_default>1</show_in_default>
263
- <show_in_website>1</show_in_website>
264
- <show_in_store>1</show_in_store>
265
- <depends>
266
- <lastname>_new_</lastname>
267
- </depends>
268
- </lastname_new>
269
- <!-- suffix -->
270
- <suffix>
271
- <sort_order>20</sort_order>
272
- <label>Suffix</label>
273
- <frontend_type>select</frontend_type>
274
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
275
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
276
- <source_model>bronto_common/system_config_source_field</source_model>
277
- <show_in_default>1</show_in_default>
278
- <show_in_website>1</show_in_website>
279
- <show_in_store>1</show_in_store>
280
- </suffix>
281
- <suffix_new>
282
- <sort_order>21</sort_order>
283
- <frontend_type>text</frontend_type>
284
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
285
- <show_in_default>1</show_in_default>
286
- <show_in_website>1</show_in_website>
287
- <show_in_store>1</show_in_store>
288
- <depends>
289
- <suffix>_new_</suffix>
290
- </depends>
291
- </suffix_new>
292
- <!-- gender -->
293
- <gender>
294
- <sort_order>25</sort_order>
295
- <label>Gender</label>
296
- <frontend_type>select</frontend_type>
297
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
298
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
299
- <source_model>bronto_common/system_config_source_field</source_model>
300
- <show_in_default>1</show_in_default>
301
- <show_in_website>1</show_in_website>
302
- <show_in_store>1</show_in_store>
303
- </gender>
304
- <gender_new>
305
- <sort_order>26</sort_order>
306
- <frontend_type>text</frontend_type>
307
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
308
- <show_in_default>1</show_in_default>
309
- <show_in_website>1</show_in_website>
310
- <show_in_store>1</show_in_store>
311
- <depends>
312
- <gender>_new_</gender>
313
- </depends>
314
- </gender_new>
315
- <!-- dob -->
316
- <dob>
317
- <sort_order>30</sort_order>
318
- <label>Date of Birth</label>
319
- <frontend_type>select</frontend_type>
320
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
321
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
322
- <source_model>bronto_common/system_config_source_field</source_model>
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
- </dob>
327
- <dob_new>
328
- <sort_order>31</sort_order>
329
- <frontend_type>text</frontend_type>
330
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
331
- <show_in_default>1</show_in_default>
332
- <show_in_website>1</show_in_website>
333
- <show_in_store>1</show_in_store>
334
- <depends>
335
- <dob>_new_</dob>
336
- </depends>
337
- </dob_new>
338
- <!-- taxvat -->
339
- <taxvat>
340
- <sort_order>35</sort_order>
341
- <label>Tax/VAT Number</label>
342
- <frontend_type>select</frontend_type>
343
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
344
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
345
- <source_model>bronto_common/system_config_source_field</source_model>
346
- <show_in_default>1</show_in_default>
347
- <show_in_website>1</show_in_website>
348
- <show_in_store>1</show_in_store>
349
- </taxvat>
350
- <taxvat_new>
351
- <sort_order>36</sort_order>
352
- <frontend_type>text</frontend_type>
353
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
354
- <show_in_default>1</show_in_default>
355
- <show_in_website>1</show_in_website>
356
- <show_in_store>1</show_in_store>
357
- <depends>
358
- <taxvat>_new_</taxvat>
359
- </depends>
360
- </taxvat_new>
361
- <!-- website_id -->
362
- <website_id>
363
- <sort_order>40</sort_order>
364
- <label>Website Association</label>
365
- <frontend_type>select</frontend_type>
366
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
367
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
368
- <source_model>bronto_common/system_config_source_field</source_model>
369
- <show_in_default>1</show_in_default>
370
- <show_in_website>1</show_in_website>
371
- <show_in_store>1</show_in_store>
372
- </website_id>
373
- <website_id_new>
374
- <sort_order>41</sort_order>
375
- <frontend_type>text</frontend_type>
376
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
377
- <show_in_default>1</show_in_default>
378
- <show_in_website>1</show_in_website>
379
- <show_in_store>1</show_in_store>
380
- <depends>
381
- <website_id>_new_</website_id>
382
- </depends>
383
- </website_id_new>
384
- <!-- group_id -->
385
- <group_id>
386
- <sort_order>45</sort_order>
387
- <label>Customer Group</label>
388
- <frontend_type>select</frontend_type>
389
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
390
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
391
- <source_model>bronto_common/system_config_source_field</source_model>
392
- <show_in_default>1</show_in_default>
393
- <show_in_website>1</show_in_website>
394
- <show_in_store>1</show_in_store>
395
- </group_id>
396
- <group_id_new>
397
- <sort_order>46</sort_order>
398
- <frontend_type>text</frontend_type>
399
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
400
- <show_in_default>1</show_in_default>
401
- <show_in_website>1</show_in_website>
402
- <show_in_store>1</show_in_store>
403
- <depends>
404
- <group_id>_new_</group_id>
405
- </depends>
406
- </group_id_new>
407
- <!-- created_at -->
408
- <created_at>
409
- <sort_order>50</sort_order>
410
- <label>Created At</label>
411
- <frontend_type>select</frontend_type>
412
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
413
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
414
- <source_model>bronto_common/system_config_source_field</source_model>
415
- <show_in_default>1</show_in_default>
416
- <show_in_website>1</show_in_website>
417
- <show_in_store>1</show_in_store>
418
- </created_at>
419
- <created_at_new>
420
- <sort_order>51</sort_order>
421
- <frontend_type>text</frontend_type>
422
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
423
- <show_in_default>1</show_in_default>
424
- <show_in_website>1</show_in_website>
425
- <show_in_store>1</show_in_store>
426
- <depends>
427
- <created_at>_new_</created_at>
428
- </depends>
429
- </created_at_new>
430
- <!-- created_in -->
431
- <created_in>
432
- <sort_order>55</sort_order>
433
- <label>Created From</label>
434
- <frontend_type>select</frontend_type>
435
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
436
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
437
- <source_model>bronto_common/system_config_source_field</source_model>
438
- <show_in_default>1</show_in_default>
439
- <show_in_website>1</show_in_website>
440
- <show_in_store>1</show_in_store>
441
- </created_in>
442
- <created_in_new>
443
- <sort_order>56</sort_order>
444
- <frontend_type>text</frontend_type>
445
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
446
- <show_in_default>1</show_in_default>
447
- <show_in_website>1</show_in_website>
448
- <show_in_store>1</show_in_store>
449
- <depends>
450
- <created_in>_new_</created_in>
451
- </depends>
452
- </created_in_new>
453
- <store_credit>
454
- <sort_order>60</sort_order>
455
- <label>Store Credit</label>
456
- <frontend_type>select</frontend_type>
457
- <frontend_model>bronto_customer/adminhtml_system_config_form_field_storecredit
458
- </frontend_model>
459
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
460
- <source_model>bronto_common/system_config_source_field</source_model>
461
- <show_in_default>1</show_in_default>
462
- <show_in_website>1</show_in_website>
463
- <show_in_store>1</show_in_store>
464
- </store_credit>
465
- <store_credit_new>
466
- <sort_order>61</sort_order>
467
- <frontend_type>text</frontend_type>
468
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
469
- <show_in_default>1</show_in_default>
470
- <show_in_website>1</show_in_website>
471
- <show_in_store>1</show_in_store>
472
- <depends>
473
- <store_credit>_new_</store_credit>
474
- </depends>
475
- </store_credit_new>
476
- <reward_points>
477
- <sort_order>65</sort_order>
478
- <label>Reward Points Balance</label>
479
- <frontend_type>select</frontend_type>
480
- <frontend_model>bronto_customer/adminhtml_system_config_form_field_rewardpoints
481
- </frontend_model>
482
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
483
- <source_model>bronto_common/system_config_source_field</source_model>
484
- <show_in_default>1</show_in_default>
485
- <show_in_website>1</show_in_website>
486
- <show_in_store>1</show_in_store>
487
- </reward_points>
488
- <reward_points_new>
489
- <sort_order>66</sort_order>
490
- <frontend_type>text</frontend_type>
491
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
492
- <show_in_default>1</show_in_default>
493
- <show_in_website>1</show_in_website>
494
- <show_in_store>1</show_in_store>
495
- <depends>
496
- <reward_points>_new_</reward_points>
497
- </depends>
498
- </reward_points_new>
499
- <reward_points_dollars>
500
- <sort_order>70</sort_order>
501
- <label>Reward Points Currency Amount</label>
502
- <frontend_type>select</frontend_type>
503
- <frontend_model>bronto_customer/adminhtml_system_config_form_field_rewardpoints
504
- </frontend_model>
505
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
506
- <source_model>bronto_common/system_config_source_field</source_model>
507
- <show_in_default>1</show_in_default>
508
- <show_in_website>1</show_in_website>
509
- <show_in_store>1</show_in_store>
510
- </reward_points_dollars>
511
- <reward_points_dollars_new>
512
- <sort_order>71</sort_order>
513
- <frontend_type>text</frontend_type>
514
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
515
- <show_in_default>1</show_in_default>
516
- <show_in_website>1</show_in_website>
517
- <show_in_store>1</show_in_store>
518
- <depends>
519
- <reward_points_dollars>_new_</reward_points_dollars>
520
- </depends>
521
- </reward_points_dollars_new>
522
- </fields>
523
- </attributes>
524
- <address_attributes>
525
- <label>Default Shipping Address</label>
526
- <frontend_type>text</frontend_type>
527
- <frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_address
528
- </frontend_model>
529
- <sort_order>15</sort_order>
530
- <show_in_default>1</show_in_default>
531
- <show_in_website>1</show_in_website>
532
- <show_in_store>1</show_in_store>
533
- <fields>
534
- <!-- street -->
535
- <street>
536
- <sort_order>1</sort_order>
537
- <label>Street Address</label>
538
- <frontend_type>select</frontend_type>
539
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
540
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
541
- <source_model>bronto_common/system_config_source_field</source_model>
542
- <show_in_default>1</show_in_default>
543
- <show_in_website>1</show_in_website>
544
- <show_in_store>1</show_in_store>
545
- </street>
546
- <street_new>
547
- <sort_order>2</sort_order>
548
- <frontend_type>text</frontend_type>
549
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
550
- <show_in_default>1</show_in_default>
551
- <show_in_website>1</show_in_website>
552
- <show_in_store>1</show_in_store>
553
- <depends>
554
- <street>_new_</street>
555
- </depends>
556
- </street_new>
557
- <!-- city -->
558
- <city>
559
- <sort_order>5</sort_order>
560
- <label>City</label>
561
- <frontend_type>select</frontend_type>
562
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
563
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
564
- <source_model>bronto_common/system_config_source_field</source_model>
565
- <show_in_default>1</show_in_default>
566
- <show_in_website>1</show_in_website>
567
- <show_in_store>1</show_in_store>
568
- </city>
569
- <city_new>
570
- <sort_order>6</sort_order>
571
- <frontend_type>text</frontend_type>
572
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
573
- <show_in_default>1</show_in_default>
574
- <show_in_website>1</show_in_website>
575
- <show_in_store>1</show_in_store>
576
- <depends>
577
- <city>_new_</city>
578
- </depends>
579
- </city_new>
580
- <!-- region -->
581
- <region>
582
- <sort_order>10</sort_order>
583
- <label>State/Province Name</label>
584
- <frontend_type>select</frontend_type>
585
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
586
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
587
- <source_model>bronto_common/system_config_source_field</source_model>
588
- <show_in_default>1</show_in_default>
589
- <show_in_website>1</show_in_website>
590
- <show_in_store>1</show_in_store>
591
- </region>
592
- <region_new>
593
- <sort_order>11</sort_order>
594
- <frontend_type>text</frontend_type>
595
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
596
- <show_in_default>1</show_in_default>
597
- <show_in_website>1</show_in_website>
598
- <show_in_store>1</show_in_store>
599
- <depends>
600
- <region>_new_</region>
601
- </depends>
602
- </region_new>
603
- <region_code_id>
604
- <sort_order>12</sort_order>
605
- <label>State/Province Code</label>
606
- <frontend_type>select</frontend_type>
607
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
608
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
609
- <source_model>bronto_common/system_config_source_field</source_model>
610
- <show_in_default>1</show_in_default>
611
- <show_in_website>1</show_in_website>
612
- <show_in_store>1</show_in_store>
613
- </region_code_id>
614
- <region_code_id_new>
615
- <sort_order>13</sort_order>
616
- <frontend_type>text</frontend_type>
617
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
618
- <show_in_default>1</show_in_default>
619
- <show_in_website>1</show_in_website>
620
- <show_in_store>1</show_in_store>
621
- <depends>
622
- <region_code_id>_new_</region_code_id>
623
- </depends>
624
- </region_code_id_new>
625
- <!-- postcode -->
626
- <postcode>
627
- <sort_order>15</sort_order>
628
- <label>Zip/Postal Code</label>
629
- <frontend_type>select</frontend_type>
630
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
631
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
632
- <source_model>bronto_common/system_config_source_field</source_model>
633
- <show_in_default>1</show_in_default>
634
- <show_in_website>1</show_in_website>
635
- <show_in_store>1</show_in_store>
636
- </postcode>
637
- <postcode_new>
638
- <sort_order>16</sort_order>
639
- <frontend_type>text</frontend_type>
640
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
641
- <show_in_default>1</show_in_default>
642
- <show_in_website>1</show_in_website>
643
- <show_in_store>1</show_in_store>
644
- <depends>
645
- <postcode>_new_</postcode>
646
- </depends>
647
- </postcode_new>
648
- <!-- country_id -->
649
- <country_id>
650
- <sort_order>20</sort_order>
651
- <label>Country Name</label>
652
- <frontend_type>select</frontend_type>
653
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
654
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
655
- <source_model>bronto_common/system_config_source_field</source_model>
656
- <show_in_default>1</show_in_default>
657
- <show_in_website>1</show_in_website>
658
- <show_in_store>1</show_in_store>
659
- </country_id>
660
- <country_id_new>
661
- <sort_order>21</sort_order>
662
- <frontend_type>text</frontend_type>
663
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
664
- <show_in_default>1</show_in_default>
665
- <show_in_website>1</show_in_website>
666
- <show_in_store>1</show_in_store>
667
- <depends>
668
- <country_id>_new_</country_id>
669
- </depends>
670
- </country_id_new>
671
- <country_code_id>
672
- <sort_order>22</sort_order>
673
- <label>Country Code</label>
674
- <frontend_type>select</frontend_type>
675
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
676
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
677
- <source_model>bronto_common/system_config_source_field</source_model>
678
- <show_in_default>1</show_in_default>
679
- <show_in_website>1</show_in_website>
680
- <show_in_store>1</show_in_store>
681
- </country_code_id>
682
- <country_code_id_new>
683
- <sort_order>23</sort_order>
684
- <frontend_type>text</frontend_type>
685
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
686
- <show_in_default>1</show_in_default>
687
- <show_in_website>1</show_in_website>
688
- <show_in_store>1</show_in_store>
689
- <depends>
690
- <country_code_id>_new_</country_code_id>
691
- </depends>
692
- </country_code_id_new>
693
- <!-- company -->
694
- <company>
695
- <sort_order>25</sort_order>
696
- <label>Company</label>
697
- <frontend_type>select</frontend_type>
698
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
699
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
700
- <source_model>bronto_common/system_config_source_field</source_model>
701
- <show_in_default>1</show_in_default>
702
- <show_in_website>1</show_in_website>
703
- <show_in_store>1</show_in_store>
704
- </company>
705
- <company_new>
706
- <sort_order>26</sort_order>
707
- <frontend_type>text</frontend_type>
708
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
709
- <show_in_default>1</show_in_default>
710
- <show_in_website>1</show_in_website>
711
- <show_in_store>1</show_in_store>
712
- <depends>
713
- <company>_new_</company>
714
- </depends>
715
- </company_new>
716
- <!-- telephone -->
717
- <telephone>
718
- <sort_order>30</sort_order>
719
- <label>Telephone</label>
720
- <frontend_type>select</frontend_type>
721
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
722
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
723
- <source_model>bronto_common/system_config_source_field</source_model>
724
- <show_in_default>1</show_in_default>
725
- <show_in_website>1</show_in_website>
726
- <show_in_store>1</show_in_store>
727
- </telephone>
728
- <telephone_new>
729
- <sort_order>31</sort_order>
730
- <frontend_type>text</frontend_type>
731
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
732
- <show_in_default>1</show_in_default>
733
- <show_in_website>1</show_in_website>
734
- <show_in_store>1</show_in_store>
735
- <depends>
736
- <telephone>_new_</telephone>
737
- </depends>
738
- </telephone_new>
739
- <!-- fax -->
740
- <fax>
741
- <sort_order>35</sort_order>
742
- <label>Fax</label>
743
- <frontend_type>select</frontend_type>
744
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
745
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
746
- <source_model>bronto_common/system_config_source_field</source_model>
747
- <show_in_default>1</show_in_default>
748
- <show_in_website>1</show_in_website>
749
- <show_in_store>1</show_in_store>
750
- </fax>
751
- <fax_new>
752
- <sort_order>36</sort_order>
753
- <frontend_type>text</frontend_type>
754
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
755
- <show_in_default>1</show_in_default>
756
- <show_in_website>1</show_in_website>
757
- <show_in_store>1</show_in_store>
758
- <depends>
759
- <fax>_new_</fax>
760
- </depends>
761
- </fax_new>
762
- </fields>
763
- </address_attributes>
764
- <billing_address_attributes>
765
- <label>Default Billing Address</label>
766
- <frontend_type>text</frontend_type>
767
- <frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_address
768
- </frontend_model>
769
- <sort_order>20</sort_order>
770
- <show_in_default>1</show_in_default>
771
- <show_in_website>1</show_in_website>
772
- <show_in_store>1</show_in_store>
773
- <fields>
774
- <!-- street -->
775
- <street>
776
- <sort_order>1</sort_order>
777
- <label>Street Address</label>
778
- <frontend_type>select</frontend_type>
779
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
780
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
781
- <source_model>bronto_common/system_config_source_field</source_model>
782
- <show_in_default>1</show_in_default>
783
- <show_in_website>1</show_in_website>
784
- <show_in_store>1</show_in_store>
785
- </street>
786
- <street_new>
787
- <sort_order>2</sort_order>
788
- <frontend_type>text</frontend_type>
789
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
790
- <show_in_default>1</show_in_default>
791
- <show_in_website>1</show_in_website>
792
- <show_in_store>1</show_in_store>
793
- <depends>
794
- <street>_new_</street>
795
- </depends>
796
- </street_new>
797
- <!-- city -->
798
- <city>
799
- <sort_order>5</sort_order>
800
- <label>City</label>
801
- <frontend_type>select</frontend_type>
802
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
803
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
804
- <source_model>bronto_common/system_config_source_field</source_model>
805
- <show_in_default>1</show_in_default>
806
- <show_in_website>1</show_in_website>
807
- <show_in_store>1</show_in_store>
808
- </city>
809
- <city_new>
810
- <sort_order>6</sort_order>
811
- <frontend_type>text</frontend_type>
812
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
813
- <show_in_default>1</show_in_default>
814
- <show_in_website>1</show_in_website>
815
- <show_in_store>1</show_in_store>
816
- <depends>
817
- <city>_new_</city>
818
- </depends>
819
- </city_new>
820
- <!-- region -->
821
- <region>
822
- <sort_order>10</sort_order>
823
- <label>State/Province Name</label>
824
- <frontend_type>select</frontend_type>
825
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
826
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
827
- <source_model>bronto_common/system_config_source_field</source_model>
828
- <show_in_default>1</show_in_default>
829
- <show_in_website>1</show_in_website>
830
- <show_in_store>1</show_in_store>
831
- </region>
832
- <region_new>
833
- <sort_order>11</sort_order>
834
- <frontend_type>text</frontend_type>
835
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
836
- <show_in_default>1</show_in_default>
837
- <show_in_website>1</show_in_website>
838
- <show_in_store>1</show_in_store>
839
- <depends>
840
- <region>_new_</region>
841
- </depends>
842
- </region_new>
843
- <region_code_id>
844
- <sort_order>12</sort_order>
845
- <label>State/Province Code</label>
846
- <frontend_type>select</frontend_type>
847
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
848
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
849
- <source_model>bronto_common/system_config_source_field</source_model>
850
- <show_in_default>1</show_in_default>
851
- <show_in_website>1</show_in_website>
852
- <show_in_store>1</show_in_store>
853
- </region_code_id>
854
- <region_code_id_new>
855
- <sort_order>13</sort_order>
856
- <frontend_type>text</frontend_type>
857
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
858
- <show_in_default>1</show_in_default>
859
- <show_in_website>1</show_in_website>
860
- <show_in_store>1</show_in_store>
861
- <depends>
862
- <region_code_id>_new_</region_code_id>
863
- </depends>
864
- </region_code_id_new>
865
- <!-- postcode -->
866
- <postcode>
867
- <sort_order>15</sort_order>
868
- <label>Zip/Postal Code</label>
869
- <frontend_type>select</frontend_type>
870
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
871
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
872
- <source_model>bronto_common/system_config_source_field</source_model>
873
- <show_in_default>1</show_in_default>
874
- <show_in_website>1</show_in_website>
875
- <show_in_store>1</show_in_store>
876
- </postcode>
877
- <postcode_new>
878
- <sort_order>16</sort_order>
879
- <frontend_type>text</frontend_type>
880
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
881
- <show_in_default>1</show_in_default>
882
- <show_in_website>1</show_in_website>
883
- <show_in_store>1</show_in_store>
884
- <depends>
885
- <postcode>_new_</postcode>
886
- </depends>
887
- </postcode_new>
888
- <!-- country_id -->
889
- <country_id>
890
- <sort_order>20</sort_order>
891
- <label>Country Name</label>
892
- <frontend_type>select</frontend_type>
893
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
894
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
895
- <source_model>bronto_common/system_config_source_field</source_model>
896
- <show_in_default>1</show_in_default>
897
- <show_in_website>1</show_in_website>
898
- <show_in_store>1</show_in_store>
899
- </country_id>
900
- <country_id_new>
901
- <sort_order>21</sort_order>
902
- <frontend_type>text</frontend_type>
903
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
904
- <show_in_default>1</show_in_default>
905
- <show_in_website>1</show_in_website>
906
- <show_in_store>1</show_in_store>
907
- <depends>
908
- <country_id>_new_</country_id>
909
- </depends>
910
- </country_id_new>
911
- <country_code_id>
912
- <sort_order>22</sort_order>
913
- <label>Country Code</label>
914
- <frontend_type>select</frontend_type>
915
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
916
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
917
- <source_model>bronto_common/system_config_source_field</source_model>
918
- <show_in_default>1</show_in_default>
919
- <show_in_website>1</show_in_website>
920
- <show_in_store>1</show_in_store>
921
- </country_code_id>
922
- <country_code_id_new>
923
- <sort_order>23</sort_order>
924
- <frontend_type>text</frontend_type>
925
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
926
- <show_in_default>1</show_in_default>
927
- <show_in_website>1</show_in_website>
928
- <show_in_store>1</show_in_store>
929
- <depends>
930
- <country_code_id>_new_</country_code_id>
931
- </depends>
932
- </country_code_id_new>
933
- <!-- company -->
934
- <company>
935
- <sort_order>25</sort_order>
936
- <label>Company</label>
937
- <frontend_type>select</frontend_type>
938
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
939
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
940
- <source_model>bronto_common/system_config_source_field</source_model>
941
- <show_in_default>1</show_in_default>
942
- <show_in_website>1</show_in_website>
943
- <show_in_store>1</show_in_store>
944
- </company>
945
- <company_new>
946
- <sort_order>26</sort_order>
947
- <frontend_type>text</frontend_type>
948
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
949
- <show_in_default>1</show_in_default>
950
- <show_in_website>1</show_in_website>
951
- <show_in_store>1</show_in_store>
952
- <depends>
953
- <company>_new_</company>
954
- </depends>
955
- </company_new>
956
- <!-- telephone -->
957
- <telephone>
958
- <sort_order>30</sort_order>
959
- <label>Telephone</label>
960
- <frontend_type>select</frontend_type>
961
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
962
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
963
- <source_model>bronto_common/system_config_source_field</source_model>
964
- <show_in_default>1</show_in_default>
965
- <show_in_website>1</show_in_website>
966
- <show_in_store>1</show_in_store>
967
- </telephone>
968
- <telephone_new>
969
- <sort_order>31</sort_order>
970
- <frontend_type>text</frontend_type>
971
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
972
- <show_in_default>1</show_in_default>
973
- <show_in_website>1</show_in_website>
974
- <show_in_store>1</show_in_store>
975
- <depends>
976
- <telephone>_new_</telephone>
977
- </depends>
978
- </telephone_new>
979
- <!-- fax -->
980
- <fax>
981
- <sort_order>35</sort_order>
982
- <label>Fax</label>
983
- <frontend_type>select</frontend_type>
984
- <frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
985
- <backend_model>bronto_customer/system_config_backend_brontofield</backend_model>
986
- <source_model>bronto_common/system_config_source_field</source_model>
987
- <show_in_default>1</show_in_default>
988
- <show_in_website>1</show_in_website>
989
- <show_in_store>1</show_in_store>
990
- </fax>
991
- <fax_new>
992
- <sort_order>36</sort_order>
993
- <frontend_type>text</frontend_type>
994
- <backend_model>bronto_customer/system_config_backend_newfield</backend_model>
995
- <show_in_default>1</show_in_default>
996
- <show_in_website>1</show_in_website>
997
- <show_in_store>1</show_in_store>
998
- <depends>
999
- <fax>_new_</fax>
1000
- </depends>
1001
- </fax_new>
1002
- </fields>
1003
- </billing_address_attributes>
1004
- </groups>
1005
- </bronto_customer>
1006
- </sections>
1007
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.0.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Sales_Model_Mysql4_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- //
9
- // Customer Attributes
10
- $installer->addAttribute('customer', 'bronto_imported', array(
11
- 'type' => 'datetime',
12
- 'required' => false,
13
- ));
14
-
15
- // try {
16
- // $installer->getConnection()->addKey(
17
- // $installer->getTable('sales/order'), 'IDX_BRONTO_IMPORTED', 'bronto_imported'
18
- // );
19
- // } catch (Exception $e) {
20
- // // Already exists...
21
- // }
22
-
23
- $installer->endSetup();
24
-
25
- // Mark installation date
26
- $config = Mage::getConfig();
27
- $config->saveConfig(Bronto_Customer_Helper_Data::XML_PATH_INSTALL_DATE, time());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.3.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Sales_Model_Mysql4_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- // Create New Table
10
- $installer->run("
11
- DROP TABLE IF EXISTS `{$this->getTable('bronto_customer_queue')}`;
12
-
13
- CREATE TABLE IF NOT EXISTS `{$this->getTable('bronto_customer_queue')}` (
14
- `queue_id` int(10) NOT NULL AUTO_INCREMENT,
15
- `customer_id` int(10) unsigned NOT NULL COMMENT 'Customer Entity Id',
16
- `store_id` smallint(5) unsigned NOT NULL COMMENT 'Store Id',
17
- `bronto_imported` datetime DEFAULT NULL COMMENT 'Bronto Imported',
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`),
26
- KEY `IDX_BRONTO_CUSTOMER_QUEUE_UPDATED_AT` (`updated_at`),
27
- CONSTRAINT `FK_BRONTO_CUSTOMER_QUEUE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`)
28
- REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
29
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Customer Import Queue';
30
- ");
31
- } catch (Exception $e) {
32
- throw new RuntimeException('Failed Creating Customer Queue Table: ' . $e->getMessage());
33
- }
34
-
35
- try {
36
- // Populate New Table
37
- $installer->run("
38
- INSERT IGNORE INTO `{$this->getTable('bronto_customer_queue')}`
39
- (`customer_id`, `store_id`, `bronto_imported`, `created_at`, `updated_at`)
40
- SELECT `ce`.`entity_id`, `ce`.`store_id`, null, `ce`.`created_at`, `ce`.`updated_at`
41
- FROM `{$this->getTable('customer_entity')}` `ce`
42
- WHERE `ce`.`is_active` = 1;
43
- ");
44
- } catch (Exception $e) {
45
- throw new RuntimeException('Failed Populating Customer Queue Table: ' . $e->getMessage());
46
- }
47
-
48
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.0-1.0.1.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * fall back to create table if existing modules already exists to support upgrade
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
- // Create New Table
13
- $installer->run("
14
- CREATE TABLE IF NOT EXISTS `{$this->getTable('bronto_customer_queue')}` (
15
- `customer_id` int(10) unsigned NOT NULL COMMENT 'Customer Entity Id',
16
- `store_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Store Id',
17
- `bronto_imported` datetime DEFAULT NULL COMMENT 'Bronto Imported',
18
- `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
19
- `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
20
- PRIMARY KEY (`customer_id`),
21
- KEY `IDX_BRONTO_CUSTOMER_QUEUE_STORE_ID` (`store_id`),
22
- KEY `IDX_BRONTO_CUSTOMER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
23
- KEY `IDX_BRONTO_CUSTOMER_QUEUE_CREATED_AT` (`created_at`),
24
- KEY `IDX_BRONTO_CUSTOMER_QUEUE_UPDATED_AT` (`updated_at`),
25
- CONSTRAINT `FK_BRONTO_CUSTOMER_QUEUE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
26
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Customer Import Queue';
27
- ");
28
-
29
- // Populate New Table
30
- $installer->run("
31
- INSERT IGNORE INTO `{$this->getTable('bronto_customer_queue')}`
32
- (`customer_id`, `store_id`, `bronto_imported`, `created_at`, `updated_at`)
33
- SELECT `ce`.`entity_id`, `ce`.`store_id`, `eav`.`value`, `ce`.`created_at`, `ce`.`updated_at`
34
- FROM `{$this->getTable('customer_entity')}` `ce`
35
- LEFT JOIN `{$this->getTable('eav_attribute')}` `ea` ON `ea`.`attribute_code` = 'bronto_imported'
36
- LEFT JOIN `{$this->getTable('customer_entity_datetime')}` `eav` ON `eav`.`attribute_id` = `ea`.`attribute_id` AND `eav`.`entity_id` = `ce`.`entity_id`
37
- WHERE `ce`.`is_active` = 1;
38
- ");
39
-
40
- // Remove Customer Attribute that was added on install
41
- $installer->removeAttribute('customer', 'bronto_imported');
42
- } catch (Exception $e) {
43
- throw new RuntimeException('Failed Creating and Populating Table: ' . $e->getMessage());
44
- }
45
-
46
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.1-1.0.2.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * fall back to create table if existing modules already exists to support upgrade
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 TABLE `{$this->getTable('bronto_customer_queue')}` DROP FOREIGN KEY `FK_BRONTO_CUSTOMER_QUEUE_STORE_ID_CORE_STORE_STORE_ID` ;
15
- ALTER TABLE `{$this->getTable('bronto_customer_queue')}` ADD COLUMN `queue_id` INT(10) NOT NULL AUTO_INCREMENT FIRST,
16
- CHANGE COLUMN `store_id` `store_id` SMALLINT(5) UNSIGNED NOT NULL COMMENT 'Store Id',
17
- ADD CONSTRAINT `FK_BRONTO_CUSTOMER_QUEUE_STORE_ID_CORE_STORE_STORE_ID`
18
- FOREIGN KEY (`store_id`)
19
- REFERENCES `{$this->getTable('core_store')}` (`store_id`)
20
- ON DELETE CASCADE
21
- ON UPDATE CASCADE
22
- , DROP PRIMARY KEY
23
- , ADD PRIMARY KEY (`queue_id`, `customer_id`, `store_id`) ;
24
- ");
25
- } catch (Exception $e) {
26
- throw new RuntimeException('Failed Modifying Table: ' . $e->getMessage());
27
- }
28
-
29
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.2-1.0.3.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * fall back to create table if existing modules already exists to support upgrade
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());
30
- }
31
-
32
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/About.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var string
11
- */
12
- protected $_module = 'bronto_email';
13
-
14
- /**
15
- * @var string
16
- */
17
- protected $_name = 'Bronto Transactional Email Module';
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Settings.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
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
9
- {
10
- /**
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 DELETED
@@ -1,247 +0,0 @@
1
- <?php
2
-
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
9
- {
10
- const XML_PATH_TEMPLATE_EMAIL = '//sections/*/groups/*/fields/*[source_model="adminhtml/system_config_source_email_template"]';
11
-
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
-
29
- $order = 0;
30
- foreach ($fields as $section => $groups) {
31
- $html .= $this->_getSubsetHtml($element, $section, $groups, $order);
32
- $order = $order + 5;
33
- }
34
-
35
- $html .= $this->_getFooterHtml($element);
36
-
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) {
94
- $fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
95
- } else {
96
- $fieldRenderer = $this->_getFieldRenderer();
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']
104
- );
105
-
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
- )
117
- );
118
-
119
- $fieldRenderer->setForm($this->getForm());
120
- $field->setRenderer($fieldRenderer);
121
- } catch (Exception $e) {
122
- Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
123
-
124
- return '';
125
- }
126
-
127
- return $field;
128
- }
129
-
130
- /**
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])
146
- ->setSection($section)
147
- ->setGroups($groups);
148
-
149
- $tempFieldset = $this->_addSubFields($fieldset, $element);
150
- if (!$tempFieldset) {
151
- return '';
152
- }
153
-
154
- return $tempFieldset->toHtml();
155
- }
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
-
171
- /**
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
- ));
189
- }
190
-
191
- return $this->_dummySubset;
192
- }
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(
206
- 'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system/config'),
207
- );
208
-
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
-
228
- $adminhtmlConfig = Mage::getSingleton('adminhtml/config');
229
- $adminhtmlConfig->getSections();
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
-
245
- return $result;
246
- }
247
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Field.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Email
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Email_Block_Adminhtml_System_Config_Templates_Field extends Mage_Adminhtml_Block_System_Config_Form_Field
8
- {
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);
21
-
22
- return parent::render($element);
23
- }
24
-
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Fieldset.php DELETED
@@ -1,425 +0,0 @@
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;
8
- protected $_fieldRenderer;
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;
49
- $html .= $this->_getLabelHtml($element, $element->getFieldConfig()->getSection(), $group, $groupData, $order);
50
- foreach ($groupData['fields'] as $field) {
51
- try {
52
- $order = $order + 5;
53
- $html .= $this->_getFieldHtml($element, $field, $order);
54
- } catch (Exception $e) {
55
- Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
56
- }
57
- }
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 '';
95
- }
96
-
97
- return $tempField->toHtml();
98
- }
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
- }
118
-
119
- return $label->toHtml();
120
- }
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
-
144
- return $this->_dummyElement;
145
- }
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
-
167
- return $this->_dummyLabel;
168
- }
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(
180
- Varien_Data_Form_Element_Abstract $fieldset,
181
- Varien_Object $element,
182
- array $field
183
- )
184
- {
185
- // Get Attribute Data and Inheritance
186
- $path = $field['path'];
187
-
188
- // Get Config Data
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
-
207
- // Get field Renderer
208
- if ($element->frontend_model) {
209
- $fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
210
- } else {
211
- $fieldRenderer = $this->_getFieldRenderer();
212
- }
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) {
225
- $model = Mage::getModel((string)$element->backend_model);
226
- if (!$model instanceof Mage_Core_Model_Config_Data) {
227
- Mage::throwException('Invalid config field backend model: ' . (string)$element->backend_model);
228
- }
229
- $model->setPath($path)->setValue($data)->afterLoad();
230
- $data = $model->getValue();
231
- }
232
-
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
- )
247
- );
248
-
249
- // Add Validation
250
- if ($element->validate) {
251
- $field->addClass($element->validate);
252
- }
253
-
254
- // Determine if value can be empty
255
- if (isset($element->frontend_type) && 'multiselect' === (string)$element->frontend_type && isset($element->can_be_empty)) {
256
- $field->setCanBeEmpty(true);
257
- }
258
-
259
- // Set Field Renderer
260
- $field->setRenderer($fieldRenderer);
261
-
262
- // Use Source Model to define available options
263
- if ($element->source_model) {
264
- $sourceModel = Mage::getSingleton((string)$element->source_model);
265
- if ($sourceModel instanceof Varien_Object) {
266
- $sourceModel->setPath($path);
267
- }
268
-
269
- $field->setValues($sourceModel->toOptionArray());
270
- }
271
-
272
- return $field;
273
- }
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,
288
- Varien_Object $element,
289
- array $groupData,
290
- $section,
291
- $group
292
- )
293
- {
294
- $configCode = 'bronto_email_templates_label_' . $section . '_' . $group;
295
-
296
- $data = $groupData['parts'][2]['title'];
297
- $inherit = false;
298
-
299
- // Get field Renderer
300
- if ($element->frontend_model) {
301
- $fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
302
- } else {
303
- $fieldRenderer = $this->_getFieldRenderer();
304
- }
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
- )
322
- );
323
-
324
- // Set Field Renderer
325
- $field->setRenderer($fieldRenderer);
326
- } catch (Exception $e) {
327
- Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
328
-
329
- return '';
330
- }
331
-
332
- return $field;
333
- }
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
- {
344
- $configData = array();
345
- /* @var $configDataCollection Mage_Core_Model_Resource_Config_Data_Collection */
346
- $configDataCollection = $this->_getConfigCollection($path);
347
-
348
- // Get Scope
349
- $scope = $this->getForm()->getScope();
350
- $scopeId = $this->getForm()->getScopeId();
351
-
352
- $inherit = false;
353
- if ($configDataCollection->count()) {
354
- while ($scope) {
355
- foreach ($configDataCollection as $config) {
356
- if (
357
- ($scope == $config->getScope() || $scope . 's' == $config->getScope()) &&
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
-
374
- return $configData;
375
- }
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)
385
- {
386
- /* @var $configDataCollection Mage_Core_Model_Resource_Config_Data_Collection */
387
- $configDataCollection = Mage::getModel('core/config_data')->getCollection()
388
- ->addFieldToFilter('path', $path);
389
-
390
- return $configDataCollection;
391
- }
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)
402
- {
403
- if ('store' == $scope || 'website' == $scope) {
404
- $scope .= 's';
405
- }
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
- }
422
-
423
- return array('scope' => $scope, 'scope_id' => $scopeId);
424
- }
425
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Label.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Email
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Email_Block_Adminhtml_System_Config_Templates_Label
8
- extends Mage_Adminhtml_Block_System_Config_Form_Field_Heading
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
- $label = $element->getLabel();
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; " .
31
- trim($labelParts[2]);
32
-
33
- $element->setLabel($newLabel);
34
- }
35
-
36
- return parent::render($element);
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Sendtype.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Email
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Email_Block_Adminhtml_System_Config_Templates_Sendtype
8
- extends Mage_Adminhtml_Block_System_Config_Form_Field
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';
21
- }
22
- $element->setValue($realValue);
23
- $element->setPath($realpath);
24
-
25
- return parent::render($element);
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import.php DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Set transactional emails grid template
11
- */
12
- protected function _construct()
13
- {
14
- Mage_Adminhtml_Block_Template::_construct();
15
- $this->setTemplate('bronto/email/template/list.phtml');
16
- }
17
-
18
- /**
19
- * @return Mage_Core_Block_Abstract
20
- */
21
- protected function _prepareLayout()
22
- {
23
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
24
- return parent::_prepareLayout();
25
- }
26
-
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
-
45
- $this->setChild('grid', $this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_grid', 'email.import.grid'));
46
-
47
- return Mage_Adminhtml_Block_Template::_prepareLayout();
48
- }
49
-
50
- /**
51
- * Get transactional emails page header text
52
- *
53
- * @return string
54
- */
55
- public function getHeaderText()
56
- {
57
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
58
- return parent::getHeaderText();
59
- }
60
-
61
- return Mage::helper('bronto_email')->__('Import Magento Transactional Email Templates');
62
- }
63
-
64
- /**
65
- * Get URL to import existing email templates
66
- *
67
- * @return string
68
- */
69
- public function getLoadDefaultsUrl()
70
- {
71
- return $this->getUrl('*/system_email_template/loadDefaults');
72
- }
73
-
74
- /**
75
- * Get URL to go back
76
- *
77
- * @return string
78
- */
79
- public function getBackUrl()
80
- {
81
- return $this->getUrl('*/system_email_template/index');
82
- }
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 DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
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
9
- {
10
- protected function _prepareLayout()
11
- {
12
- parent::_prepareLayout();
13
-
14
- $this->setChild('back_button',
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
- );
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid.php DELETED
@@ -1,107 +0,0 @@
1
- <?php
2
-
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
- {
9
-
10
- /**
11
- * Turn off AJAX for this grid, as it kicks back to the Dashboard
12
- * @see parent
13
- */
14
- protected function _construct()
15
- {
16
- parent::_construct();
17
- $this->setUseAjax(false);
18
- }
19
-
20
- protected function _prepareCollection()
21
- {
22
- /* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
23
- $collection = Mage::getModel('bronto_email/template')->getCollection();
24
-
25
- $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
26
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
27
-
28
- // Apply conditional logic to handle 1.9 overriding collection _construct
29
- if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, array('edition' => 'Professional', 'major' => 9), 10))) {
30
- $collection->getSelect()->joinLeft(
31
- $brontoTable,
32
- "{$templateTable}.template_id = {$brontoTable}.core_template_id"
33
- );
34
- }
35
-
36
- // Limit grid to show only those templates without message id assigned
37
- $collection->addFieldToFilter("{$brontoTable}.bronto_message_id", array('null' => true));
38
-
39
- $this->setCollection($collection);
40
-
41
- return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
42
- }
43
-
44
- /**
45
- * Add columns to the grid
46
- *
47
- * @return Bronto_Email_Block_Adminhtml_System_Email_Template_Grid
48
- */
49
- protected function _prepareColumns()
50
- {
51
-
52
- parent::_prepareColumns();
53
-
54
- if (Mage::helper('bronto_email')->isEnabledForAny()) {
55
- $this->addColumn('action', array(
56
- 'header' => Mage::helper('adminhtml')->__('Action'),
57
- 'index' => 'template_id',
58
- 'sortable' => false,
59
- 'filter' => false,
60
- 'width' => '100px',
61
- 'renderer' => 'bronto_email/adminhtml_system_email_import_grid_renderer_action'
62
- ));
63
- }
64
-
65
- return $this;
66
- }
67
-
68
- protected function _prepareMassaction()
69
- {
70
- $this->setMassactionIdField('template_id');
71
- $this->getMassactionBlock()->setFormFieldName('template_id');
72
-
73
- $stores = Mage::app()->getStores(true);
74
- if (is_array($stores) && count($stores) >= 1) {
75
- foreach ($stores as $store) {
76
- if (Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
77
- $this->getMassactionBlock()->addItem('import|' . $store->getCode(), array(
78
- 'url' => $this->getUrl('*/*/massImport', array('template_id' => '', 'store_id' => $store->getId())),
79
- 'label' => Mage::helper('bronto_email')->__('Import For Store: ' . (!$store->getId() ? 'Default' : $store->getName())),
80
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will import the selected template(s) to Bronto for the specified store.'),
81
- ));
82
- }
83
- }
84
- }
85
-
86
- $this->getMassactionBlock()->addItem('delete', array(
87
- 'label' => Mage::helper('bronto_email')->__('Delete'),
88
- 'url' => $this->getUrl('*/*/massDelete', array('delete_level' => 'full')),
89
- '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.')
90
- ));
91
-
92
- return $this;
93
- }
94
-
95
- /**
96
- * get Row Url for editing template on row click
97
- *
98
- * @param $row
99
- *
100
- * @return string
101
- */
102
- public function getRowUrl($row)
103
- {
104
- return $this->getUrl('*/*/importEdit', array('id' => $row->getId()));
105
- }
106
-
107
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid/Renderer/Action.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
4
- {
5
- public function render(Varien_Object $row)
6
- {
7
- $actions = array();
8
-
9
- $actions[] = array(
10
- 'url' => $this->getUrl('*/*/edit', array('id' => $row->getId())),
11
- 'caption' => $this->__('Edit'),
12
- );
13
-
14
- $stores = Mage::app()->getStores(true);
15
- if (is_array($stores) && count($stores) >= 1) {
16
- foreach ($stores as $store) {
17
- if (Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
18
- $actions[] = array(
19
- 'url' => $this->getUrl('*/*/massImport', array('template_id' => $row->getId(), 'store_id' => $store->getId())),
20
- 'caption' => $this->__('Import For Store: ' . (!$store->getId() ? 'Default' : $store->getName())),
21
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to import the selected template?'),
22
- );
23
- }
24
- }
25
- }
26
- $actions[] = array(
27
- 'url' => $this->getUrl('*/*/massDelete', array('template_id' => $row->getId(), 'delete_level' => 'full')),
28
- 'caption' => $this->__('Delete'),
29
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template?'),
30
- );
31
-
32
- $this->getColumn()->setActions($actions);
33
-
34
- return parent::render($row);
35
- }
36
-
37
- protected function _getEscapedValue($value)
38
- {
39
- return addcslashes(htmlspecialchars($value), '\\\'');
40
- }
41
-
42
- protected function _actionsToHtml(array $actions)
43
- {
44
- $html = array();
45
- $attributesObject = new Varien_Object();
46
- foreach ($actions as $action) {
47
- $attributesObject->setData($action['@']);
48
- $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
49
- }
50
-
51
- return implode(' <span class="separator">&nbsp;|&nbsp;</span> ', $html);
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * @var string
11
- */
12
- protected $_controller = 'adminhtml_system_email_log';
13
-
14
- /**
15
- * @var string
16
- */
17
- protected $_clearButtonLabel = 'Clear Log History';
18
-
19
- /**
20
- * @var string
21
- */
22
- protected $_blockGroup = 'bronto_email';
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');
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('*/system_email_template/index');
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid.php DELETED
@@ -1,114 +0,0 @@
1
- <?php
2
-
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
- {
16
- parent::__construct($attributes);
17
- $this->setId('logGrid');
18
- $this->setIdFieldName('log_id');
19
- $this->setDefaultSort('sent_at', 'desc');
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();
101
- }
102
-
103
- /**
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)
111
- {
112
- return null;
113
- }
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Customer.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
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,
22
- parent::render($row)
23
- );
24
- }
25
-
26
- return parent::render($row);
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Fields.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
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
- {
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/Email/Block/Adminhtml/System/Email/Template.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Set transactional emails grid template
11
- */
12
- protected function _construct()
13
- {
14
- Mage_Adminhtml_Block_Template::_construct();
15
- $this->setTemplate('bronto/email/template/list.phtml');
16
- }
17
-
18
- /**
19
- * @return Mage_Core_Block_Abstract
20
- */
21
- protected function _prepareLayout()
22
- {
23
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
24
- return parent::_prepareLayout();
25
- }
26
-
27
- $this->setChild('add_button',
28
- $this->getLayout()->createBlock('adminhtml/widget_button')
29
- ->setData(array(
30
- 'label' => Mage::helper('adminhtml')->__('Add New Template'),
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
-
45
- if (Mage::helper('bronto_email')->isLogEnabled()) {
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
- }
55
-
56
- $this->setChild('grid', $this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_grid', 'email.template.grid'));
57
-
58
- return Mage_Adminhtml_Block_Template::_prepareLayout();
59
- }
60
-
61
- /**
62
- * Get transactional emails page header text
63
- *
64
- * @return string
65
- */
66
- public function getHeaderText()
67
- {
68
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
69
- return parent::getHeaderText();
70
- }
71
-
72
- return Mage::helper('bronto_email')->__('Bronto Transactional Emails');
73
- }
74
-
75
- /**
76
- * Get URL for create new email template
77
- *
78
- * @return string
79
- */
80
- public function getCreateUrl()
81
- {
82
- return $this->getUrl('*/*/brontonew');
83
- }
84
-
85
- /**
86
- * Get URL for transactional email log
87
- *
88
- * @return string
89
- */
90
- public function getLogUrl()
91
- {
92
- return $this->getUrl('*/system_email_log/index');
93
- }
94
-
95
- /**
96
- * Get URL to import existing email templates
97
- *
98
- * @return string
99
- */
100
- public function getImportUrl()
101
- {
102
- return $this->getUrl('*/system_email_template/import');
103
- }
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
-
117
- /**
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())
126
- {
127
- return Mage::helper('bronto_email')->getScopeUrl($route, $params);
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit.php DELETED
@@ -1,209 +0,0 @@
1
- <?php
2
-
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
- {
9
- public function __construct()
10
- {
11
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
12
- return parent::__construct();
13
- }
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()
27
- {
28
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
29
- return parent::_prepareLayout();
30
- }
31
-
32
- parent::_prepareLayout();
33
-
34
- $this->unsetChild('to_plain_button');
35
- $this->unsetChild('to_html_button');
36
- $this->unsetChild('preview_button');
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
- /**
53
- * Return header text for form
54
- *
55
- * @return string
56
- */
57
- public function getHeaderText()
58
- {
59
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
60
- return parent::getHeaderText();
61
- }
62
-
63
- if ($this->getEditMode()) {
64
- return Mage::helper('adminhtml')->__('Edit Template');
65
- }
66
-
67
- return Mage::helper('adminhtml')->__('New Template');
68
- }
69
-
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
- {
79
- $paths = $this->getEmailTemplate()->getSystemConfigPathsWhereUsedAsDefault();
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
-
87
- $pathsParts = $this->_getSystemConfigPathsParts($paths);
88
-
89
- if ($asJSON) {
90
- return Mage::helper('core')->jsonEncode($pathsParts);
91
- }
92
-
93
- return $pathsParts;
94
- }
95
-
96
- /**
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
127
- // Add "System" to path
128
- $prefixParts[] = array(
129
- 'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system'),
130
- );
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
138
- $pathParts = $prefixParts;
139
- foreach ($paths as $pathData) {
140
- if (!array_key_exists('path', $pathData)) {
141
- continue;
142
- }
143
-
144
- list($sectionName, $groupName, $fieldName) = explode('/', $pathData['path']);
145
- $urlParams = array('section' => $sectionName);
146
- if (isset($pathData['scope']) && isset($pathData['scope_id'])) {
147
- switch ($pathData['scope']) {
148
- case 'stores':
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:
164
- break;
165
- }
166
- }
167
- $adminhtmlConfig = Mage::getSingleton('adminhtml/config');
168
- $adminhtmlConfig->getSections();
169
-
170
- // Check if titles are set to prevent "[Object]" from displaying in their place
171
- // If Section Name is set, add it to path
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
179
- if ($groupTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName)) {
180
- $pathParts[] = array(
181
- 'title' => $groupTitle,
182
- );
183
- }
184
- // If Field Name is set, add it to path
185
- if ($fieldTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName, $fieldName)) {
186
- $pathParts[] = array(
187
- 'title' => $fieldTitle,
188
- 'scope' => $scopeLabel
189
- );
190
- }
191
-
192
- $result[] = $pathParts;
193
- $pathParts = $prefixParts;
194
- }
195
- }
196
-
197
- return $result;
198
- }
199
-
200
- /**
201
- * Return action url for form
202
- *
203
- * @return string
204
- */
205
- public function getSaveUrl()
206
- {
207
- return $this->getUrl('*/*/brontoSave', array('_current' => true));
208
- }
209
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit/Form.php DELETED
@@ -1,457 +0,0 @@
1
- <?php
2
-
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
- {
9
-
10
- /**
11
- * Prepare layout.
12
- * Add files to use dialog windows
13
- *
14
- * @return Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form
15
- */
16
- protected function _prepareLayout()
17
- {
18
- if ($head = $this->getLayout()->getBlock('head')) {
19
- $head->addItem('js', 'prototype/window.js')
20
- ->addItem('js_css', 'prototype/windows/themes/default.css')
21
- ->addCss('lib/prototype/windows/themes/magento.css')
22
- ->addItem('js', 'mage/adminhtml/variables.js');
23
- }
24
-
25
- return parent::_prepareLayout();
26
- }
27
-
28
- /**
29
- * @return Mage_Adminhtml_Block_Widget_Form
30
- */
31
- protected function _prepareForm()
32
- {
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
-
40
- // Create New Form Element
41
- $form = new Varien_Data_Form();
42
-
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
50
- $templateId = $this->getEmailTemplate()->getId();
51
-
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
-
89
- // If has more than one store, provide store select field,
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(true, true),
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
118
- $sendtype->setAfterElementHtml("
119
- <script type=\"text/javascript\">
120
- Event.observe(window, 'load', function() {
121
- triggerSendType($('template_send_type').value);
122
- });
123
-
124
- function triggerSendType(sendType) {
125
- if (sendType == 'magento') {
126
- // Disable Some
127
- $('bronto_message_id').disable();
128
- $('send_flags').disable();
129
- $('sales_rule').disable();
130
- $$('#product_recommendation').each(function(elem) { elem.disable() });
131
- $$('#container_product_recommendation').each(function(elem) { elem.hide() } );
132
- $('orig_template_text').disable();
133
- $('container_bronto_message_id').hide();
134
- $('container_send_flags').hide();
135
- $('container_sales_rule').hide();
136
- $('container_orig_template_text').hide();
137
-
138
- // Enable Others
139
- $('template_subject').enable();
140
- $('template_text').enable();
141
- $('container_template_subject').show();
142
- $('container_template_text').show();
143
- $('insert_variable').show();
144
-
145
- if ($('field_template_styles') != undefined) {
146
- $('field_template_styles').show();
147
- $('template_styles').enable();
148
- }
149
- } else {
150
- // Enable Some
151
- $('bronto_message_id').enable();
152
- $('send_flags').enable();
153
- $('sales_rule').enable();
154
- $$('#product_recommendation').each(function(elem) { elem.enable() } );
155
- $$('#container_product_recommendation').each(function(elem) { elem.show() });
156
- $('orig_template_text').enable();
157
- $('container_bronto_message_id').show();
158
- $('container_send_flags').show();
159
- $('container_sales_rule').show();
160
- $('container_orig_template_text').show();
161
-
162
- // Disable Others
163
- $('template_subject').disable();
164
- $('template_text').disable();
165
- $('container_template_subject').hide();
166
- $('container_template_text').hide();
167
- $('insert_variable').hide();
168
-
169
- if ($('field_template_styles') != undefined) {
170
- $('template_styles').disable();
171
- $('field_template_styles').hide();
172
- }
173
- }
174
- }
175
-
176
- function updateMessages(){
177
- var storeId = $('store_id').value;
178
- var sendType = $('template_send_type').value;
179
- var template = '{$templateId}';
180
-
181
- triggerSendType(sendType);
182
-
183
- if (sendType != 'magento') {
184
- var reloadurl = '" . $this->getUrl('adminhtml/system_email_template/ajaxlist') . "template_id/'+template+'/id/'+storeId+'/type/'+sendType;
185
- new Ajax.Request(reloadurl, {
186
- method: 'get',
187
- onLoading: function (transport) {
188
- $('bronto_message_id').update('Searching...');
189
- },
190
- onComplete: function(transport) {
191
- $('bronto_message_id').update(transport.responseText);
192
- }
193
- });
194
- }
195
- }
196
-
197
- function syncHiddenValue(element) {
198
- var fieldValue = element.value;
199
-
200
- if ($(element.id + '_hidden') != undefined) {
201
- $(element.id + '_hidden').value = fieldValue;
202
- }
203
- }
204
- </script>");
205
-
206
- // Template Name/Code
207
- $fieldset->addField('template_code', 'text', array(
208
- 'name' => 'template_code',
209
- 'label' => Mage::helper('adminhtml')->__('Name'),
210
- 'required' => true
211
- ));
212
-
213
- // Add hidden fields to hold backups of the necessary values
214
- $fieldset->addField('bronto_message_id_hidden', 'hidden', array('name' => 'bronto_message_id_hidden'));
215
- $fieldset->addField('sales_rule_hidden', 'hidden', array('name' => 'sales_rule_hidden'));
216
- $fieldset->addField('product_recommendation_hidden', 'hidden', array('name' => 'product_recommendation_hidden'));
217
- $fieldset->addField('template_subject_hidden', 'hidden', array('name' => 'template_subject_hidden'));
218
- $fieldset->addField('template_text_hidden', 'hidden', array('name' => 'template_text_hidden'));
219
- $fieldset->addField('template_styles_hidden', 'hidden', array('name' => 'template_styles_hidden'));
220
-
221
- // Used for magento send type
222
- $fieldset->addField('template_subject', 'text', array(
223
- 'name' => 'template_subject',
224
- 'label' => Mage::helper('adminhtml')->__('Template Subject'),
225
- 'onchange' => "syncHiddenValue(this);",
226
- 'container_id' => 'container_template_subject',
227
- 'required' => true,
228
- ));
229
-
230
- // Create field to allow selecting Bronto Message to bind to template
231
- $fieldset->addField('bronto_message_id', 'select', array(
232
- 'name' => 'bronto_message_id',
233
- 'label' => Mage::helper('adminhtml')->__('Bronto Message'),
234
- 'container_id' => 'container_bronto_message_id',
235
- 'onchange' => "syncHiddenValue(this);",
236
- 'values' => Mage::helper('bronto_email/message')->getAllMessageOptions(),
237
- 'required' => true,
238
- ));
239
-
240
- $fieldset->addField('send_flags', 'select', array(
241
- 'name' => 'send_flags',
242
- 'label' => Mage::helper('adminhtml')->__('Send Flags'),
243
- 'title' => Mage::helper('adminhtml')->__('Send Flags'),
244
- 'container_id' => 'container_send_flags',
245
- 'values' => Mage::getModel('bronto_common/system_config_source_sendOptions')->toOptionArray(true),
246
- 'note' => $this->__("Send flags for this message. The options are: <br/> - <strong>Sender Authentication</strong>: Will sign your message with DomainKeys/DKIM, optimizing your message delivery to Hotmail, MSN, and Yahoo! email addresses. <br/> - <strong>Fatigue Override</strong>: The delivery can be sent even if it exceeds the frequency cap settings for a customer. <br/> - <strong>Reply Tracking</strong>: Will store a copy of all replies to your messages on the Replies page within the Bronto platform.")
247
- ));
248
-
249
- // Create field to allow selecting a sales rule to pull a coupon code from
250
- $fieldset->addField('sales_rule', 'select', array(
251
- 'name' => 'sales_rule',
252
- 'label' => Mage::helper('adminhtml')->__('Shopping Cart Price Rule Coupon Code'),
253
- '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.'),
254
- 'container_id' => 'container_sales_rule',
255
- 'onchange' => "syncHiddenValue(this);",
256
- 'values' => Mage::getModel('bronto_common/system_config_source_coupon')->toOptionArray(true),
257
- 'required' => false,
258
- ));
259
-
260
- if (Mage::helper('bronto_product')->isEnabledForAny()) {
261
- $fieldset->addField('product_recommendation', 'select', array(
262
- 'name' => 'product_recommendation',
263
- 'container_id' => 'container_product_recommendation',
264
- 'onchange' => "syncHiddenValue(this);",
265
- 'label' => Mage::helper('adminhtml')->__('Product Recommendations'),
266
- 'required' => false,
267
- 'values' => Mage::getModel('bronto_product/recommendation')->toOptionArray(true),
268
- 'note' => $this->__('Inject related product content into this message. Recommendations are created in <strong>Promotions</strong> &raquo; <strong>Bronto Product Recommendations')
269
- ));
270
- }
271
-
272
- // Display Variables that are available for the original template
273
- $fieldset->addField('template_variables_key', 'label', array(
274
- 'container_id' => 'template_variables_key_row',
275
- 'label' => Mage::helper('adminhtml')->__('Variables'),
276
- 'after_element_html' => '<div id="template_variables_key_list"></div>' .
277
- ($templateId ? '' : '<script>$("template_variables_key_row").hide();</script>')
278
- ));
279
-
280
- // Display template text that was imported into Bronto
281
- $fieldset->addField('orig_template_text', 'textarea', array(
282
- 'name' => 'orig_template_text',
283
- 'label' => Mage::helper('adminhtml')->__('Original Template Content'),
284
- 'note' => $this->__('For Reference Only'),
285
- 'container_id' => 'container_orig_template_text',
286
- 'onchange' => "syncHiddenValue(this);",
287
- 'readonly' => true,
288
- 'style' => 'height:24em;background-color:#efefef;',
289
- ));
290
-
291
- $fieldset->addField('orig_template_variables', 'hidden', array(
292
- 'name' => 'orig_template_variables',
293
- ));
294
-
295
- $fieldset->addField('variables', 'hidden', array(
296
- 'name' => 'variables',
297
- 'value' => Zend_Json::encode($this->getVariables())
298
- ));
299
-
300
- $fieldset->addField('template_variables', 'hidden', array(
301
- 'name' => 'template_variables',
302
- ));
303
-
304
- // Used for magento send type
305
- $insertVariableButton = $this->getLayout()
306
- ->createBlock('adminhtml/widget_button', '', array(
307
- 'type' => 'button',
308
- 'label' => Mage::helper('adminhtml')->__('Insert Variable...'),
309
- 'container_id' => 'container_widget_button',
310
- 'onclick' => 'templateControl.openVariableChooser();return false;',
311
- ));
312
-
313
- $fieldset->addField('insert_variable', 'note', array(
314
- 'text' => $insertVariableButton->toHtml()
315
- ));
316
-
317
- $fieldset->addField('template_text', 'textarea', array(
318
- 'name' => 'template_text',
319
- 'label' => Mage::helper('adminhtml')->__('Template Content'),
320
- 'title' => Mage::helper('adminhtml')->__('Template Content'),
321
- 'container_id' => 'container_template_text',
322
- 'onchange' => "syncHiddenValue(this);",
323
- 'required' => true,
324
- 'style' => 'height:24em',
325
- ));
326
-
327
- if (!$this->getEmailTemplate()->isPlain()) {
328
- $fieldset->addField('template_styles', 'textarea', array(
329
- 'name' => 'template_styles',
330
- 'label' => Mage::helper('adminhtml')->__('Template Styles'),
331
- 'container_id' => 'field_template_styles',
332
- 'onchange' => "syncHiddenValue(this);",
333
- ));
334
- }
335
-
336
- if ($templateId) {
337
- if ($this->getEmailTemplate()->getUseDefaultSalesRule()) {
338
- $this->getEmailTemplate()->setSalesRule('default');
339
- }
340
- if ($this->getEmailTemplate()->getUseDefaultRec()) {
341
- $this->getEmailTemplate()->setProductRecommendation('default');
342
- }
343
- $form->addValues($this->getEmailTemplate()->getData());
344
- $form->addValues(array(
345
- 'template_variables' => Zend_Json::encode($this->getEmailTemplate()->getVariablesOptionArray(true)),
346
- // Populate hidden fields
347
- 'bronto_message_id_hidden' => $this->getEmailTemplate()->getBrontoMessageId(),
348
- 'sales_rule_hidden' => $this->getEmailTemplate()->getSalesRule(),
349
- 'template_subject_hidden' => $this->getEmailTemplate()->getTemplateSubject(),
350
- 'template_text_hidden' => $this->getEmailTemplate()->getTemplateText(),
351
- 'template_styles_hidden' => $this->getEmailTemplate()->getTemplateStyles(),
352
- 'product_recommendation_hidden' => $this->getEmailTemplate()->getProductRecommendation(),
353
- ));
354
- }
355
-
356
- if ($values = Mage::getSingleton('adminhtml/session')->getData('email_template_form_data', true)) {
357
- $form->setValues($values);
358
- }
359
-
360
- $this->setForm($form);
361
-
362
- return parent::_prepareForm();
363
- }
364
-
365
- /**
366
- * Return current email template model
367
- *
368
- * @return Mage_Core_Model_Email_Template
369
- */
370
- public function getEmailTemplate()
371
- {
372
- return Mage::registry('current_email_template');
373
- }
374
-
375
- /**
376
- * Filter Store Options by stores where module is enabled
377
- *
378
- * @param bool $empty
379
- * @param bool $all
380
- *
381
- * @return array
382
- */
383
- protected function _getActiveStoreValuesForForm($empty = false, $all = false)
384
- {
385
- $storeOptions = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm($empty, $all);
386
- $curWebsite = 0;
387
- $curWebCount = 0;
388
-
389
- // Cycle Through Options
390
- foreach ($storeOptions as $optionId => $option) {
391
- if (is_array($option['value']) && empty($option['value'])) {
392
- if ($optionId != $curWebsite) {
393
- if ($curWebCount == 0) {
394
- unset($storeOptions[$curWebsite]);
395
- }
396
- $curWebCount = 0;
397
- }
398
-
399
- $curWebsite = $optionId;
400
- }
401
-
402
- // If Option has an array value with items
403
- if (is_array($option['value']) && count($option['value']) >= 1) {
404
- $curWebCount++;
405
- // Cycle Through Sub-Options
406
- foreach ($option['value'] as $subId => $subOption) {
407
- // If Sub-Option value is a string and is numeric
408
- if (is_string($subOption['value']) && is_numeric($subOption['value'])) {
409
- // If Sub-Option Value is a store id and that store is not enabled, unset it's value
410
- if (!Mage::helper('bronto_email')->isEnabled('store', $subOption['value'])) {
411
- unset($storeOptions[$optionId]['value'][$subId]);
412
- // If Option no longer has any values, remove Option
413
- if (count($storeOptions[$optionId]['value']) < 1) {
414
- $curWebCount--;
415
- unset($storeOptions[$optionId]);
416
- }
417
- }
418
- }
419
- }
420
- }
421
- }
422
-
423
- // If the last website has no groups, remove it
424
- if ($curWebCount == 0) {
425
- if (array_key_exists($curWebsite, $storeOptions)) {
426
- unset($storeOptions[$curWebsite]);
427
- }
428
- }
429
-
430
- return $storeOptions;
431
- }
432
-
433
- /**
434
- * Retrieve variables to insert into email
435
- *
436
- * @return array
437
- */
438
- public function getVariables()
439
- {
440
- $variables = array();
441
- $variables[] = Mage::getModel('core/source_email_variables')
442
- ->toOptionArray(true);
443
- $customVariables = Mage::getModel('core/variable')
444
- ->getVariablesOptionArray(true);
445
- if ($customVariables) {
446
- $variables[] = $customVariables;
447
- }
448
- /* @var $template Mage_Core_Model_Email_Template */
449
- $template = Mage::registry('current_email_template');
450
- if ($template->getId() && $templateVariables = $template->getVariablesOptionArray(true)) {
451
- $variables[] = $templateVariables;
452
- }
453
-
454
- return $variables;
455
- }
456
-
457
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->setId('systemBrontoEmailTemplateGrid');
13
- $this->setUseAjax(false);
14
- }
15
-
16
- protected function _prepareCollection()
17
- {
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, array('edition' => 'Professional', 'major' => 9), 10))) {
26
- $collection->getSelect()->joinLeft(
27
- $brontoTable,
28
- "{$templateTable}.template_id = {$brontoTable}.core_template_id"
29
- );
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
-
37
- return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
38
- }
39
-
40
- /**
41
- * Add columns to the grid
42
- *
43
- * @return Bronto_Email_Block_Adminhtml_System_Email_Template_Grid
44
- */
45
- protected function _prepareColumns()
46
- {
47
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
48
- return parent::_prepareColumns();
49
- }
50
-
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
- if (!Mage::app()->isSingleStoreMode()) {
92
- $this->addColumn('store_id', array(
93
- 'header' => Mage::helper('adminhtml')->__('Store View'),
94
- 'type' => 'store',
95
- 'index' => 'store_id',
96
- 'sortable' => true,
97
- 'store_view' => true
98
- ));
99
- }
100
-
101
- $this->addColumn(
102
- 'template_send_type',
103
- array(
104
- 'header' => Mage::helper('adminhtml')->__('Send Type'),
105
- 'index' => 'template_send_type',
106
- 'type' => 'options',
107
- 'options' => array(
108
- 'marketing' => 'Bronto Marketing',
109
- 'transactional' => 'Bronto Transactional',
110
- 'magento' => 'Magento Email',
111
- ),
112
- )
113
- );
114
-
115
- $this->addColumn('action', array(
116
- 'header' => Mage::helper('adminhtml')->__('Action'),
117
- 'index' => 'template_id',
118
- 'sortable' => false,
119
- 'filter' => false,
120
- 'width' => '130px',
121
- 'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_action'
122
- ));
123
-
124
- return $this;
125
- }
126
-
127
- protected function _prepareMassaction()
128
- {
129
- $this->setMassactionIdField('template_id');
130
- $this->getMassactionBlock()->setFormFieldName('template_id');
131
- $this->getMassactionBlock()->addItem('marketing', array(
132
- 'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Marketing'),
133
- 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'marketing')),
134
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a marketing message?')
135
- ));
136
- $this->getMassactionBlock()->addItem('transactional', array(
137
- 'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Transactional'),
138
- 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'transactional')),
139
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a transactional message?')
140
- ));
141
- $this->getMassactionBlock()->addItem('magento', array(
142
- 'label' => Mage::helper('bronto_email')->__('Set to send as Magento Email'),
143
- 'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'magento')),
144
- 'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Magento?')
145
- ));
146
- $this->getMassactionBlock()->addItem('delete', array(
147
- 'label' => Mage::helper('bronto_email')->__('Delete'),
148
- 'url' => $this->getUrl('*/*/massDelete', array('' => '')),
149
- '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).')
150
- ));
151
-
152
- return $this;
153
- }
154
-
155
- /**
156
- * get Row Url for editing template on row click
157
- *
158
- * @param $row
159
- *
160
- * @return string
161
- */
162
- public function getRowUrl($row)
163
- {
164
- return $this->getUrl('*/*/brontoEdit', array('id' => $row->getId()));
165
- }
166
-
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Action.php DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
4
- {
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
- );
22
-
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
- );
59
- break;
60
- }
61
-
62
- $this->getColumn()->setActions($actions);
63
-
64
- return parent::render($row);
65
- }
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Storename.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
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
-
22
- return $storeName;
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Helper/Contact.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Retrieve helper module name
11
- *
12
- * @return string
13
- */
14
- protected function _getModuleName()
15
- {
16
- return 'Bronto_Email';
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)
29
- {
30
- return parent::getContactByEmail($email, $customSource, $store);
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Helper/Data.php DELETED
@@ -1,312 +0,0 @@
1
- <?php
2
-
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
- const XML_PATH_DEFAULT_COUPON = 'bronto_email/settings/default_coupon';
16
- const XML_PATH_DEFAULT_REC = 'bronto_email/settings/default_recommendation';
17
- const XML_PATH_DEFAULT_SEND_FLAG = 'bronto_email/settings/default_send_flags';
18
-
19
- /**
20
- * Xml path to email template nodes
21
- */
22
- const XML_PATH_TEMPLATE_EMAIL = '//sections/*/groups/*/fields/*[source_model="adminhtml/system_config_source_email_template"]';
23
-
24
- /**
25
- * Module Human Readable Name
26
- */
27
- protected $_name = 'Bronto Transactional Emails';
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
- * Disable Module for specified Scope
41
- *
42
- * @param string $scope
43
- * @param int $scopeId
44
- * @param bool $deleteConfig
45
- *
46
- * @return bool
47
- */
48
- public function disableModule($scope = 'default', $scopeId = 0, $deleteConfig = false)
49
- {
50
- return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId, $deleteConfig);
51
- }
52
-
53
- /**
54
- * Retrieve helper module name
55
- *
56
- * @return string
57
- */
58
- protected function _getModuleName()
59
- {
60
- return 'Bronto_Email';
61
- }
62
-
63
- /**
64
- * Determine if any stores have module enabled
65
- *
66
- * @return bool
67
- */
68
- public function isEnabledForAny()
69
- {
70
- $stores = Mage::app()->getStores();
71
- if (is_array($stores) && count($stores) >= 1) {
72
- foreach ($stores as $store) {
73
- if ($this->isEnabled('store', $store->getId())) {
74
- return true;
75
- }
76
- }
77
- }
78
-
79
- return false;
80
- }
81
-
82
- /**
83
- * Check if module is enabled
84
- *
85
- * @param string $scope
86
- * @param int $scopeId
87
- *
88
- * @return bool
89
- */
90
- public function isEnabled($scope = 'default', $scopeId = 0)
91
- {
92
- // Get Enabled Scope
93
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
94
- }
95
-
96
- /*
97
- * Get Text to display in notice when enabling module
98
- *
99
- * @return string
100
- */
101
- public function getModuleEnabledText()
102
- {
103
- $message = parent::getModuleEnabledText();
104
- $scopeData = $this->getScopeParams();
105
- if ($scopeData['scope'] != 'default') {
106
- $message = $this->__(
107
- 'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
108
- 'you should un-check the `Use Website` or `Use Default` for ALL options in the <em>Assign Templates</em> group on this page ' .
109
- 'and select the desired templates.'
110
- );
111
- }
112
-
113
- return $message;
114
- }
115
-
116
- /**
117
- * Gets the default rule id
118
- *
119
- * @param string $scope
120
- * @param int $scopeId
121
- * @return string
122
- */
123
- public function getDefaultRule($scope = 'default', $scopeId = 0)
124
- {
125
- return $this->getAdminScopedConfig(self::XML_PATH_DEFAULT_COUPON, $scope, $scopeId);
126
- }
127
-
128
- /**
129
- * Gets the default product recommendation
130
- *
131
- * @param string $scope
132
- * @param int $scopeId
133
- * @return string
134
- */
135
- public function getDefaultRecommendation($scope = 'default', $scopeId = 0)
136
- {
137
- return $this->getAdminScopedConfig(self::XML_PATH_DEFAULT_REC, $scope, $scopeId);
138
- }
139
-
140
- /**
141
- * Gets the default send flags
142
- *
143
- * @param string $scope
144
- * @param int $scopeId
145
- * @return int
146
- */
147
- public function getDefaultSendFlags($scope = 'default', $scopeId = 0)
148
- {
149
- return $this->getAdminScopedConfig(self::XML_PATH_DEFAULT_SEND_FLAG, $scope, $scopeId);
150
- }
151
-
152
- /**
153
- * Get Config setting for sending through bronto
154
- *
155
- * @param string $scope
156
- * @param int $scopeId
157
- *
158
- * @return bool
159
- */
160
- public function canUseBronto($scope = 'default', $scopeId = 0)
161
- {
162
- if (!$this->getApiToken($scope, $scopeId)) {
163
- return false;
164
- }
165
-
166
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_USE_BRONTO, $scope, $scopeId);
167
- }
168
-
169
- /**
170
- * Sets the "Send through Bronto" option for any config scope
171
- *
172
- * @param $brontoSend
173
- * @param string $scope
174
- * @param int $scopeId
175
- *
176
- * @return $this
177
- */
178
- public function setUseBronto($brontoSend, $scope = 'default', $scopeId = 0)
179
- {
180
- $config = Mage::getModel('core/config');
181
- $config->saveConfig(self::XML_PATH_USE_BRONTO, $brontoSend ? '1' : '0', $scope, $scopeId);
182
-
183
- return $this;
184
- }
185
-
186
- /**
187
- * Determine if email can be sent through bronto
188
- *
189
- * @param Mage_Core_Model_Email_Template $template
190
- * @param null $storeId
191
- *
192
- * @return bool
193
- */
194
- public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
195
- {
196
- if (
197
- $this->isEnabled('store', $storeId) &&
198
- $this->canUseBronto('store', $storeId) &&
199
- !is_null($template->getBrontoMessageId()) &&
200
- $template->getTemplateSendType() != 'magento'
201
- ) {
202
- return true;
203
- }
204
-
205
- return false;
206
- }
207
-
208
- /**
209
- * @return bool
210
- */
211
- public function isLogEnabled()
212
- {
213
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_LOG_ENABLED);
214
- }
215
-
216
- /**
217
- * @return bool
218
- */
219
- public function isLogFieldsEnabled()
220
- {
221
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_LOG_FIELDS_ENABLED);
222
- }
223
-
224
- /**
225
- * @see parent
226
- * @return bool
227
- */
228
- public function hasCustomConfig()
229
- {
230
- return true;
231
- }
232
-
233
- /**
234
- * Gets any saved emails, and reports it
235
- *
236
- * @return array
237
- */
238
- public function getCustomConfig($scope = 'default', $scopeId = 0)
239
- {
240
- $emails = array();
241
- $templates = Mage::getModel('bronto_email/template')->getCollection();
242
-
243
- if ($this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, array('edition' => 'Professional', 'major' => 9), 10))) {
244
- $templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
245
- $brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
246
- $templates->getSelect()->joinLeft(
247
- $brontoTable,
248
- "{$templateTable}.template_id = {$brontoTable}.core_template_id"
249
- );
250
- }
251
-
252
- $templates->addFieldToFilter('bronto_message_id', array('notnull' => true));
253
-
254
- foreach ($templates as $template) {
255
- $emails[] = array(
256
- 'template_id' => $template->getTemplateId(),
257
- 'template_code' => $template->getTemplateCode(),
258
- 'bronto_message_id' => $template->getBrontoMessageId(),
259
- 'bronto_message_name' => $template->getBrontoMessageName(),
260
- 'send_type' => $template->getTemplateSendType(),
261
- );
262
- }
263
-
264
- $settings = array();
265
- foreach ($this->getTemplatePaths() as $configPath) {
266
- $data = $this->getAdminScopedConfig($configPath, $scope, $scopeId);
267
- if (str_replace('/', '_', $configPath) == $data) {
268
- $data = 'Default';
269
- }
270
- $settings[$configPath] = $data;
271
- }
272
-
273
- return array(
274
- 'templates' => $emails,
275
- 'settings' => $settings,
276
- );
277
- }
278
-
279
- /**
280
- * Get array of all template config paths
281
- *
282
- * @return array
283
- */
284
- public function getTemplatePaths()
285
- {
286
- $templatePaths = array();
287
-
288
- $configSections = Mage::getSingleton('adminhtml/config')->getSections();
289
-
290
- // look for node entries in all system.xml that use source_model=adminhtml/system_config_source_email_template
291
- // they are will be templates, what we try find
292
- $sysCfgNodes = $configSections->xpath(self::XML_PATH_TEMPLATE_EMAIL);
293
- if (!is_array($sysCfgNodes)) {
294
- return array();
295
- }
296
-
297
- foreach ($sysCfgNodes as $fieldNode) {
298
-
299
- $groupNode = $fieldNode->getParent()->getParent();
300
- $sectionNode = $groupNode->getParent()->getParent();
301
-
302
- // create email template path in system.xml
303
- $sectionName = $sectionNode->getName();
304
- $groupName = $groupNode->getName();
305
- $fieldName = $fieldNode->getName();
306
-
307
- $templatePaths[] = implode('/', array($sectionName, $groupName, $fieldName));
308
- }
309
-
310
- return $templatePaths;
311
- }
312
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Helper/Field.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Retrieve helper module name
11
- *
12
- * @return string
13
- */
14
- protected function _getModuleName()
15
- {
16
- return 'Bronto_Email';
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Helper/Message.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Retrieve helper module name
11
- *
12
- * @return string
13
- */
14
- protected function _getModuleName()
15
- {
16
- return 'Bronto_Email';
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Log.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->_init('bronto_email/log');
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Message.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
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
- {
9
- public function _construct()
10
- {
11
- parent::_construct();
12
- $this->_init('bronto_email/message');
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Mysql4/Log.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
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
- {
9
- public function _construct()
10
- {
11
- $this->_init('bronto_email/log', 'log_id');
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Mysql4/Log/Collection.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->_init('bronto_email/log');
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_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
-
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/Email/Model/Mysql4/Message.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Primery key auto increment flag
11
- *
12
- * @var bool
13
- */
14
- protected $_isPkAutoIncrement = false;
15
-
16
- public function _construct()
17
- {
18
- $this->_init('bronto_email/message', 'core_template_id');
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Mysql4/Message/Collection.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->_init('bronto_email/message');
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Mysql4/Template.php DELETED
@@ -1,74 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Initialize email template resource model
11
- *
12
- */
13
- protected function _construct()
14
- {
15
- parent::_construct();
16
- $this->_init('bronto_email/template', 'template_id');
17
- $this->_setMainTable('core/email_template', 'template_id');
18
- }
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)
29
- {
30
- $select = $this->_getReadAdapter()->select()
31
- ->from($this->getTable('core/email_template'))
32
- ->where("`{$this->getTable('core/email_template')}`.`orig_template_code` = :orig_template_code")
33
- ->joinLeft(
34
- $this->getTable('bronto_email/message'),
35
- "`{$this->getTable('core/email_template')}`.`template_id` = `{$this->getTable('bronto_email/message')}`.`core_template_id`"
36
- );
37
-
38
- // Filter by store_id if provided
39
- if ($storeId) {
40
- $select->where("`{$this->getTable('bronto_email/message')}`.`store_id` = ?", $storeId);
41
- }
42
-
43
- $result = $this->_getReadAdapter()->fetchRow($select, array('orig_template_code' => $templateCode));
44
-
45
- if (!$result) {
46
- return array();
47
- }
48
-
49
- return $result;
50
- }
51
-
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)
67
- ->joinLeft(
68
- array($this->getTable('bronto_email/message')),
69
- "`{$this->getMainTable()}`.`template_id` = `{$this->getTable('bronto_email/message')}`.`core_template_id`"
70
- );
71
-
72
- return $select;
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Mysql4/Template/Collection.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected $_brontoTable;
10
-
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, array('edition' => 'Professional', 'major' => 9)))) {
17
- $this->_select->joinLeft(
18
- array($this->_brontoTable),
19
- "{$this->_templateTable}.template_id = {$this->_brontoTable}.core_template_id"
20
- );
21
- }
22
- }
23
-
24
- /**
25
- * Adds the store filtering based on All Store views or a specific one
26
- *
27
- * @param int $storeId
28
- * @return Bronto_Email_Model_Mysql4_Template_Collection
29
- */
30
- public function addStoreViewFilter($storeId)
31
- {
32
- return $this->addFieldToFilter('store_id', array(
33
- 'in' => array('0', $storeId))
34
- );
35
- }
36
-
37
- /**
38
- * Init collection select
39
- *
40
- * @return Bronto_Email_Model_Mysql4_Template_Collection
41
- */
42
- protected function _initSelect()
43
- {
44
- $this->getSelect()->from(array('main_table' => $this->getMainTable()))
45
- ->joinLeft(
46
- array($this->_brontoTable),
47
- "main_table.template_id = {$this->_brontoTable}.core_template_id"
48
- );
49
-
50
- return $this;
51
- }
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Observer.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
-
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)
17
- {
18
- if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
19
- return;
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)
34
- {
35
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_email')->__(Mage::helper('bronto_email')->getModuleEnabledText()));
36
- }
37
-
38
- /**
39
- * Observes the module becoming enabled and moves custom templates to the
40
- * bronto email table
41
- *
42
- * @param Varien_Event_Observer $observer
43
- */
44
- public function moveOldTemplates(Varien_Event_Observer $observer)
45
- {
46
- $helper = Mage::helper('bronto_email');
47
- $settings = $helper->getTemplatePaths();
48
- $scopeParams = $helper->getScopeParams();
49
- foreach ($settings as $setting) {
50
- $data = $helper->getAdminScopedConfig($setting);
51
- if (str_replace('/', '_', $setting) == $data) {
52
- continue;
53
- }
54
- $model = Mage::getModel('bronto_email/message')->load($data);
55
- if (!$model->getId()) {
56
- try {
57
- Mage::getModel('bronto_email/template_import')
58
- ->importTemplate($data, $scopeParams['store_id'], true);
59
- } catch (Exception $e) {
60
- $helper->writeError("Failed to import message {$e->getMessage()}");
61
- }
62
- }
63
- }
64
- }
65
-
66
- /**
67
- * Grab Config Data Object before save and handle the 'Create New...' value for
68
- * fields that were generated dynamically
69
- *
70
- * @param Varien_Event_Observer $observer
71
- *
72
- * @return Varien_Event_Observer
73
- */
74
- public function saveDynamicField(Varien_Event_Observer $observer)
75
- {
76
- if (!Mage::helper(self::NOTICE_IDENTIFIER)->isEnabled()) {
77
- return $observer;
78
- }
79
-
80
- $action = $observer->getEvent()->getControllerAction();
81
-
82
- if ($action->getRequest()->getParam('section') == 'bronto_email') {
83
- $groups = $action->getRequest()->getPost('groups');
84
- $website = $action->getRequest()->getParam('website');
85
- $store = $action->getRequest()->getParam('store');
86
-
87
- // Handle saving as real path values
88
- $this->_handleAttributes($website, $store, $groups);
89
-
90
- // Unset groups for bronto_email template paths
91
- unset($groups['templates']);
92
- $observer->getEvent()->getControllerAction()
93
- ->getRequest()->setPost('groups', $groups);
94
-
95
- // reinit configuration
96
- Mage::getConfig()->reinit();
97
- Mage::app()->reinitStores();
98
- }
99
-
100
- return $observer;
101
- }
102
-
103
- /**
104
- * Get Section, Group, and field from field path and save to "real" path
105
- *
106
- * @param $website
107
- * @param $store
108
- * @param $groups
109
- */
110
- protected function _handleAttributes($website, $store, $groups)
111
- {
112
- $fields = $groups['templates']['fields'];
113
- $config = Mage::getModel('core/config');
114
- $scopeParams = Mage::helper('bronto_common')->getScopeParams();
115
-
116
- // Cycle through template fields
117
- foreach ($fields as $field => $fieldData) {
118
- // Get Section, Group and Field
119
- list($sectionName, $groupName, $fieldName) = explode('-', $field);
120
- $sectionName = str_replace('bronto_email_templates_', '', $sectionName);
121
- if (is_array($fieldData) && !array_key_exists('value', $fieldData)) {
122
- continue;
123
- }
124
-
125
- // Because send_type values aren't arrays, we have to
126
- $value = (is_array($fieldData)) ? $fieldData['value'] : $fieldData;
127
-
128
- $scope = $scopeParams['scope'];
129
- if ($scope != 'default') {
130
- $scope .= 's';
131
- }
132
-
133
- $config->saveConfig(
134
- $sectionName . '/' . $groupName . '/' . $fieldName,
135
- $value,
136
- $scope,
137
- $scopeParams[$scopeParams['scope'] . '_id']
138
- );
139
- }
140
- }
141
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Resource/Setup.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Email_Model_Resource_Setup extends Bronto_Common_Model_Resource_Abstract
4
- {
5
-
6
- /**
7
- * @see parent
8
- */
9
- protected function _module()
10
- {
11
- return 'bronto_email';
12
- }
13
-
14
- /**
15
- * @see parent
16
- */
17
- protected function _tables()
18
- {
19
- return array(
20
- 'message' => "
21
- CREATE TABLE `{table}` (
22
- `core_template_id` int(10) unsigned NOT NULL COMMENT 'Magento Template ID',
23
- `template_send_type` varchar(255) NOT NULL DEFAULT 'magento' COMMENT 'Type of message to send as',
24
- `orig_template_text` text COMMENT 'Original Template Text',
25
- `bronto_message_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Message ID',
26
- `bronto_message_name` varchar(255) DEFAULT NULL COMMENT 'Bronto Message Name',
27
- `bronto_message_approved` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Bronto Message Transactional Approval Status',
28
- `store_id` int(11) NOT NULL DEFAULT '1' COMMENT 'Store ID for Template',
29
- `sales_rule` int(10) NULL COMMENT 'Sales Rule for Coupon Codes',
30
- `product_recommendation` int(11) unsigned DEFAULT NULL COMMENT 'Product Recommendations',
31
- `send_flags` int(3) unsigned DEFAULT NULL COMMENT 'Delivery Flags',
32
- `inline_css` varchar(255) DEFAULT NULL COMMENT 'Inline CSS file used in the lastest version of Magento',
33
- PRIMARY KEY (`core_template_id`),
34
- KEY `IDX_BRONTO_STORE_ID` (`store_id`),
35
- CONSTRAINT `FK_BRONTO_EMAIL_TEMPLATE_ID_CORE_EMAIL_TEMPLATE_ID` FOREIGN KEY (`core_template_id`)
36
- REFERENCES `{$this->getTable('core/email_template')}` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
37
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Template Attributes'
38
- ",
39
- 'log' => "
40
- CREATE TABLE `{table}` (
41
- `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
42
- `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
43
- `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
44
- `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
45
- `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
46
- `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
47
- `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
48
- `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
49
- `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
50
- `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
51
- `fields` text COMMENT 'Fields',
52
- PRIMARY KEY (`log_id`),
53
- KEY `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`),
54
- KEY `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`)
55
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Delivery Logs'
56
- ");
57
- }
58
-
59
- /**
60
- * @see parent
61
- */
62
- protected function _updates()
63
- {
64
- return array(
65
- '1.2.0' => array(
66
- 'message' => array(
67
- 'sql' =>
68
- "ALTER TABLE {table} ADD COLUMN `product_recommendation` int(11) unsigned DEFAULT NULL AFTER `sales_rule`;"
69
- )
70
- ),
71
- '1.2.1' => array(
72
- 'message' => array(
73
- 'sql' =>
74
- "ALTER TABLE {table} ADD COLUMN `send_flags` int(3) unsigned DEFAULT NULL AFTER `product_recommendation`;"
75
- )
76
- ),
77
- '1.2.2' => array(
78
- 'message' => array(
79
- 'sql' =>
80
- 'ALTER TABLE {table} ADD COLUMN `inline_css` varchar(255) DEFAULT NULL AFTER `send_flags`;'
81
- )
82
- )
83
- );
84
- }
85
-
86
- /**
87
- * Sets the Bronto sending for all available scopes if the module is enabled
88
- *
89
- * @return Bronto_Email_Model_Resource_Setup
90
- */
91
- public function setDefaultSending()
92
- {
93
- $this->_reloadNewConfig()->_setDefaultSending()->_reloadNewConfig();
94
- foreach (Mage::app()->getWebsites() as $website) {
95
- $this->_setDefaultSending(null, $website->getId());
96
- }
97
-
98
- $this->_reloadNewConfig();
99
- foreach (Mage::app()->getStores() as $store) {
100
- $this->_setDefaultSending($store->getId());
101
- }
102
-
103
- return $this;
104
- }
105
-
106
- /**
107
- * @return Bronto_Email_Model_Resource_Setup
108
- */
109
- protected function _reloadNewConfig()
110
- {
111
- Mage::getConfig()->reinit();
112
- Mage::app()->reinitStores();
113
-
114
- return $this;
115
- }
116
-
117
- /**
118
- * Sets the default sending to bronto is the module is enabled
119
- *
120
- * @param string|int $storeId
121
- * @param string|int $websiteId
122
- *
123
- * @return Bronto_Email_Model_Resource_Setup
124
- */
125
- protected function _setDefaultSending($storeId = null, $websiteId = null)
126
- {
127
- if (!is_null($storeId)) {
128
- $scope = 'store';
129
- $scopeId = $storeId;
130
- } elseif (!is_null($websiteId)) {
131
- $scope = 'website';
132
- $scopeId = $websiteId;
133
- } else {
134
- $scope = 'default';
135
- $scopeId = 0;
136
- }
137
- $helper = Mage::helper('bronto_email');
138
- if (
139
- $helper->isEnabled($scope, $scopeId) &&
140
- !$helper->canUseBronto($scope, $scopeId)
141
- ) {
142
- $helper->setUseBronto(true, $scope, $scopeId);
143
- }
144
-
145
- return $this;
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Field.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Customer
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Email_Model_System_Config_Backend_Templates_Field extends Mage_Core_Model_Config_Data
8
- {
9
-
10
- /**
11
- * Processing object before save data
12
- *
13
- * @return Mage_Core_Model_Abstract
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
-
21
- parent::_beforeSave();
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
- {
34
- Mage::getModel('core/config_data')
35
- ->load($path, 'path')
36
- ->setValue($value)
37
- ->setPath($path)
38
- ->save();
39
-
40
- return $this;
41
- }
42
-
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Sendtype.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Customer
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Email_Model_System_Config_Backend_Templates_Sendtype extends Mage_Core_Model_Config_Data
8
- {
9
- /**
10
- * Processing object before save data
11
- *
12
- * @return Mage_Core_Model_Abstract
13
- */
14
- protected function _beforeSave()
15
- {
16
- $realpath = str_replace('-', '/', array_pop(explode('/', $this->getPath())));
17
- $this->_saveConfigData($realpath, $this->getValue());
18
-
19
- parent::_beforeSave();
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
- {
32
- Mage::getModel('core/config_data')
33
- ->load($path, 'path')
34
- ->setValue($value)
35
- ->setPath($path)
36
- ->save();
37
-
38
- return $this;
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/System/Config/Backend/Usebronto.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
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
- {
9
-
10
- protected $_eventPrefix = 'bronto_email_usebronto';
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/System/Config/Source/Email/Template.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Email_Model_System_Config_Source_Email_Template extends Mage_Adminhtml_Model_System_Config_Source_Email_Template
4
- {
5
-
6
- /**
7
- * Generate list of email templates
8
- *
9
- * @return array
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, array('edition' => 'Professional', 'major' => 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->addStoreViewFilter($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
59
- $pathParts = explode('/', $this->getPath());
60
-
61
- if ('bronto_email' == $pathParts[0] && 'templates' == $pathParts[1]) {
62
- $path = str_replace('-', '/', array_pop($pathParts));
63
- } else {
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');
78
- if ($templateLabelNode) {
79
- $templateName = Mage::helper('adminhtml')->__((string)$templateLabelNode);
80
- $templateName = Mage::helper('adminhtml')->__('%s (Default Template from Locale)', $templateName);
81
- }
82
-
83
- array_unshift(
84
- $options, array(
85
- 'value' => $nodeName,
86
- 'label' => $templateName
87
- )
88
- );
89
-
90
- return $options;
91
- }
92
-
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/System/Config/Source/Sendtype.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Bronto\Customer
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Email_Model_System_Config_Source_Sendtype
8
- {
9
- /**
10
- * @return array
11
- */
12
- public function toOptionArray()
13
- {
14
- return array(
15
- array('value' => 'transactional', 'label' => Mage::helper('adminhtml')->__('Transactional')),
16
- array('value' => 'marketing', 'label' => Mage::helper('adminhtml')->__('Marketing')),
17
- );
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Template.php DELETED
@@ -1,229 +0,0 @@
1
- <?php
2
- class Bronto_Email_Model_Template extends Bronto_Common_Model_Email_Template
3
- {
4
- /**
5
- * @var string
6
- */
7
- protected $_helper = 'bronto_email';
8
-
9
- /**
10
- * Constructor
11
- */
12
- public function _construct()
13
- {
14
- $this->_init('bronto_email/template');
15
- }
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
- {
28
- $originalTemplate = $this->getResource()->loadByOriginalCode($templateCode, $storeId);
29
-
30
- if (count($originalTemplate)) {
31
- $this->addData($originalTemplate);
32
- } else {
33
- $this->loadDefault($templateCode, $locale);
34
- $this->setOrigTemplateCode($templateCode);
35
- }
36
-
37
- return $this;
38
- }
39
-
40
- /**
41
- * Handle loading Existing and Default Magento templates
42
- *
43
- * @return boolean
44
- */
45
- public function handleDefaultTemplates()
46
- {
47
- /** @var $templateMode Bronto_Email_Model_Template_Import */
48
- $templateModel = Mage::getModel('bronto_email/template_import');
49
-
50
- // Process Templates
51
- try {
52
- $templateModel->handleDefaults();
53
- } catch (Exception $e) {
54
- Mage::throwException($e->getMessage());
55
- }
56
-
57
- return true;
58
- }
59
-
60
- /**
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
-
76
- $data = & $defaultTemplates[$templateId];
77
- $this->setTemplateType($data['type'] == 'html' ? self::TYPE_HTML : self::TYPE_TEXT);
78
-
79
- $templateText = Mage::app()->getTranslator()->getTemplateFile(
80
- $data['file'], 'email', $locale
81
- );
82
-
83
- if (preg_match('/<!--@subject\s*(.*?)\s*@-->/', $templateText, $matches)) {
84
- $this->setTemplateSubject($matches[1]);
85
- $templateText = str_replace($matches[0], '', $templateText);
86
- }
87
-
88
- if (preg_match('/<!--@vars\n((?:.)*?)\n@-->/us', $templateText, $matches)) {
89
- $this->setData('orig_template_variables', str_replace("\n", '', $matches[1]));
90
- $templateText = str_replace($matches[0], '', $templateText);
91
- }
92
-
93
- if (preg_match('/<!--@styles\s*(.*?)\s*@-->/sm', $templateText, $matches)) {
94
- $this->setTemplateStyles($matches[1]);
95
- $templateText = str_replace($matches[0], '', $templateText);
96
- }
97
-
98
- /**
99
- * Remove comment lines
100
- */
101
- $templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText);
102
-
103
- $this->setTemplateText($templateText);
104
- $this->setOrigTemplateText($templateText);
105
- $this->setId($templateId);
106
-
107
- return $this;
108
- }
109
-
110
- /**
111
- * Collect all system config paths where current template is used as default
112
- *
113
- * @return array
114
- */
115
- public function getSystemConfigPathsWhereUsedAsDefault()
116
- {
117
- $templateCode = $this->getOrigTemplateCode();
118
- if (!$templateCode) {
119
- return array();
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 . '"]');
127
-
128
- if (!is_array($defaultCfgNodes)) {
129
- return array();
130
- }
131
-
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);
141
- }
142
- }
143
-
144
- return $paths;
145
- }
146
-
147
- /**
148
- * Collect all system config paths where current template is currently used
149
- *
150
- * @return array
151
- */
152
- public function getSystemConfigPathsWhereUsedCurrently()
153
- {
154
- $templateCode = $this->getTemplateId();
155
- if (!$templateCode) {
156
- return array();
157
- }
158
-
159
- $paths = Mage::helper($this->_helper)->getTemplatePaths();
160
-
161
- $configData = $this->_getResource()->getSystemConfigByPathsAndTemplateId($paths, $templateCode);
162
- if (!$configData) {
163
- return array();
164
- }
165
-
166
- return $configData;
167
- }
168
-
169
- /**
170
- * @see parent
171
- */
172
- protected function _emailClass()
173
- {
174
- return 'bronto_email/template';
175
- }
176
-
177
- /**
178
- * Log about the functionality of sending the email before it goes out
179
- *
180
- * @param Bronto_Api_Model_Contact $contact
181
- * @param Bronto_Api_Model_Message $message
182
- *
183
- * @return void
184
- */
185
- protected function _beforeSend(Bronto_Api_Model_Contact $contact, Bronto_Api_Model_Message $message)
186
- {
187
- Mage::dispatchEvent('bronto_email_send_before');
188
-
189
- if (Mage::helper('bronto_email')->isLogEnabled()) {
190
- $this->_log = Mage::getModel('bronto_email/log');
191
- $this->_log->setCustomerEmail($contact->email);
192
- $this->_log->setContactId($contact->id);
193
- $this->_log->setMessageId($message->id);
194
- $this->_log->setMessageName($message->name);
195
- $this->_log->setSuccess(0);
196
- $this->_log->setSentAt(new Zend_Db_Expr('NOW()'));
197
- $this->_log->save();
198
- }
199
- }
200
-
201
- /**
202
- * Log data on sending message
203
- *
204
- * @param bool $success
205
- * @param string $error
206
- * @param Bronto_Api_Model_Delivery $delivery
207
- *
208
- * @return void
209
- */
210
- protected function _afterSend($success, $error = null, Bronto_Api_Model_Delivery $delivery = null)
211
- {
212
- Mage::dispatchEvent('bronto_email_send_after');
213
-
214
- if (Mage::helper('bronto_email')->isLogEnabled()) {
215
- $this->_log->setSuccess((int)$success);
216
- if (!empty($error)) {
217
- $this->_log->setError($error);
218
- }
219
- if ($delivery) {
220
- $this->_log->setDeliveryId($delivery->id);
221
- if (Mage::helper('bronto_email')->isLogFieldsEnabled()) {
222
- $this->_log->setFields(serialize($delivery->getFields()));
223
- }
224
- }
225
- $this->_log->save();
226
- $this->_log = null;
227
- }
228
- }
229
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Template/Import.php DELETED
@@ -1,317 +0,0 @@
1
- <?php
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
- {
8
- /**
9
- * @var Bronto_Api_Object
10
- */
11
- private $_apiObject;
12
-
13
- /**
14
- * Load Template to import into Bronto
15
- *
16
- * @param int $templateId
17
- * @param mixed $storeId
18
- * @param bool $force
19
- *
20
- * @return string
21
- * @throws Exception
22
- */
23
- public function importTemplate($templateId, $storeId = false, $force = false)
24
- {
25
- /** @var $template Bronto_Email_Model_Template_Import */
26
- $template = $this->load($templateId);
27
-
28
- try {
29
- return $this->processMessage($template, $storeId, $force);
30
- } catch (Exception $e) {
31
- throw new Exception($e->getMessage());
32
- }
33
- }
34
-
35
- /**
36
- * Import template into Bronto
37
- *
38
- * @param Bronto_Email_Model_Template $template
39
- * @param bool $storeId
40
- *
41
- * @return bool
42
- */
43
- protected function processMessage(Bronto_Email_Model_Template $template, $storeId = false, $force = false)
44
- {
45
- $data = $template->getData();
46
- $emt = Mage::getModel('bronto_common/email_template_templatefilter');
47
-
48
- // Get Store
49
- $store = null;
50
- if ($storeId) {
51
- $store = Mage::app()->getStore($storeId);
52
- } else if (isset($data['store_id'])) {
53
- $store = Mage::app()->getStore($data['store_id']);
54
- }
55
-
56
- if (empty($store)) {
57
- $store = Mage::app()->getDefaultStoreView();
58
- }
59
-
60
- if (!$store) {
61
- $store = Mage::app()->getStore();
62
- }
63
-
64
- // If module is not enabled for this store, don't proceed
65
- if (!$force && !Mage::helper('bronto_email')->isEnabled('store', $store->getId())) {
66
- return false;
67
- }
68
-
69
- // Get Token
70
- $api = Mage::helper('bronto_common')->getApi(null, 'store', $store->getId());
71
- if (!$api) {
72
- return false;
73
- }
74
-
75
- $messageOps = $api->transferMessage();
76
- if (method_exists($emt, 'getInlineCssFile')) {
77
- $emt
78
- ->setTemplateProcessor(array($template, 'getTemplateByConfigPath'))
79
- ->setIncludeProcessor(array($template, 'getInclude'))
80
- ->setUseAbsoluteLinks(true)
81
- ->setStoreId($store->getId())
82
- ->setUseSessionInUrl(false);
83
- }
84
-
85
- $appEmu = Mage::getSingleton('core/app_emulation');
86
- $emuInfo = $appEmu->startEnvironmentEmulation($store->getId(), 'frontend');
87
-
88
- // Add Check for required fields
89
- if (array_key_exists('template_text', $data) && array_key_exists('template_subject', $data)) {
90
- // Define variables for filtered Subject and Text
91
- $templateSubject = $emt->filter($data['template_subject']);
92
- $templateText = $emt->filter($data['template_text']);
93
- $templateTextRip = $emt->filter($this->ripTags($data['template_text']));
94
-
95
- if (method_exists($emt, 'getInlineCssFile')) {
96
- $template->setInlineCssFile($emt->getInlineCssFile());
97
- $templateText = $template->getPreparedTemplateText($templateText);
98
- }
99
-
100
- // If message missing subject, use template code
101
- if ('' == $templateSubject) {
102
- $templateSubject = $data['template_code'];
103
- $template->setTemplateSubject($data['template_code']);
104
- }
105
-
106
- try {
107
- // Template has invalid or missing required attributes
108
- if ('' == $templateText || '' == $templateTextRip) {
109
- Mage::throwException('Template is missing body');
110
- }
111
-
112
- $message = $messageOps->read()
113
- ->where->name->equalTo($data['template_code'])
114
- ->withIncludeContent(true)
115
- ->first();
116
- if (!$message) {
117
- $message = $messageOps->createObject()
118
- ->withName($data['template_code'])
119
- ->withStatus('active');
120
- }
121
- $message
122
- ->addHtml($templateSubject, $templateText)
123
- ->addText($templateSubject, $templateTextRip);
124
-
125
- $writeOps = $message->hasId() ?
126
- $messageOps->update()->updateMessage($message) :
127
- $messageOps->add()->addMessage($message);
128
- foreach ($writeOps as $result) {
129
- $item = $result->getItem();
130
- if ($item->getIsError()) {
131
- Mage::throwException($item->getErrorCode() . ' ' . $item->getErrorMessage());
132
- } else if ($item->getIsNew()) {
133
- $message->withId($item->getId());
134
- }
135
- }
136
- } catch (Exception $e) {
137
- $appEmu->stopEnvironmentEmulation($emuInfo);
138
- Mage::throwException("Failed Importing Template `{$data['template_code']}` : [Bronto] " . $e->getMessage());
139
-
140
- return false;
141
- }
142
-
143
- // Create Bronto Template Entry
144
- $brontoTemplate = Mage::getModel('bronto_email/message')
145
- ->load($template->getId())
146
- ->setCoreTemplateId($template->getId())
147
- ->setOrigTemplateText($templateText)
148
- ->setBrontoMessageId($message->getId())
149
- ->setBrontoMessageName($message->getName())
150
- ->setBrontoMessageApproved(1)
151
- ->setStoreId($store->getId())
152
- ->setInlineCss($template->getInlineCssFile())
153
- ->save();
154
-
155
- // Clean Up
156
- unset($brontoTemplate);
157
- }
158
- $appEmu->stopEnvironmentEmulation($emuInfo);
159
-
160
- return true;
161
- }
162
-
163
- /**
164
- * Collect all existing and default templates from magento and add to new table
165
- */
166
- public function handleDefaults()
167
- {
168
- // process existing
169
- try {
170
- $this->_processExisting();
171
- } catch (Exception $e) {
172
- Mage::throwException($this->__('Failed loading existing templates'));
173
- }
174
-
175
- // process defaults
176
- try {
177
- $allStores = Mage::app()->getStores();
178
- $this->_processDefaults($allStores);
179
- } catch (Exception $e) {
180
- Mage::throwException($this->__('Failed loading default templates'));
181
- }
182
-
183
- return true;
184
- }
185
-
186
- /**
187
- * Load Existing templates into Bronto Email Template table
188
- *
189
- * @return bool
190
- */
191
- protected function _processExisting()
192
- {
193
- $customTemplates = $this->getCollection();
194
- foreach ($customTemplates as $customTemplate) {
195
- try {
196
- /** @var $template Bronto_Email_Model_Message */
197
- $template = Mage::getModel('bronto_email/message')
198
- ->load($customTemplate->getId());
199
-
200
- // If we didn't get a template match, set the Id
201
- if (is_null($template->getId())) {
202
- $template->setId($customTemplate->getId());
203
- }
204
-
205
- // If message does not already exist, then proceed
206
- if (!$template->getBrontoMessageId() || is_null($template->getBrontoMessageId())) {
207
- $template->setTemplateSendType('magento')
208
- ->setOrigTemplateText($customTemplate->getTemplateText())
209
- ->setBrontoMessageId(null)
210
- ->setBrontoMessageName(null)
211
- ->setBrontoMessageApproved(0)
212
- ->save();
213
- }
214
-
215
- // Clean up
216
- unset($template);
217
- } catch (Exception $e) {
218
- Mage::helper('bronto_email')->writeDebug('Bronto Import Existing Templates:' . $e->getMessage());
219
- }
220
- }
221
-
222
- return true;
223
- }
224
-
225
- /**
226
- * Load Default templates into Bronto Email Template table
227
- *
228
- * @param array $allStores
229
- *
230
- * @return bool
231
- */
232
- protected function _processDefaults(array $allStores)
233
- {
234
- foreach ($allStores as $_eachStoreId) {
235
- $_store = Mage::app()->getStore($_eachStoreId);
236
- $_storeCode = $_store->getCode();
237
- $_storeId = $_store->getId();
238
- $_locale = $_store->getConfig('general/locale/code');
239
-
240
- //process default
241
- $templates = $this->getDefaultTemplates();
242
- foreach (array_keys($templates) as $templateToLoad) {
243
- try {
244
- /** @var $template Bronto_Email_Model_Template */
245
- $template = Mage::getModel('bronto_email/template');
246
-
247
- $template->loadByOriginalCode($templateToLoad, $_storeId, $_locale);
248
-
249
- // Ensure Defaults use pretty label
250
- $label = $templates[$templateToLoad]['label'] . ' (' . $_storeCode . ')';
251
- if ('en_US' != $_locale) {
252
- $label .= ' [' . $_locale . ']';
253
- }
254
-
255
- // Create Core Template
256
- $template->setTemplateCode($label);
257
- $templateText = trim($template->getTemplateText());
258
- $template->setTemplateText($templateText);
259
- $template->setAddedAt(Mage::getModel('core/date')->date('Y-m-d H:i:s'));
260
- $template->unsTemplateId(); // template ID may be template code, so unset it
261
-
262
- $template->save();
263
-
264
- // Get Template ID from Core Template
265
- $templateId = $template->getId();
266
-
267
- // Build Bronto Template
268
- /** @var $brontoTemplate Bronto_Email_Model_Message */
269
- $brontoTemplate = Mage::getModel('bronto_email/message')
270
- ->load($templateId);
271
-
272
- // If we didn't get a template match, set the Id
273
- if (is_null($brontoTemplate->getId())) {
274
- $brontoTemplate->setId($templateId);
275
- }
276
-
277
- // If message does not already exist, then proceed
278
- if (!$brontoTemplate->getBrontoMessageId() || is_null($brontoTemplate->getBrontoMessageId())) {
279
- $brontoTemplate->setTemplateSendType('magento')
280
- ->setOrigTemplateText($templateText)
281
- ->setBrontoMessageId(null)
282
- ->setBrontoMessageName(null)
283
- ->setBrontoMessageApproved(0)
284
- ->setStoreId($_storeId)
285
- ->save();
286
- }
287
-
288
- // Clean up
289
- unset($template);
290
- unset($brontoTemplate);
291
- } catch (Exception $e) {
292
-
293
- Mage::helper('bronto_email')->writeDebug('Bronto Import Default Templates:' . $e->getMessage());
294
- }
295
- }
296
- }
297
-
298
- return true;
299
- }
300
-
301
- /**
302
- * Remove HTML and multiple spaces
303
- *
304
- * @param string $string
305
- *
306
- * @return string
307
- */
308
- protected function ripTags($string)
309
- {
310
- $string = preg_replace('/<[^>]*>/', ' ', $string);
311
- // ----- remove multiple spaces -----
312
- $string = trim(preg_replace('/ {2,}/', ' ', $string));
313
-
314
- return $string;
315
- }
316
-
317
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/Model/Template/Mailer.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
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());
26
-
27
- // If sending through bronto is not enabled, push through parent
28
- if (!Mage::helper('bronto_email')->canSendBronto($emailTemplate)) {
29
- return parent::send();
30
- }
31
-
32
- $message = new Bronto_Api_Model_Message();
33
- $message->withId($emailTemplate->getBrontoMessageId());
34
-
35
- // Send all emails from corresponding list
36
- while (!empty($this->_emailInfos)) {
37
- $emailInfo = array_pop($this->_emailInfos);
38
-
39
- // Handle "Bcc" recepients of the current email
40
- if ($emailTemplate->getTemplateSendType() == 'magento') {
41
- $emailTemplate->addBcc($emailInfo->getBccEmails());
42
- } else {
43
- foreach ($emailInfo->getBccEmails() as $bcc) {
44
- $emailInfo->addTo($bcc);
45
- }
46
- }
47
-
48
- // Set required design parameters and delegate email sending to Mage_Core_Model_Email_Template
49
- $emailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))
50
- ->sendTransactional(
51
- $message,
52
- $this->getSender(),
53
- $emailInfo->getToEmails(),
54
- $emailInfo->getToNames(),
55
- $this->getTemplateParams(),
56
- $this->getStoreId()
57
- );
58
- }
59
-
60
- return $this;
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/LogController.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected function _initAction()
10
- {
11
- $this->_title($this->__('Bronto Deliveries'))->_title($this->__('Logs'));
12
- $this->loadLayout()
13
- ->_setActiveMenu('system/email/log')
14
- ->_addBreadcrumb(
15
- Mage::helper('bronto_email')->__('Bronto Delivery Log'),
16
- Mage::helper('bronto_email')->__('Bronto Delivery Log')
17
- );
18
-
19
- return $this;
20
- }
21
-
22
- public function indexAction()
23
- {
24
- $this->_initAction()->renderLayout();
25
- }
26
-
27
- /**
28
- * Override for ACL permissions
29
- */
30
- protected function _isAllowed()
31
- {
32
- $session = Mage::getSingleton('admin/session');
33
- return $session->isAllowed('admin/system/config/bronto_email');
34
- }
35
-
36
- /**
37
- * Deletes all log history
38
- */
39
- public function clearAction()
40
- {
41
- /* @var $collection Bronto_Email_Model_Mysql4_Log_Collection */
42
- $collection = Mage::getModel('bronto_email/log')->getCollection();
43
- $collection->delete();
44
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bronto_email')->__('All log entries have been deleted'));
45
- $this->_redirect('*/*/index');
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/TemplateController.php DELETED
@@ -1,570 +0,0 @@
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
- {
11
-
12
- protected $_returnableActions = array('save', 'delete');
13
-
14
- /**
15
- * Main Grid view for Transactional Email Templates
16
- * Overwritten to show Bronto Templates
17
- *
18
- * @return null
19
- */
20
- public function indexAction()
21
- {
22
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
23
- return parent::indexAction();
24
- }
25
-
26
- $this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
27
- Mage::getSingleton('adminhtml/session')->setPostRedirect('*/*/');
28
-
29
- if ($this->getRequest()->getQuery('ajax')) {
30
- $this->_forward('brontoGrid');
31
-
32
- return false;
33
- }
34
-
35
- $this->loadLayout();
36
- $this->_setActiveMenu('system/email_template');
37
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Bronto Transactional Emails'), Mage::helper('adminhtml')->__('Bronto Transactional Emails'));
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()
51
- {
52
- $this->_title($this->__('System'))->_title($this->__('Import Transactional Emails'));
53
- Mage::getSingleton('adminhtml/session')->setPostRedirect('*/*/import');
54
-
55
- if ($this->getRequest()->getQuery('ajax')) {
56
- $this->_forward('grid');
57
-
58
- return;
59
- }
60
-
61
- $this->loadLayout();
62
- $this->_setActiveMenu('system/email_template');
63
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Import Transactional Emails'), Mage::helper('adminhtml')->__('Import Transactional Emails'));
64
-
65
- $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import', 'import'));
66
- $this->renderLayout();
67
- }
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
- {
76
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
77
- return parent::gridAction();
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
- {
92
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
93
- return parent::gridAction();
94
- }
95
-
96
- $this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_grid')->toHtml());
97
-
98
- return $this;
99
- }
100
-
101
- /**
102
- * Create drop-down of templates
103
- */
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');
113
- }
114
-
115
- $messages = Mage::helper('bronto_email/message')->getMessagesOptionsArray($storeId, null, $filter, true);
116
- foreach ($messages as $message) {
117
- if ($message['value'] == $template->getBrontoMessageId()) {
118
- echo sprintf('<option value="%s" selected="selected">%s</option>', $message['value'], $message['label']);
119
- } else {
120
- echo sprintf('<option value="%s">%s</option>', $message['value'], $message['label']);
121
- }
122
- }
123
- }
124
-
125
- /**
126
- * Populate 'Original Template Text' field with Bronto Message Content on template change
127
- *
128
- * @access public
129
- */
130
- public function ajaxtemplateAction()
131
- {
132
- $templateId = $this->getRequest()->getParam('template_id', false);
133
-
134
- if ($templateId) {
135
- $template = Mage::getModel('bronto_email/template')->loadDefault($templateId);
136
-
137
- $templateContent = trim($template->getTemplateText());
138
- // echo Template Content
139
- echo $templateContent;
140
- }
141
-
142
- echo '';
143
- }
144
-
145
- /**
146
- * Determines if this action is a returnable action
147
- *
148
- * @return boolean
149
- */
150
- protected function _isReturnableAction()
151
- {
152
- return in_array($this->getRequest()->getActionName(), $this->_returnableActions);
153
- }
154
-
155
- /**
156
- * Sends the user back to the Post-Redirect location, if the action is returnable
157
- */
158
- protected function _postReturn()
159
- {
160
- $session = Mage::getSingleton('adminhtml/session');
161
- if ($this->_isReturnableAction() && $session->hasPostRedirect()) {
162
- $this->_redirect($session->getPostRedirect());
163
- }
164
- }
165
-
166
- /**
167
- * Override to route back to Post-Redirect location
168
- */
169
- public function postDispatch()
170
- {
171
- parent::postDispatch();
172
- $this->_postReturn();
173
- }
174
-
175
- /**
176
- * Override Save Action for Bronto Templates
177
- *
178
- * @return $this|void
179
- */
180
- public function brontoSaveAction()
181
- {
182
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
183
- return parent::saveAction();
184
- }
185
-
186
- $request = $this->getRequest();
187
- $id = $this->getRequest()->getParam('id');
188
- $template = $this->_initTemplate('id');
189
-
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
- // Only set if the module is enabled, essentially
255
- if ($request->has('product_recommendation')) {
256
- $rec = $request->getParam('product_recommendation', null);
257
- $brontoTemplate->setProductRecommendation($rec);
258
- }
259
-
260
- if ($request->has('send_flags')) {
261
- $sendFlags = $request->getParam('send_flags', null);
262
- $brontoTemplate->setSendFlags($sendFlags);
263
- }
264
-
265
- $salesRule = $request->getParam('sales_rule', null);
266
- $brontoTemplate->setSalesRule($salesRule);
267
- $brontoTemplate->setTemplateSendType($sendType);
268
-
269
- // If Template doesn't exist or added_at is not set, set it
270
- if (!$template->getId() || !$template->getAddedAt()) {
271
- $template->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
272
- }
273
-
274
- // Save Template
275
- $template->save();
276
-
277
- // Set Bronto Template ID to match newly saved Template and then save
278
- if ($brontoTemplate) {
279
- $brontoTemplate->setId($template->getId());
280
- $brontoTemplate->save();
281
- }
282
-
283
- Mage::getSingleton('adminhtml/session')->setFormData(false);
284
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The email template has been saved.'));
285
- $this->_redirect('*/*');
286
- } catch (Exception $e) {
287
- Mage::getSingleton('adminhtml/session')->setData('email_template_form_data', $this->getRequest()->getParams());
288
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
289
- $this->_forward('brontoNew');
290
- }
291
-
292
- return $this;
293
- }
294
-
295
- /**
296
- * Get Message Name from Message ID
297
- *
298
- * @param string|int $messageId
299
- *
300
- * @return string
301
- */
302
- private function _getMessageName($messageId)
303
- {
304
- $messages = Mage::helper('bronto_common/message')->getAllMessageOptions();
305
- foreach ($messages as $message) {
306
- if ($message['value'] == $messageId) {
307
- return $message['label'];
308
- }
309
- }
310
-
311
- return false;
312
- }
313
-
314
- /**
315
- * Edit Default Templates
316
- *
317
- * @return $this
318
- */
319
- public function importEditAction()
320
- {
321
- $this->loadLayout();
322
- $template = $this->_initTemplate('id');
323
- $this->_setActiveMenu('system/email_template');
324
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Transactional Emails'), Mage::helper('adminhtml')->__('Transactional Emails'), $this->getUrl('*/*'));
325
-
326
- if ($this->getRequest()->getParam('id')) {
327
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Edit Template'), Mage::helper('adminhtml')->__('Edit System Template'));
328
- } else {
329
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('New Template'), Mage::helper('adminhtml')->__('New System Template'));
330
- }
331
-
332
- $this->_title($template->getId() ? $template->getTemplateCode() : $this->__('New Template'));
333
-
334
- $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_edit', 'template_edit')
335
- ->setEditMode((bool)$this->getRequest()->getParam('id')));
336
- $this->renderLayout();
337
-
338
- return $this;
339
- }
340
-
341
- /**
342
- * Edit transactional email action
343
- */
344
- public function brontoEditAction()
345
- {
346
- $this->_forward('brontonew');
347
- }
348
-
349
- /**
350
- * Create transactional email action
351
- */
352
- public function brontoNewAction()
353
- {
354
- $this->loadLayout();
355
- $template = $this->_initTemplate('id');
356
- $this->_setActiveMenu('system/email_template');
357
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Transactional Emails'), Mage::helper('adminhtml')->__('Transactional Emails'), $this->getUrl('*/*'));
358
-
359
- if ($this->getRequest()->getParam('id')) {
360
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Edit Template'), Mage::helper('adminhtml')->__('Edit System Template'));
361
- } else {
362
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('New Template'), Mage::helper('adminhtml')->__('New System Template'));
363
- }
364
-
365
- $this->_title($template->getId() ? $template->getTemplateCode() : $this->__('New Template'));
366
-
367
- $this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_edit', 'template_edit')
368
- ->setEditMode((bool)$this->getRequest()->getParam('id')));
369
- $this->renderLayout();
370
- }
371
-
372
- /**
373
- * Set template data to retrieve it in template info form
374
- */
375
- public function defaultTemplateAction()
376
- {
377
- if (!Mage::helper('bronto_email')->isEnabledForAny()) {
378
- return parent::defaultTemplateAction();
379
- }
380
-
381
- $template = $this->_initTemplate('id');
382
- $templateCode = $this->getRequest()->getParam('code');
383
-
384
- $template->loadDefault($templateCode, $this->getRequest()->getParam('locale'));
385
- $template->setData('orig_template_code', $templateCode);
386
- $template->setData('template_variables', Zend_Json::encode($template->getVariablesOptionArray(true)));
387
-
388
- $templateBlock = $this->getLayout()->createBlock('adminhtml/system_email_template_edit');
389
- $template->setData('orig_template_used_default_for', $templateBlock->getUsedDefaultForPaths(false));
390
-
391
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($template->getData()));
392
-
393
- return $this;
394
- }
395
-
396
- /**
397
- * Mass Action for Import
398
- */
399
- public function massImportAction()
400
- {
401
- $templateIds = $this->getRequest()->getParam('template_id', array());
402
- $storeId = $this->getRequest()->getParam('store_id', null);
403
- $imported = 0;
404
-
405
- // If single ID, set as array
406
- if (is_numeric($templateIds)) {
407
- $templateIds = array($templateIds);
408
- }
409
-
410
- // Begin Processing Templates
411
- if (count($templateIds) > 0) {
412
- $importModel = Mage::getModel('bronto_email/template_import');
413
- foreach ($templateIds as $templateId) {
414
- try {
415
- if ($importModel->importTemplate($templateId, $storeId)) {
416
- $imported++;
417
- }
418
- } catch (Exception $e) {
419
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
420
- }
421
- }
422
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
423
- 'Total of %d email template(s) have been successfully imported.', $imported
424
- ));
425
- } else {
426
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bronto_email')->__('Please select template(s).'));
427
- }
428
-
429
- $this->_redirect('*/*/index');
430
- }
431
-
432
- /**
433
- * Mass Action for Import
434
- */
435
- public function massDeleteAction()
436
- {
437
- $templateIds = $this->getRequest()->getParam('template_id', array());
438
- $deleteLevel = $this->getRequest()->getParam('delete_level', 'message');
439
- $deleted = 0;
440
-
441
- // If single ID, set as array
442
- if (is_numeric($templateIds)) {
443
- $templateIds = array($templateIds);
444
- }
445
-
446
- // Begin Processing Templates
447
- if (count($templateIds) > 0) {
448
- foreach ($templateIds as $templateId) {
449
- if ('full' == $deleteLevel) {
450
- $template = Mage::getModel('bronto_email/template')->load($templateId);
451
- } else {
452
- $template = Mage::getModel('bronto_email/message')->load($templateId);
453
- }
454
-
455
- if ($template->getId()) {
456
- try {
457
- $template->delete();
458
- $deleted++;
459
- } catch (Exception $e) {
460
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
461
- }
462
- }
463
- }
464
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
465
- 'Total of %d email template(s) have been successfully deleted.', $deleted
466
- ));
467
- } else {
468
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bronto_email')->__('Please select template(s).'));
469
- }
470
-
471
- $this->_redirect('*/*');
472
- }
473
-
474
- public function updateSendTypeAction()
475
- {
476
- $templateIds = $this->getRequest()->getParam('template_id', array());
477
- $sendType = $this->getRequest()->getParam('send_type', 'marketing');
478
- $updated = 0;
479
-
480
- // If single ID, set as array
481
- if (is_numeric($templateIds)) {
482
- $templateIds = array($templateIds);
483
- }
484
-
485
- // Begin Processing Templates
486
- if (count($templateIds) > 0) {
487
- foreach ($templateIds as $templateId) {
488
- $template = Mage::getModel('bronto_email/message')->load($templateId);
489
-
490
- // TODO: When approval status is available from api, implement this check
491
- // if ('transactional' == $sendType && 0 === $template->getBrontoMessageApproved()) {
492
- // Mage::helper('bronto_email')->writeError(
493
- // Mage::helper('bronto_email')->__($template->getTemplateCode() . ' has not been approved for transactional sending')
494
- // );
495
- // }
496
-
497
- if ($template->getId()) {
498
- try {
499
- $template->setTemplateSendType($sendType);
500
- $template->save();
501
- $updated++;
502
- } catch (Exception $e) {
503
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
504
- }
505
- }
506
- }
507
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
508
- 'Total of %d email template(s) have been successfully updated.', $updated
509
- ));
510
- } else {
511
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bronto_email')->__('Please select template(s).'));
512
- }
513
-
514
- $this->_redirect('*/*/index');
515
- }
516
-
517
- /**
518
- * Load in all of Magento's default templates
519
- */
520
- public function loadDefaultsAction()
521
- {
522
- /** @var $templateMode Bronto_Email_Model_Template_Import */
523
- $templateModel = Mage::getModel('bronto_email/template');
524
-
525
- // Process Templates
526
- try {
527
- $templateModel->handleDefaultTemplates();
528
- } catch (Exception $e) {
529
- Mage::helper('bronto_email')->writeError($e->getMessage());
530
- }
531
-
532
- $this->_redirect('*/*/import');
533
- }
534
-
535
- /**
536
- * Preview Action to display Template Content
537
- */
538
- public function previewAction()
539
- {
540
- parent::previewAction();
541
- }
542
-
543
- /**
544
- * Load email template from request
545
- *
546
- * @param string $idFieldName
547
- *
548
- * @return Mage_Adminhtml_Model_Email_Template $model
549
- */
550
- protected function _initTemplate($idFieldName = 'template_id')
551
- {
552
- $this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
553
-
554
- $id = (int)$this->getRequest()->getParam($idFieldName);
555
- $model = Mage::getModel('bronto_email/template');
556
-
557
- if ($id) {
558
- $model->load($id);
559
- }
560
-
561
- if (!Mage::registry('email_template')) {
562
- Mage::register('email_template', $model);
563
- }
564
- if (!Mage::registry('current_email_template')) {
565
- Mage::register('current_email_template', $model);
566
- }
567
-
568
- return $model;
569
- }
570
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/etc/adminhtml.xml DELETED
@@ -1,23 +0,0 @@
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_email translate="title" module="bronto_email">
12
- <title>Bronto Transactional Emails Section</title>
13
- <sort_order>9998</sort_order>
14
- </bronto_email>
15
- </children>
16
- </config>
17
- </children>
18
- </system>
19
- </children>
20
- </admin>
21
- </resources>
22
- </acl>
23
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/etc/config.xml DELETED
@@ -1,139 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Bronto_Email>
5
- <version>1.2.2</version>
6
- </Bronto_Email>
7
- </modules>
8
- <global>
9
- <helpers>
10
- <bronto_email>
11
- <class>Bronto_Email_Helper</class>
12
- </bronto_email>
13
- </helpers>
14
- <blocks>
15
- <bronto_email>
16
- <class>Bronto_Email_Block</class>
17
- </bronto_email>
18
- </blocks>
19
- <models>
20
- <bronto_email>
21
- <class>Bronto_Email_Model</class>
22
- <resourceModel>bronto_email_mysql4</resourceModel>
23
- </bronto_email>
24
- <bronto_email_mysql4>
25
- <class>Bronto_Email_Model_Mysql4</class>
26
- <entities>
27
- <log>
28
- <table>bronto_email_log</table>
29
- </log>
30
- <template>
31
- <table>core_email_template</table>
32
- </template>
33
- <message>
34
- <table>bronto_email_template</table>
35
- </message>
36
- </entities>
37
- </bronto_email_mysql4>
38
- <core>
39
- <rewrite>
40
- <email_template>Bronto_Email_Model_Template</email_template>
41
- <email_template_mailer>Bronto_Email_Model_Template_Mailer</email_template_mailer>
42
- </rewrite>
43
- </core>
44
- <adminhtml>
45
- <rewrite>
46
- <system_config_source_email_template>Bronto_Email_Model_System_Config_Source_Email_Template</system_config_source_email_template>
47
- </rewrite>
48
- </adminhtml>
49
- </models>
50
- <resources>
51
- <bronto_email_setup>
52
- <setup>
53
- <module>Bronto_Email</module>
54
- <class>Bronto_Email_Model_Resource_Setup</class>
55
- </setup>
56
- </bronto_email_setup>
57
- <bronto_email_write>
58
- <connection>
59
- <use>core_write</use>
60
- </connection>
61
- </bronto_email_write>
62
- <bronto_email_read>
63
- <connection>
64
- <use>core_read</use>
65
- </connection>
66
- </bronto_email_read>
67
- </resources>
68
- </global>
69
- <admin>
70
- <routers>
71
- <adminhtml>
72
- <args>
73
- <modules>
74
- <bronto_email before="Mage_Adminhtml">Bronto_Email_Adminhtml</bronto_email>
75
- </modules>
76
- </args>
77
- </adminhtml>
78
- </routers>
79
- </admin>
80
- <default>
81
- <bronto_email>
82
- <settings>
83
- <enabled>0</enabled>
84
- <use_bronto>0</use_bronto>
85
- <log_enabled>1</log_enabled>
86
- <log_fields_enabled>1</log_fields_enabled>
87
- </settings>
88
- </bronto_email>
89
- </default>
90
- <adminhtml>
91
- <events>
92
- <bronto_email_enable>
93
- <observers>
94
- <bronto_email_enable>
95
- <type>singleton</type>
96
- <class>bronto_email/observer</class>
97
- <method>watchEnableAction</method>
98
- </bronto_email_enable>
99
- <bronto_move_templates>
100
- <type>singleton</type>
101
- <class>bronto_email/observer</class>
102
- <method>moveOldTemplates</method>
103
- </bronto_move_templates>
104
- </observers>
105
- </bronto_email_enable>
106
- <controller_action_predispatch>
107
- <observers>
108
- <bronto_email_controller_action_predispatch>
109
- <class>bronto_email/observer</class>
110
- <method>checkBrontoRequirements</method>
111
- </bronto_email_controller_action_predispatch>
112
- </observers>
113
- </controller_action_predispatch>
114
- <controller_action_predispatch_adminhtml_system_config_save>
115
- <observers>
116
- <bronto_email_controller_action_postdispatch_adminhtml_system_config_save>
117
- <type>singleton</type>
118
- <class>bronto_email/observer</class>
119
- <method>saveDynamicField</method>
120
- </bronto_email_controller_action_postdispatch_adminhtml_system_config_save>
121
- </observers>
122
- </controller_action_predispatch_adminhtml_system_config_save>
123
- </events>
124
- <layout>
125
- <updates>
126
- <bronto_email>
127
- <file>bronto/email.xml</file>
128
- </bronto_email>
129
- </updates>
130
- </layout>
131
- </adminhtml>
132
- <phpunit>
133
- <suite>
134
- <modules>
135
- <Bronto_Email/>
136
- </modules>
137
- </suite>
138
- </phpunit>
139
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/etc/system.xml DELETED
@@ -1,1407 +0,0 @@
1
- <?xml version="1.0"?>
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>
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_email/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 translate="label">
22
- <label>Settings</label>
23
- <frontend_type>text</frontend_type>
24
- <frontend_model>bronto_email/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>
29
- <expanded>1</expanded>
30
- <fields>
31
- <enabled translate="label">
32
- <label>Enable Module</label>
33
- <frontend_type>select</frontend_type>
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>0</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>
41
- </enabled>
42
- <use_bronto translate="label">
43
- <label>Allow Sending Through Bronto</label>
44
- <depends>
45
- <enabled>1</enabled>
46
- </depends>
47
- <frontend_type>select</frontend_type>
48
- <backend_model>bronto_email/system_config_backend_usebronto</backend_model>
49
- <source_model>adminhtml/system_config_source_yesno</source_model>
50
- <sort_order>1</sort_order>
51
- <show_in_default>1</show_in_default>
52
- <show_in_website>1</show_in_website>
53
- <show_in_store>1</show_in_store>
54
- </use_bronto>
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>10</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>11</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
- <default_coupon>
80
- <label>Default Price Rule Coupon Code</label>
81
- <depends>
82
- <enabled>1</enabled>
83
- </depends>
84
- <frontend_type>select</frontend_type>
85
- <source_model>bronto_common/system_config_source_coupon</source_model>
86
- <sort_order>12</sort_order>
87
- <show_in_default>1</show_in_default>
88
- <show_in_website>1</show_in_website>
89
- <show_in_store>1</show_in_store>
90
- <comment><![CDATA[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.]]></comment>
91
- </default_coupon>
92
- <default_recommendation>
93
- <label>Default Product Recommendation</label>
94
- <depends>
95
- <enabled>1</enabled>
96
- </depends>
97
- <frontend_type>select</frontend_type>
98
- <source_model>bronto_product/recommendation</source_model>
99
- <sort_order>13</sort_order>
100
- <show_in_default>1</show_in_default>
101
- <show_in_website>1</show_in_website>
102
- <show_in_store>1</show_in_store>
103
- <comment><![CDATA[Inject related product content in the message. Recommendations are created in <strong>Promotions</strong> &raquo; <strong>Bronto Product Recommendations]]></comment>
104
- </default_recommendation>
105
- <default_send_flags>
106
- <label>Default Send Flags</label>
107
- <depends>
108
- <enabled>1</enabled>
109
- </depends>
110
- <frontend_type>select</frontend_type>
111
- <source_model>bronto_common/system_config_source_sendOptions</source_model>
112
- <sort_order>14</sort_order>
113
- <show_in_default>1</show_in_default>
114
- <show_in_website>1</show_in_website>
115
- <show_in_store>1</show_in_store>
116
- <comment><![CDATA[Specify the default send flags for
117
- all transactional emails. The options are:
118
- <br/> - <strong>Sender Authentication</strong>: Will
119
- sign your message with DomainKeys/DKIM,
120
- optimizing your message delivery to Hotmail,
121
- MSN, and Yahoo! email addresses.
122
- <br/> - <strong>Fatigue Override</strong>: The
123
- delivery can be sent even if it exceeds the
124
- frequency cap settings for a customer.
125
- <br/> - <strong>Reply Tracking</strong>: Will store
126
- a copy of all replies to your messages on the
127
- Replies page within the Bronto platform.
128
- ]]></comment>
129
- </default_send_flags>
130
- </fields>
131
- </settings>
132
- <templates translate="label">
133
- <label>Assign Templates</label>
134
- <frontend_type>text</frontend_type>
135
- <frontend_model>bronto_email/adminhtml_system_config_templates</frontend_model>
136
- <sort_order>2</sort_order>
137
- <show_in_default>1</show_in_default>
138
- <show_in_website>1</show_in_website>
139
- <show_in_store>1</show_in_store>
140
- <expanded>1</expanded>
141
- <!--<fields>
142
- <label_currency>
143
- <label><![CDATA[##currency## General &raquo; Currency Setup &raquo; Scheduled Import Settings]]></label>
144
- <frontend_type>label</frontend_type>
145
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
146
- <sort_order>0</sort_order>
147
- <show_in_default>1</show_in_default>
148
- <show_in_website>1</show_in_website>
149
- <show_in_store>1</show_in_store>
150
- </label_currency>
151
- <currency-import-error_email_template translate="label">
152
- <label>Error Email Template</label>
153
- <frontend_type>select</frontend_type>
154
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
155
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
156
- <source_model>bronto_email/system_config_source_email_template</source_model>
157
- <sort_order>1</sort_order>
158
- <show_in_default>1</show_in_default>
159
- <show_in_website>1</show_in_website>
160
- <show_in_store>1</show_in_store>
161
- </currency-import-error_email_template>
162
- <currency-import-error_email_template_send_type translate="label">
163
- <label>Send Type</label>
164
- <frontend_type>radios</frontend_type>
165
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
166
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
167
- <source_model>bronto_email/system_config_source_sendtype</source_model>
168
- <sort_order>2</sort_order>
169
- <show_in_default>1</show_in_default>
170
- <show_in_website>1</show_in_website>
171
- <show_in_store>1</show_in_store>
172
- </currency-import-error_email_template_send_type>
173
-
174
- <label_contacts>
175
- <label><![CDATA[##contacts## General &raquo; Contacts &raquo; Email Options]]></label>
176
- <frontend_type>label</frontend_type>
177
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
178
- <sort_order>5</sort_order>
179
- <show_in_default>1</show_in_default>
180
- <show_in_website>1</show_in_website>
181
- <show_in_store>1</show_in_store>
182
- </label_contacts>
183
- <contacts-email-email_template translate="label">
184
- <label>Email Template</label>
185
- <frontend_type>select</frontend_type>
186
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
187
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
188
- <source_model>bronto_email/system_config_source_email_template</source_model>
189
- <sort_order>6</sort_order>
190
- <show_in_default>1</show_in_default>
191
- <show_in_website>1</show_in_website>
192
- <show_in_store>1</show_in_store>
193
- </contacts-email-email_template>
194
- <contacts-email-email_template_send_type translate="label">
195
- <label>Send Type</label>
196
- <frontend_type>radios</frontend_type>
197
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
198
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
199
- <source_model>bronto_email/system_config_source_sendtype</source_model>
200
- <sort_order>7</sort_order>
201
- <show_in_default>1</show_in_default>
202
- <show_in_website>1</show_in_website>
203
- <show_in_store>1</show_in_store>
204
- </contacts-email-email_template_send_type>
205
-
206
- <label_sendfriend>
207
- <label><![CDATA[##sendfriend## Catalog &raquo; Email to a Friend &raquo; Email Templates]]></label>
208
- <frontend_type>label</frontend_type>
209
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
210
- <sort_order>10</sort_order>
211
- <show_in_default>1</show_in_default>
212
- <show_in_website>1</show_in_website>
213
- <show_in_store>1</show_in_store>
214
- </label_sendfriend>
215
- <sendfriend-email-template translate="label">
216
- <label>Email Template</label>
217
- <frontend_type>select</frontend_type>
218
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
219
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
220
- <source_model>bronto_email/system_config_source_email_template</source_model>
221
- <sort_order>11</sort_order>
222
- <show_in_default>1</show_in_default>
223
- <show_in_website>1</show_in_website>
224
- <show_in_store>1</show_in_store>
225
- </sendfriend-email-template>
226
- <sendfriend-email-template_send_type translate="label">
227
- <label>Send Type</label>
228
- <frontend_type>radios</frontend_type>
229
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
230
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
231
- <source_model>bronto_email/system_config_source_sendtype</source_model>
232
- <sort_order>12</sort_order>
233
- <show_in_default>1</show_in_default>
234
- <show_in_website>1</show_in_website>
235
- <show_in_store>1</show_in_store>
236
- </sendfriend-email-template_send_type>
237
-
238
- <label_newsletter>
239
- <label><![CDATA[##newsletter## Customers &raquo; Newsletter &raquo; Subscription Options]]></label>
240
- <frontend_type>label</frontend_type>
241
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
242
- <sort_order>20</sort_order>
243
- <show_in_default>1</show_in_default>
244
- <show_in_website>1</show_in_website>
245
- <show_in_store>1</show_in_store>
246
- </label_newsletter>
247
- <newsletter-subscription-success_email_template translate="label">
248
- <label>Success Email Template</label>
249
- <frontend_type>select</frontend_type>
250
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
251
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
252
- <source_model>bronto_email/system_config_source_email_template</source_model>
253
- <sort_order>21</sort_order>
254
- <show_in_default>1</show_in_default>
255
- <show_in_website>1</show_in_website>
256
- <show_in_store>1</show_in_store>
257
- </newsletter-subscription-success_email_template>
258
- <newsletter-subscription-success_email_template_send_type translate="label">
259
- <label>Send Type</label>
260
- <frontend_type>radios</frontend_type>
261
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
262
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
263
- <source_model>bronto_email/system_config_source_sendtype</source_model>
264
- <sort_order>22</sort_order>
265
- <show_in_default>1</show_in_default>
266
- <show_in_website>1</show_in_website>
267
- <show_in_store>1</show_in_store>
268
- </newsletter-subscription-success_email_template_send_type>
269
- <newsletter-subscription-un_email_template translate="label">
270
- <label>Unsubscription Email Template</label>
271
- <frontend_type>select</frontend_type>
272
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
273
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
274
- <source_model>bronto_email/system_config_source_email_template</source_model>
275
- <sort_order>23</sort_order>
276
- <show_in_default>1</show_in_default>
277
- <show_in_website>1</show_in_website>
278
- <show_in_store>1</show_in_store>
279
- </newsletter-subscription-un_email_template>
280
- <newsletter-subscription-un_email_template_send_type translate="label">
281
- <label>Send Type</label>
282
- <frontend_type>radios</frontend_type>
283
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
284
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
285
- <source_model>bronto_email/system_config_source_sendtype</source_model>
286
- <sort_order>24</sort_order>
287
- <show_in_default>1</show_in_default>
288
- <show_in_website>1</show_in_website>
289
- <show_in_store>1</show_in_store>
290
- </newsletter-subscription-un_email_template_send_type>
291
- <newsletter-subscription-confirm_email_template translate="label">
292
- <label>Confirmation Email Template</label>
293
- <frontend_type>select</frontend_type>
294
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
295
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
296
- <source_model>bronto_email/system_config_source_email_template</source_model>
297
- <sort_order>25</sort_order>
298
- <show_in_default>1</show_in_default>
299
- <show_in_website>1</show_in_website>
300
- <show_in_store>1</show_in_store>
301
- </newsletter-subscription-confirm_email_template>
302
- <newsletter-subscription-confirm_email_template_send_type translate="label">
303
- <label>Send Type</label>
304
- <frontend_type>radios</frontend_type>
305
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
306
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
307
- <source_model>bronto_email/system_config_source_sendtype</source_model>
308
- <sort_order>26</sort_order>
309
- <show_in_default>1</show_in_default>
310
- <show_in_website>1</show_in_website>
311
- <show_in_store>1</show_in_store>
312
- </newsletter-subscription-confirm_email_template_send_type>
313
-
314
- <label_customer_create>
315
- <label><![CDATA[##customer## Customers &raquo; Customer Configuration &raquo; Create New Account Options]]></label>
316
- <frontend_type>label</frontend_type>
317
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
318
- <sort_order>30</sort_order>
319
- <show_in_default>1</show_in_default>
320
- <show_in_website>1</show_in_website>
321
- <show_in_store>1</show_in_store>
322
- </label_customer_create>
323
- <customer-create_account-email_template translate="label">
324
- <label>Default Welcome Email</label>
325
- <frontend_type>select</frontend_type>
326
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
327
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
328
- <source_model>bronto_email/system_config_source_email_template</source_model>
329
- <sort_order>31</sort_order>
330
- <show_in_default>1</show_in_default>
331
- <show_in_website>1</show_in_website>
332
- <show_in_store>1</show_in_store>
333
- </customer-create_account-email_template>
334
- <customer-create_account-email_template_send_type translate="label">
335
- <label>Send Type</label>
336
- <frontend_type>radios</frontend_type>
337
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
338
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
339
- <source_model>bronto_email/system_config_source_sendtype</source_model>
340
- <sort_order>32</sort_order>
341
- <show_in_default>1</show_in_default>
342
- <show_in_website>1</show_in_website>
343
- <show_in_store>1</show_in_store>
344
- </customer-create_account-email_template_send_type>
345
- <customer-create_account-email_confirmation_template translate="label">
346
- <label>Confirmation Link Email</label>
347
- <frontend_type>select</frontend_type>
348
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
349
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
350
- <source_model>bronto_email/system_config_source_email_template</source_model>
351
- <sort_order>33</sort_order>
352
- <show_in_default>1</show_in_default>
353
- <show_in_website>1</show_in_website>
354
- <show_in_store>1</show_in_store>
355
- </customer-create_account-email_confirmation_template>
356
- <customer-create_account-email_confirmation_template_send_type translate="label">
357
- <label>Send Type</label>
358
- <frontend_type>radios</frontend_type>
359
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
360
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
361
- <source_model>bronto_email/system_config_source_sendtype</source_model>
362
- <sort_order>34</sort_order>
363
- <show_in_default>1</show_in_default>
364
- <show_in_website>1</show_in_website>
365
- <show_in_store>1</show_in_store>
366
- </customer-create_account-email_confirmation_template_send_type>
367
- <customer-create_account-email_confirmed_template translate="label comment">
368
- <label>Welcome Email</label>
369
- <comment>This email will be sent instead of default welcome email, after account confirmation.</comment>
370
- <frontend_type>select</frontend_type>
371
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
372
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
373
- <source_model>bronto_email/system_config_source_email_template</source_model>
374
- <sort_order>35</sort_order>
375
- <show_in_default>1</show_in_default>
376
- <show_in_website>1</show_in_website>
377
- <show_in_store>1</show_in_store>
378
- </customer-create_account-email_confirmed_template>
379
- <customer-create_account-email_confirmed_template_send_type translate="label">
380
- <label>Send Type</label>
381
- <frontend_type>radios</frontend_type>
382
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
383
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
384
- <source_model>bronto_email/system_config_source_sendtype</source_model>
385
- <sort_order>36</sort_order>
386
- <show_in_default>1</show_in_default>
387
- <show_in_website>1</show_in_website>
388
- <show_in_store>1</show_in_store>
389
- </customer-create_account-email_confirmed_template_send_type>
390
-
391
- <label_customer_password>
392
- <label><![CDATA[##customer## Customers &raquo; Customer Configuration &raquo; Password Options]]></label>
393
- <frontend_type>label</frontend_type>
394
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
395
- <sort_order>40</sort_order>
396
- <show_in_default>1</show_in_default>
397
- <show_in_website>1</show_in_website>
398
- <show_in_store>1</show_in_store>
399
- </label_customer_password>
400
- <customer-password-forgot_email_template translate="label">
401
- <label>Forgot Email Template</label>
402
- <frontend_type>select</frontend_type>
403
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
404
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
405
- <source_model>bronto_email/system_config_source_email_template</source_model>
406
- <sort_order>41</sort_order>
407
- <show_in_default>1</show_in_default>
408
- <show_in_website>1</show_in_website>
409
- <show_in_store>1</show_in_store>
410
- </customer-password-forgot_email_template>
411
- <customer-password-forgot_email_template_send_type translate="label">
412
- <label>Send Type</label>
413
- <frontend_type>radios</frontend_type>
414
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
415
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
416
- <source_model>bronto_email/system_config_source_sendtype</source_model>
417
- <sort_order>42</sort_order>
418
- <show_in_default>1</show_in_default>
419
- <show_in_website>1</show_in_website>
420
- <show_in_store>1</show_in_store>
421
- </customer-password-forgot_email_template_send_type>
422
- <customer-password-remind_email_template translate="label">
423
- <label>Reminder Email Template</label>
424
- <frontend_type>select</frontend_type>
425
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
426
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
427
- <source_model>bronto_email/system_config_source_email_template</source_model>
428
- <sort_order>43</sort_order>
429
- <show_in_default>1</show_in_default>
430
- <show_in_website>1</show_in_website>
431
- <show_in_store>1</show_in_store>
432
- </customer-password-remind_email_template>
433
- <customer-password-remind_email_template_send_type translate="label">
434
- <label>Send Type</label>
435
- <frontend_type>radios</frontend_type>
436
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
437
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
438
- <source_model>bronto_email/system_config_source_sendtype</source_model>
439
- <sort_order>44</sort_order>
440
- <show_in_default>1</show_in_default>
441
- <show_in_website>1</show_in_website>
442
- <show_in_store>1</show_in_store>
443
- </customer-password-remind_email_template_send_type>
444
-
445
- <label_customer_store_credit>
446
- <label><![CDATA[##customer## Customers &raquo; Customer Configuration &raquo; Store Credit Options]]></label>
447
- <frontend_type>label</frontend_type>
448
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
449
- <sort_order>50</sort_order>
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
- </label_customer_store_credit>
454
- <customer-enterprise_customerbalance-email_template translate="label">
455
- <label>Store Credit Update Email Template</label>
456
- <frontend_type>select</frontend_type>
457
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
458
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
459
- <source_model>bronto_email/system_config_source_email_template</source_model>
460
- <sort_order>51</sort_order>
461
- <show_in_default>1</show_in_default>
462
- <show_in_website>1</show_in_website>
463
- <show_in_store>1</show_in_store>
464
- </customer-enterprise_customerbalance-email_template>
465
- <customer-enterprise_customerbalance-email_template_send_type translate="label">
466
- <label>Send Type</label>
467
- <frontend_type>radios</frontend_type>
468
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
469
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
470
- <source_model>bronto_email/system_config_source_sendtype</source_model>
471
- <sort_order>52</sort_order>
472
- <show_in_default>1</show_in_default>
473
- <show_in_website>1</show_in_website>
474
- <show_in_store>1</show_in_store>
475
- </customer-enterprise_customerbalance-email_template_send_type>
476
-
477
- <label_wishlist>
478
- <label><![CDATA[##wishlist## Customers &raquo; Wishlist &raquo; Share Options]]></label>
479
- <frontend_type>label</frontend_type>
480
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
481
- <sort_order>60</sort_order>
482
- <show_in_default>1</show_in_default>
483
- <show_in_website>1</show_in_website>
484
- <show_in_store>1</show_in_store>
485
- </label_wishlist>
486
- <wishlist-email-email_template translate="label">
487
- <label>Email Template</label>
488
- <frontend_type>select</frontend_type>
489
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
490
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
491
- <source_model>bronto_email/system_config_source_email_template</source_model>
492
- <sort_order>61</sort_order>
493
- <show_in_default>1</show_in_default>
494
- <show_in_website>1</show_in_website>
495
- <show_in_store>1</show_in_store>
496
- </wishlist-email-email_template>
497
- <wishlist-email-email_template_send_type translate="label">
498
- <label>Send Type</label>
499
- <frontend_type>radios</frontend_type>
500
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
501
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
502
- <source_model>bronto_email/system_config_source_sendtype</source_model>
503
- <sort_order>62</sort_order>
504
- <show_in_default>1</show_in_default>
505
- <show_in_website>1</show_in_website>
506
- <show_in_store>1</show_in_store>
507
- </wishlist-email-email_template_send_type>
508
-
509
- <label_invitations>
510
- <label><![CDATA[##enterprise_invitation## Customers &raquo; Invitations &raquo; Email]]></label>
511
- <frontend_type>label</frontend_type>
512
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
513
- <sort_order>70</sort_order>
514
- <show_in_default>1</show_in_default>
515
- <show_in_website>1</show_in_website>
516
- <show_in_store>1</show_in_store>
517
- </label_invitations>
518
- <enterprise_invitation-email-template translate="label">
519
- <label>Customer Invitation Email Template</label>
520
- <frontend_type>select</frontend_type>
521
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
522
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
523
- <source_model>bronto_email/system_config_source_email_template</source_model>
524
- <sort_order>71</sort_order>
525
- <show_in_default>1</show_in_default>
526
- <show_in_website>1</show_in_website>
527
- <show_in_store>1</show_in_store>
528
- </enterprise_invitation-email-template>
529
- <enterprise_invitation-email-template_send_type translate="label">
530
- <label>Send Type</label>
531
- <frontend_type>radios</frontend_type>
532
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
533
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
534
- <source_model>bronto_email/system_config_source_sendtype</source_model>
535
- <sort_order>72</sort_order>
536
- <show_in_default>1</show_in_default>
537
- <show_in_website>1</show_in_website>
538
- <show_in_store>1</show_in_store>
539
- </enterprise_invitation-email-template_send_type>
540
-
541
- <label_rewards>
542
- <label><![CDATA[##enterprise_reward## Customers &raquo; Reward Points &raquo; Email Notification Settings]]></label>
543
- <frontend_type>label</frontend_type>
544
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
545
- <sort_order>80</sort_order>
546
- <show_in_default>1</show_in_default>
547
- <show_in_website>1</show_in_website>
548
- <show_in_store>1</show_in_store>
549
- </label_rewards>
550
- <enterprise_reward-notification-balance_update_template translate="label">
551
- <label>Balance Update Email</label>
552
- <frontend_type>select</frontend_type>
553
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
554
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
555
- <source_model>bronto_email/system_config_source_email_template</source_model>
556
- <sort_order>81</sort_order>
557
- <show_in_default>1</show_in_default>
558
- <show_in_website>1</show_in_website>
559
- <show_in_store>1</show_in_store>
560
- </enterprise_reward-notification-balance_update_template>
561
- <enterprise_reward-notification-balance_update_template_send_type translate="label">
562
- <label>Send Type</label>
563
- <frontend_type>radios</frontend_type>
564
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
565
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
566
- <source_model>bronto_email/system_config_source_sendtype</source_model>
567
- <sort_order>82</sort_order>
568
- <show_in_default>1</show_in_default>
569
- <show_in_website>1</show_in_website>
570
- <show_in_store>1</show_in_store>
571
- </enterprise_reward-notification-balance_update_template_send_type>
572
- <enterprise_reward-notification-expiry_warning_template translate="label">
573
- <label>Reward Points Expiry Warning Email</label>
574
- <frontend_type>select</frontend_type>
575
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
576
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
577
- <source_model>bronto_email/system_config_source_email_template</source_model>
578
- <sort_order>83</sort_order>
579
- <show_in_default>1</show_in_default>
580
- <show_in_website>1</show_in_website>
581
- <show_in_store>1</show_in_store>
582
- </enterprise_reward-notification-expiry_warning_template>
583
- <enterprise_reward-notification-expiry_warning_template_send_type translate="label">
584
- <label>Send Type</label>
585
- <frontend_type>radios</frontend_type>
586
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
587
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
588
- <source_model>bronto_email/system_config_source_sendtype</source_model>
589
- <sort_order>84</sort_order>
590
- <show_in_default>1</show_in_default>
591
- <show_in_website>1</show_in_website>
592
- <show_in_store>1</show_in_store>
593
- </enterprise_reward-notification-expiry_warning_template_send_type>
594
-
595
- <label_giftregistry_owner_notification>
596
- <label><![CDATA[##enterprise_giftregistry## Customers &raquo; Gift Registry &raquo; Owner Notification]]></label>
597
- <frontend_type>label</frontend_type>
598
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
599
- <sort_order>90</sort_order>
600
- <show_in_default>1</show_in_default>
601
- <show_in_website>1</show_in_website>
602
- <show_in_store>1</show_in_store>
603
- </label_giftregistry_owner_notification>
604
- <enterprise_giftregistry-owner_email-template translate="label">
605
- <label>Email Template</label>
606
- <frontend_type>select</frontend_type>
607
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
608
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
609
- <source_model>bronto_email/system_config_source_email_template</source_model>
610
- <sort_order>91</sort_order>
611
- <show_in_default>1</show_in_default>
612
- <show_in_website>1</show_in_website>
613
- <show_in_store>1</show_in_store>
614
- </enterprise_giftregistry-owner_email-template>
615
- <enterprise_giftregistry-owner_email-template_send_type translate="label">
616
- <label>Send Type</label>
617
- <frontend_type>radios</frontend_type>
618
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
619
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
620
- <source_model>bronto_email/system_config_source_sendtype</source_model>
621
- <sort_order>92</sort_order>
622
- <show_in_default>1</show_in_default>
623
- <show_in_website>1</show_in_website>
624
- <show_in_store>1</show_in_store>
625
- </enterprise_giftregistry-owner_email-template_send_type>
626
-
627
- <label_giftregistry_sharing>
628
- <label><![CDATA[##enterprise_giftregistry## Customers &raquo; Gift Registry &raquo; Gift Registry Sharing]]></label>
629
- <frontend_type>label</frontend_type>
630
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
631
- <sort_order>100</sort_order>
632
- <show_in_default>1</show_in_default>
633
- <show_in_website>1</show_in_website>
634
- <show_in_store>1</show_in_store>
635
- </label_giftregistry_sharing>
636
- <enterprise_giftregistry-sharing_email-template translate="label">
637
- <label>Email Template</label>
638
- <frontend_type>select</frontend_type>
639
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
640
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
641
- <source_model>bronto_email/system_config_source_email_template</source_model>
642
- <sort_order>101</sort_order>
643
- <show_in_default>1</show_in_default>
644
- <show_in_website>1</show_in_website>
645
- <show_in_store>1</show_in_store>
646
- </enterprise_giftregistry-sharing_email-template>
647
- <enterprise_giftregistry-sharing_email-template_send_type translate="label">
648
- <label>Send Type</label>
649
- <frontend_type>radios</frontend_type>
650
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
651
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
652
- <source_model>bronto_email/system_config_source_sendtype</source_model>
653
- <sort_order>102</sort_order>
654
- <show_in_default>1</show_in_default>
655
- <show_in_website>1</show_in_website>
656
- <show_in_store>1</show_in_store>
657
- </enterprise_giftregistry-sharing_email-template_send_type>
658
-
659
- <label_giftregistry_update>
660
- <label><![CDATA[##enterprise_giftregistry## Customers &raquo; Gift Registry &raquo; Gift Registry Update]]></label>
661
- <frontend_type>label</frontend_type>
662
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
663
- <sort_order>110</sort_order>
664
- <show_in_default>1</show_in_default>
665
- <show_in_website>1</show_in_website>
666
- <show_in_store>1</show_in_store>
667
- </label_giftregistry_update>
668
- <enterprise_giftregistry-update_email-template translate="label">
669
- <label>Email Template</label>
670
- <frontend_type>select</frontend_type>
671
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
672
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
673
- <source_model>bronto_email/system_config_source_email_template</source_model>
674
- <sort_order>111</sort_order>
675
- <show_in_default>1</show_in_default>
676
- <show_in_website>1</show_in_website>
677
- <show_in_store>1</show_in_store>
678
- </enterprise_giftregistry-update_email-template>
679
- <enterprise_giftregistry-update_email-template_send_type translate="label">
680
- <label>Send Type</label>
681
- <frontend_type>radios</frontend_type>
682
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
683
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
684
- <source_model>bronto_email/system_config_source_sendtype</source_model>
685
- <sort_order>112</sort_order>
686
- <show_in_default>1</show_in_default>
687
- <show_in_website>1</show_in_website>
688
- <show_in_store>1</show_in_store>
689
- </enterprise_giftregistry-update_email-template_send_type>
690
-
691
- <label_sales_email_order>
692
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Order]]></label>
693
- <frontend_type>label</frontend_type>
694
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
695
- <sort_order>120</sort_order>
696
- <show_in_default>1</show_in_default>
697
- <show_in_website>1</show_in_website>
698
- <show_in_store>1</show_in_store>
699
- </label_sales_email_order>
700
- <sales_email-order-template translate="label">
701
- <label>New Order Confirmation Template</label>
702
- <frontend_type>select</frontend_type>
703
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
704
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
705
- <source_model>bronto_email/system_config_source_email_template</source_model>
706
- <sort_order>121</sort_order>
707
- <show_in_default>1</show_in_default>
708
- <show_in_website>1</show_in_website>
709
- <show_in_store>1</show_in_store>
710
- </sales_email-order-template>
711
- <sales_email-order-template_send_type translate="label">
712
- <label>Send Type</label>
713
- <frontend_type>radios</frontend_type>
714
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
715
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
716
- <source_model>bronto_email/system_config_source_sendtype</source_model>
717
- <sort_order>122</sort_order>
718
- <show_in_default>1</show_in_default>
719
- <show_in_website>1</show_in_website>
720
- <show_in_store>1</show_in_store>
721
- </sales_email-order-template_send_type>
722
- <sales_email-order-guest_template translate="label">
723
- <label>New Order Confirmation Template for Guest</label>
724
- <frontend_type>select</frontend_type>
725
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
726
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
727
- <source_model>bronto_email/system_config_source_email_template</source_model>
728
- <sort_order>123</sort_order>
729
- <show_in_default>1</show_in_default>
730
- <show_in_website>1</show_in_website>
731
- <show_in_store>1</show_in_store>
732
- </sales_email-order-guest_template>
733
- <sales_email-order-guest_template_send_type translate="label">
734
- <label>Send Type</label>
735
- <frontend_type>radios</frontend_type>
736
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
737
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
738
- <source_model>bronto_email/system_config_source_sendtype</source_model>
739
- <sort_order>124</sort_order>
740
- <show_in_default>1</show_in_default>
741
- <show_in_website>1</show_in_website>
742
- <show_in_store>1</show_in_store>
743
- </sales_email-order-guest_template_send_type>
744
-
745
- <label_sales_email_order_comments>
746
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Order Comments]]></label>
747
- <frontend_type>label</frontend_type>
748
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
749
- <sort_order>130</sort_order>
750
- <show_in_default>1</show_in_default>
751
- <show_in_website>1</show_in_website>
752
- <show_in_store>1</show_in_store>
753
- </label_sales_email_order_comments>
754
- <sales_email-order_comment-template translate="label">
755
- <label>Order Comment Email Template</label>
756
- <frontend_type>select</frontend_type>
757
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
758
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
759
- <source_model>bronto_email/system_config_source_email_template</source_model>
760
- <sort_order>131</sort_order>
761
- <show_in_default>1</show_in_default>
762
- <show_in_website>1</show_in_website>
763
- <show_in_store>1</show_in_store>
764
- </sales_email-order_comment-template>
765
- <sales_email-order_comment-template_send_type translate="label">
766
- <label>Send Type</label>
767
- <frontend_type>radios</frontend_type>
768
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
769
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
770
- <source_model>bronto_email/system_config_source_sendtype</source_model>
771
- <sort_order>132</sort_order>
772
- <show_in_default>1</show_in_default>
773
- <show_in_website>1</show_in_website>
774
- <show_in_store>1</show_in_store>
775
- </sales_email-order_comment-template_send_type>
776
- <sales_email-order_comment-guest_template translate="label">
777
- <label>Order Comment Email Template for Guest</label>
778
- <frontend_type>select</frontend_type>
779
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
780
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
781
- <source_model>bronto_email/system_config_source_email_template</source_model>
782
- <sort_order>133</sort_order>
783
- <show_in_default>1</show_in_default>
784
- <show_in_website>1</show_in_website>
785
- <show_in_store>1</show_in_store>
786
- </sales_email-order_comment-guest_template>
787
- <sales_email-order_comment-guest_template_send_type translate="label">
788
- <label>Send Type</label>
789
- <frontend_type>radios</frontend_type>
790
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
791
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
792
- <source_model>bronto_email/system_config_source_sendtype</source_model>
793
- <sort_order>134</sort_order>
794
- <show_in_default>1</show_in_default>
795
- <show_in_website>1</show_in_website>
796
- <show_in_store>1</show_in_store>
797
- </sales_email-order_comment-guest_template_send_type>
798
-
799
- <label_sales_email_invoice>
800
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Invoice]]></label>
801
- <frontend_type>label</frontend_type>
802
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
803
- <sort_order>140</sort_order>
804
- <show_in_default>1</show_in_default>
805
- <show_in_website>1</show_in_website>
806
- <show_in_store>1</show_in_store>
807
- </label_sales_email_invoice>
808
- <sales_email-invoice-template translate="label">
809
- <label>Invoice Email Template</label>
810
- <frontend_type>select</frontend_type>
811
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
812
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
813
- <source_model>bronto_email/system_config_source_email_template</source_model>
814
- <sort_order>141</sort_order>
815
- <show_in_default>1</show_in_default>
816
- <show_in_website>1</show_in_website>
817
- <show_in_store>1</show_in_store>
818
- </sales_email-invoice-template>
819
- <sales_email-invoice-template_send_type translate="label">
820
- <label>Send Type</label>
821
- <frontend_type>radios</frontend_type>
822
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
823
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
824
- <source_model>bronto_email/system_config_source_sendtype</source_model>
825
- <sort_order>142</sort_order>
826
- <show_in_default>1</show_in_default>
827
- <show_in_website>1</show_in_website>
828
- <show_in_store>1</show_in_store>
829
- </sales_email-invoice-template_send_type>
830
- <sales_email-invoice-guest_template translate="label">
831
- <label>Invoice Email Template for Guest</label>
832
- <frontend_type>select</frontend_type>
833
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
834
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
835
- <source_model>bronto_email/system_config_source_email_template</source_model>
836
- <sort_order>143</sort_order>
837
- <show_in_default>1</show_in_default>
838
- <show_in_website>1</show_in_website>
839
- <show_in_store>1</show_in_store>
840
- </sales_email-invoice-guest_template>
841
- <sales_email-invoice-guest_template_send_type translate="label">
842
- <label>Send Type</label>
843
- <frontend_type>radios</frontend_type>
844
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
845
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
846
- <source_model>bronto_email/system_config_source_sendtype</source_model>
847
- <sort_order>144</sort_order>
848
- <show_in_default>1</show_in_default>
849
- <show_in_website>1</show_in_website>
850
- <show_in_store>1</show_in_store>
851
- </sales_email-invoice-guest_template_send_type>
852
-
853
- <label_sales_email_invoice_comment>
854
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Invoice Comments]]></label>
855
- <frontend_type>label</frontend_type>
856
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
857
- <sort_order>150</sort_order>
858
- <show_in_default>1</show_in_default>
859
- <show_in_website>1</show_in_website>
860
- <show_in_store>1</show_in_store>
861
- </label_sales_email_invoice_comment>
862
- <sales_email-invoice_comment-template translate="label">
863
- <label>Invoice Comment Email Template</label>
864
- <frontend_type>select</frontend_type>
865
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
866
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
867
- <source_model>bronto_email/system_config_source_email_template</source_model>
868
- <sort_order>151</sort_order>
869
- <show_in_default>1</show_in_default>
870
- <show_in_website>1</show_in_website>
871
- <show_in_store>1</show_in_store>
872
- </sales_email-invoice_comment-template>
873
- <sales_email-invoice_comment-template_send_type translate="label">
874
- <label>Send Type</label>
875
- <frontend_type>radios</frontend_type>
876
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
877
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
878
- <source_model>bronto_email/system_config_source_sendtype</source_model>
879
- <sort_order>152</sort_order>
880
- <show_in_default>1</show_in_default>
881
- <show_in_website>1</show_in_website>
882
- <show_in_store>1</show_in_store>
883
- </sales_email-invoice_comment-template_send_type>
884
- <sales_email-invoice_comment-guest_template translate="label">
885
- <label>Invoice Comment Email Template for Guest</label>
886
- <frontend_type>select</frontend_type>
887
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
888
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
889
- <source_model>bronto_email/system_config_source_email_template</source_model>
890
- <sort_order>153</sort_order>
891
- <show_in_default>1</show_in_default>
892
- <show_in_website>1</show_in_website>
893
- <show_in_store>1</show_in_store>
894
- </sales_email-invoice_comment-guest_template>
895
- <sales_email-invoice_comment-guest_template_send_type translate="label">
896
- <label>Send Type</label>
897
- <frontend_type>radios</frontend_type>
898
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
899
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
900
- <source_model>bronto_email/system_config_source_sendtype</source_model>
901
- <sort_order>154</sort_order>
902
- <show_in_default>1</show_in_default>
903
- <show_in_website>1</show_in_website>
904
- <show_in_store>1</show_in_store>
905
- </sales_email-invoice_comment-guest_template_send_type>
906
-
907
- <label_sales_email_shipment>
908
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Shipment]]></label>
909
- <frontend_type>label</frontend_type>
910
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
911
- <sort_order>160</sort_order>
912
- <show_in_default>1</show_in_default>
913
- <show_in_website>1</show_in_website>
914
- <show_in_store>1</show_in_store>
915
- </label_sales_email_shipment>
916
- <sales_email-shipment-template translate="label">
917
- <label>Shipment Email Template</label>
918
- <frontend_type>select</frontend_type>
919
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
920
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
921
- <source_model>bronto_email/system_config_source_email_template</source_model>
922
- <sort_order>161</sort_order>
923
- <show_in_default>1</show_in_default>
924
- <show_in_website>1</show_in_website>
925
- <show_in_store>1</show_in_store>
926
- </sales_email-shipment-template>
927
- <sales_email-shipment-template_send_type translate="label">
928
- <label>Send Type</label>
929
- <frontend_type>radios</frontend_type>
930
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
931
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
932
- <source_model>bronto_email/system_config_source_sendtype</source_model>
933
- <sort_order>162</sort_order>
934
- <show_in_default>1</show_in_default>
935
- <show_in_website>1</show_in_website>
936
- <show_in_store>1</show_in_store>
937
- </sales_email-shipment-template_send_type>
938
- <sales_email-shipment-guest_template translate="label">
939
- <label>Shipment Email Template for Guest</label>
940
- <frontend_type>select</frontend_type>
941
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
942
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
943
- <source_model>bronto_email/system_config_source_email_template</source_model>
944
- <sort_order>163</sort_order>
945
- <show_in_default>1</show_in_default>
946
- <show_in_website>1</show_in_website>
947
- <show_in_store>1</show_in_store>
948
- </sales_email-shipment-guest_template>
949
- <sales_email-shipment-guest_template_send_type translate="label">
950
- <label>Send Type</label>
951
- <frontend_type>radios</frontend_type>
952
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
953
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
954
- <source_model>bronto_email/system_config_source_sendtype</source_model>
955
- <sort_order>164</sort_order>
956
- <show_in_default>1</show_in_default>
957
- <show_in_website>1</show_in_website>
958
- <show_in_store>1</show_in_store>
959
- </sales_email-shipment-guest_template_send_type>
960
-
961
- <label_sales_email_shipment_comment>
962
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Shipment Comments]]></label>
963
- <frontend_type>label</frontend_type>
964
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
965
- <sort_order>170</sort_order>
966
- <show_in_default>1</show_in_default>
967
- <show_in_website>1</show_in_website>
968
- <show_in_store>1</show_in_store>
969
- </label_sales_email_shipment_comment>
970
- <sales_email-shipment_comment-template translate="label">
971
- <label>Shipment Comment Email Template</label>
972
- <frontend_type>select</frontend_type>
973
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
974
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
975
- <source_model>bronto_email/system_config_source_email_template</source_model>
976
- <sort_order>171</sort_order>
977
- <show_in_default>1</show_in_default>
978
- <show_in_website>1</show_in_website>
979
- <show_in_store>1</show_in_store>
980
- </sales_email-shipment_comment-template>
981
- <sales_email-shipment_comment-template_send_type translate="label">
982
- <label>Send Type</label>
983
- <frontend_type>radios</frontend_type>
984
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
985
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
986
- <source_model>bronto_email/system_config_source_sendtype</source_model>
987
- <sort_order>172</sort_order>
988
- <show_in_default>1</show_in_default>
989
- <show_in_website>1</show_in_website>
990
- <show_in_store>1</show_in_store>
991
- </sales_email-shipment_comment-template_send_type>
992
- <sales_email-shipment_comment-guest_template translate="label">
993
- <label>Shipment Comment Email Template for Guest</label>
994
- <frontend_type>select</frontend_type>
995
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
996
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
997
- <source_model>bronto_email/system_config_source_email_template</source_model>
998
- <sort_order>173</sort_order>
999
- <show_in_default>1</show_in_default>
1000
- <show_in_website>1</show_in_website>
1001
- <show_in_store>1</show_in_store>
1002
- </sales_email-shipment_comment-guest_template>
1003
- <sales_email-shipment_comment-guest_template_send_type translate="label">
1004
- <label>Send Type</label>
1005
- <frontend_type>radios</frontend_type>
1006
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1007
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1008
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1009
- <sort_order>174</sort_order>
1010
- <show_in_default>1</show_in_default>
1011
- <show_in_website>1</show_in_website>
1012
- <show_in_store>1</show_in_store>
1013
- </sales_email-shipment_comment-guest_template_send_type>
1014
-
1015
- <label_sales_email_creditmemo>
1016
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Credit Memo]]></label>
1017
- <frontend_type>label</frontend_type>
1018
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1019
- <sort_order>180</sort_order>
1020
- <show_in_default>1</show_in_default>
1021
- <show_in_website>1</show_in_website>
1022
- <show_in_store>1</show_in_store>
1023
- </label_sales_email_creditmemo>
1024
- <sales_email-creditmemo-template translate="label">
1025
- <label>Credit Memo Email Template</label>
1026
- <frontend_type>select</frontend_type>
1027
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1028
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1029
- <source_model>bronto_email/system_config_source_email_template</source_model>
1030
- <sort_order>181</sort_order>
1031
- <show_in_default>1</show_in_default>
1032
- <show_in_website>1</show_in_website>
1033
- <show_in_store>1</show_in_store>
1034
- </sales_email-creditmemo-template>
1035
- <sales_email-creditmemo-template_send_type translate="label">
1036
- <label>Send Type</label>
1037
- <frontend_type>radios</frontend_type>
1038
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1039
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1040
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1041
- <sort_order>182</sort_order>
1042
- <show_in_default>1</show_in_default>
1043
- <show_in_website>1</show_in_website>
1044
- <show_in_store>1</show_in_store>
1045
- </sales_email-creditmemo-template_send_type>
1046
- <sales_email-creditmemo-guest_template translate="label">
1047
- <label>Credit Memo Email Template for Guest</label>
1048
- <frontend_type>select</frontend_type>
1049
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1050
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1051
- <source_model>bronto_email/system_config_source_email_template</source_model>
1052
- <sort_order>183</sort_order>
1053
- <show_in_default>1</show_in_default>
1054
- <show_in_website>1</show_in_website>
1055
- <show_in_store>1</show_in_store>
1056
- </sales_email-creditmemo-guest_template>
1057
- <sales_email-creditmemo-guest_template_send_type translate="label">
1058
- <label>Send Type</label>
1059
- <frontend_type>radios</frontend_type>
1060
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1061
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1062
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1063
- <sort_order>184</sort_order>
1064
- <show_in_default>1</show_in_default>
1065
- <show_in_website>1</show_in_website>
1066
- <show_in_store>1</show_in_store>
1067
- </sales_email-creditmemo-guest_template_send_type>
1068
-
1069
- <label_sales_email_creditmemo_comment>
1070
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; Credit Memo Comments]]></label>
1071
- <frontend_type>label</frontend_type>
1072
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1073
- <sort_order>190</sort_order>
1074
- <show_in_default>1</show_in_default>
1075
- <show_in_website>1</show_in_website>
1076
- <show_in_store>1</show_in_store>
1077
- </label_sales_email_creditmemo_comment>
1078
- <sales_email-creditmemo_comment-template translate="label">
1079
- <label>Credit Memo Comment Email Template</label>
1080
- <frontend_type>select</frontend_type>
1081
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1082
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1083
- <source_model>bronto_email/system_config_source_email_template</source_model>
1084
- <sort_order>191</sort_order>
1085
- <show_in_default>1</show_in_default>
1086
- <show_in_website>1</show_in_website>
1087
- <show_in_store>1</show_in_store>
1088
- </sales_email-creditmemo_comment-template>
1089
- <sales_email-creditmemo_comment-template_send_type translate="label">
1090
- <label>Send Type</label>
1091
- <frontend_type>radios</frontend_type>
1092
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1093
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1094
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1095
- <sort_order>192</sort_order>
1096
- <show_in_default>1</show_in_default>
1097
- <show_in_website>1</show_in_website>
1098
- <show_in_store>1</show_in_store>
1099
- </sales_email-creditmemo_comment-template_send_type>
1100
- <sales_email-creditmemo_comment-guest_template translate="label">
1101
- <label>Credit Memo Comment Email Template for Guest</label>
1102
- <frontend_type>select</frontend_type>
1103
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1104
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1105
- <source_model>bronto_email/system_config_source_email_template</source_model>
1106
- <sort_order>193</sort_order>
1107
- <show_in_default>1</show_in_default>
1108
- <show_in_website>1</show_in_website>
1109
- <show_in_store>1</show_in_store>
1110
- </sales_email-creditmemo_comment-guest_template>
1111
- <sales_email-creditmemo_comment-guest_template_send_type translate="label">
1112
- <label>Send Type</label>
1113
- <frontend_type>radios</frontend_type>
1114
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1115
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1116
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1117
- <sort_order>194</sort_order>
1118
- <show_in_default>1</show_in_default>
1119
- <show_in_website>1</show_in_website>
1120
- <show_in_store>1</show_in_store>
1121
- </sales_email-creditmemo_comment-guest_template_send_type>
1122
-
1123
- <label_sales_email_enterprise_rma>
1124
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; RMA]]></label>
1125
- <frontend_type>label</frontend_type>
1126
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1127
- <sort_order>200</sort_order>
1128
- <show_in_default>1</show_in_default>
1129
- <show_in_website>1</show_in_website>
1130
- <show_in_store>1</show_in_store>
1131
- </label_sales_email_enterprise_rma>
1132
- <sales_email-enterprise_rma-template translate="label">
1133
- <label>RMA Email Template</label>
1134
- <frontend_type>select</frontend_type>
1135
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1136
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1137
- <source_model>bronto_email/system_config_source_email_template</source_model>
1138
- <sort_order>201</sort_order>
1139
- <show_in_default>1</show_in_default>
1140
- <show_in_website>1</show_in_website>
1141
- <show_in_store>1</show_in_store>
1142
- </sales_email-enterprise_rma-template>
1143
- <sales_email-enterprise_rma-template_send_type translate="label">
1144
- <label>Send Type</label>
1145
- <frontend_type>radios</frontend_type>
1146
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1147
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1148
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1149
- <sort_order>202</sort_order>
1150
- <show_in_default>1</show_in_default>
1151
- <show_in_website>1</show_in_website>
1152
- <show_in_store>1</show_in_store>
1153
- </sales_email-enterprise_rma-template_send_type>
1154
- <sales_email-enterprise_rma-guest_template translate="label">
1155
- <label>RMA Email Template for Guest</label>
1156
- <frontend_type>select</frontend_type>
1157
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1158
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1159
- <source_model>bronto_email/system_config_source_email_template</source_model>
1160
- <sort_order>203</sort_order>
1161
- <show_in_default>1</show_in_default>
1162
- <show_in_website>1</show_in_website>
1163
- <show_in_store>1</show_in_store>
1164
- </sales_email-enterprise_rma-guest_template>
1165
- <sales_email-enterprise_rma-guest_template_send_type translate="label">
1166
- <label>Send Type</label>
1167
- <frontend_type>radios</frontend_type>
1168
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1169
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1170
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1171
- <sort_order>204</sort_order>
1172
- <show_in_default>1</show_in_default>
1173
- <show_in_website>1</show_in_website>
1174
- <show_in_store>1</show_in_store>
1175
- </sales_email-enterprise_rma-guest_template_send_type>
1176
-
1177
- <label_sales_email_enterprise_rma_auth>
1178
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; RMA Authorization]]></label>
1179
- <frontend_type>label</frontend_type>
1180
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1181
- <sort_order>210</sort_order>
1182
- <show_in_default>1</show_in_default>
1183
- <show_in_website>1</show_in_website>
1184
- <show_in_store>1</show_in_store>
1185
- </label_sales_email_enterprise_rma_auth>
1186
- <sales_email-enterprise_rma_auth-template translate="label">
1187
- <label>RMA Authorization Email Template</label>
1188
- <frontend_type>select</frontend_type>
1189
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1190
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1191
- <source_model>bronto_email/system_config_source_email_template</source_model>
1192
- <sort_order>211</sort_order>
1193
- <show_in_default>1</show_in_default>
1194
- <show_in_website>1</show_in_website>
1195
- <show_in_store>1</show_in_store>
1196
- </sales_email-enterprise_rma_auth-template>
1197
- <sales_email-enterprise_rma_auth-template_send_type translate="label">
1198
- <label>Send Type</label>
1199
- <frontend_type>radios</frontend_type>
1200
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1201
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1202
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1203
- <sort_order>212</sort_order>
1204
- <show_in_default>1</show_in_default>
1205
- <show_in_website>1</show_in_website>
1206
- <show_in_store>1</show_in_store>
1207
- </sales_email-enterprise_rma_auth-template_send_type>
1208
- <sales_email-enterprise_rma_auth-guest_template translate="label">
1209
- <label>RMA Authorization Email Template for Guest</label>
1210
- <frontend_type>select</frontend_type>
1211
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1212
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1213
- <source_model>bronto_email/system_config_source_email_template</source_model>
1214
- <sort_order>213</sort_order>
1215
- <show_in_default>1</show_in_default>
1216
- <show_in_website>1</show_in_website>
1217
- <show_in_store>1</show_in_store>
1218
- </sales_email-enterprise_rma_auth-guest_template>
1219
- <sales_email-enterprise_rma_auth-guest_template_send_type translate="label">
1220
- <label>Send Type</label>
1221
- <frontend_type>radios</frontend_type>
1222
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1223
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1224
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1225
- <sort_order>214</sort_order>
1226
- <show_in_default>1</show_in_default>
1227
- <show_in_website>1</show_in_website>
1228
- <show_in_store>1</show_in_store>
1229
- </sales_email-enterprise_rma_auth-guest_template_send_type>
1230
-
1231
- <label_sales_email_enterprise_rma_comment>
1232
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; RMA Admin Comments]]></label>
1233
- <frontend_type>label</frontend_type>
1234
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1235
- <sort_order>220</sort_order>
1236
- <show_in_default>1</show_in_default>
1237
- <show_in_website>1</show_in_website>
1238
- <show_in_store>1</show_in_store>
1239
- </label_sales_email_enterprise_rma_comment>
1240
- <sales_email-enterprise_rma_comment-template translate="label">
1241
- <label>RMA Comment Email Template</label>
1242
- <frontend_type>select</frontend_type>
1243
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1244
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1245
- <source_model>bronto_email/system_config_source_email_template</source_model>
1246
- <sort_order>221</sort_order>
1247
- <show_in_default>1</show_in_default>
1248
- <show_in_website>1</show_in_website>
1249
- <show_in_store>1</show_in_store>
1250
- </sales_email-enterprise_rma_comment-template>
1251
- <sales_email-enterprise_rma_comment-template_send_type translate="label">
1252
- <label>Send Type</label>
1253
- <frontend_type>radios</frontend_type>
1254
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1255
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1256
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1257
- <sort_order>222</sort_order>
1258
- <show_in_default>1</show_in_default>
1259
- <show_in_website>1</show_in_website>
1260
- <show_in_store>1</show_in_store>
1261
- </sales_email-enterprise_rma_comment-template_send_type>
1262
- <sales_email-enterprise_rma_comment-guest_template translate="label">
1263
- <label>RMA Comment Email Template for Guest</label>
1264
- <frontend_type>select</frontend_type>
1265
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1266
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1267
- <source_model>bronto_email/system_config_source_email_template</source_model>
1268
- <sort_order>223</sort_order>
1269
- <show_in_default>1</show_in_default>
1270
- <show_in_website>1</show_in_website>
1271
- <show_in_store>1</show_in_store>
1272
- </sales_email-enterprise_rma_comment-guest_template>
1273
- <sales_email-enterprise_rma_comment-guest_template_send_type translate="label">
1274
- <label>Send Type</label>
1275
- <frontend_type>radios</frontend_type>
1276
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1277
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1278
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1279
- <sort_order>224</sort_order>
1280
- <show_in_default>1</show_in_default>
1281
- <show_in_website>1</show_in_website>
1282
- <show_in_store>1</show_in_store>
1283
- </sales_email-enterprise_rma_comment-guest_template_send_type>
1284
-
1285
- <label_sales_email_enterprise_rma_customer_comment>
1286
- <label><![CDATA[##sales_email## Sales &raquo; Sales Emails &raquo; RMA Customer Comments]]></label>
1287
- <frontend_type>label</frontend_type>
1288
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1289
- <sort_order>230</sort_order>
1290
- <show_in_default>1</show_in_default>
1291
- <show_in_website>1</show_in_website>
1292
- <show_in_store>1</show_in_store>
1293
- </label_sales_email_enterprise_rma_customer_comment>
1294
- <sales_email-enterprise_rma_customer_comment-template translate="label">
1295
- <label>RMA Comment Email Template</label>
1296
- <frontend_type>select</frontend_type>
1297
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1298
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1299
- <source_model>bronto_email/system_config_source_email_template</source_model>
1300
- <sort_order>231</sort_order>
1301
- <show_in_default>1</show_in_default>
1302
- <show_in_website>1</show_in_website>
1303
- <show_in_store>1</show_in_store>
1304
- </sales_email-enterprise_rma_customer_comment-template>
1305
- <sales_email-enterprise_rma_customer_comment-template_send_type translate="label">
1306
- <label>Send Type</label>
1307
- <frontend_type>radios</frontend_type>
1308
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1309
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1310
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1311
- <sort_order>232</sort_order>
1312
- <show_in_default>1</show_in_default>
1313
- <show_in_website>1</show_in_website>
1314
- <show_in_store>1</show_in_store>
1315
- </sales_email-enterprise_rma_customer_comment-template_send_type>
1316
- <sales_email-enterprise_rma_customer_comment-guest_template translate="label">
1317
- <label>RMA Comment Email Template for Guest</label>
1318
- <frontend_type>select</frontend_type>
1319
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1320
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1321
- <source_model>bronto_email/system_config_source_email_template</source_model>
1322
- <sort_order>233</sort_order>
1323
- <show_in_default>1</show_in_default>
1324
- <show_in_website>1</show_in_website>
1325
- <show_in_store>1</show_in_store>
1326
- </sales_email-enterprise_rma_customer_comment-guest_template>
1327
- <sales_email-enterprise_rma_customer_comment-guest_template_send_type translate="label">
1328
- <label>Send Type</label>
1329
- <frontend_type>radios</frontend_type>
1330
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1331
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1332
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1333
- <sort_order>234</sort_order>
1334
- <show_in_default>1</show_in_default>
1335
- <show_in_website>1</show_in_website>
1336
- <show_in_store>1</show_in_store>
1337
- </sales_email-enterprise_rma_customer_comment-guest_template_send_type>
1338
-
1339
- <label_sales_checkout_payment_failed>
1340
- <label><![CDATA[##checkout## Sales &raquo; Checkout &raquo; Payment Failed Emails]]></label>
1341
- <frontend_type>label</frontend_type>
1342
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1343
- <sort_order>240</sort_order>
1344
- <show_in_default>1</show_in_default>
1345
- <show_in_website>1</show_in_website>
1346
- <show_in_store>1</show_in_store>
1347
- </label_sales_checkout_payment_failed>
1348
- <checkout-payment_failed-template translate="label">
1349
- <label>Payment Failed Template</label>
1350
- <frontend_type>select</frontend_type>
1351
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1352
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1353
- <source_model>bronto_email/system_config_source_email_template</source_model>
1354
- <sort_order>241</sort_order>
1355
- <show_in_default>1</show_in_default>
1356
- <show_in_website>1</show_in_website>
1357
- <show_in_store>1</show_in_store>
1358
- </checkout-payment_failed-template>
1359
- <checkout-payment_failed-template_send_type translate="label">
1360
- <label>Send Type</label>
1361
- <frontend_type>radios</frontend_type>
1362
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1363
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1364
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1365
- <sort_order>242</sort_order>
1366
- <show_in_default>1</show_in_default>
1367
- <show_in_website>1</show_in_website>
1368
- <show_in_store>1</show_in_store>
1369
- </checkout-payment_failed-template_send_type>
1370
-
1371
- <label_admin_forgot_password>
1372
- <label><![CDATA[##admin## Advanced &raquo; Admin &raquo; Admin User Emails]]></label>
1373
- <frontend_type>label</frontend_type>
1374
- <frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
1375
- <sort_order>250</sort_order>
1376
- <show_in_default>1</show_in_default>
1377
- <show_in_website>1</show_in_website>
1378
- <show_in_store>1</show_in_store>
1379
- </label_admin_forgot_password>
1380
- <admin-emails-forgot_email_template translate="label">
1381
- <label>Forgot Password Email Template</label>
1382
- <frontend_type>select</frontend_type>
1383
- <frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
1384
- <backend_model>bronto_email/system_config_backend_templates_field</backend_model>
1385
- <source_model>bronto_email/system_config_source_email_template</source_model>
1386
- <sort_order>251</sort_order>
1387
- <show_in_default>1</show_in_default>
1388
- <show_in_website>1</show_in_website>
1389
- <show_in_store>1</show_in_store>
1390
- </admin-emails-forgot_email_template>
1391
- <admin-emails-forgot_email_template_send_type translate="label">
1392
- <label>Send Type</label>
1393
- <frontend_type>radios</frontend_type>
1394
- <frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
1395
- <backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
1396
- <source_model>bronto_email/system_config_source_sendtype</source_model>
1397
- <sort_order>252</sort_order>
1398
- <show_in_default>1</show_in_default>
1399
- <show_in_website>1</show_in_website>
1400
- <show_in_store>1</show_in_store>
1401
- </admin-emails-forgot_email_template_send_type>
1402
- </fields>-->
1403
- </templates>
1404
- </groups>
1405
- </bronto_email>
1406
- </sections>
1407
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.0.php DELETED
@@ -1,30 +0,0 @@
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
-
11
- ALTER TABLE `{$installer->getTable('core/email_template')}`
12
- ADD COLUMN `bronto_message_id` char(36) NOT NULL default '';
13
-
14
- ");
15
- } catch (Exception $e) {
16
- //
17
- }
18
-
19
- try {
20
- $installer->run("
21
-
22
- ALTER TABLE `{$installer->getTable('core/email_template')}`
23
- ADD COLUMN `bronto_message_name` varchar(255) NOT NULL default '';
24
-
25
- ");
26
- } catch (Exception $e) {
27
- //
28
- }
29
-
30
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.2.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->run("
9
-
10
- CREATE TABLE `{$this->getTable('bronto_email_log')}` (
11
- `log_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
12
- `customer_id` int(10) UNSIGNED NULL DEFAULT NULL ,
13
- `customer_email` varchar(255) NULL DEFAULT NULL ,
14
- `contact_id` char(36) NULL DEFAULT NULL ,
15
- `message_id` char(36) NOT NULL ,
16
- `delivery_id` char(36) NULL DEFAULT NULL ,
17
- `sent_at` datetime NULL DEFAULT NULL ,
18
- `success` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 ,
19
- `error` varchar(255) NULL DEFAULT NULL ,
20
- PRIMARY KEY (`log_id`),
21
- INDEX `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`)
22
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
-
24
- ");
25
-
26
- try {
27
- $installer->run("
28
-
29
- ALTER TABLE `{$installer->getTable('core/email_template')}`
30
- ADD COLUMN `bronto_message_id` char(36) NULL DEFAULT NULL;
31
-
32
- ");
33
- } catch (Exception $e) {
34
- //
35
- }
36
-
37
- try {
38
- $installer->run("
39
-
40
- ALTER TABLE `{$installer->getTable('core/email_template')}`
41
- ADD COLUMN `bronto_message_name` varchar(255) NULL DEFAULT NULL;
42
-
43
- ");
44
- } catch (Exception $e) {
45
- //
46
- }
47
-
48
- try {
49
- $installer->run("
50
-
51
- ALTER TABLE `{$installer->getTable('core/email_template')}`
52
- ADD COLUMN `bronto_message_approved` tinyint(1) UNSIGNED NOT NULL DEFAULT 1;
53
-
54
- ");
55
- } catch (Exception $e) {
56
- //
57
- }
58
-
59
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.5.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->run("
9
-
10
- CREATE TABLE `{$this->getTable('bronto_email_log')}` (
11
- `log_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
12
- `customer_id` int(10) UNSIGNED NULL DEFAULT NULL ,
13
- `customer_email` varchar(255) NULL DEFAULT NULL ,
14
- `contact_id` char(36) NULL DEFAULT NULL ,
15
- `message_id` char(36) NOT NULL ,
16
- `delivery_id` char(36) NULL DEFAULT NULL ,
17
- `sent_at` datetime NULL DEFAULT NULL ,
18
- `success` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 ,
19
- `error` varchar(255) NULL DEFAULT NULL ,
20
- PRIMARY KEY (`log_id`),
21
- INDEX `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`)
22
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
-
24
- ");
25
-
26
- try {
27
- $installer->run("
28
-
29
- ALTER TABLE `{$installer->getTable('core/email_template')}`
30
- ADD COLUMN `bronto_message_id` char(36) NULL DEFAULT NULL;
31
-
32
- ");
33
- } catch (Exception $e) {
34
- //
35
- }
36
-
37
- try {
38
- $installer->run("
39
-
40
- ALTER TABLE `{$installer->getTable('core/email_template')}`
41
- ADD COLUMN `bronto_message_name` varchar(255) NULL DEFAULT NULL;
42
-
43
- ");
44
- } catch (Exception $e) {
45
- //
46
- }
47
-
48
- try {
49
- $installer->run("
50
-
51
- ALTER TABLE `{$installer->getTable('core/email_template')}`
52
- ADD COLUMN `bronto_message_approved` tinyint(1) UNSIGNED NOT NULL DEFAULT 1;
53
-
54
- ");
55
- } catch (Exception $e) {
56
- //
57
- }
58
-
59
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.0.8.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->run("
9
-
10
- CREATE TABLE `{$this->getTable('bronto_email_log')}` (
11
- `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
12
- `customer_id` int(10) unsigned DEFAULT NULL,
13
- `customer_email` varchar(255) DEFAULT NULL,
14
- `contact_id` char(36) DEFAULT NULL,
15
- `message_id` char(36) NOT NULL,
16
- `message_name` varchar(64) DEFAULT NULL,
17
- `delivery_id` char(36) DEFAULT NULL,
18
- `sent_at` datetime DEFAULT NULL,
19
- `success` tinyint(1) unsigned NOT NULL DEFAULT '0',
20
- `error` varchar(255) DEFAULT NULL,
21
- `fields` text,
22
- PRIMARY KEY (`log_id`),
23
- KEY `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`),
24
- KEY `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`)
25
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
-
27
- ");
28
-
29
- try {
30
- $installer->run("
31
-
32
- ALTER TABLE `{$installer->getTable('core/email_template')}`
33
- ADD COLUMN `bronto_message_id` char(36) NULL DEFAULT NULL;
34
-
35
- ");
36
- } catch (Exception $e) {
37
- //
38
- }
39
-
40
- try {
41
- $installer->run("
42
-
43
- ALTER TABLE `{$installer->getTable('core/email_template')}`
44
- ADD COLUMN `bronto_message_name` varchar(255) NULL DEFAULT NULL;
45
-
46
- ");
47
- } catch (Exception $e) {
48
- //
49
- }
50
-
51
- try {
52
- $installer->run("
53
-
54
- ALTER TABLE `{$installer->getTable('core/email_template')}`
55
- ADD COLUMN `bronto_message_approved` tinyint(1) UNSIGNED NOT NULL DEFAULT 1;
56
-
57
- ");
58
- } catch (Exception $e) {
59
- //
60
- }
61
-
62
- $installer->endSetup();
63
-
64
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.2.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->run("
9
-
10
- CREATE TABLE `{$this->getTable('bronto_email_log')}` (
11
- `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
12
- `customer_id` int(10) unsigned DEFAULT NULL,
13
- `customer_email` varchar(255) DEFAULT NULL,
14
- `contact_id` char(36) DEFAULT NULL,
15
- `message_id` char(36) NOT NULL,
16
- `message_name` varchar(64) DEFAULT NULL,
17
- `delivery_id` char(36) DEFAULT NULL,
18
- `sent_at` datetime DEFAULT NULL,
19
- `success` tinyint(1) unsigned NOT NULL DEFAULT '0',
20
- `error` varchar(255) DEFAULT NULL,
21
- `fields` text,
22
- PRIMARY KEY (`log_id`),
23
- KEY `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`),
24
- KEY `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`)
25
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
-
27
- ");
28
-
29
- try {
30
- $installer->run("
31
-
32
- ALTER TABLE `{$installer->getTable('core/email_template')}`
33
- ADD COLUMN `bronto_message_id` char(36) NULL DEFAULT NULL;
34
-
35
- ");
36
- } catch (Exception $e) {
37
- //
38
- }
39
-
40
- try {
41
- $installer->run("
42
-
43
- ALTER TABLE `{$installer->getTable('core/email_template')}`
44
- ADD COLUMN `bronto_message_name` varchar(255) NULL DEFAULT NULL;
45
-
46
- ");
47
- } catch (Exception $e) {
48
- //
49
- }
50
-
51
- try {
52
- $installer->run("
53
-
54
- ALTER TABLE `{$installer->getTable('core/email_template')}`
55
- ADD COLUMN `bronto_message_approved` tinyint(1) UNSIGNED NOT NULL DEFAULT 1;
56
-
57
- ");
58
- } catch (Exception $e) {
59
- //
60
- }
61
-
62
- try {
63
- $installer->run("
64
-
65
- ALTER TABLE `{$installer->getTable('core/email_template')}`
66
- ADD COLUMN `store_id` int(10) NOT NULL default '1';
67
-
68
- ");
69
-
70
- } catch (Exception $e) {
71
- Mage::log($e->getMessage());
72
- }
73
-
74
- $installer->endSetup();
75
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.7.php DELETED
@@ -1,63 +0,0 @@
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
- PRIMARY KEY (`core_template_id`),
24
- CONSTRAINT `FK_BRONTO_EMAIL_TEMPLATE_ID_CORE_EMAIL_TEMPLATE_ID` FOREIGN KEY (`core_template_id`)
25
- REFERENCES `{$installer->getTable('core/email_template')}` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
26
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Template Attributes'
27
- ");
28
-
29
- } catch (Exception $e) {
30
- Mage::helper('bronto_email')->writeError($e->getMessage());
31
- }
32
-
33
- /**
34
- * Email Log table
35
- */
36
- try {
37
-
38
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_email/log')}`;");
39
-
40
- $installer->run("
41
- CREATE TABLE `{$installer->getTable('bronto_email/log')}` (
42
- `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
43
- `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
44
- `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
45
- `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
46
- `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
47
- `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
48
- `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
49
- `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
50
- `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
51
- `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
52
- `fields` text COMMENT 'Fields',
53
- PRIMARY KEY (`log_id`),
54
- KEY `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`),
55
- KEY `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`)
56
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Delivery Logs'
57
- ");
58
-
59
- } catch (Exception $e) {
60
- Mage::helper('bronto_email')->writeError($e->getMessage());
61
- }
62
-
63
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.8.php DELETED
@@ -1,64 +0,0 @@
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-install-1.1.9.php DELETED
@@ -1,65 +0,0 @@
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
- KEY `IDX_BRONTO_STORE_ID` (`store_id`),
26
- CONSTRAINT `FK_BRONTO_EMAIL_TEMPLATE_ID_CORE_EMAIL_TEMPLATE_ID` FOREIGN KEY (`core_template_id`)
27
- REFERENCES `{$installer->getTable('core/email_template')}` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
28
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Template Attributes'
29
- ");
30
-
31
- } catch (Exception $e) {
32
- Mage::helper('bronto_email')->writeError($e->getMessage());
33
- }
34
-
35
- /**
36
- * Email Log table
37
- */
38
- try {
39
-
40
- $installer->run("DROP TABLE IF EXISTS `{$installer->getTable('bronto_email/log')}`;");
41
-
42
- $installer->run("
43
- CREATE TABLE `{$installer->getTable('bronto_email/log')}` (
44
- `log_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log ID',
45
- `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer ID',
46
- `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email Address',
47
- `contact_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Contact ID',
48
- `message_id` varchar(36) NOT NULL COMMENT 'Bronto Message ID',
49
- `message_name` varchar(64) DEFAULT NULL COMMENT 'Bronto Message Name',
50
- `delivery_id` varchar(36) DEFAULT NULL COMMENT 'Bronto Delivery ID',
51
- `sent_at` datetime DEFAULT NULL COMMENT 'Date Message Sent',
52
- `success` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Message Send Success',
53
- `error` varchar(255) DEFAULT NULL COMMENT 'Error Message',
54
- `fields` text COMMENT 'Fields',
55
- PRIMARY KEY (`log_id`),
56
- KEY `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`),
57
- KEY `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`)
58
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Delivery Logs'
59
- ");
60
-
61
- } catch (Exception $e) {
62
- Mage::helper('bronto_email')->writeError($e->getMessage());
63
- }
64
-
65
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.2.0.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_email')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.2.1.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_email')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.2.2.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->createTables();
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_email')->writeError($e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.0-1.0.2.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->run("
9
-
10
- CREATE TABLE `{$this->getTable('bronto_email_log')}` (
11
- `log_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
12
- `customer_id` int(10) UNSIGNED NULL DEFAULT NULL ,
13
- `customer_email` varchar(255) NULL DEFAULT NULL ,
14
- `contact_id` char(36) NULL DEFAULT NULL ,
15
- `message_id` char(36) NOT NULL ,
16
- `delivery_id` char(36) NULL DEFAULT NULL ,
17
- `sent_at` datetime NULL DEFAULT NULL ,
18
- `success` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 ,
19
- `error` varchar(255) NULL DEFAULT NULL ,
20
- PRIMARY KEY (`log_id`),
21
- INDEX `IDX_BRONTO_EMAIL_LOG_CUSTOMER_EMAIL` (`customer_email`)
22
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
-
24
- ");
25
-
26
- try {
27
- $installer->run("
28
-
29
- ALTER TABLE `{$installer->getTable('core/email_template')}`
30
- MODIFY COLUMN `bronto_message_id` char(36) NULL DEFAULT NULL;
31
-
32
- ");
33
- } catch (Exception $e) {
34
- //
35
- }
36
-
37
- try {
38
- $installer->run("
39
-
40
- ALTER TABLE `{$installer->getTable('core/email_template')}`
41
- ADD COLUMN `bronto_message_approved` tinyint(1) UNSIGNED NOT NULL DEFAULT 1;
42
-
43
- ");
44
- } catch (Exception $e) {
45
- //
46
- }
47
-
48
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.2-1.0.5.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->endSetup();
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.5-1.0.8.php DELETED
@@ -1,21 +0,0 @@
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
-
11
- ALTER TABLE `{$this->getTable('bronto_email_log')}`
12
- ADD COLUMN `message_name` varchar(64) NULL DEFAULT NULL AFTER `message_id`,
13
- ADD COLUMN `fields` text NULL AFTER `error`,
14
- ADD INDEX `IDX_BRONTO_EMAIL_LOG_SENT_AT` (`sent_at`) ;
15
-
16
- ");
17
- } catch (Exception $e) {
18
- //
19
- }
20
-
21
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.0.8-1.1.1.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Mage_Core_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- $installer->endSetup();
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.1-1.1.2.php DELETED
@@ -1,20 +0,0 @@
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
-
11
- ALTER TABLE `{$installer->getTable('core/email_template')}`
12
- ADD COLUMN `store_id` int(10) NOT NULL default '1';
13
-
14
- ");
15
-
16
- } catch (Exception $e) {
17
- Mage::log($e->getMessage());
18
- }
19
-
20
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.2-1.1.7.php DELETED
@@ -1,63 +0,0 @@
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
- PRIMARY KEY (`core_template_id`),
24
- CONSTRAINT `FK_BRONTO_EMAIL_TEMPLATE_ID_CORE_EMAIL_TEMPLATE_ID` FOREIGN KEY (`core_template_id`)
25
- REFERENCES `{$installer->getTable('core/email_template')}` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
26
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Email Template Attributes'
27
- ");
28
- } catch (Exception $e) {
29
- Mage::helper('bronto_email')->writeError($e->getMessage());
30
- }
31
-
32
- /**
33
- * Move bronto email template attributes to new bronto table
34
- */
35
- try {
36
- $installer->run("
37
- INSERT IGNORE INTO `{$this->getTable('bronto_email/message')}`
38
- SELECT `template_id`, 'magento', `template_text`, `bronto_message_id`, `bronto_message_name`, `bronto_message_approved`, `store_id`
39
- FROM `{$installer->getTable('core/email_template')}`;
40
- ");
41
-
42
- /**
43
- * Remove columns that were added to core/email_template table
44
- * within same try/catch so we don't remove columns if insert fails
45
- */
46
- $installer->run("
47
- ALTER TABLE `{$installer->getTable('core/email_template')}` DROP `bronto_message_id`;
48
- ALTER TABLE `{$installer->getTable('core/email_template')}` DROP `bronto_message_name`;
49
- ALTER TABLE `{$installer->getTable('core/email_template')}` DROP `bronto_message_approved`;
50
- ALTER TABLE `{$installer->getTable('core/email_template')}` DROP `store_id`;
51
- ");
52
-
53
- $installer->run("
54
- UPDATE `{$installer->getTable('bronto_email/message')}`
55
- SET `template_send_type` = 'transactional';
56
- ");
57
- } catch (Exception $e) {
58
- Mage::helper('bronto_email')->writeError($e->getMessage());
59
- }
60
-
61
- $installer->endSetup();
62
-
63
- $installer->setDefaultSending();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.7-1.1.8.php DELETED
@@ -1,20 +0,0 @@
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/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.8-1.1.9.php DELETED
@@ -1,20 +0,0 @@
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 KEY `IDX_BRONTO_STORE_ID` (`store_id`);
15
- ");
16
- } catch (Exception $e) {
17
- Mage::helper('bronto_email')->writeError($e->getMessage());
18
- }
19
-
20
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.9-1.2.0.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
- $installer->updateTables('1.2.0');
7
- $installer->endSetup();
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.2.0-1.2.1.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->updateTables('1.2.1');
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_email')->writeError('Failed to upgrade email to 1.2.1: ' . $e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.2.1-1.2.2.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- try {
8
- $installer->updateTables('1.2.2');
9
- } catch (Exception $e) {
10
- Mage::helper('bronto_email')->writeError('Failed to upgrade email to 1.2.2: ' . $e->getMessage());
11
- }
12
-
13
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Emailcapture/Block/Emailcapture.php DELETED
@@ -1,42 +0,0 @@
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
- $secure = Mage::app()->getFrontController()->getRequest()->isSecure();
17
- return Mage::getUrl('emailcapture/index/capture', array('_secure' => $secure));
18
- }
19
-
20
- /**
21
- * Check if module is enabled
22
- *
23
- * @param string $scope
24
- * @param int $scopeId
25
- *
26
- * @return bool
27
- */
28
- public function isEnabled($scope = 'default', $scopeId = 0)
29
- {
30
- return Mage::helper('bronto_emailcapture')->isEnabled($scope, $scopeId);
31
- }
32
-
33
- /**
34
- * Get CSS Selector for Email Capture Fields
35
- *
36
- * @return mixed
37
- */
38
- public function getFieldSelector()
39
- {
40
- return Mage::helper('bronto_emailcapture')->getFieldSelector();
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Emailcapture/Helper/Data.php DELETED
@@ -1,61 +0,0 @@
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 DELETED
@@ -1,36 +0,0 @@
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 DELETED
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,66 +0,0 @@
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 DELETED
@@ -1,138 +0,0 @@
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
- $resource = Mage::getSingleton('core/resource');
136
- $this->_getResource()->getWriteAdapter()->delete($resource->getTableName('bronto_emailcapture/queue'), $where);
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Emailcapture/controllers/IndexController.php DELETED
@@ -1,39 +0,0 @@
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 DELETED
@@ -1,119 +0,0 @@
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 DELETED
@@ -1,41 +0,0 @@
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 DELETED
@@ -1,22 +0,0 @@
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 DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Block_Adminhtml_ItemRender extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
4
- {
5
-
6
- /**
7
- * @see parent
8
- */
9
- public function _construct()
10
- {
11
- parent::_construct();
12
- $this->setTemplate('bronto/news/item.phtml');
13
- }
14
-
15
- /**
16
- * @see parent
17
- */
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 DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Block_Adminhtml_Redirect
4
- extends Mage_Adminhtml_Block_Template
5
- {
6
- private $_url;
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;
14
- }
15
-
16
- public function setRedirectUrl($url)
17
- {
18
- $this->_url = $url;
19
-
20
- return $this;
21
- }
22
-
23
- public function getRedirectUrl()
24
- {
25
- return $this->_url;
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Block/Adminhtml/System/Config/About.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Block_Adminhtml_System_Config_About extends Bronto_Common_Block_Adminhtml_System_Config_About
4
- {
5
-
6
- /**
7
- * @var string
8
- */
9
- protected $_module = 'bronto_news';
10
-
11
- /**
12
- * @var string
13
- */
14
- protected $_name = 'Bronto News for Magento';
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Block/Adminhtml/System/Config/Form.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form
4
- {
5
-
6
- /**
7
- * Gets the internal url for submission
8
- *
9
- * @return string
10
- */
11
- public function getSubmitUrl()
12
- {
13
- return $this->getUrl('*/announcement/refresh');
14
- }
15
-
16
- /**
17
- * @see parent
18
- */
19
- public function setParentBlock(Mage_Core_Block_Abstract $block)
20
- {
21
- $block
22
- ->getChild('save_button')
23
- ->setLabel(Mage::helper('adminhtml')->__('Refresh'))
24
- ->setOnClick("configForm.submit('{$this->getSubmitUrl()}');");
25
-
26
- return parent::setParentBlock($block);
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Block/Adminhtml/System/Config/General.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Block_Adminhtml_System_Config_General extends Bronto_News_Block_Adminhtml_System_Config_News
4
- {
5
-
6
- /**
7
- * @see parent
8
- */
9
- protected function _pullRssItems()
10
- {
11
- return Mage::getModel('bronto_news/item')->getLimitedGeneralNotes();
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Block/Adminhtml/System/Config/News.php DELETED
@@ -1,159 +0,0 @@
1
- <?php
2
-
3
- abstract class Bronto_News_Block_Adminhtml_System_Config_News extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
- {
5
-
6
- /**
7
- * @var Mage_Core_Helper_Abstract
8
- */
9
- protected $_helper;
10
-
11
- /**
12
- * @var
13
- */
14
- protected $_renderer;
15
-
16
- /**
17
- * @var Varien_Object
18
- */
19
- protected $_itemDefinition;
20
-
21
- /**
22
- * @return Bronto_News_Model_Mysql4_Item_Collection
23
- */
24
- protected abstract function _pullRssItems();
25
-
26
- /**
27
- * @return Mage_Core_Helper_Abstract
28
- */
29
- protected function _getHelper()
30
- {
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
-
62
- /**
63
- * @return Varien_Object
64
- */
65
- protected function _getItemDefinition()
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
-
76
- return $this->_itemDefinition;
77
- }
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
-
96
- return $field;
97
- }
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)
105
- {
106
- $helper = $this->_getHelper();
107
-
108
- if (!$helper->validApiToken()) {
109
- // Route to API token
110
- $url = $helper->getScopeUrl('*/system_config/edit', array(
111
- 'section' => 'bronto'
112
- ));
113
-
114
- $element->setComment("In order to receive <strong>{$element->getLegend()}</strong>, you must enter a valid <a href=\"{$url}\">API Token</a>.");
115
- } else {
116
- foreach ($this->_pullRssItems() as $rssItem) {
117
- $this
118
- ->addItemToFieldset($element, $rssItem)
119
- ->setRenderer($this->_getRenderer());
120
- }
121
- }
122
-
123
- return parent::render($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/Block/Adminhtml/System/Config/Releases.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Block_Adminhtml_System_Config_Releases extends Bronto_News_Block_Adminhtml_System_Config_News
4
- {
5
-
6
- /**
7
- * @see parent
8
- */
9
- protected function _pullRssItems()
10
- {
11
- return Mage::getModel('bronto_news/item')->getLimitedReleaseNotes();
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Helper/Data.php DELETED
@@ -1,231 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
4
- {
5
- const XML_PATH_FEEDS = 'bronto_news/feeds';
6
-
7
- /**
8
- * @var Varien_Http_Adapter_Curl
9
- */
10
- protected $_xmlProvider;
11
-
12
- /**
13
- * @var Zend_Http_Client
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
- *
35
- * @return int
36
- */
37
- public function getThreshold()
38
- {
39
- return (int)$this->getAdminScopedConfig(self::XML_PATH_FEEDS . '/threshold');
40
- }
41
-
42
- /**
43
- * Gets the release announcements RSS url
44
- *
45
- * @return string
46
- */
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
-
54
- /**
55
- * Gets the general feed RSS url
56
- *
57
- * @return string
58
- */
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)
74
- {
75
- if (is_null($this->_client)) {
76
- $this->_client = new Zend_Http_Client();
77
- }
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)
93
- {
94
- if (is_null($this->_xmlProvider)) {
95
- $this->setXmlProvider(new Varien_Http_Adapter_Curl());
96
- }
97
-
98
- $this->_client->setUri($url ? $url : 'http');
99
- $response = $this->_client->request(Zend_Http_Client::GET);
100
-
101
- return $response->getBody();
102
- }
103
-
104
- /**
105
- * Is this is the first time? (ie: no RSS items in DB)
106
- *
107
- * @return boolean
108
- */
109
- public function isFirstTime()
110
- {
111
- return Mage::getModel('bronto_news/item')->getCollection()->count() === 0;
112
- }
113
-
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)
124
- {
125
- // We want to report on XML parsing errors
126
- $previousValue = libxml_use_internal_errors(true);
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
138
- $rssItem = Mage::getModel('bronto_news/item')->load($guid, 'link');
139
-
140
- // Silence the alert if this rss item already exists
141
- $rssItem
142
- ->setSilence($silence ? $silence : $rssItem->hasLink())
143
- ->setTitle((string)$item->title)
144
- ->setDescription(current(explode('--', $description)))
145
- ->setPubDate($date->date('Y-m-d H:m:s', $formattedDate))
146
- ->setLink($guid)
147
- ->setType($type)
148
- ->save();
149
-
150
- $this->writeDebug("Processed [$type] item: {$item->title}");
151
- }
152
- } catch (Exception $e) {
153
- $exception = new RuntimeException("Failed to pull RSS for $type announcements.");
154
- $this->writeError($e->getMessage());
155
- $this->writeError("Failed processing $url:\n{$e->getTraceAsString()}");
156
- }
157
-
158
- // Would be great in a finally block
159
- libxml_use_internal_errors($previousValue);
160
-
161
- if (isset($exception)) {
162
- throw $exception;
163
- }
164
- }
165
-
166
- /**
167
- * Pulls the RSS information, creating announcements as necessary
168
- */
169
- public function pullNewItems()
170
- {
171
- $urls = array(
172
- Bronto_News_Model_Item::TYPE_RELEASE => $this->getReleaseUrl(),
173
- Bronto_News_Model_Item::TYPE_GENERAL => $this->getGeneralUrl(),
174
- );
175
-
176
- if ($firstTime = $this->isFirstTime()) {
177
- try {
178
- Mage::getModel('bronto_news/item')
179
- ->setTitle('Thank you for installing the Bronto Extension for Magento. Please visit our resource center for full documentation and release notes.')
180
- ->setDescription('Please click on the Read Details link to be redirected to the resource center.')
181
- ->setLink('http://a.bron.to/magento')
182
- ->setType(Bronto_News_Model_Item::TYPE_OTHER)
183
- ->setPubDate(Mage::getModel('core/date')->date('Y-m-s H:m:s'))
184
- ->save();
185
- } catch (Exception $e) {
186
- $this->writeError('Could not create initial announcement');
187
- }
188
- }
189
-
190
- foreach ($urls as $type => $url) {
191
- $this->writeDebug("Processing $type RSS feed at $url");
192
- $this->_processItems($type, $url, $firstTime);
193
- }
194
- }
195
-
196
- /**
197
- * Wraps the internal notification URL with a controller route to
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)
205
- {
206
- return Mage::app()->getStore()
207
- ->getUrl('announcement/route/index', array('item' => $item->getId()));
208
- }
209
-
210
- /**
211
- * Creates an in-app Magento announcement
212
- *
213
- * @param Bronto_News_Model_Item $item
214
- */
215
- public function createAnnouncement(Bronto_News_Model_Item $item)
216
- {
217
- if ($item->isAlert()) {
218
- $notice = Mage::getModel('adminnotification/inbox')
219
- ->setSeverity(Mage_Adminnotification_Model_Inbox::SEVERITY_NOTICE)
220
- ->setTitle($item->getAlertTitle())
221
- ->setDescription($item->getDescription())
222
- ->setUrl($this->wrapNotificationUrl($item))
223
- ->save();
224
-
225
- $item
226
- ->setSilence(true)
227
- ->setNotificationId($notice->getId())
228
- ->save();
229
- }
230
- }
231
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Model/Item.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Model_Item extends Mage_Core_Model_Abstract
4
- {
5
-
6
- const TYPE_GENERAL = 'general';
7
- const TYPE_RELEASE = 'releases';
8
- const TYPE_OTHER = 'other';
9
-
10
- /**
11
- * @var Mage_Core_Helper_Abstract
12
- */
13
- protected $_helper;
14
-
15
- /**
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
-
29
- /**
30
- * Gets the helper used for this model
31
- *
32
- * @return Mage_Core_Helper_Abstract
33
- */
34
- protected function _getHelper()
35
- {
36
- if (is_null($this->_helper)) {
37
- $this->setHelper(Mage::helper('bronto_news'));
38
- }
39
-
40
- return $this->_helper;
41
- }
42
-
43
- /**
44
- * @see parent
45
- */
46
- public function _construct()
47
- {
48
- parent::_construct();
49
- $this->_init('bronto_news/item');
50
- }
51
-
52
- /**
53
- * @see parent
54
- */
55
- public function afterCommitCallback()
56
- {
57
- parent::afterCommitCallback();
58
- if (!$this->getSilence()) {
59
- $this->_getHelper()->createAnnouncement($this);
60
- }
61
-
62
- return $this;
63
- }
64
-
65
- /**
66
- * Is this RSS item an alert item
67
- *
68
- * @return boolean
69
- */
70
- public function isAlert()
71
- {
72
- return (
73
- $this->getType() != self::TYPE_GENERAL ||
74
- preg_match('/^\[?ALERT\]?/i', $this->getTitle())
75
- );
76
- }
77
-
78
- /**
79
- * Returns the "Magento Alert title" for the given notification
80
- *
81
- * @return string
82
- */
83
- public function getAlertTitle()
84
- {
85
- return "[Bronto Alert] {$this->getTitle()}";
86
- }
87
-
88
- /**
89
- * Marks all alerts as read
90
- *
91
- * @return Bronto_News_Model_Item
92
- */
93
- public function markAlertAsRead()
94
- {
95
- $notification = Mage::getModel('adminnotification/inbox')
96
- ->load($this->getNotificationId(), 'notification_id');
97
-
98
- if ($notification->hasNotificationId()) {
99
- $notification->setIsRead(1)->save();
100
- }
101
-
102
- return $this;
103
- }
104
-
105
- /**
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)
113
- {
114
- return $this
115
- ->getCollection()
116
- ->addFieldToFilter('type', $type)
117
- ->orderByMostRecent();
118
- }
119
-
120
- /**
121
- * Returns the most recent, limited release notes
122
- *
123
- * @return Mage_Core_Model_Resource_Db_Collection_Abstract
124
- */
125
- public function getLimitedReleaseNotes()
126
- {
127
- return $this
128
- ->getItemsOfType(self::TYPE_RELEASE)
129
- ->setPageSize($this->_getHelper()->getThreshold());
130
- }
131
-
132
- /**
133
- * Returns the most recent, limited general notes
134
- *
135
- * @return Mage_Core_Model_Resource_Db_Collection_Abstract
136
- */
137
- public function getLimitedGeneralNotes()
138
- {
139
- return $this
140
- ->getItemsOfType(self::TYPE_GENERAL)
141
- ->setPageSize($this->_getHelper()->getThreshold());
142
- }
143
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Model/Mysql4/Item.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Model_Mysql4_Item extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
-
6
- /**
7
- * @see parent
8
- */
9
- protected function _construct()
10
- {
11
- $this->_init('bronto_news/item', 'item_id');
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Model/Mysql4/Item/Collection.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Model_Mysql4_Item_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
-
6
- /**
7
- * @see parent
8
- */
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->_init('bronto_news/item');
13
- }
14
-
15
- /**
16
- * Orders the items by publication date
17
- *
18
- * @return Bronto_News_Model_Mysql4_Item_Collection
19
- */
20
- public function orderByMostRecent()
21
- {
22
- return $this->addOrder('pub_date');
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Model/Observer.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Model_Observer
4
- {
5
-
6
- /**
7
- * @var Mage_Core_Helper_Abstract
8
- */
9
- protected $_helper;
10
-
11
- /**
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
-
25
- /**
26
- * Gets the helper cached on this request
27
- *
28
- * @return Mage_Core_Helper_Abstract
29
- */
30
- protected function _getHelper()
31
- {
32
- if (is_null($this->_helper)) {
33
- $this->setHelper(Mage::helper('bronto_news'));
34
- }
35
-
36
- return $this->_helper;
37
- }
38
-
39
- /**
40
- * Forwards call to helper class
41
- */
42
- public function pullNewItems()
43
- {
44
- $helper = $this->_getHelper();
45
-
46
- if ($helper->validApiToken()) {
47
- try {
48
- $helper->pullNewItems();
49
- } catch (Exception $e) {
50
- $helper->writeError('Failed pulling items.');
51
- }
52
- }
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/Model/Resource/Setup.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
4
- {
5
-
6
- /**
7
- * Creates the initial items in the queue
8
- *
9
- * @return boolean
10
- */
11
- public function createInitialItems()
12
- {
13
- $helper = Mage::helper('bronto_news');
14
- if (!$helper->validApiToken()) {
15
- return false;
16
- }
17
-
18
- try {
19
- $helper->pullNewItems();
20
- } catch (Exception $e) {
21
- $helper->writeError('Failed to pull items on install.');
22
-
23
- return false;
24
- }
25
-
26
- return true;
27
- }
28
-
29
- /**
30
- * Load the initial config data for the module
31
- */
32
- public function loadInitialSettings()
33
- {
34
- Mage::getConfig()->reinit();
35
- Mage::app()->reinitStores();
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/controllers/Adminhtml/AnnouncementController.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_Adminhtml_AnnouncementController extends Mage_Adminhtml_Controller_Action
4
- {
5
-
6
- /**
7
- * @var Mage_Core_Helper_Abstract
8
- */
9
- protected $_helper;
10
-
11
- /**
12
- * @return Mage_Core_Helper_Abstract
13
- */
14
- protected function _getHelper()
15
- {
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 {
45
- $helper->pullNewItems();
46
- $session->addSuccess('Successfully refreshed Announcements & News.');
47
- } catch (Exception $e) {
48
- $helper->writeError($e->getMessage());
49
- $helper->writeError($e->getTraceAsString());
50
- $session->addError('Failed to refresh Announcements & News.');
51
- }
52
-
53
- $this->_redirectReferer();
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/controllers/RouteController.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
3
- class Bronto_News_RouteController extends Mage_Core_Controller_Front_Action
4
- {
5
-
6
- /**
7
- * Open announcement redirect by item id
8
- * Example: announcement/route/index/item/id
9
- */
10
- public function indexAction()
11
- {
12
- $id = $this->getRequest()->getParam('item', 0);
13
-
14
- if ($id) {
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
- }
22
-
23
- return $this->_redirectUrl('/');
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/etc/adminhtml.xml DELETED
@@ -1,23 +0,0 @@
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_news module="bronto_news">
12
- <title>Bronto News Section</title>
13
- <sort_order>9992</sort_order>
14
- </bronto_news>
15
- </children>
16
- </config>
17
- </children>
18
- </system>
19
- </children>
20
- </admin>
21
- </resources>
22
- </acl>
23
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/etc/config.xml DELETED
@@ -1,116 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Bronto_News>
5
- <version>1.0.0</version>
6
- </Bronto_News>
7
- </modules>
8
- <global>
9
- <blocks>
10
- <bronto_news>
11
- <class>Bronto_News_Block</class>
12
- </bronto_news>
13
- </blocks>
14
- <helpers>
15
- <bronto_news>
16
- <class>Bronto_News_Helper</class>
17
- </bronto_news>
18
- </helpers>
19
- <models>
20
- <bronto_news>
21
- <class>Bronto_News_Model</class>
22
- <resourceModel>bronto_news_mysql4</resourceModel>
23
- </bronto_news>
24
- <bronto_news_mysql4>
25
- <class>Bronto_News_Model_Mysql4</class>
26
- <entities>
27
- <item>
28
- <table>bronto_news_item</table>
29
- </item>
30
- </entities>
31
- </bronto_news_mysql4>
32
- </models>
33
- <resources>
34
- <bronto_news_setup>
35
- <setup>
36
- <module>Bronto_News</module>
37
- <class>Bronto_News_Model_Resource_Setup</class>
38
- </setup>
39
- <connection>
40
- <use>core_setup</use>
41
- </connection>
42
- </bronto_news_setup>
43
- </resources>
44
- </global>
45
- <frontend>
46
- <routers>
47
- <bronto_news>
48
- <use>standard</use>
49
- <args>
50
- <module>Bronto_News</module>
51
- <frontName>announcement</frontName>
52
- </args>
53
- </bronto_news>
54
- </routers>
55
- </frontend>
56
- <admin>
57
- <routers>
58
- <adminhtml>
59
- <args>
60
- <modules>
61
- <bronto_news before="Mage_Adminhtml">Bronto_News_Adminhtml</bronto_news>
62
- </modules>
63
- </args>
64
- </adminhtml>
65
- </routers>
66
- </admin>
67
- <adminhtml>
68
- <layout>
69
- <updates>
70
- <bronto_news>
71
- <file>bronto/news.xml</file>
72
- </bronto_news>
73
- </updates>
74
- </layout>
75
- <events>
76
- <bronto_token_model_save_after>
77
- <observers>
78
- <bronto_news_bronto_token_save>
79
- <class>bronto_news/observer</class>
80
- <method>pullNewItems</method>
81
- </bronto_news_bronto_token_save>
82
- </observers>
83
- </bronto_token_model_save_after>
84
- </events>
85
- </adminhtml>
86
- <crontab>
87
- <jobs>
88
- <bronto_news_pull_items>
89
- <!-- Run once a day -->
90
- <schedule>
91
- <cron_expr>0 0 * * *</cron_expr>
92
- </schedule>
93
- <run>
94
- <model>bronto_news/observer::pullNewItems</model>
95
- </run>
96
- </bronto_news_pull_items>
97
- </jobs>
98
- </crontab>
99
- <default>
100
- <bronto_news>
101
- <feeds>
102
- <releases>http://app.bronto.com/public/?q=feed&amp;id=5jodwr23wmaolrs5mpw6gq91zofp0&amp;fn=Link&amp;ssid=30245</releases>
103
- <general>http://app.bronto.com/public/?q=feed&amp;id=bimy41imold5nrca83kyqcuvbtru9&amp;fn=Link&amp;ssid=30245</general>
104
- <threshold>5</threshold>
105
- </feeds>
106
- </bronto_news>
107
- </default>
108
-
109
- <phpunit>
110
- <suite>
111
- <modules>
112
- <Bronto_News/>
113
- </modules>
114
- </suite>
115
- </phpunit>
116
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/etc/system.xml DELETED
@@ -1,45 +0,0 @@
1
- <?xml version="1.0"?>
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>
9
- <sort_order>150</sort_order>
10
- <show_in_default>1</show_in_default>
11
- <show_in_website>1</show_in_website>
12
- <show_in_store>1</show_in_store>
13
- <groups>
14
- <about>
15
- <frontend_type>text</frontend_type>
16
- <frontend_model>bronto_news/adminhtml_system_config_about</frontend_model>
17
- <sort_order>0</sort_order>
18
- <show_in_default>1</show_in_default>
19
- <show_in_website>1</show_in_website>
20
- <show_in_store>1</show_in_store>
21
- </about>
22
- <releases translate="label">
23
- <label>Release Announcements</label>
24
- <frontend_type>text</frontend_type>
25
- <frontend_model>bronto_news/adminhtml_system_config_releases</frontend_model>
26
- <sort_order>1</sort_order>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>1</show_in_website>
29
- <show_in_store>1</show_in_store>
30
- <expanded>1</expanded>
31
- </releases>
32
- <general translate="label">
33
- <label>General News</label>
34
- <frontend_type>text</frontend_type>
35
- <frontend_model>bronto_news/adminhtml_system_config_general</frontend_model>
36
- <sort_order>2</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
- <expanded>1</expanded>
41
- </general>
42
- </groups>
43
- </bronto_news>
44
- </sections>
45
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/News/sql/bronto_news_setup/mysql4-install-1.0.0.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
- /* @var $installer Bronto_News_Model_Resource_Setup */
5
-
6
- $installer->startSetup();
7
-
8
- try {
9
- $installer->run("
10
- CREATE TABLE `{$installer->getTable('bronto_news_item')}` (
11
- `item_id` int(10) unsigned NOT NULL auto_increment,
12
- `link` varchar(255) NOT NULL,
13
- `title` varchar(255) NOT NULL,
14
- `description` text NOT NULL,
15
- `pub_date` datetime NOT NULL,
16
- `type` varchar(20) NOT NULL,
17
- `notification_id` int(10) unsigned NULL,
18
- PRIMARY KEY (`item_id`),
19
- KEY `IDX_BRONTO_NEWS_ITEM_LINK` (`link`),
20
- KEY `IDX_BRONTO_NEWS_ITEM_TYPE` (`type`),
21
- KEY `IDX_BRONTO_NEWS_ITEM_TITLE` (`title`)
22
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
- ");
24
- } catch (Exception $e) {
25
- Mage::helper('bronto_news')->writeError($e->getMessage());
26
- Mage::helper('bronto_news')->writeError($e->getTraceAsString());
27
- }
28
-
29
- $installer->loadInitialSettings();
30
-
31
- $installer->createInitialItems();
32
-
33
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/About.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
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
- */
16
- protected $_module = 'bronto_newsletter';
17
-
18
- /**
19
- * Description for protected
20
- *
21
- * @var string
22
- * @access protected
23
- */
24
- protected $_name = 'Bronto Contact Newsletter Sign-Up for Magento';
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Cron.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
-
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
- {
9
- protected $_jobCode = 'bronto_newsletter_import';
10
- protected $_hasProgressBar = true;
11
-
12
- /**
13
- * @return Bronto_Order_Block_Adminhtml_System_Config_Cron
14
- */
15
- protected function _prepareLayout()
16
- {
17
- $this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_sync'));
18
- $this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_reset'));
19
- $this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_mark'));
20
- $this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_run'));
21
-
22
- return parent::_prepareLayout();
23
- }
24
-
25
- /**
26
- * @return int
27
- */
28
- protected function getProgressBarTotal()
29
- {
30
- return $this->getNewsletterResourceCollection()
31
- ->getSize();
32
- }
33
-
34
- /**
35
- * @return int
36
- */
37
- protected function getProgressBarPending()
38
- {
39
- return $this->getNewsletterResourceCollection()
40
- ->addBrontoNotImportedFilter()
41
- ->addBrontoNotSuppressedFilter()
42
- ->getSize();
43
- }
44
-
45
- /**
46
- * @return int
47
- */
48
- protected function getProgressBarSuppressed()
49
- {
50
- return $this->getNewsletterResourceCollection()
51
- ->addBrontoNotImportedFilter()
52
- ->addBrontoSuppressedFilter()
53
- ->getSize();
54
- }
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()
62
- {
63
- $collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
64
- $storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
65
-
66
- if ($storeIds) {
67
- if (!is_array($storeIds)) {
68
- $storeIds = array($storeIds);
69
- }
70
- foreach ($storeIds as $key => $storeId) {
71
- if (Mage::getStoreConfig(Bronto_Newsletter_Helper_Data::XML_PATH_ENABLED, $storeId)) {
72
- unset($storeIds[$key]);
73
- }
74
- }
75
-
76
- if (count($storeIds) > 0) {
77
- $collection->addStoreFilter($storeIds);
78
-
79
- return $collection->addBrontoNotImportedFilter()
80
- ->getSize();
81
- }
82
- }
83
-
84
- return 0;
85
- }
86
-
87
- /**
88
- * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
89
- */
90
- protected function getNewsletterResourceCollection()
91
- {
92
- $collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
93
- $storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
94
-
95
- if ($storeIds) {
96
- $collection->addStoreFilter($storeIds);
97
- }
98
-
99
- return $collection;
100
- }
101
-
102
- /**
103
- * Determine if should show the cron table
104
- *
105
- * @return mixed
106
- */
107
- public function showCronTable()
108
- {
109
- return Mage::helper('bronto_newsletter')->canUseMageCron();
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Suppressed.php DELETED
@@ -1,27 +0,0 @@
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
-
20
- /**
21
- * @see parent
22
- */
23
- public function getResetUrl()
24
- {
25
- return Mage::helper('bronto_common')->getScopeUrl('adminhtml/newsletter/reset');
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Mark.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Mark extends Mage_Adminhtml_Block_Widget_Button
4
- {
5
- /**
6
- * @see parent
7
- */
8
- protected function _construct()
9
- {
10
- $this->setLabel('Mark All Imported');
11
- $this->setOnClick("deleteConfirm('This will mark all subscribers as imported and will not send the information to Bronto.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/newsletter/mark') . "'); return false;");
12
- $this->setClass('bronto-cron-mark');
13
-
14
- if (!Mage::helper('bronto_newsletter')->isModuleActive() || (!Mage::helper('bronto_common')->isDebugEnabled())) {
15
- $this->setDisabled(true)->setClass('disabled');
16
- }
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Reset.php DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Internal constructor not depended on params. Can be used for object initialization
11
- */
12
- protected function _construct()
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())) {
19
- $this->setDisabled(true)->setClass('disabled');
20
- if (!Mage::helper('bronto_customer')->isDebugEnabled()) {
21
- $this->setTitle('Enable Debug in the General section to ' . $this->getLabel() . '.');
22
- }
23
- }
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Run.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Internal constructor not depended on params. Can be used for object initialization
11
- */
12
- protected function _construct()
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()) {
20
- $this->setDisabled(true)->setClass('disabled');
21
- }
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Sync.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
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
- {
9
- /**
10
- * Internal constructor not depended on params. Can be used for object initialization
11
- */
12
- protected function _construct()
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');
20
- }
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Block/Checkout/Onepage/Newsletter.php DELETED
@@ -1,222 +0,0 @@
1
- <?php
2
-
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
- */
16
- public function isSubscribed()
17
- {
18
- return Mage::helper('bronto_newsletter')->isCustomerSubscribed($this->getCustomer());
19
- }
20
-
21
- /**
22
- * @return bool
23
- */
24
- public function isEnabled()
25
- {
26
- return Mage::helper('bronto_newsletter')->isEnabled();
27
- }
28
-
29
- /**
30
- * @return string
31
- */
32
- public function getCssSelector()
33
- {
34
- return Mage::helper('bronto_newsletter')->getCssSelector();
35
- }
36
-
37
- /**
38
- * @return string
39
- */
40
- public function getCheckboxStyle()
41
- {
42
- return Mage::helper('bronto_newsletter')->getCheckboxStyle();
43
- }
44
-
45
- /**
46
- * @return bool
47
- */
48
- public function isEnabledCheckedByDefault()
49
- {
50
- return Mage::helper('bronto_newsletter')->isEnabledCheckedByDefault();
51
- }
52
-
53
- /**
54
- * @return bool
55
- */
56
- public function isEnabledForGuestCheckout()
57
- {
58
- return Mage::helper('bronto_newsletter')->isEnabledForGuestCheckout();
59
- }
60
-
61
- /**
62
- * @return bool
63
- */
64
- public function isEnabledForRegisterCheckout()
65
- {
66
- return Mage::helper('bronto_newsletter')->isEnabledForRegisterCheckout();
67
- }
68
-
69
- /**
70
- * @return bool
71
- */
72
- public function isEnabledForLoggedinCheckout()
73
- {
74
- return Mage::helper('bronto_newsletter')->isEnabledForLoggedinCheckout();
75
- }
76
-
77
- /**
78
- * This allows checkbox field to pre-load
79
- *
80
- * @return boolean
81
- */
82
- public function isEnabledForLoadingCheckout()
83
- {
84
- return true;
85
- }
86
-
87
- /**
88
- * @return bool
89
- */
90
- public function isEnabledIfAlreadySubscribed()
91
- {
92
- return Mage::helper('bronto_newsletter')->isEnabledIfAlreadySubscribed();
93
- }
94
-
95
- /**
96
- * Get Url for Ajax call
97
- *
98
- * @return string
99
- */
100
- public function getRequestUrl()
101
- {
102
- $store = Mage::app()->getStore();
103
- return Mage::getSingleton('core/url')->getUrl('btnewsletter/index/checkbox', array('_secure' => $store->isCurrentlySecure()));
104
- }
105
-
106
- /**
107
- * Get Url for Updating Subscription Status
108
- *
109
- * @return string
110
- */
111
- public function getSubscribeUrl()
112
- {
113
- $store = Mage::app()->getStore();
114
- return Mage::getSingleton('core/url')->getUrl('btnewsletter/index/subscribe', array('_secure' => $store->isCurrentlySecure()));
115
- }
116
-
117
- /**
118
- * Set checkout mode
119
- *
120
- * @param string $mode 'guest', 'register', 'loggedin'
121
- *
122
- * @return Bronto_Newsletter_Block_Checkout_Onepage_Newsletter
123
- */
124
- public function setMode($mode)
125
- {
126
- if ($this->isCustomerLoggedIn()) {
127
- $mode = 'loggedin';
128
- } elseif (!in_array($mode, array('loggedin', 'guest', 'register'))) {
129
- $mode = 'loading';
130
- }
131
-
132
- $this->_mode = $mode;
133
-
134
- return $this;
135
- }
136
-
137
- /**
138
- * Get value of Checked parameter
139
- *
140
- * @param bool $asInt
141
- *
142
- * @return bool|int
143
- */
144
- public function getChecked($asInt = false)
145
- {
146
- if ($asInt) {
147
- return ($this->_checked) ? 1 : 0;
148
- }
149
-
150
- return $this->_checked;
151
- }
152
-
153
- /**
154
- * Get Checkbox Checked status
155
- *
156
- * @return string
157
- */
158
- public function getCheckboxChecked()
159
- {
160
- return ($this->_checked) ? ' checked="checked"' : '';
161
- }
162
-
163
- /**
164
- * Get Checkbox visibility
165
- *
166
- * @return string
167
- */
168
- public function getCheckboxShow()
169
- {
170
- return ($this->_show) ? '' : ' style="display:none;"';
171
- }
172
-
173
- /**
174
- * Get Checkbox Checked value
175
- *
176
- * @return string
177
- */
178
- public function getCheckboxValue()
179
- {
180
- return ($this->_checked) ? '1' : '0';
181
- }
182
-
183
- /**
184
- * Get the text to display for the checkbox label
185
- *
186
- * @return bool
187
- */
188
- public function getCheckboxLabelText()
189
- {
190
- return Mage::helper('bronto_newsletter')->getCheckboxLabelText();
191
- }
192
-
193
- /**
194
- * Calculate checkbox display settings
195
- */
196
- protected function _setCheckboxStatus()
197
- {
198
- // If customer subscribed, or checked by default is enabled, set checked
199
- if ($this->isSubscribed() || $this->isEnabledCheckedByDefault()) {
200
- $this->_checked = true;
201
-
202
- // Set Initial subscription status to active
203
- Mage::getSingleton('checkout/session')
204
- ->setIsSubscribed(Bronto_Api_Model_Contact::STATUS_ACTIVE);
205
- } else {
206
- // Set Initial subscription status to transactional
207
- Mage::getSingleton('checkout/session')
208
- ->setIsSubscribed(Bronto_Api_Model_Contact::STATUS_TRANSACTIONAL);
209
- }
210
-
211
- // If module enabled and checkbox enabled for checkout method, show it
212
- $methodName = 'isEnabledFor' . ucfirst($this->_mode) . 'Checkout';
213
- if (!$this->isEnabled() || (!method_exists($this, $methodName) || !$this->$methodName())) {
214
- $this->_show = false;
215
- }
216
-
217
- // If customer subscribed, but checkbox not enabled if subscribed, hide
218
- if ($this->isSubscribed() && !$this->isEnabledIfAlreadySubscribed()) {
219
- $this->_show = false;
220
- }
221
- }
222
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Helper/Contact.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @package Newsletter
5
- * @copyright 2011-2012 Bronto Software, Inc.
6
- */
7
- class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
8
- {
9
-
10
- /**
11
- * Description for const
12
- */
13
- const XML_PATH_UPDATE_STATUS = 'bronto_newsletter/contacts/update_status';
14
- const XML_PATH_UPDATE_UNSUB = 'bronto_newsletter/contacts/update_unsub';
15
-
16
- /**
17
- * Description for const
18
- */
19
- const XML_PATH_LISTS = 'bronto_newsletter/contacts/lists';
20
-
21
- /**
22
- * @param string $scope
23
- * @param mixed $scopeId
24
- * @return bool
25
- */
26
- public function getUpdateStatus($scope = 'default', $scopeId = 0)
27
- {
28
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_UPDATE_STATUS, $scope, $scopeId);
29
- }
30
-
31
- /**
32
- * @param string $scope
33
- * @param mixed $scopeId
34
- * @return bool
35
- */
36
- public function isRemoveUnsubs($scope = 'default', $scopeId = 0)
37
- {
38
- return (bool) $this->getAdminScopedConfig(self::XML_PATH_UPDATE_UNSUB, $scope, $scopeId);
39
- }
40
-
41
- /**
42
- * Get Array of Bronto Subscriber List IDs
43
- *
44
- * @param string $scope
45
- * @param mixed $scopeId
46
- * @return array|mixed
47
- */
48
- public function getListIds($scope = 'default', $scopeId = 0)
49
- {
50
- $listIds = $this->getAdminScopedConfig(self::XML_PATH_LISTS, $scope, $scopeId);
51
- if (empty($listIds)) {
52
- return array();
53
- }
54
-
55
- if (!is_array($listIds)) {
56
- $listIds = explode(',', $listIds);
57
- }
58
-
59
- return $listIds;
60
- }
61
-
62
- /**
63
- * Get the list object from list id
64
- *
65
- * @param int $listId
66
- * @param string $scope
67
- * @param mixed $scopeId
68
- *
69
- * @return boolean|Bronto_Api_List_Row
70
- */
71
- public function getListData($listId, $scope = 'default', $scopeId = 0)
72
- {
73
- if ($api = $this->getApi(null, $scope, $scopeId)) {
74
- /* @var $listObject Bronto_Api_List */
75
- $listObject = $api->getListObject();
76
- try {
77
- foreach ($listObject->readAll(array('id' => $listId))->iterate() as $list/* @var $list Bronto_Api_List_Row */) {
78
- if ($list->id == $listId) {
79
- return $list;
80
- }
81
- }
82
- } catch (Exception $e) {
83
- Mage::helper('bronto_newsletter')->writeError('Failed to retrieve list: ' . $e->getMessage());
84
- }
85
- }
86
-
87
- return false;
88
- }
89
-
90
- /**
91
- * Supercedes the previous method
92
- *
93
- * @param string $scope
94
- * @param string $scopeId
95
- * @return array
96
- */
97
- public function getActualLists($scope = 'default', $scopeId = 0)
98
- {
99
- $listIds = $this->getListIds($scope, $scopeId);
100
- if (!empty($listIds) && $api = $this->getApi(null, $scope, $scopeId)) {
101
- $listObject = $api->transferMailList();
102
- try {
103
- return $listObject->read()->where->id->in($listIds)->getIterator()->toArray();
104
- } catch (Exception $e) {
105
- Mage::helper('bronto_newsletter')->writeError('Failed to retrieve lists: ' . $e->getMessage());
106
- }
107
- }
108
- return array();
109
- }
110
-
111
- /**
112
- * Retrieve helper module name
113
- *
114
- * @return string
115
- */
116
- protected function _getModuleName()
117
- {
118
- return 'Bronto_Newsletter';
119
- }
120
-
121
- /**
122
- * Convert Magento Newsletter Subscriber Status to Bronto API Contact Status
123
- *
124
- * @param Mage_Newsletter_Model_Subscriber $subscriber
125
- *
126
- * @return boolean
127
- */
128
- public function getQueueStatus(Mage_Newsletter_Model_Subscriber $subscriber)
129
- {
130
- // Set correct status based on subscriber status
131
- switch ($subscriber->getStatus()) {
132
- case Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED:
133
- $status = Bronto_Api_Model_Contact::STATUS_ACTIVE;
134
- break;
135
-
136
- case Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED:
137
- $status = Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED;
138
- break;
139
-
140
- case Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED:
141
- $status = Bronto_Api_Model_Contact::STATUS_UNCONFIRMED;
142
- break;
143
-
144
- case Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE:
145
- default:
146
- $status = Bronto_Api_Model_Contact::STATUS_TRANSACTIONAL;
147
- break;
148
- }
149
-
150
- return $status;
151
- }
152
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Helper/Data.php DELETED
@@ -1,257 +0,0 @@
1
- <?php
2
-
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_CHECKBOX_CSS = 'bronto_newsletter/checkout/css_selector';
20
- const XML_PATH_CHECKBOX_STYLE = 'bronto_newsletter/checkout/checkbox_style';
21
- const XML_PATH_INSTALL_DATE = 'bronto_newsletter/settings/install_date';
22
- const XML_PATH_UPGRADE_DATE = 'bronto_newsletter/settings/upgrade_date';
23
-
24
- const XML_PATH_CRON_STRING = 'crontab/jobs/bronto_newsletter_import/schedule/cron_expr';
25
- const XML_PATH_CRON_MODEL = 'crontab/jobs/bronto_newsletter_import/run/model';
26
-
27
- /**
28
- * Module Human Readable Name
29
- */
30
- protected $_name = 'Bronto Newsletter Opt-In';
31
-
32
- /**
33
- * Get Human Readable Name
34
- *
35
- * @return string
36
- */
37
- public function getName()
38
- {
39
- return $this->__($this->_name);
40
- }
41
-
42
- /**
43
- * Check if module is enabled
44
- *
45
- * @param string $scope
46
- * @param int $scopeId
47
- *
48
- * @return bool
49
- */
50
- public function isEnabled($scope = 'default', $scopeId = 0)
51
- {
52
- // Get Enabled Scope
53
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $scope, $scopeId);
54
- }
55
-
56
- /*
57
- * Get Text to display in notice when enabling module
58
- *
59
- * @return string
60
- */
61
- public function getModuleEnabledText()
62
- {
63
- $message = parent::getModuleEnabledText();
64
- $scopeData = $this->getScopeParams();
65
- if ($scopeData['scope'] != 'default') {
66
- $message = $this->__(
67
- 'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
68
- 'you should un-check the `Use Website` or `Use Default` for the <em>Add to List(s)</em> field in the <em>Contacts</em> ' .
69
- 'group on this page and select the desired list(s).'
70
- );
71
- }
72
-
73
- return $message;
74
- }
75
-
76
- /**
77
- * Disable Specified Module
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
- * Gets the CSS selector for the checkbox
92
- *
93
- * @param string $scope
94
- * @param int $scopeId
95
- * @return string
96
- */
97
- public function getCssSelector($scope = 'default', $scopeId = 0)
98
- {
99
- return $this->getAdminScopedConfig(self::XML_PATH_CHECKBOX_CSS, $scope, $scopeId);
100
- }
101
-
102
- /**
103
- * Gets the Checkbox styles
104
- *
105
- * @param string $scope
106
- * @param int $scopeId
107
- * @return string
108
- */
109
- public function getCheckboxStyle($scope = 'default', $scopeId = 0)
110
- {
111
- return $this->getAdminScopedConfig(self::XML_PATH_CHECKBOX_STYLE, $scope, $scopeId);
112
- }
113
-
114
- /**
115
- * @return int
116
- */
117
- public function getSyncLimit()
118
- {
119
- return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
120
- }
121
-
122
- /**
123
- * Get import limit from config
124
- *
125
- * @param string $scope
126
- * @param int $scopeId
127
- *
128
- * @return int
129
- */
130
- public function getLimit($scope = 'default', $scopeId = 0)
131
- {
132
- return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $scope, $scopeId);
133
- }
134
-
135
- /**
136
- * Check if module can use the magento cron
137
- *
138
- * @return bool
139
- */
140
- public function canUseMageCron()
141
- {
142
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_MAGE_CRON, 'default', 0);
143
- }
144
-
145
- /**
146
- * @return string
147
- */
148
- public function getCronStringPath()
149
- {
150
- return self::XML_PATH_CRON_STRING;
151
- }
152
-
153
- /**
154
- * @return string
155
- */
156
- public function getCronModelPath()
157
- {
158
- return self::XML_PATH_CRON_MODEL;
159
- }
160
-
161
- /**
162
- * @return bool
163
- */
164
- public function isEnabledCheckedByDefault()
165
- {
166
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_DEFAULT);
167
- }
168
-
169
- /**
170
- * @return bool
171
- */
172
- public function isEnabledForLoggedinCheckout()
173
- {
174
- return (bool)Mage::getStoreConfig(self::XML_PATH_SHOW_LOGGEDIN);
175
- }
176
-
177
- /**
178
- * @return bool
179
- */
180
- public function isEnabledForGuestCheckout()
181
- {
182
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_SHOW_GUEST);
183
- }
184
-
185
- /**
186
- * @return bool
187
- */
188
- public function isEnabledForRegisterCheckout()
189
- {
190
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_SHOW_REGISTRAR);
191
- }
192
-
193
- /**
194
- * @return bool
195
- */
196
- public function isEnabledIfAlreadySubscribed()
197
- {
198
- return (bool)$this->getAdminScopedConfig(self::XML_PATH_SHOW_SUBSCRIBED);
199
- }
200
-
201
- /**
202
- * @return string
203
- */
204
- public function getCheckboxLabelText()
205
- {
206
- return $this->getAdminScopedConfig(self::XML_PATH_LABEL_TEXT);
207
- }
208
-
209
- /**
210
- * @param Mage_Customer_Model_Customer $customer
211
- *
212
- * @return boolean
213
- */
214
- public function isCustomerSubscribed(Mage_Customer_Model_Customer $customer = null)
215
- {
216
- if (!$customer) {
217
- return false;
218
- }
219
-
220
- /* @var $subscriber Mage_Newsletter_Model_Subscriber */
221
- $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
222
-
223
- return (bool)$subscriber->isSubscribed();
224
- }
225
-
226
- /**
227
- * Retrieve helper module name
228
- *
229
- * @return string
230
- */
231
- protected function _getModuleName()
232
- {
233
- return 'Bronto_Newsletter';
234
- }
235
-
236
- /**
237
- * Get Count of Subscribers not in queue
238
- *
239
- * @return int
240
- */
241
- public function getMissingSubscribersCount()
242
- {
243
- return Mage::getModel('bronto_newsletter/queue')
244
- ->getMissingSubscribersCount();
245
- }
246
-
247
- /**
248
- * Get Subscribers which aren't in queue
249
- *
250
- * @return array
251
- */
252
- public function getMissingSubscribers()
253
- {
254
- return Mage::getModel('bronto_newsletter/queue')
255
- ->getMissingSubscribers();
256
- }
257
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Model/Mysql4/Queue.php DELETED
@@ -1,38 +0,0 @@
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
- {
9
- /**
10
- * Primary key auto increment flag
11
- *
12
- * @var bool
13
- */
14
- protected $_isPkAutoIncrement = false;
15
-
16
- /**
17
- * Short description for function
18
- *
19
- * Long description (if any) ...
20
- *
21
- * @return void
22
- * @access public
23
- */
24
- public function _construct()
25
- {
26
- $this->_init('bronto_newsletter/queue', 'queue_id');
27
- }
28
-
29
- /**
30
- * Get Write adapter instance
31
- *
32
- * @return Varien_Db_Adapter_Interface
33
- */
34
- public function getWriteAdapter()
35
- {
36
- return $this->_getWriteAdapter();
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Model/Mysql4/Queue/Collection.php DELETED
@@ -1,121 +0,0 @@
1
- <?php
2
-
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
9
- {
10
- /**
11
- * Short description for function
12
- *
13
- * Long description (if any) ...
14
- *
15
- * @return void
16
- * @access public
17
- */
18
- public function _construct()
19
- {
20
- parent::_construct();
21
- $this->_init('bronto_newsletter/queue');
22
- }
23
-
24
-
25
- /**
26
- * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
27
- */
28
- public function addBrontoImportedFilter()
29
- {
30
- $this->addFieldToFilter('imported', array('eq' => '1'));
31
-
32
- return $this;
33
- }
34
-
35
- /**
36
- * @return Bronto_Order_Model_Mysql4_Queue_Collection
37
- */
38
- public function addBrontoSuppressedFilter()
39
- {
40
- $this->addFieldToFilter('bronto_suppressed', array('notnull' => true));
41
-
42
- return $this;
43
- }
44
-
45
- /**
46
- * @return Bronto_Order_Model_Mysql4_Queue_Collection
47
- */
48
- public function addBrontoNotSuppressedFilter()
49
- {
50
- $this->addFieldToFilter('bronto_suppressed', array('null' => true));
51
-
52
- return $this;
53
- }
54
-
55
- /**
56
- * @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
57
- */
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)
71
- {
72
- $nullCheck = false;
73
-
74
- if (!is_array($storeIds)) {
75
- $storeIds = array($storeIds);
76
- }
77
-
78
- $storeIds = array_unique($storeIds);
79
-
80
- if ($index = array_search(null, $storeIds, true)) {
81
- unset($storeIds[$index]);
82
- $nullCheck = true;
83
- }
84
-
85
- if ($nullCheck) {
86
- $this->getSelect()->where('store IN(?) OR store IS NULL', $storeIds);
87
- } else {
88
- $this->getSelect()->where('store IN(?)', $storeIds);
89
- }
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 DELETED
@@ -1,431 +0,0 @@
1
- <?php
2
-
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
- /**
25
- * @param Varien_Event_Observer $observer
26
- *
27
- * @return mixed
28
- */
29
- public function checkBrontoRequirements(Varien_Event_Observer $observer)
30
- {
31
- if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
32
- return;
33
- }
34
-
35
- // Verify Requirements
36
- if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFIER, array('soap', 'openssl'))) {
37
- return;
38
- }
39
- }
40
-
41
- /**
42
- * Observes module becoming enabled and displays message warning user to configure settings
43
- * @param Varien_Event_Observer $observer
44
- */
45
- public function watchEnableAction(Varien_Event_Observer $observer)
46
- {
47
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_newsletter')->__(Mage::helper('bronto_newsletter')->getModuleEnabledText()));
48
- }
49
-
50
- /**
51
- * Get Bronto Contact Row via Email address
52
- *
53
- * @param string $email
54
- *
55
- * @return boolean|Bronto_Api_Contact_Row
56
- */
57
- protected function _getBrontoContact($email)
58
- {
59
- try {
60
- /* @var $contact Bronto_Api_Contact_Row */
61
- $contact = Mage::helper('bronto_newsletter/contact')->getContactByEmail(
62
- $email,
63
- null,
64
- Mage::app()->getStore()->getId()
65
- );
66
-
67
- return $contact;
68
- } catch (Exception $e) {
69
- $this->_helper->writeError($e);
70
-
71
- return false;
72
- }
73
- }
74
-
75
- /**
76
- * Observe checkout event and handle assigning status
77
- *
78
- * @param Varien_Event_Observer $observer
79
- *
80
- * @return boolean|Varien_Event_Observer
81
- */
82
- public function handleSubscriptionAtCheckout(Varien_Event_Observer $observer)
83
- {
84
- if (!$this->_helper->isEnabled()) {
85
- return false;
86
- }
87
-
88
- // Get Subscription status from session
89
- $isSubscribed = Mage::getSingleton('checkout/session')->getIsSubscribed();
90
- if (empty($isSubscribed)) {
91
- $this->_helper->writeDebug('No subscription status found in session.');
92
- return false;
93
- }
94
-
95
- try {
96
- // Get e-mail address we are working with
97
- $email = $observer->getEvent()->getOrder()->getData('customer_email');
98
- if (empty($email)) {
99
- $this->_helper->writeError('No customer email was provided.');
100
- return false;
101
- }
102
-
103
- /* @var $subscriber Mage_Newsletter_Model_Subscriber */
104
- $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
105
- // Determine action
106
- switch ($isSubscribed) {
107
- case Bronto_Api_Model_Contact::STATUS_ACTIVE:
108
- case Bronto_Api_Model_Contact::STATUS_ONBOARDING:
109
- if ($subscriber->getStatus() != Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
110
- $subscriber->subscribe($email);
111
- }
112
- break;
113
- case Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED:
114
- return $subscriber->unsubscribe();
115
- break;
116
- case Bronto_Api_Model_Contact::STATUS_TRANSACTIONAL:
117
- default:
118
- // No-op
119
- break;
120
- }
121
- } catch (Exception $e) {
122
- $this->_helper->writeError($e);
123
- }
124
-
125
- return $observer;
126
- }
127
-
128
- /**
129
- * Handle setting subscriber as transactional in bronto queue and
130
- * removing from magento subscription
131
- *
132
- * @param Mage_Newsletter_Model_Subscriber $subscriber
133
- * @param string $email
134
- *
135
- * @return boolean|Mage_Newsletter_Model_Subscriber
136
- */
137
- private function _makeTransactional(Mage_Newsletter_Model_Subscriber $subscriber, $email)
138
- {
139
- /* @var $contact Bronto_Api_Contact_Row */
140
- if (!$contact = $this->_getBrontoContact($email)) {
141
- $this->_helper->writeError('Unable to create contact object');
142
-
143
- return false;
144
- }
145
-
146
- // Get Customer using the email provided
147
- $customerId = Mage::getModel('customer/customer')
148
- ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
149
- ->loadByEmail($email)
150
- ->getId();
151
-
152
- if (!$customerId) {
153
- $customerId = Mage::getSingleton('customer/session')->getId();
154
- }
155
-
156
- // Set Magento Subscriber and Status
157
- $subscriber->setCustomerId($customerId)
158
- ->setSubscriberEmail($email)
159
- ->setStoreId(Mage::app()->getStore()->getId())
160
- ->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE)
161
- ->save();
162
-
163
- if ($contact->status == Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED) {
164
- $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
165
- } else {
166
- $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
167
- }
168
-
169
- $subscriber->save();
170
- return $subscriber;
171
- }
172
-
173
- /**
174
- * Update Bronto from Magento Subscriber Status
175
- *
176
- * @param Varien_Event_Observer $observer
177
- *
178
- * @return $this|bool
179
- */
180
- public function updateBrontoFromNewsletterStatus(Varien_Event_Observer $observer)
181
- {
182
- if (!$this->_helper->isEnabled()) {
183
- return false;
184
- }
185
-
186
- // Insert contact email into queuing table. Cron will
187
- // then issue an update to Bronto on its next run.
188
- try {
189
- /* @var $subscriber Mage_Newsletter_Model_Subscriber */
190
- if (!$subscriber = $observer->getEvent()->getSubscriber()) {
191
- $this->_helper->writeError('Unable to create subscriber object');
192
-
193
- return false;
194
- }
195
-
196
- // Send to queue
197
- $this->_saveToQueue($subscriber, $subscriber->getStoreId());
198
- } catch (Exception $e) {
199
- $this->_helper->writeError($e);
200
- }
201
-
202
- return $this;
203
- }
204
-
205
- /**
206
- * Add Subscriber to Bronto Newsletter Opt-in queue
207
- *
208
- * @param Mage_Newsletter_Model_Subscriber $subscriber
209
- * @param int $storeId
210
- *
211
- * @return $this|bool
212
- */
213
- private function _saveToQueue(Mage_Newsletter_Model_Subscriber $subscriber, $storeId)
214
- {
215
- // Get e-mail address we are working with
216
- $email = $subscriber->getEmail();
217
- if (empty($email)) {
218
- $this->_helper->writeError('Subscriber does not have an email address.');
219
-
220
- return false;
221
- }
222
-
223
- // Get Calculated Status
224
- $status = Mage::helper('bronto_newsletter/contact')->getQueueStatus($subscriber);
225
-
226
- /* @var $contactQueue Bronto_Newsletter_Model_Queue */
227
- $contactQueue = Mage::getModel('bronto_newsletter/queue')
228
- ->getContactRow($subscriber->getId(), $storeId);
229
-
230
- // If ContactQueue status doesn't match subscriber status, replace it
231
- if ($status != $contactQueue->getStatus()) {
232
- if ($subscriber->getSubscribeSource() == 'popup') {
233
- $contactQueue->setImported(2);
234
- } else {
235
- $contactQueue->setImported(0);
236
- }
237
- $contactQueue->setSubscriberEmail($subscriber->getEmail())
238
- ->setStatus($status)
239
- ->setMessagePreference('html')
240
- ->setSource('api')
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
- {
258
- // Define default results
259
- $result = array('total' => 0, 'success' => 0, 'error' => 0);
260
-
261
- // If limit is false or 0, return
262
- if (!$limit) {
263
- $this->_helper->writeDebug(' Limit empty. Skipping...');
264
-
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
- }
276
-
277
- $this->_helper->writeDebug("Starting Subscriber Opt-In process for store: {$store->getName()} ({$storeId})");
278
-
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');
286
-
287
- // Get Subscriber Queue for store
288
- /* var $subscribers Bronto_Newsletter_Model_Mysql4_Queue_Collection */
289
- $subscribers = Mage::getModel('bronto_newsletter/queue')
290
- ->getCollection()
291
- ->addBrontoNotImportedFilter()
292
- ->addBrontoNotSuppressedFilter()
293
- ->orderByUpdatedAt()
294
- ->addStoreFilter($storeId)
295
- ->setPageSize($limit)
296
- ->getItems();
297
-
298
- $contactOps = $helper->getApi(null, 'store', $storeId)->transferContact();
299
- $actualLists = $helper->getActualLists('store', $storeId);
300
- foreach ($subscribers as $subscriber) {
301
- try {
302
- /* @var $contact Bronto_Api_Model_Contact */
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
- // If Bronto Status is 'Bounced', mark suppressed, show error and continue foreach
313
- if ($contact->status == Bronto_Api_Model_Contact::STATUS_BOUNCE) {
314
- $bounceMessage = "Subscriber {$contact->email} Has Been Bounced in Bronto";
315
- $subscriber->setBrontoSuppressed($bounceMessage)->save();
316
- Mage::throwException($bounceMessage);
317
- }
318
-
319
- // Get List Details
320
- if ($subscriber->getStatus() == Bronto_Api_Model_Contact::STATUS_ACTIVE || ($helper->isRemoveUnsubs('store', $storeId) && $subscriber->getStatus() == Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED)) {
321
- foreach ($actualLists as $listId => $list) {
322
- if ($subscriber->getStatus() == Bronto_Api_Model_Contact::STATUS_ACTIVE) {
323
- $helper->writeInfo(" Adding Contact to list: {$list->getName()}");
324
- $contact->addList($listId);
325
- } else {
326
- $helper->writeInfo(" Removing Contact from list: {$list->getName()}");
327
- $contact->removeList($listId);
328
- }
329
- }
330
- }
331
-
332
- if ($helper->getUpdateStatus('store', $storeId)) {
333
- switch ($subscriber->getStatus()) {
334
- case Bronto_Api_Model_Contact::STATUS_UNCONFIRMED:
335
- case Bronto_Api_Model_Contact::STATUS_TRANSACTIONAL:
336
- if ($contact->id && $contact->status != Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED) {
337
- $helper->writeInfo(
338
- " Keeping Contact ({$contact->email}) status as: {$contact->status}"
339
- );
340
- break;
341
- }
342
- $contact->status = $subscriber->getStatus();
343
- $helper->writeInfo(" Setting Contact ({$contact->email}) status to: {$contact->status}");
344
- break;
345
-
346
- case Bronto_Api_Model_Contact::STATUS_ACTIVE:
347
- if ($contact->status == Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED &&
348
- $subscriber->getImported() == 2
349
- ) {
350
- $helper->writeInfo(
351
- " Keeping Contact ({$contact->email}) status as: {$contact->status}"
352
- );
353
- break;
354
- }
355
- $contact->status = $subscriber->getStatus();
356
- $helper->writeInfo(" Setting Contact ({$contact->email}) status to: {$contact->status}");
357
- break;
358
-
359
- default:
360
- $contact->status = $subscriber->getStatus();
361
- $helper->writeInfo(" Setting Contact ({$contact->email}) status to: {$contact->status}");
362
- break;
363
- }
364
- }
365
-
366
- // Don't add contacts to be unsubscribed
367
- if (!$contact->hasId() && $contact->getStatus() == Bronto_Api_Model_Contact::STATUS_UNSUBSCRIBED) {
368
- $subscriber->setImported(1)->save();
369
- $result['success']++;
370
- continue;
371
- }
372
- // Force an add or update on the individual contact
373
- $contactOps->save($contact, true);
374
- $subscriber->setImported(1)->save();
375
-
376
- $result['success']++;
377
- } catch (Exception $e) {
378
- // 303 = invalid email address
379
- // 315 = on suppression list
380
- // 317 = email over 100 characters in length
381
- if (in_array($e->getCode(), array(303, 305, 314, 315, 317))) {
382
- $subscriber->setBrontoSuppressed($e->getMessage());
383
- }
384
-
385
- $this->_helper->writeError($e);
386
-
387
- $subscriber->setImported(0)->save();
388
- $result['error']++;
389
- }
390
-
391
- $result['total']++;
392
- }
393
-
394
- return $result;
395
- }
396
-
397
- /**
398
- * Process queued subscribers
399
- *
400
- * @param bool $brontoCron
401
- *
402
- * @return array
403
- */
404
- public function processSubscribers($brontoCron = false)
405
- {
406
- $result = array(
407
- 'total' => 0,
408
- 'success' => 0,
409
- 'error' => 0,
410
- );
411
-
412
- // Only allow cron to run if isset to use mage cron or is coming from bronto cron
413
- if (Mage::helper('bronto_newsletter')->canUseMageCron() || $brontoCron) {
414
- $limit = $this->_helper->getLimit();
415
-
416
- $stores = Mage::app()->getStores(true);
417
- foreach ($stores as $_store) {
418
- if ($limit <= 0) {
419
- continue;
420
- }
421
- $storeResult = $this->processSubscribersForStore($_store, $limit);
422
- $result['total'] += $storeResult['total'];
423
- $result['success'] += $storeResult['success'];
424
- $result['error'] += $storeResult['error'];
425
- $limit = $limit - $storeResult['total'];
426
- }
427
- }
428
-
429
- return $result;
430
- }
431
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Bronto/Newsletter/Model/Queue.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
-
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
- {
9
-
10
- /**
11
- * Short description for function
12
- *
13
- * Long description (if any) ...
14
- *
15
- * @return void
16
- * @access public
17
- */
18
- public function _construct()
19
- {
20
- parent::_construct();
21
- $this->_init('bronto_newsletter/queue');
22
- }
23
-
24
- public function getContactRow($subscriber_id, $store_id)
25
- {
26
- $collection = $this->getCollection()
27
- ->addFieldToFilter('subscriber_id', $subscriber_id)
28
- ->addFieldToFilter('store', $store_id);
29
-
30
- if ($collection->count() == 1) {
31
- return $collection->getFirstItem();
32
- } else {
33
- $this->setSubscriberId($subscriber_id)
34
- ->setCreatedAt(Mage::getSingleton('core/date')->gmtDate())
35
- ->setStore($store_id);
36
- }
37
-
38
- return $this;
39
- }
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();
54
- $select->from(
55
- array('subscriber' => $resource->getTable('newsletter/subscriber')), array(new Zend_Db_Expr('COUNT(subscriber_id) as count'))
56
- )
57
- ->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter));
58
-
59
- // Get Results
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
- }
67
- }
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)
78
- {
79
- // Build Sub-Select Statement
80
- $subselect = $adapter->select()
81
- ->from(
82
- array('queue' => $resource->getTable('bronto_newsletter/queue')), array(new Zend_Db_Expr(1))
83
- )
84
- ->where('queue.subscriber_id = subscriber.subscriber_id');
85
-
86
- return $subselect;
87
- }
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();
102
-
103
- // Build Select Statement
104
- $select = $adapter->select();
105
- $select->from(
106
- array('subscriber' => $resource->getTable('newsletter/subscriber')),
107
- array('subscriber_id', 'store_id', 'subscriber_email', 'subscriber_status')
108
- )
109
- ->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter))
110
- ->limit($count);
111
-
112
- // Get Results
113
- $result = $adapter->query($select)->fetchAll();
114
-
115
-